-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbookingstatus.php
83 lines (71 loc) · 2.21 KB
/
bookingstatus.php
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
<?php
require "init.php";
if($_POST["key"]!="android")
{
echo "No Permission to access this page!";
exit();
}
$dat=$_POST["date"];
//echo "d:".$dat;
$stime=$_POST["time"];
//echo "s".$stime;
$hours=intval($_POST["hours"]);
$h=$hours*60*60;
$dat=date('Y-m-d',strtotime($dat));
//echo "date:$dat";
$stime=date('H:i:s',strtotime($stime));
//echo "startime:".$stime;
$etime=date('H:i:s',strtotime($stime)+$h);
//echo "endtime:".$etime;
$status=array();
$sql="select slotid,stime,etime from bookingslot where dat='$dat' and '$stime'>=stime and '$stime'<=etime;";
$result=mysqli_query($con,$sql);
if(!$result)
{
die("Error in connection " . mysqli_connect_error());
}
while($row=mysqli_fetch_array($result,MYSQLI_ASSOC))
{
$status['status'][]=array('slotid'=>$row['slotid'],
'stime'=>$row['stime'],
'etime'=>$row['etime']);
}
$sql="select slotid,stime,etime from bookingslot where dat='$dat' and '$etime'>=stime and '$etime'<=etime;";
$result=mysqli_query($con,$sql);
if(!$result)
{
die("Error in connection " . mysqli_connect_error());
}
while($row=mysqli_fetch_array($result,MYSQLI_ASSOC))
{
$status['status'][]=array('slotid'=>$row['slotid'],
'stime'=>$row['stime'],
'etime'=>$row['etime']);
}
$sql="select slotid,stime,etime from bookingslot where dat='$dat' and '$stime'>=stime and '$etime'<=etime;";
$result=mysqli_query($con,$sql);
if(!$result)
{
die("Error in connection " . mysqli_connect_error());
}
while($row=mysqli_fetch_array($result,MYSQLI_ASSOC))
{
$status['status'][]=array('slotid'=>$row['slotid'],
'stime'=>$row['stime'],
'etime'=>$row['etime']);
}
$sql="select slotid,stime,etime from bookingslot where dat='$dat' and stime>='$stime' and etime<='$etime';";
$result=mysqli_query($con,$sql);
if(!$result)
{
die("Error in connection " . mysqli_connect_error());
}
while($row=mysqli_fetch_array($result,MYSQLI_ASSOC))
{
$status['status'][]=array('slotid'=>$row['slotid'],
'stime'=>$row['stime'],
'etime'=>$row['etime']);
}
echo json_encode($status);
mysqli_close($con);
?>