-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·361 lines (338 loc) · 13.7 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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
<?php
$conn = mysqli_connect("127.0.0.1", "root", "digo_secret", "digo_parts_db");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$orderId = $_GET['orderId'];
if (!$orderId) {
$orderId = $_GET["orderdel"];
}
$del = isset($_GET['deleted']) && !empty($_GET['deleted']);
?>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="includes/css/bootstrap.min.css" rel="stylesheet">
<script src="includes/js/jquery.js"></script>
<script src="includes/js/bootstrap.min.js"></script>
<link rel="shortcut icon" href="">
</head>
<style>
* { font-size: 1.1em}
.identifier {
float:right;
font-size:2em;
}
.confirm-overlay {
width:100%;
height:100%;
position:fixed;
background: white;
display:none;
}
.digo-overlay {
width:100%;
height:100%;
position:fixed;
background: white;
padding: 20px;
}
.confirm-dialog {
/*display: none;*/
width: 440px;
height: 220px;
border-radius: 8px;
border: 1px solid black;
background-color: #f5f5f5;
position: absolute;
top:0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
margin-top:120px;
}
.dialog-container {
width: 100%;
height:100%;
overflow: hidden;
}
.dialog-container p {
width: 100%;
height:50%;
padding:12px;
}
.dialog-container ul {
width: 100%;
height:50%;
float:left;
list-style-type: none;
padding:0;
}
.dialog-container li {
width: 50%;
float:left;
text-align: center;
margin:0;
padding:0;
border-top:2px solid #ddd;
vertical-align:middle;
}
.dialog-container ul li:before {
content:'';
height:90%;
display:inline-block;
margin-bottom:-90%;
vertical-align: middle;
}
.dialog-container li a {
width:100%;
height: 100%;
padding-top:12.5%;
text-decoration: none;
color:black;
display:inline-block;
}
.dialog-container li:first-child {
border-right: 2px solid #ddd;
}
.message {
display:none;
}
</style>
<body>
<?php
if (strpos($orderId, "digo") !== false) :
$digoOrderId = substr($orderId, 4);
?>
<div class="digo-overlay">
<div>Werkorder <?php echo $digoOrderId; ?> ingescand. <div class="identifier">Kenteken: <?php
$sql = "SELECT license from order_info WHERE `werkorder`=$digoOrderId LIMIT 1";
$sqlLicense = mysqli_fetch_row($conn->query($sql));
echo $sqlLicense[0] . "</div><br>";
$sql = "SELECT werkorder, description, amount
from part_allocation
WHERE `werkorder`=$digoOrderId and big=1 and sorted=1";
$resultBig = $conn->query($sql);
if (mysqli_num_rows($resultBig) == 0) :
?>
Er zijn geen grote onderdelen
<?php else :
?>
<h3>Grote onderdelen aanwezig:</h3>
<br>
<?php
echo "<table class='table'><tr><th>Naam</th><th>Aantal</th></tr>";
while ($row = $resultBig->fetch_assoc()) {
echo "<tr><td>" . $row["description"] . "</td>";
echo "<td>" . $row["amount"] . "</td></tr>";
}
?>
</table>
<?php
endif;
?>
<script>
function checkDBChanges() {
$.ajax({
type: "GET",
url: "requestStatus.php",
dataType: "json",
success: function (data) {
if (data.orderid != 0 && data.orderid != curOrder) {
window.location.replace("http://" + location.hostname + "/index.php?orderId=" + data.orderid);
}
}
});
}
setInterval(checkDBChanges, 5000);
setTimeout(function () {
window.location.replace("/");
}, 30000);
</script>
</div>
</div>
<?php
exit;
endif;
?>
<div class="confirm-overlay">
<?php
if ($del && !$allBig) {
$del = $_GET['deleted'];
echo "<form method='post' action='undo.php'>";
echo "<div class='alert alert-info' style='width:auto margin:20px'>";
echo "order: $orderId product $del weggelegd<button type='submit' class='btn btn-sm btn-primary' style='margin:0;float:right'>Ongedaan maken</button><input type='hidden' name='del' value='" . $del . "'><input type='hidden' name='w_order' value='" . $orderId . "'>";
echo "</div>";
echo "</form>";
}
?>
<div class="confirm-dialog">
<div class="dialog-container">
<p>Wilt u de bak behouden?</p>
<ul>
<li><a href="#1" onclick="alterIndex()">Nee</a></li>
<li><a href="#0" onclick="javacript:$('.confirm-overlay').hide()">Ja</a></li>
</ul>
</div> <!-- cd-popup-container -->
</div> <!-- cd-popup -->
</div> <!-- cd-popup -->
<div class="" style="margin:20px"><h3>
<?php
if (!empty($allBig = $_GET['allbig'])) {
if ($allBig) {
?>
<script>
$('.confirm-overlay').show();
</script>
<?php
}
}
/* This sets the $time variable to the current hour in the 24 hour clock format */
$time = date("H");
/* Set the $timezone variable to become the current timezone */
$timezone = date("e");
/* If the time is less than 1200 hours, show good morning */
if ($time < "12") {
echo "Goedemorgen";
} else
/* If the time is grater than or equal to 1200 hours, but less than 1700 hours, so good afternoon */
if ($time >= "12" && $time < "17") {
echo "Goedemiddag";
} else
/* Should the time be between or equal to 1700 and 1900 hours, show good evening */
if ($time >= "17") {
echo "Goedenavond";
}
?>
</h3>
<br>
<input class="form-control" style="width:120px;display:inline" id="search" type="hidden"/>
<div class="message alert alert-success" style="margin:24px;margin-top:0">
</div>
<?php
$orderSet = isset($_GET['orderId']) && !empty($_GET['orderId']);
if (!$orderSet) {
echo "<h1>Scan een werkorder of een pakbon om te beginnen.</h1></br></br>";
}
$sql = "SELECT * FROM part_allocation where sorted = 0";
$result = $conn->query($sql);
if ($del && !$allBig) {
$del = $_GET['deleted'];
echo "<form method='post' action='undo.php'>";
echo "<div class='alert alert-info'>";
echo "order: $orderId product $del weggelegd<button type='submit' class='btn btn-xs btn-primary' style='margin:0;float:right'>Ongedaan maken</button><input type='hidden' name='del' value='" . $del . "'><input type='hidden' name='w_order' value='" . $orderId . "'>";
echo "</div>";
echo "</form>";
}
if ($orderId && $result->num_rows > 0) :
?>
<table class = "table" id="order-table">
<tr>
<th>order</th>
<th>artikel</th>
<th>product</th>
<th>aantal</th>
<th>klaar</th>
<th>label</th>
<!--<th>afwezig</th>-->
</tr>
<?php
// output data of each row
while ($row = $result->fetch_assoc()) :
?><tr>
<form method="post" action="clear.php">
<td class="col-sm-1" id = "order-id"><input type="hidden" name="w_order" value="<?php echo $row['werkorder']; ?>"/><?php echo $row['werkorder']; ?></td>
<td id = "product-id"><input type="hidden" name="part_id" value="<?php echo $row['product_id']; ?>"/><?php echo $row['product_id']; ?></td>
<td id = "product-name"><?php echo $row['description']; ?></td>
<td class="col-sm-1" id = "product-amount"><?php echo $row['amount']; ?></td>
<td class="col-sm-1" style="padding:4px" id = "product-clear"><button type="submit" name="clear" class="btn btn-xs"><img width=36px height=36px alt="weggelegd" src='includes/images/check.png'/></button></td>
</form>
<td class="col-sm-1" style="padding:4px" id="product-amount"><button type="submit" onclick="labelPrint('<?php echo $row['werkorder'] . "','" . $row['product_id']; ?>')" class="btn btn-xs"><img width=36px height=36px alt="sticker printen" src='includes/images/print.png'/></button></td>
<!--<td style="padding:4px" id="product-amount"><button type="submit" class="btn btn-xs"><img width=24px height=24px alt="niet aanwezig" src='includes/images/missing.png'/></button></td>-->
</tr>
<?php endwhile;
?>
</table>
<form method="post" action="stop.php"><button type="submit" name="clear" class="btn btn-sm btn-danger">STOP</button>
<?php
else :
if ($orderSet) {
echo "Geen producten gevonden<br><br>";
} else {
//echo "Dit is de productpagina.</br>";
//echo "Producten zullen hier verschijnen wanneer een order wordt ingescand.</br></br>";
}
endif;
?>
</div>
</body>
</html>
<script>
<?php
$jsid = $orderId | 0;
echo "var curOrder = " . $jsid . ";"
?>
function checkDBChanges() {
$.ajax({
type: "GET",
url: "requestStatus.php",
dataType: "json",
success: function (data) {
if (data.orderid != 0 && data.orderid != curOrder) {
window.location.replace("http://" + location.hostname + "/index.php?orderId=" + data.orderid);
}
}
});
}
function labelPrint(id, productId) {
$('.message').html("Bezig met printen").show();
setTimeout(function () {
$('.message').html("").hide()
}, 8000);
$.ajax({
type: "POST",
url: "requestLabel.php",
data: {"label_id": id, "product_id": productId}
});
}
function alterIndex() {
$.ajax({
type: "POST",
url: "alterIndex.php",
data: {"order_id": <?php
if (!$orderId)
echo 0;
echo $orderId
?>}
}).done(function () {
window.location.replace('/');
});
}
setInterval(checkDBChanges, 5000);
if (curOrder !== 0) {
$("#search").val(curOrder);
search(curOrder);
}
function search(value) {
var found = 0;
$("#order-table tr").each(function (index) {
$(this).find("#order-id").each(function () {
var id = $(this).text().toLowerCase().trim();
var not_found = (id.indexOf(value) == -1);
$(this).closest('tr').toggle(!not_found);
if (not_found == false) {
found = 1;
}
});
});
if (!found && curOrder != 0) {
$('.message').html("Alle producten zijn weggelegd. U wordt verwezen naar de homepage over 5 seconden.").show();
setTimeout(function () {
window.location.replace("stop.php");
}, 5000);
} else {
$('.message').html("").hide();
}
}
</script>