diff -r 03e81378182d -r a85c1d4c4d12 www/prod_print.php --- a/www/prod_print.php Sun Feb 03 23:21:55 2019 +0100 +++ b/www/prod_print.php Mon Feb 04 15:21:49 2019 +0100 @@ -30,6 +30,9 @@ $colorw = 0; $total_ibus = 0; $preboil_sg = 0; +date_default_timezone_set('Europe/Amsterdam'); +$prdate = date(DATE_RFC2822); + class PDF_MySQL_Table extends FPDF { @@ -58,6 +61,7 @@ function TableGlobal($row) { /* 2 Columns */ + $recipetype = array( 'Extract', 'Deelmaisch', 'Mout' ); $vul = $this->w - $this->rMargin - $this->lMargin - 160; $cMargin=$this->cMargin; $this->cMargin=2; @@ -73,7 +77,7 @@ $this->SetX($this->TableX); $this->Cell(35,5,'Type',0,0,'L',true); - $this->Cell(45,5,$row['type'],0,0,'L',true); + $this->Cell(45,5,$recipetype[$row['type']],0,0,'L',true); $this->Cell($vul,5,'',0,0,'L',false); $this->Cell(35,5,'Batch grootte',0,0,'L',true); $this->Cell(45,5,$row['batch_size'].' liter',0,0,'L',true); @@ -105,6 +109,7 @@ global $pCara; global $colorw; global $preboil_sg; + $added = array( 'Maischen', 'Koken', 'Vergisten', 'Nagisten/lageren', 'Bottelen' ); $vul = $this->w - $this->rMargin - $this->lMargin - 132; $this->AddCol($vul,'Grondstof','L'); $this->AddCol(30,'Leverancier','L'); @@ -129,9 +134,6 @@ foreach($arr as $item) { //foreach element in $arr $name = iconv('UTF-8','windows-1252',$item['f_name']); $supplier = iconv('UTF-8','windows-1252',$item['f_supplier']); - $added = iconv('UTF-8','windows-1252',$item['f_added']); - $type = iconv('UTF-8','windows-1252',$item['f_type']); - $graintype = iconv('UTF-8','windows-1252',$item['f_graintype']); $amount = floatval($item['f_amount']); $costkg = floatval($item['f_cost']); $yield = floatval($item['f_yield']); @@ -139,9 +141,9 @@ $color = floatval($item['f_color']); $percent = floatval($item['f_percentage']); - if ($type == "Sugar") + if ($item['f_type'] == 1) // Sugar $pSugar += $percent; - if ($graintype == "Crystal") + if ($item['f_graintype'] == 2) // Crystal $pCara += $percent; $cost = $amount * $costkg; @@ -149,7 +151,7 @@ $total_fermentables += $amount; /* Calculate the amount of sugars */ $d = $amount * ($yield / 100) * (1 - $moisture / 100); - if ($added == "Mash") { + if ($item['f_added'] == 0) { $d = floatval($row['efficiency']) / 100 * $d; $sugarsm += $d; } @@ -159,7 +161,7 @@ $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); - $this->Cell(17,5,added_type_names($added),0,0,'L',true); + $this->Cell(17,5,$added[$item['f_added']],0,0,'L',true); $this->Cell(20,5,sprintf("%8.3f",$amount),0,0,'R',true); $this->Cell(15,5,sprintf("%.1f%%",$percent),0,0,'R',true); $this->Cell(15,5,sprintf("%.1f%%",$yield),0,0,'R',true); @@ -185,6 +187,8 @@ global $total_ibus; global $cost_hops; global $preboil_sg; + $hopform = array( 'Pellets', 'Plugs', 'Bellen' ); + $hopuse = array( 'Maischen', 'First wort', 'Koken', 'Vlamuit', 'Whirlpool', 'Koudhop' ); $vul = $this->w - $this->rMargin - $this->lMargin - 135; $this->AddCol($vul,'Hop','L'); $this->AddCol(35,'Land','L'); @@ -208,8 +212,6 @@ foreach($arr as $item) { //foreach element in $arr $name = iconv('UTF-8','windows-1252',$item['h_name']); $origin = iconv('UTF-8','windows-1252',$item['h_origin']); - $useat = iconv('UTF-8','windows-1252',$item['h_useat']); - $form = iconv('UTF-8','windows-1252',$item['h_form']); $amount = floatval($item['h_amount']) * 1000; $mass = $amount; $costkg = floatval($item['h_cost']); @@ -220,16 +222,16 @@ $cost_hops += $cost; $total_hops += $amount; - $moment = hop_useat_names($useat); - if ($useat == "Boil") { + $moment = $hopuse[$item['h_useat']]; + if ($item['h_useat'] == 2) { // Boil $moment = "Kook@".$time; } - $ibu = calc_IBU($useat, $form, /*floatval($row['est_og'])*/ $preboil_sg, floatval($row['batch_size']), $mass, $time, $alpha, $row['ibu_method']); + $ibu = calc_IBU($item['h_useat'], $item['h_form'], $preboil_sg, floatval($row['batch_size']), $mass, $time, $alpha, $row['ibu_method']); $total_ibus += $ibu; $this->Cell($vul,5,$name,0,0,'L',true); $this->Cell(35,5,$origin,0,0,'L',true); - $this->Cell(15,5,hop_form_names($form),0,0,'L',true); + $this->Cell(15,5,$hopform[$item['h_form']],0,0,'L',true); $this->Cell(20,5,$moment,0,0,'L',true); $this->Cell(15,5,sprintf("%.1f%%",$alpha),0,0,'R',true); $this->Cell(12,5,sprintf("%.1f",$ibu),0,0,'R',true); @@ -252,6 +254,8 @@ function TableYeasts($row) { global $cost_yeasts; global $svg; + $yeastform = array( 'Vloeibaar', 'Droog', 'Schuine buis', 'Slurry', 'Ingevroren', 'Depot' ); + $yeastuse = array( 'Hoofdgisting', 'Nagisting', 'Lagering', 'Bottelen' ); $vul = $this->w - $this->rMargin - $this->lMargin - 140; $this->AddCol(27,'Laboratorium','L'); $this->AddCol(18,'Product','L'); @@ -276,24 +280,26 @@ $name = iconv('UTF-8','windows-1252',$item['y_name']); $laboratory = iconv('UTF-8','windows-1252',$item['y_laboratory']); $product_id = iconv('UTF-8','windows-1252',$item['y_product_id']); - $form = iconv('UTF-8','windows-1252',$item['y_form']); - $use = iconv('UTF-8','windows-1252',$item['y_use']); - $amount = floatval($item['y_amount']) * 1000; - $costg = floatval($item['y_cost']); $attenuation = floatval($item['y_attenuation']); - $cost = $amount * $costg; + $cost = floatval($item['y_amount']) * floatval($item['y_cost']); $cost_yeasts += $cost; - if ($use == "Primary") + if ($item['y_use'] == 0) // Primary $svg = $attenuation; + if ($item['y_form'] == 0) // Liquid + $amount = sprintf("%.0f",floatval($item['y_amount']))." pak"; + else if ($item['y_form'] == 1) // Dry + $amount = sprintf("%.1f",floatval($item['y_amount'])*1000)." gr"; + else + $amount = sprintf("%.0f",floatval($item['y_amount'])*1000)." ml"; $this->Cell(27,5,$laboratory,0,0,'L',true); $this->Cell(18,5,$product_id,0,0,'L',true); $this->Cell($vul,5,$name,0,0,'L',true); - $this->Cell(20,5,yeast_use_names($use),0,0,'L',true); + $this->Cell(20,5,$yeastuse[$item['y_use']],0,0,'L',true); $this->Cell(15,5,sprintf("%.1f%%",$attenuation),0,0,'R',true); - $this->Cell(22,5,yeast_form_names($form),0,0,'L',true); - $this->Cell(18,5,sprintf("%.1f",$amount),0,0,'R',true); + $this->Cell(22,5,$yeastform[$item['y_form']],0,0,'L',true); + $this->Cell(18,5,$amount,0,0,'R',true); $this->Cell(20,5,sprintf("%8.3f",$cost).EURO,0,0,'R',true); $this->Ln(); } @@ -309,10 +315,12 @@ function TableMiscs($row) { global $cost_miscs; - $vul = $this->w - $this->rMargin - $this->lMargin - 95; + $misctype = array( 'Specerij', 'Kruid', 'Smaakstof', 'Klaringsmiddel', 'Brouwzout', 'Gistvoeding', 'Anders' ); + $miscuse = array( 'Starter', 'Maischen', 'Koken', 'Hoofdvergisting', 'Nagisting/lagering', 'Bottelen' ); + $vul = $this->w - $this->rMargin - $this->lMargin - 100; $this->AddCol($vul,'Naam','L'); $this->AddCol(30,'Soort','L'); - $this->AddCol(25,'Gebruik','L'); + $this->AddCol(30,'Gebruik','L'); $this->AddCol(20,'Hoeveel','R'); $this->AddCol(20,'Prijs','R'); @@ -328,8 +336,8 @@ $arr = json_decode($row['json_miscs'], true); foreach($arr as $item) { $name = iconv('UTF-8','windows-1252',$item['m_name']); - $type = iconv('UTF-8','windows-1252',$item['m_type']); - $use_use = iconv('UTF-8','windows-1252',$item['m_use_use']); + $type = $item['m_type']; + $use_use = $item['m_use_use']; $amount = floatval($item['m_amount']) * 1000; $costg = floatval($item['m_cost']) / 1000; $time = floatval($item['m_time']); @@ -337,24 +345,24 @@ $cost = $amount * $costg; $cost_miscs += $cost; - if ($type == "Water agent") + if ($type == 4) // Water agent $this->SetFillColor(240,140,130); - else if ($type == "Fining") + else if ($type == 3) // Fining $this->SetFillColor(95,180,25); - else if (($type == "Spice") || ($type == "Herb") || ($type == "Flavor") || ($type == "Yeast nutrient")) + else if (($type == 0) || ($type == 1) || ($type == 2) || ($type == 5)) // Spice, Herb, Flavour, Yeast nutrient $this->SetFillColor(240,250,65); else $this->SetFillColor(210,245,255); - if ($use_use == "Boil") - $gebruik = sprintf("%s %d min",misc_use_names($use_use),$time); + if ($use_use == 2) // Boil + $gebruik = sprintf("%s %d min",$miscuse[$use_use],$time); else - $gebruik = misc_use_names($use_use); + $gebruik = $miscuse[$use_use]; $hoeveel = sprintf("%.1f %s",$amount,$aiw ? "gr":"ml"); $this->Cell($vul,5,$name,0,0,'L',true); - $this->Cell(30,5,misc_type_names($type),0,0,'L',true); - $this->Cell(25,5,$gebruik,0,0,'L',true); + $this->Cell(30,5,$misctype[$type],0,0,'L',true); + $this->Cell(30,5,$gebruik,0,0,'L',true); $this->Cell(20,5,$hoeveel,0,0,'R',true); $this->Cell(20,5,sprintf("%8.3f",$cost).EURO,0,0,'R',true); $this->Ln(); @@ -453,12 +461,25 @@ class PDF extends PDF_MySQL_Table { function Header() { global $row; + global $prdate; + $stage = array( 'Plan', 'Wacht', 'Brouwen', 'Hoofdgisting', 'Nagisting', 'Lagering', 'Afvullen', 'Hergisten', 'Rijpen', 'Proeven', 'Gereed', 'Afgesloten' ); $this->Image('images/logo.png',10,6,30); // Title $this->SetFont('Helvetica','B',18); $this->SetX(45); - $this->Cell(0,8,$row['name'],1,1,'L'); - $this->Ln(20); + $this->Cell(0,8,$row['name'],0,1,'L'); + $this->Ln(1); + $this->SetFont('Helvetica','',10); + $this->SetX(45); + $this->Cell(17,5,'Datum:',0,0,'L'); + $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'); + $this->SetX(45); + $this->Cell(17,5,'Fase:',0,0,'L'); + $this->Cell(0,5,$stage[$row['stage']],0,1,'L'); + $this->Ln(6); // Ensure table header is printed parent::Header(); } @@ -483,6 +504,22 @@ $pdf->SetFillColor(210,245,255); $pdf->MultiCell(0,4,$row['notes'],0,'L',true); } -// Disclaimer toevoegen dat dit alleen recept ontwikkeling is. Uitkomsten zoals IBU zijn een berekende schatting. -// Footer sectie met berekende/geschatte uitkomsten zoals ABV, kostprijs per liter enz. + +if ($row['stage'] == 2) { + // Checklist +} +if ($row['stage'] > 2) { + // Brouw rapport +} +if ($row['stage'] > 3) { + // Vergisting gegevens +} +if ($row['stage'] > 6) { + // Package report +} +if ($row['stage'] > 9) { + // Taste notes +} + + $pdf->Output();