Mon, 13 Aug 2018 19:49:42 +0200
Waters import and home page
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 | } | |
16 | ||
17 | $brouwhulp = '/home/mbroek/Documents/brouwhulp'; | |
18 | ||
19 | ||
20 | function do_fermentables() | |
21 | { | |
22 | global $brouwhulp, $db; | |
23 | ||
24 | echo " Start adding fermentables to the database\n"; | |
25 | $sql = "TRUNCATE TABLE inventory_fermentables;"; | |
26 | if (! $result = mysqli_query($db, $sql)) { | |
27 | printf("Error: %s\n", mysqli_error($db)); | |
28 | } | |
29 | $myfermentables = simplexml_load_file($brouwhulp . '/fermentables.xml'); | |
30 | ||
31 | foreach ($myfermentables->FERMENTABLE as $fermentable) { | |
32 | ||
33 | $sql = "INSERT INTO inventory_fermentables SET name='" . mysqli_real_escape_string($db, $fermentable->NAME); | |
34 | $sql .= "', type='" . $fermentable->TYPE; | |
35 | if ($fermentable->YIELD) | |
36 | $sql .= "', yield='" . $fermentable->YIELD; | |
37 | if ($fermentable->COLOR) { | |
38 | $srm = $fermentable->COLOR; | |
39 | $ebc = srm_to_ebc($srm); | |
40 | if ($ebc < 0) | |
41 | $ebc = 0; | |
42 | $nsrm = ebc_to_srm($ebc); | |
43 | echo 'SRM '.$srm.' EBC '.$ebc.' back '.$nsrm.PHP_EOL; | |
44 | $sql .= "', color='" . $ebc; | |
45 | } | |
46 | ($fermentable->ADD_AFTER_BOIL == "TRUE") ? $sql .= "', add_after_boil='1" : $sql .= "', add_after_boil='0"; | |
47 | $sql .= "', origin='" . mysqli_real_escape_string($db, $fermentable->ORIGIN); | |
48 | $sql .= "', supplier='" . mysqli_real_escape_string($db, $fermentable->SUPPLIER); | |
49 | $sql .= "', notes='" . mysqli_real_escape_string($db, $fermentable->NOTES); | |
50 | if ($fermentable->COARSE_FINE_DIFF) | |
51 | $sql .= "', coarse_fine_diff='" . $fermentable->COARSE_FINE_DIFF; | |
52 | if ($fermentable->MOISTURE) | |
53 | $sql .= "', moisture='" . $fermentable->MOISTURE; | |
54 | if ($fermentable->DIASTATIC_POWER) | |
55 | $sql .= "', diastatic_power='" . $fermentable->DIASTATIC_POWER; | |
56 | if ($fermentable->PROTEIN) | |
57 | $sql .= "', protein='" . $fermentable->PROTEIN; | |
58 | if ($fermentable->MAX_IN_BATCH) | |
59 | $sql .= "', max_in_batch='" . $fermentable->MAX_IN_BATCH; | |
60 | ($fermentable->RECOMMEND_MASH == "TRUE") ? $sql .= "', recommend_mash='Y" : $sql .= "', recommend_mash='N"; | |
61 | if ($fermentable->IBU_GAL_PER_LB) | |
62 | $sql .= "', ibu_gal_per_lb='" . $fermentable->IBU_GAL_PER_LB; | |
63 | ($fermentable->ALWAYS_ON_STOCK == "TRUE") ? $sql .= "', always_on_stock='Y" : $sql .= "', always_on_stock='N"; | |
64 | if ($fermentable->INVENTORY) | |
65 | $sql .= "', inventory='" . $fermentable->INVENTORY; | |
66 | if ($fermentable->COST) | |
67 | $sql .= "', cost='" . $fermentable->COST; | |
68 | /* | |
69 | * These are not beerxml standard: | |
70 | */ | |
71 | if ($fermentable->DI_pH) | |
72 | $sql .= "', di_ph='" . $fermentable->DI_pH; | |
73 | if ($fermentable->{'ACID_TO_pH_5.7'}) | |
74 | $sql .= "', acid_to_ph_57='" . $fermentable->{'ACID_TO_pH_5.7'}; | |
75 | $sql .= "', graintype='" . $fermentable->GRAINTYPE; | |
76 | $sql .= "';"; | |
77 | if (! $result = mysqli_query($db, $sql)) { | |
78 | printf("Error: %s\n", mysqli_error($db)); | |
79 | } | |
80 | } | |
81 | } | |
82 | ||
83 | ||
84 | function do_hops() | |
85 | { | |
86 | global $brouwhulp, $db; | |
87 | ||
88 | echo " Start adding hops to the database\n"; | |
89 | $sql = "TRUNCATE TABLE inventory_hops;"; | |
90 | if (! $result = mysqli_query($db, $sql)) { | |
91 | printf("Error: %s\n", mysqli_error($db)); | |
92 | } | |
93 | ||
94 | $myhops = simplexml_load_file($brouwhulp . '/hops.xml'); | |
95 | ||
96 | foreach ($myhops->HOP as $hop) { | |
97 | ||
98 | $sql = "INSERT INTO inventory_hops SET name='" . mysqli_real_escape_string($db, $hop->NAME); | |
99 | if ($hop->ALPHA) | |
100 | $sql .= "', alpha='" . $hop->ALPHA; | |
101 | if ($hop->BETA) | |
102 | $sql .= "', beta='" . $hop->BETA; | |
103 | if ($hop->HUMULENE) | |
104 | $sql .= "', humulene='" . $hop->HUMULENE; | |
105 | if ($hop->CARYOPHYLLENE) | |
106 | $sql .= "', caryophyllene='" . $hop->CARYOPHYLLENE; | |
107 | if ($hop->COHUMULONE) | |
108 | $sql .= "', cohumulone='" . $hop->COHUMULONE; | |
109 | if ($hop->MYCRENE) | |
110 | $sql .= "', myrcene='" . $hop->MYCRENE; | |
111 | if ($hop->HSI) | |
112 | $sql .= "', hsi='" . $hop->HSI; | |
113 | $sql .= "', useat='" . $hop->USE; | |
114 | $sql .= "', type='" . $hop->TYPE; | |
115 | $sql .= "', form='" . $hop->FORM; | |
116 | $sql .= "', notes='" . mysqli_real_escape_string($db, $hop->NOTES); | |
117 | $sql .= "', origin='" . mysqli_real_escape_string($db, $hop->ORIGIN); | |
118 | $sql .= "', substitutes='" . mysqli_real_escape_string($db, $hop->SUBSTITUTES); | |
119 | ($hop->ALWAYS_ON_STOCK == 'TRUE') ? $sql .= "', always_on_stock='Y" : $sql .= "', always_on_stock='N"; | |
120 | if ($hop->INVENTORY) | |
121 | $sql .= "', inventory='" . $hop->INVENTORY; | |
122 | if ($hop->COST) | |
123 | $sql .= "', cost='" . $hop->COST; | |
13 | 124 | if ($hop->TOTAL_OIL) |
125 | $sql .= "', total_oil='" . $hop->TOTAL_OIL; | |
11 | 126 | $sql .= "';"; |
127 | if (! $result = mysqli_query($db, $sql)) { | |
128 | printf("Error: %s\n", mysqli_error($db)); | |
129 | } | |
130 | } | |
131 | ||
132 | } | |
133 | ||
134 | ||
135 | ||
136 | function do_yeasts() | |
137 | { | |
138 | global $brouwhulp, $db; | |
139 | ||
140 | echo " Start adding yeasts to the database\n"; | |
141 | $sql = "TRUNCATE TABLE inventory_yeasts;"; | |
142 | if (! $result = mysqli_query($db, $sql)) { | |
143 | printf("Error: %s\n", mysqli_error($db)); | |
144 | } | |
145 | ||
146 | $yeasts = simplexml_load_file($brouwhulp . '/yeasts.xml'); | |
147 | ||
148 | foreach ($yeasts->YEAST as $yeast) { | |
149 | ||
150 | $sql = "INSERT INTO inventory_yeasts SET name='" . mysqli_real_escape_string($db, $yeast->NAME); | |
151 | $sql .= "', type='" . $yeast->TYPE; | |
152 | $sql .= "', form='" . $yeast->FORM; | |
153 | if ($yeast->AMOUNT) | |
154 | $sql .= "', amount='" . $yeast->AMOUNT; | |
155 | ($yeast->AMOUNT_IS_WEIGHT == 'TRUE') ? $sql .= "', amount_is_weight='Y" : $sql .= "', amount_is_weight='N"; | |
156 | $sql .= "', laboratory='" . mysqli_real_escape_string($db, $yeast->LABORATORY); | |
157 | $sql .= "', product_id='" . mysqli_real_escape_string($db, $yeast->PRODUCT_ID); | |
158 | if ($yeast->MIN_TEMPERATURE) | |
159 | $sql .= "', min_temperature='" . $yeast->MIN_TEMPERATURE; | |
160 | if ($yeast->MAX_TEMPERATURE) | |
161 | $sql .= "', max_temperature='" . $yeast->MAX_TEMPERATURE; | |
162 | $sql .= "', flocculation='" . $yeast->FLOCCULATION; | |
163 | if ($yeast->ATTENUATION) | |
164 | $sql .= "', attenuation='" . $yeast->ATTENUATION; | |
165 | $sql .= "', notes='" . mysqli_real_escape_string($db, $yeast->NOTES); | |
166 | $sql .= "', best_for='" . mysqli_real_escape_string($db, $yeast->BEST_FOR); | |
167 | if ($yeast->TIMES_CULTURED) | |
168 | $sql .= "', times_cultured='" . $yeast->TIMES_CULTURED; | |
169 | if ($yeast->MAX_REUSE) | |
170 | $sql .= "', max_reuse='" . $yeast->MAX_REUSE; | |
171 | if ($yeast->INVENTORY) | |
172 | $sql .= "', inventory='" . $yeast->INVENTORY; | |
173 | if ($yeast->COST) | |
174 | $sql .= "', cost='" . $yeast->COST; | |
175 | if ($yeast->CULTURE_DATE) { | |
176 | $date = substr($yeast->CULTURE_DATE, 6, 4) . '-' . substr($yeast->CULTURE_DATE, 3, 2) . '-' . substr($yeast->CULTURE_DATE, 0, 2); | |
177 | $sql .= "', production_date='" . $date; | |
178 | } | |
179 | $sql .= "';"; | |
180 | if (! $result = mysqli_query($db, $sql)) { | |
181 | printf("Error: %s\n", mysqli_error($db)); | |
182 | } | |
183 | } | |
184 | } | |
185 | ||
186 | ||
187 | ||
188 | function do_waters() | |
189 | { | |
190 | global $brouwhulp, $db; | |
191 | ||
192 | echo " Start adding waters to the database\n"; | |
193 | $sql = "TRUNCATE TABLE inventory_water_profiles;"; | |
194 | if (! $result = mysqli_query($db, $sql)) { | |
195 | printf("Error: %s\n", mysqli_error($db)); | |
196 | } | |
15 | 197 | $sql = "TRUNCATE TABLE inventory_water_sources;"; |
198 | if (! $result = mysqli_query($db, $sql)) { | |
199 | printf("Error: %s\n", mysqli_error($db)); | |
200 | } | |
11 | 201 | |
202 | $waters = simplexml_load_file($brouwhulp . '/waters.xml'); | |
203 | ||
204 | foreach ($waters->WATER as $water) { | |
205 | ||
15 | 206 | if (($water->NAME == "Gedemineraliseerd water") || ($water->NAME == "Cristalline") || ($water->NAME == "Montille (Delhaize)") || |
207 | ($water->NAME == "Spa Reine") || ($water->NAME == "Velsen") || ($water->NAME == "Zutphen") || | |
208 | ($water->NAME == "Aurele Bronwater (Colruyt)")) { | |
209 | $sql = "INSERT INTO inventory_water_sources SET name='" . mysqli_real_escape_string($db, $water->NAME); | |
210 | } else { | |
211 | $sql = "INSERT INTO inventory_water_profiles SET name='" . mysqli_real_escape_string($db, $water->NAME); | |
212 | } | |
213 | ||
11 | 214 | ($water->ALWAYS_ON_STOCK == 'TRUE') ? $sql .= "', always_on_stock='Y" : $sql .= "', always_on_stock='N"; |
215 | if ($water->NOTES) | |
216 | $sql .= "', notes='" . mysqli_real_escape_string($db, $water->NOTES); | |
217 | $sql .= "', calcium='" . $water->CALCIUM; | |
218 | $sql .= "', bicarbonate='" . $water->BICARBONATE; | |
219 | $sql .= "', sulfate='" . $water->SULFATE; | |
220 | $sql .= "', chloride='" . $water->CHLORIDE; | |
221 | $sql .= "', sodium='" . $water->SODIUM; | |
222 | $sql .= "', magnesium='" . $water->MAGNESIUM; | |
223 | $sql .= "', ph='" . $water->PH; | |
224 | if ($water->TOTAL_ALKALINITY) | |
225 | $sql .= "', total_alkalinity='" . $water->TOTAL_ALKALINITY; | |
226 | ($water->DEFAULT_WATER == 'TRUE') ? $sql .= "', default_water='Y" : $sql .= "', default_water='N"; | |
227 | $sql .= "';"; | |
228 | if (! $result = mysqli_query($db, $sql)) { | |
229 | printf("Error: %s\n", mysqli_error($db)); | |
230 | } | |
231 | } | |
232 | } | |
233 | ||
234 | ||
235 | ||
236 | function do_miscs() | |
237 | { | |
238 | global $brouwhulp, $db; | |
239 | ||
240 | echo " Start adding miscs to the database\n"; | |
241 | $sql = "TRUNCATE TABLE inventory_miscs;"; | |
242 | if (! $result = mysqli_query($db, $sql)) { | |
243 | printf("Error: %s\n", mysqli_error($db)); | |
244 | } | |
245 | ||
246 | $miscs = simplexml_load_file($brouwhulp . '/miscs.xml'); | |
247 | ||
248 | foreach ($miscs->MISC as $misc) { | |
249 | ||
250 | $sql = "INSERT INTO inventory_miscs SET name='" . mysqli_real_escape_string($db, $misc->NAME); | |
251 | if ($misc->NOTES) | |
252 | $sql .= "', notes='" . mysqli_real_escape_string($db, $misc->NOTES); | |
253 | $sql .= "', type='" . $misc->TYPE; | |
254 | $sql .= "', use_use='" . $misc->USE; | |
255 | $sql .= "', time='" . $misc->TIME; | |
256 | $sql .= "', amount='" . $misc->AMOUNT; | |
257 | ($misc->AMOUNT_IS_WEIGHT == 'TRUE') ? $sql .= "', amount_is_weight='Y" : $sql .= "', amount_is_weight='N"; | |
258 | if ($misc->USE_FOR) | |
259 | $sql .= "', use_for='" . mysqli_real_escape_string($db, $misc->USE_FOR); | |
260 | if ($misc->ALWAYS_ON_STOCK) | |
261 | ($misc->ALWAYS_ON_STOCK == 'TRUE') ? $sql .= "', always_on_stock='Y" : $sql .= "', always_on_stock='N"; | |
262 | if ($misc->INVENTORY) | |
263 | $sql .= "', inventory='" . $misc->INVENTORY; | |
264 | if ($misc->COST) | |
265 | $sql .= "', cost='" . $misc->COST; | |
266 | $sql .= "';"; | |
267 | if (! $result = mysqli_query($db, $sql)) { | |
268 | printf("Error: %s\n", mysqli_error($db)); | |
269 | } | |
270 | } | |
271 | } | |
272 | ||
273 | ||
274 | ||
275 | function do_equipments() | |
276 | { | |
277 | global $brouwhulp, $db; | |
278 | ||
279 | echo " Start adding equipments to the database\n"; | |
280 | $sql = "TRUNCATE TABLE inventory_equipments;"; | |
281 | if (! $result = mysqli_query($db, $sql)) { | |
282 | printf("Error: %s\n", mysqli_error($db)); | |
283 | } | |
284 | ||
285 | $equipments = simplexml_load_file($brouwhulp . '/equipments.xml'); | |
286 | ||
287 | foreach ($equipments->EQUIPMENT as $equipment) { | |
288 | ||
289 | $sql = "INSERT INTO inventory_equipments SET name='" . mysqli_real_escape_string($db, $equipment->NAME); | |
290 | $sql .= "', boil_size='" . $equipment->BOIL_SIZE; | |
291 | $sql .= "', batch_size='" . $equipment->BATCH_SIZE; | |
292 | $sql .= "', tun_volume='" . $equipment->TUN_VOLUME; | |
293 | $sql .= "', tun_weight='" . $equipment->TUN_WEIGHT; | |
294 | $sql .= "', tun_specific_heat='" . $equipment->TUN_SPECIFIC_HEAT; | |
295 | $sql .= "', top_up_water='" . $equipment->TOP_UP_WATER; | |
296 | $sql .= "', trub_chiller_loss='" . $equipment->TRUB_CHILLER_LOSS; | |
297 | /* | |
298 | * Brouwhulp uses a percentage for the evaporation rate. This is wrong | |
299 | * but was made so because the beerxml standard requires this. What we | |
300 | * do is calculate the actual evaporation and store that. | |
301 | * This is what we use. Brouwhulp calculates this on the fly. | |
302 | */ | |
303 | $sql .= "', evap_rate='" . ($equipment->EVAP_RATE * $equipment->BOIL_SIZE) / 100.0; | |
304 | $sql .= "', boil_time='" . $equipment->BOIL_TIME; | |
305 | ($equipment->CALC_BOIL_VOLUME == 'TRUE') ? $sql .= "', calc_boil_volume='Y" : $sql .= "', calc_boil_volume='N"; | |
306 | $sql .= "', lauter_deadspace='" . $equipment->LAUTER_DEADSPACE; | |
307 | $sql .= "', top_up_kettle='" . $equipment->TOP_UP_KETTLE; | |
308 | $sql .= "', hop_utilization='" . $equipment->HOP_UTILIZATION; | |
309 | if ($equipment->NOTES) | |
310 | $sql .= "', notes='" . mysqli_real_escape_string($db, $equipment->NOTES); | |
311 | $sql .= "', lauter_volume='" . $equipment->LAUTER_VOLUME; | |
312 | $sql .= "', kettle_volume='" . $equipment->KETTLE_VOLUME; | |
313 | if ($equipment->TUN_MATERIAL) | |
314 | $sql .= "', tun_material='" . mysqli_real_escape_string($db, $equipment->TUN_MATERIAL); | |
315 | $sql .= "', tun_height='" . $equipment->TUN_HEIGHT; | |
316 | $sql .= "', kettle_height='" . $equipment->KETTLE_HEIGHT; | |
317 | $sql .= "', lauter_height='" . $equipment->LAUTER_HEIGHT; | |
318 | $sql .= "', mash_volume='" . $equipment->MASH_VOLUME; | |
319 | $sql .= "', efficiency='" . $equipment->EFFICIENCY; | |
320 | ||
321 | $sql .= "';"; | |
322 | if (! $result = mysqli_query($db, $sql)) { | |
323 | printf("Error: %s\n", mysqli_error($db)); | |
324 | } | |
325 | } | |
326 | } | |
327 | ||
328 | ||
329 | ||
330 | function do_styles() | |
331 | { | |
332 | global $brouwhulp, $db; | |
333 | ||
334 | echo " Start adding styles to the database\n"; | |
335 | $sql = "TRUNCATE TABLE inventory_styles;"; | |
336 | if (! $result = mysqli_query($db, $sql)) { | |
337 | printf("Error: %s\n", mysqli_error($db)); | |
338 | } | |
339 | ||
340 | $styles = simplexml_load_file($brouwhulp . '/styles.xml'); | |
341 | ||
342 | foreach ($styles->STYLE as $style) { | |
343 | ||
344 | $sql = "INSERT INTO inventory_styles SET name='" . mysqli_real_escape_string($db, $style->NAME); | |
345 | if ($style->NOTES) | |
346 | $sql .= "', notes='" . mysqli_real_escape_string($db, $style->NOTES); | |
347 | if ($style->CATEGORY) | |
348 | $sql .= "', category='" . mysqli_real_escape_string($db, $style->CATEGORY); | |
349 | if ($style->CATEGORY_NUMBER) | |
350 | $sql .= "', category_number='" . $style->CATEGORY_NUMBER; | |
351 | if ($style->STYLE_LETTER) | |
352 | $sql .= "', style_letter='" . mysqli_real_escape_string($db, $style->STYLE_LETTER); | |
353 | if ($style->STYLE_GUIDE) | |
354 | $sql .= "', style_guide='" . mysqli_real_escape_string($db, $style->STYLE_GUIDE); | |
355 | $sql .= "', type='" . $style->TYPE; | |
356 | $sql .= "', og_min='" . $style->OG_MIN; | |
357 | $sql .= "', og_max='" . $style->OG_MAX; | |
358 | $sql .= "', fg_min='" . $style->FG_MIN; | |
359 | $sql .= "', fg_max='" . $style->FG_MAX; | |
360 | $sql .= "', ibu_min='" . $style->IBU_MIN; | |
361 | $sql .= "', ibu_max='" . $style->IBU_MAX; | |
362 | $sql .= "', color_min='" . $style->COLOR_MIN; | |
363 | $sql .= "', color_max='" . $style->COLOR_MAX; | |
364 | $sql .= "', carb_min='" . $style->CARB_MIN; | |
365 | $sql .= "', carb_max='" . $style->CARB_MAX; | |
366 | $sql .= "', abv_min='" . $style->ABV_MIN; | |
367 | $sql .= "', abv_max='" . $style->ABV_MAX; | |
368 | if ($style->PROFILE) | |
369 | $sql .= "', profile='" . mysqli_real_escape_string($db, $style->PROFILE); | |
370 | if ($style->INGREDIENTS) | |
371 | $sql .= "', ingredients='" . mysqli_real_escape_string($db, $style->INGREDIENTS); | |
372 | if ($style->EXAMPLES) | |
373 | $sql .= "', examples='" . mysqli_real_escape_string($db, $style->EXAMPLES); | |
374 | ||
375 | $sql .= "';"; | |
376 | if (! $result = mysqli_query($db, $sql)) { | |
377 | printf("Error: %s\n", mysqli_error($db)); | |
378 | } | |
379 | } | |
380 | } | |
381 | ||
382 | ||
383 | ||
384 | function do_mash() | |
385 | { | |
386 | global $brouwhulp, $db; | |
387 | ||
388 | echo " Start adding mash profiles to the database\n"; | |
389 | $sql = "TRUNCATE TABLE inventory_mash_steps;"; | |
390 | if (! $result = mysqli_query($db, $sql)) { | |
391 | printf("Error: %s\n", mysqli_error($db)); | |
392 | } | |
393 | $sql = "TRUNCATE TABLE inventory_mash_profiles;"; | |
394 | if (! $result = mysqli_query($db, $sql)) { | |
395 | printf("Error: %s\n", mysqli_error($db)); | |
396 | } | |
397 | ||
398 | $mashes = simplexml_load_file($brouwhulp . '/mashs.xml'); | |
399 | ||
400 | foreach ($mashes->MASH as $mash) { | |
401 | $sql = "INSERT INTO inventory_mash_profiles SET name='" . mysqli_real_escape_string($db, $mash->NAME); | |
402 | if ($mash->NOTES) | |
403 | $sql .= "', notes='" . mysqli_real_escape_string($db, $mash->NOTES); | |
404 | if ($mash->GRAIN_TEMP) | |
405 | $sql .= "', grain_temp='" . $mash->GRAIN_TEMP; | |
406 | if ($mash->TUN_TEMP) | |
407 | $sql .= "', tun_temp='" . $mash->TUN_TEMP; | |
408 | if ($mash->SPARGE_TEMP) | |
409 | $sql .= "', sparge_temp='" . $mash->SPARGE_TEMP; | |
410 | if ($mash->PH) | |
411 | $sql .= "', ph='" . $mash->PH; | |
412 | if ($mash->TUN_WEIGHT) | |
413 | $sql .= "', tun_weight='" . $mash->TUN_WEIGHT; | |
414 | if ($mash->TUN_SPECIFIX_HEAT) | |
415 | $sql .= "', tun_specific_heat='" . $mash->TUN_SPECIFIC_HEAT; | |
416 | ($mash->EQUIP_ADJUST == 'TRUE') ? $sql .= "', equip_adjust='Y" : $sql .= "', equip_adjust='N"; | |
417 | $sql .= "';"; | |
418 | /* | |
419 | * Store the record and get the record number that is created. | |
420 | * Store that as a reference in the steps. | |
421 | */ | |
422 | if (! $result = mysqli_query($db, $sql)) { | |
423 | printf("Error: %s\n", mysqli_error($db)); | |
424 | } | |
425 | $record = mysqli_insert_id($db); | |
426 | ||
427 | /* | |
428 | * Put the steps in a different table with a reference to the profile. | |
429 | */ | |
430 | if ($mash->MASH_STEPS) { | |
431 | foreach ($mash->MASH_STEPS->MASH_STEP as $step) { | |
432 | ||
433 | $sql = "INSERT INTO inventory_mash_steps SET name='" . mysqli_real_escape_string($db, $step->NAME); | |
434 | $sql .= "', rec_mash_profile='" . $record; | |
435 | if ($step->TYPE) | |
436 | $sql .= "', type='" . $step->TYPE; | |
437 | if ($step->INFUSE_AMOUNT) | |
438 | $sql .= "', infuse_amount='" . $step->INFUSE_AMOUNT; | |
439 | if ($step->STEP_TEMP) | |
440 | $sql .= "', step_temp='" . $step->STEP_TEMP; | |
441 | if ($step->STEP_TIME) | |
442 | $sql .= "', step_time='" . $step->STEP_TIME; | |
443 | if ($step->RAMP_TIME) | |
444 | $sql .= "', ramp_time='" . $step->RAMP_TIME; | |
445 | if ($step->END_TEMP) | |
446 | $sql .= "', end_temp='" . $step->END_TEMP; | |
447 | if ($step->DESCRIPTION) | |
448 | $sql .= "', description='" . mysqli_real_escape_string($db, $step->DESCRIPTION); | |
449 | $sql .= "';"; | |
450 | if (! $result = mysqli_query($db, $sql)) { | |
451 | printf("Error: %s\n", mysqli_error($db)); | |
452 | } | |
453 | } | |
454 | } | |
455 | } | |
456 | } | |
457 | ||
458 | ||
459 | ||
15 | 460 | //do_fermentables(); |
461 | //do_hops(); | |
11 | 462 | //do_yeasts(); |
15 | 463 | do_waters(); |
11 | 464 | //do_miscs(); |
465 | //do_equipments(); | |
466 | //do_styles(); | |
467 | //do_mash(); | |
468 | ||
469 | mysqli_close($db); | |
470 | ||
471 | echo "Finished adding data\n"; | |
472 | ||
473 | ||
474 | ?> |