# HG changeset patch # User Michiel Broek # Date 1541867033 -3600 # Node ID 85521c6e00224e80ef0e2583f8b4cd5b25316764 # Parent 7af1d472475ae3f1051ab50e47ebafe9ac4da9a5 Added recipe print yeasts section. diff -r 7af1d472475a -r 85521c6e0022 www/includes/formulas.php --- a/www/includes/formulas.php Thu Nov 08 20:30:32 2018 +0100 +++ b/www/includes/formulas.php Sat Nov 10 17:23:53 2018 +0100 @@ -1,5 +1,23 @@ 299) { + $i = 299; + } + + /* Table copied from Brouwhulp/BrewBuddy */ + $R = array( 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, // 0 + 250, 250, 250, 250, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240, 239, 238, 237, 236, 235, // 2 + 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, 224, 223, 222, 221, 220, 219, 218, 217, 216, 215, // 4 + 214, 213, 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, 200, 200, 199, 199, 198, 198, // 6 + 197, 197, 196, 196, 195, 195, 194, 194, 193, 193, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, // 8 + 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, // 10 + 192, 192, 192, 192, 192, 192, 192, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, // 12 + 179, 178, 177, 175, 174, 172, 171, 169, 168, 167, 195, 164, 162, 161, 159, 158, 157, 155, 154, 152, // 14 + 151, 149, 148, 147, 145, 144, 142, 141, 139, 138, 137, 135, 134, 132, 131, 129, 128, 127, 125, 124, // 16 + 122, 121, 119, 118, 117, 115, 114, 112, 111, 109, 108, 107, 105, 104, 102, 101, 99, 98, 97, 95, // 18 + 94, 92, 91, 89, 88, 87, 85, 84, 82, 81, 79, 78, 77, 75, 74, 72, 71, 69, 68, 67, // 20 + 65, 64, 62, 61, 59, 58, 57, 55, 54, 52, 51, 49, 48, 47, 45, 44, 43, 41, 39, 38, // 22 + 37, 37, 36, 36, 35, 35, 34, 34, 33, 33, 32, 32, 31, 31, 30, 30, 29, 29, 28, 28, // 24 + 27, 27, 26, 26, 25, 25, 24, 24, 23, 23, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18, // 26 + 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8 ); + + $G = array( 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, + 250, 250, 250, 250, 250, 250, 249, 248, 247, 246, 245, 244, 242, 240, 238, 236, 234, 232, 230, 228, + 226, 224, 222, 220, 218, 216, 214, 212, 210, 208, 206, 204, 202, 200, 198, 196, 194, 192, 190, 188, + 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, + 146, 144, 142, 141, 140, 139, 139, 138, 137, 136, 136, 135, 134, 133, 133, 132, 131, 130, 130, 129, + 128, 127, 127, 126, 125, 124, 124, 123, 122, 121, 121, 120, 119, 118, 118, 117, 116, 115, 115, 114, + 113, 112, 112, 111, 110, 109, 109, 108, 107, 106, 106, 105, 104, 103, 103, 102, 101, 100, 100, 99, + 98, 97, 97, 96, 95, 94, 94, 93, 92, 91, 91, 90, 89, 88, 88, 87, 86, 85, 85, 84, + 83, 82, 82, 81, 80, 79, 78, 77, 76, 75, 75, 74, 73, 72, 72, 71, 70, 69, 69, 68, + 67, 66, 66, 65, 64, 63, 63, 62, 61, 60, 60, 59, 58, 57, 57, 56, 55, 54, 54, 53, + 52, 51, 51, 50, 49, 48, 48, 47, 46, 45, 45, 44, 43, 42, 42, 41, 40, 39, 39, 38, + 37, 36, 36, 35, 34, 33, 33, 32, 31, 30, 30, 29, 28, 27, 27, 26, 25, 24, 24, 23, + 22, 22, 22, 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 17, 17, 17, 16, 16, + 16, 15, 15, 15, 14, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 9, + 9, 9, 8, 8, 8, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3 ); + + $B = array( 210, 204, 199, 193, 188, 182, 177, 171, 166, 160, 155, 149, 144, 138, 133, 127, 122, 116, 111, 105, + 100, 94, 89, 83, 78, 72, 67, 61, 56, 50, 45, 45, 45, 46, 46, 46, 46, 47, 47, 47, + 47, 48, 48, 48, 48, 49, 49, 49, 49, 50, 50, 50, 50, 51, 51, 51, 51, 52, 52, 52, + 52, 53, 53, 53, 53, 54, 54, 54, 54, 55, 55, 55, 55, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 55, 55, 55, 55, 54, 54, 54, 54, 53, 53, 53, 53, 52, 52, 52, 52, 51, + 51, 51, 51, 50, 50, 50, 50, 49, 49, 48, 47, 47, 46, 45, 45, 44, 43, 43, 42, 41, + 41, 40, 39, 39, 38, 37, 37, 36, 35, 34, 33, 32, 31, 29, 28, 27, 26, 25, 24, 23, + 21, 20, 19, 18, 17, 16, 15, 13, 12, 11, 10, 9, 8, 9, 9, 10, 10, 11, 11, 12, + 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, + 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 17, 17, 17, 17, 16, 16, 15, 15, + 15, 14, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 9, 8, + 8, 8, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2 ); + + return array($R[$i],$G[$i],$B[$i]); +} + + ?> diff -r 7af1d472475a -r 85521c6e0022 www/rec_print.php --- a/www/rec_print.php Thu Nov 08 20:30:32 2018 +0100 +++ b/www/rec_print.php Sat Nov 10 17:23:53 2018 +0100 @@ -1,26 +1,36 @@ SetFont('Helvetica','B',9); $this->SetX($this->TableX); - $this->SetFillColor($this->HeaderColor[0],$this->HeaderColor[1],$this->HeaderColor[2]); + $this->SetFillColor(255,150,100); foreach($this->aCols as $col) $this->Cell($col['w'],5,$col['c'],0,0,$col['a'],true); $this->Ln(); @@ -41,23 +51,20 @@ $this->aCols[]=array('c'=>$caption,'w'=>$width,'a'=>$align); } - function TableGlobal($row,$prop) { + function TableGlobal($row) { /* 2 Columns */ $vul = $this->w - $this->rMargin - $this->lMargin - 170; $cMargin=$this->cMargin; - $this->cMargin=$prop['padding']; + $this->cMargin=2; $this->TableX=$this->lMargin; - $this->HeaderColor=$prop['HeaderColor']; - $this->TotalColor=$prop['TotalColor']; - $this->RowColors=array($prop['color1'],$prop['color2']); - $this->SetFont('Helvetica','B',11); + $this->SetFont('Helvetica','B',9); $this->SetX($this->TableX); - $this->SetFillColor($this->HeaderColor[0],$this->HeaderColor[1],$this->HeaderColor[2]); - $this->Cell(0, 6, 'Recept overzicht',0,0,'C',true); + $this->SetFillColor(255,150,100); + $this->Cell(0, 5, 'Recept overzicht',0,0,'C',true); $this->Ln(); $this->SetFont('Helvetica','',9); - $this->SetFillColor($this->RowColors[0][0],$this->RowColors[0][1],$this->RowColors[0][2]); + $this->SetFillColor(210,245,255); $this->SetX($this->TableX); $this->Cell(35,5,'Type',0,0,'L',true); @@ -101,8 +108,11 @@ $this->SetX($this->TableX); $this->Cell(35,5,'Kleur ('.$row['color_method'].')',0,0,'L',true); + $beercolor = ebc_to_color($row['est_color']); + $this->SetFillColor($beercolor[0],$beercolor[1],$beercolor[2]); $this->Cell(25,5,$row['est_color'].' EBC',0,0,'L',true); $this->Cell(25,5,'('.$row['st_color_min'].' - '.$row['st_color_max'].' EBC)',0,0,'L',true); + $this->SetFillColor(210,245,255); $this->Cell($vul,5,'',0,0,'L',false); $this->Cell(35,5,'Bitterheid ('.$row['ibu_method'].')',0,0,'L',true); $this->Cell(25,5,sprintf("%.0f",$row['est_ibu']).' IBU',0,0,'L',true); @@ -112,31 +122,32 @@ $this->cMargin=$cMargin; } - function TableFermentables($row,$prop) { - $vul = $this->w - $this->rMargin - $this->lMargin - 130; + function TableFermentables($row) { + global $cost_fermentables; + global $total_fermentables; + $vul = $this->w - $this->rMargin - $this->lMargin - 130; $this->AddCol($vul,'Grondstof','L'); - $this->AddCol( 30,'Leverancier','L'); - $this->AddCol( 15,'EBC','R'); - $this->AddCol( 15,'Moment','L'); - $this->AddCol( 20,'Kg','R'); - $this->AddCol( 15,'Procent','R'); - $this->AddCol( 15,'Opbr.','R'); - $this->AddCol( 20,'Prijs','R'); + $this->AddCol(30,'Leverancier','L'); + $this->AddCol(15,'EBC','R'); + $this->AddCol(15,'Moment','L'); + $this->AddCol(20,'Kg','R'); + $this->AddCol(15,'Procent','R'); + $this->AddCol(15,'Opbr.','R'); + $this->AddCol(20,'Prijs','R'); $cMargin=$this->cMargin; - $this->cMargin=$prop['padding']; + $this->cMargin=2; $this->TableX=$this->lMargin; $this->TableHeader(); - $this->ColorIndex=0; $this->ProcessingTable=true; $this->SetFont('Helvetica','',9); - $this->SetFillColor($this->RowColors[0][0],$this->RowColors[0][1],$this->RowColors[0][2]); + $this->SetFillColor(250, 195, 65); $arr = json_decode($row['json_fermentables'], true); foreach($arr as $item) { //foreach element in $arr - $name = $item['f_name']; - $supplier = $item['f_supplier']; + $name = iconv('UTF-8','windows-1252',$item['f_name']); + $supplier = iconv('UTF-8','windows-1252',$item['f_supplier']); $amount = floatval($item['f_amount']); $costkg = floatval($item['f_cost']); $yield = floatval($item['f_yield']); @@ -149,6 +160,8 @@ else $add = $item['f_added']; $cost = $amount * $costkg; + $cost_fermentables += $cost; + $total_fermentables += $amount; $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); @@ -160,10 +173,200 @@ $this->Ln(); } + $this->SetFillColor(210,245,255); + $this->Cell($vul+60,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); + $this->Ln(); $this->ProcessingTable=false; $this->cMargin=$cMargin; $this->aCols=array(); } + + function TableHops($row) { + global $total_hops; + global $cost_hops; + $vul = $this->w - $this->rMargin - $this->lMargin - 135; + $this->AddCol($vul,'Hop','L'); + $this->AddCol(35,'Land','L'); + $this->AddCol(15,'Soort','L'); + $this->AddCol(20,'Moment','L'); + $this->AddCol(15,'Alpha','R'); + $this->AddCol(12,'IBU','R'); + $this->AddCol(18,'Gram','R'); + $this->AddCol(20,'Prijs','R'); + + $cMargin=$this->cMargin; + $this->cMargin=2; + $this->TableX=$this->lMargin; + $this->TableHeader(); + $this->ProcessingTable=true; + + $this->SetFont('Helvetica','',9); + $this->SetFillColor(100, 250, 65); + + $arr = json_decode($row['json_hops'], true); + 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']); + $time = floatval($item['h_time']); + $alpha = floatval($item['h_alpha']); + + $cost = ($amount * $costkg) / 1000; + $cost_hops += $cost; + $total_hops += $amount; + + $fmoment = 1.0; + $moment = "Kook@".$time; + if (($useat == "Dry Hop") || ($useat == "Dry hop")) { + $fmoment = 0.0; + $moment = "Dry-hop"; + } else if ($useat == "Whirlpool") { + $fmoment = 0.0; + $moment = "Whirlpool"; + } else if ($useat == "Mash") { + $fmoment = 0.7; // Brouwhulp + $moment = "Maischen"; + } else if (($useat == "First Wort") || ($useat == "First wort")) { + $fmoment = 1.1; // Brouwhulp, Louis, Ozzie + $moment = "First wort"; + } else if ($useat == "Aroma") { + $fmoment = 0.0; // Brouwhulp 1.0 redeneert vlamuit. + $moment = "Vlamuit"; + } + + $pfactor = 1.0; + if ($form == "Pellet") { + $pfactor = 1.1; + } + + /* Tinseth only for now */ + $AddedAlphaAcids = (($alpha / 100) * $mass * 1000) / floatval($row['batch_size']); + $Bigness_factor = 1.65 * pow( 0.000125, floatval($row['est_og']) - 1); + $BoilTime_factor = ((1 - exp(-0.04 * $time)) / 4.15); + $utiisation = $Bigness_factor * $BoilTime_factor; + $ibu = (round($utiisation * $AddedAlphaAcids * $fmoment * $pfactor * 10) / 10.0); + + $this->Cell($vul,5,$name,0,0,'L',true); + $this->Cell(35,5,$origin,0,0,'L',true); + $this->Cell(15,5,$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); + $this->Cell(18,5,sprintf("%.1f",$amount),0,0,'R',true); + $this->Cell(20,5,sprintf("%8.3f",$cost).EURO,0,0,'R',true); + $this->Ln(); + } + + $this->SetFillColor(210,245,255); + $this->Cell($vul+97,5,'',0,0,'L',false); + $this->Cell(18,5,sprintf("%.1f",$total_hops),0,0,'R',true); + $this->Cell(20,5,sprintf("%8.3f",$cost_hops).EURO,0,0,'R',true); + $this->Ln(); + $this->ProcessingTable=false; + $this->cMargin=$cMargin; + $this->aCols=array(); + } + + function TableYeasts($row) { + global $cost_yeasts; + $vul = $this->w - $this->rMargin - $this->lMargin - 140; + $this->AddCol(27,'Laboratorium','L'); + $this->AddCol(18,'Product','L'); + $this->AddCol($vul,'Gist','L'); + $this->AddCol(20,'Gebruik','L'); + $this->AddCol(15,'Attn','R'); + $this->AddCol(22,'Vorm','L'); + $this->AddCol(18,'Gram','R'); + $this->AddCol(20,'Prijs','R'); + + $cMargin=$this->cMargin; + $this->cMargin=2; + $this->TableX=$this->lMargin; + $this->TableHeader(); + $this->ProcessingTable=true; + + $this->SetFont('Helvetica','',9); + $this->SetFillColor(175, 175, 255); + $svg = 70; /* Conservative SVG% as default */ + + $arr = json_decode($row['json_yeasts'], true); + foreach($arr as $item) { //foreach element in $arr + $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_yeasts += $cost; + + if ($use == "Primary") { + $svg = $attenuation; + $gebruik = 'Hoofdgist'; + } else if ($use == "Bottle") + $gebruik = 'Bottelgist'; + else + $gebruik = $use; + + if ($form == "Liquid") + $vorm = 'Vloeibaar'; + else if ($form == "Dry") + $vorm = 'Droog'; + else if ($form == "Slant") + $vorm = 'Schuine buis'; + else if ($form == "Culture") + $vorm = 'Slurry'; + else if ($form == "Frozen") + $vorm = 'Ingevroren'; + else if ($form == "Bottel") + $vorm = 'Depot'; + else + $vorm = $form; + + $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,$gebruik,0,0,'L',true); + $this->Cell(15,5,sprintf("%.1f%%",$attenuation),0,0,'R',true); + $this->Cell(22,5,$vorm,0,0,'L',true); + $this->Cell(18,5,sprintf("%.1f",$amount),0,0,'R',true); + $this->Cell(20,5,sprintf("%8.3f",$cost).EURO,0,0,'R',true); + $this->Ln(); + } + + $this->SetFillColor(210,245,255); + $this->Cell($vul+120,5,'',0,0,'L',false); + $this->Cell(20,5,sprintf("%8.3f",$cost_yeasts).EURO,0,0,'R',true); + $this->Ln(); + + $og = floatval($row['est_og']); + $fg = $og - ($svg * ($og - 1.0)) / 100; + $this->Cell(0,5,'FG: '.sprintf("%5.3f",$fg),0,0,'L',false); + $this->Ln(); + $this->ProcessingTable=false; + $this->cMargin=$cMargin; + $this->aCols=array(); + } + + /* + MiscColor:= RGBtoColor(240, 250, 65); + WaterAgentColor:= RGBtoColor(240, 140, 130); + FiningColor:= RGBtoColor(95, 180, 25); + WaterColor:= RGBtoColor(120, 255, 250); + */ + function TableMiscs($row) { + global $cost_miscs; + $vul = $this->w - $this->rMargin - $this->lMargin - 135; + } } @@ -188,13 +391,18 @@ */ $pdf = new PDF(); $pdf->AddPage(); -$prop = array('HeaderColor'=>array(255,150,100), 'color1'=>array(210,245,255), - 'color2'=>array(255,255,210), 'TotalColor'=>array(255,150,100), 'padding'=>2); -$pdf->TableGlobal($row,$prop); +$pdf->TableGlobal($row); +$pdf->Ln(10); +$pdf->TableFermentables($row); $pdf->Ln(10); -$pdf->TableFermentables($row,$prop); +$pdf->TableHops($row); +$pdf->Ln(10); +$pdf->TableYeasts($row); +$pdf->Ln(10); +$pdf->TableMiscs($row); //$pdf->SetFont('Helvetica','',10); //$pdf->Cell(0,10,'Receptje '.$record,0,1,'C'); - +// Disclaimer toeveogen dat dit alleen recept ontwikkeling is. +// Footer sectie met berekende/geschatte uitkomsten zoals FG, ABV, kostprijs per liter enz. $pdf->Output();