-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
86 lines (69 loc) · 2.49 KB
/
index.php
File metadata and controls
86 lines (69 loc) · 2.49 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
<?php
//check is user is logged in
include "inc/session_check.php";
//Create page to list current booking details
$title = "Current Booking";
include "inc/config.php";
show_header_start();
show_header_end();
echo "<body>";
show_menu();
$db = db_connect();
echo "<center>";
echo "<table border=1 style=\"font-size: 9pt;\">\n";
echo "<tr>\n";
echo "<th><b>id</b></th>\n";
echo "<th><b>user</b></th>\n";
echo "<th><b>begin</b></th>\n";
echo "<th><b>end</b></th>\n";
echo "<th><b>servers</b></th>\n";
echo "<th><b>comment</b></th>\n";
echo "<th>edit</th>";
echo "<th>delete</th>";
echo "</tr>\n";
//Get current booking details from booking and booking_map table
$query=' SELECT
booking.id AS id, booking.user AS user, booking.begin AS begin, booking.end AS end,
GROUP_CONCAT(server.name ORDER BY server.name SEPARATOR \', \') AS servers,
booking.comment AS comment
FROM
booking
INNER JOIN booking_map ON booking.id = booking_map.booking_id
INNER JOIN server ON booking_map.server_id = server.id
WHERE
now() BETWEEN booking.begin AND booking.end AND booking.status=1
GROUP BY
booking.id';
$res = $db->query($query);
//retrive booking data and display it in table
while($row = $res->fetch()) {
echo "<tr>";
echo "<td width=\"35px;\">".$row['id']."</td>\n";
echo "<td width=\"110px;\">".$row['user']."</td>\n";
$bdt = $row['begin'];
$bdt = substr($bdt, 0, -3);
echo "<td width=\"120px;\">".$bdt."</td>\n";
$edt = $row['end'];
$edt = substr($edt, 0, -3);
echo "<td width=\"120px;\">".$edt."</td>\n";
echo "<td width=\"300px;\">".$row['servers']."</td>\n";
echo "<td width=\"500px;\">".$row['comment']."</td>\n";
$user = array();
$user = explode(",",$row['user']);
//if admin user or owner, allow to edit and delete
if ((in_array($_SESSION['user'], $user)) || ($_SESSION['user'] == 'mainadmin') || ($_SESSION['user'] == 'karelk'))
{
echo "<td width=\"40px;\"><a href=\"edit.php?id=".$row['id']."\">edit</a></td>\n";
echo "<td width=\"60px;\"><a href=\"delete.php?id=".$row['id']."\" onclick=\"return confirm('Are you sure you want to delete?')\">delete</a></td>\n";
}else
{
echo "<td width=\"40px;\"><font color=\"grey\">edit</font></td>\n";
echo "<td width=\"60px;\"><font color=\"grey\">delete</font></td>\n";
}
echo "</tr>";
}
echo "</table>";
echo "</center>";
echo "</body>";
show_footer();
?>