www/rec_print.php

changeset 85
ca7a37586551
parent 84
3e5e87f1818d
child 86
e977a505ea8c
--- a/www/rec_print.php	Sat Nov 10 20:56:07 2018 +0100
+++ b/www/rec_print.php	Sun Nov 11 16:36:38 2018 +0100
@@ -141,9 +141,10 @@
 		$this->TableHeader();
 		$this->ProcessingTable=true;
 
+		$sugf = 0;
+		$tot = 0;
 		$this->SetFont('Helvetica','',9);
 		$this->SetFillColor(250, 195, 65);
-
 		$arr = json_decode($row['json_fermentables'], true);
 		foreach($arr as $item) { //foreach element in $arr
 			$name     = iconv('UTF-8','windows-1252',$item['f_name']);
@@ -152,11 +153,22 @@
 			$amount   = floatval($item['f_amount']);
 			$costkg   = floatval($item['f_cost']);
 			$yield    = floatval($item['f_yield']);
+			$moisture = floatval($item['f_moisture']);
 			$color    = floatval($item['f_color']);
 			$percent  = floatval($item['f_percentage']);
 			$cost = $amount * $costkg;
 			$cost_fermentables += $cost;
 			$total_fermentables += $amount;
+			/* Calculate the amount of sugars */
+			$d = $amount * ($yield / 100) * (1 - $moisture / 100);
+			if ($added == "Mash")
+				$d = floatval($row['efficiency']) / 100 * $d;
+			$sugf += $d;
+			$tot += $amount;
+			//$plato = 100 * $d / $amount;
+			//$this->Cell(0,5,$tot.' sugf: '.$sugf.' d: '.$d.' pt: '.$plato.' moisture: '.$moisture,0,0,'L',false);
+			//$this->Ln();
+
 			$this->Cell($vul,5,$name,0,0,'L',true);
 			$this->Cell(30,5,$supplier,0,0,'L',true);
 			$this->Cell(15,5,sprintf("%.0f",$color),0,0,'R',true);
@@ -168,8 +180,17 @@
 			$this->Ln();
 		}
 
+		$plato = 100 * $sugf / floatval($row['batch_size']);
+		$sg = plato_to_sg($plato);
+		/* Average loops, HansH 5x. Brouwhulp 20x, about 10x is enough so keep 20. */ 
+		for ($i = 0; $i < 20; $i++) {
+			if ($sg > 0)
+				$plato = 100 * $sugf / (floatval($row['batch_size']) * $sg);
+			$sg = plato_to_sg($plato);
+		}
 		$this->SetFillColor(210,245,255);
-		$this->Cell($vul+62,5,'',0,0,'L',false);
+		$this->Cell($vul,5,sprintf("%.1f",$plato).' Plato, OG: '.sprintf("%.3f",$sg),0,0,'L',true);
+		$this->Cell(62,5,'',0,0,'L',false);
 		$this->Cell(20,5,sprintf("%8.3f",$total_fermentables),0,0,'R',true);
 		$this->Cell(30,5,'',0,0,'L',false);
 		$this->Cell(20,5,sprintf("%8.3f",$cost_fermentables).EURO,0,0,'R',true);

mercurial