www/includes/db_product.php

changeset 238
8e7384587a10
parent 237
9337b5ff8698
child 240
a85c1d4c4d12
equal deleted inserted replaced
237:9337b5ff8698 238:8e7384587a10
49 $sql .= "', eq_boil_size='" . $_POST['eq_boil_size']; 49 $sql .= "', eq_boil_size='" . $_POST['eq_boil_size'];
50 $sql .= "', eq_batch_size='" . $_POST['eq_batch_size']; 50 $sql .= "', eq_batch_size='" . $_POST['eq_batch_size'];
51 $sql .= "', eq_tun_volume='" . $_POST['eq_tun_volume']; 51 $sql .= "', eq_tun_volume='" . $_POST['eq_tun_volume'];
52 $sql .= "', eq_tun_weight='" . $_POST['eq_tun_weight']; 52 $sql .= "', eq_tun_weight='" . $_POST['eq_tun_weight'];
53 $sql .= "', eq_tun_specific_heat='" . $_POST['eq_tun_specific_heat']; 53 $sql .= "', eq_tun_specific_heat='" . $_POST['eq_tun_specific_heat'];
54 $sql .= "', eq_tun_material='" . mysqli_real_escape_string($connect, $_POST['eq_tun_material']); 54 $sql .= "', eq_tun_material='" . $_POST['eq_tun_material'];
55 $sql .= "', eq_tun_height='" . $_POST['eq_tun_height']; 55 $sql .= "', eq_tun_height='" . $_POST['eq_tun_height'];
56 $sql .= "', eq_top_up_water='" . $_POST['eq_top_up_water']; 56 $sql .= "', eq_top_up_water='" . $_POST['eq_top_up_water'];
57 $sql .= "', eq_trub_chiller_loss='" . $_POST['eq_trub_chiller_loss']; 57 $sql .= "', eq_trub_chiller_loss='" . $_POST['eq_trub_chiller_loss'];
58 $sql .= "', eq_evap_rate='" . $_POST['eq_evap_rate']; 58 $sql .= "', eq_evap_rate='" . $_POST['eq_evap_rate'];
59 $sql .= "', eq_boil_time='" . $_POST['eq_boil_time']; 59 $sql .= "', eq_boil_time='" . $_POST['eq_boil_time'];
136 * Recipe part 136 * Recipe part
137 */ 137 */
138 $sql .= "', st_name='" . mysqli_real_escape_string($connect, $_POST['st_name']); 138 $sql .= "', st_name='" . mysqli_real_escape_string($connect, $_POST['st_name']);
139 $sql .= "', st_letter='" . mysqli_real_escape_string($connect, $_POST['st_letter']); 139 $sql .= "', st_letter='" . mysqli_real_escape_string($connect, $_POST['st_letter']);
140 $sql .= "', st_guide='" . mysqli_real_escape_string($connect, $_POST['st_guide']); 140 $sql .= "', st_guide='" . mysqli_real_escape_string($connect, $_POST['st_guide']);
141 $sql .= "', st_type='" . mysqli_real_escape_string($connect, $_POST['st_type']); 141 $sql .= "', st_type='" . $_POST['st_type'];
142 $sql .= "', st_category='" . mysqli_real_escape_string($connect, $_POST['st_category']); 142 $sql .= "', st_category='" . mysqli_real_escape_string($connect, $_POST['st_category']);
143 $sql .= "', st_category_number='" . $_POST['st_category_number']; 143 $sql .= "', st_category_number='" . $_POST['st_category_number'];
144 $sql .= "', st_og_min='" . $_POST['st_og_min']; 144 $sql .= "', st_og_min='" . $_POST['st_og_min'];
145 $sql .= "', st_og_max='" . $_POST['st_og_max']; 145 $sql .= "', st_og_max='" . $_POST['st_og_max'];
146 $sql .= "', st_fg_min='" . $_POST['st_fg_min']; 146 $sql .= "', st_fg_min='" . $_POST['st_fg_min'];
198 $sql .= "', w2_magnesium='" . $_POST['w2_magnesium']; 198 $sql .= "', w2_magnesium='" . $_POST['w2_magnesium'];
199 $sql .= "', w2_total_alkalinity='" . $_POST['w2_total_alkalinity']; 199 $sql .= "', w2_total_alkalinity='" . $_POST['w2_total_alkalinity'];
200 $sql .= "', w2_ph='" . $_POST['w2_ph']; 200 $sql .= "', w2_ph='" . $_POST['w2_ph'];
201 $sql .= "', w2_cost='" . $_POST['w2_cost']; 201 $sql .= "', w2_cost='" . $_POST['w2_cost'];
202 } 202 }
203 $sql .= "', wa_acid_name='" . $_POST['wa_acid_name'];
204 $sql .= "', wa_acid_perc='" . $_POST['wa_acid_perc'];
205 $sql .= "', wa_base_name='" . $_POST['wa_base_name'];
203 syslog(LOG_NOTICE, $sql); 206 syslog(LOG_NOTICE, $sql);
204 207
208 $fermentables = '[';
209 $comma = FALSE;
205 if (isset($_POST['fermentables'])) { 210 if (isset($_POST['fermentables'])) {
206 $array = $_POST['fermentables']; 211 $array = $_POST['fermentables'];
207 foreach($array as $key => $item){ 212 foreach($array as $key => $item){
208 foreach ($disallowed as $disallowed_key) { 213 /*
209 unset($array[$key]["$disallowed_key"]); 214 * Manual encode to json.
210 } 215 */
211 } 216 if ($comma)
212 // syslog(LOG_NOTICE, "json_fermentables=: ".str_replace($rescapers,$rreplacements,json_encode($array))); 217 $fermentables .= ',';
213 $sql .= "', json_fermentables='" . str_replace($rescapers,$rreplacements,json_encode($array)); 218 $comma = TRUE;
214 } 219 $fermentable = '{"f_name":"' . str_replace($rescapers,$rreplacements,$item['f_name']);
215 220 $fermentable .= '","f_origin":"' . str_replace($rescapers,$rreplacements,$item['f_origin']);
221 $fermentable .= '","f_supplier":"' . str_replace($rescapers,$rreplacements,$item['f_supplier']);
222 $fermentable .= '","f_amount":' . $item['f_amount'];
223 $fermentable .= ',"f_cost":' . $item['f_cost'];
224 $fermentable .= ',"f_type":' . $item['f_type'];
225 $fermentable .= ',"f_yield":' . $item['f_yield'];
226 $fermentable .= ',"f_color":' . $item['f_color'];
227 $fermentable .= ',"f_coarse_fine_diff":' . $item['f_coarse_fine_diff'];
228 $fermentable .= ',"f_moisture":' . $item['f_moisture'];
229 $fermentable .= ',"f_diastatic_power":' . $item['f_diastatic_power'];
230 $fermentable .= ',"f_protein":' . $item['f_protein'];
231 $fermentable .= ',"f_dissolved_protein":' . $item['f_dissolved_protein'];
232 $fermentable .= ',"f_max_in_batch":' . $item['f_max_in_batch'];
233 $fermentable .= ',"f_graintype":' . $item['f_graintype'];
234 $fermentable .= ',"f_added":' . $item['f_added'];
235 $fermentable .= ',"f_recommend_mash":' . $item['f_recommend_mash'];
236 $fermentable .= ',"f_add_after_boil":' . $item['f_add_after_boil'];
237 $fermentable .= ',"f_adjust_to_total_100":' . $item['f_adjust_to_total_100'];
238 $fermentable .= ',"f_percentage":' . $item['f_percentage'];
239 $fermentable .= ',"f_di_ph":' . $item['f_di_ph'];
240 $fermentable .= ',"f_acid_to_ph_57":' . $item['f_acid_to_ph_57'] . '}';
241 syslog(LOG_NOTICE, $fermentable);
242 $fermentables .= $fermentable;
243 }
244 }
245 $fermentables .= ']';
246 $sql .= "', json_fermentables='" . $fermentables;
247
248 $hops = '[';
249 $comma = FALSE;
216 if (isset($_POST['hops'])) { 250 if (isset($_POST['hops'])) {
217 $array = $_POST['hops']; 251 $array = $_POST['hops'];
218 foreach($array as $key => $item){ 252 foreach($array as $key => $item){
219 foreach ($disallowed as $disallowed_key) { 253 if ($comma)
220 unset($array[$key]["$disallowed_key"]); 254 $hops .= ',';
221 } 255 $comma = TRUE;
222 } 256 $hop = '{"h_name":"' . str_replace($rescapers,$rreplacements,$item['h_name']);
223 // syslog(LOG_NOTICE, "json_hops: ".str_replace($rescapers,$rreplacements,json_encode($array))); 257 $hop .= '","h_origin":"' . str_replace($rescapers,$rreplacements,$item['h_origin']);
224 $sql .= "', json_hops='" . str_replace($rescapers,$rreplacements,json_encode($array)); 258 $hop .= '","h_amount":' . $item['h_amount'];
225 } 259 $hop .= ',"h_cost":' . $item['h_cost'];
226 260 $hop .= ',"h_type":' . $item['h_type'];
261 $hop .= ',"h_form":' . $item['h_form'];
262 $hop .= ',"h_useat":' . $item['h_useat'];
263 $hop .= ',"h_time":' . $item['h_time'];
264 $hop .= ',"h_alpha":' . $item['h_alpha'];
265 $hop .= ',"h_beta":' . $item['h_beta'];
266 $hop .= ',"h_hsi":' . $item['h_hsi'];
267 $hop .= ',"h_humulene":' . $item['h_humulene'];
268 $hop .= ',"h_caryophyllene":' . $item['h_caryophyllene'];
269 $hop .= ',"h_cohumulone":' . $item['h_cohumulone'];
270 $hop .= ',"h_myrcene":' . $item['h_myrcene'];
271 $hop .= ',"h_total_oil":' . $item['h_total_oil'] . '}';
272 syslog(LOG_NOTICE, $hop);
273 $hops .= $hop;
274 }
275 }
276 $hops .= ']';
277 $sql .= "', json_hops='" . $hops;
278
279 $miscs = '[';
280 $comma = FALSE;
227 if (isset($_POST['miscs'])) { 281 if (isset($_POST['miscs'])) {
228 $array = $_POST['miscs']; 282 $array = $_POST['miscs'];
229 foreach($array as $key => $item){ 283 foreach($array as $key => $item){
230 foreach ($disallowed as $disallowed_key) { 284 if ($comma)
231 unset($array[$key]["$disallowed_key"]); 285 $miscs .= ',';
232 } 286 $comma = TRUE;
233 } 287 $misc = '{"m_name":"' . str_replace($rescapers,$rreplacements,$item['m_name']);
234 // syslog(LOG_NOTICE, "json_miscs: ".str_replace($rescapers,$rreplacements,json_encode($array))); 288 $misc .= '","m_amount":' . $item['m_amount'];
235 $sql .= "', json_miscs='" . str_replace($rescapers,$rreplacements,json_encode($array)); 289 $misc .= ',"m_type":' . $item['m_type'];
236 } 290 $misc .= ',"m_use_use":' . $item['m_use_use'];
237 291 $misc .= ',"m_time":' . $item['m_time'];
292 $misc .= ',"m_amount_is_weight":' . $item['m_amount_is_weight'];
293 $misc .= ',"m_cost":' . $item['m_cost'] . '}';
294 syslog(LOG_NOTICE, $misc);
295 $miscs .= $misc;
296 }
297 }
298 $miscs .= ']';
299 $sql .= "', json_miscs='" . $miscs;
300
301 $yeasts = '[';
302 $comma = FALSE;
238 if (isset($_POST['yeasts'])) { 303 if (isset($_POST['yeasts'])) {
239 $array = $_POST['yeasts']; 304 $array = $_POST['yeasts'];
240 foreach($array as $key => $item){ 305 foreach($array as $key => $item){
241 foreach ($disallowed as $disallowed_key) { 306 if ($comma)
242 unset($array[$key]["$disallowed_key"]); 307 $yeasts .= ',';
243 } 308 $comma = TRUE;
244 } 309 $yeast = '{"y_name":"' . str_replace($rescapers,$rreplacements,$item['y_name']);
245 // syslog(LOG_NOTICE, "json_yeasts: ". str_replace($rescapers,$rreplacements,json_encode($array))); 310 $yeast .= '","y_laboratory":"' . str_replace($rescapers,$rreplacements,$item['y_laboratory']);
246 $sql .= "', json_yeasts='" . str_replace($rescapers,$rreplacements,json_encode($array)); 311 $yeast .= '","y_product_id":"' . str_replace($rescapers,$rreplacements,$item['y_product_id']);
247 } 312 $yeast .= '","y_amount":' . $item['y_amount'];
248 313 $yeast .= ',"y_type":' . $item['y_type'];
314 $yeast .= ',"y_form":' . $item['y_form'];
315 $yeast .= ',"y_min_temperature":' . $item['y_min_temperature'];
316 $yeast .= ',"y_max_temperature":' . $item['y_max_temperature'];
317 $yeast .= ',"y_flocculation":' . $item['y_flocculation'];
318 $yeast .= ',"y_attenuation":' . $item['y_attenuation'];
319 $yeast .= ',"y_cells":' . $item['y_cells'];
320 $yeast .= ',"y_inventory":' . $item['y_inventory'];
321 $yeast .= ',"y_use":' . $item['y_use'];
322 $yeast .= ',"y_cost":' . $item['y_cost'] . '}';
323 syslog(LOG_NOTICE, $yeast);
324 $yeasts .= $yeast;
325 }
326 }
327 $yeasts .= ']';
328 $sql .= "', json_yeasts='" . $yeasts;
329
330 $mashs = '[';
331 $comma = FALSE;
249 if (isset($_POST['mashs'])) { 332 if (isset($_POST['mashs'])) {
250 $array = $_POST['mashs']; 333 $array = $_POST['mashs'];
251 foreach($array as $key => $item){ 334 foreach($array as $key => $item){
252 foreach ($disallowed as $disallowed_key) { 335 if ($comma)
253 unset($array[$key]["$disallowed_key"]); 336 $mashs .= ',';
254 } 337 $comma = TRUE;
255 } 338 $mash = '{"step_name":"' . str_replace($rescapers,$rreplacements,$item['step_name']);
256 // syslog(LOG_NOTICE, "json_mashs: ".str_replace($rescapers,$rreplacements,json_encode($array))); 339 $mash .= '","step_type":' . $item['step_type'];
257 $sql .= "', json_mashs='" . str_replace($rescapers,$rreplacements,json_encode($array)); 340 if (isset($item['step_infuse_amount']) && $item['step_infuse_amount'] != "")
258 } 341 $mash .= ',"step_infuse_amount":' . $item['step_infuse_amount'];
342 else
343 $mash .= ',"step_infuse_amount":0';
344 $mash .= ',"step_temp":' . $item['step_temp'];
345 $mash .= ',"step_time":' . $item['step_time'];
346 $mash .= ',"ramp_time":' . $item['ramp_time'];
347 $mash .= ',"end_temp":' . $item['end_temp'] . '}';
348 syslog(LOG_NOTICE, $mash);
349 $mashs .= $mash;
350 }
351 }
352 $mashs .= ']';
353 $sql .= "', json_mashs='" . $mashs;
259 354
260 if (isset($_POST['insert'])) { 355 if (isset($_POST['insert'])) {
261 $sql .= "';"; 356 $sql .= "';";
262 } 357 }
263 if (isset($_POST['update'])) { 358 if (isset($_POST['update'])) {

mercurial