1 <?php |
|
2 require_once($_SERVER['DOCUMENT_ROOT'].'/includes/global.inc.php'); |
|
3 require_once($_SERVER['DOCUMENT_ROOT'].'/includes/formulas.php'); |
|
4 require_once($_SERVER['DOCUMENT_ROOT'].'/includes/constants.php'); |
|
5 require_once($_SERVER['DOCUMENT_ROOT'].'/fpdf/fpdf.php'); |
|
6 |
|
7 |
|
8 $link = mysqli_connect(DBASE_HOST,DBASE_USER,DBASE_PASS,DBASE_NAME); |
|
9 if (! $link) { |
|
10 die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); |
|
11 } |
|
12 if (! mysqli_set_charset($link, "utf8" )) { |
|
13 echo "error"; |
|
14 return 1; |
|
15 } |
|
16 |
|
17 setlocale ( LC_ALL, 'nl_NL.UTF-8'); |
|
18 $record = $_GET["record"]; |
|
19 $result = mysqli_query($link, "SELECT * FROM recipes WHERE record='".$record."'"); |
|
20 $row = mysqli_fetch_array($result); |
|
21 |
|
22 $total_fermentables = 0.0; |
|
23 $cost_fermentables = 0.0; |
|
24 $total_hops = 0.0; |
|
25 $cost_hops = 0.0; |
|
26 $cost_yeasts = 0.0; |
|
27 $cost_miscs = 0.0; |
|
28 $pSugar = 0; |
|
29 $pCara = 0; |
|
30 $svg = 77; |
|
31 $colorw = 0; |
|
32 $total_ibus = 0; |
|
33 $preboil_sg = 0; |
|
34 date_default_timezone_set('Europe/Amsterdam'); |
|
35 $prdate = date(DATE_RFC2822); |
|
36 |
|
37 class PDF_MySQL_Table extends FPDF |
|
38 { |
|
39 protected $ProcessingTable=false; |
|
40 protected $aCols=array(); |
|
41 protected $TableX; |
|
42 |
|
43 function Header() { |
|
44 // Print the table header if necessary |
|
45 if ($this->ProcessingTable) |
|
46 $this->TableHeader(); |
|
47 } |
|
48 |
|
49 function TableHeader() { |
|
50 $this->SetFont('Helvetica','B',9); |
|
51 $this->SetX($this->TableX); |
|
52 $this->SetFillColor(255,150,100); |
|
53 foreach($this->aCols as $col) |
|
54 $this->Cell($col['w'],5,$col['c'],0,0,$col['a'],true); |
|
55 $this->Ln(); |
|
56 } |
|
57 |
|
58 function AddCol($width=-1, $caption='', $align='L') { |
|
59 $this->aCols[]=array('c'=>$caption,'w'=>$width,'a'=>$align); |
|
60 } |
|
61 |
|
62 function TableGlobal($row) { |
|
63 /* 2 Columns */ |
|
64 global $recipetype; |
|
65 $vul = $this->w - $this->rMargin - $this->lMargin - 120; |
|
66 $cMargin=$this->cMargin; |
|
67 $this->cMargin=2; |
|
68 $this->TableX=$this->lMargin; |
|
69 $this->SetFont('Helvetica','B',9); |
|
70 $this->SetX($this->TableX); |
|
71 $this->SetFillColor(255,150,100); |
|
72 $this->Cell(0, 5, 'Recept overzicht',0,0,'C',true); |
|
73 $this->Ln(); |
|
74 |
|
75 $this->SetFont('Helvetica','',9); |
|
76 $this->SetFillColor(210,245,255); |
|
77 |
|
78 $this->SetX($this->TableX); |
|
79 $this->Cell(35,5,'Type',0,0,'L',true); |
|
80 $this->Cell(25,5,$recipetype[$row['type']],0,0,'L',true); |
|
81 $this->Cell($vul,5,'',0,0,'L',false); |
|
82 $this->Cell(35,5,'Batch grootte',0,0,'L',true); |
|
83 $this->Cell(25,5,$row['batch_size'].' liter',0,0,'L',true); |
|
84 $this->Ln(); |
|
85 |
|
86 $this->SetX($this->TableX); |
|
87 $this->Cell(35,5,'Kooktijd',0,0,'L',true); |
|
88 $this->Cell(25,5,$row['boil_time'].' minuten',0,0,'L',true); |
|
89 $this->Cell($vul,5,'',0,0,'L',false); |
|
90 $this->Cell(35,5,'Brouwzaal rendement',0,0,'L',true); |
|
91 $this->Cell(25,5,$row['efficiency'].' %',0,0,'L',true); |
|
92 $this->Ln(); |
|
93 |
|
94 $this->cMargin=$cMargin; |
|
95 } |
|
96 |
|
97 function TableFermentables($row) { |
|
98 global $cost_fermentables; |
|
99 global $total_fermentables; |
|
100 global $pSugar; |
|
101 global $pCara; |
|
102 global $colorw; |
|
103 global $preboil_sg; |
|
104 global $added; |
|
105 global $fermentabletype; |
|
106 global $graintype; |
|
107 $vul = $this->w - $this->rMargin - $this->lMargin - 125; |
|
108 $this->Ln(); |
|
109 $this->AddCol($vul,'Mout, granen en suikers','L'); |
|
110 $this->AddCol(15,'Procent','R'); |
|
111 $this->AddCol(15,'Opbr.','R'); |
|
112 $this->AddCol(25,'Soort', 'L'); |
|
113 $this->AddCol(30,'Gebruik moment','L'); |
|
114 $this->AddCol(20,'Hoeveel','R'); |
|
115 $this->AddCol(20,'Prijs','R'); |
|
116 |
|
117 $cMargin=$this->cMargin; |
|
118 $this->cMargin=2; |
|
119 $this->TableX=$this->lMargin; |
|
120 $this->TableHeader(); |
|
121 $this->ProcessingTable=true; |
|
122 |
|
123 $sugarsf = 0; |
|
124 $sugarsm = 0; |
|
125 $this->SetFont('Helvetica','',9); |
|
126 $this->SetFillColor(250, 195, 65); |
|
127 $arr = json_decode($row['json_fermentables'], true); |
|
128 foreach($arr as $item) { //foreach element in $arr |
|
129 $name = iconv('UTF-8','windows-1252',$item['f_name']); |
|
130 $supplier = iconv('UTF-8','windows-1252',$item['f_supplier']); |
|
131 $amount = floatval($item['f_amount']); |
|
132 $costkg = floatval($item['f_cost']); |
|
133 $yield = floatval($item['f_yield']); |
|
134 $moisture = floatval($item['f_moisture']); |
|
135 $color = floatval($item['f_color']); |
|
136 $percent = floatval($item['f_percentage']); |
|
137 |
|
138 if ($item['f_type'] == 1) // Sugar |
|
139 $pSugar += $percent; |
|
140 if ($item['f_graintype'] == 2) // Crystal |
|
141 $pCara += $percent; |
|
142 |
|
143 if ($item['f_type'] == 0) |
|
144 $soort = iconv('UTF-8','windows-1252',$graintype[$item['f_graintype']]); |
|
145 else |
|
146 $soort = iconv('UTF-8','windows-1252',$fermentabletype[$item['f_type']]); |
|
147 |
|
148 $cost = $amount * $costkg; |
|
149 $cost_fermentables += $cost; |
|
150 $total_fermentables += $amount; |
|
151 /* Calculate the amount of sugars */ |
|
152 $d = $amount * ($yield / 100) * (1 - $moisture / 100); |
|
153 if ($item['f_added'] == 0) { // Mash |
|
154 $d = floatval($row['efficiency']) / 100 * $d; |
|
155 $sugarsm += $d; |
|
156 } |
|
157 $sugarsf += $d; |
|
158 $colorw += ($amount * ebc_to_srm($color) / $row['batch_size']) * 8.34436; |
|
159 |
|
160 if ($amount > 100) |
|
161 $amount = sprintf("%.1f",$amount).' kg'; |
|
162 else if ($amount > 10) |
|
163 $amount = sprintf("%.2f",$amount).' kg'; |
|
164 else |
|
165 $amount = sprintf("%.0f",$amount * 1000).' gr'; |
|
166 $this->Cell($vul,5,$name.' ('.$supplier.') '.sprintf("%.0f",$color).' EBC',0,0,'L',true); |
|
167 $this->Cell(15,5,sprintf("%.1f%%",$percent),0,0,'R',true); |
|
168 $this->Cell(15,5,sprintf("%.1f%%",$yield),0,0,'R',true); |
|
169 $this->Cell(25,5,$soort,0,0,'L',true); |
|
170 $this->Cell(30,5,$added[$item['f_added']],0,0,'L',true); |
|
171 $this->Cell(20,5,$amount,0,0,'R',true); |
|
172 $this->Cell(20,5,sprintf("%.3f",$cost).EURO,0,0,'R',true); |
|
173 $this->Ln(); |
|
174 } |
|
175 |
|
176 $row['est_og'] = estimate_sg($sugarsf, floatval($row['batch_size'])); |
|
177 $preboil_sg = estimate_sg($sugarsm, floatval($row['boil_size'])); |
|
178 $this->SetFillColor(210,245,255); |
|
179 $this->Cell($vul+105,5,'',0,0,'L',false); |
|
180 $this->Cell(20,5,sprintf("%.3f",$cost_fermentables).EURO,0,0,'R',true); |
|
181 $this->ProcessingTable=false; |
|
182 $this->cMargin=$cMargin; |
|
183 $this->aCols=array(); |
|
184 $this->Ln(); |
|
185 } |
|
186 |
|
187 function TableHops($row) { |
|
188 global $total_hops; |
|
189 global $total_ibus; |
|
190 global $cost_hops; |
|
191 global $preboil_sg; |
|
192 global $hopform; |
|
193 global $hopuse; |
|
194 $vul = $this->w - $this->rMargin - $this->lMargin - 122; |
|
195 $this->Ln(); |
|
196 $this->AddCol($vul,'Hop','L'); |
|
197 $this->AddCol(15,'Alpha','R'); |
|
198 $this->AddCol(12,'IBU','R'); |
|
199 $this->AddCol(25,'Soort','L'); |
|
200 $this->AddCol(30,'Gebruik moment','L'); |
|
201 $this->AddCol(20,'Hoeveel','R'); |
|
202 $this->AddCol(20,'Prijs','R'); |
|
203 |
|
204 $cMargin=$this->cMargin; |
|
205 $this->cMargin=2; |
|
206 $this->TableX=$this->lMargin; |
|
207 $this->TableHeader(); |
|
208 $this->ProcessingTable=true; |
|
209 |
|
210 $this->SetFont('Helvetica','',9); |
|
211 $this->SetFillColor(100, 250, 65); |
|
212 |
|
213 $arr = json_decode($row['json_hops'], true); |
|
214 foreach($arr as $item) { //foreach element in $arr |
|
215 $name = iconv('UTF-8','windows-1252',$item['h_name']); |
|
216 $origin = iconv('UTF-8','windows-1252',$item['h_origin']); |
|
217 $amount = floatval($item['h_amount']); |
|
218 $mass = $amount * 1000; |
|
219 $costkg = floatval($item['h_cost']); |
|
220 $time = floatval($item['h_time']); |
|
221 $alpha = floatval($item['h_alpha']); |
|
222 |
|
223 $cost = ($amount * $costkg); |
|
224 $cost_hops += $cost; |
|
225 $total_hops += $amount; |
|
226 |
|
227 $moment = $hopuse[$item['h_useat']]; |
|
228 if (($item['h_useat'] == 2) || ($item['h_useat'] == 4)) { // Boil or Whirlpool |
|
229 $moment = $hopuse[$item['h_useat']].' '.$time." min"; |
|
230 } else if ($item['h_useat'] == 5) { // Dryhop |
|
231 $moment = $hopuse[$item['h_useat']].' '.sprintf("%.0f", $time / 1440).' dagen'; |
|
232 } |
|
233 $ibu = calc_IBU($item['h_useat'], $item['h_form'], $preboil_sg, floatval($row['batch_size']), $mass, $time, $alpha, |
|
234 $row['ibu_method'], $row['brew_whirlpool9'], $row['brew_whirlpool7'], $row['brew_whirlpool6']); |
|
235 $total_ibus += $ibu; |
|
236 |
|
237 if ($amount > 1) |
|
238 $amount = sprintf("%.3f",$amount).' kg'; |
|
239 else |
|
240 $amount = sprintf("%.1f",$amount * 1000).' gr'; |
|
241 |
|
242 $this->Cell($vul,5,$name.' ('.$origin.')',0,0,'L',true); |
|
243 $this->Cell(15,5,sprintf("%.1f%%",$alpha),0,0,'R',true); |
|
244 $this->Cell(12,5,sprintf("%.1f",$ibu),0,0,'R',true); |
|
245 $this->Cell(25,5,$hopform[$item['h_form']],0,0,'L',true); |
|
246 $this->Cell(30,5,$moment,0,0,'L',true); |
|
247 $this->Cell(20,5,$amount,0,0,'R',true); |
|
248 $this->Cell(20,5,sprintf("%.3f",$cost).EURO,0,0,'R',true); |
|
249 $this->Ln(); |
|
250 } |
|
251 |
|
252 $this->SetFillColor(210,245,255); |
|
253 $this->Cell($vul+102,5,'',0,0,'L',false); |
|
254 $this->Cell(20,5,sprintf("%.3f",$cost_hops).EURO,0,0,'R',true); |
|
255 $this->ProcessingTable=false; |
|
256 $this->cMargin=$cMargin; |
|
257 $this->aCols=array(); |
|
258 $this->Ln(); |
|
259 } |
|
260 |
|
261 function TableYeasts($row) { |
|
262 global $cost_yeasts; |
|
263 global $svg; |
|
264 global $yeastform; |
|
265 global $yeastuse; |
|
266 $vul = $this->w - $this->rMargin - $this->lMargin - 110; |
|
267 $this->Ln(); |
|
268 $this->AddCol($vul,'Gist','L'); |
|
269 $this->AddCol(15,'Attn','R'); |
|
270 $this->AddCol(25,'Soort','L'); |
|
271 $this->AddCol(30,'Gebruik moment','L'); |
|
272 $this->AddCol(20,'Hoeveel','R'); |
|
273 $this->AddCol(20,'Prijs','R'); |
|
274 |
|
275 $cMargin=$this->cMargin; |
|
276 $this->cMargin=2; |
|
277 $this->TableX=$this->lMargin; |
|
278 $this->TableHeader(); |
|
279 $this->ProcessingTable=true; |
|
280 |
|
281 $this->SetFont('Helvetica','',9); |
|
282 $this->SetFillColor(175, 175, 255); |
|
283 |
|
284 $arr = json_decode($row['json_yeasts'], true); |
|
285 foreach($arr as $item) { //foreach element in $arr |
|
286 $name = iconv('UTF-8','windows-1252',$item['y_name']); |
|
287 $laboratory = iconv('UTF-8','windows-1252',$item['y_laboratory']); |
|
288 $product_id = iconv('UTF-8','windows-1252',$item['y_product_id']); |
|
289 $attenuation = floatval($item['y_attenuation']); |
|
290 $cost = floatval($item['y_amount']) * floatval($item['y_cost']); |
|
291 $cost_yeasts += $cost; |
|
292 |
|
293 if ($item['y_use'] == 0) // Primary |
|
294 $svg = $attenuation; |
|
295 |
|
296 if ($item['y_form'] == 0) // Liquid |
|
297 $amount = sprintf("%.0f",floatval($item['y_amount']))." pak"; |
|
298 else if ($item['y_form'] == 1 || $item['y_form'] == 6) // Dry |
|
299 $amount = sprintf("%.1f",floatval($item['y_amount'])*1000)." gr"; |
|
300 else |
|
301 $amount = sprintf("%.0f",floatval($item['y_amount'])*1000)." ml"; |
|
302 $this->Cell($vul,5,$laboratory.' '.$product_id.' ('.$name.')',0,0,'L',true); |
|
303 $this->Cell(15,5,sprintf("%.1f%%",$attenuation),0,0,'R',true); |
|
304 $this->Cell(25,5,$yeastform[$item['y_form']],0,0,'L',true); |
|
305 $this->Cell(30,5,$yeastuse[$item['y_use']],0,0,'L',true); |
|
306 $this->Cell(20,5,$amount,0,0,'R',true); |
|
307 $this->Cell(20,5,sprintf("%8.3f",$cost).EURO,0,0,'R',true); |
|
308 $this->Ln(); |
|
309 } |
|
310 |
|
311 $this->SetFillColor(210,245,255); |
|
312 $this->Cell($vul+90,5,'',0,0,'L',false); |
|
313 $this->Cell(20,5,sprintf("%8.3f",$cost_yeasts).EURO,0,0,'R',true); |
|
314 $this->ProcessingTable=false; |
|
315 $this->cMargin=$cMargin; |
|
316 $this->aCols=array(); |
|
317 $this->Ln(); |
|
318 } |
|
319 |
|
320 function TableMiscs($row) { |
|
321 global $cost_miscs; |
|
322 global $misctype; |
|
323 global $miscuse; |
|
324 $vul = $this->w - $this->rMargin - $this->lMargin - 95; |
|
325 if ($this->GetY() > 200) |
|
326 $this->AddPage(); |
|
327 else |
|
328 $this->Ln(); |
|
329 $this->AddCol($vul,'Naam','L'); |
|
330 $this->AddCol(25,'Soort','L'); |
|
331 $this->AddCol(30,'Gebruik moment','L'); |
|
332 $this->AddCol(20,'Hoeveel','R'); |
|
333 $this->AddCol(20,'Prijs','R'); |
|
334 |
|
335 $cMargin=$this->cMargin; |
|
336 $this->cMargin=2; |
|
337 $this->TableX=$this->lMargin; |
|
338 $this->TableHeader(); |
|
339 $this->ProcessingTable=true; |
|
340 |
|
341 $this->SetFont('Helvetica','',9); |
|
342 $this->SetFillColor(175, 175, 255); |
|
343 |
|
344 $arr = json_decode($row['json_miscs'], true); |
|
345 foreach($arr as $item) { |
|
346 $name = iconv('UTF-8','windows-1252',$item['m_name']); |
|
347 $type = $item['m_type']; |
|
348 $use_use = $item['m_use_use']; |
|
349 $amount = floatval($item['m_amount']) * 1000; |
|
350 $costg = floatval($item['m_cost']) / 1000; |
|
351 $time = floatval($item['m_time']); |
|
352 $aiw = $item['m_amount_is_weight']; |
|
353 $cost = $amount * $costg; |
|
354 $cost_miscs += $cost; |
|
355 |
|
356 if ($type == 4) // Water agent |
|
357 $this->SetFillColor(240,140,130); |
|
358 else if ($type == 3) // Fining |
|
359 $this->SetFillColor(95,180,25); |
|
360 else if (($type == 0) || ($type == 1) || ($type == 2) || ($type == 5)) // Spice, Herb, Flavour, Yeast nutrient |
|
361 $this->SetFillColor(240,250,65); |
|
362 else |
|
363 $this->SetFillColor(210,245,255); |
|
364 |
|
365 if ($use_use == 2) // Boil |
|
366 $gebruik = sprintf("%s %d min",$miscuse[$use_use],$time); |
|
367 else |
|
368 $gebruik = $miscuse[$use_use]; |
|
369 |
|
370 $hoeveel = sprintf("%.1f %s",$amount,$aiw ? "gr":"ml"); |
|
371 $this->Cell($vul,5,$name,0,0,'L',true); |
|
372 $this->Cell(25,5,$misctype[$type],0,0,'L',true); |
|
373 $this->Cell(30,5,$gebruik,0,0,'L',true); |
|
374 $this->Cell(20,5,$hoeveel,0,0,'R',true); |
|
375 $this->Cell(20,5,sprintf("%8.3f",$cost).EURO,0,0,'R',true); |
|
376 $this->Ln(); |
|
377 } |
|
378 |
|
379 $this->SetFillColor(210,245,255); |
|
380 $this->Cell($vul+75,5,'',0,0,'L',false); |
|
381 $this->Cell(20,5,sprintf("%8.3f",$cost_miscs).EURO,0,0,'R',true); |
|
382 |
|
383 $this->ProcessingTable=false; |
|
384 $this->cMargin=$cMargin; |
|
385 $this->aCols=array(); |
|
386 $this->Ln(); |
|
387 } |
|
388 |
|
389 function TableMashs($row) { |
|
390 global $cost_yeasts; |
|
391 global $svg; |
|
392 global $mashkg; |
|
393 global $mashtype; |
|
394 $vul = $this->w - $this->rMargin - $this->lMargin - 138; |
|
395 if ($this->GetY() > 250) |
|
396 $this->AddPage(); |
|
397 else |
|
398 $this->Ln(); |
|
399 $this->AddCol($vul,'Maisch stap naam','L'); |
|
400 $this->AddCol(25,'Stap type','L'); |
|
401 $this->AddCol(16,'Start '.DEG.'C','R'); |
|
402 $this->AddCol(16,'Eind '.DEG.'C','R'); |
|
403 $this->AddCol(15,'Rust min','R'); |
|
404 $this->AddCol(15,'Stap min','R'); |
|
405 $this->AddCol(15,'L/Kg','R'); |
|
406 $this->AddCol(18,'Inf/dec L','R'); |
|
407 $this->AddCol(18,'Inf/dec '.DEG.'C','R'); |
|
408 |
|
409 $cMargin=$this->cMargin; |
|
410 $this->cMargin=2; |
|
411 $this->TableX=$this->lMargin; |
|
412 $this->TableHeader(); |
|
413 $this->ProcessingTable=true; |
|
414 |
|
415 $this->SetFont('Helvetica','',9); |
|
416 $this->SetFillColor(175, 175, 255); |
|
417 |
|
418 $vol = 0; |
|
419 $arr = json_decode($row['json_mashs'], true); |
|
420 foreach($arr as $item) { //foreach element in $arr |
|
421 |
|
422 if ($item['step_type'] == 0) |
|
423 $vol += $item['step_infuse_amount']; |
|
424 if ($mashkg > 0) |
|
425 $thick = $vol / $mashkg; |
|
426 else |
|
427 $thick = 0; |
|
428 $this->Cell($vul,5,$item['step_name'],0,0,'L',true); |
|
429 $this->Cell(25,5,$mashtype[$item['step_type']],0,0,'L',true); |
|
430 $this->Cell(16,5,sprintf("%.1f",$item['step_temp']),0,0,'R',true); |
|
431 $this->Cell(16,5,sprintf("%.1f",$item['end_temp']),0,0,'R',true); |
|
432 $this->Cell(15,5,sprintf("%.0f",$item['step_time']),0,0,'R',true); |
|
433 $this->Cell(15,5,sprintf("%.0f",$item['ramp_time']),0,0,'R',true); |
|
434 $this->Cell(15,5,sprintf("%.2f",$thick),0,0,'R',true); |
|
435 if ($item['step_type'] == 1) { |
|
436 $this->Cell(18,5,' ',0,0,'R',true); |
|
437 $this->Cell(18,5,' ',0,0,'R',true); |
|
438 } else { |
|
439 $this->Cell(18,5,sprintf("%.1f",$item['step_infuse_amount']),0,0,'R',true); |
|
440 $this->Cell(18,5,sprintf("%.1f",$item['step_infuse_temp']),0,0,'R',true); |
|
441 } |
|
442 $this->Ln(); |
|
443 } |
|
444 $this->ProcessingTable=false; |
|
445 $this->cMargin=$cMargin; |
|
446 $this->aCols=array(); |
|
447 $this->Ln(); |
|
448 } |
|
449 |
|
450 function TableWaters($row) { |
|
451 |
|
452 $vul = $this->w - $this->rMargin - $this->lMargin - 137; |
|
453 if ($this->GetY() > 250) |
|
454 $this->AddPage(); |
|
455 else |
|
456 $this->Ln(); |
|
457 $this->AddCol($vul,'Water bron','L'); |
|
458 $this->AddCol(20,'Volume','R'); |
|
459 $this->AddCol(15,'Ca','R'); |
|
460 $this->AddCol(15,'Mg','R'); |
|
461 $this->AddCol(15,'Na','R'); |
|
462 $this->AddCol(15,'CaCO3','R'); |
|
463 $this->AddCol(15,'Cl','R'); |
|
464 $this->AddCol(15,'SO4','R'); |
|
465 $this->AddCol(15,'pH','R'); |
|
466 |
|
467 $cMargin=$this->cMargin; |
|
468 $this->cMargin=2; |
|
469 $this->TableX=$this->lMargin; |
|
470 $this->TableHeader(); |
|
471 $this->ProcessingTable=true; |
|
472 |
|
473 $this->SetFont('Helvetica','',9); |
|
474 $this->SetFillColor(120, 255, 250); |
|
475 |
|
476 $this->Cell($vul,5,$row['w1_name'],0,0,'L',true); |
|
477 $this->Cell(20,5,sprintf("%.1f", $row['w1_amount']).' L',0,0,'R',true); |
|
478 $this->Cell(15,5,sprintf("%.1f", $row['w1_calcium']),0,0,'R',true); |
|
479 $this->Cell(15,5,sprintf("%.1f", $row['w1_magnesium']),0,0,'R',true); |
|
480 $this->Cell(15,5,sprintf("%.1f", $row['w1_sodium']),0,0,'R',true); |
|
481 $this->Cell(15,5,sprintf("%.1f", $row['w1_total_alkalinity']),0,0,'R',true); |
|
482 $this->Cell(15,5,sprintf("%.1f", $row['w1_chloride']),0,0,'R',true); |
|
483 $this->Cell(15,5,sprintf("%.1f", $row['w1_sulfate']),0,0,'R',true); |
|
484 $this->Cell(15,5,sprintf("%.1f", $row['w1_ph']),0,0,'R',true); |
|
485 $this->Ln(); |
|
486 $this->Cell($vul,5,$row['w2_name'],0,0,'L',true); |
|
487 $this->Cell(20,5,sprintf("%.1f", $row['w2_amount']).' L',0,0,'R',true); |
|
488 $this->Cell(15,5,sprintf("%.1f", $row['w2_calcium']),0,0,'R',true); |
|
489 $this->Cell(15,5,sprintf("%.1f", $row['w2_magnesium']),0,0,'R',true); |
|
490 $this->Cell(15,5,sprintf("%.1f", $row['w2_sodium']),0,0,'R',true); |
|
491 $this->Cell(15,5,sprintf("%.1f", $row['w2_total_alkalinity']),0,0,'R',true); |
|
492 $this->Cell(15,5,sprintf("%.1f", $row['w2_chloride']),0,0,'R',true); |
|
493 $this->Cell(15,5,sprintf("%.1f", $row['w2_sulfate']),0,0,'R',true); |
|
494 $this->Cell(15,5,sprintf("%.1f", $row['w2_ph']),0,0,'R',true); |
|
495 $this->Ln(); |
|
496 $this->Cell($vul,5,'Gemengd water',0,0,'L',true); |
|
497 $this->Cell(20,5,sprintf("%.1f", $row['wg_amount']).' L',0,0,'R',true); |
|
498 $this->Cell(15,5,sprintf("%.1f", $row['wg_calcium']),0,0,'R',true); |
|
499 $this->Cell(15,5,sprintf("%.1f", $row['wg_magnesium']),0,0,'R',true); |
|
500 $this->Cell(15,5,sprintf("%.1f", $row['wg_sodium']),0,0,'R',true); |
|
501 $this->Cell(15,5,sprintf("%.1f", $row['wg_total_alkalinity']),0,0,'R',true); |
|
502 $this->Cell(15,5,sprintf("%.1f", $row['wg_chloride']),0,0,'R',true); |
|
503 $this->Cell(15,5,sprintf("%.1f", $row['wg_sulfate']),0,0,'R',true); |
|
504 $this->Cell(15,5,sprintf("%.1f", $row['wg_ph']),0,0,'R',true); |
|
505 $this->Ln(); |
|
506 $this->Cell($vul,5,'Behandeld water',0,0,'L',true); |
|
507 $this->Cell(20,5,'',0,0,'R',true); |
|
508 $this->Cell(15,5,sprintf("%.1f", $row['wb_calcium']),0,0,'R',true); |
|
509 $this->Cell(15,5,sprintf("%.1f", $row['wb_magnesium']),0,0,'R',true); |
|
510 $this->Cell(15,5,sprintf("%.1f", $row['wb_sodium']),0,0,'R',true); |
|
511 $this->Cell(15,5,sprintf("%.1f", $row['wb_total_alkalinity']),0,0,'R',true); |
|
512 $this->Cell(15,5,sprintf("%.1f", $row['wb_chloride']),0,0,'R',true); |
|
513 $this->Cell(15,5,sprintf("%.1f", $row['wb_sulfate']),0,0,'R',true); |
|
514 $this->Cell(15,5,sprintf("%.1f", $row['wb_ph']),0,0,'R',true); |
|
515 $this->ProcessingTable=false; |
|
516 $this->cMargin=$cMargin; |
|
517 $this->aCols=array(); |
|
518 $this->Ln(); |
|
519 } |
|
520 |
|
521 function TableSummary($row) { |
|
522 global $pSugar; |
|
523 global $pCara; |
|
524 global $svg; |
|
525 global $colorw; |
|
526 global $cost_fermentables; |
|
527 global $cost_hops; |
|
528 global $cost_miscs; |
|
529 global $cost_yeasts; |
|
530 global $colormethod; |
|
531 global $ibumethod; |
|
532 /* 2 Columns */ |
|
533 if ($this->GetY() > 200) |
|
534 $this->AddPage(); |
|
535 else |
|
536 $this->Ln(); |
|
537 $vul = $this->w - $this->rMargin - $this->lMargin - 170; |
|
538 $cMargin=$this->cMargin; |
|
539 $this->cMargin=2; |
|
540 $this->TableX=$this->lMargin; |
|
541 $this->SetFont('Helvetica','B',9); |
|
542 $this->SetX($this->TableX); |
|
543 $this->SetFillColor(255,150,100); |
|
544 $this->Cell(0, 5, 'Recept samenvatting',0,0,'C',true); |
|
545 $this->Ln(); |
|
546 |
|
547 $this->SetFont('Helvetica','',9); |
|
548 $this->SetFillColor(210,245,255); |
|
549 |
|
550 $row['est_fg'] = estimate_fg($pSugar, $pCara, 0, 0, 0, $svg, $row['est_og']); |
|
551 |
|
552 $this->SetX($this->TableX); |
|
553 $this->Cell(35,5,'Start SG',0,0,'L',true); |
|
554 $this->Cell(25,5,sprintf("%.3f",$row['est_og']),0,0,'L',true); |
|
555 $this->Cell(25,5,'('.sprintf("%.3f",$row['st_og_min']).' - '.sprintf("%.3f",$row['st_og_max']).')',0,0,'L',true); |
|
556 $this->Cell($vul,5,'',0,0,'L',false); |
|
557 $this->Cell(35,5,'Eind SG',0,0,'L',true); |
|
558 $this->Cell(25,5,sprintf("%.3f",$row['est_fg']),0,0,'L',true); |
|
559 $this->Cell(25,5,'('.sprintf("%.3f",$row['st_fg_min']).' - '.sprintf("%.3f",$row['st_fg_max']).')',0,0,'L',true); |
|
560 $this->Ln(); |
|
561 |
|
562 $row['est_abv'] = abvol($row['est_og'], $row['est_fg']); |
|
563 $this->SetX($this->TableX); |
|
564 $this->Cell(35,5,'Geschat alcohol',0,0,'L',true); |
|
565 $this->Cell(25,5,sprintf("%.1f",$row['est_abv']).'%',0,0,'L',true); |
|
566 $this->Cell(25,5,'('.sprintf("%.1f",$row['st_abv_min']).' - '.sprintf("%.1f",$row['st_abv_max']).'%)',0,0,'L',true); |
|
567 $this->Cell($vul,5,'',0,0,'L',false); |
|
568 $this->Cell(35,5,'CO2',0,0,'L',true); |
|
569 $this->Cell(25,5,sprintf("%.1f",$row['est_carb']).'%',0,0,'L',true); |
|
570 $this->Cell(25,5,'('.sprintf("%.1f",$row['st_carb_min']).' - '.sprintf("%.1f",$row['st_carb_max']).'%)',0,0,'L',true); |
|
571 $this->Ln(); |
|
572 |
|
573 $row['est_color'] = kw_to_ebc($row['color_method'], $colorw); |
|
574 $this->SetX($this->TableX); |
|
575 $this->Cell(35,5,'Kleur ('.$colormethod[$row['color_method']].')',0,0,'L',true); |
|
576 $beercolor = ebc_to_color($row['est_color']); |
|
577 if ($row['est_color'] > 30) |
|
578 $this->SetTextColor(250); |
|
579 $this->SetFillColor($beercolor[0],$beercolor[1],$beercolor[2]); |
|
580 $this->Cell(25,5,$row['est_color'].' EBC',0,0,'L',true); |
|
581 $this->Cell(25,5,'('.$row['st_color_min'].' - '.$row['st_color_max'].' EBC)',0,0,'L',true); |
|
582 $this->SetTextColor(0); |
|
583 $this->SetFillColor(210,245,255); |
|
584 $this->Cell($vul,5,'',0,0,'L',false); |
|
585 $this->Cell(35,5,'Bitterheid ('.$ibumethod[$row['ibu_method']].')',0,0,'L',true); |
|
586 $this->Cell(25,5,sprintf("%.0f",$row['est_ibu']).' IBU',0,0,'L',true); |
|
587 $this->Cell(25,5,'('.$row['st_ibu_min'].' - '.$row['st_ibu_max'].' IBU)',0,0,'L',true); |
|
588 $this->Ln(); |
|
589 |
|
590 $this->SetX($this->TableX); |
|
591 $cost_total = $cost_fermentables + $cost_hops + $cost_miscs + $cost_yeasts; |
|
592 $this->Cell(35,5,'Kosten',0,0,'L',true); |
|
593 $this->Cell(25,5,sprintf("%.2f",$cost_total).EURO,0,0,'L',true); |
|
594 $this->Cell(25,5,sprintf("%.2f",$cost_total/$row['batch_size']).EURO.' / liter',0,0,'L',true); |
|
595 |
|
596 // calorieen |
|
597 $this->ProcessingTable=false; |
|
598 $this->cMargin=$cMargin; |
|
599 $this->aCols=array(); |
|
600 $this->Ln(); |
|
601 } |
|
602 } |
|
603 |
|
604 |
|
605 |
|
606 class PDF extends PDF_MySQL_Table { |
|
607 function Header() { |
|
608 global $row; |
|
609 global $prdate; |
|
610 $this->Image('images/logo.png',10,6,30); |
|
611 // Title |
|
612 $this->SetFont('Helvetica','B',18); |
|
613 $this->SetX(45); |
|
614 $this->Cell(0,8,$row['name'],0,1,'L'); |
|
615 $this->Ln(1); |
|
616 $this->SetFont('Helvetica','',10); |
|
617 $this->SetX(45); |
|
618 $this->Cell(17,5,'Datum:',0,0,'L'); |
|
619 $this->Cell(0,5,$prdate,0,1,'L'); |
|
620 $this->SetX(45); |
|
621 $this->Cell(17,5,'Stijl:',0,0,'L'); |
|
622 $st_name = iconv('UTF-8','windows-1252',$row['st_name']); |
|
623 $this->Cell(0,5,$st_name,0,1,'L'); |
|
624 $this->Ln(7); |
|
625 // Ensure table header is printed |
|
626 parent::Header(); |
|
627 } |
|
628 } |
|
629 |
|
630 |
|
631 /* |
|
632 * Generate PDF from recipe data |
|
633 */ |
|
634 $pdf = new PDF(); |
|
635 $pdf->AddPage(); |
|
636 $pdf->TableGlobal($row); |
|
637 $pdf->TableFermentables($row); |
|
638 $pdf->TableHops($row); |
|
639 $pdf->TableYeasts($row); |
|
640 $pdf->TableMiscs($row); |
|
641 $pdf->TableMashs($row); |
|
642 $pdf->TableWaters($row); |
|
643 $pdf->TableSummary($row); |
|
644 if (strlen($row['notes'])) { |
|
645 if ($pdf->GetY() > 200) |
|
646 $pdf->AddPage(); |
|
647 else |
|
648 $pdf->Ln(10); |
|
649 $pdf->SetFillColor(255,150,100); |
|
650 $pdf->SetFont('Helvetica','B',9); |
|
651 $pdf->Cell(0, 5, 'Recept opmerkingen',0,0,'C',true); |
|
652 $pdf->Ln(); |
|
653 $pdf->SetFont('Helvetica','',9); |
|
654 $pdf->SetFillColor(210,245,255); |
|
655 $pdf->MultiCell(0,4,$row['notes'],0,'L',true); |
|
656 } |
|
657 // Disclaimer toevoegen dat dit alleen recept ontwikkeling is. Uitkomsten zoals IBU zijn een berekende schatting. |
|
658 // Footer sectie met berekende/geschatte uitkomsten zoals ABV, kostprijs per liter enz. |
|
659 $pdf->Output(); |
|