www/prod_checklist.php

branch
stable
changeset 665
4d01937ae7af
parent 658
945d5eba869a
child 667
1246550451ca
--- a/www/prod_checklist.php	Fri Oct 18 13:20:35 2019 +0200
+++ b/www/prod_checklist.php	Fri May 01 16:37:31 2020 +0200
@@ -1,6 +1,7 @@
 <?php
 require_once($_SERVER['DOCUMENT_ROOT'].'/includes/global.inc.php');
 require_once($_SERVER['DOCUMENT_ROOT'].'/includes/formulas.php');
+require_once($_SERVER['DOCUMENT_ROOT'].'/includes/constants.php');
 require_once($_SERVER['DOCUMENT_ROOT'].'/fpdf/fpdf.php');
 
 
@@ -38,12 +39,27 @@
 		$this->Ln(1);
 	}
 
+	function Checksplit($moment, $row) {
+		global $splitat;
+		if ($row['divide_type'] && $row['divide_type'] == $moment) {
+			$this->Ln(2);
+			$this->SetFont('Helvetica','B',14);
+               		$this->Cell(0, 4,$splitat[$row['divide_type']]." splits de batch hier!",0,0,'C',true);
+               		$this->SetFont('Arial','',10);
+			$this->AddPage();
+			return true;
+		}
+		return false;
+	}
+
 	function Checklist($row) {
 
 		global $my_grain_absorbtion;
 		global $my_brix_correction;
+		global $acidtype;
 		$mashwater = 0;
 		$numsalts = 0;
+		$factor = 1 / $row['divide_factor'];
 
 		$this->AddPage();
 		$this->SetFillColor(255,255,255);
@@ -101,17 +117,17 @@
 
 		$this->Checkheader('Water en -behandeling');
 		if ($row['w1_name']) {
-			$this->Checkline(sprintf("%.1f",floatval($row['w1_amount'])).' liter water '.$row['w1_name']);
-			$mashwater += floatval($row['w1_amount']);
+			$this->Checkline(sprintf("%.1f",floatval($row['w1_amount'] * $factor)).' liter water '.$row['w1_name']);
+			$mashwater += floatval($row['w1_amount'] * $factor);
 		}
 		if ($row['w2_name']) {
-			$this->Checkline(sprintf("%.1f",floatval($row['w2_amount'])).' liter water '.$row['w2_name']);
-			$mashwater += floatval($row['w2_amount']);
+			$this->Checkline(sprintf("%.1f",floatval($row['w2_amount'] * $factor)).' liter water '.$row['w2_name']);
+			$mashwater += floatval($row['w2_amount'] * $factor);
 		}
 		foreach($miscs as $item) {
 			if ($item['m_type'] == 4) {	// Only the water agents
 				$unit = ($item['m_amount_is_weight']) ? " gr ":" ml ";
-				$this->Checkline(sprintf("%.1f",floatval($item['m_amount'] * 1000)).$unit.$item['m_name']);
+				$this->Checkline(sprintf("%.2f",floatval($item['m_amount'] * 1000 * $factor)).$unit.$item['m_name']);
 				$numsalts++;
 			}
 		}
@@ -120,7 +136,7 @@
 		$this->Checkheader('Mout afwegen en schroten');
 		foreach($ferms as $item) {
 			if ($item['f_added'] == 0) {	// to mash
-				$s = sprintf("%.3f",floatval($item['f_amount'])).' kg `';
+				$s = sprintf("%.3f",floatval($item['f_amount'] * $factor)).' kg `';
 				$s .= iconv('UTF-8','windows-1252',$item['f_name']);
 				$s .= '` ('.iconv('UTF-8','windows-1252',$item['f_supplier']).')';
 				$this->Checkline($s);
@@ -138,10 +154,10 @@
 			$loop = 0;
 			foreach($arr as $item) {
 				if ($item['step_type'] == 0)
-					$mvol += $item['step_infuse_amount'];	// We need this later.
+					$mvol += $item['step_infuse_amount'] * $factor;	// We need this later.
 				if ($loop == 0) {
 					if ($item['step_type'] == 0)
-						$l = $item['step_infuse_amount'];
+						$l = $item['step_infuse_amount'] * $factor;
 					else
 						$l = $mashwater;
 					$s = sprintf("%.1f",$l).' liter water opwarmen tot ';
@@ -154,7 +170,7 @@
 					$this->Checkline('mout storten en inmaischen');
 					foreach($hops as $item2) {
 						if ($item2['h_useat'] == 0) {
-							$s = sprintf("%.1f",$item2['h_amount']*1000).' gr `';
+							$s = sprintf("%.1f",$item2['h_amount']*1000 * $factor).' gr `';
 							$s .= iconv('UTF-8','windows-1252',$item2['h_name']).'` toevoegen';
 							$this->Checkline($s);
 						}
@@ -162,7 +178,7 @@
 					foreach($miscs as $item3) {
 						if ($item3['m_use_use'] == 1 && $item3['m_type'] != 4) {	// Only if not a water agent
 							$unit = ($item3['m_amount_is_weight']) ? " gr ":" ml ";
-							$s = sprintf("%.2f",$item3['m_amount']*1000).$unit.'`';
+							$s = sprintf("%.2f",$item3['m_amount']*1000 * $factor).$unit.'`';
 							$s .= iconv('UTF-8','windows-1252',$item3['m_name']).'` toevoegen';
 							$this->Checkline($s);
 						}
@@ -171,11 +187,11 @@
 					$this->Checkline('pH meten en bijstellen (doel pH beslag: '.sprintf("%.1f",$row['mash_ph']).' pH)');
 				} else {
 					if ($item['step_type'] == 0) {	// Infusion
-						$s = 'toevoegen '.$item['step_infuse_amount'].' liter water van xx '.DEG.'C';
+						$s = 'toevoegen '.($item['step_infuse_amount'] * $factor).' liter water van xx '.DEG.'C';
 					} else if ($item['step_type'] == 1) {	// Direct heat
 						$s = 'opwarmen tot '.$item['step_temp'].' '.DEG.'C';
 					} else {	// Decoction
-						$s = 'uitnemen, opwarmen, koken en terugstorten van '.$item['step_infuse_amount'].' liter deelbeslag';
+						$s = 'uitnemen, opwarmen, koken en terugstorten van '.($item['step_infuse_amount']*$factor).' liter deelbeslag';
 					}
 					$this->Checkline($s);
 					$this->Checkline($item['step_time'].' min. bij '.$item['step_temp'].' '.DEG.'C');
@@ -185,9 +201,9 @@
 			$est_mash_sg = 0;
 			foreach($ferms as $item) {
 				if ($item['f_added'] == 0) {
-					$d = $item['f_amount'] * ($item['f_yield'] / 100) * (1 - $item['f_moisture'] / 100);
-					$mvol += $item['f_amount'] * $item['f_moisture'] / 100;
-					$grainabsorbtion += $my_grain_absorbtion * $item['f_amount'];
+					$d = $item['f_amount'] * $factor * ($item['f_yield'] / 100) * (1 - $item['f_moisture'] / 100);
+					$mvol += $item['f_amount'] * $factor * $item['f_moisture'] / 100;
+					$grainabsorbtion += $my_grain_absorbtion * $item['f_amount'] * $factor;
 					$msugars += $d;
 				}
 			}
@@ -202,76 +218,85 @@
 		else
 			$this->Ln(5);
 
-		$acidtype = array( 'Melkzuur', 'Zoutzuur', 'Fosforzuur', 'Zwavelzuur' );
 		$this->Checkheader('Filteren en spoelen');
-		$s = sprintf("%.1f",$row['sparge_volume']).' liter spoelwater opwarmen tot '.sprintf("%.1f",$row['sparge_temp']).' '.DEG.'C';
+		$s = sprintf("%.1f",$row['sparge_volume'] * $factor).' liter spoelwater opwarmen tot '.sprintf("%.1f",$row['sparge_temp']).' '.DEG.'C';
 		$this->Checkline($s);
 		$s = 'spoelwater aanzuren tot pH <= '.sprintf("%.1f",$row['sparge_ph']).' met ';
-		$s .= sprintf("%.1f",$row['sparge_acid_amount']*1000).' ml. '.$acidtype[$row['sparge_acid_type']];
+		$s .= sprintf("%.2f",$row['sparge_acid_amount']*1000*$factor).' ml. '.$acidtype[$row['sparge_acid_type']];
 		$this->Checkline($s);
-		$spoelw = ($row['boil_size'] - $mashwater + $grainabsorbtion + $row['eq_lauter_deadspace']) * 1.03;	// A small heat correction
+		$spoelw = (($row['boil_size']*$factor) - $mashwater + $grainabsorbtion + $row['eq_lauter_deadspace']) * 1.03;	// A small heat correction
 		$this->Checkline('spoelen met ongeveer '.sprintf("%.1f",$spoelw).' liter spoelwater');
-		$s = 'doelvolume in kookketel: '.sprintf("%.1f",$row['boil_size'] * 1.04).' liter (';
-		$s .= sprintf("%.1f",kettle_cm($row['boil_size'] * 1.04,$row['eq_kettle_volume'],$row['eq_kettle_height'])).' cm onder de rand)';
+		$s = 'doelvolume in kookketel: '.sprintf("%.1f",$row['boil_size'] * $factor * 1.04).' liter (';
+		$s .= sprintf("%.1f",kettle_cm($row['boil_size'] * $factor * 1.04,$row['eq_kettle_volume'],$row['eq_kettle_height'])).' cm onder de rand)';
 		$this->Checkline($s);
-		$pre_sg = estimate_sg($msugars * floatval($row['efficiency']) / 100,floatval($row['boil_size']));
+		$pre_sg = estimate_sg($msugars * floatval($row['efficiency']) / 100,floatval($row['boil_size'] * $factor));
 		$this->Checkline('doel SG in kookketel: '.density_str($pre_sg));
 		foreach($hops as $item2) {
 			if ($item2['h_useat'] == 1) {
-				$s = sprintf("%.1f",$item2['h_amount']*1000).' gr `';
+				$s = sprintf("%.1f",$item2['h_amount']*1000*$factor).' gr `';
 				$s .= iconv('UTF-8','windows-1252',$item2['h_name']).'` toevoegen na het spoelen';
 				$this->Checkline($s);
 			}
 		}
-		if ($this->GetY() > 200)
+		if ($this->Checksplit(1, $row))
+			$factor = 1;
+		if ($this->GetY() > 200 && $row['boil_time'] > 0)
+			$this->AddPage();
+		else if ($this->GetY() > 270 && $row['boil_time'] == 0)
 			$this->AddPage();
 		else
 			$this->Ln(5);
 
 		$this->Checkheader('Koken');
-		$this->Checkline('totale kooktijd: '.$row['boil_time'].' min.');
-		for ($i = $row['boil_time']; $i >= 0; $i--) {
-			if ($i == 10) {
-				foreach($ferms as $item1) {
-					if ($item1['f_added'] == 1) {
-						$s = sprintf("%.3f",$item1['f_amount']).' kg `';
-						$s .= iconv('UTF-8','windows-1252',$item1['f_name']).'` bij 10 minuten voor einde koken';
+		if ($row['boil_time'] > 0) {
+			$this->Checkline('totale kooktijd: '.$row['boil_time'].' min.');
+			for ($i = $row['boil_time']; $i >= 0; $i--) {
+				if ($i == 10) {
+					foreach($ferms as $item1) {
+						if ($item1['f_added'] == 1) {
+							$s = sprintf("%.3f",$item1['f_amount']*$factor).' kg `';
+							$s .= iconv('UTF-8','windows-1252',$item1['f_name']).'` bij 10 minuten voor einde koken';
+							$this->Checkline($s);
+						}
+					}
+					if ($row['brew_cooling_method'] == 1)
+						$this->Checkline('Plaats dompelkoeler bij 10 minuten voor einde koken');
+				}
+				foreach($hops as $item2) {
+					if (($item2['h_useat'] == 2 || $item2['h_useat'] == 3) && ($item2['h_time'] == $i)) {
+						$s = sprintf("%.2f",$item2['h_amount']*1000*$factor).' gr `';
+						$s .= iconv('UTF-8','windows-1252',$item2['h_name']).'` bij ';
+						if ($i > 0)
+							$s .= $i.' minuten voor einde koken';
+						else
+							$s .= 'vlamuit';
 						$this->Checkline($s);
 					}
 				}
-				if ($row['brew_cooling_method'] == 1)
-					$this->Checkline('Plaats dompelkoeler bij 10 minuten voor einde koken');
-			}
-			foreach($hops as $item2) {
-				if (($item2['h_useat'] == 2 || $item2['h_useat'] == 3) && ($item2['h_time'] == $i)) {
-					$s = sprintf("%.1f",$item2['h_amount']*1000).' gr `';
-					$s .= iconv('UTF-8','windows-1252',$item2['h_name']).'` bij ';
-					if ($i > 0)
-						$s .= $i.' minuten voor einde koken';
-					else
-						$s .= 'vlamuit';
-					$this->Checkline($s);
+				foreach($miscs as $item3) {
+					if ($item3['m_use_use'] == 2 && $item3['m_time'] == $i) {
+						$unit = ($item3['m_amount_is_weight']) ? " gr ":" ml ";
+						$s = sprintf("%.2f",$item3['m_amount']*1000*$factor).$unit.'`';
+						$s .= iconv('UTF-8','windows-1252',$item3['m_name']).'` bij ';
+						if ($i > 0)
+							$s .= $i.' minuten voor einde koken';
+						else
+							$s .= 'vlamuit';
+						$this->Checkline($s);
+					}
 				}
+
 			}
-			foreach($miscs as $item3) {
-				if ($item3['m_use_use'] == 2 && $item3['m_time'] == $i) {
-					$unit = ($item3['m_amount_is_weight']) ? " gr ":" ml ";
-					$s = sprintf("%.1f",$item3['m_amount']*1000).$unit.'`';
-					$s .= iconv('UTF-8','windows-1252',$item3['m_name']).'` bij ';
-					if ($i > 0)
-						$s .= $i.' minuten voor einde koken';
-					else
-						$s .= 'vlamuit';
-					$this->Checkline($s);
-				}
-			}
-
+			$s = 'doelvolume einde koken: '.sprintf("%.1f",$row['batch_size']*$factor*1.04).' liter (';
+			$s .= sprintf("%.1f",kettle_cm($row['batch_size']*$factor*1.04,$row['eq_kettle_volume'],$row['eq_kettle_height']));
+			$s .= ' cm onder de rand)';
+			$this->Checkline($s);
+			$this->Checkline('doel SG einde koken: '.density_str($row['est_og3']));
+			if ($this->Checksplit(2, $row))
+				$factor = 1;
+		} else {
+			$this->Checkline('Dit is een `no-boil\' recept');
 		}
-		$s = 'doelvolume einde koken: '.sprintf("%.1f",$row['batch_size']*1.04).' liter (';
-		$s .= sprintf("%.1f",kettle_cm($row['batch_size']*1.04,$row['eq_kettle_volume'],$row['eq_kettle_height']));
-		$s .= ' cm onder de rand)';
-		$this->Checkline($s);
-		$this->Checkline('doel SG einde koken: '.density_str($row['est_og']));
 		if ($this->GetY() > 200)
 			$this->AddPage();
 		else
@@ -295,7 +320,7 @@
 			}
 			foreach($hops as $item2) {
 				if ($item2['h_useat'] == 4) {
-					$s = sprintf("%.1f",$item2['h_amount']*1000).' gr `';
+					$s = sprintf("%.1f",$item2['h_amount']*1000*$factor).' gr `';
 					$s .= iconv('UTF-8','windows-1252',$item2['h_name']).'` voor ';
 					$s .= $item2['h_time'].' minuten in de whirlpool';
 					$this->Checkline($s);
@@ -312,26 +337,37 @@
 		}
 		$this->Checkline('gistvat ontsmetten en evt. pomp en slangen ontsmetten');
 		$this->Checkline('wort naar gistvat overbrengen');
-
+		if ($this->Checksplit(3, $row))
+			$factor = 1;
 		if ($this->GetY() > 240)
 			$this->AddPage();
 		else
 			$this->Ln(5);
+
+		$climate = $row['brew_cooling_to'];
 		$this->Checkheader('Gist enten');
 		$dry = 0;
 		foreach ($yeasts as $item) {
+			$name       = iconv('UTF-8','windows-1252',$item['y_name']);
+                        $product_id = iconv('UTF-8','windows-1252',$item['y_product_id']);
 			if ($item['y_use'] == 0) { // primary
 				if ($item['y_form'] == 0) { // Liquid
-					$this->Checkline($item['y_amount'].' pak '.$item['y_product_id'].', '.$item['y_name'].' gist');
-				} else if ($item['y_form'] == 1 || $item['y_form'] == 6) { // Dry
-					$s = sprintf("%.1f",$item['y_amount']*1000).' gram '.$item['y_product_id'].', '.$item['y_name'];
+					$this->Checkline(($item['y_amount']*$factor).' pak '.$product_id.', '.$name.' gist');
+				} else if ($item['y_form'] == 1 || $item['y_form'] == 6) { // Dry or dried Kveik
+					$s = sprintf("%.1f",$item['y_amount']*$factor*1000).' gram '.$product_id.', '.$name;
 					$s .= ' gist';
-					$dry += $item['y_amount']*10000;
+					if ($item['y_form'] == 1)
+						$dry += $item['y_amount']*$factor*10000;
 					$this->Checkline($s);
 				} else { // Slant/Culture/Frozen/Bottle
-					$s = sprintf("%.0f",$item['y_amount']*1000).' ml '.$item['y_product_id'].', '.$item['y_name'].' gist';
+					$s = sprintf("%.0f",$item['y_amount']*$factor*1000).' ml '.$product_id.', '.$name.' gist';
 					$this->Checkline($s);
 				}
+				if ($item['y_type'] == 6 && floatval($item['y_pitch_temperature']) > 0) {
+					$s = 'Gist enten bij ' . sprintf("%.1f",floatval($item['y_pitch_temperature'])) . DEG . 'C';
+					$this->Checkline($s);
+					$climate = $item['y_pitch_temperature'];
+				}
 			}
 		}
 		if ($dry > 0) {
@@ -348,7 +384,7 @@
 				$this->Checkline('gist toevoegen');
 		}
 		if ($row['brew_fermenter_extrawater'] > 0)
-			$this->Checkline(sprintf("%.1f", $row['brew_fermenter_extrawater']).' liter water toevoegen in gistvat');
+			$this->Checkline(sprintf("%.1f", $row['brew_fermenter_extrawater']*$factor).' liter water toevoegen in gistvat');
 		if ($row['brew_aeration_type'] > 0) {
 			$s = 'wort '.$row['brew_aeration_time'].' minuten beluchten met ';
 			$s .= ($row['brew_aeration_type'] == 1) ? "lucht":"zuurstof";
@@ -360,7 +396,7 @@
 			$this->Ln(5);
 
 		$this->Checkheader('Vergisting starten');
-		$this->Checkline('klimaatkast instellen op '.sprintf("%.1f",$row['brew_cooling_to']).' '.DEG.'C');
+		$this->Checkline('klimaatkast instellen op '.sprintf("%.1f",$climate).' '.DEG.'C');
 
 		/*
 		 * During primary fermentation: fermentables, misc
@@ -383,7 +419,7 @@
 		}
 		foreach($ferms as $item1) {
                         if ($item1['f_added'] == 2) {
-				$s = sprintf("%.3f",$item1['f_amount']).' kg `';
+				$s = sprintf("%.3f",$item1['f_amount']*$factor).' kg `';
                                 $s .= iconv('UTF-8','windows-1252',$item1['f_name']).'` op dag 3 of 4 toevoegen';
                                 $this->Checkline($s);
 			}
@@ -391,11 +427,13 @@
                 foreach($miscs as $item3) {
                         if ($item3['m_use_use'] == 3) {
 				$unit = ($item3['m_amount_is_weight']) ? " gr ":" ml ";
-				$s = sprintf("%.1f",$item3['m_amount']*1000).$unit.'`';
+				$s = sprintf("%.1f",$item3['m_amount']*$factor*1000).$unit.'`';
                                 $s .= iconv('UTF-8','windows-1252',$item3['m_name']).'` op dag 3 of 4 toevoegen';
                                 $this->Checkline($s);
 			}
                 }
+		if ($this->Checksplit(4, $row))
+			$factor = 1;
 
 		/*
 		 * During secondary fermentation: yeast
@@ -404,6 +442,8 @@
                 foreach ($yeasts as $item4) {
                         if ($item4['y_use'] == 1)
 				$lines++;
+			if ($item4['y_harvest_time'] > 0)
+				$lines++;
 		}
 		if ($lines) {
 			if ($this->GetY() > (270 - (5 * $lines)))
@@ -414,18 +454,30 @@
                 }
 		foreach ($yeasts as $item4) {
                         if ($item4['y_use'] == 1) {
+				$name       = iconv('UTF-8','windows-1252',$item4['y_name']);
+                                $product_id = iconv('UTF-8','windows-1252',$item4['y_product_id']);
 				if ($item4['y_form'] == 0) { // Liquid
-                                        $this->Checkline($item4['y_amount'].' pak '.$item4['y_product_id'].', '.$item4['y_name'].' gist (eventueel met starter)');
+                                        $this->Checkline(($item4['y_amount']*$factor).' pak '.$product_id.', '.$name.' gist (eventueel met starter)');
                                 } else if ($item['y_form'] == 1) { // Dry
-                                        $s = sprintf("%.1f",$item4['y_amount']*1000).' gram '.$item4['y_product_id'].', '.$item4['y_name'];
+                                        $s = sprintf("%.1f",$item4['y_amount']*$factor*1000).' gram '.$product_id.', '.$name;
                                         $s .= ' gist';
                                         $this->Checkline($s);
                                 } else { // Slant/Culture/Frozen/Bottle
-                                        $s = sprintf("%.0f",$item4['y_amount']*1000).' ml '.$item4['y_product_id'].', '.$item4['y_name'].' gist (eventueel met starter)';
+                                        $s = sprintf("%.0f",$item4['y_amount']*$factor*1000).' ml '.$product_id.', '.$name.' gist (eventueel met starter)';
                                         $this->Checkline($s);
                                 }
 			}
+			if ($item4['y_harvest_time'] > 0) {
+				$s = 'Na ' . $item4['y_harvest_time'] . ' uur gist oogsten vanaf de ';
+				if ($item4['y_harvest_top'] > 0)
+					$s .= 'bovenzijde';
+				else
+					$s .= 'bodem';
+				$this->Checkline($s);
+			}
                 }
+		if ($this->Checksplit(5, $row))
+			$factor = 1;
 
 		/*
 		 * During tertiary fermentation: fermentables, hop, yeast, misc
@@ -456,14 +508,14 @@
                 }
 		foreach($ferms as $item1) {
                         if ($item1['f_added'] == 3) {
-                                $s = sprintf("%.3f",$item1['f_amount']).' kg `';
+                                $s = sprintf("%.3f",$item1['f_amount']*$factor).' kg `';
                                 $s .= iconv('UTF-8','windows-1252',$item1['f_name']).'` toevoegen';
                                 $this->Checkline($s);
                         }
                 }
 		foreach($hops as $item2) {
                         if ($item2['h_useat'] == 5) {
-                                $s = sprintf("%.1f",$item2['h_amount']*1000).' gr `';
+                                $s = sprintf("%.1f",$item2['h_amount']*$factor*1000).' gr `';
                                 $s .= iconv('UTF-8','windows-1252',$item2['h_name']).'` voor ';
 				$s .= sprintf("%.0f",$item2['h_time']/1440).' dagen toevoegen';
                                 $this->Checkline($s);
@@ -471,13 +523,15 @@
                 }
 		foreach ($yeasts as $item4) {
                         if ($item4['y_use'] == 2) {
+				$name       = iconv('UTF-8','windows-1252',$item4['y_name']);
+                                $product_id = iconv('UTF-8','windows-1252',$item4['y_product_id']);
                                 if ($item4['y_form'] == 0) { // Liquid
-                                        $s = $item4['y_amount'].' pak '.$item4['y_product_id'].', '.$item4['y_name'].' gist (eventueel met starter)';
+                                        $s = ($item4['y_amount']*$factor).' pak '.$product_id.', '.$name.' gist (eventueel met starter)';
                                 } else if ($item4['y_form'] == 1) { // Dry
-                                        $s = sprintf("%.1f",$item4['y_amount']*1000).' gram '.$item4['y_product_id'].', '.$item4['y_name'];
+                                        $s = sprintf("%.1f",$item4['y_amount']*$factor*1000).' gram '.$product_id.', '.$name;
                                         $s .= ' gist';
                                 } else { // Slant/Culture/Frozen/Bottle
-                                        $s = sprintf("%.0f",$item4['y_amount']*1000).' ml '.$item4['y_product_id'].', '.$item4['y_name'];
+                                        $s = sprintf("%.0f",$item4['y_amount']*$factor*1000).' ml '.$product_id.', '.$name;
 					$s .= ' gist (eventueel met starter)';
                                 }
 				$this->Checkline($s);
@@ -486,12 +540,14 @@
 		foreach($miscs as $item3) {
                         if ($item3['m_use_use'] == 4) {
 				$unit = ($item3['m_amount_is_weight']) ? " gr ":" ml ";
-                                $s = sprintf("%.1f",$item3['m_amount']*1000).$unit.'`';
+                                $s = sprintf("%.1f",$item3['m_amount']*$factor*1000).$unit.'`';
                                 $s .= iconv('UTF-8','windows-1252',$item3['m_name']).'` voor ';
 				$s .= sprintf("%.0f",$item3['m_time']/1440).' dagen toevoegen';
                                 $this->Checkline($s);
                         }
                 }
+		if ($this->Checksplit(6, $row))
+			$factor = 1;
 
 		/*
 		 * During packaging: fermentables, yeast, misc
@@ -520,30 +576,32 @@
                 }
 		foreach($ferms as $item1) {
                         if ($item1['f_added'] == 4) {
-                                $s = sprintf("%.3f",$item1['f_amount']).' kg `';
+                                $s = sprintf("%.3f",$item1['f_amount']*$factor).' kg `';
                                 $s .= iconv('UTF-8','windows-1252',$item1['f_name']).'`';
 				if ($row['bottle_priming_water'] > 0)
-					$s .= ' met '.sprintf("%.3f",$row['bottle_priming_water']).' liter water';
+					$s .= ' met '.sprintf("%.3f",$row['bottle_priming_water']*$factor).' liter water';
 				$s .= ' bij bottelen';
                                 $this->Checkline($s);
                         }
 			if ($item1['f_added'] == 5) {
-                                $s = sprintf("%.3f",$item1['f_amount']).' kg `';
+                                $s = sprintf("%.3f",$item1['f_amount']*$factor).' kg `';
                                 $s .= iconv('UTF-8','windows-1252',$item1['f_name']).'`';
 				if ($row['keg_priming_water'] > 0)
-					$s .= ' met '.sprintf("%.3f",$row['keg_priming_water']).' liter water';
+					$s .= ' met '.sprintf("%.3f",$row['keg_priming_water']*$factor).' liter water';
 				$s .= ' bij op fust zetten';
                                 $this->Checkline($s);
                         }
                 }
 		foreach ($yeasts as $item4) {
                         if ($item4['y_use'] == 3) {
+				$name       = iconv('UTF-8','windows-1252',$item4['y_name']);
+                        	$product_id = iconv('UTF-8','windows-1252',$item4['y_product_id']);
                                 if ($item4['y_form'] == 0) { // Liquid
-                                        $s = '`'.$item4['y_product_id'].', '.$item4['y_name'];
+                                        $s = '`'.$product_id.', '.$name;
                                 } else if ($item4['y_form'] == 1) { // Dry
-                                        $s = sprintf("%.1f",$item4['y_amount']*1000).' gram `'.$item4['y_product_id'].', '.$item4['y_name'];
+                                        $s = sprintf("%.1f",$item4['y_amount']*$factor*1000).' gram `'.$product_id.', '.$name;
                                 } else { // Slant/Culture/Frozen/Bottle
-                                        $s = sprintf("%.0f",$item4['y_amount']*1000).' ml `'.$item4['y_product_id'].', '.$item4['y_name'];
+                                        $s = sprintf("%.0f",$item4['y_amount']*$factor*1000).' ml `'.$product_id.', '.$name;
                                 }
 				$s .= '` als bottelgist';
 				$this->Checkline($s);
@@ -552,13 +610,12 @@
 		foreach($miscs as $item3) {
                         if ($item3['m_use_use'] == 5) {
 				$unit = ($item3['m_amount_is_weight']) ? " gr ":" ml ";
-                                $s = sprintf("%.1f",$item3['m_amount']*1000).$unit.'`';
+                                $s = sprintf("%.1f",$item3['m_amount']*$factor*1000).$unit.'`';
                                 $s .= iconv('UTF-8','windows-1252',$item3['m_name']).'` bij bottelen toevoegen';
                                 $this->Checkline($s);
                         }
                 }
 	}
-
 }
 
 
@@ -567,7 +624,7 @@
 	function Header() {
 		global $row;
 		global $prdate;
-		$stage = array( 'Plan', 'Wacht', 'Brouwen', 'Hoofdgisting', 'Nagisting', 'Lagering', 'Afvullen', 'Hergisten', 'Rijpen', 'Proeven', 'Gereed', 'Afgesloten' );
+		global $stage;
 		$this->Image('images/logo.png',10,10,30);
 		// Title
 		$this->SetFont('Helvetica','B',18);
@@ -580,11 +637,18 @@
 		$this->Cell(0,5,$prdate,0,1,'L');
 		$this->SetX(45);
 		$this->Cell(17,5,'Stijl:',0,0,'L');
-		$this->Cell(0,5,$row['st_name'],0,1,'L');
+		$st_name = iconv('UTF-8','windows-1252',$row['st_name']);
+		$this->Cell(0,5,$st_name,0,1,'L');
 		$this->SetX(45);
 		$this->Cell(17,5,'Fase:',0,0,'L');
 		$this->Cell(0,5,$stage[$row['stage']],0,1,'L');
-		$this->Ln(6);
+		$this->SetX(45);
+                $this->Cell(17,5,'Batch:',0,0,'L');
+                if ($row['divide_parts'] == 0)
+                        $this->Cell(0,5,"Niet gespitst",0,1,'L');
+                else
+                        $this->Cell(0,5,"Split batch ".($row['divide_part'] + 1)." van ".($row['divide_parts'] + 1),0,1,'L');
+                $this->Ln(2);
 		// Ensure table header is printed
 		parent::Header();
 	}

mercurial