www/rec_print.php

changeset 85
ca7a37586551
parent 84
3e5e87f1818d
child 86
e977a505ea8c
equal deleted inserted replaced
84:3e5e87f1818d 85:ca7a37586551
139 $this->cMargin=2; 139 $this->cMargin=2;
140 $this->TableX=$this->lMargin; 140 $this->TableX=$this->lMargin;
141 $this->TableHeader(); 141 $this->TableHeader();
142 $this->ProcessingTable=true; 142 $this->ProcessingTable=true;
143 143
144 $sugf = 0;
145 $tot = 0;
144 $this->SetFont('Helvetica','',9); 146 $this->SetFont('Helvetica','',9);
145 $this->SetFillColor(250, 195, 65); 147 $this->SetFillColor(250, 195, 65);
146
147 $arr = json_decode($row['json_fermentables'], true); 148 $arr = json_decode($row['json_fermentables'], true);
148 foreach($arr as $item) { //foreach element in $arr 149 foreach($arr as $item) { //foreach element in $arr
149 $name = iconv('UTF-8','windows-1252',$item['f_name']); 150 $name = iconv('UTF-8','windows-1252',$item['f_name']);
150 $supplier = iconv('UTF-8','windows-1252',$item['f_supplier']); 151 $supplier = iconv('UTF-8','windows-1252',$item['f_supplier']);
151 $added = iconv('UTF-8','windows-1252',$item['f_added']); 152 $added = iconv('UTF-8','windows-1252',$item['f_added']);
152 $amount = floatval($item['f_amount']); 153 $amount = floatval($item['f_amount']);
153 $costkg = floatval($item['f_cost']); 154 $costkg = floatval($item['f_cost']);
154 $yield = floatval($item['f_yield']); 155 $yield = floatval($item['f_yield']);
156 $moisture = floatval($item['f_moisture']);
155 $color = floatval($item['f_color']); 157 $color = floatval($item['f_color']);
156 $percent = floatval($item['f_percentage']); 158 $percent = floatval($item['f_percentage']);
157 $cost = $amount * $costkg; 159 $cost = $amount * $costkg;
158 $cost_fermentables += $cost; 160 $cost_fermentables += $cost;
159 $total_fermentables += $amount; 161 $total_fermentables += $amount;
162 /* Calculate the amount of sugars */
163 $d = $amount * ($yield / 100) * (1 - $moisture / 100);
164 if ($added == "Mash")
165 $d = floatval($row['efficiency']) / 100 * $d;
166 $sugf += $d;
167 $tot += $amount;
168 //$plato = 100 * $d / $amount;
169 //$this->Cell(0,5,$tot.' sugf: '.$sugf.' d: '.$d.' pt: '.$plato.' moisture: '.$moisture,0,0,'L',false);
170 //$this->Ln();
171
160 $this->Cell($vul,5,$name,0,0,'L',true); 172 $this->Cell($vul,5,$name,0,0,'L',true);
161 $this->Cell(30,5,$supplier,0,0,'L',true); 173 $this->Cell(30,5,$supplier,0,0,'L',true);
162 $this->Cell(15,5,sprintf("%.0f",$color),0,0,'R',true); 174 $this->Cell(15,5,sprintf("%.0f",$color),0,0,'R',true);
163 $this->Cell(17,5,added_type_names($added),0,0,'L',true); 175 $this->Cell(17,5,added_type_names($added),0,0,'L',true);
164 $this->Cell(20,5,sprintf("%8.3f",$amount),0,0,'R',true); 176 $this->Cell(20,5,sprintf("%8.3f",$amount),0,0,'R',true);
166 $this->Cell(15,5,sprintf("%.1f%%",$yield),0,0,'R',true); 178 $this->Cell(15,5,sprintf("%.1f%%",$yield),0,0,'R',true);
167 $this->Cell(20,5,sprintf("%8.3f",$cost).EURO,0,0,'R',true); 179 $this->Cell(20,5,sprintf("%8.3f",$cost).EURO,0,0,'R',true);
168 $this->Ln(); 180 $this->Ln();
169 } 181 }
170 182
171 $this->SetFillColor(210,245,255); 183 $plato = 100 * $sugf / floatval($row['batch_size']);
172 $this->Cell($vul+62,5,'',0,0,'L',false); 184 $sg = plato_to_sg($plato);
185 /* Average loops, HansH 5x. Brouwhulp 20x, about 10x is enough so keep 20. */
186 for ($i = 0; $i < 20; $i++) {
187 if ($sg > 0)
188 $plato = 100 * $sugf / (floatval($row['batch_size']) * $sg);
189 $sg = plato_to_sg($plato);
190 }
191 $this->SetFillColor(210,245,255);
192 $this->Cell($vul,5,sprintf("%.1f",$plato).' Plato, OG: '.sprintf("%.3f",$sg),0,0,'L',true);
193 $this->Cell(62,5,'',0,0,'L',false);
173 $this->Cell(20,5,sprintf("%8.3f",$total_fermentables),0,0,'R',true); 194 $this->Cell(20,5,sprintf("%8.3f",$total_fermentables),0,0,'R',true);
174 $this->Cell(30,5,'',0,0,'L',false); 195 $this->Cell(30,5,'',0,0,'L',false);
175 $this->Cell(20,5,sprintf("%8.3f",$cost_fermentables).EURO,0,0,'R',true); 196 $this->Cell(20,5,sprintf("%8.3f",$cost_fermentables).EURO,0,0,'R',true);
176 $this->Ln(10); 197 $this->Ln(10);
177 $this->ProcessingTable=false; 198 $this->ProcessingTable=false;

mercurial