www/includes/db_recipes.php

changeset 667
1246550451ca
parent 565
dfc850e6ee1f
child 710
9646123ea063
--- a/www/includes/db_recipes.php	Fri May 01 21:37:23 2020 +0200
+++ b/www/includes/db_recipes.php	Wed May 06 14:14:14 2020 +0200
@@ -304,27 +304,34 @@
 	$comma = FALSE;
 	if (isset($_POST['mashs'])) {
 		$array = $_POST['mashs'];
-		// Sort the array
-                $temp = array();
-                for ($i = 0; $i < count($array); $i++) {
-                        $temp[] = $array[$i]['step_temp'];
-                }
-                array_multisort($temp, SORT_ASC, SORT_NUMERIC, $array);
-                // Write the sorted array.
+                // Write the array and fix missing data.
 		foreach($array as $key => $item) {
 			if ($comma)
 				$mashs .= ',';
 			$comma = TRUE;
 			$mash  = '{"step_name":"' . str_replace($rescapers,$rreplacements,$item['step_name']);
 			$mash .= '","step_type":' . $item['step_type'];
+			if (isset($item['step_volume']) && $item['step_volume'] != "")
+				$mash .= ',"step_volume":' . $item['step_volume'];
+			else
+				$mash .= ',"step_volume":0';
 			if (isset($item['step_infuse_amount']) && $item['step_infuse_amount'] != "")
 				$mash .= ',"step_infuse_amount":' . $item['step_infuse_amount'];
 			else
 				$mash .= ',"step_infuse_amount":0';
+			if (isset($item['step_infuse_temp']) && $item['step_infuse_temp'] != "")
+				$mash .= ',"step_infuse_temp":' . $item['step_infuse_temp'];
+			else
+				$mash .= ',"step_infuse_temp":0';
 			$mash .= ',"step_temp":' . $item['step_temp'];
 			$mash .= ',"step_time":' . $item['step_time'];
 			$mash .= ',"ramp_time":' . $item['ramp_time'];
-			$mash .= ',"end_temp":' . $item['end_temp'] . '}';
+			$mash .= ',"end_temp":' . $item['end_temp'];
+			if (isset($item['step_wg_ratio']) && $item['step_wg_ratio'] != "")
+				$mash .= ',"step_wg_ratio":' . $item['step_wg_ratio'];
+			else
+				$mash .= ',"step_wg_ratio":0';
+			$mash .= '}';
 			$mashs .= $mash;
 			//syslog(LOG_NOTICE, $mash);
 		}

mercurial