Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.

Sun, 02 May 2021 22:03:25 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 02 May 2021 22:03:25 +0200
changeset 740
04c0e444e48e
parent 739
bb923d2cbc35
child 741
4ec5de404bc1

Upgrade mash steps when loading a product. Mash steps Brix input doesn't need wort correction. Added measure data input on the checklist for the first mash step.

www/includes/db_product.php file | annotate | diff | comparison | revisions
www/js/prod_edit.js file | annotate | diff | comparison | revisions
www/prod_checklist.php file | annotate | diff | comparison | revisions
--- a/www/includes/db_product.php	Thu Apr 15 13:10:21 2021 +0200
+++ b/www/includes/db_product.php	Sun May 02 22:03:25 2021 +0200
@@ -911,6 +911,7 @@
 		$brew .= ',"divide_part":' . $row['divide_part'];
 
 		if (isset($_GET['record'])) {
+			$mashkg = 0.0;
 			// Append stock information.
 			$fermentables = json_decode($row['json_fermentables'], true);
 			for ($i = 0; $i < count($fermentables); $i++) {
@@ -926,6 +927,9 @@
 					}
 					mysqli_free_result($result2);
 				}
+				if ($fermentables[$i]['f_added'] == 0) {
+					$mashkg += floatval($fermentables[$i]['f_amount']);
+				}
 			}
 			$brew .= ',"fermentables":' . json_encode($fermentables, JSON_UNESCAPED_UNICODE);
 
@@ -1033,14 +1037,40 @@
 				}
 			}
 			$brew .= ',"yeasts":' . json_encode($yeasts, JSON_UNESCAPED_UNICODE);
+
+        		//syslog(LOG_NOTICE, $row['json_mashs']);
+			$mashs = json_decode($row['json_mashs'], true);
+			$mashvol = 0.0;
+			for ($i = 0; $i < count($mashs); $i++) {
+				/* Upgrade missing data */
+				if (($mashs[$i]['step_type'] == 0) && (floatval($mashs[$i]['step_infuse_amount']) > 0))
+					$mashvol += floatval($mashs[$i]['step_infuse_amount']);
+				if (($mashs[$i]['step_type'] == 0) && (! isset($mashs[$i]['step_infuse_temp']))) {
+					if ($i == 0)
+						$mashs[$i]['step_infuse_temp'] = floatval($mashs[$i]['step_temp']) + 0.5;
+					else
+						$mashs[$i]['step_infuse_temp'] = 99.0;
+				}
+				if (! isset($mashs[$i]['step_volume']))
+					$mashs[$i]['step_volume'] = $mashvol;
+				if (! isset($mashs[$i]['step_wg_ratio']))
+					$mashs[$i]['step_wg_ratio'] = round(($mashvol / $mashkg) * 1000000) / 1000000;
+				if (! isset($mashs[$i]['step_ph']))
+					$mashs[$i]['step_ph'] = 0.0;
+				if (! isset($mashs[$i]['step_sg']))
+					$mashs[$i]['step_sg'] = 0.0;
+			}
+			$brew .= ',"mashs":' . json_encode($mashs, JSON_UNESCAPED_UNICODE);
+
 		} else {
 			// Just leave it
 			$brew .= ',"fermentables":' . $row['json_fermentables'];
 			$brew .= ',"hops":' . $row['json_hops'];
 			$brew .= ',"miscs":' . $row['json_miscs'];
 			$brew .= ',"yeasts":' . $row['json_yeasts'];
+			$brew .= ',"mashs":' . $row['json_mashs'];
 		}
-		$brew .= ',"mashs":' . $row['json_mashs'];
+
 		$brew .= '}';
 //		syslog(LOG_NOTICE, $brew);
 		$brews .= $brew;
--- a/www/js/prod_edit.js	Thu Apr 15 13:10:21 2021 +0200
+++ b/www/js/prod_edit.js	Sun May 02 22:03:25 2021 +0200
@@ -1,4 +1,4 @@
-/*****************************************************************************
+6*****************************************************************************
  * Copyright (C) 2018-2021
  *
  * Michiel Broek <mbroek at mbse dot eu>
@@ -1603,17 +1603,17 @@
      row['step_name'] = 'Stap ' + (rowscount + 1);
      if (rowscount > 0) {
       row['step_type'] = 1;
-      row['step_infuse_amount'] = 0;
+      row['step_infuse_amount'] = 0.0;
       row['step_volume'] = mash_infuse;
      } else {
       row['step_type'] = 0;
-      row['step_infuse_amount'] = 15;
+      row['step_infuse_amount'] = 15.0;
       row['step_volume'] = 15;
      }
      row['step_infuse_temp'] = 0;
      row['step_temp'] = 62.0;
      row['step_time'] = 20.0;
-     row['step_wg_ratio'] = 0;
+     row['step_wg_ratio'] = 0.0;
      row['ramp_time'] = 1.0;
      row['end_temp'] = 62.0;
      row['step_ph'] = 0.0;
@@ -5707,9 +5707,9 @@
     infused += parseFloat(row['step_infuse_amount']);
     row['step_volume'] = infused;
     if (mashkg > 0)
-     row['step_wg_ratio'] = Round(parseFloat(mash_infuse / mashkg), 2);
+     row['step_wg_ratio'] = Round(parseFloat(mash_infuse / mashkg), 6);
     else
-     row['step_wg_ratio'] = 0;
+     row['step_wg_ratio'] = 0.0;
     $('#mashGrid').jqxGrid('addrow', null, row);
    }
    calcMash();
@@ -5822,7 +5822,8 @@
  });
  $('#wstep_brix').jqxNumberInput(Spin1dec);
  $('#wstep_brix').on('change', function(event) {
-  var sg = brix_to_sg(parseFloat(event.args.value));
+  /* Use plato_to_sg at this stage */
+  var sg = plato_to_sg(parseFloat(event.args.value));
 console.log('brix: ' + parseFloat(event.args.value) + ' sg: ' + sg);
   if (sg > 1.005) {
    var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow);
--- a/www/prod_checklist.php	Thu Apr 15 13:10:21 2021 +0200
+++ b/www/prod_checklist.php	Sun May 02 22:03:25 2021 +0200
@@ -191,7 +191,7 @@
 							$this->Checkline($s);
 						}
 					}
-					$this->Checkline($item['step_time'].' min. bij '.$item['step_temp'].' '.DEG.'C');
+					$this->CheckInput($item['step_time'].' min. bij '.$item['step_temp'].' '.DEG.'C', 'Brix');
 					$this->CheckInput('pH meten en bijstellen (doel pH beslag: '.sprintf("%.1f",$row['mash_ph']).' pH)', 'pH');
 				} else {
 					if ($item['step_type'] == 0) {	// Infusion

mercurial