www/prod_print.php

changeset 738
11e6bd8d8107
parent 737
3f823bc205ca
child 755
509510586665
--- a/www/prod_print.php	Wed Apr 14 10:49:37 2021 +0200
+++ b/www/prod_print.php	Thu Apr 15 10:57:01 2021 +0200
@@ -38,11 +38,13 @@
 $keg_sugar = '';
 $bottle_sugar_amount = 0;
 $keg_sugar_amount = 0;
+$est_mash_sg = 0;
 
 $divide_parts = $row['divide_parts'];
 $divide_part = $row['divide_part'];
 $divide_factor = floatval($row['divide_factor']);
 
+
 class PDF_MySQL_Table extends FPDF
 {
 	protected $ProcessingTable=false;
@@ -141,6 +143,7 @@
 		global $added;
 		global $fermentabletype;
 		global $graintype;
+		global $est_mash_sg;
 		$vul = $this->w - $this->rMargin - $this->lMargin - 125;
 		$this->Ln();
 		$this->AddCol($vul,'Mout, granen en suikers','L');
@@ -160,6 +163,7 @@
 		$sugarsf = 0;
 		$sugarsm = 0;
 		$mashkg = 0;
+		$s = 0;
 		$this->SetFont('Helvetica','',9);
 		$this->SetFillColor(250, 195, 65);
 		$arr = json_decode($row['json_fermentables'], true);
@@ -198,6 +202,7 @@
 			/* Calculate the amount of sugars */
 			$d = $amount * ($yield / 100) * (1 - $moisture / 100);
 			if ($item['f_added']  == 0) {
+				$s += $d;
 				$d = floatval($row['efficiency']) / 100 * $d;
 				$sugarsm += $d;
 				$mashkg += $amount;
@@ -223,7 +228,9 @@
 			$this->Cell(20,5,sprintf("%.3f",$cost).EURO,0,0,'R',true);
 			$this->Ln();
 		}
-
+		$v = $s / 1.611 + $row['wg_amount'];
+		$s = 1000 * $s / ($v * 10);	//deg. Plato
+		$est_mash_sg = plato_to_sg($s);
 		$row['est_og'] = estimate_sg($sugarsf, floatval($row['batch_size']));
 		$preboil_sg = estimate_sg($sugarsm, floatval($row['boil_size']));
 		$this->SetFillColor(210,245,255);
@@ -692,14 +699,26 @@
                 $this->Ln();
 	}
 
+	function PrintDiff($v1, $v2, $decimals, $un) {
+
+		$val1 = floatval($v1);
+		$val2 = floatval($v2);
+		if ($val2 > $val1)
+			$diff = '+' . number_format($val2 - $val1, $decimals) . $un;
+		else
+			$diff = number_format($val2 - $val1, $decimals) . $un;
+		$this->Cell(30,5,$diff,0,0,'L',true);
+	}
+
 	function Brewday($row) {
 
 		global $my_brix_correction;
 		global $my_grain_absorbtion;
 		global $coolingtype;
 		global $aerationtype;
-
-		if ($this->GetY() > 180)
+		global $est_mash_sg;
+		global $mashtype;
+		if ($this->GetY() > 100)
                         $this->AddPage();
                 else
                         $this->Ln(10);
@@ -716,132 +735,201 @@
 
 		$this->SetFont('Helvetica','',9);
         	$this->SetFillColor(210,245,255);
-
         	$this->SetX($this->TableX);
         	$this->Cell(35,5,'Datum start',0,0,'L',true);
         	$this->Cell(50,5,$row['brew_date_start'],0,0,'L',true);
         	$this->Cell($vul,5,'',0,0,'L',false);
-        	$this->Cell(35,5,'Maisch zuurgraad',0,0,'L',true);
-        	$this->Cell(50,5,sprintf("%.1f", $row['brew_mash_ph']).' pH',0,0,'L',true);
+		$this->Cell(35,5,'Datum eind',0,0,'L',true);
+		$this->Cell(50,5,$row['brew_date_end'],0,0,'L',true);
+		$this->Ln(10);
+
+		$domash = 0;
+		$arr = json_decode($row['json_mashs'], true);
+		foreach($arr as $item) {
+			if ($item['step_sg'] > 1.005)
+				$domash = 1;
+		}
+		if ($domash) {
+			$this->SetX($this->TableX);
+			$this->SetFont('Helvetica','B',9);
+			$this->SetFillColor(175,175,255);
+			$vul = $this->w - $this->rMargin - $this->lMargin - 125;
+			$this->Cell(5, 5, '',0,0,'L',true);
+			$this->Cell($vul,5, 'Maisch stap',0,0,'L',true);
+			$this->Cell(30,5, 'Type',0,0,'L',true);
+			$this->Cell(30,5, 'Temperatuur',0,0,'L',true);
+			$this->Cell(30,5, 'SG',0,0,'L',true);
+			$this->Cell(30,5, 'pH',0,0,'L',true);
+			$this->Ln();
+			$this->SetFont('Helvetica','',9);
+			$this->SetFillColor(210,245,255);
+			$arr = json_decode($row['json_mashs'], true);
+			$step = 0;
+			foreach($arr as $item) {
+				$step++;
+				$this->Cell(5,5,$step,0,0,'L',true);
+				$this->Cell($vul,5,$item['step_name'],0,0,'L',true);
+				$this->Cell(30,5,$mashtype[$item['step_type']],0,0,'L',true);
+				$this->Cell(30,5,sprintf("%.1f",$item['step_temp']).'-'.sprintf("%.1f",$item['end_temp']).DEG.'C',0,0,'L',true);
+				$this->Cell(30,5,sprintf("%.3f",$item['step_sg']),0,0,'L',true);
+				$this->Cell(30,5,sprintf("%.2f",$item['step_ph']),0,0,'L',true);
+				$this->Ln();
+			}
+			$this->Ln();
+		}
+
+		$this->SetX($this->TableX);
+		$this->SetFont('Helvetica','B',9);
+		$this->SetFillColor(175,175,255);
+		$vul = $this->w - $this->rMargin - $this->lMargin - 130;
+		$this->Cell($vul, 5, 'Gegeven',0,0,'L',true);
+		$this->Cell(50, 5, 'Gewenst',0,0,'L',true);
+		$this->Cell(50, 5, 'Werkelijk',0,0,'L',true);
+		$this->Cell(30, 5, 'Verschil',0,0,'L',true);
+		$this->Ln();
+
+		$this->SetX($this->TableX);
+		$this->SetFont('Helvetica','',9);
+                $this->SetFillColor(210,245,255);
+        	$this->Cell($vul,5,'Maisch zuurgraad',0,0,'L',true);
+		$this->Cell(50,5,sprintf("%.1f", $row['mash_ph']).' pH',0,0,'L',true);
+        	$this->Cell(50,5,sprintf("%.2f", $row['brew_mash_ph']).' pH',0,0,'L',true);
+		$this->PrintDiff($row['mash_ph'], $row['brew_mash_ph'], 2, ' pH');
         	$this->Ln();
 
 		$this->SetX($this->TableX);
-                $this->Cell(35,5,'Datum eind',0,0,'L',true);
-                $this->Cell(50,5,$row['brew_date_end'],0,0,'L',true);
-                $this->Cell($vul,5,'',0,0,'L',false);
-                $this->Cell(35,5,'Maisch densiteit',0,0,'L',true);
+                $this->Cell($vul,5,'Maisch densiteit',0,0,'L',true);
+		$this->Cell(50,5,density_str(floatval($est_mash_sg)),0,0,'L',true);
                 $this->Cell(50,5,density_str(floatval($row['brew_mash_sg'])),0,0,'L',true);
-                $this->Ln();
-
-		$this->SetX($this->TableX);
-                $this->Cell(85+$vul,5,'',0,0,'L',false);
-                $this->Cell(35,5,'Maisch rendement',0,0,'L',true);
-                $this->Cell(50,5,sprintf("%.1f", floatval($row['brew_mash_efficiency']))."%",0,0,'L',true);
-                $this->Ln(7);
-
-		$this->SetX($this->TableX);
-                $this->Cell(35,5,'Voor koken zuurgraad',0,0,'L',true);
-                $this->Cell(50,5,sprintf("%.1f", $row['brew_preboil_ph'])." pH",0,0,'L',true);
-                $this->Cell($vul,5,'',0,0,'L',false);
-                $this->Cell(35,5,'Na koken zuurgraad',0,0,'L',true);
-                $this->Cell(50,5,sprintf("%.1f", $row['brew_aboil_ph'])." pH",0,0,'L',true);
+		$this->PrintDiff($est_mash_sg, $row['brew_mash_sg'], 3, ' SG');
                 $this->Ln();
 
 		$this->SetX($this->TableX);
-                $this->Cell(35,5,'Voor koken densiteit',0,0,'L',true);
-                $this->Cell(50,5,density_str(floatval($row['brew_preboil_sg'])),0,0,'L',true);
-                $this->Cell($vul,5,'',0,0,'L',false);
-                $this->Cell(35,5,'Na koken densiteit',0,0,'L',true);
-                $this->Cell(50,5,density_str(floatval($row['brew_aboil_sg'])),0,0,'L',true);
-                $this->Ln();
-
-		$this->SetX($this->TableX);
-                $this->Cell(35,5,'Voor koken volume',0,0,'L',true);
-                $this->Cell(50,5,sprintf("%.1f", $row['brew_preboil_volume'])." liter",0,0,'L',true);
-                $this->Cell($vul,5,'',0,0,'L',false);
-                $this->Cell(35,5,'Na koken volume',0,0,'L',true);
-                $this->Cell(50,5,sprintf("%.1f", $row['brew_aboil_volume'])." liter",0,0,'L',true);
-                $this->Ln();
-
-		$this->SetX($this->TableX);
-                $this->Cell(35,5,'Voor koken rendement',0,0,'L',true);
-                $this->Cell(50,5,sprintf("%.1f", floatval($row['brew_preboil_efficiency']))."%",0,0,'L',true);
-                $this->Cell($vul,5,'',0,0,'L',false);
-                $this->Cell(35,5,'Na koken rendement',0,0,'L',true);
-                $this->Cell(50,5,sprintf("%.1f", floatval($row['brew_aboil_efficiency']))."%",0,0,'L',true);
-                $this->Ln(7);
-
-		$this->SetX($this->TableX);
-                $this->Cell(35,5,'Spoelwater temperatuur',0,0,'L',true);
-                $this->Cell(50,5,sprintf("%.1f", $row['sparge_temp']).DEG.'C',0,0,'L',true);
-                $this->Cell($vul,5,'',0,0,'L',false);
-                $this->Cell(35,5,'Koel methode',0,0,'L',true);
-                $this->Cell(50,5,$coolingtype[$row['brew_cooling_method']],0,0,'L',true);
+                $this->Cell($vul,5,'Maisch rendement',0,0,'L',true);
+                $this->Cell(50,5,'100.0%',0,0,'L',true);
+                $this->Cell(50,5,sprintf("%.1f", floatval($row['brew_mash_efficiency']))."%",0,0,'L',true);
+		$this->PrintDiff(100.0, $row['brew_mash_efficiency'], 1, '%');
                 $this->Ln();
 
 		$this->SetX($this->TableX);
-                $this->Cell(35,5,'Spoelwater geschat',0,0,'L',true);
-                $this->Cell(50,5,sprintf("%.1f", floatval($row['brew_sparge_est'])).' liter',0,0,'L',true);
-                $this->Cell($vul,5,'',0,0,'L',false);
-                $this->Cell(35,5,'Koel temperatuur',0,0,'L',true);
-                $this->Cell(50,5,sprintf("%.1f", floatval($row['brew_cooling_to'])).DEG.'C',0,0,'L',true);
+		$this->Cell($vul,5,'Spoelwater zuurgraad',0,0,'L',true);
+		$this->Cell(50,5,sprintf("%.1f", $row['sparge_ph']).' pH',0,0,'L',true);
+		$this->Cell(50,5,sprintf("%.2f", $row['brew_sparge_ph']).' pH',0,0,'L',true);
+		$this->PrintDiff($row['sparge_ph'], $row['brew_sparge_ph'], 2, ' pH');
+		$this->Ln(7);
+
+		$this->SetX($this->TableX);
+                $this->Cell($vul,5,'Voor koken zuurgraad',0,0,'L',true);
+		$this->Cell(50,5,'',0,0,'L',true);
+                $this->Cell(50,5,sprintf("%.2f", $row['brew_preboil_ph'])." pH",0,0,'L',true);
+		$this->Cell(30,5,'',0,0,'L',true);
+		$this->Ln();
+
+		$this->SetX($this->TableX);
+		$this->Cell($vul,5,'Voor koken densiteit',0,0,'L',true);
+		$this->Cell(50,5,'',0,0,'L',true);
+		$this->Cell(50,5,density_str(floatval($row['brew_preboil_sg'])),0,0,'L',true);
+		$this->Cell(30,5,'',0,0,'L',true);
+		$this->Ln();
+
+		$this->SetX($this->TableX);
+		$this->Cell($vul,5,'Voor koken volume',0,0,'L',true);
+		$this->Cell(50,5,sprintf("%.1f", $row['boil_size'] * 1.04)." liter",0,0,'L',true);
+		$this->Cell(50,5,sprintf("%.1f", $row['brew_preboil_volume'])." liter",0,0,'L',true);
+		$this->PrintDiff($row['boil_size'] * 1.04, $row['brew_preboil_volume'], 1, ' liter');
+		$this->Ln();
+
+		$this->SetX($this->TableX);
+		$this->Cell($vul,5,'Voor koken rendement',0,0,'L',true);
+		$this->Cell(50,5,sprintf("%.1f", floatval($row['efficiency']))."%",0,0,'L',true);
+		$this->Cell(50,5,sprintf("%.1f", floatval($row['brew_preboil_efficiency']))."%",0,0,'L',true);
+		$this->PrintDiff($row['efficiency'], $row['brew_preboil_efficiency'], 1, '%');
+		$this->Ln(7);
+
+		$this->SetX($this->TableX);
+                $this->Cell($vul,5,'Na koken zuurgraad',0,0,'L',true);
+		$this->Cell(50,5,'',0,0,'L',true);
+                $this->Cell(50,5,sprintf("%.2f", $row['brew_aboil_ph'])." pH",0,0,'L',true);
+		$this->Cell(30,5,'',0,0,'L',true);
                 $this->Ln();
 
 		$this->SetX($this->TableX);
-                $this->Cell(35,5,'Spoelwater zuurgraad',0,0,'L',true);
-                $this->Cell(50,5,sprintf("%.1f", $row['brew_sparge_ph']).' pH',0,0,'L',true);
-                $this->Cell($vul,5,'',0,0,'L',false);
-                $this->Cell(35,5,'Koel tijdsduur',0,0,'L',true);
-                $this->Cell(50,5,sprintf("%.0f", floatval($row['brew_cooling_time'])).' minuten',0,0,'L',true);
-                $this->Ln(7);
+                $this->Cell($vul,5,'Na koken densiteit',0,0,'L',true);
+		$this->Cell(50,5,density_str(floatval($row['est_og'])),0,0,'L',true);
+                $this->Cell(50,5,density_str(floatval($row['brew_aboil_sg'])),0,0,'L',true);
+		$this->PrintDiff($row['est_og'], $row['brew_aboil_sg'], 3, ' SG');
+                $this->Ln();
 
 		$this->SetX($this->TableX);
-                $this->Cell(35,5,'Whirlpool +85'.DEG.'C',0,0,'L',true);
-                $this->Cell(50,5,sprintf("%.0f", $row['brew_whirlpool9']).' minuten',0,0,'L',true);
-                $this->Cell($vul,5,'',0,0,'L',false);
-                $this->Cell(35,5,'Koeler & trub verlies',0,0,'L',true);
-                $this->Cell(50,5,sprintf("%.1f", floatval($row['brew_fermenter_tcloss'])).' liter',0,0,'L',true);
+                $this->Cell($vul,5,'Na koken volume',0,0,'L',true);
+		$this->Cell(50,5,sprintf("%.1f", $row['batch_size'] * 1.04)." liter",0,0,'L',true);
+                $this->Cell(50,5,sprintf("%.1f", $row['brew_aboil_volume'])." liter",0,0,'L',true);
+		$this->PrintDiff($row['batch_size'] * 1.04, $row['brew_aboil_volume'], 1, ' liter');
                 $this->Ln();
 
 		$this->SetX($this->TableX);
-                $this->Cell(35,5,'Whirlpool 72..79'.DEG.'C',0,0,'L',true);
-                $this->Cell(50,5,sprintf("%.0f", $row['brew_whirlpool7']).' minuten',0,0,'L',true);
-                $this->Cell($vul,5,'',0,0,'L',false);
-                $this->Cell(35,5,'Extra water in gistvat',0,0,'L',true);
-                $this->Cell(50,5,sprintf("%.1f", floatval($row['brew_fermenter_extrawater'])).' liter',0,0,'L',true);
-                $this->Ln();
-
-		$this->SetX($this->TableX);
-                $this->Cell(35,5,'Whirlpool 60..66'.DEG.'C',0,0,'L',true);
-                $this->Cell(50,5,sprintf("%.0f", $row['brew_whirlpool6']).' minuten',0,0,'L',true);
-                $this->Cell($vul,5,'',0,0,'L',false);
-                $this->Cell(35,5,'Volume naar gistvat',0,0,'L',true);
-                $this->Cell(50,5,sprintf("%.1f", floatval($row['brew_fermenter_volume'])).' liter',0,0,'L',true);
-                $this->Ln();
-
-		$this->SetX($this->TableX);
-                $this->Cell(35,5,'Whirlpool koud',0,0,'L',true);
-                $this->Cell(50,5,sprintf("%.0f", $row['brew_whirlpool2']).' minuten',0,0,'L',true);
-                $this->Cell($vul,5,'',0,0,'L',false);
-                $this->Cell(35,5,'Densiteit in gistvat',0,0,'L',true);
-                $this->Cell(50,5,density_str(floatval($row['brew_fermenter_sg'])),0,0,'L',true);
+                $this->Cell($vul,5,'Na koken rendement',0,0,'L',true);
+		$this->Cell(50,5,sprintf("%.1f", floatval($row['efficiency']))."%",0,0,'L',true);
+		$this->Cell(50,5,sprintf("%.1f", floatval($row['brew_aboil_efficiency']))."%",0,0,'L',true);
+		$this->PrintDiff($row['efficiency'], $row['brew_aboil_efficiency'], 1, '%');
                 $this->Ln(7);
 
 		$this->SetX($this->TableX);
-                $this->Cell(35,5,'Beluchten met',0,0,'L',true);
-                $this->Cell(50,5,$aerationtype[$row['brew_aeration_type']],0,0,'L',true);
-                $this->Cell($vul,5,'',0,0,'L',false);
-                $this->Cell(35,5,'Kleur in gistvat',0,0,'L',true);
-                $this->Cell(50,5,sprintf("%.0f", floatval($row['brew_fermenter_color'])).' EBC',0,0,'L',true);
-                $this->Ln();
+		$this->Cell($vul,5,'Koeler & trub verlies',0,0,'L',true);
+		$this->Cell(50,5,sprintf("%.1f", floatval($row['eq_trub_chiller_loss'])).' liter',0,0,'L',true);
+		$this->Cell(50,5,sprintf("%.1f", floatval($row['brew_fermenter_tcloss'])).' liter',0,0,'L',true);
+		$this->PrintDiff($row['eq_trub_chiller_loss'], $row['brew_fermenter_tcloss'], 1, ' lter');
+		$this->Ln();
+
+		$this->SetX($this->TableX);
+		$this->Cell($vul,5,'Extra water in gistvat',0,0,'L',true);
+		$this->Cell(50,5,sprintf("%.1f", floatval($row['eq_top_up_water'])).' liter',0,0,'L',true);
+		$this->Cell(50,5,sprintf("%.1f", floatval($row['brew_fermenter_extrawater'])).' liter',0,0,'L',true);
+		$this->PrintDiff($row['eq_top_up_water'], $row['brew_fermenter_extrawater'], 1, ' liter');
+		$this->Ln();
+
+		$this->SetX($this->TableX);
+		$this->Cell($vul,5,'Volume naar gistvat',0,0,'L',true);
+		$this->Cell(50,5,sprintf("%.1f", floatval($row['batch_size']) - floatval($row['eq_trub_chiller_loss'])).' liter',0,0,'L',true);
+		$this->Cell(50,5,sprintf("%.1f", floatval($row['brew_fermenter_volume'])).' liter',0,0,'L',true);
+		$this->PrintDiff(floatval($row['batch_size']) - floatval($row['eq_trub_chiller_loss']), $row['brew_fermenter_volume'], 1, ' liter');
+		$this->Ln();
+
+		$this->SetX($this->TableX);
+		$this->Cell($vul,5,'Densiteit in gistvat',0,0,'L',true);
+		$this->Cell(50,5,density_str(floatval($row['est_og'])),0,0,'L',true);
+		$this->Cell(50,5,density_str(floatval($row['brew_fermenter_sg'])),0,0,'L',true);
+		$this->PrintDiff($row['est_og'], $row['brew_fermenter_sg'], 3, ' SG');
+		$this->Ln();
 
 		$this->SetX($this->TableX);
-                $this->Cell(35,5,'Beluchten snelheid/tijd',0,0,'L',true);
-                $this->Cell(50,5,$row['brew_aeration_speed'].'/'.$row['brew_aeration_time'],0,0,'L',true);
-                $this->Cell($vul,5,'',0,0,'L',false);
-                $this->Cell(35,5,'Bitterheid in gistvat',0,0,'L',true);
-                $this->Cell(50,5,sprintf("%.0f", floatval($row['brew_fermenter_ibu'])).' IBU',0,0,'L',true);
-                $this->Ln();
+		$this->Cell($vul,5,'Kleur in gistvat',0,0,'L',true);
+		$this->Cell(50,5,sprintf("%.0f", floatval($row['est_color'])).' EBC',0,0,'L',true);
+		$this->Cell(50,5,sprintf("%.0f", floatval($row['brew_fermenter_color'])).' EBC',0,0,'L',true);
+		$this->PrintDiff($row['est_color'], $row['brew_fermenter_color'], 0, ' EBC');
+		$this->Ln();
+
+		$this->SetX($this->TableX);
+		$this->Cell($vul,5,'Bitterheid in gistvat',0,0,'L',true);
+		$this->Cell(50,5,sprintf("%.0f", floatval($row['est_ibu'])).' IBU',0,0,'L',true);
+		$this->Cell(50,5,sprintf("%.0f", floatval($row['brew_fermenter_ibu'])).' IBU',0,0,'L',true);
+		$this->PrintDiff($row['est_ibu'], $row['brew_fermenter_ibu'], 0, ' IBU');
+		$this->Ln(7);
+
+		$this->SetX($this->TableX);
+		$this->Cell($vul,5,'Koelen methode',0,0,'L',true);
+		$this->Cell(50,5,$coolingtype[$row['brew_cooling_method']],0,0,'L',true);
+		$this->Ln();
+
+		$this->SetX($this->TableX);
+		$this->Cell($vul,5,'Koelen temperatuur',0,0,'L',true);
+		$this->Cell(50,5,sprintf("%.1f", floatval($row['brew_cooling_to'])).DEG.'C',0,0,'L',true);
+		$this->Ln();
+
+		$this->SetX($this->TableX);
+		$this->Cell($vul,5,'Koelen tijdsduur',0,0,'L',true);
+		$this->Cell(50,5,sprintf("%.0f", floatval($row['brew_cooling_time'])).' minuten',0,0,'L',true);
+		$this->Ln(7);
 	}
 
 	function Fermentation($row) {

mercurial