www/includes/db_product.php

changeset 554
c62ff53cfc3d
parent 533
be8691b7d634
child 565
dfc850e6ee1f
equal deleted inserted replaced
553:481dbe0af222 554:c62ff53cfc3d
435 $yeast .= ',"y_attenuation":' . $item['y_attenuation']; 435 $yeast .= ',"y_attenuation":' . $item['y_attenuation'];
436 $yeast .= ',"y_cells":' . $item['y_cells']; 436 $yeast .= ',"y_cells":' . $item['y_cells'];
437 $yeast .= ',"y_tolerance":' . $item['y_tolerance']; 437 $yeast .= ',"y_tolerance":' . $item['y_tolerance'];
438 $yeast .= ',"y_inventory":' . $item['y_inventory']; 438 $yeast .= ',"y_inventory":' . $item['y_inventory'];
439 $yeast .= ',"y_use":' . $item['y_use']; 439 $yeast .= ',"y_use":' . $item['y_use'];
440 $yeast .= ',"y_sta1":' . $item['y_sta1'];
441 $yeast .= ',"y_bacteria":' . $item['y_bacteria'];
442 $yeast .= ',"y_harvest_top":' . $item['y_harvest_top'];
443 $yeast .= ',"y_harvest_time":' . $item['y_harvest_time'];
444 $yeast .= ',"y_pitch_temperature":' . $item['y_pitch_temperature'];
445 $yeast .= ',"y_pofpos":' . $item['y_pofpos'];
446 $yeast .= ',"y_zymocide":' . $item['y_zymocide'];
440 $yeast .= ',"y_cost":' . $item['y_cost'] . '}'; 447 $yeast .= ',"y_cost":' . $item['y_cost'] . '}';
441 //syslog(LOG_NOTICE, $yeast); 448 //syslog(LOG_NOTICE, $yeast);
442 $yeasts .= $yeast; 449 $yeasts .= $yeast;
443 } 450 }
444 } 451 }
929 for ($i = 0; $i < count($yeasts); $i++) { 936 for ($i = 0; $i < count($yeasts); $i++) {
930 $yeasts[$i]['y_inventory'] = 0; // Not in stock 937 $yeasts[$i]['y_inventory'] = 0; // Not in stock
931 $yeasts[$i]['y_avail'] = 0; // Ingredient not in db 938 $yeasts[$i]['y_avail'] = 0; // Ingredient not in db
932 if (! isset($yeasts[$i]['y_tolerance'])) 939 if (! isset($yeasts[$i]['y_tolerance']))
933 $yeasts[$i]['y_tolerance'] = 0; 940 $yeasts[$i]['y_tolerance'] = 0;
934 $sql2 = "SELECT inventory,tolerance FROM inventory_yeasts "; 941 $sql2 = "SELECT inventory,tolerance,sta1,bacteria,harvest_top,harvest_time,pitch_temperature,pofpos,zymocide ";
942 $sql2 .= "FROM inventory_yeasts ";
935 $sql2 .= "WHERE name='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_name'])."' AND"; 943 $sql2 .= "WHERE name='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_name'])."' AND";
936 $sql2 .= " form='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_form'])."' AND"; 944 $sql2 .= " form='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_form'])."' AND";
937 $sql2 .= " laboratory='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_laboratory'])."' AND"; 945 $sql2 .= " laboratory='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_laboratory'])."' AND";
938 $sql2 .= " product_id='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_product_id'])."'"; 946 $sql2 .= " product_id='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_product_id'])."'";
939 if ($result2 = mysqli_query($connect, $sql2)) { 947 if ($result2 = mysqli_query($connect, $sql2)) {
940 if ($obj = mysqli_fetch_object($result2)) { 948 if ($obj = mysqli_fetch_object($result2)) {
941 $yeasts[$i]['y_inventory'] = floatval($obj->inventory); 949 $yeasts[$i]['y_inventory'] = floatval($obj->inventory);
942 $yeasts[$i]['y_avail'] = 1; 950 $yeasts[$i]['y_avail'] = 1;
943 if ($yeasts[$i]['y_tolerance'] == 0) { 951 if ($yeasts[$i]['y_tolerance'] == 0)
944 $yeasts[$i]['y_tolerance'] = floatval($obj->tolerance); // Upgrade alcohol tolerance 952 $yeasts[$i]['y_tolerance'] = floatval($obj->tolerance); // Upgrade alcohol tolerance
945 } 953 // Upgrade new fields
954 if (! isset($yeasts[$i]['y_sta1']))
955 $yeasts[$i]['y_sta1'] = intval($obj->sta1);
956 if (! isset($yeasts[$i]['y_bacteria']))
957 $yeasts[$i]['y_bacteria'] = intval($obj->bacteria);
958 if (! isset($yeasts[$i]['y_harvest_top']))
959 $yeasts[$i]['y_harvest_top'] = intval($obj->harvest_top);
960 if (! isset($yeasts[$i]['y_harvest_time']))
961 $yeasts[$i]['y_harvest_time'] = intval($obj->harvest_time);
962 if (! isset($yeasts[$i]['y_pitch_temperature']))
963 $yeasts[$i]['y_pitch_temperature'] = floatval($obj->pitch_temperature);
964 if (! isset($yeasts[$i]['y_pofpos']))
965 $yeasts[$i]['y_pofpos'] = intval($obj->pofpos);
966 if (! isset($yeasts[$i]['y_zymocide']))
967 $yeasts[$i]['y_zymocide'] = intval($obj->zymocide);
946 } 968 }
947 mysqli_free_result($result2); 969 mysqli_free_result($result2);
948 } 970 }
949 } 971 }
950 $brew .= ',"yeasts":' . json_encode($yeasts, JSON_UNESCAPED_UNICODE); 972 $brew .= ',"yeasts":' . json_encode($yeasts, JSON_UNESCAPED_UNICODE);

mercurial