-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmenu.php
More file actions
353 lines (315 loc) · 13.2 KB
/
Copy pathmenu.php
File metadata and controls
353 lines (315 loc) · 13.2 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
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
<?php
session_start();
?>
<script src="js/jquery-2.1.4.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/jquery.ajaxfileupload.js"></script>
<script>
function show_cmt(dish_id) {
$.post("fetchComment.php", {dish_id: dish_id},
function (data, status) {
$("#" + dish_id).next(".collapse").find(".comment-content").html(data);
})
}
$(document).ready(function () {
var fname = null;
var interval;
function applyAjaxFileUpload(element) {
$(element).AjaxFileUpload({
action: "func-upload.php",
onChange: function(filename) {
var $span = $("<span />")
.attr("class", $(this).attr("id"))
.text("Uploading")
.insertAfter($(this));
$(this).remove();
interval = window.setInterval(function() {
var text = $span.text();
if (text.length < 13) {
$span.text(text + ".");
} else {
$span.text("Uploading");
}
}, 200);
},
onSubmit: function(filename) {
return true;
},
onComplete: function(filename, response) {
fname = response['name'];
window.clearInterval(interval);
var $span = $("span." + $(this).attr("id")).text(filename + " "),
$fileInput = $("<input />")
.attr({
type: "file",
name: $(this).attr("name"),
id: $(this).attr("id")
});
if (typeof(response.error) === "string") {
$span.replaceWith($fileInput);
applyAjaxFileUpload($fileInput);
alert(response.error);
return;
}
$("<a />")
.attr("href", "#")
.text("x")
.bind("click", function(e) {
$span.replaceWith($fileInput);
applyAjaxFileUpload($fileInput);
})
.appendTo($span);
}
});
}
applyAjaxFileUpload("#demo1");
$("button").focus(function(){this.blur()});
$(".menu_items").on("click", function () {
$(this).css("background-color", "#FFCC99").find("input[name='menu']").attr("checked", "checked");
$(this).find(".glyphicon-ok").removeClass("hide");
$(this).siblings(".menu_items").css("background-color", "#FFFFFF").find(".glyphicon-ok").addClass("hide");
$(this).siblings(".menu_items").find("input[name='menu']").removeAttr("checked");
}).on("mouseover", function () {
$(this).css({"cursor": "hand"});
}).on("mouseout", function () {
$(this).css({"cursor": "pointer"});
});
$(".collapse").hide();
$(".comment").click(function (e) {
e.stopPropagation();
if ($(this).parents(".menu_items").next('.collapse').css("display") == 'none') {
show_cmt($(this).parents(".menu_items").attr("id"));
}
$(this).parents(".menu_items").next('.collapse').delay(50).slideToggle();
});
$(".well").click(function (e) {
e.stopPropagation();
});
$(".order_submit").click(function() {
var dish_id = $("input:checked").parents(".menu_items").attr("id");
if( !dish_id ) {
alert("你还没有点餐噢噢噢噢~");
}
else {
$.post("func-order.php", {dish_id: dish_id},
function (data, status) {
if(data=="点餐成功") {
$.post("orderFinish.php", {dish_id: dish_id},
function (data, status) {
$(".content").html(data);
});
}
else {
alert(data);
}
});
}
});
$(".comment_submit").click(function () {
var dish_id = $(this).parents(".collapse").prev(".menu_items").attr("id");
var content = $(this).parents(".collapse").find("textarea").val();
if (!content) {
alert("评论不能为空哦~");
} else {
$.post("addcomment.php", {
dish_id: dish_id,
content: content
}, function (data, status) {
alert(data);
show_cmt(dish_id);
})
}
$(this).parents(".collapse").find("textarea").val("");
});
$(".add_submit").hide();
$(".delete_submit").hide();
var state = 1;
$(".manage_submit").click(function(){
var order=$(".order_submit");
var manage=$(this);
if(state){
manage.animate({height:'100px',width:'100px',fontSize:'20px'},function(){
manage.text("退出管理");
$(".add_submit").show();
$(".order_submit_disable").hide();
$(".delete_submit").show();
});
order.animate({opacity:'0.1'},function(){
order.hide();
})
}else{
manage.animate({height:'60px',width:'60px',fontSize:'14px'},function(){
manage.text("管理");
order.show();
order.animate({opacity:'1.0'});
$(".add_submit").hide();
$(".order_submit_disable").show();
$(".delete_submit").hide();
});
}
state=!state;
});
$(".add_submit").click(function(){
$("#addModal").modal("show");
});
$(".menu_submit").click(function(){
dishname = $("[name='dishname']").val();
desc = $("[name='description']").val();
if (dishname.length > 0 && desc.length > 0 && fname.length > 0) {
$.post("addmenu.php",{
dishname:dishname,
picture:fname,
desc:desc
},function(data,status){
window.location.reload();
});
}
else {
alert("输入为空");
}
// $.post("addmenu.php",{
// dishname:dishname,
// picture:picture,
// description:description
// },function(data,status){
// alert(data);
// alert(status)
// $(".content").load("menu.php");
// });
});
$(".close_popover").click(function(){
$("#addModal").modal("hide");
});
$(".delete_submit").click(function(){
var dish_id=$("input:checked").parents(".menu_items").attr("id");
if( !dish_id ) {
alert("你还没有选择噢噢噢噢~");
}
else {
if (confirm("确认删除?")) {
$.post("delmenu.php", {
dish_id: dish_id
}, function (data, status) {
$(".content").load("menu.php");
});
}
};
});
$(function(){
$("[data-toggle='tooltip']").tooltip();
})
});
</script>
<div class="menu_title">
<h1 style="text-align: center;color: #000033;">今日菜单</h1>
<hr/>
</div>
<div class="row">
<form>
<div class="col-md-2"></div>
<div class="col-md-8">
<?php
include("conn.php");
foreach ($dbh->query('SELECT menu.id,menu.dishname,menu.picture,menu.description,COUNT(today_order.user_id) as num FROM menu left join today_order on menu.id=today_order.dish_id where menu.flag=0 GROUP BY menu.id') as $tmp) {
?>
<div class="table-bordered menu_items" id="<?php echo $tmp[0] ?>">
<input class="sr-only" type="radio" name="menu" value="option"/>
<div class="row">
<div class="col-md-3">
<?php
if (!empty($tmp[2])) {
?>
<img src="<?php echo $tmp[2] ?>" class="food_pic"/>
<?php
} else {
?>
<img src="jpg\0.gif" class="food_pic"/>
<?php
}
?>
</div>
<div class="col-md-7">
<h4><?php echo $tmp[1] ?></h4><br/>
<p><?php echo $tmp[3] ?></p>
</div>
<div class="col-md-1">
<div class="badge" style="margin-top: 20px;"><?php echo $tmp[4] ?>人</div>
<button class="btn btn-primary comment" type="button">
<span class="glyphicon glyphicon-comment"></span>
</button>
</div>
<div class="col-md-1">
<span class="glyphicon glyphicon-ok hide" style="color:green;margin:10px;"></span>
</div>
</div>
</div>
<div class="collapse">
<div class="well show_comment">
<div class="row">
<div class="col-md-10">
<textarea name="content" rows="auto" cols="80" class="comment_form"></textarea>
</div>
<div class="col-md-2">
<button class="btn btn-primary comment_submit" type="button" style="margin-top: 5px;">提交</button>
</div>
</div>
<hr style="margin-top: 18px;" class="style-two"/>
<div class="comment-content">
</div>
</div>
</div>
<?php
}
$dbh = null;
?>
</div>
<div class="col-md-2">
<?php
include("func-get-state.php");
// echo $state;
if( $state == 1 ){
echo '<button class="btn btn-warning order_submit" type="button">点餐</button>';
}
else {
echo '<button class="btn btn-warning order_submit_disable" type="button" data-toggle="tooltip" data-placement="top" title="未到点餐时间">点餐</button>';
}
?>
<?php
if( isset($_SESSION['isAdmin']) && $_SESSION['isAdmin'] == 1) {
echo '
<button class="btn btn-info manage_submit" type="button" style="margin-top:100px">管理</button>
<button class="btn btn-success add_submit" type="button" style="margin-top:230px;margin-left:18px;">添加</button>
<button class="btn btn-danger delete_submit" type="button" style="margin-top:310px;margin-left:18px;">删除</button>
';
}
?>
</div>
</form>
</div>
<div class="modal fade" id="addModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">添加菜单</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label> 名称 </label>
<input class="form-control" type="text" name="dishname"/>
</div>
<div class="form-group">
<label> 图片 </label>
<input class="form-control" type="file" name="file" id="demo1"/></div>
<div class="form-group">
<label> 描述 </label>
<textarea class="form-control" name="description"></textarea>
</div>
<div class="form-group" style="text-align:center;margin-top:10px;">
<button class="btn btn-warning menu_submit" style="margin-right:15px;">提交</button>
<button class="btn btn-default close_popover">取消</button>
</div>
</div>
</div>
</div>
</div>