forked from dtsai14/lunch-order
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
181 lines (165 loc) · 7.22 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
<?php
include_once './authenticate.php';
include_once './mysql.php';
?>
<!DOCTYPE html>
<html>
<head lang="en">
<title>Lunch Task Manager</title>
<?php include_once './sources.php';
?>
</head>
<body>
<div class="container">
<?php include "./header/header.php";
?>
<div id="voting-container">
<div id="orders-closed-alert"></div>
<span id="vote-alert"></span>
<h3>Which restaurant would you like the office to order from today?</h3>
<form id="voting-form" role="form">
<table id="voting" class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th style="width: 5%">Vote</th>
<th style="width: 20%">Restaurant Name</th>
<th>Current Votes</th>
</tr>
</thead>
<tbody id="vote-table">
</tbody>
</table>
<button id="send-vote" type="submit" class="btn btn-default">Vote</button>
<br><br>
</form>
</div>
<div id="ordering-container">
<!--<div class="alert alert-dismissable alert-info">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<strong>Voting has closed for today!</strong> Please vote again tomorrow :)
</div> -->
<div>
<h2>Today</h2>
<div id="restaurant-alerts"></div>
</div>
<br>
<h2>Place your order:</h2>
<form role="form" id="order-form">
<div class="form-group">
<label for="restaurant">Restaurant</label>
<select id="restaurant-dropdown" class="form-control" required>
</select>
</div>
<div class="form-group">
<label for="order">Order</label>
<textarea name="order" class="form-control" id="order" maxlength="1000" cols="20" rows="6"
required></textarea>
</div>
<button id="send-order" class="btn btn-primary">Submit</button>
</form>
<br><br>
<h2>Orders <span class="pull-right"><small><?= date('l, F d, Y') ?></small></span></h2>
<div id="order-list"></div>
</div>
</div>
<script id="vote-alert-template" type="text/x-handlebars-template">
{{#voteAlert}}
<div class='alert alert-{{type}} alert-dismissable'>
<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>
{{text}}
</div>
{{/voteAlert}}
</script>
<script id="vote-table-template" type="text/x-handlebars-template">
{{#restaurantVotes}}
<tr>
<td>
<div class='radio'>
<input type='radio' name='vote' id='{{id}}' value='{{id}}' required>
</div>
</td>
<td>
{{#if menu_url}}
<a href='{{menu_url}}' target='_blank'>{{name}}</a>
{{else}}
{{name}}
{{/if}}
</td>
<td>
<div>
<span class='badge pull-left'>{{num_votes}}</span>
<div class='progress progress-striped'>
<div class='progress-bar progress-bar-info' role='progressbar' aria-valuenow='{{num_votes}}' aria-valuemin='0' aria-valuemax='{{num_users}}' style='width:{{vote_bar}}%'></div>
</div>
</div>
</td>
</tr>
{{/restaurantVotes}}
</script>
<script id="restaurant-dropdown-template" type="text/x-handlebars-template">
{{#activeRestaurants}}
<option value="{{open_restaurant_id}}">{{name}}</option>
{{/activeRestaurants}}
</script>
<script id="restaurant-alerts-template" type="text/x-handlebars-template">
{{#activeRestaurants}}
<div class='alert alert-warning'>
<strong>{{username}}</strong> is currently taking orders for {{name}}.
{{#if menu_url}}
View menu <a href='{{menu_url}}' target='_blank' class='alert-link'>here</a>.
{{else}}
No menu has been uploaded; please see <strong>{{username}}</strong> for menu.
{{/if}}
</div>
{{/activeRestaurants}}
</script>
<script id="order-list-template" type="text/x-handlebars-template">
{{#orders}}
<div class='panel panel-default order-actions' data-auth-edit='{{auth_edit}}' data-auth-reject='{{auth_reject}}' data-rejection-id='{{rejection_id}}' id="{{order_id}}">
<div class='panel-heading'>
<button class='delete-order-button btn btn-danger btn-xs' data-order-id='{{order_id}}'>
<span class='glyphicon glyphicon-remove'></span>
</button>
<h3 style="display:inline" class='panel-title'>{{username}}'s order from {{restaurant_name}}
<span class='badge pull-right'>{{creation_time}}</span>
</h3>
</div>
<div class='panel-body order-panel'><span class="order-text">{{text}}</span>
<button class='reject-order-button btn btn-danger btn-xs pull-right' data-order-id='{{order_id}}'>Reject</button>
<button class='accept-order-button btn btn-info btn-xs pull-right' data-order-id='{{order_id}}'>Accept</button>
<button class='edit-order-button btn btn-primary btn-xs pull-right' data-order-id='{{order_id}}'>Edit Order</button>
</div>
<div class='panel-body edit-panel'>
<textarea class="form-control" rows="2">{{text}}</textarea>
<br>
<button class='save-changes-button btn btn-info btn-xs' data-order-id='{{order_id}}'>Save Changes</button>
<button class='cancel-changes-button btn btn-default btn-xs' data-order-id='{{order_id}}'>Cancel</button>
<br>
</div>
<div class='panel-footer reject-panel'>
<form role="form" class="reject-message-form" data-order-id='{{order_id}}'>
<div class="form-group">
<label for="reject-message">Reject {{username}}'s order:</label>
<textarea class="form-control reject-message" rows="2" placeholder="Please enter a message to the user." required></textarea>
</div>
<button type="submit" class='save-changes-button btn btn-info btn-xs' data-order-id='{{order_id}}'>Send</button>
<button class='cancel-reject-button btn btn-default btn-xs' data-order-id='{{order_id}}'>Cancel</button>
</form>
</div>
</div>
{{/orders}}
</script>
<script id="orders-closed-alert-template" type="text/x-handlebars-template">
<div class='alert alert-danger'>
Orders have already been taken and closed today for:
<ul>
{{#each closedRestaurants}}
<li>{{this}}</li>
{{/each}}
</ul>
Please check with your admin to see if orders will be opened again today.
</div>
</script>
<script src="./js/index.js"></script>
</body>
</html>