# HG changeset patch # User Michiel Broek # Date 1550151772 -3600 # Node ID fb1e88f1c64342dd1855c0576b3132cc00409a99 # Parent 65ca75fc4af8d3f9aa6dd12667ba1e2eeb4308f2 Better fg estimation in product print. diff -r 65ca75fc4af8 -r fb1e88f1c643 www/prod_print.php --- a/www/prod_print.php Wed Feb 13 21:10:38 2019 +0100 +++ b/www/prod_print.php Thu Feb 14 14:42:52 2019 +0100 @@ -30,6 +30,7 @@ $colorw = 0; $total_ibus = 0; $preboil_sg = 0; +$mashkg = 0; date_default_timezone_set('Europe/Amsterdam'); $prdate = date(DATE_RFC2822); @@ -109,6 +110,7 @@ global $pCara; global $colorw; global $preboil_sg; + global $mashkg; $added = array( 'Maischen', 'Koken', 'Vergisten', 'Nagisten/lageren', 'Bottelen' ); $vul = $this->w - $this->rMargin - $this->lMargin - 132; $this->AddCol($vul,'Grondstof','L'); @@ -128,6 +130,7 @@ $sugarsf = 0; $sugarsm = 0; + $mashkg = 0; $this->SetFont('Helvetica','',9); $this->SetFillColor(250, 195, 65); $arr = json_decode($row['json_fermentables'], true); @@ -154,6 +157,7 @@ if ($item['f_added'] == 0) { $d = floatval($row['efficiency']) / 100 * $d; $sugarsm += $d; + $mashkg += $amount; } $sugarsf += $d; $colorw += ($amount * ebc_to_srm($color) / $row['batch_size']) * 8.34436; @@ -389,6 +393,7 @@ global $cost_hops; global $cost_miscs; global $cost_yeasts; + global $mashkg; /* 2 Columns */ $vul = $this->w - $this->rMargin - $this->lMargin - 170; $cMargin=$this->cMargin; @@ -403,7 +408,25 @@ $this->SetFont('Helvetica','',9); $this->SetFillColor(210,245,255); - $row['est_fg'] = estimate_fg($pSugar, $pCara, 0, 0, 0, $svg, $row['est_og']); + $mashtime = 0; + $mashtemp = 0; + $mash_infuse = 0; + $arr = json_decode($row['json_mashs'], true); + foreach($arr as $item) { + if ($item['step_type'] == 0) { // infusion + $mash_infuse += floatval($item['step_infuse_amount']); + } + if ($item['step_temp'] < 75) { // ignore mashout temps + $mashtime += floatval($item['step_time']); + $mashtemp += floatval($item['step_time']) * floatval($item['step_temp']); + } + } + $mashtemp = $mashtemp / $mashtime; + if (($mashkg > 0) && ($mash_infuse > 0) && ($mashtime > 0) && ($mashtemp > 0)) { + $row['est_fg'] = estimate_fg($pSugar, $pCara, $mash_infuse / $mashkg, $mashtime, $mashtemp, $svg, $row['est_og']); + } else { + $row['est_fg'] = estimate_fg($pSugar, $pCara, 0, 0, 0, $svg, $row['est_og']); + } $this->SetX($this->TableX); $this->Cell(35,5,'Start SG',0,0,'L',true);