Tue, 04 Jun 2019 19:50:06 +0200
Added console logging in the grid write callback functions. Removed grid sorting, it is done on the server side. Alert popup for block row edit functions. Better grid live updates. In recipe and product print show the whirlpool time. The checklist now shows misc ingredients added in the mash. Show hops added in the whirlpool. Most ingredient names are now quoted.
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 | * 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
|
31 | */ |
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
|
32 | $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
|
33 | $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
|
34 | $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
|
35 | if ($changed > 0) { |
354
2e372eeba04b
Better log messages in crontasks.php
Michiel Broek <mbroek@mbse.eu>
parents:
294
diff
changeset
|
36 | 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
|
37 | } |
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
|
38 | |
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
|
39 | $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
|
40 | $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
|
41 | $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
|
42 | if ($changed > 0) { |
354
2e372eeba04b
Better log messages in crontasks.php
Michiel Broek <mbroek@mbse.eu>
parents:
294
diff
changeset
|
43 | 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
|
44 | } |
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
|
45 | |
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
|
46 | $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
|
47 | $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
|
48 | $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
|
49 | if ($changed > 0) { |
354
2e372eeba04b
Better log messages in crontasks.php
Michiel Broek <mbroek@mbse.eu>
parents:
294
diff
changeset
|
50 | 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
|
51 | } |
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
|
52 | |
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
|
53 | |
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
|
54 | /* |
36c72e368948
Reduce inventory is now done in a cron job at 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 | * 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
|
56 | */ |
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
|
57 | $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
|
58 | $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
|
59 | 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
|
60 | $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
|
61 | 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
|
62 | $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
|
63 | 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
|
64 | $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
|
65 | 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
|
66 | $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
|
67 | 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
|
68 | $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
|
69 | } |
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
|
70 | } |
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
|
71 |