-
Notifications
You must be signed in to change notification settings - Fork 116
/
admin.php
322 lines (301 loc) · 15 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
<?php
ob_start();
session_start();
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/select/1.2.5/css/select.dataTables.min.css">
<link rel="stylesheet" href="css/main.css">
<?php
require 'lib/phpPasswordHashing/passwordLib.php';
require 'app/DB.php';
require 'app/Util.php';
require 'app/models/StatusEnum.php';
require 'app/models/RequirementEnum.php';
require 'app/dao/CustomerDAO.php';
require 'app/dao/BookingDetailDAO.php';
require 'app/models/Customer.php';
require 'app/models/Booking.php';
require 'app/models/Reservation.php';
require 'app/handlers/CustomerHandler.php';
require 'app/handlers/BookingDetailHandler.php';
$username = null;
$isSessionExists = $isAdmin = false;
$pendingReservation = $confirmedReservation = $totalCustomers = $totalReservations = null;
$allBookings = $cCommon = $allCustomer = null;
if (isset($_SESSION["username"]))
{
$username = $_SESSION["username"];
$isSessionExists = true;
$cHandler = new CustomerHandler();
$cHandler = $cHandler->getCustomerObj($_SESSION["accountEmail"]);
$cAdmin = new Customer();
$cAdmin->setEmail($cHandler->getEmail());
// display all reservations
$bdHandler = new BookingDetailHandler();
$allBookings = $bdHandler->getAllBookings();
$cCommon = new CustomerHandler();
$allCustomer = $cCommon->getAllCustomer();
// reservation stats
$pendingReservation = $bdHandler->getPending();
$confirmedReservation = $bdHandler->getConfirmed();
$totalCustomers = $cCommon->totalCustomersCount();
$totalReservations = count($bdHandler->getAllBookings());
}
if (isset($_SESSION["isAdmin"]) && isset($_SESSION["username"])) {
$isSessionExists = true;
$username = $_SESSION["username"];
$isAdmin = $_SESSION["isAdmin"];
}
?>
<title>Manage Booking</title>
</head>
<body>
<header>
<div class="bg-dark collapse" id="navbarHeader" style="">
<div class="container">
<div class="row">
<div class="col-sm-8 col-md-7 py-4">
<h4 class="text-white">About</h4>
<p class="text-muted">Add some information about hotel booking.</p>
</div>
<div class="col-sm-4 offset-md-1 py-4 text-right">
<!-- User full name or email if logged in -->
<?php if ($isSessionExists) { ?>
<h4 class="text-white"><?php echo $username; ?></h4>
<ul class="list-unstyled">
<li><a href="index.php" class="text-white">Home</a><i class="fas fa-home ml-2"></i></a></li>
<li><a href="#" id="sign-out-link" class="text-white">Sign out<i class="fas fa-sign-out-alt ml-2"></i></a></li>
</ul>
<?php } else { ?>
<h4>
<a class="text-white" href="sign-in.php">Sign in</a> <span class="text-white">or</span>
<a href="register.php" class="text-white">Register </a>
</h4>
<p class="text-muted">Log in so you can take advantage with our hotel room prices.</p>
<?php } ?>
</div>
</div>
</div>
</div>
<div class="navbar navbar-dark bg-dark box-shadow">
<div class="container d-flex justify-content-between">
<a href="#" class="navbar-brand d-flex align-items-center">
<i class="fas fa-h-square mr-2"></i>
<strong>Hotel Booking</strong>
</a>
<button class="navbar-toggler collapsed" type="button" data-toggle="collapse" data-target="#navbarHeader" aria-controls="navbarHeader" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</div>
</header>
<main role="main">
<?php if ($isSessionExists && $isAdmin) { ?>
<div class="container my-3">
<div class="row">
<div class="col-xl-3 col-sm-6 mb-3">
<div class="card text-white bg-primary o-hidden h-100">
<div class="card-body">
<div class="card-body-icon">
<i class="fas fa-address-book"></i>
</div>
<div class="mr-5"><?php echo $totalReservations; ?> Reservations</div>
</div>
<a class="card-footer text-white clearfix small z-1" href="#reservation">
<span class="float-left">View Details</span>
<span class="float-right"><i class="fa fa-angle-right"></i></span>
</a>
</div>
</div>
<div class="col-xl-3 col-sm-6 mb-3">
<div class="card text-white bg-warning o-hidden h-100">
<div class="card-body">
<div class="card-body-icon">
<i class="fas fa-users ml-2"></i>
</div>
<div class="mr-5"><?php echo $totalCustomers; ?> Customers</div>
</div>
<a class="card-footer text-white clearfix small z-1" href="#customers">
<span class="float-left">View Details</span>
<span class="float-right"><i class="fa fa-angle-right"></i></span>
</a>
</div>
</div>
<div class="col-xl-3 col-sm-6 mb-3">
<div class="card text-white bg-success o-hidden h-100">
<div class="card-body">
<div class="card-body-icon">
<i class="fas fa-check"></i>
</div>
<div class="mr-4"><?php echo $confirmedReservation; ?> Confirmed Reservations</div>
</div>
<div class="card-footer text-white clearfix small z-1"></div>
</div>
</div>
<div class="col-xl-3 col-sm-6 mb-3">
<div class="card text-white bg-danger o-hidden h-100">
<div class="card-body">
<div class="card-body-icon">
<i class="fa fa-fw fa-support"></i>
</div>
<div class="mr-5"><?php echo $pendingReservation; ?> Pending Reservations</div>
</div>
<div class="card-footer text-white clearfix small z-1"></div>
</div>
</div>
</div>
</div>
<div class="container" id="tableContainer">
<ul class="nav nav-tabs" id="adminTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="reservation-tab" data-toggle="tab" href="#reservation" role="tab"
aria-controls="reservation" aria-selected="true">Reservation</a>
</li>
<li class="nav-item">
<a class="nav-link" id="customers-tab" data-toggle="tab" href="#customers" role="tab"
aria-controls="customers" aria-selected="false">Customers</a>
</li>
</ul>
<div class="tab-content py-3" id="adminTabContent">
<div class="tab-pane fade show active" id="reservation" role="tabpanel" aria-labelledby="reservation-tab">
<table id="reservationDataTable" class="table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th scope="col">#</th>
<th class="text-hide p-0" data-bookId="12">12</th>
<th scope="col">Email</th>
<th scope="col">Start</th>
<th scope="col">End</th>
<th scope="col">Room type</th>
<th scope="col">Timestamp</th>
<th scope="col">Status</th>
<th scope="col">Notes</th>
</tr>
</thead>
<tbody>
<?php if (!empty($allBookings)) { ?>
<?php foreach ($allBookings as $k => $v) { ?>
<tr>
<th scope="row"><?php echo ($k + 1); ?></th>
<td class="text-hide p-0" data-id="<?php echo $v["id"]; ?>">
<?php echo $v["id"]; ?>
</td>
<?php $cid = $v["cid"]; ?>
<td><?php echo $cCommon->getCustomerObjByCid($cid)->getEmail(); ?></td>
<td><?php echo $v["start"]; ?></td>
<td><?php echo $v["end"]; ?></td>
<td><?php echo $v["type"]; ?></td>
<td><?php echo $v["timestamp"]; ?></td>
<td><?php echo $v["status"]; ?></td>
<td><?php echo $v["notes"]; ?></td>
</tr>
<?php } ?>
<?php } ?>
</tbody>
</table>
<div class="my-3">
<div class="row">
<div class="col-6">
<label class="text-secondary font-weight-bold">With selected:</label>
<button type="button" id="confirm-booking" class="btn btn-outline-success btn-sm">Confirm
</button>
<button type="button" id="cancel-booking" class="btn btn-outline-danger btn-sm">Cancel
</button>
</div>
<div class="col-6 text-right">
View:
<input type="radio" name="viewOption" value="confirmed"> Confirmed
<input type="radio" name="viewOption" value="pending"> Pending
<input type="radio" name="viewOption" value="all"> All
</div>
</div>
</div>
</div>
<div class="tab-pane fade" id="customers" role="tabpanel" aria-labelledby="customers-tab">
<table id="customerTable" class="table table-bordered">
<thead class="thead-dark">
<tr>
<th scope="col">#</th>
<th scope="col">Full name</th>
<th scope="col">Email</th>
<th scope="col">Phone</th>
</tr>
</thead>
<tbody>
<?php if (!empty($allCustomer)) { ?>
<?php foreach ($cCommon->getAllCustomer() as $key => $value) { ?>
<tr>
<td scope="row"><?php echo ($key + 1); ?></td>
<td><?php echo $value->getFullName(); ?></td>
<td><?php echo $value->getEmail(); ?></td>
<td><?php echo $value->getPhone(); ?></td>
</tr>
<?php } ?>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
<div class="modal fade" id="confirmModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Confirm selected reservation(s)</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>Are you sure you want to proceed with this action?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" id="confirmTrue">Yes</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">No</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="cancelModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Cancel selected reservation(s)</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>Are you sure you want to proceed with this action?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" id="cancelTrue">Yes</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">No</button>
</div>
</div>
</div>
</div>
<?php } ?>
</main>
<footer class="container">
<p>© Company 2017-2018</p>
</footer>
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.6.3.min.js" integrity="sha256-pvPw+upLPUjgMXY0G+8O0xUf+/Im1MZjXxxgOcBQBXU=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-+sLIOodYLS7CIrQpBjl+C7nPvqq+FbNUBDunl/OZv93DB7Ln/533i8e/mZXLi/P+" crossorigin="anonymous"></script>
<script defer src="https://use.fontawesome.com/releases/v5.0.10/js/all.js"
integrity="sha384-slN8GvtUJGnv6ca26v8EzVaR9DC58QEwsIk9q1QXdCU8Yu8ck/tL/5szYlBbqmS+"
crossorigin="anonymous"></script>
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/select/1.2.5/js/dataTables.select.min.js"></script>
<script src="js/form-submission.js"></script>
<script src="js/admin.js"></script>
</body>
</html>