-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorder_item.php
399 lines (384 loc) · 24.4 KB
/
order_item.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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
<?php
include "proses/connect.php";
$query = mysqli_query($conn, "SELECT *, SUM(harga*jumlah) AS harganya FROM tb_list_order
LEFT JOIN tb_order ON tb_order.id_order = tb_list_order.kode_order
LEFT JOIN tb_daftar_menu ON tb_daftar_menu.id = tb_list_order.menu
LEFT JOIN tb_bayar ON tb_bayar.id_bayar = tb_order.id_order
GROUP BY id_list_order
HAVING tb_list_order.kode_order = $_GET[order]");
$kode = $_GET['order'];
$meja = $_GET['meja'];
$pelanggan = $_GET['pelanggan'];
while ($record = mysqli_fetch_array($query)) {
$result[] = $record;
// $kode = $record['id_order'];
// $meja = $record['meja'];
// $pelanggan = $record['pelanggan'];
}
$select_menu = mysqli_query($conn, "SELECT id,nama_menu FROM tb_daftar_menu");
?>
<div class="col-lg-9 mt-2">
<div class="card">
<div class="card-header">
Halaman Order Item
</div>
<div class="card-body">
<a href="Order" class="btn btn-info mb-3"><i class="bi bi-arrow-left"></i></a>
<div class="row">
<div class="col-lg-3">
<div class="form-floating mb-3">
<input disabled type="text" class="form-control" id="kodeorder" value="<?php echo $kode ?>">
<label for="uploadFoto">Kode Order</label>
</div>
</div>
<div class="col-lg-2">
<div class="form-floating mb-3">
<input disabled type="text" class="form-control" id="meja" value="<?php echo $meja ?>">
<label for="uploadFoto">Meja</label>
</div>
</div>
<div class="col-lg-3">
<div class="form-floating mb-3">
<input disabled type="text" class="form-control" id="pelanggan" value="<?php echo $pelanggan ?>">
<label for="uploadFoto">Pelanggan</label>
</div>
</div>
</div>
<!-- Modal tambah Item baru -->
<div class="modal fade" id="tambahItem" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg modal-fullscreen-md-down">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="exampleModalLabel">Tambah Menu Makanan dan Minuman</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form form class="needs-validation" novalidate action="proses/proses_input_orderitem.php" method="post">
<input type="hidden" name="kode_order" value="<?php echo $kode ?>">
<input type="hidden" name="meja" value="<?php echo $meja ?>">
<input type="hidden" name="pelanggan" value="<?php echo $pelanggan ?>">
<div class="row">
<div class="col-lg-8">
<div class="form-floating mb-3">
<select class="form-select" name="menu" id="">
<option selected hidden value="">Pilih Menu</option>
<?php
foreach ($select_menu as $value) {
echo "<option value=$value[id]>$value[nama_menu]</option>";
}
?>
</select>
<label for="menu">Menu Makanan/Minuman</label>
<div class="invalid-feedback">
Pilih Menu.
</div>
</div>
</div>
<div class="col-lg-4">
<div class="form-floating mb-3">
<input type="number" class="form-control" id="floatingInput" placeholder="Jumlah Porsi" name="jumlah" required>
<label for="floatingInput">Jumlah Porsi</label>
<div class="invalid-feedback">
Masukkan Jumlah Porsi.
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="form-floating mb-3">
<input type="text" class="form-control" id="floatingInput" placeholder="Catatan" name="catatan">
<label for="floatingPassword">Catatan</label>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary" name="input_orderitem_validate" value="12345">Save changes</button>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- Akhir modal tambah Item baru -->
<?php
if (empty($result)) {
echo "Data menu makanan atau minuman tidak ada";
} else {
foreach ($result as $row) {
?>
<!-- Modal Edit-->
<div class="modal fade" id="ModalEdit<?php echo $row['id_list_order'] ?>" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg modal-fullscreen-md-down">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="exampleModalLabel">Tambah Menu Makanan dan Minuman</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form form class="needs-validation" novalidate action="proses/proses_edit_orderitem.php" method="post">
<input type="hidden" name="id" value="<?php echo $row['id_list_order'] ?>">
<input type="hidden" name="kode_order" value="<?php echo $kode ?>">
<input type="hidden" name="meja" value="<?php echo $meja ?>">
<input type="hidden" name="pelanggan" value="<?php echo $pelanggan ?>">
<div class="row">
<div class="col-lg-8">
<div class="form-floating mb-3">
<select class="form-select" name="menu" id="">
<option selected hidden value="">Pilih Menu</option>
<?php
foreach ($select_menu as $value) {
if ($row['menu'] == $value['id']) {
echo "<option selected value=$value[id]>$value[nama_menu]</option>";
} else {
echo "<option value=$value[id]>$value[nama_menu]</option>";
}
}
?>
</select>
<label for="menu">Menu Makanan/Minuman</label>
<div class="invalid-feedback">
Pilih Menu.
</div>
</div>
</div>
<div class="col-lg-4">
<div class="form-floating mb-3">
<input type="number" class="form-control" id="floatingInput" placeholder="Jumlah Porsi" name="jumlah" required value="<?php echo $row['jumlah'] ?>">
<label for="floatingInput">Jumlah Porsi</label>
<div class="invalid-feedback">
Masukkan Jumlah Porsi.
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="form-floating mb-3">
<input type="text" class="form-control" id="floatingInput" placeholder="Catatan" name="catatan" value="<?php echo $row['catatan'] ?>">
<label for="floatingPassword">Catatan</label>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary" name="edit_orderitem_validate" value="12345">Save changes</button>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- Akhir modal Edit-->
<!-- Modal Delete-->
<div class="modal fade" id="ModalDelete<?php echo $row['id_list_order'] ?>" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-md modal-fullscreen-md-down">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="exampleModalLabel">Delete Data User</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form form class="needs-validation" novalidate action="proses/proses_delete_orderitem.php" method="post">
<input type="hidden" value="<?php echo $row['id_list_order'] ?>" name="id">
<input type="hidden" name="kode_order" value="<?php echo $kode ?>">
<input type="hidden" name="meja" value="<?php echo $meja ?>">
<input type="hidden" name="pelanggan" value="<?php echo $pelanggan ?>">
<div class="col-lg-12">
Apakah anda ingin menghapus menu <b><?php echo $row['nama_menu'] ?></b>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-danger" name="delete_orderitem_validate" value="12345">Hapus</button>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- Akhir modal Delete-->
<?php
}
?>
<!-- Modal Bayar -->
<div class="modal fade" id="bayar" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg modal-fullscreen-md-down">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="exampleModalLabel">Pembayaran</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr class="text-nowrap">
<th scope="col">Menu</th>
<th scope="col">Harga</th>
<th scope="col">Qty</th>
<th scope="col">Status</th>
<th scope="col">Catatan</th>
<th scope="col">Total</th>
</tr>
</thead>
<tbody>
<?php
$total = 0;
foreach ($result as $row) {
?>
<tr>
<td>
<?php echo $row['nama_menu'] ?>
</td>
<td>
<?php echo number_format($row['harga'], 0, ',', '.') ?>
</td>
<td>
<?php echo $row['jumlah'] ?>
</td>
<td>
<?php echo $row['status'] ?>
</td>
<td>
<?php echo $row['catatan'] ?>
</td>
<td>
<?php echo number_format($row['harganya'], 0, ',', '.') ?>
</td>
</tr>
<?php
$total += $row['harganya'];
}
?>
<tr>
<td colspan="5" class="fw-bold">
Total Harga
</td>
<td class="fw-bold">
<?php echo number_format($total, 0, ',', '.') ?>
</td>
</tr>
</tbody>
</table>
</div>
<span class="text-danger fs-5 fw-semibold">Apakah Anda Yakin Ingin Melakukan Pembayaran?</span>
<form form class="needs-validation" novalidate action="proses/proses_bayar.php" method="post">
<input type="hidden" name="kode_order" value="<?php echo $kode ?>">
<input type="hidden" name="meja" value="<?php echo $meja ?>">
<input type="hidden" name="pelanggan" value="<?php echo $pelanggan ?>">
<input type="hidden" name="total" value="<?php echo $total ?>">
<div class="row">
<div class="col-lg-12">
<div class="form-floating mb-3">
<input type="number" class="form-control" id="floatingInput" placeholder="Nominal Uang" name="uang" required>
<label for="floatingInput">Nominal Uang</label>
<div class="invalid-feedback">
Masukkan Nominal Uang.
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary" name="bayar_validate" value="12345">Bayar</button>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- Akhir modal Bayar -->
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr class="text-nowrap">
<th scope="col">Menu</th>
<th scope="col">Harga</th>
<th scope="col">Qty</th>
<th scope="col">Status</th>
<th scope="col">Catatan</th>
<th scope="col">Total</th>
<th scope="col">Aksi</th>
</tr>
</thead>
<tbody>
<?php
$total = 0;
foreach ($result as $row) {
?>
<tr>
<td>
<?php echo $row['nama_menu'] ?>
</td>
<td>
<?php echo number_format($row['harga'], 0, ',', '.') ?>
</td>
<td>
<?php echo $row['jumlah'] ?>
</td>
<td>
<?php
if($row['status'] == 1) {
echo "<span class='badge text-bg-warning'>Masuk ke Dapur</span>";
} else if ($row['status'] == 2) {
echo "<span class='badge text-bg-primary'>Siap Saji</span>";
}
?>
</td>
<td>
<?php echo $row['catatan'] ?>
</td>
<td>
<?php echo number_format($row['harganya'], 0, ',', '.') ?>
</td>
<td>
<div class="d-flex">
<button class="<?php echo(!empty($row['id_bayar'])) ? "btn btn-secondary btn-sm me-1 disabled" : "btn btn-warning btn-sm me-1" ; ?>" data-bs-toggle="modal" data-bs-target="#ModalEdit<?php echo $row['id_list_order'] ?>"><i class="bi bi-pencil-square"></i></i></button>
<button class="<?php echo(!empty($row['id_bayar'])) ? "btn btn-secondary btn-sm me-1 disabled" : "btn btn-danger btn-sm me-1" ; ?>" data-bs-toggle="modal" data-bs-target="#ModalDelete<?php echo $row['id_list_order'] ?>"><i class="bi bi-trash"></i></i></button>
</div>
</td>
</tr>
<?php
$total += $row['harganya'];
}
?>
<tr>
<td colspan="5" class="fw-bold">
Total Harga
</td>
<td class="fw-bold">
<?php echo number_format($total, 0, ',', '.') ?>
</td>
</tr>
</tbody>
</table>
</div>
<?php
}
?>
<div>
<button class="<?php echo(!empty($row['id_bayar'])) ? "btn btn-secondary disabled" : "btn btn-success" ; ?>" data-bs-toggle="modal" data-bs-target="#tambahItem"><i class="bi bi-plus-circle-fill"></i> Item</button>
<button class="<?php echo(!empty($row['id_bayar'])) ? "btn btn-secondary disabled" : "btn btn-primary" ; ?>" data-bs-toggle="modal" data-bs-target="#bayar"><i class="bi bi-cash-coin"></i> Bayar</button>
</div>
</div>
</div>
</div>
<script>
// Example starter JavaScript for disabling form submissions if there are invalid fields
(() => {
'use strict'
// Fetch all the forms we want to apply custom Bootstrap validation styles to
const forms = document.querySelectorAll('.needs-validation')
// Loop over them and prevent submission
Array.from(forms).forEach(form => {
form.addEventListener('submit', event => {
if (!form.checkValidity()) {
event.preventDefault()
event.stopPropagation()
}
form.classList.add('was-validated')
}, false)
})
})()
</script>