-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
215 lines (197 loc) · 11 KB
/
index.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
<?php
require_once './config.php';
//編寫查詢sql語句
$sql = 'SELECT * FROM `goods`';
//執行查詢操作、處理結果集
$result = mysqli_query($link, $sql);
if (!$result) {
exit('查詢sql語句執行失敗。錯誤信息:'.mysqli_error($link)); // 獲取錯誤信息
}
$data = mysqli_fetch_all($result, MYSQLI_ASSOC);
// echo '<pre>';
// var_dump($data); //array(2) { [0]=> array(4) { ["id"]=> string(1) "1" ["name"]=> string(12) "鴨頭小份" ["specification"]=> strin
// echo '</pre>';
?>
<!doctype html>
<html lang="en">
<head>
<title>結帳系統</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="./css/index.css">
</head>
<body>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.6.0.js"
integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous">
</script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous">
</script>
<div class="container-fluid">
<div class="d-flex">
<div class="col mr-3">
<div class="row">
<div class="col">
<div class="row justify-content-around m-3">
<div class="col-4 border text-center p-2 clearcache">清緩存用</div>
<div class="col-4 border text-center p-2">查看報表</div>
<!-- <div class="col-4 border text-center p-2 historyOrder"> <a href="history.php">歷史訂單</a></div> -->
<div class="col-4 border text-center p-2 historyOrder">歷史訂單</div>
</div>
<!-- <form action="create_order.php" method="post"> -->
<div>
<table class="table table-striped gooosTable text-center m-auto w-100">
<thead>
<tr>
<th class="p-2 border orderNumber">序號</th>
<th class="p-2 w-25 border">商品</th>
<th class="p-2 border">單價</th>
<th class="p-2 border">數量</th>
<th class="p-2 w-25 border">小記</th>
<th class="p-2 border deltd">刪除</th>
</tr>
</thead>
<tbody class="scrollLeft">
</tbody>
</table>
</div>
<div class="row justify-content-around m-3">
<div class="col-7 border text-center p-2 allmoney font-weight-bold">總金額$ :
<span>0</span>
</div>
<div class="col-3 text-center p-2 font-weight-bold bg-info text-white">
<div id="submit">訂單確認</div>
</div>
</div>
<!-- </form> -->
</div>
</div>
<div class="row">
<div class="col-10 m-auto border">
<div class="row ">
<div class="col border text-center p-2 fz-0 numberbtnNum">1</div>
<div class="col border text-center p-2 fz-0 numberbtnNum">2</div>
<div class="col border text-center p-2 fz-0 numberbtnNum">3</div>
</div>
<div class="row">
<div class="col border text-center p-2 fz-0 numberbtnNum">4</div>
<div class="col border text-center p-2 fz-0 numberbtnNum">5</div>
<div class="col border text-center p-2 fz-0 numberbtnNum">6</div>
</div>
<div class="row">
<div class="col border text-center p-2 fz-0 numberbtnNum">7</div>
<div class="col border text-center p-2 fz-0 numberbtnNum">8</div>
<div class="col border text-center p-2 fz-0 numberbtnNum">9</div>
</div>
<div class="row">
<div class="col border text-center p-2 fz-0 numberbtnNum">0</div>
<div class="col border text-center p-2 fz-0"></div>
<div class="col border text-center p-2 fz-0 countDel">DEL</div>
</div>
<div class="row">
<div class="col-4 border text-center p-2 fz-1 cancelAll">交易取消</div>
<div class="col-8 border text-center p-2 fz-1 confirm">確認</div>
</div>
</div>
</div>
</div>
<div class="col scorllRight h5">
<!-- 迴圈處 -->
<?php
$all_type = ['鴨肉類', '豬肉類', '飲料', '雞肉類', '其他類'];
$all_type_switch = ['duck', 'pork', 'drink', 'chicken', 'others'];
for ($i = 0; $i < count($all_type); ++$i) {
echo '<div>';
echo '<div class="h3 m-2 p-3 text-center bg-info text-white">';
echo $all_type[$i];
echo '</div>';
echo '<div class="rightGoods d-flex justify-content-start flex-wrap">';
for ($j = 0; $j < count($data); ++$j) {
if ($data[$j]['type'] == $all_type_switch[$i]) {
$k = $j + 1;
echo "<div class='goodsTitle border py-3 px-2 m-2 text-center' data-name='".$data[$j]['name']."' data-money='".$data[$j]['money']."' data-specification='".$data[$j]['specification']."' data-id='".$k."' >";
echo $data[$j]['name'].'</br>'.$data[$j]['money'].'元';
echo '</div>';
}
}
echo '</div>';
echo '</div>';
}
?>
</div>
</div>
</div>
<!-- 彈窗範例
<div class="modal historypage" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
<p>Modal body text goes here.</p>
</div>
</div>
</div>
</div> -->
<div class="container-fluid position-absolute historypage">
<div class="historyheader sticky-top">
<div class="modal-header">
<h4 class="modal-title font-weight-bold text-center">歷史訂單</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<table class="table table-hover table-striped text-center tablehead mb-0">
<!-- <thead> 加thead會跑版 原因不明所以關掉 -->
<tr class="historythead">
<td class="w-10">序號</th>
<td class="w-20">日期</td>
<td class="w-15">單號</td>
<td>商品</td>
<td class="w-10">項目單價</td>
<td class="w-10">數量</td>
<td>訂單總金額</td>
<td>刪除訂單</td>
</tr>
</table>
</div>
<div class="table-responsive">
<table class="table table-hover table-striped text-center">
<!-- </thead> -->
<tbody class="historytbody">
<?php
$sql_rocerds = 'SELECT * from order_goods join order_records on order_goods.order_id = order_records.order_id ORDER BY `order_records`.`time` DESC;';
// echo $sql_rocerds;
//執行查詢操作、處理結果集
$result = mysqli_query($link, $sql_rocerds);
if (!$result) {
exit('查詢sql語句執行失敗。錯誤信息:'.mysqli_error($link)); // 獲取錯誤信息
}
$dataHistory = mysqli_fetch_all($result, MYSQLI_ASSOC);
// var_dump($dataHistory);
for ($i = 0; $i < count($dataHistory); ++$i) {
echo '<tr>';
echo '<td class="w-10">'.$i.'</td>';
echo '<td class="w-20">'.$dataHistory[$i]['time'].'</td>';
echo '<td class="w-15">'.$dataHistory[$i]['order_id'].'</td>';
echo '<td>'.$dataHistory[$i]['name'].'</td>';
echo '<td <td class="w-10">'.$dataHistory[$i]['money'].'</td>';
echo '<td <td class="w-10">'.$dataHistory[$i]['amount'].'</td>';
echo '<td>'.$dataHistory[$i]['total'].'</td>';
echo '<td ><button type="button" class="btn btn-danger historyDel" data-order='.$dataHistory[$i]['order_id'].'>刪除</button></td>';
echo '</tr>';
}
?>
</tbody>
</table>
</div>
</div>
<script src="./js/index.js"></script>
</body>
</html>