-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathvisitorpassresponse.php.bak
105 lines (86 loc) · 3.16 KB
/
visitorpassresponse.php.bak
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
$strQuery = "SELECT vi.id,vi.firstname,vi.tomeet,vi.comingfrom,vi.mobile,vi.emailid,vi.checkin,vi.checkout,vi.status FROM visitorinfo vi";
//Checking the condition for Date field
if( $_POST['DATE1'] != "DD/MM/YYYY" || $_POST['DATE2'] != "DD/MM/YYYY" )
{
$s_date = $_POST['DATE1'];
$s_time = ($_POST['starttime']=='')?'00':$_POST['starttime'];
$s_date = explode('/',$s_date);
$str_sdate = $s_date[2]."-".$s_date[1]."-".$s_date[0];
$e_date = $_POST['DATE2'];
$e_time = ($_POST['endtime']=='')?'23:59:59':($_POST['endtime']==24)?'23:59:59':$_POST['endtime'].':00:00';
$e_date = explode('/',$e_date);
$str_edate = $e_date[2]."-".$e_date[1]."-".$e_date[0];
if(($str_sdate != "YYYY-MM-DD"))
{
$str_sdate = $str_sdate . " $s_time:00:00";
$datesecond = strtotime($str_sdate);
$unixdate = $datesecond - 19800;
$unixdate = date("Y-m-d H:i:s",$unixdate);
$strQuery .= " where vi.checkin>= '".$unixdate."'";
}
if(($str_edate != "YYYY-MM-DD"))
{
$str_edate = $str_edate . " $e_time";
$datesecond = strtotime($str_edate);
$unixdate = $datesecond - 19800;
$unixdate = date("Y-m-d H:i:s",$unixdate);
$strQuery .= " and vi.checkin<='".$unixdate."'" ;
}
}
function show_table()
{
GLOBAL $strQuery_save_file,$strCountry,$company,$tid,$s_date,$requesttype,$saveFileURL;
if(isset($_REQUEST['saveas']))
{
echo "
<table>
<tr>
<td>
<form method='POST' action='$saveFileURL' name = 'schedule_info'>
<b>Enter File Name </b><input type = 'text' name='filename'>
<!--<input type='hidden' value=\"$strCountry\" name ='strCountry'>-->
<input type='hidden' value=\"$strQuery_save_file\" name ='strQuery'>
<input type='hidden' value=\"$tid\" name ='tid'>
<input type='hidden' value=\"$s_date[2]\" name ='s_date'>
<input type='hidden' value=\"$requesttype\" name ='rt'>
<input type='Submit' value='Save As'>
</form>
</td>
</tr>
</table>";
exit();
}
}
$count = 0;
$strResult = '';
$con = mysql_connect("localhost","test","sundar");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con);
// Execute query
$result = mysql_query($strQuery,$con);
while ($row = mysql_fetch_object($result)) {
$count++;
$visitorid = $row->id;
$firstname = $row->firstname;
$tomeet = $row->tomeet;
$comingfrom = $row->comingfrom;
$mobile = $row->mobile;
$email = $row->emailid;
$checkin = $row->checkin;
$checkout = $row->checkout;
if($row->status == 1)
$status = 'in';
else
$status = 'out';
$strResult .= "{sno:$count,visitorid:$visitorid,firstname:\"$firstname\",tomeet:\"$tomeet\",comingfrom:\"$comingfrom\",emailid:\"$email\",mobile:\"$mobile\",checkin:\"$checkin\",checkout:\"$checkout\",status:\"$status\"},";
}
$strResult = substr($strResult,0,strlen($strResult)-1);
echo '{"total":"'.$count.'","results":['.$strResult.']}';
mysql_free_result($result);
// some code
mysql_close($con);
?>