462 |
462 |
463 $mashs = '['; |
463 $mashs = '['; |
464 $comma = FALSE; |
464 $comma = FALSE; |
465 if (isset($_POST['mashs'])) { |
465 if (isset($_POST['mashs'])) { |
466 $array = $_POST['mashs']; |
466 $array = $_POST['mashs']; |
467 // Sort the array |
467 // Write the array and fix missing data. |
468 $temp = array(); |
|
469 for ($i = 0; $i < count($array); $i++) { |
|
470 $temp[] = $array[$i]['step_temp']; |
|
471 } |
|
472 array_multisort($temp, SORT_ASC, SORT_NUMERIC, $array); |
|
473 // Write the sorted array. |
|
474 foreach($array as $key => $item){ |
468 foreach($array as $key => $item){ |
475 if ($comma) |
469 if ($comma) |
476 $mashs .= ','; |
470 $mashs .= ','; |
477 $comma = TRUE; |
471 $comma = TRUE; |
478 $mash = '{"step_name":"' . str_replace($rescapers,$rreplacements,$item['step_name']); |
472 $mash = '{"step_name":"' . str_replace($rescapers,$rreplacements,$item['step_name']); |
479 $mash .= '","step_type":' . $item['step_type']; |
473 $mash .= '","step_type":' . $item['step_type']; |
|
474 if (isset($item['step_volume']) && $item['step_volume'] != "") |
|
475 $mash .= ',"step_volume":' . $item['step_volume']; |
|
476 else |
|
477 $mash .= ',"step_volume":0'; |
480 if (isset($item['step_infuse_amount']) && $item['step_infuse_amount'] != "") |
478 if (isset($item['step_infuse_amount']) && $item['step_infuse_amount'] != "") |
481 $mash .= ',"step_infuse_amount":' . $item['step_infuse_amount']; |
479 $mash .= ',"step_infuse_amount":' . $item['step_infuse_amount']; |
482 else |
480 else |
483 $mash .= ',"step_infuse_amount":0'; |
481 $mash .= ',"step_infuse_amount":0'; |
|
482 if (isset($item['step_infuse_temp']) && $item['step_infuse_temp'] != "") |
|
483 $mash .= ',"step_infuse_temp":' . $item['step_infuse_temp']; |
|
484 else |
|
485 $mash .= ',"step_infuse_temp":0'; |
484 $mash .= ',"step_temp":' . $item['step_temp']; |
486 $mash .= ',"step_temp":' . $item['step_temp']; |
485 $mash .= ',"step_time":' . $item['step_time']; |
487 $mash .= ',"step_time":' . $item['step_time']; |
486 $mash .= ',"ramp_time":' . $item['ramp_time']; |
488 $mash .= ',"ramp_time":' . $item['ramp_time']; |
487 $mash .= ',"end_temp":' . $item['end_temp'] . '}'; |
489 $mash .= ',"end_temp":' . $item['end_temp']; |
488 //syslog(LOG_NOTICE, $mash); |
490 if (isset($item['step_wg_ratio']) && $item['step_wg_ratio'] != "") |
|
491 $mash .= ',"step_wg_ratio":' . $item['step_wg_ratio']; |
|
492 else |
|
493 $mash .= ',"step_wg_ratio":0'; |
|
494 $mash .= '}'; |
|
495 syslog(LOG_NOTICE, $mash); |
489 $mashs .= $mash; |
496 $mashs .= $mash; |
490 } |
497 } |
491 } |
498 } |
492 $mashs .= ']'; |
499 $mashs .= ']'; |
493 //syslog(LOG_NOTICE, $mashs); |
500 //syslog(LOG_NOTICE, $mashs); |
1001 $brew .= ',"fermentables":' . $row['json_fermentables']; |
1008 $brew .= ',"fermentables":' . $row['json_fermentables']; |
1002 $brew .= ',"hops":' . $row['json_hops']; |
1009 $brew .= ',"hops":' . $row['json_hops']; |
1003 $brew .= ',"miscs":' . $row['json_miscs']; |
1010 $brew .= ',"miscs":' . $row['json_miscs']; |
1004 $brew .= ',"yeasts":' . $row['json_yeasts']; |
1011 $brew .= ',"yeasts":' . $row['json_yeasts']; |
1005 } |
1012 } |
|
1013 syslog(LOG_NOTICE, $row['json_mashs']); |
1006 $brew .= ',"mashs":' . $row['json_mashs']; |
1014 $brew .= ',"mashs":' . $row['json_mashs']; |
1007 $brew .= '}'; |
1015 $brew .= '}'; |
1008 // syslog(LOG_NOTICE, $brew); |
1016 // syslog(LOG_NOTICE, $brew); |
1009 $brews .= $brew; |
1017 $brews .= $brew; |
1010 } |
1018 } |