-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbookaccept.php
More file actions
91 lines (66 loc) · 2.4 KB
/
bookaccept.php
File metadata and controls
91 lines (66 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
include ('way2sms-api.php');
include ('email.php');
function bookaccept()
{
require 'DBconnect.php';
do
{
$sql="SELECT mainid,frontpoint,rearpoint FROM bookrequests WHERE frontpoint!=-1 and available_books!=0";
$result=mysqli_query($con,$sql);
if(!$result)
die('Could not get data: ' . mysqli_error($con));
$count=mysqli_num_rows($result);
while($row=mysqli_fetch_assoc($result))
{
$mainid=$row['mainid'];
$F=$row['frontpoint'];
$R=$row['rearpoint'];
$sql2="SELECT c".$F." FROM bookrequests WHERE mainid='$mainid'";
$result2=mysqli_query($con,$sql2);
if(!$result2)
die('Could not get data: ' . mysqli_error($con));
$row2=mysqli_fetch_assoc($result2);
$user=$row2["c"."$F"];
$sql2="SELECT name FROM books WHERE mainid='$mainid'";
$result2=mysqli_query($con,$sql2);
if(!$result2)
die('Could not get data: ' . mysqli_error($con));
$row2=mysqli_fetch_assoc($result2);
$bkname=$row2['name'];
$subject='Book Request accepted';
$message='Your request for the book "'.$bkname.'"('.$mainid.') is accepted...come to library before tommarrow';
if($F==$R)
{
$sql2="UPDATE bookrequests SET available_books=available_books-1,c".$F."='',frontpoint=-1,rearpoint=-1 WHERE mainid='$mainid'";
$result2=mysqli_query($con,$sql2);
if(!$result2)
die('Could not get data: ' . mysqli_error($con));
}
else
{
$sql2="UPDATE bookrequests SET available_books=available_books-1,c".$F."='',frontpoint=".(($F+1)%16)." WHERE mainid='$mainid'";
$result2=mysqli_query($con,$sql2);
if(!$result2)
die('Could not get data: ' . mysqli_error($con));
}
$sql3="SELECT email,mobno FROM staffandstudent WHERE ID='$user'";
$result3=mysqli_query($con,$sql3);
if(!$result3)
die('Could not get data: ' . mysqli_error($con));
$row3= mysqli_fetch_assoc($result3);
$to=$row3['email'];
$mobno=$row3['mobno'];
$sql3="INSERT INTO notification (userid,bookid,type) VALUES('$user','$mainid','accepted')";
$result3=mysqli_query($con,$sql3);
if(!$result3)
die('Could not get data: ' . mysqli_error($con));
sendemail("JuBinAyoob","JuB123",$to,$subject,$message);
echo "<br>message send to ".$mobno.' : ';
$res = sendWay2SMS("8129062800","JuB321",$mobno,$message);
if(is_array($res)) echo $res[0]['result'] ? 'true' : 'false';
else echo $res;
}
}while($count>0);
}
?>