Tue, 31 Aug 2021 20:48:37 +0200
Split batch, adjust mash step volume. In the duplicated log_brew handle the missing values. In save product, round the mash step sg to 4 decimals. In prod_edit, ingredients are stored as strings, not arrays. This triggered a memory corruption that only happened in rare circumstances. Don't fix mash step fields in the javascript, it is already done during load from the database. Calculation of the mash volume is rounded to 6 decimals. Enter mash step Brix/Plato value, the SG result is rounded to 4 decimals.
99
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | <?php |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | require($_SERVER['DOCUMENT_ROOT']."/config.php"); |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | require($_SERVER['DOCUMENT_ROOT']."/version.php"); |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | #Connect to the database |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | $connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME); |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | if (! $connect) { |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | } |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | mysqli_set_charset($connect, "utf8" ); |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | $escapers = array("\\", "/", "\"", "\n", "\r", "\t", "\x08", "\x0c"); |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | $replacements = array("\\\\", "\\/", "\\\"", "\\n", "\\r", "\\t", "\\f", "\\b"); |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | |
768
ae1195153fa2
Better error reporting in profiles fermentation steps, mash profiles, beer styles, water profiles and general setup.
Michiel Broek <mbroek@mbse.eu>
parents:
625
diff
changeset
|
15 | $response = array( |
ae1195153fa2
Better error reporting in profiles fermentation steps, mash profiles, beer styles, water profiles and general setup.
Michiel Broek <mbroek@mbse.eu>
parents:
625
diff
changeset
|
16 | 'error' => false, |
ae1195153fa2
Better error reporting in profiles fermentation steps, mash profiles, beer styles, water profiles and general setup.
Michiel Broek <mbroek@mbse.eu>
parents:
625
diff
changeset
|
17 | 'msg' => 'Ok', |
ae1195153fa2
Better error reporting in profiles fermentation steps, mash profiles, beer styles, water profiles and general setup.
Michiel Broek <mbroek@mbse.eu>
parents:
625
diff
changeset
|
18 | ); |
ae1195153fa2
Better error reporting in profiles fermentation steps, mash profiles, beer styles, water profiles and general setup.
Michiel Broek <mbroek@mbse.eu>
parents:
625
diff
changeset
|
19 | |
99
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | $query = "SELECT * FROM profile_setup WHERE record='1'"; |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | if (isset($_POST['update'])) { |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
23 | /* Search water record */ |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
24 | $result = mysqli_query($connect, "SELECT record FROM inventory_waters WHERE name='".$_POST['default_water']."';"); |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
25 | if ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
26 | $default_water = $row['record']; |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
27 | else |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
28 | $default_water = 0; |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
29 | $sql = "UPDATE `profile_setup` SET "; |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
30 | $sql .= "brewery_name='" . mysqli_real_escape_string($connect, $_POST['brewery_name']); |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
31 | $sql .= "', factor_mashhop='" . $_POST['factor_mashhop']; |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
32 | $sql .= "', factor_fwh='" . $_POST['factor_fwh']; |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
33 | $sql .= "', factor_pellet='" . $_POST['factor_pellet']; |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
34 | $sql .= "', factor_plug='" . $_POST['factor_plug']; |
289
4082c41f45e9
Added the use and calculation of wet hops. Assume 5.5 times more hops needed by weight.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
35 | $sql .= "', factor_wethop='" . $_POST['factor_wethop']; |
446 | 36 | $sql .= "', factor_cryohop='" . $_POST['factor_cryohop']; |
289
4082c41f45e9
Added the use and calculation of wet hops. Assume 5.5 times more hops needed by weight.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
37 | $sql .= "', color_method='" . $_POST['color_method']; |
4082c41f45e9
Added the use and calculation of wet hops. Assume 5.5 times more hops needed by weight.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
38 | $sql .= "', ibu_method='" . $_POST['ibu_method']; |
99
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
39 | $sql .= "', brix_correction='" . $_POST['brix_correction']; |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
40 | $sql .= "', grain_absorbtion='" . $_POST['grain_absorbtion']; |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
41 | $sql .= "', default_water='" . $default_water; |
625
57bc32b5f411
Extended the max value for brix correction value to 1.09. Added setting of a private yeast lab for later use. Fixed missing some default setup values.
Michiel Broek <mbroek@mbse.eu>
parents:
446
diff
changeset
|
42 | $sql .= "', my_yeastlab='" . $_POST['my_yeastlab']; |
99
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
43 | $sql .= "' WHERE record='1';"; |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
44 | $result = mysqli_query($connect, $sql); |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
45 | if (! $result) { |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
46 | syslog(LOG_NOTICE, "db_profile_setup: ".$sql." result: ".mysqli_error($connect)); |
768
ae1195153fa2
Better error reporting in profiles fermentation steps, mash profiles, beer styles, water profiles and general setup.
Michiel Broek <mbroek@mbse.eu>
parents:
625
diff
changeset
|
47 | $response['error'] = true; |
ae1195153fa2
Better error reporting in profiles fermentation steps, mash profiles, beer styles, water profiles and general setup.
Michiel Broek <mbroek@mbse.eu>
parents:
625
diff
changeset
|
48 | $response['msg'] = "SQL fout: ".mysqli_error($connect); |
ae1195153fa2
Better error reporting in profiles fermentation steps, mash profiles, beer styles, water profiles and general setup.
Michiel Broek <mbroek@mbse.eu>
parents:
625
diff
changeset
|
49 | } |
ae1195153fa2
Better error reporting in profiles fermentation steps, mash profiles, beer styles, water profiles and general setup.
Michiel Broek <mbroek@mbse.eu>
parents:
625
diff
changeset
|
50 | exit(json_encode($response)); |
ae1195153fa2
Better error reporting in profiles fermentation steps, mash profiles, beer styles, water profiles and general setup.
Michiel Broek <mbroek@mbse.eu>
parents:
625
diff
changeset
|
51 | |
99
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
52 | } else { |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
53 | $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect)); |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
54 | if ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
55 | /* search water name */ |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
56 | $wresult = mysqli_query($connect, "SELECT name FROM inventory_waters WHERE record='".$row['default_water']."';"); |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
57 | if ($wrow = mysqli_fetch_array($wresult, MYSQLI_ASSOC)) |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
58 | $default_water = $wrow['name']; |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
59 | else |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
60 | $default_water = ''; |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
61 | $data = '{"record":' . $row['record']; |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
62 | $data .= ',"brewery_name":"' . str_replace($escapers, $replacements, $row['brewery_name']); |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
63 | $data .= '","factor_mashhop":' . $row['factor_mashhop']; |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
64 | $data .= ',"factor_fwh":' . $row['factor_fwh']; |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
65 | $data .= ',"factor_pellet":' . $row['factor_pellet']; |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
66 | $data .= ',"factor_plug":' . $row['factor_plug']; |
289
4082c41f45e9
Added the use and calculation of wet hops. Assume 5.5 times more hops needed by weight.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
67 | $data .= ',"factor_wethop":' . $row['factor_wethop']; |
446 | 68 | $data .= ',"factor_cryohop":' . $row['factor_cryohop']; |
289
4082c41f45e9
Added the use and calculation of wet hops. Assume 5.5 times more hops needed by weight.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
69 | $data .= ',"ibu_method":' . $row['ibu_method']; |
4082c41f45e9
Added the use and calculation of wet hops. Assume 5.5 times more hops needed by weight.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
70 | $data .= ',"color_method":' . $row['color_method']; |
4082c41f45e9
Added the use and calculation of wet hops. Assume 5.5 times more hops needed by weight.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
71 | $data .= ',"brix_correction":' . floatval($row['brix_correction']); |
99
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
72 | $data .= ',"grain_absorbtion":' . floatval($row['grain_absorbtion']); |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
73 | $data .= ',"default_water":"' . str_replace($escapers, $replacements, $default_water); |
625
57bc32b5f411
Extended the max value for brix correction value to 1.09. Added setting of a private yeast lab for later use. Fixed missing some default setup values.
Michiel Broek <mbroek@mbse.eu>
parents:
446
diff
changeset
|
74 | $data .= '","my_yeastlab":"' . str_replace($escapers, $replacements, $row['my_yeastlab']); |
99
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
75 | $data .= '"}'; |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
76 | } |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
77 | header("Content-type: application/json"); |
768
ae1195153fa2
Better error reporting in profiles fermentation steps, mash profiles, beer styles, water profiles and general setup.
Michiel Broek <mbroek@mbse.eu>
parents:
625
diff
changeset
|
78 | exit($data); |
99
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
79 | } |
f433193f7bb6
Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
80 | ?> |