Mon, 11 Mar 2019 16:37:57 +0100
Corrected mature days count.
273
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | <?php |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | require_once('config.php'); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | #Connect to the database |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | $connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | if (! $connect) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | } |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | mysqli_set_charset($connect, "utf8" ); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | if (isset($_POST['reduce']) && isset($_POST['uuid'])) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | $sql1 = "SELECT * FROM products WHERE uuid = '" . $_POST['uuid'] . "';"; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | } else { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | exit; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | } |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | //syslog(LOG_NOTICE, $sql1); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
19 | |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | $result1 = mysqli_query($connect, $sql1) or die("SQL Error 1: " . mysqli_error($connect)); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | while ($row = mysqli_fetch_array($result1, MYSQLI_ASSOC)) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
23 | if ($row['stage'] < 6) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
24 | syslog(LOG_NOTICE, "code: " . $row['code'] . " cannot reduce inventory, not yet packaged."); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
25 | exit; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
26 | } |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
27 | if ($row['inventory_reduced']) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
28 | syslog(LOG_NOTICE, "code: " . $row['code'] . " cannot reduce inventory, already reduced."); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
29 | exit; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
30 | } |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
31 | |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
32 | syslog(LOG_NOTICE, "Start reducing inventory from ". $row['code'].' '.$row['name']); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
33 | |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
34 | $fermentables = json_decode($row['json_fermentables'], true); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
35 | for ($i = 0; $i < count($fermentables); $i++) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
36 | |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
37 | $sql2 = "UPDATE inventory_fermentables SET inventory = inventory - " . $fermentables[$i]['f_amount']; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
38 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $fermentables[$i]['f_name']); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
39 | $sql2 .= "' AND origin='" . mysqli_real_escape_string($connect, $fermentables[$i]['f_origin']); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
40 | $sql2 .= "' AND supplier='" . mysqli_real_escape_string($connect, $fermentables[$i]['f_supplier']); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
41 | $sql2 .= "' AND inventory >= " . $fermentables[$i]['f_amount']; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
42 | $sql2 .= " LIMIT 1;"; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
43 | // syslog(LOG_NOTICE, $sql2); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
44 | $result2 = mysqli_query($connect, $sql2); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
45 | $ar = mysqli_affected_rows($connect); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
46 | if ($ar == 1) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
47 | syslog(LOG_NOTICE, "Reduced fermentable `".$fermentables[$i]['f_name']."' from `".$fermentables[$i]['f_supplier']."' with ".$fermentables[$i]['f_amount']." kg"); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
48 | } else if ($ar == 0) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
49 | $sql2 = "UPDATE inventory_fermentables SET inventory = 0"; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
50 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $fermentables[$i]['f_name']); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
51 | $sql2 .= "' AND origin='" . mysqli_real_escape_string($connect, $fermentables[$i]['f_origin']); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
52 | $sql2 .= "' AND supplier='" . mysqli_real_escape_string($connect, $fermentables[$i]['f_supplier']); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
53 | $sql2 .= "' AND inventory < " . $fermentables[$i]['f_amount']; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
54 | $sql2 .= " LIMIT 1;"; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
55 | // syslog(LOG_NOTICE, $sql2); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
56 | $result2 = mysqli_query($connect, $sql2); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
57 | $ar = mysqli_affected_rows($connect); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
58 | if ($ar == 1) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
59 | syslog(LOG_NOTICE, "Reduced fermentable `".$fermentables[$i]['f_name']."' from `".$fermentables[$i]['f_supplier']."' to 0 kg"); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
60 | } else if ($ar == 0) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
61 | syslog(LOG_NOTICE, "Reduced fermentable `".$fermentables[$i]['f_name']."' from `".$fermentables[$i]['f_supplier']."' failed"); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
62 | } |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
63 | // syslog(LOG_NOTICE, "affected rows: ".$ar); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
64 | } |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
65 | } |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
66 | |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
67 | $hops = json_decode($row['json_hops'], true); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
68 | for ($i = 0; $i < count($hops); $i++) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
69 | |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
70 | $sql2 = "UPDATE inventory_hops SET inventory = inventory - " . $hops[$i]['h_amount']; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
71 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $hops[$i]['h_name']); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
72 | $sql2 .= "' AND origin='" . mysqli_real_escape_string($connect, $hops[$i]['h_origin']); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
73 | $sql2 .= "' AND form=" . $hops[$i]['h_form']; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
74 | $sql2 .= " AND inventory >= " . $hops[$i]['h_amount'] . " LIMIT 1;"; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
75 | // syslog(LOG_NOTICE, $sql2); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
76 | $result2 = mysqli_query($connect, $sql2); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
77 | $ar = mysqli_affected_rows($connect); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
78 | if ($ar == 1) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
79 | syslog(LOG_NOTICE, "Reduced hop `".$hops[$i]['h_name']."' from `".$hops[$i]['h_origin']."' with ".$hops[$i]['h_amount']." kg"); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
80 | } else if ($ar == 0) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
81 | $sql2 = "UPDATE inventory_hops SET inventory = 0"; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
82 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $hops[$i]['h_name']); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
83 | $sql2 .= "' AND origin='" . mysqli_real_escape_string($connect, $hops[$i]['h_origin']); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
84 | $sql2 .= "' AND form=" . $hops[$i]['h_form']; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
85 | $sql2 .= " AND inventory < " . $hops[$i]['h_amount'] . " LIMIT 1;"; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
86 | // syslog(LOG_NOTICE, $sql2); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
87 | $result2 = mysqli_query($connect, $sql2); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
88 | $ar = mysqli_affected_rows($connect); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
89 | if ($ar == 1) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
90 | syslog(LOG_NOTICE, "Reduced hop `".$hops[$i]['h_name']."' from `".$hops[$i]['h_origin']."' to 0 kg"); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
91 | } else if ($ar == 0) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
92 | syslog(LOG_NOTICE, "Reduced hop `".$hops[$i]['h_name']."' from `".$hops[$i]['h_origin']."' failed"); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
93 | } |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
94 | } |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
95 | } |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
96 | |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
97 | $miscs = json_decode($row['json_miscs'], true); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
98 | for ($i = 0; $i < count($miscs); $i++) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
99 | |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
100 | $sql2 = "UPDATE inventory_miscs SET inventory = inventory - " . $miscs[$i]['m_amount']; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
101 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $miscs[$i]['m_name']); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
102 | $sql2 .= "' AND inventory >= " . $miscs[$i]['m_amount'] . " LIMIT 1;"; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
103 | // syslog(LOG_NOTICE, $sql2); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
104 | $result2 = mysqli_query($connect, $sql2); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
105 | $ar = mysqli_affected_rows($connect); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
106 | if ($ar == 1) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
107 | syslog(LOG_NOTICE, "Reduced misc `".$miscs[$i]['m_name']."' with ".$miscs[$i]['m_amount']); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
108 | } else if ($ar == 0) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
109 | $sql2 = "UPDATE inventory_miscs SET inventory = 0"; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
110 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $miscs[$i]['m_name']); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
111 | $sql2 .= "' AND inventory < " . $miscs[$i]['m_amount'] . " LIMIT 1;"; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
112 | // syslog(LOG_NOTICE, $sql2); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
113 | $result2 = mysqli_query($connect, $sql2); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
114 | $ar = mysqli_affected_rows($connect); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
115 | if ($ar == 1) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
116 | syslog(LOG_NOTICE, "Reduced misc `".$miscs[$i]['m_name']."' to 0"); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
117 | } else if ($ar == 0) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
118 | syslog(LOG_NOTICE, "Reduced misc `".$miscs[$i]['m_name']."' failed"); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
119 | } |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
120 | } |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
121 | } |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
122 | |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
123 | $yeasts = json_decode($row['json_yeasts'], true); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
124 | for ($i = 0; $i < count($yeasts); $i++) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
125 | |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
126 | $sql2 = "UPDATE inventory_yeasts SET inventory = inventory - " . $yeasts[$i]['y_amount']; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
127 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_name']); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
128 | $sql2 .= "' AND laboratory='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_laboratory']); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
129 | $sql2 .= "' AND product_id='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_product_id']); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
130 | $sql2 .= "' AND form=" . $yeasts[$i]['y_form']; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
131 | $sql2 .= " AND inventory >= " . $yeasts[$i]['y_amount'] . " LIMIT 1;"; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
132 | // syslog(LOG_NOTICE, $sql2); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
133 | $result2 = mysqli_query($connect, $sql2); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
134 | $ar = mysqli_affected_rows($connect); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
135 | if ($ar == 1) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
136 | syslog(LOG_NOTICE, "Reduced yeast `".$yeasts[$i]['y_product_id'].' '.$yeasts[$i]['y_name']."' from `".$yeasts[$i]['y_laboratory']."' with ".$yeasts[$i]['y_amount']); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
137 | } else if ($ar == 0) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
138 | $sql2 = "UPDATE inventory_yeasts SET inventory = 0"; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
139 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_name']); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
140 | $sql2 .= "' AND laboratory='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_laboratory']); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
141 | $sql2 .= "' AND product_id='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_product_id']); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
142 | $sql2 .= "' AND form=" . $yeasts[$i]['y_form']; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
143 | $sql2 .= " AND inventory < " . $yeasts[$i]['y_amount'] . " LIMIT 1;"; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
144 | // syslog(LOG_NOTICE, $sql2); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
145 | $result2 = mysqli_query($connect, $sql2); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
146 | $ar = mysqli_affected_rows($connect); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
147 | if ($ar == 1) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
148 | syslog(LOG_NOTICE, "Reduced yeast `".$yeasts[$i]['y_product_id'].' '.$yeasts[$i]['y_name']."' from `".$yeasts[$i]['y_laboratory']."' to 0"); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
149 | } else if ($ar == 0) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
150 | syslog(LOG_NOTICE, "Reduced yeast `".$yeasts[$i]['y_product_id'].' '.$yeasts[$i]['y_name']."' from `".$yeasts[$i]['y_laboratory']."' failed"); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
151 | } |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
152 | } |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
153 | } |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
154 | |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
155 | if ($row['w1_name'] != '') { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
156 | $sql2 = "UPDATE inventory_waters SET inventory = inventory - ".$row['w1_amount']; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
157 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $row['w1_name']); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
158 | $sql2 .= "' AND unlimited_stock=0 AND inventory >= ".$row['w1_amount']." LIMIT 1;"; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
159 | // syslog(LOG_NOTICE, $sql2); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
160 | $result2 = mysqli_query($connect, $sql2); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
161 | $ar = mysqli_affected_rows($connect); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
162 | if ($ar == 1) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
163 | syslog(LOG_NOTICE, "Reduced water `".$row['w1_name']."' with ".$row['w1_amount']." liter"); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
164 | } else if ($ar == 0) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
165 | $sql2 = "UPDATE inventory_waters SET inventory = 0"; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
166 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $row['w1_name']); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
167 | $sql2 .= "' AND unlimited_stock=0 AND inventory < ".$row['w1_amount']." LIMIT 1;"; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
168 | // syslog(LOG_NOTICE, $sql2); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
169 | $result2 = mysqli_query($connect, $sql2); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
170 | $ar = mysqli_affected_rows($connect); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
171 | if ($ar == 1) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
172 | syslog(LOG_NOTICE, "Reduced water `".$row['w1_name']."' to 0 liters"); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
173 | } else { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
174 | syslog(LOG_NOTICE, "Reduced water `".$row['w1_name']."' failed or tapwater"); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
175 | } |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
176 | } |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
177 | } |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
178 | if ($row['w2_name'] != '') { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
179 | $sql2 = "UPDATE inventory_waters SET inventory = inventory - ".$row['w2_amount']; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
180 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $row['w2_name']); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
181 | $sql2 .= "' AND unlimited_stock=0 AND inventory >= ".$row['w2_amount']." LIMIT 1;"; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
182 | // syslog(LOG_NOTICE, $sql2); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
183 | $result2 = mysqli_query($connect, $sql2); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
184 | $ar = mysqli_affected_rows($connect); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
185 | if ($ar == 1) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
186 | syslog(LOG_NOTICE, "Reduced water `".$row['w2_name']."' with ".$row['w2_amount']." liter"); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
187 | } else if ($ar == 0) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
188 | $sql2 = "UPDATE inventory_waters SET inventory = 0"; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
189 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $row['w2_name']); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
190 | $sql2 .= "' AND unlimited_stock=0 AND inventory < ".$row['w2_amount']." LIMIT 1;"; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
191 | // syslog(LOG_NOTICE, $sql2); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
192 | $result2 = mysqli_query($connect, $sql2); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
193 | $ar = mysqli_affected_rows($connect); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
194 | if ($ar == 1) { |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
195 | syslog(LOG_NOTICE, "Reduced water `".$row['w2_name']."' to 0 liters"); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
196 | } |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
197 | } |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
198 | } |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
199 | |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
200 | syslog(LOG_NOTICE, "Finished reducing inventory from ". $row['code'].' '.$row['name']); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
201 | mysqli_free_result($result1); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
202 | |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
203 | $sql1 = "UPDATE products SET inventory_reduced=1 WHERE uuid = '" . $_POST['uuid'] . "';"; |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
204 | //syslog(LOG_NOTICE, $sql1); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
205 | $result1 = mysqli_query($connect, $sql1); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
206 | $ar = mysqli_affected_rows($connect); |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
207 | } |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
208 | |
19606adfea42
Set recipe edit values readonly when the brewday is over. Add the inventory reduce script and update the checkbox. Active after packaging.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
209 | exit(0); |