www/includes/db_product.php

Sat, 21 Aug 2021 16:14:44 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 21 Aug 2021 16:14:44 +0200
changeset 773
f4161330ed01
parent 768
ae1195153fa2
child 774
92e1e8f175a2
permissions
-rw-r--r--

Don't log successfull reduced ingredients.

111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 <?php
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 require($_SERVER['DOCUMENT_ROOT']."/config.php");
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 require($_SERVER['DOCUMENT_ROOT']."/version.php");
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 #Connect to the database
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 $connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME);
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 if (! $connect) {
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 }
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 mysqli_set_charset($connect, "utf8" );
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
13 $escapers = array("\\", "/", "\"", "\n", "\r", "\t", "\x08", "\x0c");
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
14 $replacements = array("\\\\", "\\/", "\\\"", "\\n", "\\r", "\\t", "\\f", "\\b");
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
15 $rescapers = array("'");
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
16 $rreplacements = array("\\'");
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
17 $disallowed = array('visibleindex','uniqueid','boundindex','uid','h_weight','m_weight');
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18
757
d13be50c0049 Added error handler
Michiel Broek <mbroek@mbse.eu>
parents: 740
diff changeset
19 $response = array(
d13be50c0049 Added error handler
Michiel Broek <mbroek@mbse.eu>
parents: 740
diff changeset
20 'error' => false,
d13be50c0049 Added error handler
Michiel Broek <mbroek@mbse.eu>
parents: 740
diff changeset
21 'msg' => 'Ok',
d13be50c0049 Added error handler
Michiel Broek <mbroek@mbse.eu>
parents: 740
diff changeset
22 );
d13be50c0049 Added error handler
Michiel Broek <mbroek@mbse.eu>
parents: 740
diff changeset
23
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 if (isset($_POST['insert']) || isset($_POST['update'])) {
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 if (isset($_POST['insert'])) {
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
26 $sql = "INSERT INTO `products` SET ";
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 }
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 if (isset($_POST['update'])) {
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
29 $sql = "UPDATE `products` SET ";
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 }
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
31
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
32 $stage = $_POST['stage'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
33
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 // Basic settings
166
635033a29c48 Fixed new recipes uuid generation and saving missing new fields.
Michiel Broek <mbroek@mbse.eu>
parents: 164
diff changeset
35 if (isset($_POST['uuid'])) {
635033a29c48 Fixed new recipes uuid generation and saving missing new fields.
Michiel Broek <mbroek@mbse.eu>
parents: 164
diff changeset
36 $sql .= "uuid='" . $_POST['uuid'];
635033a29c48 Fixed new recipes uuid generation and saving missing new fields.
Michiel Broek <mbroek@mbse.eu>
parents: 164
diff changeset
37 } else {
635033a29c48 Fixed new recipes uuid generation and saving missing new fields.
Michiel Broek <mbroek@mbse.eu>
parents: 164
diff changeset
38 $uuid = str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid'));
635033a29c48 Fixed new recipes uuid generation and saving missing new fields.
Michiel Broek <mbroek@mbse.eu>
parents: 164
diff changeset
39 $sql .= "uuid='" . $uuid;
635033a29c48 Fixed new recipes uuid generation and saving missing new fields.
Michiel Broek <mbroek@mbse.eu>
parents: 164
diff changeset
40 }
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
41 $sql .= "', name='" . mysqli_real_escape_string($connect, $_POST['name']);
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
42 $sql .= "', code='" . mysqli_real_escape_string($connect, $_POST['code']);
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 $sql .= "', birth='" . $_POST['birth'];
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 $sql .= "', stage='" . $_POST['stage'];
164
0a5abea575a9 Added the last tab, fermentation to the product editer.
Michiel Broek <mbroek@mbse.eu>
parents: 163
diff changeset
45 $sql .= "', notes='" . mysqli_real_escape_string($connect, $_POST['notes']);
252
b558f3dfcda3 Make sure all boolean values are saved correctly in the database.
Michiel Broek <mbroek@mbse.eu>
parents: 243
diff changeset
46 $sql .= "', log_brew='" . $_POST['log_brew'];
b558f3dfcda3 Make sure all boolean values are saved correctly in the database.
Michiel Broek <mbroek@mbse.eu>
parents: 243
diff changeset
47 $sql .= "', log_fermentation='" . $_POST['log_fermentation'];
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: 577
diff changeset
48 $sql .= "', log_ispindel='" . $_POST['log_ispindel'];
615
9034e65b0d7a Added CO2 carbonation log to the products database. Added button in the packaging tab.
Michiel Broek <mbroek@mbse.eu>
parents: 611
diff changeset
49 $sql .= "', log_co2pressure='" . $_POST['log_co2pressure'];
252
b558f3dfcda3 Make sure all boolean values are saved correctly in the database.
Michiel Broek <mbroek@mbse.eu>
parents: 243
diff changeset
50 $sql .= "', inventory_reduced='" . $_POST['inventory_reduced'];
b558f3dfcda3 Make sure all boolean values are saved correctly in the database.
Michiel Broek <mbroek@mbse.eu>
parents: 243
diff changeset
51 $sql .= "', locked='" . $_POST['locked'];
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 // Equipment
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53 $sql .= "', eq_name='" . mysqli_real_escape_string($connect, $_POST['eq_name']);
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54 $sql .= "', eq_boil_size='" . $_POST['eq_boil_size'];
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 $sql .= "', eq_batch_size='" . $_POST['eq_batch_size'];
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56 $sql .= "', eq_tun_volume='" . $_POST['eq_tun_volume'];
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 $sql .= "', eq_tun_weight='" . $_POST['eq_tun_weight'];
119
ae5e8d740173 Renamed some fields in prod_main to prevent ambigous names with the join. Delete product also deletes the corresponding recipe. Fixed equipment load and save. Read data from the product main joined with prod_recipes completed. The brewday page is now almost complete, the calculations must be added.
Michiel Broek <mbroek@mbse.eu>
parents: 115
diff changeset
58 $sql .= "', eq_tun_specific_heat='" . $_POST['eq_tun_specific_heat'];
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
59 $sql .= "', eq_tun_material='" . $_POST['eq_tun_material'];
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60 $sql .= "', eq_tun_height='" . $_POST['eq_tun_height'];
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61 $sql .= "', eq_top_up_water='" . $_POST['eq_top_up_water'];
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62 $sql .= "', eq_trub_chiller_loss='" . $_POST['eq_trub_chiller_loss'];
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63 $sql .= "', eq_evap_rate='" . $_POST['eq_evap_rate'];
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 $sql .= "', eq_boil_time='" . $_POST['eq_boil_time'];
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65 $sql .= "', eq_calc_boil_volume='" . $_POST['eq_calc_boil_volume'];
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66 $sql .= "', eq_top_up_kettle='" . $_POST['eq_top_up_kettle'];
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 $sql .= "', eq_hop_utilization='" . $_POST['eq_hop_utilization'];
164
0a5abea575a9 Added the last tab, fermentation to the product editer.
Michiel Broek <mbroek@mbse.eu>
parents: 163
diff changeset
68 $sql .= "', eq_notes='" . mysqli_real_escape_string($connect, $_POST['eq_notes']);
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69 $sql .= "', eq_lauter_volume='" . $_POST['eq_lauter_volume'];
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70 $sql .= "', eq_lauter_height='" . $_POST['eq_lauter_height'];
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 $sql .= "', eq_lauter_deadspace='" . $_POST['eq_lauter_deadspace'];
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 $sql .= "', eq_kettle_volume='" . $_POST['eq_kettle_volume'];
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 $sql .= "', eq_kettle_height='" . $_POST['eq_kettle_height'];
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74 $sql .= "', eq_mash_volume='" . $_POST['eq_mash_volume'];
149
ff45488d480e Added some icons from Brewersfriend. They should be replaced someday. Added maximum mash weight setting to the equipment database. Usefull for brew automate and RIMS systems. During recipes import acid and base additions are translated. Brews and recipes now have 2 water sources. Added water mixer. Added basic water treatment, but not for pH yet. Redesigned the fermentables and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents: 121
diff changeset
75 $sql .= "', eq_mash_max='" . $_POST['eq_mash_max'];
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76 $sql .= "', eq_efficiency='" . $_POST['eq_efficiency'];
285
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
77 // brewdate
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
78 if ($_POST['brew_date_start'] == '')
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
79 $sql .= "', brew_date_start=NULL";
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
80 else
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
81 $sql .= "', brew_date_start='" . $_POST['brew_date_start'] . "'";
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
82 $sql .= ", brew_mash_ph='" . $_POST['brew_mash_ph'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
83 $sql .= "', brew_mash_sg='" . $_POST['brew_mash_sg'];
392
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
84 $sql .= "', brew_mash_efficiency='" . $_POST['brew_mash_efficiency'];
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
85 $sql .= "', brew_sparge_est='" . $_POST['brew_sparge_est'];
285
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
86 $sql .= "', brew_sparge_ph='" . $_POST['brew_sparge_ph'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
87 $sql .= "', brew_preboil_volume='" . $_POST['brew_preboil_volume'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
88 $sql .= "', brew_preboil_sg='" . $_POST['brew_preboil_sg'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
89 $sql .= "', brew_preboil_ph='" . $_POST['brew_preboil_ph'];
392
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
90 $sql .= "', brew_preboil_efficiency='" . $_POST['brew_preboil_efficiency'];
285
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
91 $sql .= "', brew_aboil_volume='" . $_POST['brew_aboil_volume'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
92 $sql .= "', brew_aboil_sg='" . $_POST['brew_aboil_sg'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
93 $sql .= "', brew_aboil_ph='" . $_POST['brew_aboil_ph'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
94 $sql .= "', brew_aboil_efficiency='" . $_POST['brew_aboil_efficiency'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
95 $sql .= "', brew_cooling_method='" . $_POST['brew_cooling_method'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
96 $sql .= "', brew_cooling_time='" . $_POST['brew_cooling_time'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
97 $sql .= "', brew_cooling_to='" . $_POST['brew_cooling_to'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
98 $sql .= "', brew_whirlpool9='" . $_POST['brew_whirlpool9'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
99 $sql .= "', brew_whirlpool7='" . $_POST['brew_whirlpool7'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
100 $sql .= "', brew_whirlpool6='" . $_POST['brew_whirlpool6'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
101 $sql .= "', brew_whirlpool2='" . $_POST['brew_whirlpool2'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
102 $sql .= "', brew_aeration_time='" . $_POST['brew_aeration_time'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
103 $sql .= "', brew_aeration_speed='" . $_POST['brew_aeration_speed'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
104 $sql .= "', brew_aeration_type='" . $_POST['brew_aeration_type'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
105 $sql .= "', brew_fermenter_volume='" . $_POST['brew_fermenter_volume'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
106 $sql .= "', brew_fermenter_extrawater='" . $_POST['brew_fermenter_extrawater'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
107 $sql .= "', brew_fermenter_tcloss='" . $_POST['brew_fermenter_tcloss'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
108 $sql .= "', brew_fermenter_sg='" . $_POST['brew_fermenter_sg'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
109 $sql .= "', brew_fermenter_ibu='" . $_POST['brew_fermenter_ibu'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
110 $sql .= "', brew_fermenter_color='" . $_POST['brew_fermenter_color'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
111 if ($_POST['brew_date_end'] == '')
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
112 $sql .= "', brew_date_end=NULL";
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
113 else
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
114 $sql .= "', brew_date_end='" . $_POST['brew_date_end'] . "'";
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
115 $sql .= ", og='" . $_POST['og'];
163
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
116 $sql .= "', fg='" . $_POST['fg'];
285
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
117 $sql .= "', primary_start_temp='" . $_POST['primary_start_temp'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
118 $sql .= "', primary_max_temp='" . $_POST['primary_max_temp'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
119 $sql .= "', primary_end_temp='" . $_POST['primary_end_temp'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
120 if ($_POST['primary_end_date'] == '')
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
121 $sql .= "', primary_end_date=NULL";
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
122 else
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
123 $sql .= "', primary_end_date='" . $_POST['primary_end_date'] ."'";
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
124 $sql .= ", primary_end_sg='" . $_POST['primary_end_sg'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
125 $sql .= "', secondary_temp='" . $_POST['secondary_temp'];
460
046ff5fdc96c Implemented products.secondary_end_sg field. The missing values are updated by the crontask.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
126 $sql .= "', secondary_end_sg='" . $_POST['secondary_end_sg'];
285
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
127 if ($_POST['secondary_end_date'] == '')
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
128 $sql .= "', secondary_end_date=NULL";
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
129 else
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
130 $sql .= "', secondary_end_date='" . $_POST['secondary_end_date'] ."'";
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
131 $sql .= ", tertiary_temp='" . $_POST['tertiary_temp'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
132 if ($_POST['package_date'] == '')
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
133 $sql .= "', package_date=NULL";
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
134 else
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
135 $sql .= "', package_date='" . $_POST['package_date'] ."'";
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: 411
diff changeset
136 $sql .= ", package_volume='" . $_POST['package_volume'];
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: 411
diff changeset
137 $sql .= "', package_infuse_amount='" . $_POST['package_infuse_amount'];
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: 411
diff changeset
138 $sql .= "', package_infuse_abv='" . $_POST['package_infuse_abv'];
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: 411
diff changeset
139 $sql .= "', package_infuse_notes='" . mysqli_real_escape_string($connect, $_POST['package_infuse_notes']);
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: 411
diff changeset
140 $sql .= "', package_abv='" . $_POST['package_abv'];
458
47b592993dd5 Version 0.3.15. Implemented final pH during packaging. Updated prod_new, prod_duplicate, prod_edit, rec_toproduct for this new field and several other fields added in previous versions.
Michiel Broek <mbroek@mbse.eu>
parents: 457
diff changeset
141 $sql .= "', package_ph='" . $_POST['package_ph'];
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: 411
diff changeset
142 $sql .= "', bottle_amount='" . $_POST['bottle_amount'];
285
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
143 $sql .= "', bottle_carbonation='" . $_POST['bottle_carbonation'];
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: 411
diff changeset
144 $sql .= "', bottle_priming_water='" . $_POST['bottle_priming_water'];
285
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
145 $sql .= "', bottle_priming_amount='" . $_POST['bottle_priming_amount'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
146 $sql .= "', bottle_carbonation_temp='" . $_POST['bottle_carbonation_temp'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
147 $sql .= "', keg_amount='" . $_POST['keg_amount'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
148 $sql .= "', keg_carbonation='" . $_POST['keg_carbonation'];
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: 411
diff changeset
149 $sql .= "', keg_priming_water='" . $_POST['keg_priming_water'];
285
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
150 $sql .= "', keg_priming_amount='" . $_POST['keg_priming_amount'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
151 $sql .= "', keg_carbonation_temp='" . $_POST['keg_carbonation_temp'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
152 $sql .= "', keg_forced_carb='" . $_POST['keg_forced_carb'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
153 $sql .= "', keg_pressure='" . $_POST['keg_pressure'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
154 $sql .= "', taste_notes='" . mysqli_real_escape_string($connect, $_POST['taste_notes']);
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
155 $sql .= "', taste_rate='" . $_POST['taste_rate'];
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
156 if ($_POST['taste_date'] == '')
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
157 $sql .= "', taste_date=NULL";
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
158 else
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
159 $sql .= "', taste_date='" . $_POST['taste_date'] . "'";
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
160 $sql .= ", taste_color='" . mysqli_real_escape_string($connect, $_POST['taste_color']);
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
161 $sql .= "', taste_transparency='" . mysqli_real_escape_string($connect, $_POST['taste_transparency']);
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
162 $sql .= "', taste_head='" . mysqli_real_escape_string($connect, $_POST['taste_head']);
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
163 $sql .= "', taste_aroma='" . mysqli_real_escape_string($connect, $_POST['taste_aroma']);
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
164 $sql .= "', taste_taste='" . mysqli_real_escape_string($connect, $_POST['taste_taste']);
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
165 $sql .= "', taste_mouthfeel='" . mysqli_real_escape_string($connect, $_POST['taste_mouthfeel']);
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
166 $sql .= "', taste_aftertaste='" . mysqli_real_escape_string($connect, $_POST['taste_aftertaste']);
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
167
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
168 /*
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
169 * Recipe part
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
170 */
163
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
171 $sql .= "', st_name='" . mysqli_real_escape_string($connect, $_POST['st_name']);
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
172 $sql .= "', st_letter='" . mysqli_real_escape_string($connect, $_POST['st_letter']);
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
173 $sql .= "', st_guide='" . mysqli_real_escape_string($connect, $_POST['st_guide']);
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
174 $sql .= "', st_type='" . $_POST['st_type'];
163
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
175 $sql .= "', st_category='" . mysqli_real_escape_string($connect, $_POST['st_category']);
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
176 $sql .= "', st_category_number='" . $_POST['st_category_number'];
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
177 $sql .= "', st_og_min='" . $_POST['st_og_min'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
178 $sql .= "', st_og_max='" . $_POST['st_og_max'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
179 $sql .= "', st_fg_min='" . $_POST['st_fg_min'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
180 $sql .= "', st_fg_max='" . $_POST['st_fg_max'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
181 $sql .= "', st_ibu_min='" . $_POST['st_ibu_min'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
182 $sql .= "', st_ibu_max='" . $_POST['st_ibu_max'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
183 $sql .= "', st_color_min='" . $_POST['st_color_min'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
184 $sql .= "', st_color_max='" . $_POST['st_color_max'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
185 $sql .= "', st_carb_min='" . $_POST['st_carb_min'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
186 $sql .= "', st_carb_max='" . $_POST['st_carb_max'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
187 $sql .= "', st_abv_min='" . $_POST['st_abv_min'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
188 $sql .= "', st_abv_max='" . $_POST['st_abv_max'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
189 $sql .= "', type='" . $_POST['type'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
190 $sql .= "', batch_size='" . $_POST['batch_size'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
191 $sql .= "', boil_size='" . $_POST['boil_size'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
192 $sql .= "', boil_time='" . $_POST['boil_time'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
193 $sql .= "', efficiency='" . $_POST['efficiency'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
194 $sql .= "', est_og='" . $_POST['est_og'];
616
2cbf21bb9bdc Added est_og3 field in the products database so that the checklist can use it.
Michiel Broek <mbroek@mbse.eu>
parents: 615
diff changeset
195 $sql .= "', est_og3='" . $_POST['est_og3'];
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
196 $sql .= "', est_fg='" . $_POST['est_fg'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
197 $sql .= "', est_abv='" . $_POST['est_abv'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
198 $sql .= "', est_carb='" . $_POST['est_carb'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
199 $sql .= "', est_color='" . $_POST['est_color'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
200 $sql .= "', color_method='" . $_POST['color_method'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
201 $sql .= "', est_ibu='" . $_POST['est_ibu'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
202 $sql .= "', ibu_method='" . $_POST['ibu_method'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
203 $sql .= "', sparge_temp='" . $_POST['sparge_temp'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
204 $sql .= "', sparge_ph='" . $_POST['sparge_ph'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
205 $sql .= "', sparge_volume='" . $_POST['sparge_volume'];
159
6428dae0605d Backport water treatment to the product editor (inluding the bugs).
Michiel Broek <mbroek@mbse.eu>
parents: 151
diff changeset
206 $sql .= "', sparge_source='" . $_POST['sparge_source'];
6428dae0605d Backport water treatment to the product editor (inluding the bugs).
Michiel Broek <mbroek@mbse.eu>
parents: 151
diff changeset
207 $sql .= "', sparge_acid_type='" . $_POST['sparge_acid_type'];
6428dae0605d Backport water treatment to the product editor (inluding the bugs).
Michiel Broek <mbroek@mbse.eu>
parents: 151
diff changeset
208 $sql .= "', sparge_acid_perc='" . $_POST['sparge_acid_perc'];
6428dae0605d Backport water treatment to the product editor (inluding the bugs).
Michiel Broek <mbroek@mbse.eu>
parents: 151
diff changeset
209 $sql .= "', sparge_acid_amount='" . $_POST['sparge_acid_amount'];
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
210 $sql .= "', mash_ph='" . $_POST['mash_ph'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
211 $sql .= "', mash_name='" . $_POST['mash_name'];
252
b558f3dfcda3 Make sure all boolean values are saved correctly in the database.
Michiel Broek <mbroek@mbse.eu>
parents: 243
diff changeset
212 $sql .= "', calc_acid='" . $_POST['calc_acid'];
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
213 if (isset($_POST['w1_name'])) {
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
214 $sql .= "', w1_name='" . mysqli_real_escape_string($connect, $_POST['w1_name']);
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
215 $sql .= "', w1_amount='" . $_POST['w1_amount'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
216 $sql .= "', w1_calcium='" . $_POST['w1_calcium'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
217 $sql .= "', w1_sulfate='" . $_POST['w1_sulfate'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
218 $sql .= "', w1_chloride='" . $_POST['w1_chloride'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
219 $sql .= "', w1_sodium='" . $_POST['w1_sodium'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
220 $sql .= "', w1_magnesium='" . $_POST['w1_magnesium'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
221 $sql .= "', w1_total_alkalinity='" . $_POST['w1_total_alkalinity'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
222 $sql .= "', w1_ph='" . $_POST['w1_ph'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
223 $sql .= "', w1_cost='" . $_POST['w1_cost'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
224 }
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
225 if (isset($_POST['w2_name'])) {
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
226 $sql .= "', w2_name='" . mysqli_real_escape_string($connect, $_POST['w2_name']);
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
227 $sql .= "', w2_amount='" . $_POST['w2_amount'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
228 $sql .= "', w2_calcium='" . $_POST['w2_calcium'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
229 $sql .= "', w2_sulfate='" . $_POST['w2_sulfate'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
230 $sql .= "', w2_chloride='" . $_POST['w2_chloride'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
231 $sql .= "', w2_sodium='" . $_POST['w2_sodium'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
232 $sql .= "', w2_magnesium='" . $_POST['w2_magnesium'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
233 $sql .= "', w2_total_alkalinity='" . $_POST['w2_total_alkalinity'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
234 $sql .= "', w2_ph='" . $_POST['w2_ph'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
235 $sql .= "', w2_cost='" . $_POST['w2_cost'];
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
236 }
392
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
237 $sql .= "', wg_amount='" . $_POST['wg_amount'];
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
238 $sql .= "', wg_calcium='" . $_POST['wg_calcium'];
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
239 $sql .= "', wg_sulfate='" . $_POST['wg_sulfate'];
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
240 $sql .= "', wg_chloride='" . $_POST['wg_chloride'];
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
241 $sql .= "', wg_sodium='" . $_POST['wg_sodium'];
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
242 $sql .= "', wg_magnesium='" . $_POST['wg_magnesium'];
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
243 $sql .= "', wg_total_alkalinity='" . $_POST['wg_total_alkalinity'];
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
244 $sql .= "', wg_ph='" . $_POST['wg_ph'];
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
245 $sql .= "', wb_calcium='" . $_POST['wb_calcium'];
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
246 $sql .= "', wb_sulfate='" . $_POST['wb_sulfate'];
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
247 $sql .= "', wb_chloride='" . $_POST['wb_chloride'];
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
248 $sql .= "', wb_sodium='" . $_POST['wb_sodium'];
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
249 $sql .= "', wb_magnesium='" . $_POST['wb_magnesium'];
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
250 $sql .= "', wb_total_alkalinity='" . $_POST['wb_total_alkalinity'];
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
251 $sql .= "', wb_ph='" . $_POST['wb_ph'];
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
252 $sql .= "', wa_acid_name='" . $_POST['wa_acid_name'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
253 $sql .= "', wa_acid_perc='" . $_POST['wa_acid_perc'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
254 $sql .= "', wa_base_name='" . $_POST['wa_base_name'];
375
7f5455806f20 Reset starter values when saving a product without a starter. The yeast calculator only calculates a starter when enabled. Calculate the cells/ml/plato field. Disable starter buttons when the product brewday is over.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
255 if ($_POST['starter_enable'] == 0) {
518
00e110567fee The default starter SG changed to 1.037. Added several tooltips on the yeast tab.
Michiel Broek <mbroek@mbse.eu>
parents: 517
diff changeset
256 $sql .= "', starter_enable='0', starter_type='0', starter_sg='1.037', starter_viability='97";
375
7f5455806f20 Reset starter values when saving a product without a starter. The yeast calculator only calculates a starter when enabled. Calculate the cells/ml/plato field. Disable starter buttons when the product brewday is over.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
257 $sql .= "', prop1_type='0', prop1_volume='0', prop2_type='0', prop2_volume='0";
7f5455806f20 Reset starter values when saving a product without a starter. The yeast calculator only calculates a starter when enabled. Calculate the cells/ml/plato field. Disable starter buttons when the product brewday is over.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
258 $sql .= "', prop3_type='0', prop3_volume='0', prop4_type='0', prop4_volume='0";
7f5455806f20 Reset starter values when saving a product without a starter. The yeast calculator only calculates a starter when enabled. Calculate the cells/ml/plato field. Disable starter buttons when the product brewday is over.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
259 } else {
7f5455806f20 Reset starter values when saving a product without a starter. The yeast calculator only calculates a starter when enabled. Calculate the cells/ml/plato field. Disable starter buttons when the product brewday is over.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
260 $sql .= "', starter_enable='1";
7f5455806f20 Reset starter values when saving a product without a starter. The yeast calculator only calculates a starter when enabled. Calculate the cells/ml/plato field. Disable starter buttons when the product brewday is over.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
261 $sql .= "', starter_type='" . $_POST['starter_type'];
7f5455806f20 Reset starter values when saving a product without a starter. The yeast calculator only calculates a starter when enabled. Calculate the cells/ml/plato field. Disable starter buttons when the product brewday is over.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
262 $sql .= "', starter_sg='" . $_POST['starter_sg'];
457
b9055393b802 Version 0.3.14. Added yeast viability calculations for liquid yeast packs.
Michiel Broek <mbroek@mbse.eu>
parents: 432
diff changeset
263 $sql .= "', starter_viability='" . $_POST['starter_viability'];
375
7f5455806f20 Reset starter values when saving a product without a starter. The yeast calculator only calculates a starter when enabled. Calculate the cells/ml/plato field. Disable starter buttons when the product brewday is over.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
264 $sql .= "', prop1_type='" . $_POST['prop1_type'];
7f5455806f20 Reset starter values when saving a product without a starter. The yeast calculator only calculates a starter when enabled. Calculate the cells/ml/plato field. Disable starter buttons when the product brewday is over.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
265 $sql .= "', prop1_volume='" . $_POST['prop1_volume'];
7f5455806f20 Reset starter values when saving a product without a starter. The yeast calculator only calculates a starter when enabled. Calculate the cells/ml/plato field. Disable starter buttons when the product brewday is over.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
266 $sql .= "', prop2_type='" . $_POST['prop2_type'];
7f5455806f20 Reset starter values when saving a product without a starter. The yeast calculator only calculates a starter when enabled. Calculate the cells/ml/plato field. Disable starter buttons when the product brewday is over.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
267 $sql .= "', prop2_volume='" . $_POST['prop2_volume'];
7f5455806f20 Reset starter values when saving a product without a starter. The yeast calculator only calculates a starter when enabled. Calculate the cells/ml/plato field. Disable starter buttons when the product brewday is over.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
268 $sql .= "', prop3_type='" . $_POST['prop3_type'];
7f5455806f20 Reset starter values when saving a product without a starter. The yeast calculator only calculates a starter when enabled. Calculate the cells/ml/plato field. Disable starter buttons when the product brewday is over.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
269 $sql .= "', prop3_volume='" . $_POST['prop3_volume'];
7f5455806f20 Reset starter values when saving a product without a starter. The yeast calculator only calculates a starter when enabled. Calculate the cells/ml/plato field. Disable starter buttons when the product brewday is over.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
270 $sql .= "', prop4_type='" . $_POST['prop4_type'];
7f5455806f20 Reset starter values when saving a product without a starter. The yeast calculator only calculates a starter when enabled. Calculate the cells/ml/plato field. Disable starter buttons when the product brewday is over.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
271 $sql .= "', prop4_volume='" . $_POST['prop4_volume'];
7f5455806f20 Reset starter values when saving a product without a starter. The yeast calculator only calculates a starter when enabled. Calculate the cells/ml/plato field. Disable starter buttons when the product brewday is over.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
272 }
617
f962f1e5936e Implemented yeast viability calculation from the yeast production date. Changed the pitchrate logic and added Ale above 1.076 rate of 1.25.
Michiel Broek <mbroek@mbse.eu>
parents: 616
diff changeset
273 if ($_POST['yeast_prod_date'] == '')
f962f1e5936e Implemented yeast viability calculation from the yeast production date. Changed the pitchrate logic and added Ale above 1.076 rate of 1.25.
Michiel Broek <mbroek@mbse.eu>
parents: 616
diff changeset
274 $sql .= "', yeast_prod_date=NULL";
f962f1e5936e Implemented yeast viability calculation from the yeast production date. Changed the pitchrate logic and added Ale above 1.076 rate of 1.25.
Michiel Broek <mbroek@mbse.eu>
parents: 616
diff changeset
275 else
f962f1e5936e Implemented yeast viability calculation from the yeast production date. Changed the pitchrate logic and added Ale above 1.076 rate of 1.25.
Michiel Broek <mbroek@mbse.eu>
parents: 616
diff changeset
276 $sql .= "', yeast_prod_date='" . $_POST['yeast_prod_date'] . "'";
697
367ae7ff52f0 Version 0.3.34 Changed log messages in the daemon. Added yeast_pitchrate field to the product database. Added yeast pitchrate edit field to the yeast tab. Initial value is guessed. There is also a popup window for predefined values. An finally the value can be edited by the user. All popup windows are initialized together.
Michiel Broek <mbroek@mbse.eu>
parents: 667
diff changeset
277 $sql .= ", yeast_pitchrate='" . floatval($_POST['yeast_pitchrate']);
367ae7ff52f0 Version 0.3.34 Changed log messages in the daemon. Added yeast_pitchrate field to the product database. Added yeast pitchrate edit field to the yeast tab. Initial value is guessed. There is also a popup window for predefined values. An finally the value can be edited by the user. All popup windows are initialized together.
Michiel Broek <mbroek@mbse.eu>
parents: 667
diff changeset
278 $sql .= "', divide_type='" . $_POST['divide_type'];
533
be8691b7d634 Added the product divide scripts. All parts have all the volumes and weights divided, including the master record. Splitted batches have their own records with the product code formatted as code-n. From this design, we can rebuild the print and checklist.
Michiel Broek <mbroek@mbse.eu>
parents: 518
diff changeset
279 $sql .= "', divide_size='" . floatval($_POST['divide_size']);
be8691b7d634 Added the product divide scripts. All parts have all the volumes and weights divided, including the master record. Splitted batches have their own records with the product code formatted as code-n. From this design, we can rebuild the print and checklist.
Michiel Broek <mbroek@mbse.eu>
parents: 518
diff changeset
280 $sql .= "', divide_factor='" . floatval($_POST['divide_factor']);
497
0fe366d953ab Prepare screens for product divide batch.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
281 $sql .= "', divide_parts='" . $_POST['divide_parts'];
533
be8691b7d634 Added the product divide scripts. All parts have all the volumes and weights divided, including the master record. Splitted batches have their own records with the product code formatted as code-n. From this design, we can rebuild the print and checklist.
Michiel Broek <mbroek@mbse.eu>
parents: 518
diff changeset
282 $sql .= "', divide_part='" . $_POST['divide_part'];
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
283
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
284 $fermentables = '[';
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
285 $comma = FALSE;
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
286 if (isset($_POST['fermentables'])) {
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
287 $array = $_POST['fermentables'];
394
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
288 // Sort the array
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
289 $added = array();
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
290 $amount = array();
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
291 for ($i = 0; $i < count($array); $i++) {
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
292 $added[] = $array[$i]['f_added'];
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
293 $amount[] = $array[$i]['f_amount'];
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
294 }
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
295 array_multisort($added, SORT_ASC, SORT_NUMERIC,
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
296 $amount, SORT_DESC, SORT_NUMERIC,
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
297 $array);
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
298 // Write the sorted array.
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
299 foreach($array as $key => $item){
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
300 /*
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
301 * Manual encode to json.
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
302 */
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
303 if ($comma)
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
304 $fermentables .= ',';
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
305 $comma = TRUE;
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
306 $fermentable = '{"f_name":"' . str_replace($rescapers,$rreplacements,$item['f_name']);
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
307 $fermentable .= '","f_origin":"' . str_replace($rescapers,$rreplacements,$item['f_origin']);
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
308 $fermentable .= '","f_supplier":"' . str_replace($rescapers,$rreplacements,$item['f_supplier']);
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
309 $fermentable .= '","f_amount":' . $item['f_amount'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
310 $fermentable .= ',"f_cost":' . $item['f_cost'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
311 $fermentable .= ',"f_type":' . $item['f_type'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
312 $fermentable .= ',"f_yield":' . $item['f_yield'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
313 $fermentable .= ',"f_color":' . $item['f_color'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
314 $fermentable .= ',"f_coarse_fine_diff":' . $item['f_coarse_fine_diff'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
315 $fermentable .= ',"f_moisture":' . $item['f_moisture'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
316 $fermentable .= ',"f_diastatic_power":' . $item['f_diastatic_power'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
317 $fermentable .= ',"f_protein":' . $item['f_protein'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
318 $fermentable .= ',"f_dissolved_protein":' . $item['f_dissolved_protein'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
319 $fermentable .= ',"f_max_in_batch":' . $item['f_max_in_batch'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
320 $fermentable .= ',"f_graintype":' . $item['f_graintype'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
321 $fermentable .= ',"f_added":' . $item['f_added'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
322 $fermentable .= ',"f_recommend_mash":' . $item['f_recommend_mash'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
323 $fermentable .= ',"f_add_after_boil":' . $item['f_add_after_boil'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
324 $fermentable .= ',"f_adjust_to_total_100":' . $item['f_adjust_to_total_100'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
325 $fermentable .= ',"f_percentage":' . $item['f_percentage'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
326 $fermentable .= ',"f_di_ph":' . $item['f_di_ph'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
327 $fermentable .= ',"f_acid_to_ph_57":' . $item['f_acid_to_ph_57'] . '}';
285
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
328 //syslog(LOG_NOTICE, $fermentable);
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
329 $fermentables .= $fermentable;
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
330 }
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
331 }
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
332 $fermentables .= ']';
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
333 $sql .= "', json_fermentables='" . $fermentables;
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
334
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
335 $hops = '[';
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
336 $comma = FALSE;
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
337 if (isset($_POST['hops'])) {
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
338 $array = $_POST['hops'];
394
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
339 // Sort the array
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
340 $useat = array();
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
341 $time = array();
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
342 $amount = array();
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
343 for ($i = 0; $i < count($array); $i++) {
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
344 $useat[] = $array[$i]['h_useat'];
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
345 $time[] = $array[$i]['h_time'];
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
346 $amount[] = $array[$i]['h_amount'];
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
347 }
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
348 array_multisort($useat, SORT_ASC, SORT_NUMERIC,
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
349 $time, SORT_DESC, SORT_NUMERIC,
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
350 $amount, SORT_DESC, SORT_NUMERIC,
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
351 $array);
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
352 // Write the sorted array.
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
353 foreach($array as $key => $item){
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
354 if ($comma)
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
355 $hops .= ',';
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
356 $comma = TRUE;
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
357 $hop = '{"h_name":"' . str_replace($rescapers,$rreplacements,$item['h_name']);
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
358 $hop .= '","h_origin":"' . str_replace($rescapers,$rreplacements,$item['h_origin']);
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
359 $hop .= '","h_amount":' . $item['h_amount'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
360 $hop .= ',"h_cost":' . $item['h_cost'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
361 $hop .= ',"h_type":' . $item['h_type'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
362 $hop .= ',"h_form":' . $item['h_form'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
363 $hop .= ',"h_useat":' . $item['h_useat'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
364 $hop .= ',"h_time":' . $item['h_time'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
365 $hop .= ',"h_alpha":' . $item['h_alpha'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
366 $hop .= ',"h_beta":' . $item['h_beta'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
367 $hop .= ',"h_hsi":' . $item['h_hsi'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
368 $hop .= ',"h_humulene":' . $item['h_humulene'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
369 $hop .= ',"h_caryophyllene":' . $item['h_caryophyllene'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
370 $hop .= ',"h_cohumulone":' . $item['h_cohumulone'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
371 $hop .= ',"h_myrcene":' . $item['h_myrcene'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
372 $hop .= ',"h_total_oil":' . $item['h_total_oil'] . '}';
285
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
373 //syslog(LOG_NOTICE, $hop);
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
374 $hops .= $hop;
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
375 }
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
376 }
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
377 $hops .= ']';
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
378 $sql .= "', json_hops='" . $hops;
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
379
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
380 $miscs = '[';
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
381 $comma = FALSE;
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
382 if (isset($_POST['miscs'])) {
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
383 $array = $_POST['miscs'];
394
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
384 // Sort the array
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
385 $use = array();
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
386 $type = array();
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
387 $amount = array();
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
388 for ($i = 0; $i < count($array); $i++) {
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
389 $use[] = $array[$i]['m_use_use'];
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
390 $type[] = $array[$i]['m_type'];
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
391 $amount[] = $array[$i]['m_amount'];
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
392 }
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
393 array_multisort($use, SORT_ASC, SORT_NUMERIC,
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
394 $type, SORT_ASC, SORT_NUMERIC,
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
395 $amount, SORT_DESC, SORT_NUMERIC,
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
396 $array);
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
397 // Write the sorted array.
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
398 foreach($array as $key => $item){
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
399 if ($comma)
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
400 $miscs .= ',';
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
401 $comma = TRUE;
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
402 $misc = '{"m_name":"' . str_replace($rescapers,$rreplacements,$item['m_name']);
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
403 $misc .= '","m_amount":' . $item['m_amount'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
404 $misc .= ',"m_type":' . $item['m_type'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
405 $misc .= ',"m_use_use":' . $item['m_use_use'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
406 $misc .= ',"m_time":' . $item['m_time'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
407 $misc .= ',"m_amount_is_weight":' . $item['m_amount_is_weight'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
408 $misc .= ',"m_cost":' . $item['m_cost'] . '}';
285
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
409 //syslog(LOG_NOTICE, $misc);
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
410 $miscs .= $misc;
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
411 }
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
412 }
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
413 $miscs .= ']';
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
414 $sql .= "', json_miscs='" . $miscs;
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
415
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
416 $yeasts = '[';
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
417 $comma = FALSE;
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
418 if (isset($_POST['yeasts'])) {
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
419 $array = $_POST['yeasts'];
394
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
420 // Sort the array
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
421 $use = array();
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
422 $amount = array();
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
423 for ($i = 0; $i < count($array); $i++) {
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
424 $use[] = $array[$i]['y_use'];
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
425 $amount[] = $array[$i]['y_amount'];
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
426 }
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
427 array_multisort($use, SORT_ASC, SORT_NUMERIC,
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
428 $amount, SORT_DESC, SORT_NUMERIC,
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
429 $array);
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 393
diff changeset
430 // Write the sorted array.
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
431 foreach($array as $key => $item){
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
432 if ($comma)
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
433 $yeasts .= ',';
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
434 $comma = TRUE;
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
435 $yeast = '{"y_name":"' . str_replace($rescapers,$rreplacements,$item['y_name']);
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
436 $yeast .= '","y_laboratory":"' . str_replace($rescapers,$rreplacements,$item['y_laboratory']);
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
437 $yeast .= '","y_product_id":"' . str_replace($rescapers,$rreplacements,$item['y_product_id']);
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
438 $yeast .= '","y_amount":' . $item['y_amount'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
439 $yeast .= ',"y_type":' . $item['y_type'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
440 $yeast .= ',"y_form":' . $item['y_form'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
441 $yeast .= ',"y_min_temperature":' . $item['y_min_temperature'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
442 $yeast .= ',"y_max_temperature":' . $item['y_max_temperature'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
443 $yeast .= ',"y_flocculation":' . $item['y_flocculation'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
444 $yeast .= ',"y_attenuation":' . $item['y_attenuation'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
445 $yeast .= ',"y_cells":' . $item['y_cells'];
332
f0ca77097236 Display alcohol tolerance in the yeast editor. Display in red when the recipe estimate is higher then the yeast tolerance.
Michiel Broek <mbroek@mbse.eu>
parents: 326
diff changeset
446 $yeast .= ',"y_tolerance":' . $item['y_tolerance'];
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
447 $yeast .= ',"y_inventory":' . $item['y_inventory'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
448 $yeast .= ',"y_use":' . $item['y_use'];
554
c62ff53cfc3d Added the new Kveik yeast fields to the product editor. Added auto update when a product is loaded. Added extra lines to the checklist about harvest yeast and pitch temperature.
Michiel Broek <mbroek@mbse.eu>
parents: 533
diff changeset
449 $yeast .= ',"y_sta1":' . $item['y_sta1'];
c62ff53cfc3d Added the new Kveik yeast fields to the product editor. Added auto update when a product is loaded. Added extra lines to the checklist about harvest yeast and pitch temperature.
Michiel Broek <mbroek@mbse.eu>
parents: 533
diff changeset
450 $yeast .= ',"y_bacteria":' . $item['y_bacteria'];
c62ff53cfc3d Added the new Kveik yeast fields to the product editor. Added auto update when a product is loaded. Added extra lines to the checklist about harvest yeast and pitch temperature.
Michiel Broek <mbroek@mbse.eu>
parents: 533
diff changeset
451 $yeast .= ',"y_harvest_top":' . $item['y_harvest_top'];
c62ff53cfc3d Added the new Kveik yeast fields to the product editor. Added auto update when a product is loaded. Added extra lines to the checklist about harvest yeast and pitch temperature.
Michiel Broek <mbroek@mbse.eu>
parents: 533
diff changeset
452 $yeast .= ',"y_harvest_time":' . $item['y_harvest_time'];
c62ff53cfc3d Added the new Kveik yeast fields to the product editor. Added auto update when a product is loaded. Added extra lines to the checklist about harvest yeast and pitch temperature.
Michiel Broek <mbroek@mbse.eu>
parents: 533
diff changeset
453 $yeast .= ',"y_pitch_temperature":' . $item['y_pitch_temperature'];
c62ff53cfc3d Added the new Kveik yeast fields to the product editor. Added auto update when a product is loaded. Added extra lines to the checklist about harvest yeast and pitch temperature.
Michiel Broek <mbroek@mbse.eu>
parents: 533
diff changeset
454 $yeast .= ',"y_pofpos":' . $item['y_pofpos'];
c62ff53cfc3d Added the new Kveik yeast fields to the product editor. Added auto update when a product is loaded. Added extra lines to the checklist about harvest yeast and pitch temperature.
Michiel Broek <mbroek@mbse.eu>
parents: 533
diff changeset
455 $yeast .= ',"y_zymocide":' . $item['y_zymocide'];
726
872a3635e4ef Changed dry-yeast calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
456 $yeast .= ',"y_gr_hl_lo":' . $item['y_gr_hl_lo'];
872a3635e4ef Changed dry-yeast calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
457 $yeast .= ',"y_sg_lo":' . $item['y_sg_lo'];
872a3635e4ef Changed dry-yeast calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
458 $yeast .= ',"y_gr_hl_hi":' . $item['y_gr_hl_hi'];
872a3635e4ef Changed dry-yeast calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
459 $yeast .= ',"y_sg_hi":' . $item['y_sg_hi'];
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
460 $yeast .= ',"y_cost":' . $item['y_cost'] . '}';
285
0ea9dfb3fce9 Fixed save empty dates
Michiel Broek <mbroek@mbse.eu>
parents: 278
diff changeset
461 //syslog(LOG_NOTICE, $yeast);
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
462 $yeasts .= $yeast;
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
463 }
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
464 }
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
465 $yeasts .= ']';
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
466 $sql .= "', json_yeasts='" . $yeasts;
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
467
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
468 $mashs = '[';
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
469 $comma = FALSE;
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
470 if (isset($_POST['mashs'])) {
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
471 $array = $_POST['mashs'];
667
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 617
diff changeset
472 // Write the array and fix missing data.
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
473 foreach($array as $key => $item){
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
474 if ($comma)
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
475 $mashs .= ',';
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
476 $comma = TRUE;
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
477 $mash = '{"step_name":"' . str_replace($rescapers,$rreplacements,$item['step_name']);
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
478 $mash .= '","step_type":' . $item['step_type'];
667
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 617
diff changeset
479 if (isset($item['step_volume']) && $item['step_volume'] != "")
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 617
diff changeset
480 $mash .= ',"step_volume":' . $item['step_volume'];
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 617
diff changeset
481 else
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 617
diff changeset
482 $mash .= ',"step_volume":0';
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
483 if (isset($item['step_infuse_amount']) && $item['step_infuse_amount'] != "")
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
484 $mash .= ',"step_infuse_amount":' . $item['step_infuse_amount'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
485 else
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
486 $mash .= ',"step_infuse_amount":0';
667
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 617
diff changeset
487 if (isset($item['step_infuse_temp']) && $item['step_infuse_temp'] != "")
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 617
diff changeset
488 $mash .= ',"step_infuse_temp":' . $item['step_infuse_temp'];
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 617
diff changeset
489 else
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 617
diff changeset
490 $mash .= ',"step_infuse_temp":0';
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
491 $mash .= ',"step_temp":' . $item['step_temp'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
492 $mash .= ',"step_time":' . $item['step_time'];
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
493 $mash .= ',"ramp_time":' . $item['ramp_time'];
667
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 617
diff changeset
494 $mash .= ',"end_temp":' . $item['end_temp'];
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 617
diff changeset
495 if (isset($item['step_wg_ratio']) && $item['step_wg_ratio'] != "")
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 617
diff changeset
496 $mash .= ',"step_wg_ratio":' . $item['step_wg_ratio'];
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 617
diff changeset
497 else
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 617
diff changeset
498 $mash .= ',"step_wg_ratio":0';
738
11e6bd8d8107 Added mash SG and pH fields. Fixed default Yeast update. Added mash step SG and pH input datafields. Added a Brix input too. The print report shows the mash measurements too. Other brewing results now show expected and measured values and the difference.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
499 if (isset($item['step_ph']) && $item['step_ph'] != "")
11e6bd8d8107 Added mash SG and pH fields. Fixed default Yeast update. Added mash step SG and pH input datafields. Added a Brix input too. The print report shows the mash measurements too. Other brewing results now show expected and measured values and the difference.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
500 $mash .= ',"step_ph":' . $item['step_ph'];
11e6bd8d8107 Added mash SG and pH fields. Fixed default Yeast update. Added mash step SG and pH input datafields. Added a Brix input too. The print report shows the mash measurements too. Other brewing results now show expected and measured values and the difference.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
501 else
11e6bd8d8107 Added mash SG and pH fields. Fixed default Yeast update. Added mash step SG and pH input datafields. Added a Brix input too. The print report shows the mash measurements too. Other brewing results now show expected and measured values and the difference.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
502 $mash .= ',"step_ph":0.0';
11e6bd8d8107 Added mash SG and pH fields. Fixed default Yeast update. Added mash step SG and pH input datafields. Added a Brix input too. The print report shows the mash measurements too. Other brewing results now show expected and measured values and the difference.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
503 if (isset($item['step_sg']) && $item['step_sg'] != "")
11e6bd8d8107 Added mash SG and pH fields. Fixed default Yeast update. Added mash step SG and pH input datafields. Added a Brix input too. The print report shows the mash measurements too. Other brewing results now show expected and measured values and the difference.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
504 $mash .= ',"step_sg":' . $item['step_sg'];
11e6bd8d8107 Added mash SG and pH fields. Fixed default Yeast update. Added mash step SG and pH input datafields. Added a Brix input too. The print report shows the mash measurements too. Other brewing results now show expected and measured values and the difference.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
505 else
11e6bd8d8107 Added mash SG and pH fields. Fixed default Yeast update. Added mash step SG and pH input datafields. Added a Brix input too. The print report shows the mash measurements too. Other brewing results now show expected and measured values and the difference.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
506 $mash .= ',"step_sg":0.0';
667
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 617
diff changeset
507 $mash .= '}';
706
12f9316de113 Less logging in the db_product interface. Fixed some empty default values that bugged the newer php and mariadb versions.
Michiel Broek <mbroek@mbse.eu>
parents: 697
diff changeset
508 //syslog(LOG_NOTICE, $mash);
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
509 $mashs .= $mash;
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
510 }
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
511 }
238
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
512 $mashs .= ']';
8e7384587a10 Adjusted product save into the database.
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
513 $sql .= "', json_mashs='" . $mashs;
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
514
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
515 if (isset($_POST['insert'])) {
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
516 $sql .= "';";
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
517 }
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
518 if (isset($_POST['update'])) {
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
519 $sql .= "' WHERE record='" . $_POST['record'] . "';";
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
520 }
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
521
159
6428dae0605d Backport water treatment to the product editor (inluding the bugs).
Michiel Broek <mbroek@mbse.eu>
parents: 151
diff changeset
522 $result = mysqli_query($connect, $sql);
6428dae0605d Backport water treatment to the product editor (inluding the bugs).
Michiel Broek <mbroek@mbse.eu>
parents: 151
diff changeset
523 if (! $result) {
757
d13be50c0049 Added error handler
Michiel Broek <mbroek@mbse.eu>
parents: 740
diff changeset
524 syslog(LOG_NOTICE, "db_product: result: ".mysqli_error($connect));
d13be50c0049 Added error handler
Michiel Broek <mbroek@mbse.eu>
parents: 740
diff changeset
525 $response['error'] = true;
768
ae1195153fa2 Better error reporting in profiles fermentation steps, mash profiles, beer styles, water profiles and general setup.
Michiel Broek <mbroek@mbse.eu>
parents: 763
diff changeset
526 $response['msg'] = "SQL fout: ".mysqli_error($connect);
159
6428dae0605d Backport water treatment to the product editor (inluding the bugs).
Michiel Broek <mbroek@mbse.eu>
parents: 151
diff changeset
527 } else {
6428dae0605d Backport water treatment to the product editor (inluding the bugs).
Michiel Broek <mbroek@mbse.eu>
parents: 151
diff changeset
528 if (isset($_POST['update'])) {
711
0a1be3bfcc60 Removed some debug messages in products and recipes
Michiel Broek <mbroek@mbse.eu>
parents: 706
diff changeset
529 //syslog(LOG_NOTICE, "db_product: updated record ".$_POST['record']);
393
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
530 inventory_reduce();
159
6428dae0605d Backport water treatment to the product editor (inluding the bugs).
Michiel Broek <mbroek@mbse.eu>
parents: 151
diff changeset
531 } else {
6428dae0605d Backport water treatment to the product editor (inluding the bugs).
Michiel Broek <mbroek@mbse.eu>
parents: 151
diff changeset
532 $lastid = mysqli_insert_id($connect);
6428dae0605d Backport water treatment to the product editor (inluding the bugs).
Michiel Broek <mbroek@mbse.eu>
parents: 151
diff changeset
533 }
6428dae0605d Backport water treatment to the product editor (inluding the bugs).
Michiel Broek <mbroek@mbse.eu>
parents: 151
diff changeset
534 }
757
d13be50c0049 Added error handler
Michiel Broek <mbroek@mbse.eu>
parents: 740
diff changeset
535 echo json_encode($response);
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
536
500
8d53ad389204 Reworked the splitted batches, the data is now in a separate table and there is only one product record.
Michiel Broek <mbroek@mbse.eu>
parents: 499
diff changeset
537 } else if (isset($_POST['splitit'])) {
8d53ad389204 Reworked the splitted batches, the data is now in a separate table and there is only one product record.
Michiel Broek <mbroek@mbse.eu>
parents: 499
diff changeset
538 /*
8d53ad389204 Reworked the splitted batches, the data is now in a separate table and there is only one product record.
Michiel Broek <mbroek@mbse.eu>
parents: 499
diff changeset
539 * Update split batch details
8d53ad389204 Reworked the splitted batches, the data is now in a separate table and there is only one product record.
Michiel Broek <mbroek@mbse.eu>
parents: 499
diff changeset
540 */
8d53ad389204 Reworked the splitted batches, the data is now in a separate table and there is only one product record.
Michiel Broek <mbroek@mbse.eu>
parents: 499
diff changeset
541 $sql = "UPDATE `products` SET ";
8d53ad389204 Reworked the splitted batches, the data is now in a separate table and there is only one product record.
Michiel Broek <mbroek@mbse.eu>
parents: 499
diff changeset
542 $sql .= "divide_type='" . $_POST['divide_type'];
8d53ad389204 Reworked the splitted batches, the data is now in a separate table and there is only one product record.
Michiel Broek <mbroek@mbse.eu>
parents: 499
diff changeset
543 $sql .= "', divide_size='" . $_POST['divide_size'];
8d53ad389204 Reworked the splitted batches, the data is now in a separate table and there is only one product record.
Michiel Broek <mbroek@mbse.eu>
parents: 499
diff changeset
544 $sql .= "', divide_parts='" . $_POST['divide_parts'];
8d53ad389204 Reworked the splitted batches, the data is now in a separate table and there is only one product record.
Michiel Broek <mbroek@mbse.eu>
parents: 499
diff changeset
545 $sql .= "' WHERE record='" . $_POST['record'] . "';";
8d53ad389204 Reworked the splitted batches, the data is now in a separate table and there is only one product record.
Michiel Broek <mbroek@mbse.eu>
parents: 499
diff changeset
546 syslog(LOG_NOTICE, $sql);
8d53ad389204 Reworked the splitted batches, the data is now in a separate table and there is only one product record.
Michiel Broek <mbroek@mbse.eu>
parents: 499
diff changeset
547
8d53ad389204 Reworked the splitted batches, the data is now in a separate table and there is only one product record.
Michiel Broek <mbroek@mbse.eu>
parents: 499
diff changeset
548 $result = mysqli_query($connect, $sql);
8d53ad389204 Reworked the splitted batches, the data is now in a separate table and there is only one product record.
Michiel Broek <mbroek@mbse.eu>
parents: 499
diff changeset
549 if (! $result) {
8d53ad389204 Reworked the splitted batches, the data is now in a separate table and there is only one product record.
Michiel Broek <mbroek@mbse.eu>
parents: 499
diff changeset
550 syslog(LOG_NOTICE, "db_product: result: ".mysqli_error($connect));
757
d13be50c0049 Added error handler
Michiel Broek <mbroek@mbse.eu>
parents: 740
diff changeset
551 $response['error'] = true;
768
ae1195153fa2 Better error reporting in profiles fermentation steps, mash profiles, beer styles, water profiles and general setup.
Michiel Broek <mbroek@mbse.eu>
parents: 763
diff changeset
552 $response['msg'] = "SQL update fout: ".mysqli_error($connect);
500
8d53ad389204 Reworked the splitted batches, the data is now in a separate table and there is only one product record.
Michiel Broek <mbroek@mbse.eu>
parents: 499
diff changeset
553 } else {
8d53ad389204 Reworked the splitted batches, the data is now in a separate table and there is only one product record.
Michiel Broek <mbroek@mbse.eu>
parents: 499
diff changeset
554 syslog(LOG_NOTICE, "db_product: updated (divide) record ".$_POST['record']);
757
d13be50c0049 Added error handler
Michiel Broek <mbroek@mbse.eu>
parents: 740
diff changeset
555 }
d13be50c0049 Added error handler
Michiel Broek <mbroek@mbse.eu>
parents: 740
diff changeset
556 echo json_encode($response);
500
8d53ad389204 Reworked the splitted batches, the data is now in a separate table and there is only one product record.
Michiel Broek <mbroek@mbse.eu>
parents: 499
diff changeset
557
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
558 } else if (isset($_POST['delete'])) {
119
ae5e8d740173 Renamed some fields in prod_main to prevent ambigous names with the join. Delete product also deletes the corresponding recipe. Fixed equipment load and save. Read data from the product main joined with prod_recipes completed. The brewday page is now almost complete, the calculations must be added.
Michiel Broek <mbroek@mbse.eu>
parents: 115
diff changeset
559 /*
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
560 * DELETE command.
119
ae5e8d740173 Renamed some fields in prod_main to prevent ambigous names with the join. Delete product also deletes the corresponding recipe. Fixed equipment load and save. Read data from the product main joined with prod_recipes completed. The brewday page is now almost complete, the calculations must be added.
Michiel Broek <mbroek@mbse.eu>
parents: 115
diff changeset
561 */
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
562 $sql = "DELETE FROM `products` WHERE uuid='".$_POST['uuid']."';";
119
ae5e8d740173 Renamed some fields in prod_main to prevent ambigous names with the join. Delete product also deletes the corresponding recipe. Fixed equipment load and save. Read data from the product main joined with prod_recipes completed. The brewday page is now almost complete, the calculations must be added.
Michiel Broek <mbroek@mbse.eu>
parents: 115
diff changeset
563 $result = mysqli_query($connect, $sql);
ae5e8d740173 Renamed some fields in prod_main to prevent ambigous names with the join. Delete product also deletes the corresponding recipe. Fixed equipment load and save. Read data from the product main joined with prod_recipes completed. The brewday page is now almost complete, the calculations must be added.
Michiel Broek <mbroek@mbse.eu>
parents: 115
diff changeset
564 if (! $result) {
ae5e8d740173 Renamed some fields in prod_main to prevent ambigous names with the join. Delete product also deletes the corresponding recipe. Fixed equipment load and save. Read data from the product main joined with prod_recipes completed. The brewday page is now almost complete, the calculations must be added.
Michiel Broek <mbroek@mbse.eu>
parents: 115
diff changeset
565 syslog(LOG_NOTICE, "db_product: ".$sql." result: ".mysqli_error($connect));
757
d13be50c0049 Added error handler
Michiel Broek <mbroek@mbse.eu>
parents: 740
diff changeset
566 $response['error'] = true;
768
ae1195153fa2 Better error reporting in profiles fermentation steps, mash profiles, beer styles, water profiles and general setup.
Michiel Broek <mbroek@mbse.eu>
parents: 763
diff changeset
567 $response['msg'] = "SQL delete fout: ".mysqli_error($connect);
119
ae5e8d740173 Renamed some fields in prod_main to prevent ambigous names with the join. Delete product also deletes the corresponding recipe. Fixed equipment load and save. Read data from the product main joined with prod_recipes completed. The brewday page is now almost complete, the calculations must be added.
Michiel Broek <mbroek@mbse.eu>
parents: 115
diff changeset
568 } else {
ae5e8d740173 Renamed some fields in prod_main to prevent ambigous names with the join. Delete product also deletes the corresponding recipe. Fixed equipment load and save. Read data from the product main joined with prod_recipes completed. The brewday page is now almost complete, the calculations must be added.
Michiel Broek <mbroek@mbse.eu>
parents: 115
diff changeset
569 syslog(LOG_NOTICE, "db_product: deleted product uuid ".$_POST['uuid']);
ae5e8d740173 Renamed some fields in prod_main to prevent ambigous names with the join. Delete product also deletes the corresponding recipe. Fixed equipment load and save. Read data from the product main joined with prod_recipes completed. The brewday page is now almost complete, the calculations must be added.
Michiel Broek <mbroek@mbse.eu>
parents: 115
diff changeset
570 }
757
d13be50c0049 Added error handler
Michiel Broek <mbroek@mbse.eu>
parents: 740
diff changeset
571 echo json_encode($response);
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
572
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
573 } else {
119
ae5e8d740173 Renamed some fields in prod_main to prevent ambigous names with the join. Delete product also deletes the corresponding recipe. Fixed equipment load and save. Read data from the product main joined with prod_recipes completed. The brewday page is now almost complete, the calculations must be added.
Michiel Broek <mbroek@mbse.eu>
parents: 115
diff changeset
574 /*
ae5e8d740173 Renamed some fields in prod_main to prevent ambigous names with the join. Delete product also deletes the corresponding recipe. Fixed equipment load and save. Read data from the product main joined with prod_recipes completed. The brewday page is now almost complete, the calculations must be added.
Michiel Broek <mbroek@mbse.eu>
parents: 115
diff changeset
575 * SELECT, produce a list of products that are not yet Closed.
ae5e8d740173 Renamed some fields in prod_main to prevent ambigous names with the join. Delete product also deletes the corresponding recipe. Fixed equipment load and save. Read data from the product main joined with prod_recipes completed. The brewday page is now almost complete, the calculations must be added.
Michiel Broek <mbroek@mbse.eu>
parents: 115
diff changeset
576 */
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
577 if (isset($_GET['select']) && ($_GET['select'] == "inprod")) {
611
c583f446d6ca Changed order of products in production
Michiel Broek <mbroek@mbse.eu>
parents: 602
diff changeset
578 $query = "SELECT record,name,code,birth,stage,brew_date_start,package_date FROM products WHERE stage != '11' ORDER BY stage,code,birth;";
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
579 $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect));
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
580 while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
114
4935e86b2775 Small fixes for prject import from Brouwhulp. Fixes for poduct database read/write. New menu entries. Equipment select in product editor. Started brewday editor. Added conditions on some buttons and edit fields. Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 112
diff changeset
581 $brews[] = array(
4935e86b2775 Small fixes for prject import from Brouwhulp. Fixes for poduct database read/write. New menu entries. Equipment select in product editor. Started brewday editor. Added conditions on some buttons and edit fields. Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 112
diff changeset
582 'record' => $row['record'],
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
583 'name' => $row['name'],
114
4935e86b2775 Small fixes for prject import from Brouwhulp. Fixes for poduct database read/write. New menu entries. Equipment select in product editor. Started brewday editor. Added conditions on some buttons and edit fields. Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 112
diff changeset
584 'code' => $row['code'],
4935e86b2775 Small fixes for prject import from Brouwhulp. Fixes for poduct database read/write. New menu entries. Equipment select in product editor. Started brewday editor. Added conditions on some buttons and edit fields. Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 112
diff changeset
585 'birth' => $row['birth'],
321
4116e6184609 The products in production list now shows carbonation and mature period. Also the planned brewdate.
Michiel Broek <mbroek@mbse.eu>
parents: 299
diff changeset
586 'stage' => $row['stage'],
4116e6184609 The products in production list now shows carbonation and mature period. Also the planned brewdate.
Michiel Broek <mbroek@mbse.eu>
parents: 299
diff changeset
587 'brew_date' => substr($row['brew_date_start'], 0, 10),
4116e6184609 The products in production list now shows carbonation and mature period. Also the planned brewdate.
Michiel Broek <mbroek@mbse.eu>
parents: 299
diff changeset
588 'package_date' => $row['package_date']
114
4935e86b2775 Small fixes for prject import from Brouwhulp. Fixes for poduct database read/write. New menu entries. Equipment select in product editor. Started brewday editor. Added conditions on some buttons and edit fields. Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 112
diff changeset
589 );
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
590 }
296
69fadd1aded2 Updated design document. Add content header application/json to all scripts that produce json output. Chart prints show the beer code and name in the header. Charts don't display the menu anymore.
Michiel Broek <mbroek@mbse.eu>
parents: 292
diff changeset
591 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: 763
diff changeset
592 exit(json_encode($brews, JSON_UNESCAPED_UNICODE));
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
593 }
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
594
290
12aa92828e24 Added view archives by name
Michiel Broek <mbroek@mbse.eu>
parents: 285
diff changeset
595 if (isset($_GET['select']) && ($_GET['select'] == "archname")) {
577
b4bfed3684d0 In production archive lists show always the OG from the brew fermenter SG. Possible fix for the not used og field in the database.
Michiel Broek <mbroek@mbse.eu>
parents: 565
diff changeset
596 $query = "SELECT record,name,code,brew_date_start,st_name,brew_fermenter_sg,fg,batch_size FROM products WHERE stage = '11' ORDER BY name,brew_date_start;";
292
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
597 $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect));
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
598 while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
599 $brews[] = array(
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
600 'record' => $row['record'],
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
601 'name' => $row['name'],
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
602 'code' => $row['code'],
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
603 'date' => substr($row['brew_date_start'], 0, 10),
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
604 'style' => $row['st_name'],
577
b4bfed3684d0 In production archive lists show always the OG from the brew fermenter SG. Possible fix for the not used og field in the database.
Michiel Broek <mbroek@mbse.eu>
parents: 565
diff changeset
605 'og' => $row['brew_fermenter_sg'],
292
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
606 'fg' => $row['fg'],
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
607 'batch_size' => $row['batch_size']
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
608 );
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
609 }
296
69fadd1aded2 Updated design document. Add content header application/json to all scripts that produce json output. Chart prints show the beer code and name in the header. Charts don't display the menu anymore.
Michiel Broek <mbroek@mbse.eu>
parents: 292
diff changeset
610 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: 763
diff changeset
611 exit(json_encode($brews, JSON_UNESCAPED_UNICODE));
292
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
612 }
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
613
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
614 if (isset($_GET['select']) && ($_GET['select'] == "archcode")) {
577
b4bfed3684d0 In production archive lists show always the OG from the brew fermenter SG. Possible fix for the not used og field in the database.
Michiel Broek <mbroek@mbse.eu>
parents: 565
diff changeset
615 $query = "SELECT record,name,code,brew_date_start,st_name,brew_fermenter_sg,fg,batch_size FROM products WHERE stage = '11' ORDER BY code;";
290
12aa92828e24 Added view archives by name
Michiel Broek <mbroek@mbse.eu>
parents: 285
diff changeset
616 $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect));
12aa92828e24 Added view archives by name
Michiel Broek <mbroek@mbse.eu>
parents: 285
diff changeset
617 while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
12aa92828e24 Added view archives by name
Michiel Broek <mbroek@mbse.eu>
parents: 285
diff changeset
618 $brews[] = array(
12aa92828e24 Added view archives by name
Michiel Broek <mbroek@mbse.eu>
parents: 285
diff changeset
619 'record' => $row['record'],
12aa92828e24 Added view archives by name
Michiel Broek <mbroek@mbse.eu>
parents: 285
diff changeset
620 'name' => $row['name'],
12aa92828e24 Added view archives by name
Michiel Broek <mbroek@mbse.eu>
parents: 285
diff changeset
621 'code' => $row['code'],
292
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
622 'date' => substr($row['brew_date_start'], 0, 10),
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
623 'style' => $row['st_name'],
577
b4bfed3684d0 In production archive lists show always the OG from the brew fermenter SG. Possible fix for the not used og field in the database.
Michiel Broek <mbroek@mbse.eu>
parents: 565
diff changeset
624 'og' => $row['brew_fermenter_sg'],
292
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
625 'fg' => $row['fg'],
290
12aa92828e24 Added view archives by name
Michiel Broek <mbroek@mbse.eu>
parents: 285
diff changeset
626 'batch_size' => $row['batch_size']
12aa92828e24 Added view archives by name
Michiel Broek <mbroek@mbse.eu>
parents: 285
diff changeset
627 );
12aa92828e24 Added view archives by name
Michiel Broek <mbroek@mbse.eu>
parents: 285
diff changeset
628 }
296
69fadd1aded2 Updated design document. Add content header application/json to all scripts that produce json output. Chart prints show the beer code and name in the header. Charts don't display the menu anymore.
Michiel Broek <mbroek@mbse.eu>
parents: 292
diff changeset
629 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: 763
diff changeset
630 exit(json_encode($brews, JSON_UNESCAPED_UNICODE));
292
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
631 }
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
632
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
633 if (isset($_GET['select']) && ($_GET['select'] == "archdate")) {
577
b4bfed3684d0 In production archive lists show always the OG from the brew fermenter SG. Possible fix for the not used og field in the database.
Michiel Broek <mbroek@mbse.eu>
parents: 565
diff changeset
634 $query = "SELECT record,name,code,brew_date_start,st_name,brew_fermenter_sg,fg,batch_size FROM products WHERE stage = '11' ORDER BY brew_date_start;";
292
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
635 $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect));
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
636 while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
637 $brews[] = array(
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
638 'record' => $row['record'],
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
639 'name' => $row['name'],
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
640 'code' => $row['code'],
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
641 'year' => substr($row['brew_date_start'], 0, 4),
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
642 'date' => substr($row['brew_date_start'], 0, 10),
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
643 'style' => $row['st_name'],
577
b4bfed3684d0 In production archive lists show always the OG from the brew fermenter SG. Possible fix for the not used og field in the database.
Michiel Broek <mbroek@mbse.eu>
parents: 565
diff changeset
644 'og' => $row['brew_fermenter_sg'],
292
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
645 'fg' => $row['fg'],
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
646 'batch_size' => $row['batch_size']
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
647 );
90cd3798edc2 Added archive view on date and code.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
648 }
296
69fadd1aded2 Updated design document. Add content header application/json to all scripts that produce json output. Chart prints show the beer code and name in the header. Charts don't display the menu anymore.
Michiel Broek <mbroek@mbse.eu>
parents: 292
diff changeset
649 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: 763
diff changeset
650 exit(json_encode($brews, JSON_UNESCAPED_UNICODE));
290
12aa92828e24 Added view archives by name
Michiel Broek <mbroek@mbse.eu>
parents: 285
diff changeset
651 }
12aa92828e24 Added view archives by name
Michiel Broek <mbroek@mbse.eu>
parents: 285
diff changeset
652
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
653 /*
185
4c25db9e8102 Added configuration settings for MQTT in config.php. Finished screen box sizes for the fermenters monitor. Select beername and code from the current brew products and send it to the fermenter. Added switch commands to the fermenter. Delay data get from the fermenter after sending any command so there is time to process the commands. Turn switches off when the mode changes. Removed 0.2 degrees setpoint diffs for low and high, the fermenter must deal with it. Prevent turning the heater and cooler together on.
Michiel Broek <mbroek@mbse.eu>
parents: 166
diff changeset
654 * SELECT, produce a list of products that can be fermented.
4c25db9e8102 Added configuration settings for MQTT in config.php. Finished screen box sizes for the fermenters monitor. Select beername and code from the current brew products and send it to the fermenter. Added switch commands to the fermenter. Delay data get from the fermenter after sending any command so there is time to process the commands. Turn switches off when the mode changes. Removed 0.2 degrees setpoint diffs for low and high, the fermenter must deal with it. Prevent turning the heater and cooler together on.
Michiel Broek <mbroek@mbse.eu>
parents: 166
diff changeset
655 */
4c25db9e8102 Added configuration settings for MQTT in config.php. Finished screen box sizes for the fermenters monitor. Select beername and code from the current brew products and send it to the fermenter. Added switch commands to the fermenter. Delay data get from the fermenter after sending any command so there is time to process the commands. Turn switches off when the mode changes. Removed 0.2 degrees setpoint diffs for low and high, the fermenter must deal with it. Prevent turning the heater and cooler together on.
Michiel Broek <mbroek@mbse.eu>
parents: 166
diff changeset
656 if (isset($_GET['select']) && ($_GET['select'] == "ferment")) {
299
047ead629d4a Accept yeast temperature limits from thermferm via MQTT. Send yeat temperature ranges to thermferm together with the beer parameters. Store yeast temperature limits in the mon_fermenters database table. The monitor fermenters screen adjusts the temperature color ranges.
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
657 $query = "SELECT code,name,uuid,stage,json_yeasts FROM products WHERE ";
326
bf5fa5277c9f Allow to select beer that is in carbonation stage
Michiel Broek <mbroek@mbse.eu>
parents: 321
diff changeset
658 $query .= "stage='1' OR stage='2' OR stage='3' OR stage='4' OR stage='5' OR stage='6' OR stage='7' ORDER BY code;";
185
4c25db9e8102 Added configuration settings for MQTT in config.php. Finished screen box sizes for the fermenters monitor. Select beername and code from the current brew products and send it to the fermenter. Added switch commands to the fermenter. Delay data get from the fermenter after sending any command so there is time to process the commands. Turn switches off when the mode changes. Removed 0.2 degrees setpoint diffs for low and high, the fermenter must deal with it. Prevent turning the heater and cooler together on.
Michiel Broek <mbroek@mbse.eu>
parents: 166
diff changeset
659 $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect));
4c25db9e8102 Added configuration settings for MQTT in config.php. Finished screen box sizes for the fermenters monitor. Select beername and code from the current brew products and send it to the fermenter. Added switch commands to the fermenter. Delay data get from the fermenter after sending any command so there is time to process the commands. Turn switches off when the mode changes. Removed 0.2 degrees setpoint diffs for low and high, the fermenter must deal with it. Prevent turning the heater and cooler together on.
Michiel Broek <mbroek@mbse.eu>
parents: 166
diff changeset
660 while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
299
047ead629d4a Accept yeast temperature limits from thermferm via MQTT. Send yeat temperature ranges to thermferm together with the beer parameters. Store yeast temperature limits in the mon_fermenters database table. The monitor fermenters screen adjusts the temperature color ranges.
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
661 $yl = 0;
047ead629d4a Accept yeast temperature limits from thermferm via MQTT. Send yeat temperature ranges to thermferm together with the beer parameters. Store yeast temperature limits in the mon_fermenters database table. The monitor fermenters screen adjusts the temperature color ranges.
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
662 $yh = 40;
047ead629d4a Accept yeast temperature limits from thermferm via MQTT. Send yeat temperature ranges to thermferm together with the beer parameters. Store yeast temperature limits in the mon_fermenters database table. The monitor fermenters screen adjusts the temperature color ranges.
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
663 $yeasts = json_decode($row['json_yeasts'], true);
047ead629d4a Accept yeast temperature limits from thermferm via MQTT. Send yeat temperature ranges to thermferm together with the beer parameters. Store yeast temperature limits in the mon_fermenters database table. The monitor fermenters screen adjusts the temperature color ranges.
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
664 for ($i = 0; $i < count($yeasts); $i++) {
047ead629d4a Accept yeast temperature limits from thermferm via MQTT. Send yeat temperature ranges to thermferm together with the beer parameters. Store yeast temperature limits in the mon_fermenters database table. The monitor fermenters screen adjusts the temperature color ranges.
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
665 if ($yeasts[$i]['y_use'] == 0) { // Primary
047ead629d4a Accept yeast temperature limits from thermferm via MQTT. Send yeat temperature ranges to thermferm together with the beer parameters. Store yeast temperature limits in the mon_fermenters database table. The monitor fermenters screen adjusts the temperature color ranges.
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
666 if (floatval($yeasts[$i]['y_min_temperature']) > $yl)
047ead629d4a Accept yeast temperature limits from thermferm via MQTT. Send yeat temperature ranges to thermferm together with the beer parameters. Store yeast temperature limits in the mon_fermenters database table. The monitor fermenters screen adjusts the temperature color ranges.
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
667 $yl = floatval($yeasts[$i]['y_min_temperature']);
047ead629d4a Accept yeast temperature limits from thermferm via MQTT. Send yeat temperature ranges to thermferm together with the beer parameters. Store yeast temperature limits in the mon_fermenters database table. The monitor fermenters screen adjusts the temperature color ranges.
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
668 if (floatval($yeasts[$i]['y_max_temperature']) < $yh)
047ead629d4a Accept yeast temperature limits from thermferm via MQTT. Send yeat temperature ranges to thermferm together with the beer parameters. Store yeast temperature limits in the mon_fermenters database table. The monitor fermenters screen adjusts the temperature color ranges.
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
669 $yh = floatval($yeasts[$i]['y_max_temperature']);
047ead629d4a Accept yeast temperature limits from thermferm via MQTT. Send yeat temperature ranges to thermferm together with the beer parameters. Store yeast temperature limits in the mon_fermenters database table. The monitor fermenters screen adjusts the temperature color ranges.
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
670 }
047ead629d4a Accept yeast temperature limits from thermferm via MQTT. Send yeat temperature ranges to thermferm together with the beer parameters. Store yeast temperature limits in the mon_fermenters database table. The monitor fermenters screen adjusts the temperature color ranges.
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
671 }
185
4c25db9e8102 Added configuration settings for MQTT in config.php. Finished screen box sizes for the fermenters monitor. Select beername and code from the current brew products and send it to the fermenter. Added switch commands to the fermenter. Delay data get from the fermenter after sending any command so there is time to process the commands. Turn switches off when the mode changes. Removed 0.2 degrees setpoint diffs for low and high, the fermenter must deal with it. Prevent turning the heater and cooler together on.
Michiel Broek <mbroek@mbse.eu>
parents: 166
diff changeset
672 $brews[] = array(
4c25db9e8102 Added configuration settings for MQTT in config.php. Finished screen box sizes for the fermenters monitor. Select beername and code from the current brew products and send it to the fermenter. Added switch commands to the fermenter. Delay data get from the fermenter after sending any command so there is time to process the commands. Turn switches off when the mode changes. Removed 0.2 degrees setpoint diffs for low and high, the fermenter must deal with it. Prevent turning the heater and cooler together on.
Michiel Broek <mbroek@mbse.eu>
parents: 166
diff changeset
673 'code' => $row['code'],
4c25db9e8102 Added configuration settings for MQTT in config.php. Finished screen box sizes for the fermenters monitor. Select beername and code from the current brew products and send it to the fermenter. Added switch commands to the fermenter. Delay data get from the fermenter after sending any command so there is time to process the commands. Turn switches off when the mode changes. Removed 0.2 degrees setpoint diffs for low and high, the fermenter must deal with it. Prevent turning the heater and cooler together on.
Michiel Broek <mbroek@mbse.eu>
parents: 166
diff changeset
674 'name' => $row['name'],
192
7f69b43e6084 Implemented beer uuid product in monitor fermenters.
Michiel Broek <mbroek@mbse.eu>
parents: 185
diff changeset
675 'uuid' => $row['uuid'],
299
047ead629d4a Accept yeast temperature limits from thermferm via MQTT. Send yeat temperature ranges to thermferm together with the beer parameters. Store yeast temperature limits in the mon_fermenters database table. The monitor fermenters screen adjusts the temperature color ranges.
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
676 'stage' => $row['stage'],
047ead629d4a Accept yeast temperature limits from thermferm via MQTT. Send yeat temperature ranges to thermferm together with the beer parameters. Store yeast temperature limits in the mon_fermenters database table. The monitor fermenters screen adjusts the temperature color ranges.
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
677 'yeast_lo' => $yl,
047ead629d4a Accept yeast temperature limits from thermferm via MQTT. Send yeat temperature ranges to thermferm together with the beer parameters. Store yeast temperature limits in the mon_fermenters database table. The monitor fermenters screen adjusts the temperature color ranges.
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
678 'yeast_hi' => $yh
185
4c25db9e8102 Added configuration settings for MQTT in config.php. Finished screen box sizes for the fermenters monitor. Select beername and code from the current brew products and send it to the fermenter. Added switch commands to the fermenter. Delay data get from the fermenter after sending any command so there is time to process the commands. Turn switches off when the mode changes. Removed 0.2 degrees setpoint diffs for low and high, the fermenter must deal with it. Prevent turning the heater and cooler together on.
Michiel Broek <mbroek@mbse.eu>
parents: 166
diff changeset
679 );
4c25db9e8102 Added configuration settings for MQTT in config.php. Finished screen box sizes for the fermenters monitor. Select beername and code from the current brew products and send it to the fermenter. Added switch commands to the fermenter. Delay data get from the fermenter after sending any command so there is time to process the commands. Turn switches off when the mode changes. Removed 0.2 degrees setpoint diffs for low and high, the fermenter must deal with it. Prevent turning the heater and cooler together on.
Michiel Broek <mbroek@mbse.eu>
parents: 166
diff changeset
680 }
296
69fadd1aded2 Updated design document. Add content header application/json to all scripts that produce json output. Chart prints show the beer code and name in the header. Charts don't display the menu anymore.
Michiel Broek <mbroek@mbse.eu>
parents: 292
diff changeset
681 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: 763
diff changeset
682 exit(json_encode($brews, JSON_UNESCAPED_UNICODE));
185
4c25db9e8102 Added configuration settings for MQTT in config.php. Finished screen box sizes for the fermenters monitor. Select beername and code from the current brew products and send it to the fermenter. Added switch commands to the fermenter. Delay data get from the fermenter after sending any command so there is time to process the commands. Turn switches off when the mode changes. Removed 0.2 degrees setpoint diffs for low and high, the fermenter must deal with it. Prevent turning the heater and cooler together on.
Michiel Broek <mbroek@mbse.eu>
parents: 166
diff changeset
683 }
4c25db9e8102 Added configuration settings for MQTT in config.php. Finished screen box sizes for the fermenters monitor. Select beername and code from the current brew products and send it to the fermenter. Added switch commands to the fermenter. Delay data get from the fermenter after sending any command so there is time to process the commands. Turn switches off when the mode changes. Removed 0.2 degrees setpoint diffs for low and high, the fermenter must deal with it. Prevent turning the heater and cooler together on.
Michiel Broek <mbroek@mbse.eu>
parents: 166
diff changeset
684
4c25db9e8102 Added configuration settings for MQTT in config.php. Finished screen box sizes for the fermenters monitor. Select beername and code from the current brew products and send it to the fermenter. Added switch commands to the fermenter. Delay data get from the fermenter after sending any command so there is time to process the commands. Turn switches off when the mode changes. Removed 0.2 degrees setpoint diffs for low and high, the fermenter must deal with it. Prevent turning the heater and cooler together on.
Michiel Broek <mbroek@mbse.eu>
parents: 166
diff changeset
685 /*
119
ae5e8d740173 Renamed some fields in prod_main to prevent ambigous names with the join. Delete product also deletes the corresponding recipe. Fixed equipment load and save. Read data from the product main joined with prod_recipes completed. The brewday page is now almost complete, the calculations must be added.
Michiel Broek <mbroek@mbse.eu>
parents: 115
diff changeset
686 * Default, select all or a given record.
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
687 */
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
688 if (isset($_GET['record'])) {
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
689 $query = "SELECT * FROM products WHERE record='" . $_GET['record'] . "';";
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
690 } else {
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
691 $query = "SELECT * FROM products ORDER BY birth,code;";
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
692 }
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
693 $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect));
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
694 $brews = '[';
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
695 $comma = FALSE;
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
696 while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
697 // Manual encode to JSON.
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
698 if ($comma)
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
699 $brews .= ',';
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
700 $comma = TRUE;
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
701 $brew = '{"record":' . $row['record'];
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
702 $brew .= ',"uuid":"' . str_replace($escapers, $replacements, $row['uuid']);
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
703 $brew .= '","name":"' . str_replace($escapers, $replacements, $row['name']);
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
704 $brew .= '","code":"' . str_replace($escapers, $replacements, $row['code']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
705 $brew .= '","birth":"' . str_replace($escapers, $replacements, $row['birth']);
235
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
706 $brew .= '","stage":' . $row['stage'];
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
707 $brew .= ',"notes":"' . str_replace($escapers, $replacements, $row['notes']);
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
708 $brew .= '","log_brew":' . $row['log_brew'];
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
709 $brew .= ',"log_fermentation":' . $row['log_fermentation'];
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: 577
diff changeset
710 $brew .= ',"log_ispindel":' . $row['log_ispindel'];
615
9034e65b0d7a Added CO2 carbonation log to the products database. Added button in the packaging tab.
Michiel Broek <mbroek@mbse.eu>
parents: 611
diff changeset
711 $brew .= ',"log_co2pressure":' . $row['log_co2pressure'];
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
712 $brew .= ',"inventory_reduced":' . $row['inventory_reduced'];
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
713 $brew .= ',"locked":' . $row['locked'];
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
714 $brew .= ',"eq_name":"' . str_replace($escapers, $replacements, $row['eq_name']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
715 $brew .= '","eq_notes":"' . str_replace($escapers, $replacements, $row['eq_notes']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
716 $brew .= '","eq_boil_size":' . floatval($row['eq_boil_size']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
717 $brew .= ',"eq_batch_size":' . floatval($row['eq_batch_size']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
718 $brew .= ',"eq_tun_volume":' . floatval($row['eq_tun_volume']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
719 $brew .= ',"eq_tun_weight":' . floatval($row['eq_tun_weight']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
720 $brew .= ',"eq_tun_specific_heat":' . floatval($row['eq_tun_specific_heat']);
235
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
721 $brew .= ',"eq_tun_material":' . $row['eq_tun_material'];
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
722 $brew .= ',"eq_tun_height":' . floatval($row['eq_tun_height']);
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
723 $brew .= ',"eq_top_up_water":' . floatval($row['eq_top_up_water']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
724 $brew .= ',"eq_trub_chiller_loss":' . floatval($row['eq_trub_chiller_loss']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
725 $brew .= ',"eq_evap_rate":' . floatval($row['eq_evap_rate']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
726 $brew .= ',"eq_boil_time":' . floatval($row['eq_boil_time']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
727 $brew .= ',"eq_calc_boil_volume":' . $row['eq_calc_boil_volume'];
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
728 $brew .= ',"eq_calc_boil_volume":' . floatval($row['eq_calc_boil_volume']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
729 $brew .= ',"eq_top_up_kettle":' . floatval($row['eq_top_up_kettle']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
730 $brew .= ',"eq_hop_utilization":' . floatval($row['eq_hop_utilization']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
731 $brew .= ',"eq_lauter_volume":' . floatval($row['eq_lauter_volume']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
732 $brew .= ',"eq_lauter_height":' . floatval($row['eq_lauter_height']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
733 $brew .= ',"eq_lauter_deadspace":' . floatval($row['eq_lauter_deadspace']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
734 $brew .= ',"eq_kettle_volume":' . floatval($row['eq_kettle_volume']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
735 $brew .= ',"eq_kettle_height":' . floatval($row['eq_kettle_height']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
736 $brew .= ',"eq_mash_volume":' . floatval($row['eq_mash_volume']);
149
ff45488d480e Added some icons from Brewersfriend. They should be replaced someday. Added maximum mash weight setting to the equipment database. Usefull for brew automate and RIMS systems. During recipes import acid and base additions are translated. Brews and recipes now have 2 water sources. Added water mixer. Added basic water treatment, but not for pH yet. Redesigned the fermentables and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents: 121
diff changeset
737 $brew .= ',"eq_mash_max":' . floatval($row['eq_mash_max']);
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
738 $brew .= ',"eq_efficiency":' . floatval($row['eq_efficiency']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
739 $brew .= ',"eq_top_up_water":' . floatval($row['eq_top_up_water']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
740 $brew .= ',"brew_date_start":"' . $row['brew_date_start'];
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
741 $brew .= '","brew_mash_ph":' . floatval($row['brew_mash_ph']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
742 $brew .= ',"brew_mash_sg":' . floatval($row['brew_mash_sg']);
392
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
743 $brew .= ',"brew_mash_efficiency":' . floatval($row['brew_mash_efficiency']);
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
744 $brew .= ',"brew_sparge_est":' . floatval($row['brew_sparge_est']);
121
875aeb365e1c Added sparge pH during import. Added several calculations. Added calculated estimates to the brewday screen.
Michiel Broek <mbroek@mbse.eu>
parents: 119
diff changeset
745 $brew .= ',"brew_sparge_ph":' . floatval($row['brew_sparge_ph']);
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
746 $brew .= ',"brew_preboil_volume":' . floatval($row['brew_preboil_volume']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
747 $brew .= ',"brew_preboil_sg":' . floatval($row['brew_preboil_sg']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
748 $brew .= ',"brew_preboil_ph":' . floatval($row['brew_preboil_ph']);
392
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
749 $brew .= ',"brew_preboil_efficiency":' . floatval($row['brew_preboil_efficiency']);
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
750 $brew .= ',"brew_aboil_volume":' . floatval($row['brew_aboil_volume']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
751 $brew .= ',"brew_aboil_sg":' . floatval($row['brew_aboil_sg']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
752 $brew .= ',"brew_aboil_ph":' . floatval($row['brew_aboil_ph']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
753 $brew .= ',"brew_aboil_efficiency":' . floatval($row['brew_aboil_efficiency']);
235
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
754 $brew .= ',"brew_cooling_method":' . $row['brew_cooling_method'];
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
755 $brew .= ',"brew_cooling_time":' . floatval($row['brew_cooling_time']);
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
756 $brew .= ',"brew_cooling_to":' . floatval($row['brew_cooling_to']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
757 $brew .= ',"brew_whirlpool9":' . floatval($row['brew_whirlpool9']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
758 $brew .= ',"brew_whirlpool7":' . floatval($row['brew_whirlpool7']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
759 $brew .= ',"brew_whirlpool6":' . floatval($row['brew_whirlpool6']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
760 $brew .= ',"brew_whirlpool2":' . floatval($row['brew_whirlpool2']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
761 $brew .= ',"brew_fermenter_volume":' . floatval($row['brew_fermenter_volume']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
762 $brew .= ',"brew_fermenter_extrawater":' . floatval($row['brew_fermenter_extrawater']);
254
3d61397fe9cd Rework the volume to the fermenter and things that depend on that. New layout on the brewday tab. The calculation model is simpler then the brouwhulp version.
Michiel Broek <mbroek@mbse.eu>
parents: 252
diff changeset
763 $brew .= ',"brew_fermenter_tcloss":' . floatval($row['brew_fermenter_tcloss']);
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
764 $brew .= ',"brew_aeration_time":' . floatval($row['brew_aeration_time']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
765 $brew .= ',"brew_aeration_speed":' . floatval($row['brew_aeration_speed']);
235
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
766 $brew .= ',"brew_aeration_type":' . $row['brew_aeration_type'];
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
767 $brew .= ',"brew_fermenter_sg":' . floatval($row['brew_fermenter_sg']);
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
768 $brew .= ',"brew_fermenter_ibu":' . floatval($row['brew_fermenter_ibu']);
254
3d61397fe9cd Rework the volume to the fermenter and things that depend on that. New layout on the brewday tab. The calculation model is simpler then the brouwhulp version.
Michiel Broek <mbroek@mbse.eu>
parents: 252
diff changeset
769 $brew .= ',"brew_fermenter_color":' . floatval($row['brew_fermenter_color']);
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
770 $brew .= ',"brew_date_end":"' . $row['brew_date_end'];
252
b558f3dfcda3 Make sure all boolean values are saved correctly in the database.
Michiel Broek <mbroek@mbse.eu>
parents: 243
diff changeset
771 $brew .= '","og":' . floatval($row['og']);
163
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 159
diff changeset
772 $brew .= ',"fg":' . floatval($row['fg']);
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
773 $brew .= ',"primary_start_temp":' . floatval($row['primary_start_temp']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
774 $brew .= ',"primary_max_temp":' . floatval($row['primary_max_temp']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
775 $brew .= ',"primary_end_temp":' . floatval($row['primary_end_temp']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
776 $brew .= ',"primary_end_sg":' . floatval($row['primary_end_sg']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
777 $brew .= ',"primary_end_date":"' . $row['primary_end_date'];
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
778 $brew .= '","secondary_temp":' . floatval($row['secondary_temp']);
460
046ff5fdc96c Implemented products.secondary_end_sg field. The missing values are updated by the crontask.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
779 $brew .= ',"secondary_end_sg":' . floatval($row['secondary_end_sg']);
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
780 $brew .= ',"secondary_end_date":"' . $row['secondary_end_date'];
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
781 $brew .= '","tertiary_temp":' . floatval($row['tertiary_temp']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
782 $brew .= ',"package_date":"' . $row['package_date'];
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: 411
diff changeset
783 $brew .= '","package_volume":' . floatval($row['package_volume']);
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: 411
diff changeset
784 $brew .= ',"package_infuse_amount":' . floatval($row['package_infuse_amount']);
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: 411
diff changeset
785 $brew .= ',"package_infuse_abv":' . floatval($row['package_infuse_abv']);
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: 411
diff changeset
786 $brew .= ',"package_infuse_notes":"' . $row['package_infuse_notes'];
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: 411
diff changeset
787 $brew .= '","package_abv":' . floatval($row['package_abv']);
458
47b592993dd5 Version 0.3.15. Implemented final pH during packaging. Updated prod_new, prod_duplicate, prod_edit, rec_toproduct for this new field and several other fields added in previous versions.
Michiel Broek <mbroek@mbse.eu>
parents: 457
diff changeset
788 $brew .= ',"package_ph":' . floatval($row['package_ph']);
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: 411
diff changeset
789 $brew .= ',"bottle_amount":' . floatval($row['bottle_amount']);
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
790 $brew .= ',"bottle_carbonation":' . floatval($row['bottle_carbonation']);
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
791 $brew .= ',"bottle_priming_water":' . floatval($row['bottle_priming_water']);
235
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
792 $brew .= ',"bottle_priming_amount":' . floatval($row['bottle_priming_amount']);
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
793 $brew .= ',"bottle_carbonation_temp":' . floatval($row['bottle_carbonation_temp']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
794 $brew .= ',"keg_amount":' . floatval($row['keg_amount']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
795 $brew .= ',"keg_carbonation":' . floatval($row['keg_carbonation']);
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
796 $brew .= ',"keg_priming_water":' . floatval($row['keg_priming_water']);
235
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
797 $brew .= ',"keg_priming_amount":' . floatval($row['keg_priming_amount']);
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
798 $brew .= ',"keg_carbonation_temp":' . floatval($row['keg_carbonation_temp']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
799 $brew .= ',"keg_forced_carb":' . floatval($row['keg_forced_carb']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
800 $brew .= ',"keg_pressure":' . floatval($row['keg_pressure']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
801 $brew .= ',"taste_notes":"' . str_replace($escapers, $replacements, $row['taste_notes']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
802 $brew .= '","taste_rate":' . floatval($row['taste_rate']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
803 $brew .= ',"taste_date":"' . str_replace($escapers, $replacements, $row['taste_date']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
804 $brew .= '","taste_color":"' . str_replace($escapers, $replacements, $row['taste_color']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
805 $brew .= '","taste_transparency":"' . str_replace($escapers, $replacements, $row['taste_transparency']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
806 $brew .= '","taste_head":"' . str_replace($escapers, $replacements, $row['taste_head']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
807 $brew .= '","taste_aroma":"' . str_replace($escapers, $replacements, $row['taste_aroma']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
808 $brew .= '","taste_taste":"' . str_replace($escapers, $replacements, $row['taste_taste']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
809 $brew .= '","taste_mouthfeel":"' . str_replace($escapers, $replacements, $row['taste_mouthfeel']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
810 $brew .= '","taste_aftertaste":"' . str_replace($escapers, $replacements, $row['taste_aftertaste']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
811 $brew .= '","st_guide":"' . str_replace($escapers, $replacements, $row['st_guide']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
812 $brew .= '","st_letter":"' . str_replace($escapers, $replacements, $row['st_letter']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
813 $brew .= '","st_name":"' . str_replace($escapers, $replacements, $row['st_name']);
235
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
814 $brew .= '","st_type":' . $row['st_type'];
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
815 $brew .= ',"st_category":"' . str_replace($escapers, $replacements, $row['st_category']);
706
12f9316de113 Less logging in the db_product interface. Fixed some empty default values that bugged the newer php and mariadb versions.
Michiel Broek <mbroek@mbse.eu>
parents: 697
diff changeset
816 $brew .= '","st_category_number":' . $row['st_category_number'];
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
817 $brew .= ',"st_og_min":' . floatval($row['st_og_min']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
818 $brew .= ',"st_og_max":' . floatval($row['st_og_max']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
819 $brew .= ',"st_fg_min":' . floatval($row['st_fg_min']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
820 $brew .= ',"st_fg_max":' . floatval($row['st_fg_max']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
821 $brew .= ',"st_ibu_min":' . floatval($row['st_ibu_min']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
822 $brew .= ',"st_ibu_max":' . floatval($row['st_ibu_max']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
823 $brew .= ',"st_color_min":' . floatval($row['st_color_min']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
824 $brew .= ',"st_color_max":' . floatval($row['st_color_max']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
825 $brew .= ',"st_carb_min":' . floatval($row['st_carb_min']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
826 $brew .= ',"st_carb_max":' . floatval($row['st_carb_max']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
827 $brew .= ',"st_abv_min":' . floatval($row['st_abv_min']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
828 $brew .= ',"st_abv_max":' . floatval($row['st_abv_max']);
235
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
829 $brew .= ',"type":' . $row['type'];
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
830 $brew .= ',"batch_size":' . floatval($row['batch_size']);
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
831 $brew .= ',"boil_size":' . floatval($row['boil_size']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
832 $brew .= ',"boil_time":' . floatval($row['boil_time']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
833 $brew .= ',"efficiency":' . floatval($row['efficiency']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
834 $brew .= ',"est_og":' . floatval($row['est_og']);
616
2cbf21bb9bdc Added est_og3 field in the products database so that the checklist can use it.
Michiel Broek <mbroek@mbse.eu>
parents: 615
diff changeset
835 $brew .= ',"est_og3":' . floatval($row['est_og3']);
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
836 $brew .= ',"est_fg":' . floatval($row['est_fg']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
837 $brew .= ',"est_abv":' . floatval($row['est_abv']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
838 $brew .= ',"est_carb":' . floatval($row['est_carb']);
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
839 $brew .= ',"est_color":' . floatval($row['est_color']);
235
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
840 $brew .= ',"color_method":' . $row['color_method'];
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
841 $brew .= ',"est_ibu":' . floatval($row['est_ibu']);
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
842 $brew .= ',"ibu_method":' . $row['ibu_method'];
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
843 $brew .= ',"sparge_temp":' . floatval($row['sparge_temp']);
149
ff45488d480e Added some icons from Brewersfriend. They should be replaced someday. Added maximum mash weight setting to the equipment database. Usefull for brew automate and RIMS systems. During recipes import acid and base additions are translated. Brews and recipes now have 2 water sources. Added water mixer. Added basic water treatment, but not for pH yet. Redesigned the fermentables and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents: 121
diff changeset
844 $brew .= ',"sparge_ph":' . floatval($row['sparge_ph']);
ff45488d480e Added some icons from Brewersfriend. They should be replaced someday. Added maximum mash weight setting to the equipment database. Usefull for brew automate and RIMS systems. During recipes import acid and base additions are translated. Brews and recipes now have 2 water sources. Added water mixer. Added basic water treatment, but not for pH yet. Redesigned the fermentables and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents: 121
diff changeset
845 $brew .= ',"sparge_volume":' . floatval($row['sparge_volume']);
235
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
846 $brew .= ',"sparge_source":' . $row['sparge_source'];
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
847 $brew .= ',"sparge_acid_type":' . $row['sparge_acid_type'];
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
848 $brew .= ',"sparge_acid_perc":' . floatval($row['sparge_acid_perc']);
149
ff45488d480e Added some icons from Brewersfriend. They should be replaced someday. Added maximum mash weight setting to the equipment database. Usefull for brew automate and RIMS systems. During recipes import acid and base additions are translated. Brews and recipes now have 2 water sources. Added water mixer. Added basic water treatment, but not for pH yet. Redesigned the fermentables and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents: 121
diff changeset
849 $brew .= ',"sparge_acid_amount":' . floatval($row['sparge_acid_amount']);
359
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
850 $brew .= ',"mash_ph":' . floatval($row['mash_ph']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
851 $brew .= ',"mash_name":"' . str_replace($escapers, $replacements, $row['mash_name']);
149
ff45488d480e Added some icons from Brewersfriend. They should be replaced someday. Added maximum mash weight setting to the equipment database. Usefull for brew automate and RIMS systems. During recipes import acid and base additions are translated. Brews and recipes now have 2 water sources. Added water mixer. Added basic water treatment, but not for pH yet. Redesigned the fermentables and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents: 121
diff changeset
852 $brew .= '","calc_acid":' . $row['calc_acid'];
ff45488d480e Added some icons from Brewersfriend. They should be replaced someday. Added maximum mash weight setting to the equipment database. Usefull for brew automate and RIMS systems. During recipes import acid and base additions are translated. Brews and recipes now have 2 water sources. Added water mixer. Added basic water treatment, but not for pH yet. Redesigned the fermentables and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents: 121
diff changeset
853 $brew .= ',"w1_name":"' . str_replace($escapers, $replacements, $row['w1_name']);
359
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
854 $brew .= '","w1_amount":' . floatval($row['w1_amount']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
855 $brew .= ',"w1_calcium":' . floatval($row['w1_calcium']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
856 $brew .= ',"w1_sulfate":' . floatval($row['w1_sulfate']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
857 $brew .= ',"w1_chloride":' . floatval($row['w1_chloride']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
858 $brew .= ',"w1_sodium":' . floatval($row['w1_sodium']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
859 $brew .= ',"w1_magnesium":' . floatval($row['w1_magnesium']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
860 $brew .= ',"w1_total_alkalinity":' . floatval($row['w1_total_alkalinity']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
861 $brew .= ',"w1_ph":' . floatval($row['w1_ph']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
862 $brew .= ',"w1_cost":' . floatval($row['w1_cost']);
149
ff45488d480e Added some icons from Brewersfriend. They should be replaced someday. Added maximum mash weight setting to the equipment database. Usefull for brew automate and RIMS systems. During recipes import acid and base additions are translated. Brews and recipes now have 2 water sources. Added water mixer. Added basic water treatment, but not for pH yet. Redesigned the fermentables and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents: 121
diff changeset
863 $brew .= ',"w2_name":"' . str_replace($escapers, $replacements, $row['w2_name']);
359
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
864 $brew .= '","w2_amount":' . floatval($row['w2_amount']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
865 $brew .= ',"w2_calcium":' . floatval($row['w2_calcium']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
866 $brew .= ',"w2_sulfate":' . floatval($row['w2_sulfate']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
867 $brew .= ',"w2_chloride":' . floatval($row['w2_chloride']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
868 $brew .= ',"w2_sodium":' . floatval($row['w2_sodium']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
869 $brew .= ',"w2_magnesium":' . floatval($row['w2_magnesium']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
870 $brew .= ',"w2_total_alkalinity":' . floatval($row['w2_total_alkalinity']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
871 $brew .= ',"w2_ph":' . floatval($row['w2_ph']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
872 $brew .= ',"w2_cost":' . floatval($row['w2_cost']);
392
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
873 $brew .= ',"wg_amount":' . floatval($row['wg_amount']);
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
874 $brew .= ',"wg_calcium":' . floatval($row['wg_calcium']);
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
875 $brew .= ',"wg_sulfate":' . floatval($row['wg_sulfate']);
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
876 $brew .= ',"wg_chloride":' . floatval($row['wg_chloride']);
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
877 $brew .= ',"wg_sodium":' . floatval($row['wg_sodium']);
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
878 $brew .= ',"wg_magnesium":' . floatval($row['wg_magnesium']);
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
879 $brew .= ',"wg_total_alkalinity":' . floatval($row['wg_total_alkalinity']);
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
880 $brew .= ',"wg_ph":' . floatval($row['wg_ph']);
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
881 $brew .= ',"wb_calcium":' . floatval($row['wb_calcium']);
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
882 $brew .= ',"wb_sulfate":' . floatval($row['wb_sulfate']);
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
883 $brew .= ',"wb_chloride":' . floatval($row['wb_chloride']);
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
884 $brew .= ',"wb_sodium":' . floatval($row['wb_sodium']);
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
885 $brew .= ',"wb_magnesium":' . floatval($row['wb_magnesium']);
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
886 $brew .= ',"wb_total_alkalinity":' . floatval($row['wb_total_alkalinity']);
544d7d0183b2 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.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
887 $brew .= ',"wb_ph":' . floatval($row['wb_ph']);
235
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
888 $brew .= ',"wa_acid_name":' . $row['wa_acid_name'];
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
889 $brew .= ',"wa_acid_perc":' . $row['wa_acid_perc'];
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
890 $brew .= ',"wa_base_name":' . $row['wa_base_name'];
278
dc22dd5d77fd Initial design of a yeast starter calculator based on the Braukaiser model. Changed the yeast inventory prompts to the correct Dutch amounts. The pitchrate calculator makes a difference between light and heavy beers, turning point is a SG 1.060. Some code is from Homebrew Dad's calculator.
Michiel Broek <mbroek@mbse.eu>
parents: 254
diff changeset
891 $brew .= ',"starter_enable":' . $row['starter_enable'];
dc22dd5d77fd Initial design of a yeast starter calculator based on the Braukaiser model. Changed the yeast inventory prompts to the correct Dutch amounts. The pitchrate calculator makes a difference between light and heavy beers, turning point is a SG 1.060. Some code is from Homebrew Dad's calculator.
Michiel Broek <mbroek@mbse.eu>
parents: 254
diff changeset
892 $brew .= ',"starter_type":' . $row['starter_type'];
dc22dd5d77fd Initial design of a yeast starter calculator based on the Braukaiser model. Changed the yeast inventory prompts to the correct Dutch amounts. The pitchrate calculator makes a difference between light and heavy beers, turning point is a SG 1.060. Some code is from Homebrew Dad's calculator.
Michiel Broek <mbroek@mbse.eu>
parents: 254
diff changeset
893 $brew .= ',"starter_sg":' . $row['starter_sg'];
457
b9055393b802 Version 0.3.14. Added yeast viability calculations for liquid yeast packs.
Michiel Broek <mbroek@mbse.eu>
parents: 432
diff changeset
894 $brew .= ',"starter_viability":' . $row['starter_viability'];
617
f962f1e5936e Implemented yeast viability calculation from the yeast production date. Changed the pitchrate logic and added Ale above 1.076 rate of 1.25.
Michiel Broek <mbroek@mbse.eu>
parents: 616
diff changeset
895 $brew .= ',"yeast_prod_date":"' . $row['yeast_prod_date'];
697
367ae7ff52f0 Version 0.3.34 Changed log messages in the daemon. Added yeast_pitchrate field to the product database. Added yeast pitchrate edit field to the yeast tab. Initial value is guessed. There is also a popup window for predefined values. An finally the value can be edited by the user. All popup windows are initialized together.
Michiel Broek <mbroek@mbse.eu>
parents: 667
diff changeset
896 $brew .= '","yeast_pitchrate":' . $row['yeast_pitchrate'];
367ae7ff52f0 Version 0.3.34 Changed log messages in the daemon. Added yeast_pitchrate field to the product database. Added yeast pitchrate edit field to the yeast tab. Initial value is guessed. There is also a popup window for predefined values. An finally the value can be edited by the user. All popup windows are initialized together.
Michiel Broek <mbroek@mbse.eu>
parents: 667
diff changeset
897 $brew .= ',"prop1_type":' . $row['prop1_type'];
278
dc22dd5d77fd Initial design of a yeast starter calculator based on the Braukaiser model. Changed the yeast inventory prompts to the correct Dutch amounts. The pitchrate calculator makes a difference between light and heavy beers, turning point is a SG 1.060. Some code is from Homebrew Dad's calculator.
Michiel Broek <mbroek@mbse.eu>
parents: 254
diff changeset
898 $brew .= ',"prop1_volume":' . $row['prop1_volume'];
dc22dd5d77fd Initial design of a yeast starter calculator based on the Braukaiser model. Changed the yeast inventory prompts to the correct Dutch amounts. The pitchrate calculator makes a difference between light and heavy beers, turning point is a SG 1.060. Some code is from Homebrew Dad's calculator.
Michiel Broek <mbroek@mbse.eu>
parents: 254
diff changeset
899 $brew .= ',"prop2_type":' . $row['prop2_type'];
dc22dd5d77fd Initial design of a yeast starter calculator based on the Braukaiser model. Changed the yeast inventory prompts to the correct Dutch amounts. The pitchrate calculator makes a difference between light and heavy beers, turning point is a SG 1.060. Some code is from Homebrew Dad's calculator.
Michiel Broek <mbroek@mbse.eu>
parents: 254
diff changeset
900 $brew .= ',"prop2_volume":' . $row['prop2_volume'];
dc22dd5d77fd Initial design of a yeast starter calculator based on the Braukaiser model. Changed the yeast inventory prompts to the correct Dutch amounts. The pitchrate calculator makes a difference between light and heavy beers, turning point is a SG 1.060. Some code is from Homebrew Dad's calculator.
Michiel Broek <mbroek@mbse.eu>
parents: 254
diff changeset
901 $brew .= ',"prop3_type":' . $row['prop3_type'];
dc22dd5d77fd Initial design of a yeast starter calculator based on the Braukaiser model. Changed the yeast inventory prompts to the correct Dutch amounts. The pitchrate calculator makes a difference between light and heavy beers, turning point is a SG 1.060. Some code is from Homebrew Dad's calculator.
Michiel Broek <mbroek@mbse.eu>
parents: 254
diff changeset
902 $brew .= ',"prop3_volume":' . $row['prop3_volume'];
dc22dd5d77fd Initial design of a yeast starter calculator based on the Braukaiser model. Changed the yeast inventory prompts to the correct Dutch amounts. The pitchrate calculator makes a difference between light and heavy beers, turning point is a SG 1.060. Some code is from Homebrew Dad's calculator.
Michiel Broek <mbroek@mbse.eu>
parents: 254
diff changeset
903 $brew .= ',"prop4_type":' . $row['prop4_type'];
dc22dd5d77fd Initial design of a yeast starter calculator based on the Braukaiser model. Changed the yeast inventory prompts to the correct Dutch amounts. The pitchrate calculator makes a difference between light and heavy beers, turning point is a SG 1.060. Some code is from Homebrew Dad's calculator.
Michiel Broek <mbroek@mbse.eu>
parents: 254
diff changeset
904 $brew .= ',"prop4_volume":' . $row['prop4_volume'];
dc22dd5d77fd Initial design of a yeast starter calculator based on the Braukaiser model. Changed the yeast inventory prompts to the correct Dutch amounts. The pitchrate calculator makes a difference between light and heavy beers, turning point is a SG 1.060. Some code is from Homebrew Dad's calculator.
Michiel Broek <mbroek@mbse.eu>
parents: 254
diff changeset
905
497
0fe366d953ab Prepare screens for product divide batch.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
906 $brew .= ',"divide_type":' . $row['divide_type'];
0fe366d953ab Prepare screens for product divide batch.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
907 $brew .= ',"divide_size":' . floatval($row['divide_size']);
533
be8691b7d634 Added the product divide scripts. All parts have all the volumes and weights divided, including the master record. Splitted batches have their own records with the product code formatted as code-n. From this design, we can rebuild the print and checklist.
Michiel Broek <mbroek@mbse.eu>
parents: 518
diff changeset
908 $brew .= ',"divide_factor":' . floatval($row['divide_factor']);
497
0fe366d953ab Prepare screens for product divide batch.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
909 $brew .= ',"divide_parts":' . $row['divide_parts'];
533
be8691b7d634 Added the product divide scripts. All parts have all the volumes and weights divided, including the master record. Splitted batches have their own records with the product code formatted as code-n. From this design, we can rebuild the print and checklist.
Michiel Broek <mbroek@mbse.eu>
parents: 518
diff changeset
910 $brew .= ',"divide_part":' . $row['divide_part'];
497
0fe366d953ab Prepare screens for product divide batch.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
911
235
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
912 if (isset($_GET['record'])) {
740
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
913 $mashkg = 0.0;
235
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
914 // Append stock information.
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
915 $fermentables = json_decode($row['json_fermentables'], true);
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
916 for ($i = 0; $i < count($fermentables); $i++) {
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
917 $fermentables[$i]['f_inventory'] = 0; // Not in stock
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
918 $fermentables[$i]['f_avail'] = 0; // Ingredient not in db
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
919 $sql2 = "SELECT inventory FROM inventory_fermentables ";
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
920 $sql2 .= "WHERE name='".str_replace($rescapers, $rreplacements, $fermentables[$i]['f_name'])."' AND";
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
921 $sql2 .= " supplier='".str_replace($rescapers, $rreplacements, $fermentables[$i]['f_supplier'])."'";
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
922 if ($result2 = mysqli_query($connect, $sql2)) {
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
923 if ($obj = mysqli_fetch_object($result2)) {
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
924 $fermentables[$i]['f_inventory'] = floatval($obj->inventory);
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
925 $fermentables[$i]['f_avail'] = 1;
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
926 }
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
927 mysqli_free_result($result2);
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
928 }
740
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
929 if ($fermentables[$i]['f_added'] == 0) {
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
930 $mashkg += floatval($fermentables[$i]['f_amount']);
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
931 }
235
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
932 }
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
933 $brew .= ',"fermentables":' . json_encode($fermentables, JSON_UNESCAPED_UNICODE);
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
934
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
935 $hops = json_decode($row['json_hops'], true);
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
936 for ($i = 0; $i < count($hops); $i++) {
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
937 $hops[$i]['h_inventory'] = 0; // Not in stock
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
938 $hops[$i]['h_avail'] = 0; // Ingredient not in db
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
939 $sql2 = "SELECT inventory FROM inventory_hops ";
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
940 $sql2 .= "WHERE name='".str_replace($rescapers, $rreplacements, $hops[$i]['h_name'])."' AND";
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
941 $sql2 .= " origin='".str_replace($rescapers, $rreplacements, $hops[$i]['h_origin'])."' AND";
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
942 $sql2 .= " form='".$hops[$i]['h_form']."'";
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
943 if ($result2 = mysqli_query($connect, $sql2)) {
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
944 if ($obj = mysqli_fetch_object($result2)) {
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
945 $hops[$i]['h_inventory'] = floatval($obj->inventory);
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
946 $hops[$i]['h_avail'] = 1;
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
947 }
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
948 mysqli_free_result($result2);
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
949 }
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
950 }
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
951 $brew .= ',"hops":' . json_encode($hops, JSON_UNESCAPED_UNICODE);
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
952
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
953 $miscs = json_decode($row['json_miscs'], true);
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
954 for ($i = 0; $i < count($miscs); $i++) {
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
955 $miscs[$i]['m_inventory'] = 0; // Not in stock
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
956 $miscs[$i]['m_avail'] = 0; // Ingredient not in db
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
957 $sql2 = "SELECT inventory FROM inventory_miscs ";
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
958 $sql2 .= "WHERE name='".str_replace($rescapers, $rreplacements, $miscs[$i]['m_name'])."' AND";
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
959 $sql2 .= " type='".$miscs[$i]['m_type']."'";
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
960 if ($result2 = mysqli_query($connect, $sql2)) {
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
961 if ($obj = mysqli_fetch_object($result2)) {
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
962 $miscs[$i]['m_inventory'] = floatval($obj->inventory);
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
963 $miscs[$i]['m_avail'] = 1;
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
964 }
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
965 mysqli_free_result($result2);
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
966 }
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
967 }
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
968 $brew .= ',"miscs":' . json_encode($miscs, JSON_UNESCAPED_UNICODE);
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
969
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
970 $yeasts = json_decode($row['json_yeasts'], true);
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
971 for ($i = 0; $i < count($yeasts); $i++) {
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
972 $yeasts[$i]['y_inventory'] = 0; // Not in stock
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
973 $yeasts[$i]['y_avail'] = 0; // Ingredient not in db
359
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
974 if (! isset($yeasts[$i]['y_tolerance']))
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
975 $yeasts[$i]['y_tolerance'] = 0;
726
872a3635e4ef Changed dry-yeast calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
976 $sql2 = "SELECT inventory,tolerance,sta1,bacteria,harvest_top,harvest_time,pitch_temperature,pofpos,zymocide,gr_hl_lo,sg_lo,gr_hl_hi,sg_hi ";
554
c62ff53cfc3d Added the new Kveik yeast fields to the product editor. Added auto update when a product is loaded. Added extra lines to the checklist about harvest yeast and pitch temperature.
Michiel Broek <mbroek@mbse.eu>
parents: 533
diff changeset
977 $sql2 .= "FROM inventory_yeasts ";
235
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
978 $sql2 .= "WHERE name='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_name'])."' AND";
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
979 $sql2 .= " form='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_form'])."' AND";
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
980 $sql2 .= " laboratory='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_laboratory'])."' AND";
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
981 $sql2 .= " product_id='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_product_id'])."'";
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
982 if ($result2 = mysqli_query($connect, $sql2)) {
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
983 if ($obj = mysqli_fetch_object($result2)) {
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
984 $yeasts[$i]['y_inventory'] = floatval($obj->inventory);
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
985 $yeasts[$i]['y_avail'] = 1;
554
c62ff53cfc3d Added the new Kveik yeast fields to the product editor. Added auto update when a product is loaded. Added extra lines to the checklist about harvest yeast and pitch temperature.
Michiel Broek <mbroek@mbse.eu>
parents: 533
diff changeset
986 if ($yeasts[$i]['y_tolerance'] == 0)
332
f0ca77097236 Display alcohol tolerance in the yeast editor. Display in red when the recipe estimate is higher then the yeast tolerance.
Michiel Broek <mbroek@mbse.eu>
parents: 326
diff changeset
987 $yeasts[$i]['y_tolerance'] = floatval($obj->tolerance); // Upgrade alcohol tolerance
554
c62ff53cfc3d Added the new Kveik yeast fields to the product editor. Added auto update when a product is loaded. Added extra lines to the checklist about harvest yeast and pitch temperature.
Michiel Broek <mbroek@mbse.eu>
parents: 533
diff changeset
988 // Upgrade new fields
c62ff53cfc3d Added the new Kveik yeast fields to the product editor. Added auto update when a product is loaded. Added extra lines to the checklist about harvest yeast and pitch temperature.
Michiel Broek <mbroek@mbse.eu>
parents: 533
diff changeset
989 if (! isset($yeasts[$i]['y_sta1']))
c62ff53cfc3d Added the new Kveik yeast fields to the product editor. Added auto update when a product is loaded. Added extra lines to the checklist about harvest yeast and pitch temperature.
Michiel Broek <mbroek@mbse.eu>
parents: 533
diff changeset
990 $yeasts[$i]['y_sta1'] = intval($obj->sta1);
c62ff53cfc3d Added the new Kveik yeast fields to the product editor. Added auto update when a product is loaded. Added extra lines to the checklist about harvest yeast and pitch temperature.
Michiel Broek <mbroek@mbse.eu>
parents: 533
diff changeset
991 if (! isset($yeasts[$i]['y_bacteria']))
c62ff53cfc3d Added the new Kveik yeast fields to the product editor. Added auto update when a product is loaded. Added extra lines to the checklist about harvest yeast and pitch temperature.
Michiel Broek <mbroek@mbse.eu>
parents: 533
diff changeset
992 $yeasts[$i]['y_bacteria'] = intval($obj->bacteria);
c62ff53cfc3d Added the new Kveik yeast fields to the product editor. Added auto update when a product is loaded. Added extra lines to the checklist about harvest yeast and pitch temperature.
Michiel Broek <mbroek@mbse.eu>
parents: 533
diff changeset
993 if (! isset($yeasts[$i]['y_harvest_top']))
c62ff53cfc3d Added the new Kveik yeast fields to the product editor. Added auto update when a product is loaded. Added extra lines to the checklist about harvest yeast and pitch temperature.
Michiel Broek <mbroek@mbse.eu>
parents: 533
diff changeset
994 $yeasts[$i]['y_harvest_top'] = intval($obj->harvest_top);
c62ff53cfc3d Added the new Kveik yeast fields to the product editor. Added auto update when a product is loaded. Added extra lines to the checklist about harvest yeast and pitch temperature.
Michiel Broek <mbroek@mbse.eu>
parents: 533
diff changeset
995 if (! isset($yeasts[$i]['y_harvest_time']))
c62ff53cfc3d Added the new Kveik yeast fields to the product editor. Added auto update when a product is loaded. Added extra lines to the checklist about harvest yeast and pitch temperature.
Michiel Broek <mbroek@mbse.eu>
parents: 533
diff changeset
996 $yeasts[$i]['y_harvest_time'] = intval($obj->harvest_time);
c62ff53cfc3d Added the new Kveik yeast fields to the product editor. Added auto update when a product is loaded. Added extra lines to the checklist about harvest yeast and pitch temperature.
Michiel Broek <mbroek@mbse.eu>
parents: 533
diff changeset
997 if (! isset($yeasts[$i]['y_pitch_temperature']))
c62ff53cfc3d Added the new Kveik yeast fields to the product editor. Added auto update when a product is loaded. Added extra lines to the checklist about harvest yeast and pitch temperature.
Michiel Broek <mbroek@mbse.eu>
parents: 533
diff changeset
998 $yeasts[$i]['y_pitch_temperature'] = floatval($obj->pitch_temperature);
c62ff53cfc3d Added the new Kveik yeast fields to the product editor. Added auto update when a product is loaded. Added extra lines to the checklist about harvest yeast and pitch temperature.
Michiel Broek <mbroek@mbse.eu>
parents: 533
diff changeset
999 if (! isset($yeasts[$i]['y_pofpos']))
c62ff53cfc3d Added the new Kveik yeast fields to the product editor. Added auto update when a product is loaded. Added extra lines to the checklist about harvest yeast and pitch temperature.
Michiel Broek <mbroek@mbse.eu>
parents: 533
diff changeset
1000 $yeasts[$i]['y_pofpos'] = intval($obj->pofpos);
c62ff53cfc3d Added the new Kveik yeast fields to the product editor. Added auto update when a product is loaded. Added extra lines to the checklist about harvest yeast and pitch temperature.
Michiel Broek <mbroek@mbse.eu>
parents: 533
diff changeset
1001 if (! isset($yeasts[$i]['y_zymocide']))
c62ff53cfc3d Added the new Kveik yeast fields to the product editor. Added auto update when a product is loaded. Added extra lines to the checklist about harvest yeast and pitch temperature.
Michiel Broek <mbroek@mbse.eu>
parents: 533
diff changeset
1002 $yeasts[$i]['y_zymocide'] = intval($obj->zymocide);
726
872a3635e4ef Changed dry-yeast calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
1003 if (! isset($yeasts[$i]['y_gr_hl_lo']))
872a3635e4ef Changed dry-yeast calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
1004 $yeasts[$i]['y_gr_hl_lo'] = intval($obj->gr_hl_lo);
872a3635e4ef Changed dry-yeast calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
1005 if (! isset($yeasts[$i]['y_sg_lo']))
872a3635e4ef Changed dry-yeast calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
1006 $yeasts[$i]['y_sg_lo'] = floatval($obj->sg_lo);
872a3635e4ef Changed dry-yeast calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
1007 if (! isset($yeasts[$i]['y_gr_hl_hi']))
872a3635e4ef Changed dry-yeast calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
1008 $yeasts[$i]['y_gr_hl_hi'] = intval($obj->gr_hl_hi);
872a3635e4ef Changed dry-yeast calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
1009 if (! isset($yeasts[$i]['y_sg_hi']))
872a3635e4ef Changed dry-yeast calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
1010 $yeasts[$i]['y_sg_hi'] = floatval($obj->sg_hi);
565
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 554
diff changeset
1011 } else {
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 554
diff changeset
1012 if (! isset($yeasts[$i]['y_sta1']))
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 554
diff changeset
1013 $yeasts[$i]['y_sta1'] = 0;
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 554
diff changeset
1014 if (! isset($yeasts[$i]['y_bacteria']))
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 554
diff changeset
1015 $yeasts[$i]['y_bacteria'] = 0;
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 554
diff changeset
1016 if (! isset($yeasts[$i]['y_harvest_top']))
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 554
diff changeset
1017 $yeasts[$i]['y_harvest_top'] = 0;
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 554
diff changeset
1018 if (! isset($yeasts[$i]['y_harvest_time']))
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 554
diff changeset
1019 $yeasts[$i]['y_harvest_time'] = 0;
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 554
diff changeset
1020 if (! isset($yeasts[$i]['y_pitch_temperature']))
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 554
diff changeset
1021 $yeasts[$i]['y_pitch_temperature'] = 0;
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 554
diff changeset
1022 if (! isset($yeasts[$i]['y_pofpos']))
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 554
diff changeset
1023 $yeasts[$i]['y_pofpos'] = 0;
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 554
diff changeset
1024 if (! isset($yeasts[$i]['y_zymocide']))
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 554
diff changeset
1025 $yeasts[$i]['y_zymocide'] = 0;
738
11e6bd8d8107 Added mash SG and pH fields. Fixed default Yeast update. Added mash step SG and pH input datafields. Added a Brix input too. The print report shows the mash measurements too. Other brewing results now show expected and measured values and the difference.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
1026 if (! isset($yeasts[$i]['y_gr_hl_lo']))
11e6bd8d8107 Added mash SG and pH fields. Fixed default Yeast update. Added mash step SG and pH input datafields. Added a Brix input too. The print report shows the mash measurements too. Other brewing results now show expected and measured values and the difference.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
1027 $yeasts[$i]['y_gr_hl_lo'] = 50;
11e6bd8d8107 Added mash SG and pH fields. Fixed default Yeast update. Added mash step SG and pH input datafields. Added a Brix input too. The print report shows the mash measurements too. Other brewing results now show expected and measured values and the difference.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
1028 if (! isset($yeasts[$i]['y_sg_lo']))
11e6bd8d8107 Added mash SG and pH fields. Fixed default Yeast update. Added mash step SG and pH input datafields. Added a Brix input too. The print report shows the mash measurements too. Other brewing results now show expected and measured values and the difference.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
1029 $yeasts[$i]['y_sg_lo'] = 1.04;
11e6bd8d8107 Added mash SG and pH fields. Fixed default Yeast update. Added mash step SG and pH input datafields. Added a Brix input too. The print report shows the mash measurements too. Other brewing results now show expected and measured values and the difference.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
1030 if (! isset($yeasts[$i]['y_gr_hl_hi']))
11e6bd8d8107 Added mash SG and pH fields. Fixed default Yeast update. Added mash step SG and pH input datafields. Added a Brix input too. The print report shows the mash measurements too. Other brewing results now show expected and measured values and the difference.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
1031 $yeasts[$i]['y_gr_hl_hi'] = 80;
11e6bd8d8107 Added mash SG and pH fields. Fixed default Yeast update. Added mash step SG and pH input datafields. Added a Brix input too. The print report shows the mash measurements too. Other brewing results now show expected and measured values and the difference.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
1032 if (! isset($yeasts[$i]['y_sg_hi']))
11e6bd8d8107 Added mash SG and pH fields. Fixed default Yeast update. Added mash step SG and pH input datafields. Added a Brix input too. The print report shows the mash measurements too. Other brewing results now show expected and measured values and the difference.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
1033 $yeasts[$i]['y_sg_hi'] = 1.08;
565
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 554
diff changeset
1034 }
235
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
1035 mysqli_free_result($result2);
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
1036 }
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
1037 }
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
1038 $brew .= ',"yeasts":' . json_encode($yeasts, JSON_UNESCAPED_UNICODE);
740
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1039
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1040 //syslog(LOG_NOTICE, $row['json_mashs']);
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1041 $mashs = json_decode($row['json_mashs'], true);
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1042 $mashvol = 0.0;
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1043 for ($i = 0; $i < count($mashs); $i++) {
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1044 /* Upgrade missing data */
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1045 if (($mashs[$i]['step_type'] == 0) && (floatval($mashs[$i]['step_infuse_amount']) > 0))
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1046 $mashvol += floatval($mashs[$i]['step_infuse_amount']);
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1047 if (($mashs[$i]['step_type'] == 0) && (! isset($mashs[$i]['step_infuse_temp']))) {
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1048 if ($i == 0)
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1049 $mashs[$i]['step_infuse_temp'] = floatval($mashs[$i]['step_temp']) + 0.5;
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1050 else
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1051 $mashs[$i]['step_infuse_temp'] = 99.0;
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1052 }
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1053 if (! isset($mashs[$i]['step_volume']))
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1054 $mashs[$i]['step_volume'] = $mashvol;
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1055 if (! isset($mashs[$i]['step_wg_ratio']))
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1056 $mashs[$i]['step_wg_ratio'] = round(($mashvol / $mashkg) * 1000000) / 1000000;
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1057 if (! isset($mashs[$i]['step_ph']))
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1058 $mashs[$i]['step_ph'] = 0.0;
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1059 if (! isset($mashs[$i]['step_sg']))
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1060 $mashs[$i]['step_sg'] = 0.0;
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1061 }
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1062 $brew .= ',"mashs":' . json_encode($mashs, JSON_UNESCAPED_UNICODE);
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1063
235
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
1064 } else {
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
1065 // Just leave it
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
1066 $brew .= ',"fermentables":' . $row['json_fermentables'];
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
1067 $brew .= ',"hops":' . $row['json_hops'];
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
1068 $brew .= ',"miscs":' . $row['json_miscs'];
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
1069 $brew .= ',"yeasts":' . $row['json_yeasts'];
740
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1070 $brew .= ',"mashs":' . $row['json_mashs'];
235
0a063ac5d7f5 Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 192
diff changeset
1071 }
740
04c0e444e48e Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.
Michiel Broek <mbroek@mbse.eu>
parents: 738
diff changeset
1072
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
1073 $brew .= '}';
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
1074 $brews .= $brew;
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1075 }
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
1076 $brews .= ']';
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
1077 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: 763
diff changeset
1078 exit($brews);
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1079 }
393
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1080
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1081
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1082
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1083 function reduce_fermentables($item) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1084
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1085 global $connect;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1086
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1087 $amount = round($item['f_amount'] * 1000) / 1000;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1088 $sql2 = "UPDATE inventory_fermentables SET inventory = inventory - " . $amount;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1089 $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $item['f_name']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1090 $sql2 .= "' AND origin='" . mysqli_real_escape_string($connect, $item['f_origin']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1091 $sql2 .= "' AND supplier='" . mysqli_real_escape_string($connect, $item['f_supplier']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1092 $sql2 .= "' AND inventory >= " . $amount;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1093 $sql2 .= " LIMIT 1;";
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1094 $result2 = mysqli_query($connect, $sql2);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1095 $ar = mysqli_affected_rows($connect);
773
f4161330ed01 Don't log successfull reduced ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 768
diff changeset
1096 if ($ar == 0) {
393
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1097 $sql2 = "UPDATE inventory_fermentables SET inventory = 0";
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1098 $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $item['f_name']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1099 $sql2 .= "' AND origin='" . mysqli_real_escape_string($connect, $item['f_origin']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1100 $sql2 .= "' AND supplier='" . mysqli_real_escape_string($connect, $item['f_supplier']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1101 $sql2 .= "' AND inventory < " . $amount;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1102 $sql2 .= " LIMIT 1;";
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1103 $result2 = mysqli_query($connect, $sql2);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1104 $ar = mysqli_affected_rows($connect);
773
f4161330ed01 Don't log successfull reduced ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 768
diff changeset
1105 if ($ar == 0) {
393
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1106 syslog(LOG_NOTICE, "Reduce fermentable `".$item['f_name']."' from `".$item['f_supplier']."' failed");
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1107 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1108 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1109 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1110
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1111
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1112
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1113 function reduce_hops($item) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1114
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1115 global $connect;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1116
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1117 $amount = round($item['h_amount'] * 1000) / 1000;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1118 $sql2 = "UPDATE inventory_hops SET inventory = inventory - " . $amount;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1119 $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $item['h_name']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1120 $sql2 .= "' AND origin='" . mysqli_real_escape_string($connect, $item['h_origin']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1121 $sql2 .= "' AND form=" . $item['h_form'];
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1122 $sql2 .= " AND inventory >= " . $amount . " LIMIT 1;";
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1123 $result2 = mysqli_query($connect, $sql2);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1124 $ar = mysqli_affected_rows($connect);
773
f4161330ed01 Don't log successfull reduced ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 768
diff changeset
1125 if ($ar == 0) {
393
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1126 $sql2 = "UPDATE inventory_hops SET inventory = 0";
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1127 $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $item['h_name']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1128 $sql2 .= "' AND origin='" . mysqli_real_escape_string($connect, $item['h_origin']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1129 $sql2 .= "' AND form=" . $item['h_form'];
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1130 $sql2 .= " AND inventory < " . $amount . " LIMIT 1;";
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1131 $result2 = mysqli_query($connect, $sql2);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1132 $ar = mysqli_affected_rows($connect);
773
f4161330ed01 Don't log successfull reduced ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 768
diff changeset
1133 if ($ar == 0) {
393
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1134 syslog(LOG_NOTICE, "Reduce hop `".$item['h_name']."' from `".$item['h_origin']."' failed");
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1135 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1136 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1137 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1138
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1139
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1140
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1141 function reduce_miscs($item) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1142
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1143 global $connect;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1144
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1145 $amount = round($item['m_amount'] * 100000) / 100000;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1146 $sql2 = "UPDATE inventory_miscs SET inventory = inventory - " . $amount;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1147 $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $item['m_name']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1148 $sql2 .= "' AND inventory >= " . $amount . " LIMIT 1;";
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1149 $result2 = mysqli_query($connect, $sql2);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1150 $ar = mysqli_affected_rows($connect);
773
f4161330ed01 Don't log successfull reduced ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 768
diff changeset
1151 if ($ar == 0) {
393
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1152 $sql2 = "UPDATE inventory_miscs SET inventory = 0";
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1153 $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $item['m_name']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1154 $sql2 .= "' AND inventory < " . $amount . " LIMIT 1;";
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1155 $result2 = mysqli_query($connect, $sql2);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1156 $ar = mysqli_affected_rows($connect);
773
f4161330ed01 Don't log successfull reduced ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 768
diff changeset
1157 if ($ar == 0) {
393
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1158 syslog(LOG_NOTICE, "Reduce misc `".$item['m_name']."' failed");
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1159 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1160 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1161 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1162
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1163
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1164
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1165 function reduce_yeast($item) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1166
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1167 global $connect;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1168
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1169 $amount = round($item['y_amount'] * 10000) / 10000;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1170 $sql2 = "UPDATE inventory_yeasts SET inventory = inventory - " . $amount;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1171 $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $item['y_name']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1172 $sql2 .= "' AND laboratory='" . mysqli_real_escape_string($connect, $item['y_laboratory']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1173 $sql2 .= "' AND product_id='" . mysqli_real_escape_string($connect, $item['y_product_id']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1174 $sql2 .= "' AND form=" . $item['y_form'];
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1175 $sql2 .= " AND inventory >= " . $amount . " LIMIT 1;";
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1176 $result2 = mysqli_query($connect, $sql2);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1177 $ar = mysqli_affected_rows($connect);
773
f4161330ed01 Don't log successfull reduced ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 768
diff changeset
1178 if ($ar == 0) {
393
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1179 $sql2 = "UPDATE inventory_yeasts SET inventory = 0";
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1180 $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $item['y_name']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1181 $sql2 .= "' AND laboratory='" . mysqli_real_escape_string($connect, $item['y_laboratory']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1182 $sql2 .= "' AND product_id='" . mysqli_real_escape_string($connect, $item['y_product_id']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1183 $sql2 .= "' AND form=" . $item['y_form'];
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1184 $sql2 .= " AND inventory < " . $amount . " LIMIT 1;";
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1185 $result2 = mysqli_query($connect, $sql2);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1186 $ar = mysqli_affected_rows($connect);
773
f4161330ed01 Don't log successfull reduced ingredients.
Michiel Broek <mbroek@mbse.eu>
parents: 768
diff changeset
1187 if ($ar == 0) {
393
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1188 syslog(LOG_NOTICE, "Reduce yeast `".$item['y_product_id'].' '.$item['y_name']."' from `".$item['y_laboratory']."' failed");
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1189 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1190 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1191 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1192
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1193
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1194
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1195 /*
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1196 * Reduce inventory depending on the production stage.
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1197 * Stage 3+, after brew, reduce sugars(0-mash, 1-boil), hops(0-mash, 1-fwh, 2-boil, 3-aroma, 4-whirlpool), miscs(0-starter, 1-mash, 2-boil)
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1198 * Stage 4+, after primary, reduce sugars(2-fermention), yeasts(0-Primary), miscs(3-primary)
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1199 * Stage 5+, after secondary, reduce yeasts(1-Secondary)
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1200 * Stage 6+, after tertiary, reduce sugars(3-lagering), hops(5-dry-hop), yeasts(2-Tertiary), miscs(4-secondary)
411
077ada2dda9b Reduce fermentables after packaging. Always enable the packaging tab but only enable the packaging date in the lagering state. This allows early priming sugar settings.
Michiel Broek <mbroek@mbse.eu>
parents: 408
diff changeset
1201 * Stage 7+, after packaging, reduce sugars(4-bottle, 5-kegs), yeasts(3-Bottle), miscs(5-bottling)
393
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1202 */
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1203 function inventory_reduce() {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1204
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1205 global $connect;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1206
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1207 $savethis = 0;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1208 $stage = $_POST['stage'];
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1209 $inventory_reduced = $_POST['inventory_reduced'];
408
a93c9473a7c3 De database velden bottle_priming_sugar en keg_priming_sugar worden niet meer gebruikt.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
1210 if ($stage == $inventory_reduced) {
a93c9473a7c3 De database velden bottle_priming_sugar en keg_priming_sugar worden niet meer gebruikt.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
1211 return;
a93c9473a7c3 De database velden bottle_priming_sugar en keg_priming_sugar worden niet meer gebruikt.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
1212 }
393
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1213 syslog(LOG_NOTICE, "inventory_reduce() stage: ".$stage." inventory_reduced: ".$inventory_reduced);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1214
715
8fb922c00a2d Remove log messages if database inventory updates are successfull. Allways update inventory reduced stages.
Michiel Broek <mbroek@mbse.eu>
parents: 711
diff changeset
1215 /* Nothing to reduce yet, but just set the $inventory_reduced */
8fb922c00a2d Remove log messages if database inventory updates are successfull. Allways update inventory reduced stages.
Michiel Broek <mbroek@mbse.eu>
parents: 711
diff changeset
1216 if (($stage >= 1) && ($inventory_reduced < 1)) {
8fb922c00a2d Remove log messages if database inventory updates are successfull. Allways update inventory reduced stages.
Michiel Broek <mbroek@mbse.eu>
parents: 711
diff changeset
1217 $inventory_reduced = 1;
8fb922c00a2d Remove log messages if database inventory updates are successfull. Allways update inventory reduced stages.
Michiel Broek <mbroek@mbse.eu>
parents: 711
diff changeset
1218 $savethis = 1;
8fb922c00a2d Remove log messages if database inventory updates are successfull. Allways update inventory reduced stages.
Michiel Broek <mbroek@mbse.eu>
parents: 711
diff changeset
1219 }
8fb922c00a2d Remove log messages if database inventory updates are successfull. Allways update inventory reduced stages.
Michiel Broek <mbroek@mbse.eu>
parents: 711
diff changeset
1220 if (($stage >= 2) && ($inventory_reduced < 2)) {
8fb922c00a2d Remove log messages if database inventory updates are successfull. Allways update inventory reduced stages.
Michiel Broek <mbroek@mbse.eu>
parents: 711
diff changeset
1221 $inventory_reduced = 2;
8fb922c00a2d Remove log messages if database inventory updates are successfull. Allways update inventory reduced stages.
Michiel Broek <mbroek@mbse.eu>
parents: 711
diff changeset
1222 $savethis = 1;
8fb922c00a2d Remove log messages if database inventory updates are successfull. Allways update inventory reduced stages.
Michiel Broek <mbroek@mbse.eu>
parents: 711
diff changeset
1223 }
8fb922c00a2d Remove log messages if database inventory updates are successfull. Allways update inventory reduced stages.
Michiel Broek <mbroek@mbse.eu>
parents: 711
diff changeset
1224
393
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1225 /*
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1226 * If the brew is done, reduce the used ingredients.
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1227 */
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1228 if (($stage >= 3) && ($inventory_reduced < 3)) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1229 syslog(LOG_NOTICE, "Reduce brew inventory from " . $_POST['code'] . " " . $_POST['name']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1230
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1231 if (isset($_POST['fermentables'])) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1232 $array = $_POST['fermentables'];
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1233 foreach($array as $key => $item) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1234 if ($item['f_added'] <= 1) { // Mash, Boil
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1235 reduce_fermentables($item);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1236 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1237 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1238 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1239
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1240 if (isset($_POST['hops'])) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1241 $array = $_POST['hops'];
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1242 foreach($array as $key => $item) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1243 if ($item['h_useat'] <= 4) { // Mash, FWH, Boil, Flameout, Whirlpool
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1244 reduce_hops($item);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1245 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1246 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1247 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1248
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1249 if (isset($_POST['miscs'])) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1250 $array = $_POST['miscs'];
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1251 foreach($array as $key => $item) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1252 if ($item['m_use_use'] <= 2) { // Starter, Mash, Boil
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1253 reduce_miscs($item);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1254 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1255 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1256 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1257
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1258 if ($_POST['w1_name'] != '') {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1259 $sql2 = "UPDATE inventory_waters SET inventory = inventory - ".$_POST['w1_amount'];
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1260 $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $_POST['w1_name']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1261 $sql2 .= "' AND unlimited_stock=0 AND inventory >= ".$_POST['w1_amount']." LIMIT 1;";
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1262 $result2 = mysqli_query($connect, $sql2);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1263 $ar = mysqli_affected_rows($connect);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1264 if ($ar == 1) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1265 syslog(LOG_NOTICE, "Reduced water `".$_POST['w1_name']."' with ".$_POST['w1_amount']." liter");
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1266 } else if ($ar == 0) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1267 $sql2 = "UPDATE inventory_waters SET inventory = 0";
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1268 $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $_POST['w1_name']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1269 $sql2 .= "' AND unlimited_stock=0 AND inventory < ".$_POST['w1_amount']." LIMIT 1;";
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1270 $result2 = mysqli_query($connect, $sql2);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1271 $ar = mysqli_affected_rows($connect);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1272 if ($ar == 1) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1273 syslog(LOG_NOTICE, "Reduced water `".$_POST['w1_name']."' to 0 liters");
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1274 } else {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1275 syslog(LOG_NOTICE, "Reduce water `".$_POST['w1_name']."' not reduced is maybe tapwater");
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1276 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1277 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1278 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1279 if ($_POST['w2_name'] != '') {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1280 $sql2 = "UPDATE inventory_waters SET inventory = inventory - ".$_POST['w2_amount'];
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1281 $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $_POST['w2_name']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1282 $sql2 .= "' AND unlimited_stock=0 AND inventory >= ".$_POST['w2_amount']." LIMIT 1;";
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1283 $result2 = mysqli_query($connect, $sql2);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1284 $ar = mysqli_affected_rows($connect);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1285 if ($ar == 1) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1286 syslog(LOG_NOTICE, "Reduced water `".$_POST['w2_name']."' with ".$_POST['w2_amount']." liter");
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1287 } else if ($ar == 0) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1288 $sql2 = "UPDATE inventory_waters SET inventory = 0";
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1289 $sql2 .= " WHERE name='" . mysqli_real_escape_string($connect, $_POST['w2_name']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1290 $sql2 .= "' AND unlimited_stock=0 AND inventory < ".$_POST['w2_amount']." LIMIT 1;";
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1291 $result2 = mysqli_query($connect, $sql2);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1292 $ar = mysqli_affected_rows($connect);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1293 if ($ar == 1) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1294 syslog(LOG_NOTICE, "Reduced water `".$_POST['w2_name']."' to 0 liters");
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1295 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1296 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1297 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1298
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1299 $inventory_reduced = 3;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1300 $savethis = 1;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1301 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1302
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1303 /*
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1304 * After the Primary fermentation
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1305 */
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1306 if (($stage >= 4) && ($inventory_reduced < 4)) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1307 syslog(LOG_NOTICE, "Reduce Primary inventory from " . $_POST['code'] . " " . $_POST['name']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1308
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1309 if (isset($_POST['fermentables'])) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1310 $array = $_POST['fermentables'];
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1311 foreach($array as $key => $item) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1312 if ($item['f_added'] == 2) { // Fermentation
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1313 reduce_fermentables($item);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1314 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1315 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1316 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1317
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1318 if (isset($_POST['miscs'])) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1319 $array = $_POST['miscs'];
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1320 foreach($array as $key => $item) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1321 if ($item['m_use_use'] == 3) { // Fermentation
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1322 reduce_miscs($item);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1323 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1324 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1325 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1326
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1327 if (isset($_POST['yeasts'])) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1328 $array = $_POST['yeasts'];
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1329 foreach($array as $key => $item) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1330 if ($item['y_use'] == 0) { // Primary
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1331 reduce_yeast($item);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1332 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1333 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1334 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1335
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1336 $inventory_reduced = 4;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1337 $savethis = 1;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1338 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1339
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1340
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1341 /*
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1342 * After the Seconday fermentation
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1343 */
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1344 if (($stage >= 5) && ($inventory_reduced < 5)) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1345 syslog(LOG_NOTICE, "Reduce Secondary inventory from " . $_POST['code'] . " " . $_POST['name']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1346
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1347 if (isset($_POST['yeasts'])) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1348 $array = $_POST['yeasts'];
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1349 foreach($array as $key => $item) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1350 if ($item['y_use'] == 1) { // Secondary
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1351 reduce_yeast($item);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1352 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1353 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1354 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1355
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1356 $inventory_reduced = 5;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1357 $savethis = 1;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1358 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1359
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1360
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1361 /*
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1362 * After the Tertiary fermentation
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1363 */
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1364 if (($stage >= 6) && ($inventory_reduced < 6)) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1365 syslog(LOG_NOTICE, "Reduce Tertiary inventory from " . $_POST['code'] . " " . $_POST['name']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1366
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1367 if (isset($_POST['fermentables'])) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1368 $array = $_POST['fermentables'];
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1369 foreach($array as $key => $item) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1370 if ($item['f_added'] == 3) { // Lagering
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1371 reduce_fermentables($item);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1372 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1373 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1374 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1375
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1376 if (isset($_POST['hops'])) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1377 $array = $_POST['hops'];
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1378 foreach($array as $key => $item) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1379 if ($item['h_useat'] == 5) { // Dry hop
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1380 reduce_hops($item);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1381 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1382 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1383 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1384
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1385 if (isset($_POST['yeasts'])) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1386 $array = $_POST['yeasts'];
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1387 foreach($array as $key => $item) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1388 if ($item['y_use'] == 2) { // Tertiary
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1389 reduce_yeast($item);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1390 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1391 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1392 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1393
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1394 if (isset($_POST['miscs'])) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1395 $array = $_POST['miscs'];
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1396 foreach($array as $key => $item) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1397 if ($item['m_use_use'] == 4) { // Secondary or Tertiary
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1398 reduce_miscs($item);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1399 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1400 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1401 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1402
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1403 $inventory_reduced = 6;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1404 $savethis = 1;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1405 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1406
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1407 /*
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1408 * After packaging
411
077ada2dda9b Reduce fermentables after packaging. Always enable the packaging tab but only enable the packaging date in the lagering state. This allows early priming sugar settings.
Michiel Broek <mbroek@mbse.eu>
parents: 408
diff changeset
1409 * reduce sugars(4/5-bottle), yeasts(3-Bottle), miscs(5-bottling)
393
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1410 */
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1411 if (($stage >= 6) && ($inventory_reduced < 7)) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1412 syslog(LOG_NOTICE, "Reduce Packaging inventory from " . $_POST['code'] . " " . $_POST['name']);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1413
411
077ada2dda9b Reduce fermentables after packaging. Always enable the packaging tab but only enable the packaging date in the lagering state. This allows early priming sugar settings.
Michiel Broek <mbroek@mbse.eu>
parents: 408
diff changeset
1414 if (isset($_POST['fermentables'])) {
077ada2dda9b Reduce fermentables after packaging. Always enable the packaging tab but only enable the packaging date in the lagering state. This allows early priming sugar settings.
Michiel Broek <mbroek@mbse.eu>
parents: 408
diff changeset
1415 $array = $_POST['fermentables'];
077ada2dda9b Reduce fermentables after packaging. Always enable the packaging tab but only enable the packaging date in the lagering state. This allows early priming sugar settings.
Michiel Broek <mbroek@mbse.eu>
parents: 408
diff changeset
1416 foreach($array as $key => $item) {
077ada2dda9b Reduce fermentables after packaging. Always enable the packaging tab but only enable the packaging date in the lagering state. This allows early priming sugar settings.
Michiel Broek <mbroek@mbse.eu>
parents: 408
diff changeset
1417 if ($item['f_added'] >= 4) { // Bottling or Kegging
077ada2dda9b Reduce fermentables after packaging. Always enable the packaging tab but only enable the packaging date in the lagering state. This allows early priming sugar settings.
Michiel Broek <mbroek@mbse.eu>
parents: 408
diff changeset
1418 reduce_fermentables($item);
077ada2dda9b Reduce fermentables after packaging. Always enable the packaging tab but only enable the packaging date in the lagering state. This allows early priming sugar settings.
Michiel Broek <mbroek@mbse.eu>
parents: 408
diff changeset
1419 }
077ada2dda9b Reduce fermentables after packaging. Always enable the packaging tab but only enable the packaging date in the lagering state. This allows early priming sugar settings.
Michiel Broek <mbroek@mbse.eu>
parents: 408
diff changeset
1420 }
077ada2dda9b Reduce fermentables after packaging. Always enable the packaging tab but only enable the packaging date in the lagering state. This allows early priming sugar settings.
Michiel Broek <mbroek@mbse.eu>
parents: 408
diff changeset
1421 }
393
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1422
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1423 if (isset($_POST['yeasts'])) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1424 $array = $_POST['yeasts'];
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1425 foreach($array as $key => $item) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1426 if ($item['y_use'] == 3) { // Bottle
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1427 reduce_yeast($item);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1428 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1429 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1430 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1431
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1432 if (isset($_POST['miscs'])) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1433 $array = $_POST['miscs'];
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1434 foreach($array as $key => $item) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1435 if ($item['m_use_use'] == 5) { // Bottle
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1436 reduce_miscs($item);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1437 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1438 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1439 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1440
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1441 if ($stage < 7)
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1442 $stage = 7;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1443 $inventory_reduced = $stage;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1444 $savethis = 1;
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1445 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1446
715
8fb922c00a2d Remove log messages if database inventory updates are successfull. Allways update inventory reduced stages.
Michiel Broek <mbroek@mbse.eu>
parents: 711
diff changeset
1447 if (($stage >= 8) && ($inventory_reduced < $stage)) {
8fb922c00a2d Remove log messages if database inventory updates are successfull. Allways update inventory reduced stages.
Michiel Broek <mbroek@mbse.eu>
parents: 711
diff changeset
1448 $inventory_reduced = $stage;
8fb922c00a2d Remove log messages if database inventory updates are successfull. Allways update inventory reduced stages.
Michiel Broek <mbroek@mbse.eu>
parents: 711
diff changeset
1449 $savethis = 1;
8fb922c00a2d Remove log messages if database inventory updates are successfull. Allways update inventory reduced stages.
Michiel Broek <mbroek@mbse.eu>
parents: 711
diff changeset
1450 }
8fb922c00a2d Remove log messages if database inventory updates are successfull. Allways update inventory reduced stages.
Michiel Broek <mbroek@mbse.eu>
parents: 711
diff changeset
1451
393
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1452 /*
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1453 * Save only if something was reduced.
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1454 */
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1455 if ($savethis == 1) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1456 $sql2 = "UPDATE products SET stage=".$stage.", inventory_reduced=".$inventory_reduced." WHERE record='".$_POST['record']."';";
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1457 syslog(LOG_NOTICE, $sql2);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1458 $result2 = mysqli_query($connect, $sql2);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1459 $ar = mysqli_affected_rows($connect);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1460 if ($ar != 1) {
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1461 syslog(LOG_NOTICE, $sql2." error, affected rows: ".$ar);
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1462 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1463 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1464 }
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1465
5020feba78ec Moved the reduce inventory code from the crontask to the db_productsphp file so the reduce is done only after a save of a record.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
1466
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1467 ?>

mercurial