Wed, 14 Nov 2018 16:49:56 +0100
Added Rager and Daniels IBU calculations to javascript formula.
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); |
21
acb2d8098f19
Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
20
diff
changeset
|
215 | ($water->DEFAULT_WATER == 'TRUE') ? $sql .= "', default_water='1" : $sql .= "', default_water='0"; |
15 | 216 | } else { |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
38
diff
changeset
|
217 | $sql = "INSERT INTO profile_water SET name='" . mysqli_real_escape_string($db, $water->NAME); |
15 | 218 | } |
219 | ||
11 | 220 | if ($water->NOTES) |
221 | $sql .= "', notes='" . mysqli_real_escape_string($db, $water->NOTES); | |
222 | $sql .= "', calcium='" . $water->CALCIUM; | |
223 | $sql .= "', bicarbonate='" . $water->BICARBONATE; | |
224 | $sql .= "', sulfate='" . $water->SULFATE; | |
225 | $sql .= "', chloride='" . $water->CHLORIDE; | |
226 | $sql .= "', sodium='" . $water->SODIUM; | |
227 | $sql .= "', magnesium='" . $water->MAGNESIUM; | |
228 | $sql .= "', ph='" . $water->PH; | |
229 | if ($water->TOTAL_ALKALINITY) | |
230 | $sql .= "', total_alkalinity='" . $water->TOTAL_ALKALINITY; | |
231 | $sql .= "';"; | |
232 | if (! $result = mysqli_query($db, $sql)) { | |
233 | printf("Error: %s\n", mysqli_error($db)); | |
234 | } | |
235 | } | |
236 | } | |
237 | ||
238 | ||
239 | ||
240 | function do_miscs() | |
241 | { | |
242 | global $brouwhulp, $db; | |
243 | ||
244 | echo " Start adding miscs to the database\n"; | |
245 | $sql = "TRUNCATE TABLE inventory_miscs;"; | |
246 | if (! $result = mysqli_query($db, $sql)) { | |
247 | printf("Error: %s\n", mysqli_error($db)); | |
248 | } | |
249 | ||
250 | $miscs = simplexml_load_file($brouwhulp . '/miscs.xml'); | |
251 | ||
252 | foreach ($miscs->MISC as $misc) { | |
253 | ||
254 | $sql = "INSERT INTO inventory_miscs SET name='" . mysqli_real_escape_string($db, $misc->NAME); | |
255 | if ($misc->NOTES) | |
256 | $sql .= "', notes='" . mysqli_real_escape_string($db, $misc->NOTES); | |
257 | $sql .= "', type='" . $misc->TYPE; | |
258 | $sql .= "', use_use='" . $misc->USE; | |
259 | $sql .= "', time='" . $misc->TIME; | |
21
acb2d8098f19
Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
20
diff
changeset
|
260 | ($misc->AMOUNT_IS_WEIGHT == 'TRUE') ? $sql .= "', amount_is_weight='1" : $sql .= "', amount_is_weight='0"; |
11 | 261 | if ($misc->USE_FOR) |
262 | $sql .= "', use_for='" . mysqli_real_escape_string($db, $misc->USE_FOR); | |
263 | if ($misc->ALWAYS_ON_STOCK) | |
21
acb2d8098f19
Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
20
diff
changeset
|
264 | ($misc->ALWAYS_ON_STOCK == 'TRUE') ? $sql .= "', always_on_stock='1" : $sql .= "', always_on_stock='0"; |
11 | 265 | 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
|
266 | $sql .= "', inventory='" . floatval($misc->INVENTORY) / 1000.0; |
11 | 267 | 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
|
268 | $sql .= "', cost='" . floatval($misc->COST); |
11 | 269 | $sql .= "';"; |
270 | if (! $result = mysqli_query($db, $sql)) { | |
271 | printf("Error: %s\n", mysqli_error($db)); | |
272 | } | |
273 | } | |
274 | } | |
275 | ||
276 | ||
277 | ||
278 | function do_equipments() | |
279 | { | |
280 | global $brouwhulp, $db; | |
281 | ||
282 | echo " Start adding equipments to the database\n"; | |
283 | $sql = "TRUNCATE TABLE inventory_equipments;"; | |
284 | if (! $result = mysqli_query($db, $sql)) { | |
285 | printf("Error: %s\n", mysqli_error($db)); | |
286 | } | |
287 | ||
288 | $equipments = simplexml_load_file($brouwhulp . '/equipments.xml'); | |
289 | ||
290 | foreach ($equipments->EQUIPMENT as $equipment) { | |
291 | ||
292 | $sql = "INSERT INTO inventory_equipments SET name='" . mysqli_real_escape_string($db, $equipment->NAME); | |
293 | $sql .= "', boil_size='" . $equipment->BOIL_SIZE; | |
294 | $sql .= "', batch_size='" . $equipment->BATCH_SIZE; | |
295 | $sql .= "', tun_volume='" . $equipment->TUN_VOLUME; | |
296 | $sql .= "', tun_weight='" . $equipment->TUN_WEIGHT; | |
297 | $sql .= "', tun_specific_heat='" . $equipment->TUN_SPECIFIC_HEAT; | |
298 | $sql .= "', top_up_water='" . $equipment->TOP_UP_WATER; | |
299 | $sql .= "', trub_chiller_loss='" . $equipment->TRUB_CHILLER_LOSS; | |
300 | /* | |
301 | * Brouwhulp uses a percentage for the evaporation rate. This is wrong | |
302 | * but was made so because the beerxml standard requires this. What we | |
303 | * do is calculate the actual evaporation and store that. | |
304 | * This is what we use. Brouwhulp calculates this on the fly. | |
305 | */ | |
306 | $sql .= "', evap_rate='" . ($equipment->EVAP_RATE * $equipment->BOIL_SIZE) / 100.0; | |
307 | $sql .= "', boil_time='" . $equipment->BOIL_TIME; | |
21
acb2d8098f19
Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
20
diff
changeset
|
308 | ($equipment->CALC_BOIL_VOLUME == 'TRUE') ? $sql .= "', calc_boil_volume='1" : $sql .= "', calc_boil_volume='0"; |
11 | 309 | $sql .= "', lauter_deadspace='" . $equipment->LAUTER_DEADSPACE; |
310 | $sql .= "', top_up_kettle='" . $equipment->TOP_UP_KETTLE; | |
311 | $sql .= "', hop_utilization='" . $equipment->HOP_UTILIZATION; | |
312 | if ($equipment->NOTES) | |
313 | $sql .= "', notes='" . mysqli_real_escape_string($db, $equipment->NOTES); | |
314 | $sql .= "', lauter_volume='" . $equipment->LAUTER_VOLUME; | |
315 | $sql .= "', kettle_volume='" . $equipment->KETTLE_VOLUME; | |
316 | if ($equipment->TUN_MATERIAL) | |
317 | $sql .= "', tun_material='" . mysqli_real_escape_string($db, $equipment->TUN_MATERIAL); | |
318 | $sql .= "', tun_height='" . $equipment->TUN_HEIGHT; | |
319 | $sql .= "', kettle_height='" . $equipment->KETTLE_HEIGHT; | |
320 | $sql .= "', lauter_height='" . $equipment->LAUTER_HEIGHT; | |
321 | $sql .= "', mash_volume='" . $equipment->MASH_VOLUME; | |
322 | $sql .= "', efficiency='" . $equipment->EFFICIENCY; | |
323 | ||
324 | $sql .= "';"; | |
325 | if (! $result = mysqli_query($db, $sql)) { | |
326 | printf("Error: %s\n", mysqli_error($db)); | |
327 | } | |
328 | } | |
329 | } | |
330 | ||
331 | ||
332 | ||
333 | function do_styles() | |
334 | { | |
335 | global $brouwhulp, $db; | |
336 | ||
337 | 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
|
338 | $sql = "TRUNCATE TABLE profile_styles;"; |
11 | 339 | if (! $result = mysqli_query($db, $sql)) { |
340 | printf("Error: %s\n", mysqli_error($db)); | |
341 | } | |
342 | ||
343 | $styles = simplexml_load_file($brouwhulp . '/styles.xml'); | |
344 | ||
345 | foreach ($styles->STYLE as $style) { | |
346 | ||
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
38
diff
changeset
|
347 | $sql = "INSERT INTO profile_styles SET name='" . mysqli_real_escape_string($db, $style->NAME); |
11 | 348 | if ($style->NOTES) |
349 | $sql .= "', notes='" . mysqli_real_escape_string($db, $style->NOTES); | |
350 | if ($style->CATEGORY) | |
351 | $sql .= "', category='" . mysqli_real_escape_string($db, $style->CATEGORY); | |
352 | if ($style->CATEGORY_NUMBER) | |
353 | $sql .= "', category_number='" . $style->CATEGORY_NUMBER; | |
354 | if ($style->STYLE_LETTER) | |
355 | $sql .= "', style_letter='" . mysqli_real_escape_string($db, $style->STYLE_LETTER); | |
356 | if ($style->STYLE_GUIDE) | |
357 | $sql .= "', style_guide='" . mysqli_real_escape_string($db, $style->STYLE_GUIDE); | |
358 | $sql .= "', type='" . $style->TYPE; | |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
359 | $sql .= "', og_min='" . floatval($style->OG_MIN); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
360 | $sql .= "', og_max='" . floatval($style->OG_MAX); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
361 | $sql .= "', fg_min='" . floatval($style->FG_MIN); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
362 | $sql .= "', fg_max='" . floatval($style->FG_MAX); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
363 | $sql .= "', ibu_min='" . floatval($style->IBU_MIN); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
364 | $sql .= "', ibu_max='" . floatval($style->IBU_MAX); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
365 | $sql .= "', color_min='" . floatval($style->COLOR_MIN); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
366 | $sql .= "', color_max='" . floatval($style->COLOR_MAX); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
367 | $sql .= "', carb_min='" . floatval($style->CARB_MIN); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
368 | $sql .= "', carb_max='" . floatval($style->CARB_MAX); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
369 | $sql .= "', abv_min='" . floatval($style->ABV_MIN); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
370 | $sql .= "', abv_max='" . floatval($style->ABV_MAX); |
11 | 371 | if ($style->PROFILE) |
372 | $sql .= "', profile='" . mysqli_real_escape_string($db, $style->PROFILE); | |
373 | if ($style->INGREDIENTS) | |
374 | $sql .= "', ingredients='" . mysqli_real_escape_string($db, $style->INGREDIENTS); | |
375 | if ($style->EXAMPLES) | |
376 | $sql .= "', examples='" . mysqli_real_escape_string($db, $style->EXAMPLES); | |
377 | ||
378 | $sql .= "';"; | |
379 | if (! $result = mysqli_query($db, $sql)) { | |
380 | printf("Error: %s\n", mysqli_error($db)); | |
381 | } | |
382 | } | |
383 | } | |
384 | ||
385 | ||
386 | ||
387 | function do_mash() | |
388 | { | |
389 | global $brouwhulp, $db; | |
390 | ||
391 | 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
|
392 | $sql = "TRUNCATE TABLE profile_mash;"; |
11 | 393 | if (! $result = mysqli_query($db, $sql)) { |
394 | printf("Error: %s\n", mysqli_error($db)); | |
395 | } | |
396 | ||
397 | $mashes = simplexml_load_file($brouwhulp . '/mashs.xml'); | |
398 | ||
399 | foreach ($mashes->MASH as $mash) { | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
38
diff
changeset
|
400 | $sql = "INSERT INTO profile_mash SET name='" . mysqli_real_escape_string($db, $mash->NAME); |
11 | 401 | if ($mash->NOTES) |
402 | $sql .= "', notes='" . mysqli_real_escape_string($db, $mash->NOTES); | |
403 | ||
404 | /* | |
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
|
405 | * Put the steps in a json array |
11 | 406 | */ |
407 | 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
|
408 | $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
|
409 | $comma = FALSE; |
11 | 410 | foreach ($mash->MASH_STEPS->MASH_STEP as $step) { |
411 | ||
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
|
412 | 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
|
413 | $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
|
414 | $comma = TRUE; |
38
b7d44c98d609
Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents:
35
diff
changeset
|
415 | $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
|
416 | if ($step->TYPE) { |
38
b7d44c98d609
Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents:
35
diff
changeset
|
417 | $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
|
418 | } |
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 | 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
|
420 | $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
|
421 | } |
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 | 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
|
423 | $steps .= ',"step_time":"' . $step->STEP_TIME . '"'; |
11 | 424 | } |
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
|
425 | 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
|
426 | $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
|
427 | } |
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 | 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
|
429 | $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
|
430 | } |
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
|
431 | $steps .= "}"; |
11 | 432 | } |
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
|
433 | $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 | $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
|
435 | } |
35 | 436 | $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
|
437 | 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
|
438 | printf("Error: %s\n", mysqli_error($db)); |
11 | 439 | } |
440 | } | |
441 | } | |
442 | ||
443 | ||
444 | ||
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
445 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
446 | function do_recipes() |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
447 | { |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
448 | global $brouwhulp, $db; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
449 | $len_fermentables = 0; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
450 | $len_hops = 0; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
451 | $len_miscs = 0; |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
452 | $len_yeasts = 0; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
453 | $len_waters = 0; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
454 | $len_mash = 0; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
455 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
456 | echo " Start adding recipes to the database\n"; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
457 | $sql = "TRUNCATE TABLE recipes;"; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
458 | if (! $result = mysqli_query($db, $sql)) { |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
459 | printf("Error: %s\n", mysqli_error($db)); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
460 | } |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
461 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
462 | $recipes= simplexml_load_file($brouwhulp . '/recipes.xml'); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
463 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
464 | foreach ($recipes->RECIPE as $recipe) { |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
465 | $f_sugars = 0; |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
466 | $efficiency = 75; |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
467 | $batch_size = 20; |
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
|
468 | $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
|
469 | $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
|
470 | $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
|
471 | $colorw = 0; |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
472 | |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
473 | $sql = "INSERT INTO recipes SET name='" . mysqli_real_escape_string($db, $recipe->NAME); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
474 | if ($recipe->NOTES) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
475 | $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
|
476 | else |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
477 | $sql .= "', notes='"; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
478 | if ($recipe->TYPE) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
479 | $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
|
480 | else |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
481 | $sql .= "', type='"; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
482 | if ($recipe->BATCH_SIZE) |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
483 | $batch_size = floatval($recipe->BATCH_SIZE); |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
484 | $sql .= "', batch_size='" . $batch_size; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
485 | if ($recipe->BOIL_TIME) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
486 | $sql .= "', boil_time='" . floatval($recipe->BOIL_TIME); |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
487 | else |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
488 | $sql .= "', boil_time='90"; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
489 | if ($recipe->EFFICIENCY) |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
490 | $efficiency = floatval($recipe->EFFICIENCY); |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
491 | $sql .= "', efficiency='" . $efficiency; |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
492 | /* 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
|
493 | /* 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
|
494 | /* 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
|
495 | if ($recipe->COLOR_METHOD) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
496 | $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
|
497 | if ($recipe->IBU) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
498 | $sql .= "', est_ibu='" . floatval($recipe->IBU); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
499 | if ($recipe->IBU_METHOD) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
500 | $sql .= "', ibu_method='" . mysqli_real_escape_string($db, $recipe->IBU_METHOD); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
501 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
502 | if ($recipe->STYLE) { |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
503 | if ($recipe->STYLE->NAME) |
51 | 504 | $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
|
505 | if ($recipe->STYLE->STYLE_LETTER) |
51 | 506 | $sql .= "', st_letter='" . mysqli_real_escape_string($db, $recipe->STYLE->STYLE_LETTER); |
507 | if ($recipe->STYLE->STYLE_GUIDE) { | |
508 | if ($recipe->STYLE->STYLE_GUIDE == "Biertypengids Derek Walsh") { | |
509 | $sql .= "', st_guide='BKG 2015"; | |
510 | } else if ($recipe->STYLE->STYLE_GUIDE == "BKG Biertypen") { | |
511 | $sql .= "', st_guide='BKG 2015"; | |
512 | } else { | |
513 | $sql .= "', st_guide='" . mysqli_real_escape_string($db, $recipe->STYLE->STYLE_GUIDE); | |
514 | } | |
515 | } | |
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
|
516 | 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
|
517 | $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
|
518 | 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
|
519 | $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
|
520 | 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
|
521 | $sql .= "', st_type='" . mysqli_real_escape_string($db, $recipe->STYLE->TYPE); |
51 | 522 | if ($recipe->STYLE->OG_MIN) |
523 | $sql .= "', st_og_min='" . floatval($recipe->STYLE->OG_MIN); | |
524 | if ($recipe->STYLE->OG_MAX) | |
525 | $sql .= "', st_og_max='" . floatval($recipe->STYLE->OG_MAX); | |
526 | if ($recipe->STYLE->FG_MIN) | |
527 | $sql .= "', st_fg_min='" . floatval($recipe->STYLE->FG_MIN); | |
528 | if ($recipe->STYLE->FG_MAX) | |
529 | $sql .= "', st_fg_max='" . floatval($recipe->STYLE->FG_MAX); | |
530 | if ($recipe->STYLE->IBU_MIN) | |
531 | $sql .= "', st_ibu_min='" . floatval($recipe->STYLE->IBU_MIN); | |
532 | if ($recipe->STYLE->IBU_MAX) | |
533 | $sql .= "', st_ibu_max='" . floatval($recipe->STYLE->IBU_MAX); | |
534 | if ($recipe->STYLE->COLOR_MIN) { | |
535 | $srm = floatval($recipe->STYLE->COLOR_MIN); | |
536 | $sql .= "', st_color_min='" . srm_to_ebc($srm); | |
537 | } | |
538 | if ($recipe->STYLE->COLOR_MAX) { | |
539 | $srm = floatval($recipe->STYLE->COLOR_MAX); | |
540 | $sql .= "', st_color_max='" . srm_to_ebc($srm); | |
541 | } | |
542 | if ($recipe->STYLE->CARB_MIN) | |
543 | $sql .= "', st_carb_min='" . floatval($recipe->STYLE->CARB_MIN); | |
544 | if ($recipe->STYLE->CARB_MAX) | |
545 | $sql .= "', st_carb_max='" . floatval($recipe->STYLE->CARB_MAX); | |
546 | if ($recipe->STYLE->ABV_MIN) | |
547 | $sql .= "', st_abv_min='" . floatval($recipe->STYLE->ABV_MIN); | |
548 | if ($recipe->STYLE->ABV_MAX) | |
549 | $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
|
550 | } |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
551 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
552 | /* |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
553 | * Put the fermentables in a json array |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
554 | */ |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
555 | if ($recipe->FERMENTABLES) { |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
556 | $fermentables = "["; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
557 | $comma = FALSE; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
558 | foreach ($recipe->FERMENTABLES->FERMENTABLE as $fermentable) { |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
559 | if ($comma) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
560 | $fermentables .= ','; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
561 | $comma = TRUE; |
51 | 562 | $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
|
563 | $fermentables .= ',"f_origin":"' . mysqli_real_escape_string($db, $fermentable->ORIGIN) . '"'; |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
564 | $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
|
565 | $famount = floatval($fermentable->AMOUNT); |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
566 | $fermentables .= ',"f_amount":' . $famount; |
51 | 567 | $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
|
568 | $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
|
569 | $fermentables .= ',"f_type":"' . $ftype . '"'; |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
570 | $fyield = floatval($fermentable->YIELD); |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
571 | $fermentables .= ',"f_yield":' . $fyield; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
572 | if ($fermentable->COLOR) { |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
573 | $srm = floatval($fermentable->COLOR); |
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
|
574 | $colorw += ($famount * $srm / $batch_size) * 8.34436; /* Kleurwerking */ |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
575 | $ebc = srm_to_ebc($srm); |
51 | 576 | $fermentables .= ',"f_color":' . $ebc; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
577 | } |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
578 | if ($fermentable->COARSE_FINE_DIFF) |
51 | 579 | $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
|
580 | else |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
581 | $fermentables .= ',"f_coarse_fine_diff":0'; |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
582 | if ($fermentable->MOISTURE) |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
583 | $fmoisture = floatval($fermentable->MOISTURE); |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
584 | else |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
585 | $fmoisture = 0; |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
586 | $fermentables .= ',"f_moisture":' . $fmoisture; |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
587 | if ($fermentable->DIASTATIC_POWER) |
51 | 588 | $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
|
589 | else |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
590 | $fermentables .= ',"f_diastatic_power":0'; |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
591 | if ($fermentable->PROTEIN) |
51 | 592 | $fermentables .= ',"f_protein":' . floatval($fermentable->PROTEIN); |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
593 | else |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
594 | $fermentables .= ',"f_protein":0'; |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
595 | if ($fermentable->MAX_IN_BATCH) |
51 | 596 | $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
|
597 | else |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
598 | $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
|
599 | $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
|
600 | 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
|
601 | $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
|
602 | 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
|
603 | $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
|
604 | $fermentables .= ',"f_graintype":"' . $fgraintype . '"'; |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
605 | if ($fermentable->ADDED) |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
606 | $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
|
607 | else |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
608 | $fadded = "Mash"; |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
609 | $fermentables .= ',"f_added":"'.$fadded.'"'; |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
610 | ($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
|
611 | ($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
|
612 | if ($fermentable->DISSOLVED_PROTEIN) |
51 | 613 | $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
|
614 | else |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
615 | $fermentables .= ',"f_dissolved_protein":0'; |
51 | 616 | ($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
|
617 | $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
|
618 | $fermentables .= ',"f_percentage":' . $percent; |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
619 | if ($fermentable->DI_pH) |
51 | 620 | $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
|
621 | else |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
622 | $fermentables .= ',"f_di_ph":5.6'; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
623 | $fermentables .= "}"; |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
624 | /* Sugars */ |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
625 | $d = $famount * ($fyield / 100) * (1 - $fmoisture / 100); |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
626 | if ($fadded == "Mash") |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
627 | $d = floatval($efficiency) / 100 * $d; |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
628 | $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
|
629 | 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
|
630 | $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
|
631 | 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
|
632 | $pSugar += $percent; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
633 | } |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
634 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
635 | $fermentables .= ']'; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
636 | // echo $fermentables . PHP_EOL; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
637 | $sql .= "', json_fermentables='" . $fermentables; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
638 | if (strlen($fermentables) > $len_fermentables) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
639 | $len_fermentables = strlen($fermentables); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
640 | } |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
641 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
642 | /* |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
643 | * Put the hops in a json array |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
644 | */ |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
645 | if ($recipe->HOPS) { |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
646 | $hops = "["; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
647 | $comma = FALSE; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
648 | foreach ($recipe->HOPS->HOP as $hop) { |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
649 | if ($comma) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
650 | $hops .= ','; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
651 | $comma = TRUE; |
51 | 652 | $hops .= '{"h_name":"' . mysqli_real_escape_string($db, $hop->NAME) . '"'; |
653 | $hops .= ',"h_amount":' . floatval($hop->AMOUNT); | |
654 | $hops .= ',"h_cost":' . floatval($hop->COST); | |
655 | $hops .= ',"h_type":"' . mysqli_real_escape_string($db, $hop->TYPE) . '"'; | |
656 | $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
|
657 | $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
|
658 | if ($hop->TIME) |
51 | 659 | $hops .= ',"h_time":' . floatval($hop->TIME); |
59
ad28e09e3abd
Added Tinseth IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
660 | else |
ad28e09e3abd
Added Tinseth IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
661 | $hops .= ',"h_time":0'; |
51 | 662 | $hops .= ',"h_alpha":' . floatval($hop->ALPHA); |
663 | $hops .= ',"h_beta":' . floatval($hop->BETA); | |
664 | $hops .= ',"h_hsi":' . floatval($hop->HSI); | |
665 | $hops .= ',"h_humulene":' . floatval($hop->HUMULENE); | |
666 | $hops .= ',"h_carophyllene":' . floatval($hop->CAROPHYLLENE); | |
667 | $hops .= ',"h_cohumulone":' . floatval($hop->COHUMULONE); | |
668 | $hops .= ',"h_myrcene":' . floatval($hop->MYRCENE); | |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
669 | if ($hop->TOTAL_OIL) |
51 | 670 | $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
|
671 | else |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
672 | $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
|
673 | 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
|
674 | $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
|
675 | else |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
676 | $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
|
677 | |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
678 | $hops .= "}"; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
679 | } |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
680 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
681 | $hops .= ']'; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
682 | // echo $hops . PHP_EOL; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
683 | $sql .= "', json_hops='" . $hops; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
684 | if (strlen($hops) > $len_hops) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
685 | $len_hops = strlen($hops); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
686 | } |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
687 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
688 | /* |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
689 | * Put the miscs in a json array |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
690 | */ |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
691 | if ($recipe->MISCS) { |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
692 | $miscs = "["; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
693 | $comma = FALSE; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
694 | foreach ($recipe->MISCS->MISC as $misc) { |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
695 | if ($comma) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
696 | $miscs .= ','; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
697 | $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
|
698 | $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
|
699 | $miscs .= '{"m_name":"' . $mname . '"'; |
51 | 700 | $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
|
701 | if ($misc->COST) { |
51 | 702 | $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
|
703 | } 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
|
704 | /* 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
|
705 | 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
|
706 | $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
|
707 | } 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
|
708 | $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
|
709 | } |
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
|
710 | } |
51 | 711 | $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
|
712 | $miscs .= ',"m_use_use":"' . mysqli_real_escape_string($db, $misc->USE) . '"'; |
51 | 713 | ($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
|
714 | if ($misc->TIME) |
51 | 715 | $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
|
716 | else |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
717 | $miscs .= ',"m_time":0'; |
48
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 | } |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
720 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
721 | $miscs .= ']'; |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
722 | // echo $miscs . PHP_EOL; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
723 | $sql .= "', json_miscs='" . $miscs; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
724 | if (strlen($miscs) > $len_miscs) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
725 | $len_miscs = strlen($miscs); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
726 | } |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
727 | |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
728 | /* |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
729 | * Put the yeasts in a json array |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
730 | */ |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
731 | if ($recipe->YEASTS) { |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
732 | $yeasts = "["; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
733 | $comma = FALSE; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
734 | foreach ($recipe->YEASTS->YEAST as $yeast) { |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
735 | if ($comma) |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
736 | $yeasts .= ','; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
737 | $comma = TRUE; |
51 | 738 | $yeasts .= '{"y_name":"' . mysqli_real_escape_string($db, $yeast->NAME) . '"'; |
739 | $yeasts .= ',"y_amount":' . floatval($yeast->AMOUNT); | |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
740 | if ($yeast->COST) |
51 | 741 | $yeasts .= ',"y_cost":' . floatval($yeast->COST); |
61 | 742 | else |
743 | $yeasts .= ',"y_cost":0'; | |
51 | 744 | $yeasts .= ',"y_laboratory":"' . mysqli_real_escape_string($db, $yeast->LABORATORY) . '"'; |
745 | $yeasts .= ',"y_product_id":"' . mysqli_real_escape_string($db, $yeast->PRODUCT_ID) . '"'; | |
746 | $yeasts .= ',"y_type":"' . mysqli_real_escape_string($db, $yeast->TYPE) . '"'; | |
747 | $yeasts .= ',"y_form":"' . mysqli_real_escape_string($db, $yeast->FORM) . '"'; | |
748 | ($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
|
749 | if ($yeast->ADD_TO_SECONDARY=="FALSE") { |
51 | 750 | $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
|
751 | $svg = floatval($yeast->ATTENUATION); |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
752 | } else if ($yeast->PRODUCT_ID=="F2") { |
51 | 753 | $yeasts .= ',"y_use":"Bottle"'; |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
754 | } else { |
51 | 755 | $yeasts .= ',"y_use":"Secondary"'; |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
756 | } |
61 | 757 | $yeasts .= ',"y_min_temperature":' . floatval($yeast->MIN_TEMPERATURE); |
758 | $yeasts .= ',"y_max_temperature":' . floatval($yeast->MAX_TEMPERATURE); | |
759 | $yeasts .= ',"y_attenuation":' . floatval($yeast->ATTENUATION); | |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
760 | $yeasts .= "}"; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
761 | } |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
762 | |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
763 | $yeasts .= ']'; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
764 | // echo $yeasts . PHP_EOL; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
765 | $sql .= "', json_yeasts='" . $yeasts; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
766 | if (strlen($yeasts) > $len_yeasts) |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
767 | $len_yeasts = strlen($yeasts); |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
768 | } |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
769 | |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
770 | /* |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
771 | * Put the waters in a json array |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
772 | */ |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
773 | if ($recipe->WATERS) { |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
774 | $waters = "["; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
775 | $comma = FALSE; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
776 | foreach ($recipe->WATERS->WATER as $water) { |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
777 | if ($comma) |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
778 | $waters .= ','; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
779 | $comma = TRUE; |
51 | 780 | $waters .= '{"w_name":"' . mysqli_real_escape_string($db, $water->NAME) . '"'; |
781 | $waters .= ',"w_amount":' . floatval($water->AMOUNT); | |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
782 | if ($water->CALCIUM) |
51 | 783 | $waters .= ',"w_calcium":' . floatval($water->CALCIUM); |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
784 | if ($water->SULFATE) |
51 | 785 | $waters .= ',"w_sulfate":' . floatval($water->SULFATE); |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
786 | if ($water->CHLORIDE) |
51 | 787 | $waters .= ',"w_chloride":' . floatval($water->CHLORIDE); |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
788 | if ($water->SODIUM) |
51 | 789 | $waters .= ',"w_sodium":' . floatval($water->SODIUM); |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
790 | if ($water->MAGNESIUM) |
51 | 791 | $waters .= ',"w_magnesium":' . floatval($water->MAGNESIUM); |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
792 | if ($water->PH) |
51 | 793 | $waters .= ',"w_ph":' . floatval($water->PH); |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
794 | if ($water->TOTAL_ALKALINITY) |
51 | 795 | $waters .= ',"w_total_alkalinity":' . floatval($water->TOTAL_ALKALINITY); |
796 | if ($water->COST) | |
797 | $waters .= ',"w_cost":' . floatval($water->COST); | |
798 | else | |
799 | $waters .= ',"w_cost":0.00'; | |
800 | ($water->DEFAULT_WATER== "TRUE") ? $waters .= ',"w_default_water":true' : $waters.= ',"w_default_water":false'; | |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
801 | $waters .= "}"; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
802 | } |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
803 | |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
804 | $waters .= ']'; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
805 | // echo $waters . PHP_EOL; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
806 | $sql .= "', json_waters='" . $waters; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
807 | if (strlen($waters) > $len_waters) |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
808 | $len_waters = strlen($waters); |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
809 | } |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
810 | |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
811 | /* |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
812 | * Put the mash in a json array |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
813 | */ |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
814 | if ($recipe->MASH) { |
51 | 815 | $sql .= "',mash_sparge_temp='" . floatval($recipe->MASH->SPARGE_TEMP); |
816 | $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
|
817 | if ($recipe->MASH->NAME) |
51 | 818 | $sql .= "',mash_name='" . mysqli_real_escape_string($db, $recipe->MASH->NAME); |
819 | ||
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
820 | if ($recipe->MASH->MASH_STEPS) { |
51 | 821 | $steps = '['; |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
822 | $comma = FALSE; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
823 | 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
|
824 | if ($comma) |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
825 | $steps .= ','; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
826 | $comma = TRUE; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
827 | $steps .= '{"step_name":"' . mysqli_real_escape_string($db, $step->NAME) . '"'; |
51 | 828 | if ($step->TYPE) |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
829 | $steps .= ',"step_type":"' . $step->TYPE . '"'; |
51 | 830 | if ($step->INFUSE_AMOUNT) |
831 | $steps .= ',"step_infuse_amount":"' . floatval($step->INFUSE_AMOUNT) . '"'; | |
832 | if ($step->STEP_TEMP) | |
833 | $steps .= ',"step_temp":"' . floatval($step->STEP_TEMP) . '"'; | |
834 | if ($step->STEP_TIME) | |
835 | $steps .= ',"step_time":"' . floatval($step->STEP_TIME) . '"'; | |
836 | if ($step->RAMP_TIME) | |
837 | $steps .= ',"ramp_time":"' . floatval($step->RAMP_TIME) . '"'; | |
838 | if ($step->END_TEMP) | |
839 | $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
|
840 | $steps .= "}"; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
841 | } |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
842 | $steps .= ']'; |
51 | 843 | // echo $steps . PHP_EOL; |
844 | $sql .= "', json_mashs='" . $steps; | |
845 | if (strlen($steps) > $len_mash) | |
846 | $len_mash = strlen($steps); | |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
847 | } |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
848 | } |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
849 | |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
850 | /* |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
851 | * Added the calculated values |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
852 | * OG, FG, color, IBU |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
853 | */ |
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
|
854 | $og = estimate_og($f_sugars, $batch_size); |
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
|
855 | $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
|
856 | $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
|
857 | $sql .= "', est_fg='" . floatval($fg); |
88 | 858 | $abv = abvol($og, $fg); |
859 | $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
|
860 | $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
|
861 | $sql .= "', est_color='" . floatval($color); |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
862 | $sql .= "';"; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
863 | if (! $result = mysqli_query($db, $sql)) { |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
864 | printf("Error: %s\n", mysqli_error($db)); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
865 | } |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
866 | } |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
867 | // echo "Fermentables: " . $len_fermentables . PHP_EOL; |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
868 | // echo "Hops: " . $len_hops . PHP_EOL; |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
869 | // echo "Miscs: " . $len_miscs . PHP_EOL; |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
870 | // echo "Yeasts: " . $len_yeasts . PHP_EOL; |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
871 | // echo "Waters: " . $len_waters . PHP_EOL; |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
872 | // echo "Mash: " . $len_mash . PHP_EOL; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
873 | } |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
874 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
875 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
876 | |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
877 | do_fermentables(); |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
878 | do_hops(); |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
879 | do_yeasts(); |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
880 | do_miscs(); |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
881 | do_waters(); |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
882 | do_equipments(); |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
883 | do_styles(); |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
884 | do_mash(); |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
885 | do_recipes(); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
886 | |
11 | 887 | |
888 | mysqli_close($db); | |
889 | ||
890 | echo "Finished adding data\n"; | |
891 | ||
892 | ||
893 | ?> |