Repository navigation
Expand file tree
/
Copy pathedit_order_menu.php
More file actions
166 lines (140 loc) · 7.26 KB
/
Copy pathedit_order_menu.php
File metadata and controls
166 lines (140 loc) · 7.26 KB
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
<?php
include_once 'connection/checkUser.php';
include_once 'parts/header.php';
include_once 'database/Order.php';
include_once 'database/Products.php';
include_once 'database/Inventory.php';
if($_SERVER['REQUEST_METHOD'] == 'POST') {
$order_id = substr($_POST['order_id'], 0, strpos($_POST['order_id'], ','));
header("Location: edit_order.php?order_id=".$order_id);
}
?>
<body>
<div id="wrapper">
<?php include_once 'parts/nav.php';?>
<!-- Page Content -->
<div id="page-wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Edit Order Menu</h1>
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<div class="panel panel-default">
<div class="panel-heading">
Choose Order
</div>
<div class="panel-body">
<div class="row">
<div class="col-lg-6">
<form role="form" method="POST" action=<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>>
<?php
$db = new Database();
$orders_headers = Order::getOpenOrdersHeader($db);
?>
<div class="form-group">
<i class="fa fa-info-circle"></i> <label>Order Id</label>
<select id="option_order" name="order_id" onchange="showDetails(<?php echo count($orders_headers);?>);" class="form-control" style="width:200px">
<?php foreach ($orders_headers as $index=>$order) {
if(strcmp($order['STATUS'], "Open") == 0) {
?>
<option value='<?php echo($order['ORDER_ID'].",".$index)?>'><?php echo($order['ORDER_ID'])?></option>
<?php } } ?>
</select>
<?php foreach ($orders_headers as $order_index=>$order) {
if(strcmp($order['STATUS'], "Open") == 0) {
$rows = Order::getOrderRows($order['ORDER_ID'], $db);
$total = Order::getTotal($order['ORDER_ID'], $db)[0]['TOTAL'];
?>
</br>
<?php if($order_index == 0) { ?>
<div id="summary_<?php echo $order_index ?>" class="row" style="display: block;">
<?php } else { ?>
<div id="summary_<?php echo $order_index ?>" class="row" style="display: none;">
<?php } ?>
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="text-center"><strong>Order Summary</strong></h3>
</div>
<div class="panel-body">
<div class="table-responsive">
<table class="table table-condensed">
<thead>
<tr>
<td><strong>Item Name</strong></td>
<td class="text-center"><strong>Item Price</strong></td>
<td class="text-center"><strong>Item Quantity</strong></td>
<td class="text-right"><strong>Total</strong></td>
</tr>
</thead>
<tbody>
<?php if($rows)
foreach ($rows as $index=>$row) {
$max_quantity = Inventory::getMaxQuantity($row['P_ID']);
?>
<tr>
<td>
<?php echo $row['DESCRIPTION']?>
</td>
<td id="price_<?php echo $index?>" class="text-center" >$<?php echo $row['PRICE']?></td>
<td class="text-center">
<span><?php echo $row['QUANTITY']?></span>
</td>
<td class="text-right">
<div>$<?php echo $row['TOTAL']?></div>
</td>
</tr>
<?php } ?>
<tr>
<td class="highrow"></td>
<td class="highrow"></td>
<td class="highrow text-center"><strong>Total</strong></td>
<td class="highrow text-right">
<div>$<?php echo $total?></div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<?php } }?>
<button type="submit" class="btn btn-success">Edit</button>
</div>
</form>
</div>
</div>
<!-- /.row (nested) -->
</div>
<!-- /.panel-body -->
</div>
</div>
<!-- /.container-fluid -->
</div>
<!-- /#page-wrapper -->
</div>
<!-- /#wrapper -->
<script>
function showDetails(total)
{
var x = document.getElementById("option_order").value;
var order_id = x.split(",")[0];
var index = x.split(",")[1];
for(var i = 0; i < total; i++)
{
if(i != index)
{
document.getElementById("summary_"+i).style.display='none';
}
}
document.getElementById("summary_"+index).style.display='block';
}
</script>
<?php include_once 'parts/bottom.php';?>
</body>
</html>