www/prod_print.php

changeset 817
6ee186182c70
parent 816
d76f623d487c
child 818
f9c071906643
equal deleted inserted replaced
816:d76f623d487c 817:6ee186182c70
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 products 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 $mashkg = 0;
35 date_default_timezone_set('Europe/Amsterdam');
36 $prdate = date(DATE_RFC2822);
37 $bottle_sugar = '';
38 $keg_sugar = '';
39 $bottle_sugar_amount = 0;
40 $keg_sugar_amount = 0;
41 $est_mash_sg = 0;
42
43 $divide_parts = $row['divide_parts'];
44 $divide_part = $row['divide_part'];
45 $divide_factor = floatval($row['divide_factor']);
46
47
48 class PDF_MySQL_Table extends FPDF
49 {
50 protected $ProcessingTable=false;
51 protected $aCols=array();
52 protected $TableX;
53
54 function Header() {
55 // Print the table header if necessary
56 if ($this->ProcessingTable)
57 $this->TableHeader();
58 }
59
60 function TableHeader() {
61 $this->SetFont('Helvetica','B',9);
62 $this->SetX($this->TableX);
63 $this->SetFillColor(255,150,100);
64 foreach($this->aCols as $col)
65 $this->Cell($col['w'],5,$col['c'],0,0,$col['a'],true);
66 $this->Ln();
67 }
68
69 function AddCol($width=-1, $caption='', $align='L') {
70 $this->aCols[]=array('c'=>$caption,'w'=>$width,'a'=>$align);
71 }
72
73 function TableGlobal($row) {
74 global $recipetype;
75 global $divide_parts;
76 global $divide_part;
77 global $divide_factor;
78 global $splitat;
79 /* 2 Columns */
80 $vul = $this->w - $this->rMargin - $this->lMargin - 160;
81 $cMargin=$this->cMargin;
82 $this->cMargin=2;
83 $this->TableX=$this->lMargin;
84 $this->SetFont('Helvetica','B',9);
85 $this->SetX($this->TableX);
86 $this->SetFillColor(255,150,100);
87 $this->Cell(0, 5, 'Recept overzicht',0,0,'C',true);
88 $this->Ln();
89
90 $this->SetFont('Helvetica','',9);
91 $this->SetFillColor(210,245,255);
92
93 $this->SetX($this->TableX);
94 $this->Cell(35,5,'Brouw type',0,0,'L',true);
95 $this->Cell(45,5,$recipetype[$row['type']],0,0,'L',true);
96 $this->Cell($vul,5,'',0,0,'L',false);
97 $this->Cell(35,5,'Batch grootte',0,0,'L',true);
98 if ($divide_parts == 0)
99 $this->Cell(45,5,$row['batch_size'].' liter',0,0,'L',true);
100 else
101 $this->Cell(45,5,$row['batch_size'].' van '.sprintf("%.2f", ($row['batch_size'] * (1 / $divide_factor))).' liter',0,0,'L',true);
102 $this->Ln();
103
104 $this->SetX($this->TableX);
105 $this->Cell(35,5,'Kooktijd',0,0,'L',true);
106 $this->Cell(45,5,$row['boil_time'].' minuten',0,0,'L',true);
107 $this->Cell($vul,5,'',0,0,'L',false);
108 $this->Cell(35,5,'Brouwzaal rendement',0,0,'L',true);
109 $this->Cell(45,5,$row['efficiency'].' %',0,0,'L',true);
110 $this->Ln();
111
112 $this->SetX($this->TableX);
113 $this->Cell(35,5,'Bierstijl',0,0,'L',true);
114 $st_name = iconv('UTF-8','windows-1252',$row['st_name']);
115 $this->Cell(45,5,$st_name,0,0,'L',true);
116 $this->Cell($vul,5,'',0,0,'L',false);
117 $this->Cell(35,5,'Installatie',0,0,'L',true);
118 $this->Cell(45,5,$row['eq_name'],0,0,'L',true);
119 $this->Ln();
120
121 if ($divide_parts) {
122 $this->SetX($this->TableX);
123 $this->Cell(35,5,'Batch splits moment',0,0,'L',true);
124 $this->Cell(45,5,$splitat[$row['divide_type']],0,0,'L',true);
125 $this->Ln();
126 }
127
128 $this->cMargin=$cMargin;
129 }
130
131 function TableFermentables($row) {
132 global $cost_fermentables;
133 global $total_fermentables;
134 global $pSugar;
135 global $pCara;
136 global $colorw;
137 global $preboil_sg;
138 global $mashkg;
139 global $bottle_sugar;
140 global $bottle_sugar_amount;
141 global $keg_sugar;
142 global $keg_sugar_amount;
143 global $added;
144 global $fermentabletype;
145 global $graintype;
146 global $est_mash_sg;
147 $vul = $this->w - $this->rMargin - $this->lMargin - 125;
148 $this->Ln();
149 $this->AddCol($vul,'Mout, granen en suikers','L');
150 $this->AddCol(15,'Procent','R');
151 $this->AddCol(15,'Opbr.','R');
152 $this->AddCol(25,'Soort', 'L');
153 $this->AddCol(30,'Gebruik moment','L');
154 $this->AddCol(20,'Hoeveel','R');
155 $this->AddCol(20,'Prijs','R');
156
157 $cMargin=$this->cMargin;
158 $this->cMargin=2;
159 $this->TableX=$this->lMargin;
160 $this->TableHeader();
161 $this->ProcessingTable=true;
162
163 $sugarsf = 0;
164 $sugarsm = 0;
165 $mashkg = 0;
166 $s = 0;
167 $this->SetFont('Helvetica','',9);
168 $this->SetFillColor(250, 195, 65);
169 $arr = json_decode($row['json_fermentables'], true);
170 foreach($arr as $item) { //foreach element in $arr
171 $name = iconv('UTF-8','windows-1252',$item['f_name']);
172 $supplier = iconv('UTF-8','windows-1252',$item['f_supplier']);
173 $amount = floatval($item['f_amount']);
174 $costkg = floatval($item['f_cost']);
175 $yield = floatval($item['f_yield']);
176 $moisture = floatval($item['f_moisture']);
177 $color = floatval($item['f_color']);
178 $percent = floatval($item['f_percentage']);
179
180 if ($item['f_type'] == 1) // Sugar
181 $pSugar += $percent;
182 if ($item['f_graintype'] == 2) // Crystal
183 $pCara += $percent;
184
185 if ($item['f_type'] == 0)
186 $soort = iconv('UTF-8','windows-1252',$graintype[$item['f_graintype']]);
187 else
188 $soort = iconv('UTF-8','windows-1252',$fermentabletype[$item['f_type']]);
189
190 if ($item['f_added'] == 4) {
191 $bottle_sugar = $name;
192 $bottle_sugar_amount = $amount;
193 }
194 if ($item['f_added'] == 5) {
195 $keg_sugar = $name;
196 $keg_sugar_amount = $amount;
197 }
198
199 $cost = $amount * $costkg;
200 $cost_fermentables += $cost;
201 $total_fermentables += $amount;
202 /* Calculate the amount of sugars */
203 $d = $amount * ($yield / 100) * (1 - $moisture / 100);
204 if ($item['f_added'] == 0) {
205 $s += $d;
206 $d = floatval($row['efficiency']) / 100 * $d;
207 $sugarsm += $d;
208 $mashkg += $amount;
209 }
210 $sugarsf += $d;
211 $colorw += ($amount * ebc_to_srm($color) / $row['batch_size']) * 8.34436;
212
213 if ($amount > 100)
214 $amount = sprintf("%.1f",$amount).' kg';
215 else if ($amount > 10)
216 $amount = sprintf("%.2f",$amount).' kg';
217 else
218 $amount = sprintf("%.0f",$amount * 1000).' gr';
219 $this->Cell($vul,5,$name.' ('.$supplier.') '.sprintf("%.0f",$color).' EBC',0,0,'L',true);
220 if ($item['f_added'] < 4)
221 $this->Cell(15,5,sprintf("%.1f%%",$percent),0,0,'R',true);
222 else
223 $this->Cell(15,5,' ',0,0,'R',true);
224 $this->Cell(15,5,sprintf("%.1f%%",$yield),0,0,'R',true);
225 $this->Cell(25,5,$soort,0,0,'L',true);
226 $this->Cell(30,5,$added[$item['f_added']],0,0,'L',true);
227 $this->Cell(20,5,$amount,0,0,'R',true);
228 $this->Cell(20,5,sprintf("%.3f",$cost).EURO,0,0,'R',true);
229 $this->Ln();
230 }
231 $v = $s / 1.611 + $row['wg_amount'];
232 $s = 1000 * $s / ($v * 10); //deg. Plato
233 $est_mash_sg = plato_to_sg($s);
234 $row['est_og'] = estimate_sg($sugarsf, floatval($row['batch_size']));
235 $preboil_sg = estimate_sg($sugarsm, floatval($row['boil_size']));
236 $this->SetFillColor(210,245,255);
237 $this->Cell($vul+105,5,'',0,0,'L',false);
238 $this->Cell(20,5,sprintf("%.3f",$cost_fermentables).EURO,0,0,'R',true);
239 $this->ProcessingTable=false;
240 $this->cMargin=$cMargin;
241 $this->aCols=array();
242 $this->Ln();
243 }
244
245 function TableHops($row) {
246 global $total_hops;
247 global $total_ibus;
248 global $cost_hops;
249 global $preboil_sg;
250 global $hopform;
251 global $hopuse;
252 $vul = $this->w - $this->rMargin - $this->lMargin - 122;
253 $this->Ln();
254 $this->AddCol($vul,'Hop','L');
255 $this->AddCol(15,'Alpha','R');
256 $this->AddCol(12,'IBU','R');
257 $this->AddCol(25,'Soort','L');
258 $this->AddCol(30,'Gebruik moment','L');
259 $this->AddCol(20,'Hoeveel','R');
260 $this->AddCol(20,'Prijs','R');
261
262 $cMargin=$this->cMargin;
263 $this->cMargin=2;
264 $this->TableX=$this->lMargin;
265 $this->TableHeader();
266 $this->ProcessingTable=true;
267
268 $this->SetFont('Helvetica','',9);
269 $this->SetFillColor(100, 250, 65);
270
271 $arr = json_decode($row['json_hops'], true);
272 foreach($arr as $item) { //foreach element in $arr
273 $name = iconv('UTF-8','windows-1252',$item['h_name']);
274 $origin = iconv('UTF-8','windows-1252',$item['h_origin']);
275 $amount = floatval($item['h_amount']);
276 $mass = $amount * 1000;
277 $costkg = floatval($item['h_cost']);
278 $time = floatval($item['h_time']);
279 $alpha = floatval($item['h_alpha']);
280
281 $cost = ($amount * $costkg);
282 $cost_hops += $cost;
283 $total_hops += $amount;
284
285 $moment = $hopuse[$item['h_useat']];
286 if (($item['h_useat'] == 2) || ($item['h_useat'] == 4)) { // Boil or Whirlpool
287 $moment = $hopuse[$item['h_useat']].' '.$time." min";
288 } else if ($item['h_useat'] == 5) { // Dryhop
289 $moment = $hopuse[$item['h_useat']].' '.sprintf("%.0f", $time / 1440).' dagen';
290 }
291 $ibu = calc_IBU($item['h_useat'], $item['h_form'], $preboil_sg, floatval($row['batch_size']), $mass, $time, $alpha,
292 $row['ibu_method'], $row['brew_whirlpool9'], $row['brew_whirlpool7'], $row['brew_whirlpool6']);
293 $total_ibus += $ibu;
294
295 if ($amount > 1)
296 $amount = sprintf("%.3f",$amount).' kg';
297 else
298 $amount = sprintf("%.1f",$amount * 1000).' gr';
299
300 $this->Cell($vul,5,$name.' ('.$origin.')',0,0,'L',true);
301 $this->Cell(15,5,sprintf("%.1f%%",$alpha),0,0,'R',true);
302 $this->Cell(12,5,sprintf("%.1f",$ibu),0,0,'R',true);
303 $this->Cell(25,5,$hopform[$item['h_form']],0,0,'L',true);
304 $this->Cell(30,5,$moment,0,0,'L',true);
305 $this->Cell(20,5,$amount,0,0,'R',true);
306 $this->Cell(20,5,sprintf("%.3f",$cost).EURO,0,0,'R',true);
307 $this->Ln();
308 }
309
310 $this->SetFillColor(210,245,255);
311 $this->Cell($vul+102,5,'',0,0,'L',false);
312 $this->Cell(20,5,sprintf("%.3f",$cost_hops).EURO,0,0,'R',true);
313 $this->ProcessingTable=false;
314 $this->cMargin=$cMargin;
315 $this->aCols=array();
316 $this->Ln();
317 }
318
319 function TableYeasts($row) {
320 global $cost_yeasts;
321 global $svg;
322 global $yeastform;
323 global $yeastuse;
324 $vul = $this->w - $this->rMargin - $this->lMargin - 110;
325 $this->Ln();
326 $this->AddCol($vul,'Gist','L');
327 $this->AddCol(15,'Attn','R');
328 $this->AddCol(25,'Soort','L');
329 $this->AddCol(30,'Gebruik moment','L');
330 $this->AddCol(20,'Hoeveel','R');
331 $this->AddCol(20,'Prijs','R');
332
333 $cMargin=$this->cMargin;
334 $this->cMargin=2;
335 $this->TableX=$this->lMargin;
336 $this->TableHeader();
337 $this->ProcessingTable=true;
338
339 $this->SetFont('Helvetica','',9);
340 $this->SetFillColor(175, 175, 255);
341
342 $arr = json_decode($row['json_yeasts'], true);
343 foreach($arr as $item) { //foreach element in $arr
344 $name = iconv('UTF-8','windows-1252',$item['y_name']);
345 $laboratory = iconv('UTF-8','windows-1252',$item['y_laboratory']);
346 $product_id = iconv('UTF-8','windows-1252',$item['y_product_id']);
347 $attenuation = floatval($item['y_attenuation']);
348 $cost = floatval($item['y_amount']) * floatval($item['y_cost']);
349 $cost_yeasts += $cost;
350
351 if ($item['y_use'] == 0) // Primary
352 $svg = $attenuation;
353 if ($item['y_form'] == 0) // Liquid
354 $amount = sprintf("%.0f",floatval($item['y_amount']))." pak";
355 else if ($item['y_form'] == 1 || $item['y_form'] == 6) // Dry
356 $amount = sprintf("%.1f",floatval($item['y_amount'])*1000)." gr";
357 else
358 $amount = sprintf("%.0f",floatval($item['y_amount'])*1000)." ml";
359
360 $this->Cell($vul,5,$laboratory.' '.$product_id.' ('.$name.')',0,0,'L',true);
361 $this->Cell(15,5,sprintf("%.1f%%",$attenuation),0,0,'R',true);
362 $this->Cell(25,5,$yeastform[$item['y_form']],0,0,'L',true);
363 $this->Cell(30,5,$yeastuse[$item['y_use']],0,0,'L',true);
364 $this->Cell(20,5,$amount,0,0,'R',true);
365 $this->Cell(20,5,sprintf("%8.3f",$cost).EURO,0,0,'R',true);
366 $this->Ln();
367 }
368 if ($row['starter_enable'] && $row['prop1_volume']) {
369 $sv = 0;
370 $st = 0;
371 for ($i = 1; $i < 5; $i++) {
372 $pv = "prop".$i."_volume";
373 if (floatval($row[$pv])) {
374 $st++;
375 if (floatval($row[$pv]) > $sv)
376 $sv = floatval($row[$pv]);
377 }
378 }
379 $this->Cell($vul,5,$st." staps giststarter",0,0,'L',true);
380 $this->Cell(40,5,'',0,0,'R',true);
381 $this->Cell(30,5,"Vooraf",0,0,'L',true);
382 $this->Cell(20,5,sprintf("%.3f",$sv)." L",0,0,'R',true);
383 $this->Cell(20,5,'',0,0,'R',true);
384 $this->Ln();
385 }
386
387 $this->SetFillColor(210,245,255);
388 $this->Cell($vul+90,5,'',0,0,'L',false);
389 $this->Cell(20,5,sprintf("%8.3f",$cost_yeasts).EURO,0,0,'R',true);
390 $this->ProcessingTable=false;
391 $this->cMargin=$cMargin;
392 $this->aCols=array();
393 $this->Ln();
394 }
395
396 function TableMiscs($row) {
397 global $cost_miscs;
398 global $misctype;
399 global $miscuse;
400 $vul = $this->w - $this->rMargin - $this->lMargin - 95;
401 if ($this->GetY() > 200)
402 $this->AddPage();
403 else
404 $this->Ln();
405 $this->AddCol($vul,'Diversen naam','L');
406 $this->AddCol(25,'Soort','L');
407 $this->AddCol(30,'Gebruik moment','L');
408 $this->AddCol(20,'Hoeveel','R');
409 $this->AddCol(20,'Prijs','R');
410
411 $cMargin=$this->cMargin;
412 $this->cMargin=2;
413 $this->TableX=$this->lMargin;
414 $this->TableHeader();
415 $this->ProcessingTable=true;
416
417 $this->SetFont('Helvetica','',9);
418 $this->SetFillColor(175, 175, 255);
419
420 $arr = json_decode($row['json_miscs'], true);
421 foreach($arr as $item) {
422 $name = iconv('UTF-8','windows-1252',$item['m_name']);
423 $type = $item['m_type'];
424 $use_use = $item['m_use_use'];
425 $amount = floatval($item['m_amount']) * 1000;
426 $costg = floatval($item['m_cost']) / 1000;
427 $time = floatval($item['m_time']);
428 $aiw = $item['m_amount_is_weight'];
429 $cost = $amount * $costg;
430 $cost_miscs += $cost;
431
432 if ($type == 4) // Water agent
433 $this->SetFillColor(240,140,130);
434 else if ($type == 3) // Fining
435 $this->SetFillColor(95,180,25);
436 else if (($type == 0) || ($type == 1) || ($type == 2) || ($type == 5)) // Spice, Herb, Flavour, Yeast nutrient
437 $this->SetFillColor(240,250,65);
438 else
439 $this->SetFillColor(210,245,255);
440
441 if ($use_use == 2) // Boil
442 $gebruik = sprintf("%s %d min",$miscuse[$use_use],$time);
443 else
444 $gebruik = $miscuse[$use_use];
445
446 $hoeveel = sprintf("%.2f %s",$amount,$aiw ? "gr":"ml");
447 $this->Cell($vul,5,$name,0,0,'L',true);
448 $this->Cell(25,5,$misctype[$type],0,0,'L',true);
449 $this->Cell(30,5,$gebruik,0,0,'L',true);
450 $this->Cell(20,5,$hoeveel,0,0,'R',true);
451 $this->Cell(20,5,sprintf("%8.3f",$cost).EURO,0,0,'R',true);
452 $this->Ln();
453 }
454
455 $this->SetFillColor(210,245,255);
456 $this->Cell($vul+75,5,'',0,0,'L',false);
457 $this->Cell(20,5,sprintf("%8.3f",$cost_miscs).EURO,0,0,'R',true);
458
459 $this->ProcessingTable=false;
460 $this->cMargin=$cMargin;
461 $this->aCols=array();
462 $this->Ln();
463 }
464
465 function TableMashs($row) {
466 global $cost_yeasts;
467 global $svg;
468 global $mashkg;
469 global $mashtype;
470 $vul = $this->w - $this->rMargin - $this->lMargin - 138;
471 if ($this->GetY() > 250)
472 $this->AddPage();
473 else
474 $this->Ln();
475 $this->AddCol($vul,'Maisch stap naam','L');
476 $this->AddCol(25,'Stap type','L');
477 $this->AddCol(16,'Start '.DEG.'C','R');
478 $this->AddCol(16,'Eind '.DEG.'C','R');
479 $this->AddCol(15,'Rust min','R');
480 $this->AddCol(15,'Stap min','R');
481 $this->AddCol(15,'L/Kg','R');
482 $this->AddCol(18,'Inf/dec L','R');
483 $this->AddCol(18,'Inf/dec '.DEG.'C','R');
484
485 $cMargin=$this->cMargin;
486 $this->cMargin=2;
487 $this->TableX=$this->lMargin;
488 $this->TableHeader();
489 $this->ProcessingTable=true;
490
491 $this->SetFont('Helvetica','',9);
492 $this->SetFillColor(175, 175, 255);
493
494 $vol = 0;
495 $arr = json_decode($row['json_mashs'], true);
496 foreach($arr as $item) { //foreach element in $arr
497
498 if ($item['step_type'] == 0)
499 $vol += $item['step_infuse_amount'];
500 if ($mashkg > 0)
501 $thick = $vol / $mashkg;
502 else
503 $thick = 0;
504 $this->Cell($vul,5,$item['step_name'],0,0,'L',true);
505 $this->Cell(25,5,$mashtype[$item['step_type']],0,0,'L',true);
506 $this->Cell(16,5,sprintf("%.1f",$item['step_temp']),0,0,'R',true);
507 $this->Cell(16,5,sprintf("%.1f",$item['end_temp']),0,0,'R',true);
508 $this->Cell(15,5,sprintf("%.0f",$item['step_time']),0,0,'R',true);
509 $this->Cell(15,5,sprintf("%.0f",$item['ramp_time']),0,0,'R',true);
510 $this->Cell(15,5,sprintf("%.2f",$thick),0,0,'R',true);
511 if ($item['step_type'] == 1) {
512 $this->Cell(18,5,' ',0,0,'R',true);
513 $this->Cell(18,5,' ',0,0,'R',true);
514 } else {
515 $this->Cell(18,5,sprintf("%.1f",$item['step_infuse_amount']),0,0,'R',true);
516 $this->Cell(18,5,sprintf("%.1f",$item['step_infuse_temp']),0,0,'R',true);
517 }
518 $this->Ln();
519 }
520 $this->ProcessingTable=false;
521 $this->cMargin=$cMargin;
522 $this->aCols=array();
523 $this->Ln();
524 }
525
526 function TableWaters($row) {
527
528 $vul = $this->w - $this->rMargin - $this->lMargin - 137;
529 if ($this->GetY() > 250)
530 $this->AddPage();
531 else
532 $this->Ln();
533 $this->AddCol($vul,'Water bron','L');
534 $this->AddCol(20,'Volume','R');
535 $this->AddCol(15,'Ca','R');
536 $this->AddCol(15,'Mg','R');
537 $this->AddCol(15,'Na','R');
538 $this->AddCol(15,'CaCO3','R');
539 $this->AddCol(15,'Cl','R');
540 $this->AddCol(15,'SO4','R');
541 $this->AddCol(15,'pH','R');
542
543 $cMargin=$this->cMargin;
544 $this->cMargin=2;
545 $this->TableX=$this->lMargin;
546 $this->TableHeader();
547 $this->ProcessingTable=true;
548
549 $this->SetFont('Helvetica','',9);
550 $this->SetFillColor(120, 255, 250);
551
552 $this->Cell($vul,5,$row['w1_name'],0,0,'L',true);
553 $this->Cell(20,5,sprintf("%.1f", $row['w1_amount']).' L',0,0,'R',true);
554 $this->Cell(15,5,sprintf("%.1f", $row['w1_calcium']),0,0,'R',true);
555 $this->Cell(15,5,sprintf("%.1f", $row['w1_magnesium']),0,0,'R',true);
556 $this->Cell(15,5,sprintf("%.1f", $row['w1_sodium']),0,0,'R',true);
557 $this->Cell(15,5,sprintf("%.1f", $row['w1_total_alkalinity']),0,0,'R',true);
558 $this->Cell(15,5,sprintf("%.1f", $row['w1_chloride']),0,0,'R',true);
559 $this->Cell(15,5,sprintf("%.1f", $row['w1_sulfate']),0,0,'R',true);
560 $this->Cell(15,5,sprintf("%.1f", $row['w1_ph']),0,0,'R',true);
561 $this->Ln();
562 if ($row['w2_name'] && floatval($row['w2_amount'])) {
563 $this->Cell($vul,5,$row['w2_name'],0,0,'L',true);
564 $this->Cell(20,5,sprintf("%.1f", $row['w2_amount']).' L',0,0,'R',true);
565 $this->Cell(15,5,sprintf("%.1f", $row['w2_calcium']),0,0,'R',true);
566 $this->Cell(15,5,sprintf("%.1f", $row['w2_magnesium']),0,0,'R',true);
567 $this->Cell(15,5,sprintf("%.1f", $row['w2_sodium']),0,0,'R',true);
568 $this->Cell(15,5,sprintf("%.1f", $row['w2_total_alkalinity']),0,0,'R',true);
569 $this->Cell(15,5,sprintf("%.1f", $row['w2_chloride']),0,0,'R',true);
570 $this->Cell(15,5,sprintf("%.1f", $row['w2_sulfate']),0,0,'R',true);
571 $this->Cell(15,5,sprintf("%.1f", $row['w2_ph']),0,0,'R',true);
572 $this->Ln();
573 $this->Cell($vul,5,'Gemengd water',0,0,'L',true);
574 $this->Cell(20,5,sprintf("%.1f", $row['wg_amount']).' L',0,0,'R',true);
575 $this->Cell(15,5,sprintf("%.1f", $row['wg_calcium']),0,0,'R',true);
576 $this->Cell(15,5,sprintf("%.1f", $row['wg_magnesium']),0,0,'R',true);
577 $this->Cell(15,5,sprintf("%.1f", $row['wg_sodium']),0,0,'R',true);
578 $this->Cell(15,5,sprintf("%.1f", $row['wg_total_alkalinity']),0,0,'R',true);
579 $this->Cell(15,5,sprintf("%.1f", $row['wg_chloride']),0,0,'R',true);
580 $this->Cell(15,5,sprintf("%.1f", $row['wg_sulfate']),0,0,'R',true);
581 $this->Cell(15,5,sprintf("%.1f", $row['wg_ph']),0,0,'R',true);
582 $this->Ln();
583 }
584 $this->Cell($vul,5,'Behandeld water',0,0,'L',true);
585 $this->Cell(20,5,'',0,0,'R',true);
586 $this->Cell(15,5,sprintf("%.1f", $row['wb_calcium']),0,0,'R',true);
587 $this->Cell(15,5,sprintf("%.1f", $row['wb_magnesium']),0,0,'R',true);
588 $this->Cell(15,5,sprintf("%.1f", $row['wb_sodium']),0,0,'R',true);
589 $this->Cell(15,5,sprintf("%.1f", $row['wb_total_alkalinity']),0,0,'R',true);
590 $this->Cell(15,5,sprintf("%.1f", $row['wb_chloride']),0,0,'R',true);
591 $this->Cell(15,5,sprintf("%.1f", $row['wb_sulfate']),0,0,'R',true);
592 $this->Cell(15,5,sprintf("%.1f", $row['wb_ph']),0,0,'R',true);
593 $this->ProcessingTable=false;
594 $this->cMargin=$cMargin;
595 $this->aCols=array();
596 $this->Ln();
597 }
598
599 function TableSummary($row) {
600 global $pSugar;
601 global $pCara;
602 global $svg;
603 global $colorw;
604 global $cost_fermentables;
605 global $cost_hops;
606 global $cost_miscs;
607 global $cost_yeasts;
608 global $mashkg;
609 global $colormethod;
610 global $ibumethod;
611 /* 2 Columns */
612 if ($this->GetY() > 200)
613 $this->AddPage();
614 else
615 $this->Ln();
616 $vul = $this->w - $this->rMargin - $this->lMargin - 170;
617 $cMargin=$this->cMargin;
618 $this->cMargin=2;
619 $this->TableX=$this->lMargin;
620 $this->SetFont('Helvetica','B',9);
621 $this->SetX($this->TableX);
622 $this->SetFillColor(255,150,100);
623 $this->Cell(0, 5, 'Recept samenvatting',0,0,'C',true);
624 $this->Ln();
625
626 $this->SetFont('Helvetica','',9);
627 $this->SetFillColor(210,245,255);
628
629 $mashtime = 0;
630 $mashtemp = 0;
631 $mash_infuse = 0;
632 $arr = json_decode($row['json_mashs'], true);
633 foreach($arr as $item) {
634 if ($item['step_type'] == 0) { // infusion
635 $mash_infuse += floatval($item['step_infuse_amount']);
636 }
637 if ($item['step_temp'] < 75) { // ignore mashout temps
638 $mashtime += floatval($item['step_time']);
639 $mashtemp += floatval($item['step_time']) * floatval($item['step_temp']);
640 }
641 }
642 $mashtemp = $mashtemp / $mashtime;
643 if (($mashkg > 0) && ($mash_infuse > 0) && ($mashtime > 0) && ($mashtemp > 0)) {
644 $row['est_fg'] = estimate_fg($pSugar, $pCara, $mash_infuse / $mashkg, $mashtime, $mashtemp, $svg, $row['est_og']);
645 } else {
646 $row['est_fg'] = estimate_fg($pSugar, $pCara, 0, 0, 0, $svg, $row['est_og']);
647 }
648
649 $this->SetX($this->TableX);
650 $this->Cell(35,5,'Start SG',0,0,'L',true);
651 $this->Cell(25,5,sprintf("%.3f",$row['est_og']),0,0,'L',true);
652 $this->Cell(25,5,'('.sprintf("%.3f",$row['st_og_min']).' - '.sprintf("%.3f",$row['st_og_max']).')',0,0,'L',true);
653 $this->Cell($vul,5,'',0,0,'L',false);
654 $this->Cell(35,5,'Eind SG',0,0,'L',true);
655 $this->Cell(25,5,sprintf("%.3f",$row['est_fg']),0,0,'L',true);
656 $this->Cell(25,5,'('.sprintf("%.3f",$row['st_fg_min']).' - '.sprintf("%.3f",$row['st_fg_max']).')',0,0,'L',true);
657 $this->Ln();
658
659 $row['est_abv'] = abvol($row['est_og'], $row['est_fg']);
660 $this->SetX($this->TableX);
661 $this->Cell(35,5,'Geschat alcohol',0,0,'L',true);
662 $this->Cell(25,5,sprintf("%.1f",$row['est_abv']).'%',0,0,'L',true);
663 $this->Cell(25,5,'('.sprintf("%.1f",$row['st_abv_min']).' - '.sprintf("%.1f",$row['st_abv_max']).'%)',0,0,'L',true);
664 $this->Cell($vul,5,'',0,0,'L',false);
665 $this->Cell(35,5,'Flessen CO2',0,0,'L',true);
666 $this->Cell(25,5,sprintf("%.1f",$row['bottle_carbonation']).'%',0,0,'L',true);
667 $this->Cell(25,5,'('.sprintf("%.1f",$row['st_carb_min']).' - '.sprintf("%.1f",$row['st_carb_max']).'%)',0,0,'L',true);
668 $this->Ln();
669
670 $row['est_color'] = kw_to_ebc($row['color_method'], $colorw);
671 $this->SetX($this->TableX);
672 $this->Cell(35,5,'Kleur ('.$colormethod[$row['color_method']].')',0,0,'L',true);
673 $beercolor = ebc_to_color($row['est_color']);
674 if ($row['est_color'] > 30)
675 $this->SetTextColor(250);
676 $this->SetFillColor($beercolor[0],$beercolor[1],$beercolor[2]);
677 $this->Cell(25,5,$row['est_color'].' EBC',0,0,'L',true);
678 $this->Cell(25,5,'('.$row['st_color_min'].' - '.$row['st_color_max'].' EBC)',0,0,'L',true);
679 $this->SetTextColor(0);
680 $this->SetFillColor(210,245,255);
681 $this->Cell($vul,5,'',0,0,'L',false);
682 $this->Cell(35,5,'Fusten CO2',0,0,'L',true);
683 $this->Cell(25,5,sprintf("%.1f",$row['keg_carbonation']).'%',0,0,'L',true);
684 $this->Cell(25,5,'('.sprintf("%.1f",$row['st_carb_min']).' - '.sprintf("%.1f",$row['st_carb_max']).'%)',0,0,'L',true);
685 $this->Ln();
686
687 $this->SetX($this->TableX);
688 $this->Cell(35,5,'Bitterheid ('.$ibumethod[$row['ibu_method']].')',0,0,'L',true);
689 $this->Cell(25,5,sprintf("%.0f",$row['est_ibu']).' IBU',0,0,'L',true);
690 $this->Cell(25,5,'('.$row['st_ibu_min'].' - '.$row['st_ibu_max'].' IBU)',0,0,'L',true);
691 $this->Cell($vul,5,'',0,0,'L',false);
692 $cost_total = $cost_fermentables + $cost_hops + $cost_miscs + $cost_yeasts;
693 $this->Cell(35,5,'Kosten',0,0,'L',true);
694 $this->Cell(25,5,sprintf("%.2f",$cost_total).EURO,0,0,'L',true);
695 $this->Cell(25,5,sprintf("%.2f",$cost_total/$row['batch_size']).EURO.' / liter',0,0,'L',true);
696
697 // calorieen
698 $this->ProcessingTable=false;
699 $this->cMargin=$cMargin;
700 $this->aCols=array();
701 $this->Ln();
702 }
703
704 function PrintDiff($v1, $v2, $decimals, $un) {
705
706 $val1 = floatval($v1);
707 $val2 = floatval($v2);
708 if ($val2 > $val1)
709 $diff = '+' . number_format($val2 - $val1, $decimals) . $un;
710 else
711 $diff = number_format($val2 - $val1, $decimals) . $un;
712 $this->Cell(30,5,$diff,0,0,'L',true);
713 }
714
715 function Brewday($row) {
716
717 global $my_brix_correction;
718 global $my_grain_absorbtion;
719 global $coolingtype;
720 global $aerationtype;
721 global $est_mash_sg;
722 global $mashtype;
723 if ($this->GetY() > 100)
724 $this->AddPage();
725 else
726 $this->Ln(10);
727
728 $vul = $this->w - $this->rMargin - $this->lMargin - 170;
729 $cMargin=$this->cMargin;
730 $this->cMargin=2;
731 $this->TableX=$this->lMargin;
732 $this->SetFont('Helvetica','B',9);
733 $this->SetX($this->TableX);
734 $this->SetFillColor(255,150,100);
735 $this->Cell(0, 5, 'Brouwdag gegevens',0,0,'C',true);
736 $this->Ln();
737
738 $this->SetFont('Helvetica','',9);
739 $this->SetFillColor(210,245,255);
740 $this->SetX($this->TableX);
741 $this->Cell(35,5,'Datum start',0,0,'L',true);
742 $this->Cell(50,5,$row['brew_date_start'],0,0,'L',true);
743 $this->Cell($vul,5,'',0,0,'L',false);
744 $this->Cell(35,5,'Datum eind',0,0,'L',true);
745 $this->Cell(50,5,$row['brew_date_end'],0,0,'L',true);
746 $this->Ln(10);
747
748 $domash = 0;
749 $arr = json_decode($row['json_mashs'], true);
750 foreach($arr as $item) {
751 if ($item['step_sg'] > 1.005)
752 $domash = 1;
753 }
754 if ($domash) {
755 $this->SetX($this->TableX);
756 $this->SetFont('Helvetica','B',9);
757 $this->SetFillColor(175,175,255);
758 $vul = $this->w - $this->rMargin - $this->lMargin - 125;
759 $this->Cell(5, 5, '',0,0,'L',true);
760 $this->Cell($vul,5, 'Maisch stap',0,0,'L',true);
761 $this->Cell(30,5, 'Type',0,0,'L',true);
762 $this->Cell(30,5, 'Temperatuur',0,0,'L',true);
763 $this->Cell(30,5, 'SG',0,0,'L',true);
764 $this->Cell(30,5, 'pH',0,0,'L',true);
765 $this->Ln();
766 $this->SetFont('Helvetica','',9);
767 $this->SetFillColor(210,245,255);
768 $arr = json_decode($row['json_mashs'], true);
769 $step = 0;
770 foreach($arr as $item) {
771 $step++;
772 $this->Cell(5,5,$step,0,0,'L',true);
773 $this->Cell($vul,5,$item['step_name'],0,0,'L',true);
774 $this->Cell(30,5,$mashtype[$item['step_type']],0,0,'L',true);
775 $this->Cell(30,5,sprintf("%.1f",$item['step_temp']).'-'.sprintf("%.1f",$item['end_temp']).DEG.'C',0,0,'L',true);
776 $this->Cell(30,5,sprintf("%.3f",$item['step_sg']),0,0,'L',true);
777 $this->Cell(30,5,sprintf("%.2f",$item['step_ph']),0,0,'L',true);
778 $this->Ln();
779 }
780 $this->Ln();
781 }
782
783 $this->SetX($this->TableX);
784 $this->SetFont('Helvetica','B',9);
785 $this->SetFillColor(175,175,255);
786 $vul = $this->w - $this->rMargin - $this->lMargin - 130;
787 $this->Cell($vul, 5, 'Gegeven',0,0,'L',true);
788 $this->Cell(50, 5, 'Gewenst',0,0,'L',true);
789 $this->Cell(50, 5, 'Werkelijk',0,0,'L',true);
790 $this->Cell(30, 5, 'Verschil',0,0,'L',true);
791 $this->Ln();
792
793 $this->SetX($this->TableX);
794 $this->SetFont('Helvetica','',9);
795 $this->SetFillColor(210,245,255);
796 $this->Cell($vul,5,'Maisch zuurgraad',0,0,'L',true);
797 $this->Cell(50,5,sprintf("%.1f", $row['mash_ph']).' pH',0,0,'L',true);
798 $this->Cell(50,5,sprintf("%.2f", $row['brew_mash_ph']).' pH',0,0,'L',true);
799 $this->PrintDiff($row['mash_ph'], $row['brew_mash_ph'], 2, ' pH');
800 $this->Ln();
801
802 $this->SetX($this->TableX);
803 $this->Cell($vul,5,'Maisch densiteit',0,0,'L',true);
804 $this->Cell(50,5,density_str(floatval($est_mash_sg)),0,0,'L',true);
805 $this->Cell(50,5,density_str(floatval($row['brew_mash_sg'])),0,0,'L',true);
806 $this->PrintDiff($est_mash_sg, $row['brew_mash_sg'], 3, ' SG');
807 $this->Ln();
808
809 $this->SetX($this->TableX);
810 $this->Cell($vul,5,'Maisch rendement',0,0,'L',true);
811 $this->Cell(50,5,'100.0%',0,0,'L',true);
812 $this->Cell(50,5,sprintf("%.1f", floatval($row['brew_mash_efficiency']))."%",0,0,'L',true);
813 $this->PrintDiff(100.0, $row['brew_mash_efficiency'], 1, '%');
814 $this->Ln();
815
816 $this->SetX($this->TableX);
817 $this->Cell($vul,5,'Spoelwater zuurgraad',0,0,'L',true);
818 $this->Cell(50,5,sprintf("%.1f", $row['sparge_ph']).' pH',0,0,'L',true);
819 $this->Cell(50,5,sprintf("%.2f", $row['brew_sparge_ph']).' pH',0,0,'L',true);
820 $this->PrintDiff($row['sparge_ph'], $row['brew_sparge_ph'], 2, ' pH');
821 $this->Ln(7);
822
823 $this->SetX($this->TableX);
824 $this->Cell($vul,5,'Voor koken zuurgraad',0,0,'L',true);
825 $this->Cell(50,5,'',0,0,'L',true);
826 $this->Cell(50,5,sprintf("%.2f", $row['brew_preboil_ph'])." pH",0,0,'L',true);
827 $this->Cell(30,5,'',0,0,'L',true);
828 $this->Ln();
829
830 $this->SetX($this->TableX);
831 $this->Cell($vul,5,'Voor koken densiteit',0,0,'L',true);
832 $this->Cell(50,5,'',0,0,'L',true);
833 $this->Cell(50,5,density_str(floatval($row['brew_preboil_sg'])),0,0,'L',true);
834 $this->Cell(30,5,'',0,0,'L',true);
835 $this->Ln();
836
837 $this->SetX($this->TableX);
838 $this->Cell($vul,5,'Voor koken volume',0,0,'L',true);
839 $this->Cell(50,5,sprintf("%.1f", $row['boil_size'] * 1.04)." liter",0,0,'L',true);
840 $this->Cell(50,5,sprintf("%.1f", $row['brew_preboil_volume'])." liter",0,0,'L',true);
841 $this->PrintDiff($row['boil_size'] * 1.04, $row['brew_preboil_volume'], 1, ' liter');
842 $this->Ln();
843
844 $this->SetX($this->TableX);
845 $this->Cell($vul,5,'Voor koken rendement',0,0,'L',true);
846 $this->Cell(50,5,sprintf("%.1f", floatval($row['efficiency']))."%",0,0,'L',true);
847 $this->Cell(50,5,sprintf("%.1f", floatval($row['brew_preboil_efficiency']))."%",0,0,'L',true);
848 $this->PrintDiff($row['efficiency'], $row['brew_preboil_efficiency'], 1, '%');
849 $this->Ln(7);
850
851 $this->SetX($this->TableX);
852 $this->Cell($vul,5,'Na koken zuurgraad',0,0,'L',true);
853 $this->Cell(50,5,'',0,0,'L',true);
854 $this->Cell(50,5,sprintf("%.2f", $row['brew_aboil_ph'])." pH",0,0,'L',true);
855 $this->Cell(30,5,'',0,0,'L',true);
856 $this->Ln();
857
858 $this->SetX($this->TableX);
859 $this->Cell($vul,5,'Na koken densiteit',0,0,'L',true);
860 $this->Cell(50,5,density_str(floatval($row['est_og'])),0,0,'L',true);
861 $this->Cell(50,5,density_str(floatval($row['brew_aboil_sg'])),0,0,'L',true);
862 $this->PrintDiff($row['est_og'], $row['brew_aboil_sg'], 3, ' SG');
863 $this->Ln();
864
865 $this->SetX($this->TableX);
866 $this->Cell($vul,5,'Na koken volume',0,0,'L',true);
867 $this->Cell(50,5,sprintf("%.1f", $row['batch_size'] * 1.04)." liter",0,0,'L',true);
868 $this->Cell(50,5,sprintf("%.1f", $row['brew_aboil_volume'])." liter",0,0,'L',true);
869 $this->PrintDiff($row['batch_size'] * 1.04, $row['brew_aboil_volume'], 1, ' liter');
870 $this->Ln();
871
872 $this->SetX($this->TableX);
873 $this->Cell($vul,5,'Na koken rendement',0,0,'L',true);
874 $this->Cell(50,5,sprintf("%.1f", floatval($row['efficiency']))."%",0,0,'L',true);
875 $this->Cell(50,5,sprintf("%.1f", floatval($row['brew_aboil_efficiency']))."%",0,0,'L',true);
876 $this->PrintDiff($row['efficiency'], $row['brew_aboil_efficiency'], 1, '%');
877 $this->Ln(7);
878
879 $this->SetX($this->TableX);
880 $this->Cell($vul,5,'Koeler & trub verlies',0,0,'L',true);
881 $this->Cell(50,5,sprintf("%.1f", floatval($row['eq_trub_chiller_loss'])).' liter',0,0,'L',true);
882 $this->Cell(50,5,sprintf("%.1f", floatval($row['brew_fermenter_tcloss'])).' liter',0,0,'L',true);
883 $this->PrintDiff($row['eq_trub_chiller_loss'], $row['brew_fermenter_tcloss'], 1, ' lter');
884 $this->Ln();
885
886 $this->SetX($this->TableX);
887 $this->Cell($vul,5,'Extra water in gistvat',0,0,'L',true);
888 $this->Cell(50,5,sprintf("%.1f", floatval($row['eq_top_up_water'])).' liter',0,0,'L',true);
889 $this->Cell(50,5,sprintf("%.1f", floatval($row['brew_fermenter_extrawater'])).' liter',0,0,'L',true);
890 $this->PrintDiff($row['eq_top_up_water'], $row['brew_fermenter_extrawater'], 1, ' liter');
891 $this->Ln();
892
893 $this->SetX($this->TableX);
894 $this->Cell($vul,5,'Volume naar gistvat',0,0,'L',true);
895 $this->Cell(50,5,sprintf("%.1f", floatval($row['batch_size']) - floatval($row['eq_trub_chiller_loss'])).' liter',0,0,'L',true);
896 $this->Cell(50,5,sprintf("%.1f", floatval($row['brew_fermenter_volume'])).' liter',0,0,'L',true);
897 $this->PrintDiff(floatval($row['batch_size']) - floatval($row['eq_trub_chiller_loss']), $row['brew_fermenter_volume'], 1, ' liter');
898 $this->Ln();
899
900 $this->SetX($this->TableX);
901 $this->Cell($vul,5,'Densiteit in gistvat',0,0,'L',true);
902 $this->Cell(50,5,density_str(floatval($row['est_og'])),0,0,'L',true);
903 $this->Cell(50,5,density_str(floatval($row['brew_fermenter_sg'])),0,0,'L',true);
904 $this->PrintDiff($row['est_og'], $row['brew_fermenter_sg'], 3, ' SG');
905 $this->Ln();
906
907 $this->SetX($this->TableX);
908 $this->Cell($vul,5,'Kleur in gistvat',0,0,'L',true);
909 $this->Cell(50,5,sprintf("%.0f", floatval($row['est_color'])).' EBC',0,0,'L',true);
910 $this->Cell(50,5,sprintf("%.0f", floatval($row['brew_fermenter_color'])).' EBC',0,0,'L',true);
911 $this->PrintDiff($row['est_color'], $row['brew_fermenter_color'], 0, ' EBC');
912 $this->Ln();
913
914 $this->SetX($this->TableX);
915 $this->Cell($vul,5,'Bitterheid in gistvat',0,0,'L',true);
916 $this->Cell(50,5,sprintf("%.0f", floatval($row['est_ibu'])).' IBU',0,0,'L',true);
917 $this->Cell(50,5,sprintf("%.0f", floatval($row['brew_fermenter_ibu'])).' IBU',0,0,'L',true);
918 $this->PrintDiff($row['est_ibu'], $row['brew_fermenter_ibu'], 0, ' IBU');
919 $this->Ln(7);
920
921 $this->SetX($this->TableX);
922 $this->Cell($vul,5,'Koelen methode',0,0,'L',true);
923 $this->Cell(50,5,$coolingtype[$row['brew_cooling_method']],0,0,'L',true);
924 $this->Ln();
925
926 $this->SetX($this->TableX);
927 $this->Cell($vul,5,'Koelen temperatuur',0,0,'L',true);
928 $this->Cell(50,5,sprintf("%.1f", floatval($row['brew_cooling_to'])).DEG.'C',0,0,'L',true);
929 $this->Ln();
930
931 $this->SetX($this->TableX);
932 $this->Cell($vul,5,'Koelen tijdsduur',0,0,'L',true);
933 $this->Cell(50,5,sprintf("%.0f", floatval($row['brew_cooling_time'])).' minuten',0,0,'L',true);
934 $this->Ln(7);
935 }
936
937 function Fermentation($row) {
938
939 if ($this->GetY() > 230)
940 $this->AddPage();
941 else
942 $this->Ln(10);
943
944 $vul = $this->w - $this->rMargin - $this->lMargin - 180;
945 $cMargin=$this->cMargin;
946 $this->cMargin=2;
947 $this->TableX=$this->lMargin;
948 $this->SetFont('Helvetica','B',9);
949 $this->SetX($this->TableX);
950 $this->SetFillColor(255,150,100);
951 $this->Cell(0, 5, 'Vergisting gegevens',0,0,'C',true);
952 $this->Ln();
953
954 $this->SetFont('Helvetica','',9);
955 $this->SetFillColor(210,245,255);
956
957 $this->SetX($this->TableX);
958 $this->Cell(45,5,'Hoofdvergisting start temp.',0,0,'L',true);
959 $this->Cell(45,5,sprintf("%.1f",$row['primary_start_temp']).DEG.'C',0,0,'L',true);
960 $this->Cell($vul,5,'',0,0,'L',false);
961 $this->Cell(45,5,'Hoofdvergisting piek temp.',0,0,'L',true);
962 $this->Cell(45,5,sprintf("%.1f",$row['primary_max_temp']).DEG.'C',0,0,'L',true);
963 $this->Ln();
964
965 $this->SetX($this->TableX);
966 $this->Cell(45,5,'Hoofdvergisting eind temp.',0,0,'L',true);
967 $this->Cell(45,5,sprintf("%.1f",$row['primary_end_temp']).DEG.'C',0,0,'L',true);
968 $this->Cell($vul,5,'',0,0,'L',false);
969 $this->Cell(45,5,'Hoofdvergisting densiteit',0,0,'L',true);
970 $this->Cell(45,5,sprintf("%.3f",floatval($row['primary_end_sg'])).' SG',0,0,'L',true);
971 $this->Ln();
972
973 $this->SetX($this->TableX);
974 $this->Cell(45,5,'Hoofdvergisting einde',0,0,'L',true);
975 $this->Cell(45,5,$row['primary_end_date'],0,0,'L',true);
976 $this->Ln();
977
978 $this->SetX($this->TableX);
979 $this->Cell(45,5,'Navergisting tempertuur',0,0,'L',true);
980 $this->Cell(45,5,sprintf("%.1f", $row['secondary_temp']).DEG.'C',0,0,'L',true);
981 $this->Cell($vul,5,'',0,0,'L',false);
982 $this->Cell(45,5,'Nagisten densiteit',0,0,'L',true);
983 $this->Cell(45,5,sprintf("%.3f",floatval($row['secondary_end_sg'])).' SG',0,0,'L',true);
984 $this->Ln();
985
986 $this->SetX($this->TableX);
987 $this->Cell(45,5,'Nagisten einde',0,0,'L',true);
988 $this->Cell(45,5,$row['secondary_end_date'],0,0,'L',true);
989 $this->Ln();
990
991 $this->SetX($this->TableX);
992 $this->Cell(45,5,'Lageren temperatuur',0,0,'L',true);
993 $this->Cell(45,5,sprintf("%.1f",$row['tertiary_temp']).DEG.'C',0,0,'L',true);
994 $this->Cell($vul,5,'',0,0,'L',false);
995 $this->Cell(45,5,'Lageren densiteit',0,0,'L',true);
996 $this->Cell(45,5,sprintf("%.3f",floatval($row['fg'])).' SG',0,0,'L',true);
997 $this->Ln();
998
999 $this->SetX($this->TableX);
1000 $this->Cell(45,5,'Lageren einde',0,0,'L',true);
1001 $this->Cell(45,5,$row['package_date'],0,0,'L',true);
1002 $this->Cell($vul,5,'',0,0,'L',false);
1003 $svg = calc_svg(floatval($row['brew_fermenter_sg']), floatval($row['fg']));
1004 $this->Cell(45,5,'Schijnbare vergistingsgraad',0,0,'L',true);
1005 $this->Cell(45,5,sprintf("%.1f",$svg).'%',0,0,'L',true);
1006 $this->Ln();
1007 }
1008
1009 function Packaging($row) {
1010
1011 global $bottle_sugar;
1012 global $bottle_sugar_amount;
1013 global $keg_sugar;
1014 global $keg_sugar_amount;
1015
1016 if ($this->GetY() > 230)
1017 $this->AddPage();
1018 else
1019 $this->Ln(10);
1020
1021 $vul = $this->w - $this->rMargin - $this->lMargin - 180;
1022 $cMargin=$this->cMargin;
1023 $this->cMargin=2;
1024 $this->TableX=$this->lMargin;
1025 $this->SetFont('Helvetica','B',9);
1026 $this->SetX($this->TableX);
1027 $this->SetFillColor(255,150,100);
1028 $this->Cell(0, 5, 'Verpakken',0,0,'C',true);
1029 $this->Ln();
1030
1031 $this->SetFont('Helvetica','',9);
1032 $this->SetFillColor(210,245,255);
1033
1034 $this->SetX($this->TableX);
1035 $this->Cell(45,5,'Datum verpakken',0,0,'L',true);
1036 $this->Cell(45,5,$row['package_date'],0,0,'L',true);
1037 $this->Cell($vul,5,'',0,0,'L',false);
1038 $this->Cell(45,5,'Hoeveelheid',0,0,'L',true);
1039 $this->Cell(45,5,sprintf("%.1f", $row['package_volume']).' liter',0,0,'L',true);
1040 $this->Ln();
1041
1042 $this->SetX($this->TableX);
1043 $this->Cell(45,5,'Alcohol volume',0,0,'L',true);
1044 $this->Cell(45,5,sprintf("%.1f",$row['package_abv']).'%',0,0,'L',true);
1045 if (($row['package_infuse_amount'] > 0) && ($row['package_infuse_abv'] == 0)) {
1046 $this->Cell($vul,5,'',0,0,'L',false);
1047 $this->Cell(45,5,'Water toevoegen',0,0,'L',true);
1048 $this->Cell(45,5,sprintf("%.1f", $row['package_infuse_amount']).' liter',0,0,'L',true);
1049 }
1050 $this->Ln(7);
1051
1052 if (($row['package_infuse_amount'] > 0) && ($row['package_infuse_abv'] > 0)) {
1053 $this->SetX($this->TableX);
1054 $this->Cell(45,5,'Drank toevoegen',0,0,'L',true);
1055 $this->Cell(45,5,sprintf("%.1f",$row['package_infuse_amount']).' liter',0,0,'L',true);
1056 $this->Cell($vul,5,'',0,0,'L',false);
1057 $this->Cell(45,5,'Bevat alcohol volume',0,0,'L',true);
1058 $this->Cell(45,5,sprintf("%.1f", $row['package_infuse_abv']).'%',0,0,'L',true);
1059 $this->Ln();
1060
1061 $this->SetX($this->TableX);
1062 $this->Cell(180,5,iconv('UTF-8','windows-1252',$row['package_infuse_notes']),0,0,'L',true);
1063 $this->Ln(7);
1064 }
1065
1066 $this->SetX($this->TableX);
1067 $this->Cell(45,5,'Flessen volume',0,0,'L',true);
1068 $this->Cell(45,5,sprintf("%.1f",$row['bottle_amount']).' liter',0,0,'L',true);
1069 $this->Cell($vul,5,'',0,0,'L',false);
1070 $this->Cell(45,5,'Fusten volume',0,0,'L',true);
1071 $this->Cell(45,5,sprintf("%.1f", $row['keg_amount']).' liter',0,0,'L',true);
1072 $this->Ln();
1073
1074 $this->SetX($this->TableX);
1075 $this->Cell(45,5,'CO2 volumes',0,0,'L',true);
1076 $this->Cell(45,5,sprintf("%.2f",$row['bottle_carbonation']),0,0,'L',true);
1077 $this->Cell($vul,5,'',0,0,'L',false);
1078 $this->Cell(45,5,'CO2 volumes',0,0,'L',true);
1079 $this->Cell(45,5,sprintf("%.2f", $row['keg_carbonation']),0,0,'L',true);
1080 $this->Ln();
1081
1082 $this->SetX($this->TableX);
1083 $this->Cell(45,5,'Suiker',0,0,'L',true);
1084 $this->Cell(45,5,$bottle_sugar,0,0,'L',true);
1085 $this->Cell($vul,5,'',0,0,'L',false);
1086 $this->Cell(45,5,'Suiker',0,0,'L',true);
1087 $this->Cell(45,5,$keg_sugar,0,0,'L',true);
1088 $this->Ln();
1089
1090 $this->SetX($this->TableX);
1091 $this->Cell(45,5,'Hoeveelheid',0,0,'L',true);
1092 $this->Cell(45,5,sprintf("%.1f",$row['bottle_priming_amount']).' gram/liter',0,0,'L',true);
1093 $this->Cell($vul,5,'',0,0,'L',false);
1094 if ($row['keg_forced_carb']) {
1095 $this->Cell(45,5,'Geforceerd op druk zetten',0,0,'L',true);
1096 $this->Cell(45,5,'Ja',0,0,'L',true);
1097 } else {
1098 $this->Cell(45,5,'Hoeveelheid',0,0,'L',true);
1099 $this->Cell(45,5,sprintf("%.1f", $row['keg_priming_amount']).' gram/liter',0,0,'L',true);
1100 }
1101 $this->Ln();
1102
1103 $this->SetX($this->TableX);
1104 $this->Cell(45,5,'Totaal suiker',0,0,'L',true);
1105 $this->Cell(45,5,sprintf("%.3f",$bottle_sugar_amount).' kg',0,0,'L',true);
1106 $this->Cell($vul,5,'',0,0,'L',false);
1107 if ($row['keg_forced_carb']) {
1108 $this->Cell(45,5,'Druk op fust',0,0,'L',true);
1109 $this->Cell(45,5,sprintf("%.1f",$row['keg_pressure']).' bar',0,0,'L',true);
1110 } else {
1111 $this->Cell(45,5,'Totaal suiker',0,0,'L',true);
1112 $this->Cell(45,5,sprintf("%.3f",$keg_sugar_amount).' kg',0,0,'L',true);
1113 }
1114 $this->Ln();
1115
1116 $this->SetX($this->TableX);
1117 $this->Cell(45,5,'Water oplossen',0,0,'L',true);
1118 $this->Cell(45,5,sprintf("%.3f",$row['bottle_priming_water']).' liter',0,0,'L',true);
1119 $this->Cell($vul,5,'',0,0,'L',false);
1120 if (! $row['keg_forced_carb']) {
1121 $this->Cell(45,5,'Water oplossen',0,0,'L',true);
1122 $this->Cell(45,5,sprintf("%.3f",$row['keg_priming_water']).' liter',0,0,'L',true);
1123 }
1124 $this->Ln();
1125
1126 $this->SetX($this->TableX);
1127 $this->Cell(45,5,'Alcohol volume',0,0,'L',true);
1128 $this->Cell(45,5,sprintf("%.1f",$row['package_abv'] + $row['bottle_priming_amount'] * 0.47 / 7.907).'%',0,0,'L',true);
1129 $this->Cell($vul,5,'',0,0,'L',false);
1130 $this->Cell(45,5,'Alcohol volume',0,0,'L',true);
1131 $this->Cell(45,5,sprintf("%.1f",$row['package_abv'] + $row['keg_priming_amount'] * 0.47 / 7.907).'%',0,0,'L',true);
1132 $this->Ln();
1133
1134 $this->SetX($this->TableX);
1135 $this->Cell(45,5,'Hergisting temperatuur',0,0,'L',true);
1136 $this->Cell(45,5,sprintf("%.1f",$row['bottle_carbonation_temp']).DEG.'C',0,0,'L',true);
1137 $this->Cell($vul,5,'',0,0,'L',false);
1138 $this->Cell(45,5,'Hergisting temperatuur',0,0,'L',true);
1139 $this->Cell(45,5,sprintf("%.1f", $row['keg_carbonation_temp']).DEG.'C',0,0,'L',true);
1140 $this->Ln();
1141 }
1142
1143 function Tasting($row) {
1144
1145 if ($this->GetY() > 200)
1146 $this->AddPage();
1147 else
1148 $this->Ln(10);
1149
1150 $vul = $this->w - $this->rMargin - $this->lMargin - 180;
1151 $cMargin=$this->cMargin;
1152 $this->cMargin=2;
1153 $this->TableX=$this->lMargin;
1154 $this->SetFont('Helvetica','B',9);
1155 $this->SetX($this->TableX);
1156 $this->SetFillColor(255,150,100);
1157 $this->Cell(0, 5, 'Proef notities',0,0,'C',true);
1158 $this->Ln();
1159
1160 $this->SetFont('Helvetica','',9);
1161 $this->SetFillColor(210,245,255);
1162
1163 $this->SetX($this->TableX);
1164 $this->Cell(45,5,'Proeven datum',0,0,'L',true);
1165 $this->Cell(45,5,$row['taste_date'],0,0,'L',true);
1166 $this->Cell($vul,5,'',0,0,'L',false);
1167 $this->Cell(45,5,'Waardering',0,0,'L',true);
1168 $this->Cell(45,5,sprintf("%.1f", $row['taste_rate']),0,0,'L',true);
1169 $this->Ln();
1170
1171 $this->SetX($this->TableX);
1172 $this->Cell(45,5,'Kleur',0,0,'L',true);
1173 $this->Cell($vul+135,5,iconv('UTF-8','windows-1252',$row['taste_color']),0,0,'L',true);
1174 $this->Ln();
1175
1176 $this->SetX($this->TableX);
1177 $this->Cell(45,5,'Helderheid',0,0,'L',true);
1178 $this->Cell($vul+135,5,iconv('UTF-8','windows-1252',$row['taste_transparency']),0,0,'L',true);
1179 $this->Ln();
1180
1181 $this->SetX($this->TableX);
1182 $this->Cell(45,5,'Schuim',0,0,'L',true);
1183 $this->Cell($vul+135,5,iconv('UTF-8','windows-1252',$row['taste_head']),0,0,'L',true);
1184 $this->Ln();
1185
1186 $this->SetX($this->TableX);
1187 $this->Cell(45,5,'Aroma',0,0,'L',true);
1188 $this->Cell($vul+135,5,iconv('UTF-8','windows-1252',$row['taste_aroma']),0,0,'L',true);
1189 $this->Ln();
1190
1191 $this->SetX($this->TableX);
1192 $this->Cell(45,5,'Smaak',0,0,'L',true);
1193 $this->Cell($vul+135,5,iconv('UTF-8','windows-1252',$row['taste_taste']),0,0,'L',true);
1194 $this->Ln();
1195
1196 $this->SetX($this->TableX);
1197 $this->Cell(45,5,'Mondgevoel',0,0,'L',true);
1198 $this->Cell($vul+135,5,iconv('UTF-8','windows-1252',$row['taste_mouthfeel']),0,0,'L',true);
1199 $this->Ln();
1200
1201 $this->SetX($this->TableX);
1202 $this->Cell(45,5,'Nasmaak',0,0,'L',true);
1203 $this->Cell($vul+135,5,iconv('UTF-8','windows-1252',$row['taste_aftertaste']),0,0,'L',true);
1204 $this->Ln();
1205
1206 $this->SetX($this->TableX);
1207 $this->Cell(45,5,'Notities',0,0,'L',true);
1208 $this->MultiCell(0,5,iconv('UTF-8','windows-1252',$row['taste_notes']),0,'L',true);
1209 $this->Ln();
1210 }
1211 }
1212
1213
1214
1215 class PDF extends PDF_MySQL_Table {
1216 function Header() {
1217 global $row;
1218 global $prdate;
1219 global $stage;
1220 global $divide_parts;
1221 global $divide_part;
1222 $this->Image('images/logo.png',10,10,30);
1223 // Title
1224 $this->SetFont('Helvetica','B',18);
1225 $this->SetX(45);
1226 $this->Cell(0,8,$row['code'].' '.$row['name'],0,1,'L');
1227 $this->Ln(1);
1228 $this->SetFont('Helvetica','',10);
1229 $this->SetX(45);
1230 $this->Cell(17,5,'Datum:',0,0,'L');
1231 $this->Cell(0,5,$prdate,0,1,'L');
1232 $this->SetX(45);
1233 $this->Cell(17,5,'Stijl:',0,0,'L');
1234 $st_name = iconv('UTF-8','windows-1252',$row['st_name']);
1235 $this->Cell(0,5,$st_name,0,1,'L');
1236 $this->SetX(45);
1237 $this->Cell(17,5,'Fase:',0,0,'L');
1238 $this->Cell(0,5,$stage[$row['stage']],0,1,'L');
1239 $this->SetX(45);
1240 $this->Cell(17,5,'Batch:',0,0,'L');
1241 if ($divide_parts == 0)
1242 $this->Cell(0,5,"Niet gespitst",0,1,'L');
1243 else
1244 $this->Cell(0,5,"Split batch ".($divide_part + 1)." van ".($divide_parts + 1),0,1,'L');
1245 $this->Ln(2);
1246 // Ensure table header is printed
1247 parent::Header();
1248 }
1249 }
1250
1251
1252 /*
1253 * Generate PDF from recipe data
1254 */
1255 $pdf = new PDF();
1256 $pdf->AddPage();
1257 $pdf->TableGlobal($row);
1258 $pdf->TableFermentables($row);
1259 $pdf->TableHops($row);
1260 $pdf->TableYeasts($row);
1261 $pdf->TableMiscs($row);
1262 $pdf->TableMashs($row);
1263 $pdf->TableWaters($row);
1264 $pdf->TableSummary($row);
1265 if (strlen($row['notes'])) {
1266 if ($pdf->GetY() > 200)
1267 $pdf->AddPage();
1268 else
1269 $pdf->Ln(10);
1270 $pdf->SetFillColor(255,150,100);
1271 $pdf->SetFont('Helvetica','B',9);
1272 $pdf->Cell(0, 5, 'Recept opmerkingen',0,0,'C',true);
1273 $pdf->Ln();
1274 $pdf->SetFont('Helvetica','',9);
1275 $pdf->SetFillColor(210,245,255);
1276 $pdf->MultiCell(0,4,iconv('UTF-8','windows-1252',$row['notes']),0,'L',true);
1277 }
1278
1279 if ($row['stage'] > 2) {
1280 $pdf->Brewday($row);
1281 }
1282
1283 if ($row['stage'] > 3) {
1284 $pdf->Fermentation($row);
1285 }
1286 if ($row['stage'] > 6) {
1287 $pdf->Packaging($row);
1288 }
1289 if ($row['stage'] > 9) {
1290 $pdf->Tasting($row);
1291 }
1292
1293 $pdf->Output();

mercurial