This repository has been archived by the owner on Aug 2, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·335 lines (309 loc) · 13.1 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
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
<?
require_once 'database.php';
$active = database::getActive();
$discount = database::getDiscount() * 100;
$discount_sides = database::getDiscountSides();
$isLive = database::getLive();
$deadline = database::getDeadline();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>pizza-get</title>
<meta name="description" content="So you can order pizza at gaming!"/>
<meta name="viewport" content="width=1000, initial-scale=1.0, maximum-scale=1.0">
<!-- Loading Bootstrap -->
<link href="dist/css/vendor/bootstrap.min.css" rel="stylesheet">
<!-- Loading Flat UI -->
<link href="dist/css/flat-ui.css" rel="stylesheet">
<link href="docs/assets/css/demo.css" rel="stylesheet">
<link href="dist/css/pizza-get.css" rel="stylesheet">
<link rel="shortcut icon" href="img/favicon.ico">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements. All other JS at the end of file. -->
<!--[if lt IE 9]>
<script src="dist/js/vendor/html5shiv.js"></script>
<script src="dist/js/vendor/respond.min.js"></script>
<![endif]-->
</head>
<body onload="init()">
<? if ($isLive == 0 and $active == 1) { ?>
<footer>
<div class="container">
<p>TEST MODE</p>
</div>
</footer>
<? } ?>
<div class="container">
<div class="row demo-row">
<div class="col-xs-12">
<nav class="navbar navbar-inverse navbar-embossed" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse-01">
<span class="sr-only">Toggle navigation</span>
</button>
<a class="navbar-brand" href="index.php">pizza-get</a>
</div>
<div class="collapse navbar-collapse" id="navbar-collapse-01">
<ul class="nav navbar-nav navbar-left">
<li><a href="index.php">Order</a></li>
<li><a href="about.php">About</a></li>
<li><a href="https://www.dominos.co.uk/store" target="_blank">Dominos Menu</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</nav><!-- /navbar -->
</div>
</div> <!-- /row -->
<div class="demo-type-example">
<h3><?=($active == 1 ? "Order closes in <span id=\"countdown\"/>" : "Welcome to pizza-get")?></h3>
</div>
<? if ($active == 1) { ?>
<div class="login-form">
<form action="order.php" method="post" id="orderForm" onsubmit="return validateCrust()">
<div class="row">
<div class="alert alert-danger" id="size-error">
Whoops! You can't have those options with that size pizza :(
</div>
<div class="col-xs-6">
<div class="form-group" id="nameField">
<input type="text" class="form-control " placeholder="Enter your name" id="login-name" name="name" onfocus="resetName()"/>
<label class="login-field-icon fui-user" for="login-name"></label>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<select class="form-control select select-primary" data-toggle="select" name="pizza" id="pizzaSelect" onchange="processPizza(this)">
<? $result = database::getMenu();
foreach ($result as $row) {
echo '<option value="' . $row['id'] . '" >' . $row['pizza'] . ' (£' . number_format((float)$row['large']/$discount, 2, '.', '') . ')</option>';
} ?>
<option value="H">Half and Half (varies)</option>
<option value="B">Build your Own (varies)</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="form-group col-xs-4">
<select class="form-control select select-primary" data-toggle="select" name="size" id="sizeSelect" onchange="processCrust(this);">
<option value="1">Large</option>
<option value="2">Medium (-£<?=number_format((float)200/$discount, 2, '.', '')?>)</option>
<option value="3">Small (-£<?=number_format((float)400/$discount, 2, '.', '')?>)</option>
<option value="4">Personal (varies)</option>
</select>
</div>
<div class="form-group col-xs-4">
<select class="form-control select select-primary" data-toggle="select" name="crust" id="crustSelect">
<option value="a">Normal Crust</option>
<option value="b">Italian Crust</option>
<option value="c">Thin and Crispy Crust</option>
<option value="d">Stuffed Crust (+£<?=number_format((float)250/$discount, 2, '.', '')?>)</option>
<option value="e">Hotdog Stuffed Crust (+£<?=number_format((float)250/$discount, 2, '.', '')?>)</option>
<option value="g">Hotdog Stuffed Crust with Mustard (+£<?=number_format((float)250/$discount, 2, '.', '')?>)</option>
<option value="f">BBQ Stuffed Crust (+£<?=number_format((float)250/$discount, 2, '.', '')?>)</option>
</select>
</div>
<div class="form-group col-xs-4">
<a class="btn btn-primary btn-lg btn-block" href="#" onclick="processSides()" id="showSides">Show Sides</a>
</div>
</div> <!-- /row -->
<div class="form-group" id="sides">
<? $result = database::getSides();
$count = 0;
$total = 0;
foreach ($result as $row) {
if ($count == 0) {
echo "<div class=\"row\">";
}
echo "<div class=\"form-group col-xs-3\">";
echo "<label class=\"checkbox\" for=\"side" . $row['id'] . "\">";
echo "<input type=\"checkbox\" id=\"side" . $row['id'] . "\" name=\"side" . $row['id'] . "\" data-toggle=\"checkbox\">" . $row['name'] . " (£" . number_format((float)$row['price']/( $discount_sides == 1 ? $discount : 100), 2, '.', '') . ")</label>";
echo "</div>";
if ($count == 3) {
echo "</div>";
$count = -1;
}
$count++;
$total++;
}
if ($total % 4 != 0) {
echo "</div>";
}
?>
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Enter comments (like your two free topping changes)" id="comments" name="comments" />
<label class="login-field-icon fui-chat" for="comments"></label>
</div>
<a class="btn btn-primary btn-lg btn-block" id="submitForm" href="#" onclick="validateCrust()">Go to Payment</a>
</form>
</div>
<? } else { ?>
<p>Sorry, but there are no pizza orders at the moment</p>
<? } ?>
</div> <!-- /container -->
<? if ($isLive == 0 and $active == 1) { ?>
<footer>
<div class="container">
<p>TEST MODE</p>
</div>
</footer>
<? } ?>
<script src="dist/js/vendor/jquery.min.js"></script>
<script src="dist/js/vendor/video.js"></script>
<script src="dist/js/flat-ui.min.js"></script>
<script src="docs/assets/js/application.js"></script>
<script>
function processCrust(arg) {
switch(arg.value) {
case '1':
case '2':
$("option[value='c']").removeAttr('disabled');
$("option[value='d']").removeAttr('disabled');
$("option[value='e']").removeAttr('disabled');
$("option[value='f']").removeAttr('disabled');
$("option[value='g']").removeAttr('disabled');
$("option[value='b']").removeAttr('disabled');
break;
case '3':
$("option[value='c']").attr("disabled", "disabled");
$("option[value='d']").attr("disabled", "disabled");
$("option[value='e']").attr("disabled", "disabled");
$("option[value='f']").attr("disabled", "disabled");
$("option[value='g']").attr("disabled", "disabled");
break;
case '4':
$("option[value='b']").attr("disabled", "disabled");
$("option[value='c']").attr("disabled", "disabled");
$("option[value='d']").attr("disabled", "disabled");
$("option[value='e']").attr("disabled", "disabled");
$("option[value='f']").attr("disabled", "disabled");
$("option[value='g']").attr("disabled", "disabled");
}
}
function validateCrust() {
if (document.getElementById("login-name").value == "") {
$("#nameField").addClass("has-error");
return false;
}
var c = document.getElementById("crustSelect");
var s = document.getElementById("sizeSelect");
var p = document.getElementById("pizzaSelect");
if (p.options[p.selectedIndex].value == "H" && s.options[s.selectedIndex].value == "4") {
$('#size-error').show();
return false;
}
var pv = p.options[p.selectedIndex].value;
var sv = s.options[s.selectedIndex].value;
var cv = c.options[c.selectedIndex].value;
if ((pv == '20' || pv == '21' || pv == '22' || pv == '23' || pv == '24') && (sv == '3' || sv == '4' || cv != 'b')){
$('#size-error').show();
return false;
} else {
switch(c.options[c.selectedIndex].value) {
case 'b':
if (s.options[s.selectedIndex].value == '4') {
$('#size-error').show();
return false;
} else {
$('#crustSelect').removeAttr("disabled");
$('#sizeSelect').removeAttr("disabled");
document.getElementById("orderForm").submit();
}
break;
case 'c':
case 'd':
case 'e':
case 'f':
case 'g':
if (s.options[s.selectedIndex].value == '3' || s.options[s.selectedIndex].value == '4') {
$('#size-error').show();
return false;
}
default:
$('#crustSelect').removeAttr("disabled");
$('#sizeSelect').removeAttr("disabled");
document.getElementById("orderForm").submit();
}
}
}
function resetName() {
$("#nameField").removeClass("has-error");
}
function init() {
$('#sides').hide();
$('#size-error').hide();
var clock = getTimeRemaining('<?=$deadline?>');
if(clock.total>0){
document.getElementById('countdown').innerHTML =
clock.hours + 'h ' +
clock.minutes + 'm ' +
clock.seconds + 's ';
} else {
document.getElementById('countdown').innerHTML = '0h 0m 0s';
}
initializeClock('countdown', '<?=$deadline?>');
}
function processSides() {
if ($('#sides').is(":visible")) {
document.getElementById('showSides').innerHTML = "Show sides";
$('#sides').hide('fast');
} else {
document.getElementById('showSides').innerHTML = "Hide sides";
$('#sides').show('fast');
}
}
function processPizza(arg) {
if (arg.value == "H") {
$('#crustSelect').removeAttr("disabled");
$('#sizeSelect').removeAttr("disabled");
$('#orderForm').attr('action', 'custom.php?mode=H');
$('#submitForm').html('Customise Your Pizza');
$("option[value='4']").attr('disabled', 'disabled');
} else if (arg.value == "B") {
$('#crustSelect').removeAttr("disabled");
$('#sizeSelect').removeAttr("disabled");
$('#orderForm').attr('action', 'custom.php?mode=B');
$('#submitForm').html('Customise Your Pizza');
$("option[value='4']").removeAttr('disabled');
} else if (arg.value == "<?=$config['empty_pizza']?>") {
$('#crustSelect').attr("disabled", "disabled");
$('#sizeSelect').attr("disabled", "disabled");
} else {
$('#crustSelect').removeAttr("disabled");
$('#sizeSelect').removeAttr("disabled");
$('#orderForm').attr('action', 'order.php');
$('#submitForm').html('Go to Payment');
}
}
function getTimeRemaining(endtime){
var t = Date.parse(endtime) - Date.parse(new Date());
var seconds = Math.floor( (t/1000) % 60 );
var minutes = Math.floor( (t/1000/60) % 60 );
var hours = Math.floor( (t/(1000*60*60)) % 24 );
var days = Math.floor( t/(1000*60*60*24) );
return {
'total': t,
'days': days,
'hours': hours,
'minutes': minutes,
'seconds': seconds
};
}
function initializeClock(id, endtime){
var clock = document.getElementById(id);
var timeinterval = setInterval(function(){
var t = getTimeRemaining(endtime);
if(t.total>0){
clock.innerHTML =
t.hours + 'h ' +
t.minutes + 'm ' +
t.seconds + 's ';
} else {
clock.innerHTML = '0h 0m 0s';
}
},1000);
}
</script>
</body>
</html>