Sun, 02 Jun 2019 12:48:54 +0200
Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
257
62e294ab94f5
Version 0.0.6. Added a crontask that adjusts the stage of packaged beer depending on the days passed packaging
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | <?php |
62e294ab94f5
Version 0.0.6. Added a crontask that adjusts the stage of packaged beer depending on the days passed packaging
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | |
62e294ab94f5
Version 0.0.6. Added a crontask that adjusts the stage of packaged beer depending on the days passed packaging
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | require_once('config.php'); |
62e294ab94f5
Version 0.0.6. Added a crontask that adjusts the stage of packaged beer depending on the days passed packaging
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | |
294
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
5 | $escapers = array("\\", "/", "\"", "\n", "\r", "\t", "\x08", "\x0c"); |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
6 | $replacements = array("\\\\", "\\/", "\\\"", "\\n", "\\r", "\\t", "\\f", "\\b"); |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
7 | |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
8 | $connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME); |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
9 | if (! $connect) { |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
10 | die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
11 | } |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
12 | mysqli_set_charset($connect, "utf8" ); |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
13 | syslog(LOG_NOTICE, "crontasks.php started"); |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
14 | |
356
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
15 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
16 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
17 | /* |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
18 | * Upgrade inventory_reduced value from old boolean to tiny integer value. |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
19 | */ |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
20 | $query = "UPDATE products SET inventory_reduced=stage WHERE inventory_reduced = 1"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
21 | $result = mysqli_query($connect, $query); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
22 | $changed = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
23 | if ($changed > 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
24 | syslog(LOG_NOTICE, "Updated ".$changed." products to new inventory_reduced value"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
25 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
26 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
27 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
28 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
29 | /* |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
30 | * Automatic reduce inventory depending on the production stage. |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
31 | * Stage 3+, primary, reduce sugars(0-mash, 1-boil), hops(0-mash, 1-fwh, 2-boil, 3-aroma, 4-whirlpool), miscs(0-starter, 1-mash, 2-boil) |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
32 | * Stage 4+, Secondary, reduce sugars(2-fermention), yeasts(0-Primary), miscs(3-primary) |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
33 | * Stage 5+, Tertiary, reduce yeasts(1-Secondary) |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
34 | * Stage 6+, packaged, reduce sugars(3-lagering), hops(5-dry-hop), yeasts(2-Tertiary), miscs(4-secondary) |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
35 | * Stage 7+, carbonatiom, reduce sugars(4-bottle), yeasts(3-Bottle), miscs(5-bottling) |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
36 | */ |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
37 | $query = "SELECT * FROM products WHERE inventory_reduced < stage"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
38 | $result = mysqli_query($connect, $query); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
39 | while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
40 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
41 | $savethis = 0; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
42 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
43 | /* |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
44 | * If the brew is done, reduce the used ingredients. |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
45 | */ |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
46 | if (($row['stage'] >= 3) && ($row['inventory_reduced'] < 3)) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
47 | syslog(LOG_NOTICE, "Reduce brew inventory from " . $row['code'] . " " . $row['name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
48 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
49 | $fermentables = json_decode($row['json_fermentables'], true); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
50 | for ($i = 0; $i < count($fermentables); $i++) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
51 | if ($fermentables[$i]['f_added'] <= 1) { // Mash, Boil |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
52 | $sql2 = "UPDATE inventory_fermentables SET inventory = inventory - " . $fermentables[$i]['f_amount']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
53 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $fermentables[$i]['f_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
54 | $sql2 .= "' AND origin='" . mysqli_real_escape_string($connect, $fermentables[$i]['f_origin']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
55 | $sql2 .= "' AND supplier='" . mysqli_real_escape_string($connect, $fermentables[$i]['f_supplier']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
56 | $sql2 .= "' AND inventory >= " . $fermentables[$i]['f_amount']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
57 | $sql2 .= " LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
58 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
59 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
60 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
61 | syslog(LOG_NOTICE, "Reduced fermentable `".$fermentables[$i]['f_name']."' from `".$fermentables[$i]['f_supplier']."' with ".$fermentables[$i]['f_amount']." kg"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
62 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
63 | $sql2 = "UPDATE inventory_fermentables SET inventory = 0"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
64 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $fermentables[$i]['f_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
65 | $sql2 .= "' AND origin='" . mysqli_real_escape_string($connect, $fermentables[$i]['f_origin']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
66 | $sql2 .= "' AND supplier='" . mysqli_real_escape_string($connect, $fermentables[$i]['f_supplier']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
67 | $sql2 .= "' AND inventory < " . $fermentables[$i]['f_amount']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
68 | $sql2 .= " LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
69 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
70 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
71 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
72 | syslog(LOG_NOTICE, "Reduced fermentable `".$fermentables[$i]['f_name']."' from `".$fermentables[$i]['f_supplier']."' to 0 kg"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
73 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
74 | syslog(LOG_NOTICE, "Reduce fermentable `".$fermentables[$i]['f_name']."' from `".$fermentables[$i]['f_supplier']."' failed"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
75 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
76 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
77 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
78 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
79 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
80 | $hops = json_decode($row['json_hops'], true); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
81 | for ($i = 0; $i < count($hops); $i++) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
82 | if ($hops[$i]['h_useat'] <= 4) { // Mash, FWH, Boil, Flameout, Whirlpool |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
83 | $sql2 = "UPDATE inventory_hops SET inventory = inventory - " . $hops[$i]['h_amount']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
84 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $hops[$i]['h_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
85 | $sql2 .= "' AND origin='" . mysqli_real_escape_string($connect, $hops[$i]['h_origin']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
86 | $sql2 .= "' AND form=" . $hops[$i]['h_form']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
87 | $sql2 .= " AND inventory >= " . $hops[$i]['h_amount'] . " LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
88 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
89 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
90 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
91 | syslog(LOG_NOTICE, "Reduced hop `".$hops[$i]['h_name']."' from `".$hops[$i]['h_origin']."' with ".$hops[$i]['h_amount']." kg"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
92 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
93 | $sql2 = "UPDATE inventory_hops SET inventory = 0"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
94 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $hops[$i]['h_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
95 | $sql2 .= "' AND origin='" . mysqli_real_escape_string($connect, $hops[$i]['h_origin']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
96 | $sql2 .= "' AND form=" . $hops[$i]['h_form']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
97 | $sql2 .= " AND inventory < " . $hops[$i]['h_amount'] . " LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
98 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
99 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
100 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
101 | syslog(LOG_NOTICE, "Reduced hop `".$hops[$i]['h_name']."' from `".$hops[$i]['h_origin']."' to 0 kg"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
102 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
103 | syslog(LOG_NOTICE, "Reduce hop `".$hops[$i]['h_name']."' from `".$hops[$i]['h_origin']."' failed"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
104 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
105 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
106 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
107 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
108 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
109 | $miscs = json_decode($row['json_miscs'], true); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
110 | for ($i = 0; $i < count($miscs); $i++) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
111 | if ($miscs[$i]['m_use_use'] <= 2) { // Starter, Mash, Boil |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
112 | $sql2 = "UPDATE inventory_miscs SET inventory = inventory - " . $miscs[$i]['m_amount']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
113 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $miscs[$i]['m_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
114 | $sql2 .= "' AND inventory >= " . $miscs[$i]['m_amount'] . " LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
115 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
116 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
117 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
118 | syslog(LOG_NOTICE, "Reduced misc `".$miscs[$i]['m_name']."' with ".$miscs[$i]['m_amount']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
119 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
120 | $sql2 = "UPDATE inventory_miscs SET inventory = 0"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
121 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $miscs[$i]['m_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
122 | $sql2 .= "' AND inventory < " . $miscs[$i]['m_amount'] . " LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
123 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
124 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
125 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
126 | syslog(LOG_NOTICE, "Reduced misc `".$miscs[$i]['m_name']."' to 0"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
127 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
128 | syslog(LOG_NOTICE, "Reduce misc `".$miscs[$i]['m_name']."' failed"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
129 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
130 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
131 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
132 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
133 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
134 | if ($row['w1_name'] != '') { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
135 | $sql2 = "UPDATE inventory_waters SET inventory = inventory - ".$row['w1_amount']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
136 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $row['w1_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
137 | $sql2 .= "' AND unlimited_stock=0 AND inventory >= ".$row['w1_amount']." LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
138 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
139 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
140 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
141 | syslog(LOG_NOTICE, "Reduced water `".$row['w1_name']."' with ".$row['w1_amount']." liter"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
142 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
143 | $sql2 = "UPDATE inventory_waters SET inventory = 0"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
144 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $row['w1_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
145 | $sql2 .= "' AND unlimited_stock=0 AND inventory < ".$row['w1_amount']." LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
146 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
147 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
148 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
149 | syslog(LOG_NOTICE, "Reduced water `".$row['w1_name']."' to 0 liters"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
150 | } else { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
151 | syslog(LOG_NOTICE, "Reduce water `".$row['w1_name']."' not reduced is maybe tapwater"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
152 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
153 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
154 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
155 | if ($row['w2_name'] != '') { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
156 | $sql2 = "UPDATE inventory_waters SET inventory = inventory - ".$row['w2_amount']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
157 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $row['w2_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
158 | $sql2 .= "' AND unlimited_stock=0 AND inventory >= ".$row['w2_amount']." LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
159 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
160 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
161 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
162 | syslog(LOG_NOTICE, "Reduced water `".$row['w2_name']."' with ".$row['w2_amount']." liter"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
163 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
164 | $sql2 = "UPDATE inventory_waters SET inventory = 0"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
165 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $row['w2_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
166 | $sql2 .= "' AND unlimited_stock=0 AND inventory < ".$row['w2_amount']." LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
167 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
168 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
169 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
170 | syslog(LOG_NOTICE, "Reduced water `".$row['w2_name']."' to 0 liters"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
171 | } else { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
172 | syslog(LOG_NOTICE, "Reduce water `".$row['w2_name']."' failed"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
173 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
174 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
175 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
176 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
177 | $row['inventory_reduced'] = '3'; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
178 | $savethis = 1; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
179 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
180 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
181 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
182 | /* |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
183 | * After the Primary fermentation |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
184 | */ |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
185 | if (($row['stage'] >= 4) && ($row['inventory_reduced'] < 4)) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
186 | syslog(LOG_NOTICE, "Reduce Primary inventory from " . $row['code'] . " " . $row['name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
187 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
188 | $fermentables = json_decode($row['json_fermentables'], true); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
189 | for ($i = 0; $i < count($fermentables); $i++) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
190 | if ($fermentables[$i]['f_added'] == 2) { // Fermentation |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
191 | $sql2 = "UPDATE inventory_fermentables SET inventory = inventory - " . $fermentables[$i]['f_amount']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
192 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $fermentables[$i]['f_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
193 | $sql2 .= "' AND origin='" . mysqli_real_escape_string($connect, $fermentables[$i]['f_origin']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
194 | $sql2 .= "' AND supplier='" . mysqli_real_escape_string($connect, $fermentables[$i]['f_supplier']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
195 | $sql2 .= "' AND inventory >= " . $fermentables[$i]['f_amount']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
196 | $sql2 .= " LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
197 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
198 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
199 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
200 | syslog(LOG_NOTICE, "Reduced fermentable `".$fermentables[$i]['f_name']."' from `".$fermentables[$i]['f_supplier']."' with ".$fermentables[$i]['f_amount']." kg"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
201 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
202 | $sql2 = "UPDATE inventory_fermentables SET inventory = 0"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
203 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $fermentables[$i]['f_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
204 | $sql2 .= "' AND origin='" . mysqli_real_escape_string($connect, $fermentables[$i]['f_origin']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
205 | $sql2 .= "' AND supplier='" . mysqli_real_escape_string($connect, $fermentables[$i]['f_supplier']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
206 | $sql2 .= "' AND inventory < " . $fermentables[$i]['f_amount']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
207 | $sql2 .= " LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
208 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
209 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
210 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
211 | syslog(LOG_NOTICE, "Reduced fermentable `".$fermentables[$i]['f_name']."' from `".$fermentables[$i]['f_supplier']."' to 0 kg"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
212 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
213 | syslog(LOG_NOTICE, "Reduce fermentable `".$fermentables[$i]['f_name']."' from `".$fermentables[$i]['f_supplier']."' failed"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
214 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
215 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
216 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
217 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
218 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
219 | $miscs = json_decode($row['json_miscs'], true); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
220 | for ($i = 0; $i < count($miscs); $i++) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
221 | if ($miscs[$i]['m_use_use'] == 3) { // Fermentation |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
222 | $sql2 = "UPDATE inventory_miscs SET inventory = inventory - " . $miscs[$i]['m_amount']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
223 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $miscs[$i]['m_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
224 | $sql2 .= "' AND inventory >= " . $miscs[$i]['m_amount'] . " LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
225 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
226 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
227 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
228 | syslog(LOG_NOTICE, "Reduced misc `".$miscs[$i]['m_name']."' with ".$miscs[$i]['m_amount']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
229 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
230 | $sql2 = "UPDATE inventory_miscs SET inventory = 0"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
231 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $miscs[$i]['m_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
232 | $sql2 .= "' AND inventory < " . $miscs[$i]['m_amount'] . " LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
233 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
234 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
235 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
236 | syslog(LOG_NOTICE, "Reduced misc `".$miscs[$i]['m_name']."' to 0"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
237 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
238 | syslog(LOG_NOTICE, "Reduce misc `".$miscs[$i]['m_name']."' failed"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
239 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
240 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
241 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
242 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
243 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
244 | $yeasts = json_decode($row['json_yeasts'], true); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
245 | for ($i = 0; $i < count($yeasts); $i++) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
246 | if ($yeasts[$i]['y_use'] == 0) { // Primary |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
247 | $sql2 = "UPDATE inventory_yeasts SET inventory = inventory - " . $yeasts[$i]['y_amount']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
248 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
249 | $sql2 .= "' AND laboratory='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_laboratory']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
250 | $sql2 .= "' AND product_id='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_product_id']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
251 | $sql2 .= "' AND form=" . $yeasts[$i]['y_form']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
252 | $sql2 .= " AND inventory >= " . $yeasts[$i]['y_amount'] . " LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
253 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
254 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
255 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
256 | syslog(LOG_NOTICE, "Reduced yeast `".$yeasts[$i]['y_product_id'].' '.$yeasts[$i]['y_name']."' from `".$yeasts[$i]['y_laboratory']."' with ".$yeasts[$i]['y_amount']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
257 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
258 | $sql2 = "UPDATE inventory_yeasts SET inventory = 0"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
259 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
260 | $sql2 .= "' AND laboratory='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_laboratory']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
261 | $sql2 .= "' AND product_id='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_product_id']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
262 | $sql2 .= "' AND form=" . $yeasts[$i]['y_form']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
263 | $sql2 .= " AND inventory < " . $yeasts[$i]['y_amount'] . " LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
264 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
265 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
266 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
267 | syslog(LOG_NOTICE, "Reduced yeast `".$yeasts[$i]['y_product_id'].' '.$yeasts[$i]['y_name']."' from `".$yeasts[$i]['y_laboratory']."' to 0"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
268 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
269 | syslog(LOG_NOTICE, "Reduce yeast `".$yeasts[$i]['y_product_id'].' '.$yeasts[$i]['y_name']."' from `".$yeasts[$i]['y_laboratory']."' failed"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
270 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
271 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
272 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
273 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
274 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
275 | $row['inventory_reduced'] = '4'; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
276 | $savethis = 1; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
277 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
278 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
279 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
280 | /* |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
281 | * After the Seconday fermentation |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
282 | */ |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
283 | if (($row['stage'] >= 5) && ($row['inventory_reduced'] < 5)) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
284 | syslog(LOG_NOTICE, "Reduce Secondary inventory from " . $row['code'] . " " . $row['name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
285 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
286 | $yeasts = json_decode($row['json_yeasts'], true); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
287 | for ($i = 0; $i < count($yeasts); $i++) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
288 | if ($yeasts[$i]['y_use'] == 1) { // Secondary |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
289 | $sql2 = "UPDATE inventory_yeasts SET inventory = inventory - " . $yeasts[$i]['y_amount']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
290 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
291 | $sql2 .= "' AND laboratory='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_laboratory']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
292 | $sql2 .= "' AND product_id='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_product_id']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
293 | $sql2 .= "' AND form=" . $yeasts[$i]['y_form']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
294 | $sql2 .= " AND inventory >= " . $yeasts[$i]['y_amount'] . " LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
295 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
296 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
297 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
298 | syslog(LOG_NOTICE, "Reduced yeast `".$yeasts[$i]['y_product_id'].' '.$yeasts[$i]['y_name']."' from `".$yeasts[$i]['y_laboratory']."' with ".$yeasts[$i]['y_amount']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
299 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
300 | $sql2 = "UPDATE inventory_yeasts SET inventory = 0"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
301 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
302 | $sql2 .= "' AND laboratory='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_laboratory']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
303 | $sql2 .= "' AND product_id='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_product_id']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
304 | $sql2 .= "' AND form=" . $yeasts[$i]['y_form']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
305 | $sql2 .= " AND inventory < " . $yeasts[$i]['y_amount'] . " LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
306 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
307 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
308 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
309 | syslog(LOG_NOTICE, "Reduced yeast `".$yeasts[$i]['y_product_id'].' '.$yeasts[$i]['y_name']."' from `".$yeasts[$i]['y_laboratory']."' to 0"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
310 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
311 | syslog(LOG_NOTICE, "Reduce yeast `".$yeasts[$i]['y_product_id'].' '.$yeasts[$i]['y_name']."' from `".$yeasts[$i]['y_laboratory']."' failed"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
312 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
313 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
314 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
315 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
316 | $row['inventory_reduced'] = '5'; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
317 | $savethis = 1; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
318 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
319 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
320 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
321 | /* |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
322 | * After the Tertiary fermentation |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
323 | */ |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
324 | if (($row['stage'] >= 6) && ($row['inventory_reduced'] < 6)) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
325 | syslog(LOG_NOTICE, "Reduce Tertiary inventory from " . $row['code'] . " " . $row['name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
326 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
327 | $fermentables = json_decode($row['json_fermentables'], true); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
328 | for ($i = 0; $i < count($fermentables); $i++) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
329 | if ($fermentables[$i]['f_added'] == 3) { // Lagering |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
330 | $sql2 = "UPDATE inventory_fermentables SET inventory = inventory - " . $fermentables[$i]['f_amount']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
331 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $fermentables[$i]['f_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
332 | $sql2 .= "' AND origin='" . mysqli_real_escape_string($connect, $fermentables[$i]['f_origin']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
333 | $sql2 .= "' AND supplier='" . mysqli_real_escape_string($connect, $fermentables[$i]['f_supplier']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
334 | $sql2 .= "' AND inventory >= " . $fermentables[$i]['f_amount']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
335 | $sql2 .= " LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
336 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
337 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
338 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
339 | syslog(LOG_NOTICE, "Reduced fermentable `".$fermentables[$i]['f_name']."' from `".$fermentables[$i]['f_supplier']."' with ".$fermentables[$i]['f_amount']." kg"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
340 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
341 | $sql2 = "UPDATE inventory_fermentables SET inventory = 0"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
342 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $fermentables[$i]['f_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
343 | $sql2 .= "' AND origin='" . mysqli_real_escape_string($connect, $fermentables[$i]['f_origin']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
344 | $sql2 .= "' AND supplier='" . mysqli_real_escape_string($connect, $fermentables[$i]['f_supplier']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
345 | $sql2 .= "' AND inventory < " . $fermentables[$i]['f_amount']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
346 | $sql2 .= " LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
347 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
348 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
349 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
350 | syslog(LOG_NOTICE, "Reduced fermentable `".$fermentables[$i]['f_name']."' from `".$fermentables[$i]['f_supplier']."' to 0 kg"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
351 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
352 | syslog(LOG_NOTICE, "Reduce fermentable `".$fermentables[$i]['f_name']."' from `".$fermentables[$i]['f_supplier']."' failed"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
353 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
354 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
355 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
356 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
357 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
358 | $hops = json_decode($row['json_hops'], true); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
359 | for ($i = 0; $i < count($hops); $i++) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
360 | if ($hops[$i]['h_useat'] == 5) { // Dry hop |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
361 | $sql2 = "UPDATE inventory_hops SET inventory = inventory - " . $hops[$i]['h_amount']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
362 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $hops[$i]['h_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
363 | $sql2 .= "' AND origin='" . mysqli_real_escape_string($connect, $hops[$i]['h_origin']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
364 | $sql2 .= "' AND form=" . $hops[$i]['h_form']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
365 | $sql2 .= " AND inventory >= " . $hops[$i]['h_amount'] . " LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
366 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
367 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
368 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
369 | syslog(LOG_NOTICE, "Reduced hop `".$hops[$i]['h_name']."' from `".$hops[$i]['h_origin']."' with ".$hops[$i]['h_amount']." kg"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
370 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
371 | $sql2 = "UPDATE inventory_hops SET inventory = 0"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
372 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $hops[$i]['h_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
373 | $sql2 .= "' AND origin='" . mysqli_real_escape_string($connect, $hops[$i]['h_origin']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
374 | $sql2 .= "' AND form=" . $hops[$i]['h_form']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
375 | $sql2 .= " AND inventory < " . $hops[$i]['h_amount'] . " LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
376 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
377 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
378 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
379 | syslog(LOG_NOTICE, "Reduced hop `".$hops[$i]['h_name']."' from `".$hops[$i]['h_origin']."' to 0 kg"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
380 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
381 | syslog(LOG_NOTICE, "Reduce hop `".$hops[$i]['h_name']."' from `".$hops[$i]['h_origin']."' failed"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
382 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
383 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
384 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
385 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
386 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
387 | $yeasts = json_decode($row['json_yeasts'], true); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
388 | for ($i = 0; $i < count($yeasts); $i++) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
389 | if ($yeasts[$i]['y_use'] == 2) { // Tertiary |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
390 | $sql2 = "UPDATE inventory_yeasts SET inventory = inventory - " . $yeasts[$i]['y_amount']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
391 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
392 | $sql2 .= "' AND laboratory='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_laboratory']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
393 | $sql2 .= "' AND product_id='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_product_id']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
394 | $sql2 .= "' AND form=" . $yeasts[$i]['y_form']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
395 | $sql2 .= " AND inventory >= " . $yeasts[$i]['y_amount'] . " LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
396 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
397 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
398 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
399 | syslog(LOG_NOTICE, "Reduced yeast `".$yeasts[$i]['y_product_id'].' '.$yeasts[$i]['y_name']."' from `".$yeasts[$i]['y_laboratory']."' with ".$yeasts[$i]['y_amount']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
400 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
401 | $sql2 = "UPDATE inventory_yeasts SET inventory = 0"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
402 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
403 | $sql2 .= "' AND laboratory='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_laboratory']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
404 | $sql2 .= "' AND product_id='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_product_id']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
405 | $sql2 .= "' AND form=" . $yeasts[$i]['y_form']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
406 | $sql2 .= " AND inventory < " . $yeasts[$i]['y_amount'] . " LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
407 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
408 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
409 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
410 | syslog(LOG_NOTICE, "Reduced yeast `".$yeasts[$i]['y_product_id'].' '.$yeasts[$i]['y_name']."' from `".$yeasts[$i]['y_laboratory']."' to 0"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
411 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
412 | syslog(LOG_NOTICE, "Reduce yeast `".$yeasts[$i]['y_product_id'].' '.$yeasts[$i]['y_name']."' from `".$yeasts[$i]['y_laboratory']."' failed"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
413 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
414 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
415 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
416 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
417 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
418 | $miscs = json_decode($row['json_miscs'], true); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
419 | for ($i = 0; $i < count($miscs); $i++) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
420 | if ($miscs[$i]['m_use_use'] == 4) { // Secondary or Tertiary |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
421 | $sql2 = "UPDATE inventory_miscs SET inventory = inventory - " . $miscs[$i]['m_amount']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
422 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $miscs[$i]['m_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
423 | $sql2 .= "' AND inventory >= " . $miscs[$i]['m_amount'] . " LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
424 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
425 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
426 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
427 | syslog(LOG_NOTICE, "Reduced misc `".$miscs[$i]['m_name']."' with ".$miscs[$i]['m_amount']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
428 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
429 | $sql2 = "UPDATE inventory_miscs SET inventory = 0"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
430 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $miscs[$i]['m_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
431 | $sql2 .= "' AND inventory < " . $miscs[$i]['m_amount'] . " LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
432 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
433 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
434 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
435 | syslog(LOG_NOTICE, "Reduced misc `".$miscs[$i]['m_name']."' to 0"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
436 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
437 | syslog(LOG_NOTICE, "Reduce misc `".$miscs[$i]['m_name']."' failed"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
438 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
439 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
440 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
441 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
442 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
443 | $row['inventory_reduced'] = '6'; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
444 | $savethis = 1; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
445 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
446 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
447 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
448 | /* |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
449 | * After packaging |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
450 | * reduce sugars(4-bottle), yeasts(3-Bottle), miscs(5-bottling) |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
451 | */ |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
452 | if (($row['stage'] >= 7) && ($row['inventory_reduced'] < 7)) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
453 | syslog(LOG_NOTICE, "Reduce Packaging inventory from " . $row['code'] . " " . $row['name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
454 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
455 | // Bottle sugar, how? |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
456 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
457 | $yeasts = json_decode($row['json_yeasts'], true); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
458 | for ($i = 0; $i < count($yeasts); $i++) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
459 | if ($yeasts[$i]['y_use'] == 3) { // Bottle |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
460 | $sql2 = "UPDATE inventory_yeasts SET inventory = inventory - " . $yeasts[$i]['y_amount']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
461 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
462 | $sql2 .= "' AND laboratory='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_laboratory']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
463 | $sql2 .= "' AND product_id='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_product_id']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
464 | $sql2 .= "' AND form=" . $yeasts[$i]['y_form']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
465 | $sql2 .= " AND inventory >= " . $yeasts[$i]['y_amount'] . " LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
466 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
467 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
468 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
469 | syslog(LOG_NOTICE, "Reduced yeast `".$yeasts[$i]['y_product_id'].' '.$yeasts[$i]['y_name']."' from `".$yeasts[$i]['y_laboratory']."' with ".$yeasts[$i]['y_amount']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
470 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
471 | $sql2 = "UPDATE inventory_yeasts SET inventory = 0"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
472 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
473 | $sql2 .= "' AND laboratory='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_laboratory']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
474 | $sql2 .= "' AND product_id='" . mysqli_real_escape_string($connect, $yeasts[$i]['y_product_id']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
475 | $sql2 .= "' AND form=" . $yeasts[$i]['y_form']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
476 | $sql2 .= " AND inventory < " . $yeasts[$i]['y_amount'] . " LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
477 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
478 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
479 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
480 | syslog(LOG_NOTICE, "Reduced yeast `".$yeasts[$i]['y_product_id'].' '.$yeasts[$i]['y_name']."' from `".$yeasts[$i]['y_laboratory']."' to 0"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
481 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
482 | syslog(LOG_NOTICE, "Reduce yeast `".$yeasts[$i]['y_product_id'].' '.$yeasts[$i]['y_name']."' from `".$yeasts[$i]['y_laboratory']."' failed"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
483 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
484 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
485 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
486 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
487 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
488 | $miscs = json_decode($row['json_miscs'], true); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
489 | for ($i = 0; $i < count($miscs); $i++) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
490 | if ($miscs[$i]['m_use_use'] == 5) { // Bottle |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
491 | $sql2 = "UPDATE inventory_miscs SET inventory = inventory - " . $miscs[$i]['m_amount']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
492 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $miscs[$i]['m_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
493 | $sql2 .= "' AND inventory >= " . $miscs[$i]['m_amount'] . " LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
494 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
495 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
496 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
497 | syslog(LOG_NOTICE, "Reduced misc `".$miscs[$i]['m_name']."' with ".$miscs[$i]['m_amount']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
498 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
499 | $sql2 = "UPDATE inventory_miscs SET inventory = 0"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
500 | $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $miscs[$i]['m_name']); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
501 | $sql2 .= "' AND inventory < " . $miscs[$i]['m_amount'] . " LIMIT 1;"; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
502 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
503 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
504 | if ($ar == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
505 | syslog(LOG_NOTICE, "Reduced misc `".$miscs[$i]['m_name']."' to 0"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
506 | } else if ($ar == 0) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
507 | syslog(LOG_NOTICE, "Reduce misc `".$miscs[$i]['m_name']."' failed"); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
508 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
509 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
510 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
511 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
512 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
513 | $row['inventory_reduced'] = $row['stage']; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
514 | $savethis = 1; |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
515 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
516 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
517 | /* |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
518 | * Save only if something was reduced. |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
519 | */ |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
520 | if ($savethis == 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
521 | $sql2 = "UPDATE products SET inventory_reduced=".$row['inventory_reduced']." WHERE uuid = '" . $row['uuid'] . "';"; |
379
2aa6addc1853
Debug logging reactivated in the crontask.
Michiel Broek <mbroek@mbse.eu>
parents:
356
diff
changeset
|
522 | syslog(LOG_NOTICE, $sql2); |
356
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
523 | $result2 = mysqli_query($connect, $sql2); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
524 | $ar = mysqli_affected_rows($connect); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
525 | if ($ar != 1) { |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
526 | syslog(LOG_NOTICE, $sql2." error, affected rows: ".$ar); |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
527 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
528 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
529 | } |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
530 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
531 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
532 | |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
533 | /* |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
534 | * Update stages after packaging depending on the age. |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
535 | */ |
257
62e294ab94f5
Version 0.0.6. Added a crontask that adjusts the stage of packaged beer depending on the days passed packaging
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
536 | $query = "UPDATE products SET stage=7 WHERE stage = 6 AND DATEDIFF(CURDATE(), package_date) > 0"; |
294
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
537 | $result = mysqli_query($connect, $query); |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
538 | $changed = mysqli_affected_rows($connect); |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
539 | if ($changed > 0) { |
354
2e372eeba04b
Better log messages in crontasks.php
Michiel Broek <mbroek@mbse.eu>
parents:
294
diff
changeset
|
540 | syslog(LOG_NOTICE, "Updated ".$changed." products to stage 7 (Carbonation)"); |
294
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
541 | } |
257
62e294ab94f5
Version 0.0.6. Added a crontask that adjusts the stage of packaged beer depending on the days passed packaging
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
542 | |
62e294ab94f5
Version 0.0.6. Added a crontask that adjusts the stage of packaged beer depending on the days passed packaging
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
543 | $query = "UPDATE products SET stage=8 WHERE stage = 7 AND DATEDIFF(CURDATE(), package_date) > 13"; |
294
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
544 | $result = mysqli_query($connect, $query); |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
545 | $changed = mysqli_affected_rows($connect); |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
546 | if ($changed > 0) { |
354
2e372eeba04b
Better log messages in crontasks.php
Michiel Broek <mbroek@mbse.eu>
parents:
294
diff
changeset
|
547 | syslog(LOG_NOTICE, "Updated ".$changed." products to stage 8 (Mature)"); |
294
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
548 | } |
257
62e294ab94f5
Version 0.0.6. Added a crontask that adjusts the stage of packaged beer depending on the days passed packaging
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
549 | |
62e294ab94f5
Version 0.0.6. Added a crontask that adjusts the stage of packaged beer depending on the days passed packaging
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
550 | $query = "UPDATE products SET stage=9 WHERE stage = 8 AND DATEDIFF(CURDATE(), package_date) > 41"; |
294
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
551 | $result = mysqli_query($connect, $query); |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
552 | $changed = mysqli_affected_rows($connect); |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
553 | if ($changed > 0) { |
354
2e372eeba04b
Better log messages in crontasks.php
Michiel Broek <mbroek@mbse.eu>
parents:
294
diff
changeset
|
554 | syslog(LOG_NOTICE, "Updated ".$changed." products to stage 9 (Taste)"); |
294
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
555 | } |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
556 | |
257
62e294ab94f5
Version 0.0.6. Added a crontask that adjusts the stage of packaged beer depending on the days passed packaging
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
557 | |
356
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
558 | /* |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
559 | * Check fementation logs. |
36c72e368948
Reduce inventory is now done in a cron job at moments when there are ingredients used. So the inventory should be uptodate at all times.
Michiel Broek <mbroek@mbse.eu>
parents:
354
diff
changeset
|
560 | */ |
294
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
561 | $query = "SELECT record,code,name,log_brew,log_fermentation FROM products;"; |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
562 | $result = mysqli_query($connect, $query); |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
563 | while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
564 | $logfile = "log/fermentation/" . $row['code'] . " " . $row['name'] . ".log"; |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
565 | if (file_exists($logfile)) |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
566 | $ok = 1; |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
567 | else |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
568 | $ok = 0; |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
569 | if ($ok != $row['log_fermentation']) { |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
570 | $query = "UPDATE products SET log_fermentation='" . $ok . "' WHERE record='" . $row['record'] . "';"; |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
571 | syslog(LOG_NOTICE, $query); |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
572 | $result1 = mysqli_query($connect, $query); |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
573 | } |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
574 | } |
1e09d1d102a8
Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
257
diff
changeset
|
575 |