-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathorder.php
More file actions
172 lines (155 loc) · 5.87 KB
/
Copy pathorder.php
File metadata and controls
172 lines (155 loc) · 5.87 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
167
168
169
170
171
172
<?php
session_start();
?>
<link rel="stylesheet" href="css/bootstrap.min.css"/>
<link rel="stylesheet" href="css/neptune.css"/>
<head>
<script src="js/jquery-2.1.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").focus(function(){this.blur()});
$("button.open-close").click(function() {
if( $(this).text().trim() == "开启订餐" ) {
if(confirm("确认开启订餐?")) {
$("div#open-close").load("func-open-close.php");
$("div.content").load("order.php");
}
}
else if ( $(this).text().trim() == "关闭订餐" ){
if(confirm("确认关闭订餐并清空今日订单?")) {
$("div#open-close").load("func-open-close.php");
$("div.content").load("order.php");
}
}
});
});
</script>
<style>
td {
text-align: center;
}
</style>
</head>
<div class="menu_title">
<h1 style="text-align: center;color:red">统计</h1>
<hr/>
</div>
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8">
<div class="row">
<table class="table table-striped table-hover table-bordered">
<h3 style="text-align: center;color: black">按菜名统计</h3><hr/>
<tr>
<td><b>菜名</b></td>
<td><b>数量</b></td>
</tr>
<?php
include("conn.php");
foreach ($dbh->query("SELECT dishname, count(*) as count FROM order_with_info GROUP BY dish_id ORDER BY count DESC") as $row) {
echo '
<tr>
<td>'.$row['dishname'].'</td>
<td>'.$row['count'].'</td>
</tr>
';
}
?>
</table>
</div>
<div class="row">
<table class="table table-striped table-hover table-bordered">
<h3 style="text-align:center;color:black">按楼层统计</h3><hr/>
<tr>
<td><b>楼层</b></td>
<td><b>菜名</b></td>
<td><b>数量</b></td>
</tr>
<?php
$data = array();
foreach ($dbh->query("SELECT `roomNo`,`dishname`,count(*) as count FROM `order_with_info` group by roomno, dish_id order by roomno DESC, count DESC") as $row) {
if( !isset($data[$row['roomNo']]) ) {
$data[$row['roomNo']] = array();
array_push( $data[$row['roomNo']], $row['roomNo'] );
}
array_push( $data[$row['roomNo']], array($row['dishname'], $row['count']) );
}
foreach( $data as $room ) {
$roomNo = $room[0];
$dishCnt = count($room) - 1;
echo '<tr>
<td style="text-align:center" rowspan='.$dishCnt.'><b>'.$roomNo.'</b></td>
<td>'.$room[1][0].'</td>
<td>'.$room[1][1].'</td>
</tr>';
for($i = 2; $i <= $dishCnt; $i++) {
echo '<tr>
<td>'.$room[$i][0].'</td>
<td>'.$room[$i][1].'</td>
</tr>';
}
}
?>
</table>
</div>
<div class="row">
<table class="table table-striped table-hover table-bordered">
<h3 style="text-align: center;color:black">今日订餐详情</h3><hr/>
<tr>
<td><b>订餐时间</b></td>
<td><b>用户名</b></td>
<td><b>楼层</b></td>
<td><b>菜名</b></td>
</tr>
<?php
foreach ($dbh->query("SELECT * FROM `order_with_info` ORDER BY time DESC") as $row) {
echo '
<tr>
<td>'.$row['time'].'</td>
<td>'.$row['username'].'</td>
<td>'.$row['roomNo'].'</td>
<td>'.$row['dishname'].'</td>
</tr>
';
}
?>
</table>
</div>
<div class="row">
<table class="table table-striped table-hover table-bordered">
<h3 style="text-align: center;color:black">历史订餐详情</h3><hr/>
<tr>
<td><b>订餐时间</b></td>
<td><b>用户名</b></td>
<td><b>楼层</b></td>
<td><b>菜名</b></td>
</tr>
<?php
foreach ($dbh->query("SELECT * FROM `histort_order_with_info` ORDER BY time DESC") as $row) {
echo '
<tr>
<td>'.$row['time'].'</td>
<td>'.$row['username'].'</td>
<td>'.$row['roomNo'].'</td>
<td>'.$row['dishname'].'</td>
</tr>
';
}
?>
</table>
</div>
</div>
<div class="col-md-2"><button class="btn btn-primary open-close">
<?php
include("func-get-state.php");
// echo $state;
if( $state == 1 ){
echo "关闭订餐";
}
else {
echo "开启订餐";
}
?>
</button></div>
<div id="open-close"></div>
</div>