-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadmin.php
395 lines (341 loc) · 13.3 KB
/
admin.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Home</title>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/modern-business.css" rel="stylesheet">
<!-- Custom Fonts -->
<link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<style type="text/CSS">
th,td{
padding:5px;
}
</style>
</head>
<body>
<body style=" background-image: url(img/backgr.jpg);">
<!-- Navigation -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation" style="background:#213e4a; font-family:impact; font-size:20px; ">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href=
" <?php
session_start();
if(isset($_SESSION['email']))
{
if($_SESSION['email'] == 'kiran' )
echo 'admin.php';
else
echo 'customer.php';
}
else
echo 'index.php';
?>"
style="background: linear-gradient(yellow,orangered);
font-family:abril fatface; font-size: 25px; color: #213e4a">
» Khwopa Futsal «</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Booking <b class="caret"></b></a>
<ul class="dropdown-menu">
<li>
<a href="#approved">Approved</a>
</li>
<li>
<a href="#pending">Pending</a>
</li>
</ul>
</li>
<li>
<a href="#manage">Manage Users</a>
</li>
<?php
if($_SESSION['admin'] == 1 )
echo '<li>
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-user"> admin <b class="caret"></b></a>
<ul class="dropdown-menu">
<li>
<a href="destroy.php"> Logout <span class="glyphicon glyphicon-log-out"></a>
</li>';
?>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
<?php
//ession_start();
if($_SESSION['admin'] == 1 )
{
$connect = mysqli_connect("localhost","root","") or die ("Unable to connect to MySQL Sever.");
require 'config.php';
if(isset($_POST['approve']))
{
$book_id = $_POST['bookingid'];
$approv = "update booking set confirm_key = 11 where id = '$book_id'";
$connect->query($approv);
/* for sending mail to the user after confirmation!
$t=time()+13500;
$time=date("Y:M:d @ H:i:s",$t);
$to = $_POST['email'];
$subject = "My subject";
$txt = "Hi $user, \ Your booking has been approved for the date and time mentioned below.
Thank You! Mail sent @ $time";
$headers = "From: [email protected]" . "\r\n" .
"CC: [email protected]";
mail($to,$subject,$txt,$headers);*/
}
if(isset($_POST['decline']))
{
$book_id = $_POST['bookingid'];
$declin = "delete from booking where id ='$book_id'";
$connect->query($declin);
}
if(isset($_POST['delete']))
{
$del_id = $_POST['del_id'];
$del = "delete from register where id ='$del_id'";
$connect->query($del);
}
//to show stats status
/*
$userData = "select * from users;";
$itemData = "select * from items where status = 'Y';";
$orderData = "select * from orders;";
$noOfBidItem = "select itemId from items where type = 'B' and status = 'Y';";
$noOfBids = "select itemId from items where type = 'B' and custId is not null and status = 'Y';";
$userData = $connect->query($userData);
$itemData = $connect->query($itemData);
$orderData = $connect->query($orderData);
$noOfBidItem = $connect->query($noOfBidItem);
$noOfBids = $connect->query($noOfBids);
$noOfUsers = mysqli_num_rows($userData);
$noOfItems = mysqli_num_rows($itemData);
$noOfOrder = mysqli_num_rows($orderData);
$noOfBidItem = mysqli_num_rows($noOfBidItem);
$noOfBids = mysqli_num_rows($noOfBids);
echo"
<div style = 'width : 70%; top : 10px; left : 10px;border:2px solid grey; margin: 50px; box-shadow: 10px 10px 5px #DCDCDC; '>
<table style ='padding: 5px;'>
<th>Stats</th>
<tr>
<td> Total no. of users </td>
<td> Total no. of items </td>
<td> Items on Bid </td>
<td> Items on Sale </td>
<td> Total no. of orders</td>
<td> Total no. of bids</td>
</tr>
<tr>
<td>".$noOfUsers."</td>
<td>".$noOfItems."</td>
<td>".$noOfBidItem."</td>
<td>".($noOfItems-$noOfBidItem)."</td>
<td>".$noOfOrder."</td>
<td>".$noOfBids."</td>
</tr>
</table>
</div>
";
*/
$reqPending = "select * from booking where confirm_key = 10;";
$res = $connect->query($reqPending);
$i=1;
//This div is for the booking requests that await approval from the admin
?>
<div style = "background-color: #eee;
overflow:auto;
border:2px solid grey;
margin: 50px;
box-shadow: 10px 10px 5px #DCDCDC;"
class="container">
<h3><a name="pending"> Pending requests:</h3></a>
<?php
while($row = $res->fetch_assoc())
{
$email=$row['email'];
$bookingid=$row['id'];
$deadLine=$row['timecheck']+86400;
if ($deadLine-time()<13500)
$connect->query("delete from booking where id= '$bookingid'");
$que = "select id,lname, gender, address from register where email = '$email'";
$sqlrun = $connect->query($que);
$user = $sqlrun->fetch_assoc();
echo "<br><div class = 'row' style = 'border:2px;'>
<div class='col-md-6'>
<form method = 'post' action = 'admin.php'>
<table border = '0'>
<u><tr><td> Booking ID </td><td>: <b>".$row['id']."</b></td></tr></u>
<tr><td> Booked By </td><td><b>: ".$row['user'].' '. $user['lname']."</b></tr>
<tr><td> Booked Date </td><td> : ".$row['bookday']."</td></tr>
<tr><td> User ID </td><td> : ".$user['id']."</td></tr>
<tr><td> Booked at </td><td> : ".date("Y/M/d (H:i:s)",$row['timecheck'])."</td></tr>
<tr><td> Shift </td><td> : ".$row['shift']."</td></tr>
<tr><td> Gender </td><td> : ".$user['gender']."</td></tr>
<tr><td> Address </td><td> : ".$user['address']."</td></tr>
<tr><td> Contact </td><td> : ".$row['contact']."</td></tr>
<tr><td> Email </td><td> : ".$row['email']."</td></tr>
<tr><td > Payment deadLine </td><td> :<b style='background-color:orange;'>".date("Y M d ( H:i:s )",$deadLine)."</b></td></tr>
<tr><td> Voucher no. </td><td> : ".$row['vno']."</td></tr>
</table><br>
<input type = 'hidden' name = 'email' value = ".$row['email'].">
<input type = 'hidden' name = 'bookingid' value = ".$row['id'].">
<input type = 'submit' class='button' name = 'approve' value = 'Approve'>
<input type = 'submit' name = 'decline' class='button' value = 'Decline'>
</form> </div>
<div class='col-md-6'>
<img src = ".$row['vimgloc']." height = '300' width = '450'>
</div>
</div><br><br>";
$i++;
}
$i--;
echo "<hr><h4> 
<b>Total number of booking requests = ".$i." </b>
</h4></div>";
$approved = "select * from booking where confirm_key = 11;";
$res = $connect->query($approved);
$i=1;
//This div is for the bookig requests that have been approved by the admin
?>
<div style = "background-color: #eee;
overflow:auto;
border:2px solid grey;
margin: 50px;
box-shadow: 10px 10px 5px #DCDCDC;"
class="container">
<h3><a name="approved">Approved requests: </a></h3>
<?php
while($row = $res->fetch_assoc())
{
$email=$row['email'];
$bookingid=$row['id'];
$que = "select id,lname, gender, address from register where email = '$email'";
$sqlrun = $connect->query($que);
$user = $sqlrun->fetch_assoc();
echo "<br><div class='row'>
<div class='col-md-6'>
<form method = 'post' action = 'admin.php'>
<table border = '0' >
<u><tr><td> Booking ID </td><td>: <b>".$row['id']."</b></td></tr></u>
<tr><td> Booked By </td><td> : ".$row['user'].' '. $user['lname']."</tr>
<tr><td> Booked Date </td><td> : ".$row['bookday']."</td></tr>
<tr><td> User ID </td><td> : ".$user['id']."</td></tr>
<tr><td> Booked at </td><td> : ".date("Y/M/d (H:i:s)",$row['timecheck'])."</td></tr>
<tr><td> Shift </td><td> : ".$row['shift']."</td></tr>
<tr><td> Gender </td><td> : ".$user['gender']."</td></tr>
<tr><td> Address </td><td> : ".$user['address']."</td></tr>
<tr><td> Contact </td><td> : ".$row['contact']."</td></tr>
<tr><td> Email </td><td> : ".$row['email']."</td></tr>
<tr><td> Voucher no. </td><td> : ".$row['vno']."</td></tr>
</table><br>
<input type = 'hidden' name = 'email' value = ".$row['email'].">
<input type = 'hidden' name = 'bookingid' value = ".$row['id'].">
<input type = 'submit' name = 'decline' class='button' value = 'Cancel Booking'>
</form> </div>
<div class='col-md-6'>
<img src = ".$row['vimgloc']." height = '300' width = '450'>
</div>
</div><br><br>";
$i++;
}
$i--;
echo "<hr><h4>  
<b>Total number of approved bookings = ".$i." </b></h4></div>";
}
else
{
echo "Admin not verified! Please login as Admin.";
}
$que="select * from register where email !='kiran';";
$run= $connect->query($que);
$count =mysqli_num_rows($run);
echo '
<div style = "background-color: #eee;
overflow:auto;
border:2px solid grey;
margin: 50px;
box-shadow: 10px 10px 5px #DCDCDC;"
class="container">
<a name="manage"><h3>Manage Users</a></h3><br><br>
<div class = "row">
<table align = "center" border="2" width="90%" >
<tr >
<th>User_id</th>
<th>First_name</th>
<th>Last_name</th>
<th>Gender</th>
<th>Address</thh>
<th>Email_id</th>
<th>Contact_no.</th>
</tr>
<form name="edit" action="admin.php" name="delete" method="POST">';
while($row = $run->fetch_assoc())
{
echo "
<tr >
<td>".$row['id']."</td>
<td>".$row['fname']."</td>
<td>".$row['lname']."</td>
<td>".$row['gender']."</td>
<td>".$row['address']."</td>
<td>".$row['email']."</td>
<td>".$row['contact']."</td>
</tr>";
}
echo '</table><br>
<button type="button" class="btn btn-info " data-toggle="modal" data-target="#myModal" style="background: skyblue; position:relative; left:6%; width:100px; color:#222;">Edit</button>
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog" >
<div class="modal-dialog" >
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header" style=" background-image: url(img/backgr.jpg); color:#eee;">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Enter the user_id to be deleted</h4>
</div>
<div class="modal-body" style=" background-image: url(img/backgr.jpg);">
<form name="delete" action="admin.php">
<input type= "text" name="del_id" value="">
<input type="submit" value="Delete" name="delete">
</form>
</div>
<div class="modal-footer" style=" background-image: url(img/backgr.jpg);">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<p><h4><b>  Total no. of users = '."$count".'</h4></b></p>
</div>
</div>';
$connect->close();
?>
<script src="js/jquery.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>