-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashboard-list-orders.php
65 lines (48 loc) · 1.96 KB
/
dashboard-list-orders.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
<?php
ob_start();
include 'inc/navbar.php';
if (!isset($_SESSION['is_admin'])) {
header('Location: signup.php');
exit;
}
$query = 'SELECT users.name, users.email, orders.id, orders.order_date, orders.title, orders.price, orders.quantity, orders.served FROM orders JOIN users ON orders.user = users.id';
$result = mysqli_query($conn, $query);
$orders = mysqli_fetch_all($result, MYSQLI_ASSOC);
ob_end_flush();
?>
<div class="dashboard-container">
<?php include 'inc/aside.php'; ?>
<div class="dashboard-list-order">
<h1>Orders</h1>
<div>
<table border="1" border-collapse>
<tr>
<th>ID</th>
<th>Title</th>
<th>Quantity</th>
<th>Order Date</th>
<th>Name</th>
<th>Email</th>
<th>Status</th>
</tr>
<?php foreach ($orders as $order) {
$checked = $order['served'] ? 'checked' : '';
?>
<tr>
<td><?php echo $order['id'] ?></td>
<td><?php echo $order['title'] ?></td>
<td><?php echo $order['quantity'] ?></td>
<td><?php echo $order['order_date'] ?></td>
<td><?php echo $order['name'] ?></td>
<td><?php echo $order['email'] ?></td>
<td>
<span id="span-<?php echo $order['id']; ?>"><?php echo $order['served'] ? 'Served' : 'Not served '; ?></span>
<input type="checkbox" <?php echo $checked ?> onchange="updateOrderStatus(event, <?php echo $order['id']; ?>)" id="checked-<?php echo $order['id'] ?>" />
</td>
</tr>
<?php
} ?>
</table>
</div>
</div>
<?php include 'inc/footer.php'; ?>