www/includes/db_recipes.php

changeset 559
10cc2400b5d5
parent 394
ccd85f0ed96c
child 565
dfc850e6ee1f
equal deleted inserted replaced
558:a8e065a9f851 559:10cc2400b5d5
283 $yeast .= ',"y_attenuation":' . $item['y_attenuation']; 283 $yeast .= ',"y_attenuation":' . $item['y_attenuation'];
284 $yeast .= ',"y_cells":' . $item['y_cells']; 284 $yeast .= ',"y_cells":' . $item['y_cells'];
285 $yeast .= ',"y_tolerance":' . $item['y_tolerance']; 285 $yeast .= ',"y_tolerance":' . $item['y_tolerance'];
286 $yeast .= ',"y_inventory":' . $item['y_inventory']; 286 $yeast .= ',"y_inventory":' . $item['y_inventory'];
287 $yeast .= ',"y_use":' . $item['y_use']; 287 $yeast .= ',"y_use":' . $item['y_use'];
288 $yeast .= ',"y_sta1":' . $item['y_sta1'];
289 $yeast .= ',"y_bacteria":' . $item['y_bacteria'];
290 $yeast .= ',"y_harvest_top":' . $item['y_harvest_top'];
291 $yeast .= ',"y_harvest_time":' . $item['y_harvest_time'];
292 $yeast .= ',"y_pitch_temperature":' . $item['y_pitch_temperature'];
293 $yeast .= ',"y_pofpos":' . $item['y_pofpos'];
294 $yeast .= ',"y_zymocide":' . $item['y_zymocide'];
288 $yeast .= ',"y_cost":' . $item['y_cost'] . '}'; 295 $yeast .= ',"y_cost":' . $item['y_cost'] . '}';
289 syslog(LOG_NOTICE, $yeast); 296 //syslog(LOG_NOTICE, $yeast);
290 $yeasts .= $yeast; 297 $yeasts .= $yeast;
291 } 298 }
292 } 299 }
293 $yeasts .= ']'; 300 $yeasts .= ']';
294 $sql .= "', json_yeasts='" . $yeasts; 301 $sql .= "', json_yeasts='" . $yeasts;
516 for ($i = 0; $i < count($yeasts); $i++) { 523 for ($i = 0; $i < count($yeasts); $i++) {
517 $yeasts[$i]['y_inventory'] = 0; // Not in stock 524 $yeasts[$i]['y_inventory'] = 0; // Not in stock
518 $yeasts[$i]['y_avail'] = 0; // Ingredient not in db 525 $yeasts[$i]['y_avail'] = 0; // Ingredient not in db
519 if (! isset($yeasts[$i]['y_tolerance'])) 526 if (! isset($yeasts[$i]['y_tolerance']))
520 $yeasts[$i]['y_tolerance'] = 0; 527 $yeasts[$i]['y_tolerance'] = 0;
521 $sql2 = "SELECT inventory,tolerance FROM inventory_yeasts "; 528 $sql2 = "SELECT inventory,tolerance,sta1,bacteria,harvest_top,harvest_time,pitch_temperature,pofpos,zymocide ";
529 $sql2 .= "FROM inventory_yeasts ";
522 $sql2 .= "WHERE name='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_name'])."' AND"; 530 $sql2 .= "WHERE name='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_name'])."' AND";
523 $sql2 .= " form='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_form'])."' AND"; 531 $sql2 .= " form='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_form'])."' AND";
524 $sql2 .= " laboratory='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_laboratory'])."' AND"; 532 $sql2 .= " laboratory='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_laboratory'])."' AND";
525 $sql2 .= " product_id='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_product_id'])."'"; 533 $sql2 .= " product_id='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_product_id'])."'";
526 if ($result2 = mysqli_query($connect, $sql2)) { 534 if ($result2 = mysqli_query($connect, $sql2)) {
527 if ($obj = mysqli_fetch_object($result2)) { 535 if ($obj = mysqli_fetch_object($result2)) {
528 $yeasts[$i]['y_inventory'] = floatval($obj->inventory); 536 $yeasts[$i]['y_inventory'] = floatval($obj->inventory);
529 $yeasts[$i]['y_avail'] = 1; 537 $yeasts[$i]['y_avail'] = 1;
530 if ($yeasts[$i]['y_tolerance'] == 0) { 538 if ($yeasts[$i]['y_tolerance'] == 0)
531 $yeasts[$i]['y_tolerance'] = floatval($obj->tolerance); // Upgrade alcohol tolerance 539 $yeasts[$i]['y_tolerance'] = floatval($obj->tolerance); // Upgrade alcohol tolerance
532 } 540 // Upgrade new fields
541 if (! isset($yeasts[$i]['y_sta1']))
542 $yeasts[$i]['y_sta1'] = intval($obj->sta1);
543 if (! isset($yeasts[$i]['y_bacteria']))
544 $yeasts[$i]['y_bacteria'] = intval($obj->bacteria);
545 if (! isset($yeasts[$i]['y_harvest_top']))
546 $yeasts[$i]['y_harvest_top'] = intval($obj->harvest_top);
547 if (! isset($yeasts[$i]['y_harvest_time']))
548 $yeasts[$i]['y_harvest_time'] = intval($obj->harvest_time);
549 if (! isset($yeasts[$i]['y_pitch_temperature']))
550 $yeasts[$i]['y_pitch_temperature'] = floatval($obj->pitch_temperature);
551 if (! isset($yeasts[$i]['y_pofpos']))
552 $yeasts[$i]['y_pofpos'] = intval($obj->pofpos);
553 if (! isset($yeasts[$i]['y_zymocide']))
554 $yeasts[$i]['y_zymocide'] = intval($obj->zymocide);
533 } 555 }
534 mysqli_free_result($result2); 556 mysqli_free_result($result2);
535 } 557 }
536 } 558 }
537 $recipes .= ',"yeasts":' . json_encode($yeasts, JSON_UNESCAPED_UNICODE); 559 $recipes .= ',"yeasts":' . json_encode($yeasts, JSON_UNESCAPED_UNICODE);

mercurial