Mon, 19 Nov 2018 13:44:07 +0100
Added uuid and locked fields to the recipes table.
11 | 1 | <?php |
2 | /* | |
3 | * Import inventory from brouwhulp | |
4 | */ | |
5 | ||
6 | require("../config.php"); | |
7 | require("../version.php"); | |
8 | require("../includes/formulas.php"); | |
9 | ||
10 | echo "Start adding data from brouwhulp\n"; | |
11 | ||
12 | $db = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME); | |
13 | if (! $db) { | |
14 | die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); | |
15 | } | |
77
a9f8de2d7b2b
Fixed most charset problems. Added fpdf library. Added inventory pdf creation.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
16 | mysqli_set_charset($db, "utf8" ); |
11 | 17 | |
18 | $brouwhulp = '/home/mbroek/Documents/brouwhulp'; | |
19 | ||
20 | ||
89
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
21 | function get_miscs_cost($miscname) { |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
22 | global $db; |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
23 | |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
24 | if ($result = mysqli_query($db, "SELECT cost FROM inventory_miscs WHERE name='$miscname'")) { |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
25 | if ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
26 | return floatval($row['cost']); |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
27 | } |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
28 | } |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
29 | return 0.0; |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
30 | } |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
31 | |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
32 | |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
33 | |
11 | 34 | function do_fermentables() |
35 | { | |
36 | global $brouwhulp, $db; | |
37 | ||
38 | echo " Start adding fermentables to the database\n"; | |
39 | $sql = "TRUNCATE TABLE inventory_fermentables;"; | |
40 | if (! $result = mysqli_query($db, $sql)) { | |
41 | printf("Error: %s\n", mysqli_error($db)); | |
42 | } | |
43 | $myfermentables = simplexml_load_file($brouwhulp . '/fermentables.xml'); | |
44 | ||
45 | foreach ($myfermentables->FERMENTABLE as $fermentable) { | |
46 | ||
47 | $sql = "INSERT INTO inventory_fermentables SET name='" . mysqli_real_escape_string($db, $fermentable->NAME); | |
48 | $sql .= "', type='" . $fermentable->TYPE; | |
49 | if ($fermentable->YIELD) | |
50 | $sql .= "', yield='" . $fermentable->YIELD; | |
51 | if ($fermentable->COLOR) { | |
32
8bb369f32ef9
Fixed floating precision problems and also got the SRM to EBC conversion right.
Michiel Broek <mbroek@mbse.eu>
parents:
30
diff
changeset
|
52 | $srm = floatval($fermentable->COLOR); |
11 | 53 | $ebc = srm_to_ebc($srm); |
54 | $sql .= "', color='" . $ebc; | |
55 | } | |
56 | ($fermentable->ADD_AFTER_BOIL == "TRUE") ? $sql .= "', add_after_boil='1" : $sql .= "', add_after_boil='0"; | |
57 | $sql .= "', origin='" . mysqli_real_escape_string($db, $fermentable->ORIGIN); | |
58 | $sql .= "', supplier='" . mysqli_real_escape_string($db, $fermentable->SUPPLIER); | |
59 | $sql .= "', notes='" . mysqli_real_escape_string($db, $fermentable->NOTES); | |
60 | if ($fermentable->COARSE_FINE_DIFF) | |
61 | $sql .= "', coarse_fine_diff='" . $fermentable->COARSE_FINE_DIFF; | |
62 | if ($fermentable->MOISTURE) | |
63 | $sql .= "', moisture='" . $fermentable->MOISTURE; | |
64 | if ($fermentable->DIASTATIC_POWER) | |
65 | $sql .= "', diastatic_power='" . $fermentable->DIASTATIC_POWER; | |
66 | if ($fermentable->PROTEIN) | |
67 | $sql .= "', protein='" . $fermentable->PROTEIN; | |
68 | if ($fermentable->MAX_IN_BATCH) | |
69 | $sql .= "', max_in_batch='" . $fermentable->MAX_IN_BATCH; | |
21
acb2d8098f19
Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
20
diff
changeset
|
70 | ($fermentable->RECOMMEND_MASH == "TRUE") ? $sql .= "', recommend_mash='1" : $sql .= "', recommend_mash='0"; |
11 | 71 | if ($fermentable->IBU_GAL_PER_LB) |
72 | $sql .= "', ibu_gal_per_lb='" . $fermentable->IBU_GAL_PER_LB; | |
21
acb2d8098f19
Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
20
diff
changeset
|
73 | ($fermentable->ALWAYS_ON_STOCK == "TRUE") ? $sql .= "', always_on_stock='1" : $sql .= "', always_on_stock='0"; |
11 | 74 | if ($fermentable->INVENTORY) |
32
8bb369f32ef9
Fixed floating precision problems and also got the SRM to EBC conversion right.
Michiel Broek <mbroek@mbse.eu>
parents:
30
diff
changeset
|
75 | $sql .= "', inventory='" . floatval($fermentable->INVENTORY); |
11 | 76 | if ($fermentable->COST) |
32
8bb369f32ef9
Fixed floating precision problems and also got the SRM to EBC conversion right.
Michiel Broek <mbroek@mbse.eu>
parents:
30
diff
changeset
|
77 | $sql .= "', cost='" . floatval($fermentable->COST); |
11 | 78 | /* |
79 | * These are not beerxml standard: | |
80 | */ | |
81 | if ($fermentable->DI_pH) | |
82 | $sql .= "', di_ph='" . $fermentable->DI_pH; | |
83 | if ($fermentable->{'ACID_TO_pH_5.7'}) | |
84 | $sql .= "', acid_to_ph_57='" . $fermentable->{'ACID_TO_pH_5.7'}; | |
85 | $sql .= "', graintype='" . $fermentable->GRAINTYPE; | |
86 | $sql .= "';"; | |
87 | if (! $result = mysqli_query($db, $sql)) { | |
88 | printf("Error: %s\n", mysqli_error($db)); | |
89 | } | |
90 | } | |
91 | } | |
92 | ||
93 | ||
94 | function do_hops() | |
95 | { | |
96 | global $brouwhulp, $db; | |
97 | ||
98 | echo " Start adding hops to the database\n"; | |
99 | $sql = "TRUNCATE TABLE inventory_hops;"; | |
100 | if (! $result = mysqli_query($db, $sql)) { | |
101 | printf("Error: %s\n", mysqli_error($db)); | |
102 | } | |
103 | ||
104 | $myhops = simplexml_load_file($brouwhulp . '/hops.xml'); | |
105 | ||
106 | foreach ($myhops->HOP as $hop) { | |
107 | ||
108 | $sql = "INSERT INTO inventory_hops SET name='" . mysqli_real_escape_string($db, $hop->NAME); | |
109 | if ($hop->ALPHA) | |
110 | $sql .= "', alpha='" . $hop->ALPHA; | |
111 | if ($hop->BETA) | |
112 | $sql .= "', beta='" . $hop->BETA; | |
113 | if ($hop->HUMULENE) | |
114 | $sql .= "', humulene='" . $hop->HUMULENE; | |
115 | if ($hop->CARYOPHYLLENE) | |
116 | $sql .= "', caryophyllene='" . $hop->CARYOPHYLLENE; | |
117 | if ($hop->COHUMULONE) | |
118 | $sql .= "', cohumulone='" . $hop->COHUMULONE; | |
119 | if ($hop->MYCRENE) | |
120 | $sql .= "', myrcene='" . $hop->MYCRENE; | |
121 | if ($hop->HSI) | |
122 | $sql .= "', hsi='" . $hop->HSI; | |
69
ca25fdce3b85
Improved hop selection dropdown
Michiel Broek <mbroek@mbse.eu>
parents:
64
diff
changeset
|
123 | $sql .= "', useat='Boil"; // brouwhulp says Aroma always :) |
11 | 124 | $sql .= "', type='" . $hop->TYPE; |
125 | $sql .= "', form='" . $hop->FORM; | |
126 | $sql .= "', notes='" . mysqli_real_escape_string($db, $hop->NOTES); | |
127 | $sql .= "', origin='" . mysqli_real_escape_string($db, $hop->ORIGIN); | |
128 | $sql .= "', substitutes='" . mysqli_real_escape_string($db, $hop->SUBSTITUTES); | |
21
acb2d8098f19
Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
20
diff
changeset
|
129 | ($hop->ALWAYS_ON_STOCK == 'TRUE') ? $sql .= "', always_on_stock='1" : $sql .= "', always_on_stock='0"; |
11 | 130 | if ($hop->INVENTORY) |
32
8bb369f32ef9
Fixed floating precision problems and also got the SRM to EBC conversion right.
Michiel Broek <mbroek@mbse.eu>
parents:
30
diff
changeset
|
131 | $sql .= "', inventory='" . floatval($hop->INVENTORY) / 1000.0; |
11 | 132 | if ($hop->COST) |
32
8bb369f32ef9
Fixed floating precision problems and also got the SRM to EBC conversion right.
Michiel Broek <mbroek@mbse.eu>
parents:
30
diff
changeset
|
133 | $sql .= "', cost='" . floatval($hop->COST); |
13 | 134 | if ($hop->TOTAL_OIL) |
135 | $sql .= "', total_oil='" . $hop->TOTAL_OIL; | |
11 | 136 | $sql .= "';"; |
137 | if (! $result = mysqli_query($db, $sql)) { | |
138 | printf("Error: %s\n", mysqli_error($db)); | |
139 | } | |
140 | } | |
141 | ||
142 | } | |
143 | ||
144 | ||
145 | ||
146 | function do_yeasts() | |
147 | { | |
148 | global $brouwhulp, $db; | |
149 | ||
150 | echo " Start adding yeasts to the database\n"; | |
151 | $sql = "TRUNCATE TABLE inventory_yeasts;"; | |
152 | if (! $result = mysqli_query($db, $sql)) { | |
153 | printf("Error: %s\n", mysqli_error($db)); | |
154 | } | |
155 | ||
156 | $yeasts = simplexml_load_file($brouwhulp . '/yeasts.xml'); | |
157 | ||
158 | foreach ($yeasts->YEAST as $yeast) { | |
159 | ||
160 | $sql = "INSERT INTO inventory_yeasts SET name='" . mysqli_real_escape_string($db, $yeast->NAME); | |
161 | $sql .= "', type='" . $yeast->TYPE; | |
162 | $sql .= "', form='" . $yeast->FORM; | |
163 | $sql .= "', laboratory='" . mysqli_real_escape_string($db, $yeast->LABORATORY); | |
164 | $sql .= "', product_id='" . mysqli_real_escape_string($db, $yeast->PRODUCT_ID); | |
165 | if ($yeast->MIN_TEMPERATURE) | |
166 | $sql .= "', min_temperature='" . $yeast->MIN_TEMPERATURE; | |
167 | if ($yeast->MAX_TEMPERATURE) | |
168 | $sql .= "', max_temperature='" . $yeast->MAX_TEMPERATURE; | |
169 | $sql .= "', flocculation='" . $yeast->FLOCCULATION; | |
170 | if ($yeast->ATTENUATION) | |
171 | $sql .= "', attenuation='" . $yeast->ATTENUATION; | |
172 | $sql .= "', notes='" . mysqli_real_escape_string($db, $yeast->NOTES); | |
173 | $sql .= "', best_for='" . mysqli_real_escape_string($db, $yeast->BEST_FOR); | |
174 | if ($yeast->MAX_REUSE) | |
175 | $sql .= "', max_reuse='" . $yeast->MAX_REUSE; | |
176 | if ($yeast->INVENTORY) | |
32
8bb369f32ef9
Fixed floating precision problems and also got the SRM to EBC conversion right.
Michiel Broek <mbroek@mbse.eu>
parents:
30
diff
changeset
|
177 | $sql .= "', inventory='" . floatval($yeast->INVENTORY) / 1000.0; |
11 | 178 | if ($yeast->COST) |
32
8bb369f32ef9
Fixed floating precision problems and also got the SRM to EBC conversion right.
Michiel Broek <mbroek@mbse.eu>
parents:
30
diff
changeset
|
179 | $sql .= "', cost='" . floatval($yeast->COST) * 1000.0; |
11 | 180 | if ($yeast->CULTURE_DATE) { |
181 | $date = substr($yeast->CULTURE_DATE, 6, 4) . '-' . substr($yeast->CULTURE_DATE, 3, 2) . '-' . substr($yeast->CULTURE_DATE, 0, 2); | |
182 | $sql .= "', production_date='" . $date; | |
183 | } | |
184 | $sql .= "';"; | |
185 | if (! $result = mysqli_query($db, $sql)) { | |
186 | printf("Error: %s\n", mysqli_error($db)); | |
187 | } | |
188 | } | |
189 | } | |
190 | ||
191 | ||
192 | ||
193 | function do_waters() | |
194 | { | |
195 | global $brouwhulp, $db; | |
196 | ||
197 | echo " Start adding waters to the database\n"; | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
38
diff
changeset
|
198 | $sql = "TRUNCATE TABLE profile_water;"; |
11 | 199 | if (! $result = mysqli_query($db, $sql)) { |
200 | printf("Error: %s\n", mysqli_error($db)); | |
201 | } | |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
202 | $sql = "TRUNCATE TABLE inventory_waters;"; |
15 | 203 | if (! $result = mysqli_query($db, $sql)) { |
204 | printf("Error: %s\n", mysqli_error($db)); | |
205 | } | |
11 | 206 | |
207 | $waters = simplexml_load_file($brouwhulp . '/waters.xml'); | |
208 | ||
209 | foreach ($waters->WATER as $water) { | |
210 | ||
15 | 211 | if (($water->NAME == "Gedemineraliseerd water") || ($water->NAME == "Cristalline") || ($water->NAME == "Montille (Delhaize)") || |
212 | ($water->NAME == "Spa Reine") || ($water->NAME == "Velsen") || ($water->NAME == "Zutphen") || | |
213 | ($water->NAME == "Aurele Bronwater (Colruyt)")) { | |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
214 | $sql = "INSERT INTO inventory_waters SET name='" . mysqli_real_escape_string($db, $water->NAME); |
15 | 215 | } else { |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
38
diff
changeset
|
216 | $sql = "INSERT INTO profile_water SET name='" . mysqli_real_escape_string($db, $water->NAME); |
15 | 217 | } |
218 | ||
11 | 219 | if ($water->NOTES) |
220 | $sql .= "', notes='" . mysqli_real_escape_string($db, $water->NOTES); | |
221 | $sql .= "', calcium='" . $water->CALCIUM; | |
222 | $sql .= "', bicarbonate='" . $water->BICARBONATE; | |
223 | $sql .= "', sulfate='" . $water->SULFATE; | |
224 | $sql .= "', chloride='" . $water->CHLORIDE; | |
225 | $sql .= "', sodium='" . $water->SODIUM; | |
226 | $sql .= "', magnesium='" . $water->MAGNESIUM; | |
227 | $sql .= "', ph='" . $water->PH; | |
228 | if ($water->TOTAL_ALKALINITY) | |
229 | $sql .= "', total_alkalinity='" . $water->TOTAL_ALKALINITY; | |
230 | $sql .= "';"; | |
231 | if (! $result = mysqli_query($db, $sql)) { | |
232 | printf("Error: %s\n", mysqli_error($db)); | |
233 | } | |
234 | } | |
235 | } | |
236 | ||
237 | ||
238 | ||
239 | function do_miscs() | |
240 | { | |
241 | global $brouwhulp, $db; | |
242 | ||
243 | echo " Start adding miscs to the database\n"; | |
244 | $sql = "TRUNCATE TABLE inventory_miscs;"; | |
245 | if (! $result = mysqli_query($db, $sql)) { | |
246 | printf("Error: %s\n", mysqli_error($db)); | |
247 | } | |
248 | ||
249 | $miscs = simplexml_load_file($brouwhulp . '/miscs.xml'); | |
250 | ||
251 | foreach ($miscs->MISC as $misc) { | |
252 | ||
253 | $sql = "INSERT INTO inventory_miscs SET name='" . mysqli_real_escape_string($db, $misc->NAME); | |
254 | if ($misc->NOTES) | |
255 | $sql .= "', notes='" . mysqli_real_escape_string($db, $misc->NOTES); | |
256 | $sql .= "', type='" . $misc->TYPE; | |
257 | $sql .= "', use_use='" . $misc->USE; | |
258 | $sql .= "', time='" . $misc->TIME; | |
21
acb2d8098f19
Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
20
diff
changeset
|
259 | ($misc->AMOUNT_IS_WEIGHT == 'TRUE') ? $sql .= "', amount_is_weight='1" : $sql .= "', amount_is_weight='0"; |
11 | 260 | if ($misc->USE_FOR) |
261 | $sql .= "', use_for='" . mysqli_real_escape_string($db, $misc->USE_FOR); | |
262 | if ($misc->ALWAYS_ON_STOCK) | |
21
acb2d8098f19
Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
20
diff
changeset
|
263 | ($misc->ALWAYS_ON_STOCK == 'TRUE') ? $sql .= "', always_on_stock='1" : $sql .= "', always_on_stock='0"; |
11 | 264 | if ($misc->INVENTORY) |
32
8bb369f32ef9
Fixed floating precision problems and also got the SRM to EBC conversion right.
Michiel Broek <mbroek@mbse.eu>
parents:
30
diff
changeset
|
265 | $sql .= "', inventory='" . floatval($misc->INVENTORY) / 1000.0; |
11 | 266 | if ($misc->COST) |
32
8bb369f32ef9
Fixed floating precision problems and also got the SRM to EBC conversion right.
Michiel Broek <mbroek@mbse.eu>
parents:
30
diff
changeset
|
267 | $sql .= "', cost='" . floatval($misc->COST); |
11 | 268 | $sql .= "';"; |
269 | if (! $result = mysqli_query($db, $sql)) { | |
270 | printf("Error: %s\n", mysqli_error($db)); | |
271 | } | |
272 | } | |
273 | } | |
274 | ||
275 | ||
276 | ||
277 | function do_equipments() | |
278 | { | |
279 | global $brouwhulp, $db; | |
280 | ||
281 | echo " Start adding equipments to the database\n"; | |
282 | $sql = "TRUNCATE TABLE inventory_equipments;"; | |
283 | if (! $result = mysqli_query($db, $sql)) { | |
284 | printf("Error: %s\n", mysqli_error($db)); | |
285 | } | |
286 | ||
287 | $equipments = simplexml_load_file($brouwhulp . '/equipments.xml'); | |
288 | ||
289 | foreach ($equipments->EQUIPMENT as $equipment) { | |
290 | ||
291 | $sql = "INSERT INTO inventory_equipments SET name='" . mysqli_real_escape_string($db, $equipment->NAME); | |
292 | $sql .= "', boil_size='" . $equipment->BOIL_SIZE; | |
293 | $sql .= "', batch_size='" . $equipment->BATCH_SIZE; | |
294 | $sql .= "', tun_volume='" . $equipment->TUN_VOLUME; | |
295 | $sql .= "', tun_weight='" . $equipment->TUN_WEIGHT; | |
296 | $sql .= "', tun_specific_heat='" . $equipment->TUN_SPECIFIC_HEAT; | |
297 | $sql .= "', top_up_water='" . $equipment->TOP_UP_WATER; | |
298 | $sql .= "', trub_chiller_loss='" . $equipment->TRUB_CHILLER_LOSS; | |
299 | /* | |
300 | * Brouwhulp uses a percentage for the evaporation rate. This is wrong | |
301 | * but was made so because the beerxml standard requires this. What we | |
302 | * do is calculate the actual evaporation and store that. | |
303 | * This is what we use. Brouwhulp calculates this on the fly. | |
304 | */ | |
305 | $sql .= "', evap_rate='" . ($equipment->EVAP_RATE * $equipment->BOIL_SIZE) / 100.0; | |
306 | $sql .= "', boil_time='" . $equipment->BOIL_TIME; | |
21
acb2d8098f19
Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
20
diff
changeset
|
307 | ($equipment->CALC_BOIL_VOLUME == 'TRUE') ? $sql .= "', calc_boil_volume='1" : $sql .= "', calc_boil_volume='0"; |
11 | 308 | $sql .= "', lauter_deadspace='" . $equipment->LAUTER_DEADSPACE; |
309 | $sql .= "', top_up_kettle='" . $equipment->TOP_UP_KETTLE; | |
310 | $sql .= "', hop_utilization='" . $equipment->HOP_UTILIZATION; | |
311 | if ($equipment->NOTES) | |
312 | $sql .= "', notes='" . mysqli_real_escape_string($db, $equipment->NOTES); | |
313 | $sql .= "', lauter_volume='" . $equipment->LAUTER_VOLUME; | |
314 | $sql .= "', kettle_volume='" . $equipment->KETTLE_VOLUME; | |
315 | if ($equipment->TUN_MATERIAL) | |
316 | $sql .= "', tun_material='" . mysqli_real_escape_string($db, $equipment->TUN_MATERIAL); | |
317 | $sql .= "', tun_height='" . $equipment->TUN_HEIGHT; | |
318 | $sql .= "', kettle_height='" . $equipment->KETTLE_HEIGHT; | |
319 | $sql .= "', lauter_height='" . $equipment->LAUTER_HEIGHT; | |
320 | $sql .= "', mash_volume='" . $equipment->MASH_VOLUME; | |
321 | $sql .= "', efficiency='" . $equipment->EFFICIENCY; | |
322 | ||
323 | $sql .= "';"; | |
324 | if (! $result = mysqli_query($db, $sql)) { | |
325 | printf("Error: %s\n", mysqli_error($db)); | |
326 | } | |
327 | } | |
328 | } | |
329 | ||
330 | ||
331 | ||
332 | function do_styles() | |
333 | { | |
334 | global $brouwhulp, $db; | |
335 | ||
336 | echo " Start adding styles to the database\n"; | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
38
diff
changeset
|
337 | $sql = "TRUNCATE TABLE profile_styles;"; |
11 | 338 | if (! $result = mysqli_query($db, $sql)) { |
339 | printf("Error: %s\n", mysqli_error($db)); | |
340 | } | |
341 | ||
342 | $styles = simplexml_load_file($brouwhulp . '/styles.xml'); | |
343 | ||
344 | foreach ($styles->STYLE as $style) { | |
345 | ||
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
38
diff
changeset
|
346 | $sql = "INSERT INTO profile_styles SET name='" . mysqli_real_escape_string($db, $style->NAME); |
11 | 347 | if ($style->NOTES) |
348 | $sql .= "', notes='" . mysqli_real_escape_string($db, $style->NOTES); | |
349 | if ($style->CATEGORY) | |
350 | $sql .= "', category='" . mysqli_real_escape_string($db, $style->CATEGORY); | |
351 | if ($style->CATEGORY_NUMBER) | |
352 | $sql .= "', category_number='" . $style->CATEGORY_NUMBER; | |
353 | if ($style->STYLE_LETTER) | |
354 | $sql .= "', style_letter='" . mysqli_real_escape_string($db, $style->STYLE_LETTER); | |
355 | if ($style->STYLE_GUIDE) | |
356 | $sql .= "', style_guide='" . mysqli_real_escape_string($db, $style->STYLE_GUIDE); | |
357 | $sql .= "', type='" . $style->TYPE; | |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
358 | $sql .= "', og_min='" . floatval($style->OG_MIN); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
359 | $sql .= "', og_max='" . floatval($style->OG_MAX); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
360 | $sql .= "', fg_min='" . floatval($style->FG_MIN); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
361 | $sql .= "', fg_max='" . floatval($style->FG_MAX); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
362 | $sql .= "', ibu_min='" . floatval($style->IBU_MIN); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
363 | $sql .= "', ibu_max='" . floatval($style->IBU_MAX); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
364 | $sql .= "', color_min='" . floatval($style->COLOR_MIN); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
365 | $sql .= "', color_max='" . floatval($style->COLOR_MAX); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
366 | $sql .= "', carb_min='" . floatval($style->CARB_MIN); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
367 | $sql .= "', carb_max='" . floatval($style->CARB_MAX); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
368 | $sql .= "', abv_min='" . floatval($style->ABV_MIN); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
369 | $sql .= "', abv_max='" . floatval($style->ABV_MAX); |
11 | 370 | if ($style->PROFILE) |
371 | $sql .= "', profile='" . mysqli_real_escape_string($db, $style->PROFILE); | |
372 | if ($style->INGREDIENTS) | |
373 | $sql .= "', ingredients='" . mysqli_real_escape_string($db, $style->INGREDIENTS); | |
374 | if ($style->EXAMPLES) | |
375 | $sql .= "', examples='" . mysqli_real_escape_string($db, $style->EXAMPLES); | |
376 | ||
377 | $sql .= "';"; | |
378 | if (! $result = mysqli_query($db, $sql)) { | |
379 | printf("Error: %s\n", mysqli_error($db)); | |
380 | } | |
381 | } | |
382 | } | |
383 | ||
384 | ||
385 | ||
386 | function do_mash() | |
387 | { | |
388 | global $brouwhulp, $db; | |
389 | ||
390 | echo " Start adding mash profiles to the database\n"; | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
38
diff
changeset
|
391 | $sql = "TRUNCATE TABLE profile_mash;"; |
11 | 392 | if (! $result = mysqli_query($db, $sql)) { |
393 | printf("Error: %s\n", mysqli_error($db)); | |
394 | } | |
395 | ||
396 | $mashes = simplexml_load_file($brouwhulp . '/mashs.xml'); | |
397 | ||
398 | foreach ($mashes->MASH as $mash) { | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
38
diff
changeset
|
399 | $sql = "INSERT INTO profile_mash SET name='" . mysqli_real_escape_string($db, $mash->NAME); |
11 | 400 | if ($mash->NOTES) |
401 | $sql .= "', notes='" . mysqli_real_escape_string($db, $mash->NOTES); | |
402 | ||
403 | /* | |
23
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
404 | * Put the steps in a json array |
11 | 405 | */ |
406 | if ($mash->MASH_STEPS) { | |
23
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
407 | $steps = "["; |
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
408 | $comma = FALSE; |
11 | 409 | foreach ($mash->MASH_STEPS->MASH_STEP as $step) { |
410 | ||
23
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
411 | if ($comma) |
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
412 | $steps .= ','; |
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
413 | $comma = TRUE; |
38
b7d44c98d609
Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents:
35
diff
changeset
|
414 | $steps .= '{"step_name":"' . mysqli_real_escape_string($db, $step->NAME) . '"'; |
23
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
415 | if ($step->TYPE) { |
38
b7d44c98d609
Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents:
35
diff
changeset
|
416 | $steps .= ',"step_type":"' . $step->TYPE . '"'; |
23
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
417 | } |
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
418 | if ($step->STEP_TEMP) { |
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
419 | $steps .= ',"step_temp":"' . $step->STEP_TEMP . '"'; |
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
420 | } |
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
421 | if ($step->STEP_TIME) { |
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
422 | $steps .= ',"step_time":"' . $step->STEP_TIME . '"'; |
11 | 423 | } |
23
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
424 | if ($step->RAMP_TIME) { |
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
425 | $steps .= ',"ramp_time":"' . $step->RAMP_TIME . '"'; |
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
426 | } |
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
427 | if ($step->END_TEMP) { |
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
428 | $steps .= ',"end_temp":"' . $step->END_TEMP . '"'; |
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
429 | } |
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
430 | $steps .= "}"; |
11 | 431 | } |
23
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
432 | $steps .= ']'; |
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
433 | $sql .= "', steps='" . $steps; |
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
434 | } |
35 | 435 | $sql .= "';"; |
23
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
436 | if (! $result = mysqli_query($db, $sql)) { |
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
437 | printf("Error: %s\n", mysqli_error($db)); |
11 | 438 | } |
439 | } | |
440 | } | |
441 | ||
442 | ||
443 | ||
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
444 | |
104 | 445 | function do_recipes($brews) |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
446 | { |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
447 | global $brouwhulp, $db; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
448 | $len_fermentables = 0; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
449 | $len_hops = 0; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
450 | $len_miscs = 0; |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
451 | $len_yeasts = 0; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
452 | $len_waters = 0; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
453 | $len_mash = 0; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
454 | |
104 | 455 | if ($brews) { |
456 | echo " Start adding brews to the database\n"; | |
457 | $sql = "TRUNCATE TABLE production;"; | |
458 | } else { | |
459 | echo " Start adding recipes to the database\n"; | |
460 | $sql = "TRUNCATE TABLE recipes;"; | |
461 | } | |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
462 | if (! $result = mysqli_query($db, $sql)) { |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
463 | printf("Error: %s\n", mysqli_error($db)); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
464 | } |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
465 | |
104 | 466 | if ($brews) |
467 | $recipes = simplexml_load_file($brouwhulp . '/brews.xml'); | |
468 | else | |
469 | $recipes = simplexml_load_file($brouwhulp . '/recipes.xml'); | |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
470 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
471 | foreach ($recipes->RECIPE as $recipe) { |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
472 | $f_sugars = 0; |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
473 | $efficiency = 75; |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
474 | $batch_size = 20; |
94
295c3af2a421
Include boil_size field in the recipes table. Calculate pre-boil SG. Use that in the IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
89
diff
changeset
|
475 | $boil_size = 22; |
87
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
476 | $pCara = 0; |
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
477 | $pSugar = 0; |
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
478 | $svg = 77; |
89
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
479 | $colorw = 0; |
105
d06ddc4d1af0
Added uuid and locked fields to the recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
480 | $uuid = str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid')); |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
481 | |
104 | 482 | if ($brews) |
105
d06ddc4d1af0
Added uuid and locked fields to the recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
483 | $sql = "INSERT INTO brews SET uuid='" . $uuid; |
104 | 484 | else |
105
d06ddc4d1af0
Added uuid and locked fields to the recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
485 | $sql = "INSERT INTO recipes SET uuid='" . $uuid; |
d06ddc4d1af0
Added uuid and locked fields to the recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
486 | $sql .= "', name='" . mysqli_real_escape_string($db, $recipe->NAME); |
d06ddc4d1af0
Added uuid and locked fields to the recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
487 | $sql .= "', locked='0"; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
488 | if ($recipe->NOTES) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
489 | $sql .= "', notes='" . mysqli_real_escape_string($db, $recipe->NOTES); |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
490 | else |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
491 | $sql .= "', notes='"; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
492 | if ($recipe->TYPE) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
493 | $sql .= "', type='" . mysqli_real_escape_string($db, $recipe->TYPE); |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
494 | else |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
495 | $sql .= "', type='"; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
496 | if ($recipe->BATCH_SIZE) |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
497 | $batch_size = floatval($recipe->BATCH_SIZE); |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
498 | $sql .= "', batch_size='" . $batch_size; |
94
295c3af2a421
Include boil_size field in the recipes table. Calculate pre-boil SG. Use that in the IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
89
diff
changeset
|
499 | if ($recipe->BOIL_SIZE) |
295c3af2a421
Include boil_size field in the recipes table. Calculate pre-boil SG. Use that in the IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
89
diff
changeset
|
500 | $boil_size = floatval($recipe->BOIL_SIZE); |
295c3af2a421
Include boil_size field in the recipes table. Calculate pre-boil SG. Use that in the IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
89
diff
changeset
|
501 | $sql .= "', boil_size='" . $boil_size; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
502 | if ($recipe->BOIL_TIME) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
503 | $sql .= "', boil_time='" . floatval($recipe->BOIL_TIME); |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
504 | else |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
505 | $sql .= "', boil_time='90"; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
506 | if ($recipe->EFFICIENCY) |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
507 | $efficiency = floatval($recipe->EFFICIENCY); |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
508 | $sql .= "', efficiency='" . $efficiency; |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
509 | /* Don't use $recipe->EST_OG but recalculate it */ |
87
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
510 | /* Don't use $recipe->EST_FG but recalculate it */ |
89
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
511 | /* Don't use $recipe->EST_COLOR but recalculate it */ |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
512 | if ($recipe->COLOR_METHOD) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
513 | $sql .= "', color_method='" . mysqli_real_escape_string($db, $recipe->COLOR_METHOD); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
514 | if ($recipe->IBU) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
515 | $sql .= "', est_ibu='" . floatval($recipe->IBU); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
516 | if ($recipe->IBU_METHOD) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
517 | $sql .= "', ibu_method='" . mysqli_real_escape_string($db, $recipe->IBU_METHOD); |
102
679ddf512b65
Added est_carb field import in the recipes.
Michiel Broek <mbroek@mbse.eu>
parents:
100
diff
changeset
|
518 | if ($recipe->CARBONATION) |
679ddf512b65
Added est_carb field import in the recipes.
Michiel Broek <mbroek@mbse.eu>
parents:
100
diff
changeset
|
519 | $sql .= "', est_carb='" . floatval($recipe->CARBONATION); |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
520 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
521 | if ($recipe->STYLE) { |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
522 | if ($recipe->STYLE->NAME) |
51 | 523 | $sql .= "', st_name='" . mysqli_real_escape_string($db, $recipe->STYLE->NAME); |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
524 | if ($recipe->STYLE->STYLE_LETTER) |
51 | 525 | $sql .= "', st_letter='" . mysqli_real_escape_string($db, $recipe->STYLE->STYLE_LETTER); |
526 | if ($recipe->STYLE->STYLE_GUIDE) { | |
527 | if ($recipe->STYLE->STYLE_GUIDE == "Biertypengids Derek Walsh") { | |
528 | $sql .= "', st_guide='BKG 2015"; | |
529 | } else if ($recipe->STYLE->STYLE_GUIDE == "BKG Biertypen") { | |
530 | $sql .= "', st_guide='BKG 2015"; | |
531 | } else { | |
532 | $sql .= "', st_guide='" . mysqli_real_escape_string($db, $recipe->STYLE->STYLE_GUIDE); | |
533 | } | |
534 | } | |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
69
diff
changeset
|
535 | if ($recipe->STYLE->CATEGORY) |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
69
diff
changeset
|
536 | $sql .= "', st_category='" . mysqli_real_escape_string($db, $recipe->STYLE->CATEGORY); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
69
diff
changeset
|
537 | if ($recipe->STYLE->CATEGORY_NUMBER) |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
69
diff
changeset
|
538 | $sql .= "', st_category_number='" . floatval($recipe->STYLE->CATEGORY_NUMBER); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
69
diff
changeset
|
539 | if ($recipe->STYLE->TYPE) |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
69
diff
changeset
|
540 | $sql .= "', st_type='" . mysqli_real_escape_string($db, $recipe->STYLE->TYPE); |
51 | 541 | if ($recipe->STYLE->OG_MIN) |
542 | $sql .= "', st_og_min='" . floatval($recipe->STYLE->OG_MIN); | |
543 | if ($recipe->STYLE->OG_MAX) | |
544 | $sql .= "', st_og_max='" . floatval($recipe->STYLE->OG_MAX); | |
545 | if ($recipe->STYLE->FG_MIN) | |
546 | $sql .= "', st_fg_min='" . floatval($recipe->STYLE->FG_MIN); | |
547 | if ($recipe->STYLE->FG_MAX) | |
548 | $sql .= "', st_fg_max='" . floatval($recipe->STYLE->FG_MAX); | |
549 | if ($recipe->STYLE->IBU_MIN) | |
550 | $sql .= "', st_ibu_min='" . floatval($recipe->STYLE->IBU_MIN); | |
551 | if ($recipe->STYLE->IBU_MAX) | |
552 | $sql .= "', st_ibu_max='" . floatval($recipe->STYLE->IBU_MAX); | |
553 | if ($recipe->STYLE->COLOR_MIN) { | |
554 | $srm = floatval($recipe->STYLE->COLOR_MIN); | |
555 | $sql .= "', st_color_min='" . srm_to_ebc($srm); | |
556 | } | |
557 | if ($recipe->STYLE->COLOR_MAX) { | |
558 | $srm = floatval($recipe->STYLE->COLOR_MAX); | |
559 | $sql .= "', st_color_max='" . srm_to_ebc($srm); | |
560 | } | |
561 | if ($recipe->STYLE->CARB_MIN) | |
562 | $sql .= "', st_carb_min='" . floatval($recipe->STYLE->CARB_MIN); | |
563 | if ($recipe->STYLE->CARB_MAX) | |
564 | $sql .= "', st_carb_max='" . floatval($recipe->STYLE->CARB_MAX); | |
565 | if ($recipe->STYLE->ABV_MIN) | |
566 | $sql .= "', st_abv_min='" . floatval($recipe->STYLE->ABV_MIN); | |
567 | if ($recipe->STYLE->ABV_MAX) | |
568 | $sql .= "', st_abv_max='" . floatval($recipe->STYLE->ABV_MAX); | |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
569 | } |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
570 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
571 | /* |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
572 | * Put the fermentables in a json array |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
573 | */ |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
574 | if ($recipe->FERMENTABLES) { |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
575 | $fermentables = "["; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
576 | $comma = FALSE; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
577 | foreach ($recipe->FERMENTABLES->FERMENTABLE as $fermentable) { |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
578 | if ($comma) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
579 | $fermentables .= ','; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
580 | $comma = TRUE; |
51 | 581 | $fermentables .= '{"f_name":"' . mysqli_real_escape_string($db, $fermentable->NAME) . '"'; |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
582 | $fermentables .= ',"f_origin":"' . mysqli_real_escape_string($db, $fermentable->ORIGIN) . '"'; |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
583 | $fermentables .= ',"f_supplier":"' . mysqli_real_escape_string($db, $fermentable->SUPPLIER) . '"'; |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
584 | $famount = floatval($fermentable->AMOUNT); |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
585 | $fermentables .= ',"f_amount":' . $famount; |
51 | 586 | $fermentables .= ',"f_cost":' . floatval($fermentable->COST); |
87
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
587 | $ftype = mysqli_real_escape_string($db, $fermentable->TYPE); |
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
588 | $fermentables .= ',"f_type":"' . $ftype . '"'; |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
589 | $fyield = floatval($fermentable->YIELD); |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
590 | $fermentables .= ',"f_yield":' . $fyield; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
591 | if ($fermentable->COLOR) { |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
592 | $srm = floatval($fermentable->COLOR); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
593 | $ebc = srm_to_ebc($srm); |
100
08c92cb740b9
Fix for missing coor info on fermentables during recipes import. Log when srm or ebc values are negatie during conversions. Load setup record in global.inc.php and make some variables available for PHP and JS.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
594 | } else { |
08c92cb740b9
Fix for missing coor info on fermentables during recipes import. Log when srm or ebc values are negatie during conversions. Load setup record in global.inc.php and make some variables available for PHP and JS.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
595 | $srm = 0; |
08c92cb740b9
Fix for missing coor info on fermentables during recipes import. Log when srm or ebc values are negatie during conversions. Load setup record in global.inc.php and make some variables available for PHP and JS.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
596 | $ebc = 0; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
597 | } |
100
08c92cb740b9
Fix for missing coor info on fermentables during recipes import. Log when srm or ebc values are negatie during conversions. Load setup record in global.inc.php and make some variables available for PHP and JS.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
598 | $colorw += ($famount * $srm / $batch_size) * 8.34436; /* Kleurwerking */ |
08c92cb740b9
Fix for missing coor info on fermentables during recipes import. Log when srm or ebc values are negatie during conversions. Load setup record in global.inc.php and make some variables available for PHP and JS.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
599 | $fermentables .= ',"f_color":' . $ebc; |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
600 | if ($fermentable->COARSE_FINE_DIFF) |
51 | 601 | $fermentables .= ',"f_coarse_fine_diff":' . floatval($fermentable->COARSE_FINE_DIFF); |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
602 | else |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
603 | $fermentables .= ',"f_coarse_fine_diff":0'; |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
604 | if ($fermentable->MOISTURE) |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
605 | $fmoisture = floatval($fermentable->MOISTURE); |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
606 | else |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
607 | $fmoisture = 0; |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
608 | $fermentables .= ',"f_moisture":' . $fmoisture; |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
609 | if ($fermentable->DIASTATIC_POWER) |
51 | 610 | $fermentables .= ',"f_diastatic_power":' . floatval($fermentable->DIASTATIC_POWER); |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
611 | else |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
612 | $fermentables .= ',"f_diastatic_power":0'; |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
613 | if ($fermentable->PROTEIN) |
51 | 614 | $fermentables .= ',"f_protein":' . floatval($fermentable->PROTEIN); |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
615 | else |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
616 | $fermentables .= ',"f_protein":0'; |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
617 | if ($fermentable->MAX_IN_BATCH) |
51 | 618 | $fermentables .= ',"f_max_in_batch":' . floatval($fermentable->MAX_IN_BATCH); |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
619 | else |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
620 | $fermentables .= ',"f_max_in_batch":100.0'; |
87
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
621 | $fgraintype = mysqli_real_escape_string($db, $fermentable->GRAINTYPE); |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
622 | if ($fermentable->GRAINTYPE) |
87
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
623 | $fgraintype = mysqli_real_escape_string($db, $fermentable->GRAINTYPE); |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
624 | else |
87
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
625 | $fgraintype = "Base"; |
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
626 | $fermentables .= ',"f_graintype":"' . $fgraintype . '"'; |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
627 | if ($fermentable->ADDED) |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
628 | $fadded = mysqli_real_escape_string($db, $fermentable->ADDED); |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
629 | else |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
630 | $fadded = "Mash"; |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
631 | $fermentables .= ',"f_added":"'.$fadded.'"'; |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
632 | ($fermentable->ADD_AFTER_BOIL== "TRUE") ? $fermentables .= ',"f_add_after_boil":true' : $fermentables .= ',"f_add_after_boil":false'; |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
633 | ($fermentable->RECOMMEND_MASH== "TRUE") ? $fermentables .= ',"f_recommend_mash":true' : $fermentables .= ',"f_recommend_mash":false'; |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
634 | if ($fermentable->DISSOLVED_PROTEIN) |
51 | 635 | $fermentables .= ',"f_dissolved_protein":' . floatval($fermentable->DISSOLVED_PROTEIN); |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
636 | else |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
637 | $fermentables .= ',"f_dissolved_protein":0'; |
51 | 638 | ($fermentable->ADJUST_TO_TOTAL_100 == "TRUE") ? $fermentables .= ',"f_adjust_to_total_100":true' : $fermentables .= ',"f_adjust_to_total_100":false'; |
87
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
639 | $percent = floatval($fermentable->PERCENTAGE); |
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
640 | $fermentables .= ',"f_percentage":' . $percent; |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
641 | if ($fermentable->DI_pH) |
51 | 642 | $fermentables .= ',"f_di_ph":' . floatval($fermentable->DI_pH); |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
643 | else |
102
679ddf512b65
Added est_carb field import in the recipes.
Michiel Broek <mbroek@mbse.eu>
parents:
100
diff
changeset
|
644 | $fermentables .= ',"f_di_ph":0.0'; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
645 | $fermentables .= "}"; |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
646 | /* Sugars */ |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
647 | $d = $famount * ($fyield / 100) * (1 - $fmoisture / 100); |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
648 | if ($fadded == "Mash") |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
649 | $d = floatval($efficiency) / 100 * $d; |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
650 | $f_sugars += $d; |
87
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
651 | if ($fgraintype == "Crystal") |
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
652 | $pCara += $percent; |
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
653 | if ($ftype == "Sugar") |
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
654 | $pSugar += $percent; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
655 | } |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
656 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
657 | $fermentables .= ']'; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
658 | // echo $fermentables . PHP_EOL; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
659 | $sql .= "', json_fermentables='" . $fermentables; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
660 | if (strlen($fermentables) > $len_fermentables) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
661 | $len_fermentables = strlen($fermentables); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
662 | } |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
663 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
664 | /* |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
665 | * Put the hops in a json array |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
666 | */ |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
667 | if ($recipe->HOPS) { |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
668 | $hops = "["; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
669 | $comma = FALSE; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
670 | foreach ($recipe->HOPS->HOP as $hop) { |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
671 | if ($comma) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
672 | $hops .= ','; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
673 | $comma = TRUE; |
51 | 674 | $hops .= '{"h_name":"' . mysqli_real_escape_string($db, $hop->NAME) . '"'; |
675 | $hops .= ',"h_amount":' . floatval($hop->AMOUNT); | |
676 | $hops .= ',"h_cost":' . floatval($hop->COST); | |
677 | $hops .= ',"h_type":"' . mysqli_real_escape_string($db, $hop->TYPE) . '"'; | |
678 | $hops .= ',"h_form":"' . mysqli_real_escape_string($db, $hop->FORM) . '"'; | |
58
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
679 | $hops .= ',"h_useat":"' . mysqli_real_escape_string($db, $hop->USE) . '"'; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
680 | if ($hop->TIME) |
51 | 681 | $hops .= ',"h_time":' . floatval($hop->TIME); |
59
ad28e09e3abd
Added Tinseth IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
682 | else |
ad28e09e3abd
Added Tinseth IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
683 | $hops .= ',"h_time":0'; |
51 | 684 | $hops .= ',"h_alpha":' . floatval($hop->ALPHA); |
685 | $hops .= ',"h_beta":' . floatval($hop->BETA); | |
686 | $hops .= ',"h_hsi":' . floatval($hop->HSI); | |
687 | $hops .= ',"h_humulene":' . floatval($hop->HUMULENE); | |
688 | $hops .= ',"h_carophyllene":' . floatval($hop->CAROPHYLLENE); | |
689 | $hops .= ',"h_cohumulone":' . floatval($hop->COHUMULONE); | |
690 | $hops .= ',"h_myrcene":' . floatval($hop->MYRCENE); | |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
691 | if ($hop->TOTAL_OIL) |
51 | 692 | $hops .= ',"h_total_oil":' . floatval($hop->TOTAL_OIL); |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
693 | else |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
694 | $hops .= ',"h_total_oil":0'; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
695 | if ($hop->ORIGIN) |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
696 | $hops .= ',"h_origin":"' . mysqli_real_escape_string($db, $hop->ORIGIN) . '"'; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
697 | else |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
698 | $hops .= ',"h_origin":""'; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
699 | |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
700 | $hops .= "}"; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
701 | } |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
702 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
703 | $hops .= ']'; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
704 | // echo $hops . PHP_EOL; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
705 | $sql .= "', json_hops='" . $hops; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
706 | if (strlen($hops) > $len_hops) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
707 | $len_hops = strlen($hops); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
708 | } |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
709 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
710 | /* |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
711 | * Put the miscs in a json array |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
712 | */ |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
713 | if ($recipe->MISCS) { |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
714 | $miscs = "["; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
715 | $comma = FALSE; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
716 | foreach ($recipe->MISCS->MISC as $misc) { |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
717 | if ($comma) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
718 | $miscs .= ','; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
719 | $comma = TRUE; |
89
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
720 | $mname = mysqli_real_escape_string($db, $misc->NAME); |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
721 | $miscs .= '{"m_name":"' . $mname . '"'; |
51 | 722 | $miscs .= ',"m_amount":' . floatval($misc->AMOUNT); |
89
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
723 | if ($misc->COST) { |
51 | 724 | $miscs .= ',"m_cost":' . floatval($misc->COST); |
89
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
725 | } else { |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
726 | /* Brouwhulp bug, added water agents have no cost field. */ |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
727 | if ($misc->TYPE == "Water agent") { |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
728 | $miscs .= ',"m_cost":'. get_miscs_cost($mname); |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
729 | } else { |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
730 | $miscs .= ',"m_cost":0'; |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
731 | } |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
732 | } |
51 | 733 | $miscs .= ',"m_type":"' . mysqli_real_escape_string($db, $misc->TYPE) . '"'; |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
734 | $miscs .= ',"m_use_use":"' . mysqli_real_escape_string($db, $misc->USE) . '"'; |
51 | 735 | ($misc->AMOUNT_IS_WEIGHT== "TRUE") ? $miscs .= ',"m_amount_is_weight":true' : $miscs.= ',"m_amount_is_weight":false'; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
736 | if ($misc->TIME) |
51 | 737 | $miscs .= ',"m_time":' . floatval($misc->TIME); |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
738 | else |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
739 | $miscs .= ',"m_time":0'; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
740 | $miscs .= "}"; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
741 | } |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
742 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
743 | $miscs .= ']'; |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
744 | // echo $miscs . PHP_EOL; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
745 | $sql .= "', json_miscs='" . $miscs; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
746 | if (strlen($miscs) > $len_miscs) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
747 | $len_miscs = strlen($miscs); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
748 | } |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
749 | |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
750 | /* |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
751 | * Put the yeasts in a json array |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
752 | */ |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
753 | if ($recipe->YEASTS) { |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
754 | $yeasts = "["; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
755 | $comma = FALSE; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
756 | foreach ($recipe->YEASTS->YEAST as $yeast) { |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
757 | if ($comma) |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
758 | $yeasts .= ','; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
759 | $comma = TRUE; |
51 | 760 | $yeasts .= '{"y_name":"' . mysqli_real_escape_string($db, $yeast->NAME) . '"'; |
761 | $yeasts .= ',"y_amount":' . floatval($yeast->AMOUNT); | |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
762 | if ($yeast->COST) |
51 | 763 | $yeasts .= ',"y_cost":' . floatval($yeast->COST); |
61 | 764 | else |
765 | $yeasts .= ',"y_cost":0'; | |
51 | 766 | $yeasts .= ',"y_laboratory":"' . mysqli_real_escape_string($db, $yeast->LABORATORY) . '"'; |
767 | $yeasts .= ',"y_product_id":"' . mysqli_real_escape_string($db, $yeast->PRODUCT_ID) . '"'; | |
768 | $yeasts .= ',"y_type":"' . mysqli_real_escape_string($db, $yeast->TYPE) . '"'; | |
769 | $yeasts .= ',"y_form":"' . mysqli_real_escape_string($db, $yeast->FORM) . '"'; | |
770 | ($yeast->AMOUNT_IS_WEIGHT== "TRUE") ? $yeasts .= ',"y_amount_is_weight":true' : $yeasts.= ',"y_amount_is_weight":false'; | |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
771 | if ($yeast->ADD_TO_SECONDARY=="FALSE") { |
51 | 772 | $yeasts .= ',"y_use":"Primary"'; |
87
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
773 | $svg = floatval($yeast->ATTENUATION); |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
774 | } else if ($yeast->PRODUCT_ID=="F2") { |
51 | 775 | $yeasts .= ',"y_use":"Bottle"'; |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
776 | } else { |
51 | 777 | $yeasts .= ',"y_use":"Secondary"'; |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
778 | } |
61 | 779 | $yeasts .= ',"y_min_temperature":' . floatval($yeast->MIN_TEMPERATURE); |
780 | $yeasts .= ',"y_max_temperature":' . floatval($yeast->MAX_TEMPERATURE); | |
781 | $yeasts .= ',"y_attenuation":' . floatval($yeast->ATTENUATION); | |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
782 | $yeasts .= "}"; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
783 | } |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
784 | |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
785 | $yeasts .= ']'; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
786 | // echo $yeasts . PHP_EOL; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
787 | $sql .= "', json_yeasts='" . $yeasts; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
788 | if (strlen($yeasts) > $len_yeasts) |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
789 | $len_yeasts = strlen($yeasts); |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
790 | } |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
791 | |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
792 | /* |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
793 | * Put the waters in a json array |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
794 | */ |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
795 | if ($recipe->WATERS) { |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
796 | $waters = "["; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
797 | $comma = FALSE; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
798 | foreach ($recipe->WATERS->WATER as $water) { |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
799 | if ($comma) |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
800 | $waters .= ','; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
801 | $comma = TRUE; |
51 | 802 | $waters .= '{"w_name":"' . mysqli_real_escape_string($db, $water->NAME) . '"'; |
803 | $waters .= ',"w_amount":' . floatval($water->AMOUNT); | |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
804 | if ($water->CALCIUM) |
51 | 805 | $waters .= ',"w_calcium":' . floatval($water->CALCIUM); |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
806 | if ($water->SULFATE) |
51 | 807 | $waters .= ',"w_sulfate":' . floatval($water->SULFATE); |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
808 | if ($water->CHLORIDE) |
51 | 809 | $waters .= ',"w_chloride":' . floatval($water->CHLORIDE); |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
810 | if ($water->SODIUM) |
51 | 811 | $waters .= ',"w_sodium":' . floatval($water->SODIUM); |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
812 | if ($water->MAGNESIUM) |
51 | 813 | $waters .= ',"w_magnesium":' . floatval($water->MAGNESIUM); |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
814 | if ($water->PH) |
51 | 815 | $waters .= ',"w_ph":' . floatval($water->PH); |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
816 | if ($water->TOTAL_ALKALINITY) |
51 | 817 | $waters .= ',"w_total_alkalinity":' . floatval($water->TOTAL_ALKALINITY); |
818 | if ($water->COST) | |
819 | $waters .= ',"w_cost":' . floatval($water->COST); | |
820 | else | |
821 | $waters .= ',"w_cost":0.00'; | |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
822 | $waters .= "}"; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
823 | } |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
824 | |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
825 | $waters .= ']'; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
826 | // echo $waters . PHP_EOL; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
827 | $sql .= "', json_waters='" . $waters; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
828 | if (strlen($waters) > $len_waters) |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
829 | $len_waters = strlen($waters); |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
830 | } |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
831 | |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
832 | /* |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
833 | * Put the mash in a json array |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
834 | */ |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
835 | if ($recipe->MASH) { |
51 | 836 | $sql .= "',mash_sparge_temp='" . floatval($recipe->MASH->SPARGE_TEMP); |
837 | $sql .= "',mash_ph='" . floatval($recipe->MASH->PH); | |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
838 | if ($recipe->MASH->NAME) |
51 | 839 | $sql .= "',mash_name='" . mysqli_real_escape_string($db, $recipe->MASH->NAME); |
840 | ||
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
841 | if ($recipe->MASH->MASH_STEPS) { |
51 | 842 | $steps = '['; |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
843 | $comma = FALSE; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
844 | foreach ($recipe->MASH->MASH_STEPS->MASH_STEP as $step) { |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
845 | if ($comma) |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
846 | $steps .= ','; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
847 | $comma = TRUE; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
848 | $steps .= '{"step_name":"' . mysqli_real_escape_string($db, $step->NAME) . '"'; |
51 | 849 | if ($step->TYPE) |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
850 | $steps .= ',"step_type":"' . $step->TYPE . '"'; |
51 | 851 | if ($step->INFUSE_AMOUNT) |
852 | $steps .= ',"step_infuse_amount":"' . floatval($step->INFUSE_AMOUNT) . '"'; | |
853 | if ($step->STEP_TEMP) | |
854 | $steps .= ',"step_temp":"' . floatval($step->STEP_TEMP) . '"'; | |
855 | if ($step->STEP_TIME) | |
856 | $steps .= ',"step_time":"' . floatval($step->STEP_TIME) . '"'; | |
857 | if ($step->RAMP_TIME) | |
858 | $steps .= ',"ramp_time":"' . floatval($step->RAMP_TIME) . '"'; | |
859 | if ($step->END_TEMP) | |
860 | $steps .= ',"end_temp":"' . floatval($step->END_TEMP) . '"'; | |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
861 | $steps .= "}"; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
862 | } |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
863 | $steps .= ']'; |
51 | 864 | // echo $steps . PHP_EOL; |
865 | $sql .= "', json_mashs='" . $steps; | |
866 | if (strlen($steps) > $len_mash) | |
867 | $len_mash = strlen($steps); | |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
868 | } |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
869 | } |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
870 | |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
871 | /* |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
872 | * Added the calculated values |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
873 | * OG, FG, color, IBU |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
874 | */ |
96
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
94
diff
changeset
|
875 | $og = estimate_sg($f_sugars, $batch_size); |
87
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
876 | $sql .= "', est_og='" . floatval($og); |
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
877 | $fg = estimate_fg($pSugar, $pCara, 0, 0, 0, $svg, $og); |
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
878 | $sql .= "', est_fg='" . floatval($fg); |
88 | 879 | $abv = abvol($og, $fg); |
880 | $sql .= "', est_abv='" . floatval($abv); | |
89
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
881 | $color = kw_to_ebc(mysqli_real_escape_string($db, $recipe->COLOR_METHOD), $colorw); |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
882 | $sql .= "', est_color='" . floatval($color); |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
883 | $sql .= "';"; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
884 | if (! $result = mysqli_query($db, $sql)) { |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
885 | printf("Error: %s\n", mysqli_error($db)); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
886 | } |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
887 | } |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
888 | // echo "Fermentables: " . $len_fermentables . PHP_EOL; |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
889 | // echo "Hops: " . $len_hops . PHP_EOL; |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
890 | // echo "Miscs: " . $len_miscs . PHP_EOL; |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
891 | // echo "Yeasts: " . $len_yeasts . PHP_EOL; |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
892 | // echo "Waters: " . $len_waters . PHP_EOL; |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
893 | // echo "Mash: " . $len_mash . PHP_EOL; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
894 | } |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
895 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
896 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
897 | |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
898 | do_fermentables(); |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
899 | do_hops(); |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
900 | do_yeasts(); |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
901 | do_miscs(); |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
902 | do_waters(); |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
903 | do_equipments(); |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
904 | do_styles(); |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
905 | do_mash(); |
104 | 906 | do_recipes(0); |
907 | //do_recipes(1); | |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
908 | |
11 | 909 | |
910 | mysqli_close($db); | |
911 | ||
912 | echo "Finished adding data\n"; | |
913 | ||
914 | ||
915 | ?> |