-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbookings.php
More file actions
75 lines (68 loc) · 2.53 KB
/
Copy pathbookings.php
File metadata and controls
75 lines (68 loc) · 2.53 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
<?php
error_reporting(0);
session_start();
if (!isset($_SESSION['rollno'])) header('Location: login.php');
include_once('include/_header.php');
require_once('config/db.php');
if(isset($_GET['del']))
{
if(intval($_GET['del']))
{
// echo $_GET['del'];
$statement = $link->query("SELECT file FROM $tablename WHERE id = ".$_GET['del']);
$res = $statement->fetchAll(PDO::FETCH_ASSOC);
// print_r($res[0]['file']);
if(!empty($res) && $res !== 'none')
{
unlink($res[0]['file']);
$statement = $link->query("DELETE FROM $tablename WHERE id = ".$_GET['del']);
$link->execute();
header('location: bookings.php');
}
}
}
?>
<div class="container">
<legend class="text-center">Current bookings for <?php echo $_SESSION['rollno'] ?></legend>
<table class="table table-striped table-hover ">
<thead>
<tr class="info">
<th>#</th>
<th>Date</th>
<th>Timings</th>
<th>Reason</th>
<th>File</th>
<th>Approved?</th>
<th>Delete Request</th>
</tr>
</thead>
<tbody>
<?php
$statement = $link->query("SELECT * FROM $tablename WHERE lower(rollno) = lower('".$_SESSION['rollno']."')");
$bookings = $statement->fetchAll(PDO::FETCH_ASSOC);
if(empty($bookings))
{
echo "<div class=\"well well-lg\">Oops. You have no bookings. <a href=\"booknew.php\">Create a booking request</a></div>";
}
$apprStatus = array('-1' => 'Rejected', '0' => 'Pending review', '1' => 'Approved');
foreach($bookings as $id => $booking)
{
// print_r($booking);
echo "
<tr>
<td>".($id+1)."</td>
<td>".$booking['date']."</td>
<td>".$booking['fromTime']." - ".$booking['toTime']."</td>
<td>".$booking['reason']."</td>
<td><a href=\"".$booking['file']."\">Click here</a></td>
<td>".($apprStatus[$booking['approved']])."</td>
<td><a class=\"btn btn-danger\" href=\"bookings.php?del=".$booking['id']."\">Delete Request</a></td>
</tr>";
}
?>
</tbody>
</table>
</div>
<?php
include_once('include/_footer.php');
?>