-
Notifications
You must be signed in to change notification settings - Fork 0
/
getorders.php
227 lines (184 loc) · 5.25 KB
/
getorders.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
<?php
require 'employee_core.php';
require 'database_connect.php';
if(loggedin() && isset($_GET['req']) && $_GET['req'] == '1')
{
?>
<tr>
<th>Order #</th>
<th>Username</th>
<th>Order Details</th>
<th>Total</th>
<th>Address</th>
<th>Contact</th>
<th>Status</th>
<th>Time</th>
<th>Change</th>
</tr>
<?php
$query = "SELECT orders.order_id, users.username, orders.order_list, orders.order_quantity, orders.order_total, orders.address, orders.contact, orders.status, orders.order_time FROM orders LEFT JOIN users ON orders.user_id = users.id WHERE orders.status != 4 AND orders.status != 6 ORDER BY orders.order_id DESC";
$query_run = mysqli_query($connect,$query);
while($row = mysqli_fetch_assoc($query_run))
{
$list = explode(" ", $row['order_list']);
$quantity = explode(" ", $row['order_quantity']);
$count = count($list);
$query = "SELECT item, cost FROM menu WHERE id=";
for($i=0; $i<$count; $i++)
{
$query = $query.$list[$i]." OR id=";
}
$query = $query."0";
$query_run2 = mysqli_query($connect,$query);
$details = "";
$q_count = 0;
while($row2 = mysqli_fetch_assoc($query_run2))
{
$details = $details.$row2['item']." x".$quantity[$q_count].", ";
$q_count++;
}
if($row['status']=='0')
{
$status = 'Order Received';
}
else if($row['status']=='1')
{
$status = 'Preparing';
}
else if($row['status']=='2')
{
$status = 'Awaiting Delivery';
}
else if($row['status']=='3')
{
$status = 'Out for Delivery';
}
else if($row['status']=='5')
{
$status = 'Cancelled';
}
?>
<form action="order_edit.php" method="POST" id="<?php echo $row['order_id']; ?>">
<input type="hidden" name="order_id" value="<?php echo $row['order_id']; ?>">
<input type="hidden" name="status" value="<?php echo ((int)$row['status'] + 1); ?>">
</form>
<tr>
<td><?php echo $row['order_id']; ?></td>
<td><i><?php echo $row['username']; ?></i></td>
<td><?php echo $details; ?></td>
<td><?php echo $row['order_total']; ?></td>
<td style="padding: 10px 0;"><?php echo nl2br("$row[address]"); ?></td>
<td><?php echo $row['contact']; ?></td>
<td><b><?php echo $status ?></b></td>
<td><?php echo $row['order_time']; ?></td>
<td>
<form action="order_edit.php" method="POST" id="<?php echo $row['order_id']; ?>">
<input type="hidden" name="order_id" value="<?php echo $row['order_id']; ?>">
<input type="hidden" name="status" value="<?php echo ((int)$row['status'] + 1); ?>">
<input class="sub-btn" type="submit" value="Next Status">
</form>
</td>
</tr>
<?php
}
}
else if(loggedin() && isset($_GET['req']) && $_GET['req'] == '2')
{
$query = "SELECT order_id FROM orders WHERE status != 4 AND status != 6 ORDER BY order_id";
$query_run = mysqli_query($connect,$query);
while($row = mysqli_fetch_assoc($query_run))
{
?><option value="<?php echo $row['order_id'] ?>"><?php echo $row['order_id']; ?></option><?php
}
}
else if(loggedin() && isset($_GET['req']) && $_GET['req'] == '3')
{
?>
<tr>
<th>Order #</th>
<th>Username</th>
<th>Order Details</th>
<th>Total</th>
<th>Address</th>
<th>Contact</th>
<th>Status</th>
<th>Time</th>
</tr>
<?php
$query = "SELECT orders.order_id, users.username, orders.order_list, orders.order_quantity, orders.order_total, orders.address, orders.contact, orders.status, orders.order_time FROM orders LEFT JOIN users ON orders.user_id = users.id WHERE 1 ORDER BY orders.order_id DESC";
$query_run = mysqli_query($connect,$query);
while($row = mysqli_fetch_assoc($query_run))
{
$list = explode(" ", $row['order_list']);
$quantity = explode(" ", $row['order_quantity']);
$count = count($list);
$query = "SELECT item, cost FROM menu WHERE id=";
for($i=0; $i<$count; $i++)
{
$query = $query.$list[$i]." OR id=";
}
$query = $query."0";
$query_run2 = mysqli_query($connect,$query);
$details = "";
$q_count = 0;
while($row2 = mysqli_fetch_assoc($query_run2))
{
$details = $details.$row2['item']." x".$quantity[$q_count].", ";
$q_count++;
}
if($row['status']=='0')
{
$status = 'Order Received';
}
else if($row['status']=='1')
{
$status = 'Preparing';
}
else if($row['status']=='2')
{
$status = 'Awaiting Delivery';
}
else if($row['status']=='3')
{
$status = 'Out for Delivery';
}
else if($row['status']=='4')
{
$status = 'Delivered';
}
else if($row['status']=='5')
{
$status = 'Cancelled';
}
else if($row['status']=='6')
{
$status = 'Cancelled (Acknowledged)';
}
?>
<tr>
<td><?php echo $row['order_id']; ?></td>
<td><i><?php echo $row['username']; ?></i></td>
<td><?php echo $details; ?></td>
<td><?php echo $row['order_total']; ?></td>
<td style="padding: 10px 0;"><?php echo nl2br("$row[address]"); ?></td>
<td><?php echo $row['contact']; ?></td>
<td><b><?php echo $status ?></b></td>
<td><?php echo $row['order_time']; ?></td>
</tr>
<?php
}
}
else if(loggedin() && isset($_GET['req']) && $_GET['req'] == '4')
{
$query = "SELECT order_id FROM orders WHERE 1 ORDER BY order_id";
$query_run = mysqli_query($connect,$query);
while($row = mysqli_fetch_assoc($query_run))
{
?><option value="<?php echo $row['order_id'] ?>"><?php echo $row['order_id']; ?></option><?php
}
}
else
{
http_response_code(404);
}
?>