-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathorders.php
137 lines (120 loc) · 4.29 KB
/
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
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
<?php
session_start();
require_once __DIR__ . '/src/Order.php';
include('connection/connect.php');
include('navbar.php');
if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true) {
header("location: login.php");
exit;
}
elseif ($_SESSION["id"] !== 1) {
echo "<script>if(confirm('Only Restaurants can view the orders.')){document.location.href='menu.php'};</script>";
exit;
}
else {
$mremail = strval($_SESSION["email"]);
}
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="css/style.css">
<title>FoodShala | Orders</title>
</head>
<style>
.fixed_header th, .fixed_header td {
width: 260px;
}
.table-fixed tbody {
height: auto;
max-height: 600px;
overflow-y: auto;
width: 100%;
}
</style>
<body>
<!-- --><?php
//
// echo "<pre>";
// $orders = Order::getByRestaurant( $mremail );
// foreach ( $orders as $order ){
// $items = $order->items( $mremail );
// }
// exit;
//
//
// $result = $con->query("SELECT r_name FROM user_res WHERE r_email = '$mremail'");
// while($row = mysqli_fetch_array($result)) {
// $rname = $row['r_name'];
// }
// echo "<br><br><center><h1>Orders of ".$rname."</h1></center>";
// ?>
<div class="container">
<div id="boxtitle" style="color: white;">
<?php
$result = $con->query("SELECT r_name FROM user_res WHERE r_email = '$mremail'");
while($row = mysqli_fetch_array($result)) {
$rname = $row['r_name'];
}
echo "<center><h1>".$rname."'s Menu</h1></center>";
$orders = Order::getByRestaurant( $mremail );
?>
</div>
<table class="table table-hover table-fixed fixed_header bg-light mt-5">
<thead class="deep-orange white-text">
<th class="font-weight-bold">Order ID</th>
<th class="font-weight-bold">Customer</th>
<th class="font-weight-bold">Customer Number</th>
<th class="font-weight-bold">Address</th>
<th class="font-weight-bold">Total</th>
<th class="font-weight-bold">Order Time</th>
</thead>
<tbody>
<?php if (empty( $orders )): ?>
<tr>
<td colspan="4">No orders present.</td>
</tr>
<?php endif; ?>
<?php
foreach ( $orders as $index => $order ):
$customer = $order->customer();
$items = $order->items( $mremail );
?>
<tr>
<th class="text-left font-weight-bold" width="100">#<?php echo $order->number(); ?></th>
<th class="font-weight-bold" width="200"><?php echo $customer->name; ?></th>
<th class="font-weight-bold"><?php echo $customer->phone; ?></th>
<th class="text-left font-weight-bold"><?php echo $customer->address; ?></th>
<th class="text-right font-weight-bold" width="100"><?php echo number_format( $order->amount ); ?></th>
<th class="font-weight-bold"><?php echo $order->created_at->format('d M, Y | h:i a'); ?></th>
</tr>
<tr>
<td colspan="6" style="height: auto; padding: 2px 0;">
<hr class="my-0">
</td>
</tr>
<?php foreach ($items as $item): ?>
<tr>
<td colspan="2"></td>
<td class="text-left"><?php echo $item->item_name; ?></td>
<td><?php echo $item->item_qty; ?></td>
<td class="text-right"><?php echo number_format( $item->item_total_cost ); ?></td>
<td></td>
</tr>
<?php endforeach; ?>
<?php if ( $index != count( $orders ) - 1 ): ?>
<tr>
<td colspan="6" style="height: auto; padding: 2px 0;">
<hr class="my-2" style="border-width: 5px">
</td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
</tbody>
</table>
</div>
<!-- For debugging only -->
<!-- <pre> --><?php //var_dump( Cart::instance()->all() ); ?> <!-- </pre> -->
</body>
</html>