Better stage detection during product import from brouwhulp. Added tooltips for treated water.

Mon, 24 Dec 2018 15:52:11 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 24 Dec 2018 15:52:11 +0100
changeset 150
159d7a89fcef
parent 149
ff45488d480e
child 151
2c9cfe2f0860

Better stage detection during product import from brouwhulp. Added tooltips for treated water.

www/import/from_brouwhulp.php file | annotate | diff | comparison | revisions
www/js/prod_inprod.js file | annotate | diff | comparison | revisions
www/js/rec_edit.js file | annotate | diff | comparison | revisions
--- a/www/import/from_brouwhulp.php	Sun Dec 23 20:13:36 2018 +0100
+++ b/www/import/from_brouwhulp.php	Mon Dec 24 15:52:11 2018 +0100
@@ -995,6 +995,7 @@
                 $pSugar = 0;
                 $svg = 77;
 		$colorw = 0;
+		$stageno = 0;
 		$stage = "Plan";	// Default value.
                 $uuid = str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid'));
 
@@ -1239,11 +1240,13 @@
 		if (($recipe->DATE) && (! $recipe->TIME_STARTED) && (! $recipe->TIME_ENDED)) {
 			/* We have a plan date but haven't brewed yet, use current date */
 			$psql .= "', birth='" . date("Y-m-d");
+			$stageno= 1;
 			$stage = "Wait";
 		}
 
 		if (($recipe->DATE) && ($recipe->TIME_STARTED) && ($recipe->TIME_ENDED)) {
 			/* We have brew data */
+			$stageno = 3;
 			$stage = "Primary";	// Need to think about during a brew...
 			$brewdate = substr($recipe->DATE, 6, 4).substr($recipe->DATE,2,4).substr($recipe->DATE,0,2);
 			$psql .= "', birth='" . $brewdate;
@@ -1292,7 +1295,7 @@
 			$psql .= "', brew_date_end='" . $date_end;
 		}
 
-		if ($recipe->PRIMARY_AGE) {
+		if ($recipe->PRIMARY_AGE && ($stageno >= 3)) {
 			/* PRIMARY_TEMP is the average of START_TEMP_PRIMARY MAX_TEMP_PRIMARY END_TEMP_PRIMARY */
 			$pdate = new DateTime($brewdate);
 			$pdate->modify("+".floatval($recipe->PRIMARY_AGE)." days");
@@ -1301,38 +1304,46 @@
 			$psql .= "', primary_end_temp='" . floatval($recipe->END_TEMP_PRIMARY);
 			$psql .= "', primary_end_sg='" . floatval($recipe->SG_END_PRIMARY);
 			$psql .= "', primary_end_date='" . $pdate->format("Y-m-d");
+			$stageno = 4;
 			$stage = "Secondary";
 
-			if ($recipe->SECONDARY_AGE) {
+			if ($recipe->SECONDARY_AGE && ($stageno >= 4)) {
 				$sdate = new DateTime($brewdate);
 				$sdate->modify("+".floatval($recipe->SECONDARY_AGE)." days");
 				$psql .= "', secondary_temp='" . floatval($recipe->SECONDARY_TEMP);
 				$psql .= "', secondary_end_date='" . $sdate->format("Y-m-d");
+				$stageno = 5;
 				$stage = "Tertiary";
 
-				if ($recipe->TERTIARY_TEMP) {
+				if ($recipe->TERTIARY_TEMP && ($stageno >= 5)) {
 					$psql .= "', tertiary_temp='" . floatval($recipe->TERTIARY_TEMP);
 				}
 			}
 		}
 
 		if ($recipe->DATE_BOTTLING && ($recipe->AMOUNT_BOTTLING || $recipe->AMOUNT_KEGGED) &&
-		    ($recipe->AMOUNT_PRIMING || $recipe->AMOUNT_PRIMING_KEGS)) {
+		    ($recipe->AMOUNT_PRIMING || $recipe->AMOUNT_PRIMING_KEGS) && ($stageno >= 5)) {
 			$bdate = substr($recipe->DATE_BOTTLING, 6, 4).substr($recipe->DATE_BOTTLING,2,4).substr($recipe->DATE_BOTTLING,0,2);
 			$psql .= "', package_date='" . $bdate;
 			$stage = "Package";
+			$stageno = 6;
 			$dStart = new DateTime($bdate);
 			$dEnd  = new DateTime('');
 			$dDiff = $dStart->diff($dEnd);
 			$age = floatval($dDiff->days);
-			if ($age == 0)			// Package day
+			if ($age == 0) {		// Package day
 				$stage = "Package";
-			else if ($age < 14)		// Carbonation period
+				$stageno = 6;
+			} else if ($age < 14) {		// Carbonation period
 				$stage = "Carbonation";
-			else if ($age < 42)		// Mature, fixed 6 weeks
+				$stageno = 7;
+			} else if ($age < 42) {		// Mature, fixed 6 weeks
 				$stage = "Mature";
-			else				// Ready for tasting.
+				$stageno = 8;
+			} else {			// Ready for tasting.
 				$stage = "Taste";
+				$stageno = 9;
+			}
 
 			if ($recipe->AMOUNT_BOTTLING && $recipe->AMOUNT_PRIMING) {
 				$psql .= "', bottle_amount='" . floatval($recipe->AMOUNT_BOTTLING);
@@ -1353,8 +1364,9 @@
 			}
 		}
 
-		if ($recipe->TASTE_NOTES && $recipe->TASTING_RATE && $recipe->TASTE_DATE) {
+		if ($recipe->TASTE_NOTES && $recipe->TASTING_RATE && $recipe->TASTE_DATE && ($stageno >= 9)) {
 			$stage = "Ready";	// Ready if tasted.
+			$stageno = 10;
 			$psql .= "', taste_notes='" . mysqli_real_escape_string($db, $recipe->TASTE_NOTES);
 			$psql .= "', taste_rate='" . floatval($recipe->TASTING_RATE);
 			$tdate = substr($recipe->TASTE_DATE, 6, 4).substr($recipe->TASTE_DATE,2,4).substr($recipe->TASTE_DATE,0,2);
@@ -1373,6 +1385,7 @@
 			$psql .= "', plocked='1";
 			$rsql .= "', locked='1";
 			$stage = "Closed";
+			$stageno = 11;
 		} else {
 			$psql .= "', plocked='0";
 			$rsql .= "', locked='0";
--- a/www/js/prod_inprod.js	Sun Dec 23 20:13:36 2018 +0100
+++ b/www/js/prod_inprod.js	Mon Dec 24 15:52:11 2018 +0100
@@ -62,7 +62,7 @@
 			{ text: 'Datum', datafield: 'birth', width: 120 },
 			{ text: 'Code', datafield: 'code', width: 120 },
 			{ text: 'Naam', datafield: 'pname' },
-			{ text: 'Fase', datafield: 'stage', width: 150 },
+			{ text: 'Fase', datafield: 'stage', width: 130 },
 			{ text: 'Wijzig', datafield: 'Edit', width: 120, align: 'center', columntype: 'button', cellsrenderer: function () {
 				return "Wijzig";
 				}, buttonclick: function (row) {
--- a/www/js/rec_edit.js	Sun Dec 23 20:13:36 2018 +0100
+++ b/www/js/rec_edit.js	Mon Dec 24 15:52:11 2018 +0100
@@ -721,6 +721,12 @@
 	$("#wa_nacl").jqxTooltip({ content: 'Keukenzout. Voor het maken van een ander waterprofiel. Voegt natrium en chloride toe. Voor het accentueren van zoetheid. Bij hoge dosering wordt het bier ziltig.'});
 	$("#w2_amount").jqxTooltip({ content: 'De verdeling van het hoofd en meng water. Het totale maisch water volume blijft gelijk.'});
 
+	$("#wb_calcium").jqxTooltip({ content: 'De ideale hoeveelheid Calcium is tussen 40 en 150.'});
+	$("#wb_magnesium").jqxTooltip({ content: 'De ideale hoeveelheid Magnesium is lager dan 30.'});
+	$("#wb_sodium").jqxTooltip({ content: 'De ideale hoeveelheid Natrium is lager dan 150.'});
+	$("#wb_chloride").jqxTooltip({ content: 'De ideale hoeveelheid Chloride is lager dan 100.'});
+	$("#wb_sulfate").jqxTooltip({ content: 'De ideale hoeveelheid Sulfaat is lager dan 350.'});
+
 	// prepare the data
 	var source = {
 		datatype: "json",

mercurial