Include boil_size field in the recipes table. Calculate pre-boil SG. Use that in the IBU calculation.

Thu, 15 Nov 2018 14:27:37 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 15 Nov 2018 14:27:37 +0100
changeset 94
295c3af2a421
parent 93
357d59d8ec5e
child 95
8dc0a00b1db4

Include boil_size field in the recipes table. Calculate pre-boil SG. Use that in the IBU calculation.

www/import/from_brouwhulp.php file | annotate | diff | comparison | revisions
www/includes/db_recipes.php file | annotate | diff | comparison | revisions
www/includes/formulas.php file | annotate | diff | comparison | revisions
www/js/global.js file | annotate | diff | comparison | revisions
www/rec_print.php file | annotate | diff | comparison | revisions
--- a/www/import/from_brouwhulp.php	Wed Nov 14 20:49:19 2018 +0100
+++ b/www/import/from_brouwhulp.php	Thu Nov 15 14:27:37 2018 +0100
@@ -465,6 +465,7 @@
 		$f_sugars = 0;
 		$efficiency = 75;
 		$batch_size = 20;
+		$boil_size = 22;
 		$pCara = 0;
 		$pSugar = 0;
 		$svg = 77;
@@ -482,6 +483,9 @@
 		if ($recipe->BATCH_SIZE)
 			$batch_size = floatval($recipe->BATCH_SIZE);
 		$sql .= "', batch_size='" . $batch_size;
+		if ($recipe->BOIL_SIZE)
+			$boil_size = floatval($recipe->BOIL_SIZE);
+		$sql .= "', boil_size='" . $boil_size;
 		if ($recipe->BOIL_TIME)
 			$sql .= "', boil_time='" . floatval($recipe->BOIL_TIME);
 		else
--- a/www/includes/db_recipes.php	Wed Nov 14 20:49:19 2018 +0100
+++ b/www/includes/db_recipes.php	Thu Nov 15 14:27:37 2018 +0100
@@ -50,6 +50,7 @@
 	$sql .= "', notes='" . mysqli_real_escape_string($connect, $_POST['notes']);
 	$sql .= "', type='" . $_POST['type'];
 	$sql .= "', batch_size='" . $_POST['batch_size'];
+	$sql .= "', boil_size='" . $_POST['boil_size'];
 	$sql .= "', boil_time='" . $_POST['boil_time'];
 	$sql .= "', efficiency='" . $_POST['efficiency'];
 	$sql .= "', est_og='" . $_POST['est_og'];
@@ -196,6 +197,7 @@
 		$recipes .= '","notes":"' . str_replace($escapers, $replacements, $row['notes']);
 		$recipes .= '","type":"' . $row['type'];
 		$recipes .= '","batch_size":' . floatval($row['batch_size']);
+		$recipes .= ',"boil_size":' . floatval($row['boil_size']);
 		$recipes .= ',"boil_time":' . floatval($row['boil_time']);
 		$recipes .= ',"efficiency":' . floatval($row['efficiency']);
 		$recipes .= ',"est_og":' . floatval($row['est_og']);
--- a/www/includes/formulas.php	Wed Nov 14 20:49:19 2018 +0100
+++ b/www/includes/formulas.php	Thu Nov 15 14:27:37 2018 +0100
@@ -259,6 +259,7 @@
 }
 
 
+
 /*
 
 Brouwhulp data.pas
--- a/www/js/global.js	Wed Nov 14 20:49:19 2018 +0100
+++ b/www/js/global.js	Thu Nov 15 14:27:37 2018 +0100
@@ -96,7 +96,7 @@
 	var pfactor = 1.0;
 	var ibu     = 0;
 
-	console.log("toIBU_Tinseth("+Use+"," + Form + "," + SG + "," + Volume + "," + Amount + "," + Boiltime + "," + Alpha + "," + Method + ")");
+	console.log("toIBU("+Use+"," + Form + "," + SG + "," + Volume + "," + Amount + "," + Boiltime + "," + Alpha + "," + Method + ")");
 
 	if ((Use == "Dry Hop") || (Use == "Dry hop") || (Use == "Whirlpool") || (Use == "Aroma")) {
 		fmoment = 0.0;
--- a/www/rec_print.php	Wed Nov 14 20:49:19 2018 +0100
+++ b/www/rec_print.php	Thu Nov 15 14:27:37 2018 +0100
@@ -29,7 +29,7 @@
 $svg = 77;
 $colorw = 0;
 $total_ibus = 0;
-
+$preboil_sg = 0;
 
 class PDF_MySQL_Table extends FPDF
 {
@@ -96,6 +96,7 @@
 		global $pSugar;
 		global $pCara;
 		global $colorw;
+		global $preboil_sg;
 		$vul = $this->w - $this->rMargin - $this->lMargin - 132;
 		$this->AddCol($vul,'Grondstof','L');
 		$this->AddCol(30,'Leverancier','L');
@@ -156,6 +157,7 @@
 		}
 
 		$row['est_og'] = estimate_og($sugf, floatval($row['batch_size']));
+		$preboil_sg = estimate_og($sugf, floatval($row['boil_size']));
 		$this->SetFillColor(210,245,255);
 		$this->Cell($vul+62,5,'',0,0,'L',false);
 		$this->Cell(20,5,sprintf("%8.3f",$total_fermentables),0,0,'R',true);
@@ -171,6 +173,7 @@
 		global $total_hops;
 		global $total_ibus;
 		global $cost_hops;
+		global $preboil_sg;
 		$vul = $this->w - $this->rMargin - $this->lMargin - 135;
 		$this->AddCol($vul,'Hop','L');
 		$this->AddCol(35,'Land','L');
@@ -210,7 +213,7 @@
 			if ($useat == "Boil") {
 				$moment   = "Kook@".$time;
 			}
-			$ibu = calc_IBU($useat, $form, floatval($row['est_og']), floatval($row['batch_size']), $mass, $time, $alpha, $row['ibu_method']);
+			$ibu = calc_IBU($useat, $form, /*floatval($row['est_og'])*/ $preboil_sg, floatval($row['batch_size']), $mass, $time, $alpha, $row['ibu_method']);
 			$total_ibus += $ibu;
 
 			$this->Cell($vul,5,$name,0,0,'L',true);

mercurial