www/includes/db_recipes.php

changeset 228
98536f6539ee
parent 226
40e68b18b50d
child 233
14a84d42031d
--- a/www/includes/db_recipes.php	Fri Feb 01 11:58:38 2019 +0100
+++ b/www/includes/db_recipes.php	Fri Feb 01 15:30:33 2019 +0100
@@ -227,16 +227,30 @@
 	$yeasts .= ']';
 	$sql .= "', json_yeasts='" . $yeasts;
 
+	$mashs = '[';
+	$comma = FALSE;
 	if (isset($_POST['mashs'])) {
 		$array = $_POST['mashs'];
-		foreach($array as $key => $item){
-			foreach ($disallowed as $disallowed_key) {
-				unset($array[$key]["$disallowed_key"]);
-			}
+		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_infuse_amount']) && $item['step_infuse_amount'] != "")
+				$mash .= ',"step_infuse_amount":' . $item['step_infuse_amount'];
+			else
+				$mash .= ',"step_infuse_amount":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);
+			$mashs .= $mash;
 		}
-		syslog(LOG_NOTICE, "json_mashs: ".str_replace($rescapers,$rreplacements,json_encode($array)));
-		$sql .= "', json_mashs='" . str_replace($rescapers,$rreplacements,json_encode($array));
 	}
+	$mashs .= ']';
+	$sql .= "', json_mashs='" . $mashs;
 
 	if (isset($_POST['insert'])) {
 		$sql .= "';";

mercurial