www/crontasks.php

Sat, 23 May 2020 20:53:48 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 23 May 2020 20:53:48 +0200
changeset 691
9c21125f584e
parent 615
9034e65b0d7a
child 855
2d328a2a4025
permissions
-rw-r--r--

Added clone command to the equipment inventory.

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 /*
419
99a7f2a6976e Added packaging volume and add water or liquer to the beer after fermentation. Auto divide changing volumes between bottles and fusts. Upgrade the database in the crontask. Added these fields to the packaging tab screen.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
18 * Upgrade package values.
99a7f2a6976e Added packaging volume and add water or liquer to the beer after fermentation. Auto divide changing volumes between bottles and fusts. Upgrade the database in the crontask. Added these fields to the packaging tab screen.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
19 */
99a7f2a6976e Added packaging volume and add water or liquer to the beer after fermentation. Auto divide changing volumes between bottles and fusts. Upgrade the database in the crontask. Added these fields to the packaging tab screen.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
20 $query = "UPDATE products SET package_volume = bottle_amount + keg_amount WHERE package_volume='0';";
99a7f2a6976e Added packaging volume and add water or liquer to the beer after fermentation. Auto divide changing volumes between bottles and fusts. Upgrade the database in the crontask. Added these fields to the packaging tab screen.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
21 $result = mysqli_query($connect, $query);
99a7f2a6976e Added packaging volume and add water or liquer to the beer after fermentation. Auto divide changing volumes between bottles and fusts. Upgrade the database in the crontask. Added these fields to the packaging tab screen.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
22 $changed = mysqli_affected_rows($connect);
99a7f2a6976e Added packaging volume and add water or liquer to the beer after fermentation. Auto divide changing volumes between bottles and fusts. Upgrade the database in the crontask. Added these fields to the packaging tab screen.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
23 if ($changed > 0) {
99a7f2a6976e Added packaging volume and add water or liquer to the beer after fermentation. Auto divide changing volumes between bottles and fusts. Upgrade the database in the crontask. Added these fields to the packaging tab screen.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
24 syslog(LOG_NOTICE, "Updated ".$changed." products to new package_volume value");
99a7f2a6976e Added packaging volume and add water or liquer to the beer after fermentation. Auto divide changing volumes between bottles and fusts. Upgrade the database in the crontask. Added these fields to the packaging tab screen.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
25 }
422
7943afc0fcde Added cron upgrade tasks to initialize the priming_water amounts. Fixed these to be a float instead of integer.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
26 $query = "UPDATE products SET bottle_priming_water = bottle_amount * bottle_priming_amount / 500 WHERE bottle_priming_water = 0;";
7943afc0fcde Added cron upgrade tasks to initialize the priming_water amounts. Fixed these to be a float instead of integer.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
27 $result = mysqli_query($connect, $query);
7943afc0fcde Added cron upgrade tasks to initialize the priming_water amounts. Fixed these to be a float instead of integer.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
28 $changed = mysqli_affected_rows($connect);
7943afc0fcde Added cron upgrade tasks to initialize the priming_water amounts. Fixed these to be a float instead of integer.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
29 if ($changed > 0) {
7943afc0fcde Added cron upgrade tasks to initialize the priming_water amounts. Fixed these to be a float instead of integer.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
30 syslog(LOG_NOTICE, "Updated ".$changed." products to new package_volume value");
7943afc0fcde Added cron upgrade tasks to initialize the priming_water amounts. Fixed these to be a float instead of integer.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
31 }
7943afc0fcde Added cron upgrade tasks to initialize the priming_water amounts. Fixed these to be a float instead of integer.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
32 $query = "UPDATE products SET keg_priming_water = keg_amount * keg_priming_amount / 500 WHERE keg_priming_water = 0;";
7943afc0fcde Added cron upgrade tasks to initialize the priming_water amounts. Fixed these to be a float instead of integer.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
33 $result = mysqli_query($connect, $query);
7943afc0fcde Added cron upgrade tasks to initialize the priming_water amounts. Fixed these to be a float instead of integer.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
34 $changed = mysqli_affected_rows($connect);
7943afc0fcde Added cron upgrade tasks to initialize the priming_water amounts. Fixed these to be a float instead of integer.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
35 if ($changed > 0) {
7943afc0fcde Added cron upgrade tasks to initialize the priming_water amounts. Fixed these to be a float instead of integer.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
36 syslog(LOG_NOTICE, "Updated ".$changed." products to new package_volume value");
7943afc0fcde Added cron upgrade tasks to initialize the priming_water amounts. Fixed these to be a float instead of integer.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
37 }
419
99a7f2a6976e Added packaging volume and add water or liquer to the beer after fermentation. Auto divide changing volumes between bottles and fusts. Upgrade the database in the crontask. Added these fields to the packaging tab screen.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
38
99a7f2a6976e Added packaging volume and add water or liquer to the beer after fermentation. Auto divide changing volumes between bottles and fusts. Upgrade the database in the crontask. Added these fields to the packaging tab screen.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
39 /*
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
40 * 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
41 */
36c72e368948 Reduce inventory is now done in a cron job at 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 $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
43 $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
44 $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
45 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
46 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
47 }
36c72e368948 Reduce inventory is now done in a cron job at 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
36c72e368948 Reduce inventory is now done in a cron job at 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
36c72e368948 Reduce inventory is now done in a cron job at 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 /*
36c72e368948 Reduce inventory is now done in a cron job at 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 * 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
53 */
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
54 $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
55 $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
56 $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
57 if ($changed > 0) {
354
2e372eeba04b Better log messages in crontasks.php
Michiel Broek <mbroek@mbse.eu>
parents: 294
diff changeset
58 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
59 }
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
60
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
61 $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
62 $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
63 $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
64 if ($changed > 0) {
354
2e372eeba04b Better log messages in crontasks.php
Michiel Broek <mbroek@mbse.eu>
parents: 294
diff changeset
65 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
66 }
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
67
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
68 $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
69 $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
70 $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
71 if ($changed > 0) {
354
2e372eeba04b Better log messages in crontasks.php
Michiel Broek <mbroek@mbse.eu>
parents: 294
diff changeset
72 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
73 }
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
74
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
75
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
76 /*
615
9034e65b0d7a Added CO2 carbonation log to the products database. Added button in the packaging tab.
Michiel Broek <mbroek@mbse.eu>
parents: 602
diff changeset
77 * Check several logs.
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
78 */
615
9034e65b0d7a Added CO2 carbonation log to the products database. Added button in the packaging tab.
Michiel Broek <mbroek@mbse.eu>
parents: 602
diff changeset
79 $query = "SELECT record,code,name,log_brew,log_fermentation,log_ispindel,log_co2pressure FROM products;";
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
80 $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
81 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
82 $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
83 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
84 $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
85 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
86 $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
87 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
88 $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
89 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
90 $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
91 }
602
10b61aacb1c1 New products field log_ispindel. Add check for ispindel log to crontasks.php Added log_ispindel to prod_edit, pprod_divide, prod_new and prod_duplicate. Renamed some log_fermentation vergisting names into klimaatkast.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
92 $logfile = "log/ispindel/" . $row['code'] . " " . $row['name'] . ".log";
10b61aacb1c1 New products field log_ispindel. Add check for ispindel log to crontasks.php Added log_ispindel to prod_edit, pprod_divide, prod_new and prod_duplicate. Renamed some log_fermentation vergisting names into klimaatkast.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
93 if (file_exists($logfile))
10b61aacb1c1 New products field log_ispindel. Add check for ispindel log to crontasks.php Added log_ispindel to prod_edit, pprod_divide, prod_new and prod_duplicate. Renamed some log_fermentation vergisting names into klimaatkast.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
94 $ok = 1;
10b61aacb1c1 New products field log_ispindel. Add check for ispindel log to crontasks.php Added log_ispindel to prod_edit, pprod_divide, prod_new and prod_duplicate. Renamed some log_fermentation vergisting names into klimaatkast.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
95 else
10b61aacb1c1 New products field log_ispindel. Add check for ispindel log to crontasks.php Added log_ispindel to prod_edit, pprod_divide, prod_new and prod_duplicate. Renamed some log_fermentation vergisting names into klimaatkast.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
96 $ok = 0;
10b61aacb1c1 New products field log_ispindel. Add check for ispindel log to crontasks.php Added log_ispindel to prod_edit, pprod_divide, prod_new and prod_duplicate. Renamed some log_fermentation vergisting names into klimaatkast.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
97 if ($ok != $row['log_ispindel']) {
10b61aacb1c1 New products field log_ispindel. Add check for ispindel log to crontasks.php Added log_ispindel to prod_edit, pprod_divide, prod_new and prod_duplicate. Renamed some log_fermentation vergisting names into klimaatkast.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
98 $query = "UPDATE products SET log_ispindel='" . $ok . "' WHERE record='" . $row['record'] . "';";
10b61aacb1c1 New products field log_ispindel. Add check for ispindel log to crontasks.php Added log_ispindel to prod_edit, pprod_divide, prod_new and prod_duplicate. Renamed some log_fermentation vergisting names into klimaatkast.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
99 syslog(LOG_NOTICE, $query);
10b61aacb1c1 New products field log_ispindel. Add check for ispindel log to crontasks.php Added log_ispindel to prod_edit, pprod_divide, prod_new and prod_duplicate. Renamed some log_fermentation vergisting names into klimaatkast.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
100 $result1 = mysqli_query($connect, $query);
10b61aacb1c1 New products field log_ispindel. Add check for ispindel log to crontasks.php Added log_ispindel to prod_edit, pprod_divide, prod_new and prod_duplicate. Renamed some log_fermentation vergisting names into klimaatkast.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
101 }
615
9034e65b0d7a Added CO2 carbonation log to the products database. Added button in the packaging tab.
Michiel Broek <mbroek@mbse.eu>
parents: 602
diff changeset
102 $logfile = "log/co2pressure/" . $row['code'] . " " . $row['name'] . ".log";
9034e65b0d7a Added CO2 carbonation log to the products database. Added button in the packaging tab.
Michiel Broek <mbroek@mbse.eu>
parents: 602
diff changeset
103 if (file_exists($logfile))
9034e65b0d7a Added CO2 carbonation log to the products database. Added button in the packaging tab.
Michiel Broek <mbroek@mbse.eu>
parents: 602
diff changeset
104 $ok = 1;
9034e65b0d7a Added CO2 carbonation log to the products database. Added button in the packaging tab.
Michiel Broek <mbroek@mbse.eu>
parents: 602
diff changeset
105 else
9034e65b0d7a Added CO2 carbonation log to the products database. Added button in the packaging tab.
Michiel Broek <mbroek@mbse.eu>
parents: 602
diff changeset
106 $ok = 0;
9034e65b0d7a Added CO2 carbonation log to the products database. Added button in the packaging tab.
Michiel Broek <mbroek@mbse.eu>
parents: 602
diff changeset
107 if ($ok != $row['log_co2pressure']) {
9034e65b0d7a Added CO2 carbonation log to the products database. Added button in the packaging tab.
Michiel Broek <mbroek@mbse.eu>
parents: 602
diff changeset
108 $query = "UPDATE products SET log_co2pressure='" . $ok . "' WHERE record='" . $row['record'] . "';";
9034e65b0d7a Added CO2 carbonation log to the products database. Added button in the packaging tab.
Michiel Broek <mbroek@mbse.eu>
parents: 602
diff changeset
109 syslog(LOG_NOTICE, $query);
9034e65b0d7a Added CO2 carbonation log to the products database. Added button in the packaging tab.
Michiel Broek <mbroek@mbse.eu>
parents: 602
diff changeset
110 $result1 = mysqli_query($connect, $query);
9034e65b0d7a Added CO2 carbonation log to the products database. Added button in the packaging tab.
Michiel Broek <mbroek@mbse.eu>
parents: 602
diff changeset
111 }
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
112 }
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
113
460
046ff5fdc96c Implemented products.secondary_end_sg field. The missing values are updated by the crontask.
Michiel Broek <mbroek@mbse.eu>
parents: 422
diff changeset
114
046ff5fdc96c Implemented products.secondary_end_sg field. The missing values are updated by the crontask.
Michiel Broek <mbroek@mbse.eu>
parents: 422
diff changeset
115 /*
046ff5fdc96c Implemented products.secondary_end_sg field. The missing values are updated by the crontask.
Michiel Broek <mbroek@mbse.eu>
parents: 422
diff changeset
116 * Check and update secondary_end_sg
046ff5fdc96c Implemented products.secondary_end_sg field. The missing values are updated by the crontask.
Michiel Broek <mbroek@mbse.eu>
parents: 422
diff changeset
117 */
046ff5fdc96c Implemented products.secondary_end_sg field. The missing values are updated by the crontask.
Michiel Broek <mbroek@mbse.eu>
parents: 422
diff changeset
118 $query = "UPDATE products SET secondary_end_sg=fg WHERE stage > 5 AND secondary_end_sg='0';";
046ff5fdc96c Implemented products.secondary_end_sg field. The missing values are updated by the crontask.
Michiel Broek <mbroek@mbse.eu>
parents: 422
diff changeset
119 $result = mysqli_query($connect, $query);
046ff5fdc96c Implemented products.secondary_end_sg field. The missing values are updated by the crontask.
Michiel Broek <mbroek@mbse.eu>
parents: 422
diff changeset
120 $changed = mysqli_affected_rows($connect);
046ff5fdc96c Implemented products.secondary_end_sg field. The missing values are updated by the crontask.
Michiel Broek <mbroek@mbse.eu>
parents: 422
diff changeset
121 if ($changed > 0) {
046ff5fdc96c Implemented products.secondary_end_sg field. The missing values are updated by the crontask.
Michiel Broek <mbroek@mbse.eu>
parents: 422
diff changeset
122 syslog(LOG_NOTICE, "Updated ".$changed." products with new secondary_end_sg value");
046ff5fdc96c Implemented products.secondary_end_sg field. The missing values are updated by the crontask.
Michiel Broek <mbroek@mbse.eu>
parents: 422
diff changeset
123 }
046ff5fdc96c Implemented products.secondary_end_sg field. The missing values are updated by the crontask.
Michiel Broek <mbroek@mbse.eu>
parents: 422
diff changeset
124
046ff5fdc96c Implemented products.secondary_end_sg field. The missing values are updated by the crontask.
Michiel Broek <mbroek@mbse.eu>
parents: 422
diff changeset
125

mercurial