-
Notifications
You must be signed in to change notification settings - Fork 0
/
clear.php
48 lines (43 loc) · 1.48 KB
/
clear.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
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
$extraArgs = "";
$all = true;
if (isset($_POST['clear'])) {
$conn = mysqli_connect("127.0.0.1", "root", "digo_secret", "digo_parts_db");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$order = $_POST['w_order'];
$sql = "UPDATE part_allocation SET sorted=1 where product_id=\"" . $_POST['part_id'] . "\" AND werkorder=\"" . $order . "\"";
$result = $conn->query($sql);
$sql = "SELECT werkorder
from part_allocation
WHERE werkorder=$order
GROUP BY werkorder
HAVING MAX(sorted) = 1 AND MIN(sorted) = 1 AND MAX(big) = 1 AND MIN(big) = 1";
$resultBig = $conn->query($sql);
$sql = "SELECT werkorder
from part_allocation
WHERE werkorder=$order
GROUP BY werkorder
HAVING MAX(sorted) = 1 AND MIN(sorted) = 1";
$resultAll = $conn->query($sql);
$all = mysqli_num_rows($resultAll);
if ($all) {
$extraArgs .= "&orderdel=" . $order;
$sql = "UPDATE system_status set orderid=0 where placeholder=0";
$conn->query($sql);
}
if (mysqli_num_rows($resultBig)) {
$extraArgs .= "&allbig=1";
}
}
if (!$all) {
header('Location: index.php?orderId=' . $order . "&deleted=" . $_POST['part_id'] . $extraArgs);
} else {
header('Location: index.php?deleted=' . $_POST['part_id'] . $extraArgs);
}