www/includes/db_product.php

changeset 667
1246550451ca
parent 617
f962f1e5936e
child 697
367ae7ff52f0
--- a/www/includes/db_product.php	Fri May 01 21:37:23 2020 +0200
+++ b/www/includes/db_product.php	Wed May 06 14:14:14 2020 +0200
@@ -464,28 +464,35 @@
 	$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'] . '}';
-			//syslog(LOG_NOTICE, $mash);
+			$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 .= '}';
+			syslog(LOG_NOTICE, $mash);
 			$mashs .= $mash;
 		}
 	}
@@ -1003,6 +1010,7 @@
 			$brew .= ',"miscs":' . $row['json_miscs'];
 			$brew .= ',"yeasts":' . $row['json_yeasts'];
 		}
+syslog(LOG_NOTICE, $row['json_mashs']);
 		$brew .= ',"mashs":' . $row['json_mashs'];
 		$brew .= '}';
 //		syslog(LOG_NOTICE, $brew);

mercurial