www/prod_checklist.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 date_default_timezone_set('Europe/Amsterdam');
23 $prdate = date(DATE_RFC2822);
24
25
26 class PDF_MySQL_Table extends FPDF
27 {
28 function Checkheader($text) {
29 $this->SetFont('Arial','B',10);
30 $this->Cell(0, 4,$text,0,0,'L',true);
31 $this->SetFont('Arial','',10);
32 $this->Ln(6);
33 }
34
35 function Checkline($text) {
36 $this->Cell(2, 4,' ',0,0,'L',true);
37 $this->Cell(4, 4,' ',1,0,'L',true);
38 $this->Cell(0, 4,' '.$text,0,1,'L',true);
39 $this->Ln(1);
40 }
41
42 function CheckInput($text, $prompt) {
43 if (strlen($text)) {
44 $this->Cell(2, 4,' ',0,0,'L',true);
45 $this->Cell(4, 4,' ',1,0,'L',true);
46 $this->Cell(130, 4,' '.$text,0,0,'L',true);
47 } else {
48 $this->Cell(136, 4,' ',0,0,'L',true);
49 }
50 $this->Cell(0, 4, 'Gemeten: _________ '.$prompt,0,1,'L',true);
51 $this->Ln(1);
52 }
53
54 function Checksplit($moment, $row) {
55 global $splitat;
56 if ($row['divide_type'] && $row['divide_type'] == $moment) {
57 $this->Ln(2);
58 $this->SetFont('Helvetica','B',14);
59 $this->Cell(0, 4,$splitat[$row['divide_type']]." splits de batch hier!",0,0,'C',true);
60 $this->SetFont('Arial','',10);
61 $this->AddPage();
62 return true;
63 }
64 return false;
65 }
66
67 function Checklist($row) {
68
69 global $my_grain_absorbtion;
70 global $my_brix_correction;
71 global $acidtype;
72 $mashwater = 0;
73 $numsalts = 0;
74 $factor = 1 / $row['divide_factor'];
75
76 $this->AddPage();
77 $this->SetFillColor(255,255,255);
78
79 $ferms = json_decode($row['json_fermentables'], true);
80 $hops = json_decode($row['json_hops'], true);
81 $miscs = json_decode($row['json_miscs'], true);
82 $yeasts = json_decode($row['json_yeasts'], true);
83
84 if ($row['starter_enable'] && $row['prop1_volume']) {
85 $this->Checkheader('Giststarter maken');
86 $days = 0;
87 $last = 0;
88 for ($i = 1; $i < 5; $i++) {
89 $pt = "prop".$i."_type";
90 $pv = "prop".$i."_volume";
91 if (floatval($row[$pv])) {
92 $last = $i;
93 if ($row[$pt] == 0)
94 $days += 2;
95 else if ($row[$pt] == 1)
96 $days += 4;
97 else
98 $days += 6;
99 }
100 }
101 $this->Checkline("begin ongeveer ".$days." dagen voor de brouwdag met de giststarter");
102 for ($i = 1; $i < 5; $i++) {
103 $pt = "prop".$i."_type";
104 $pv = "prop".$i."_volume";
105 if (floatval($row[$pv])) {
106 $s = "Starter stap ".$i.", van ".sprintf("%.3f",floatval($row[$pv]));
107 $s .= " liter maken met SG ".sprintf("%.3f",floatval($row['starter_sg']));
108 $this->Checkline($s);
109 if ($row[$pt] == 0) {
110 $s = "ongeveer 24 uur op een magneetroerder";
111 } else if ($row[$pt] == 1) {
112 $s = "enkele dagen regelmatig schudden";
113 } else {
114 $s = "bijna een week rustig laten staan";
115 }
116 $s .= " tot er voldoende gist is";
117 $this->Checkline($s);
118 if ($i < $last) {
119 $this->Checkline("starter minstens 24 uur in de koeling laten uitzakken");
120 $this->Checkline("starter uit de koelkast halen en afgieten");
121 } else {
122 $this->Checkline("starter in de koeling zetten tot de brouwdag");
123 $this->Checkline("starter op de brouwdag uit de koelkast halen en afgieten");
124 }
125 }
126 }
127 $this->Ln(5);
128 }
129
130 $this->Checkheader('Water en -behandeling');
131 if ($row['w1_name']) {
132 $this->Checkline(sprintf("%.1f",floatval($row['w1_amount'] * $factor)).' liter water '.$row['w1_name']);
133 $mashwater += floatval($row['w1_amount'] * $factor);
134 }
135 if ($row['w2_name'] && floatval($row['w2_amount'])) {
136 $this->Checkline(sprintf("%.1f",floatval($row['w2_amount'] * $factor)).' liter water '.$row['w2_name']);
137 $mashwater += floatval($row['w2_amount'] * $factor);
138 }
139 foreach($miscs as $item) {
140 if ($item['m_type'] == 4) { // Only the water agents
141 $unit = ($item['m_amount_is_weight']) ? " gr ":" ml ";
142 $this->Checkline(sprintf("%.2f",floatval($item['m_amount'] * 1000 * $factor)).$unit.$item['m_name']);
143 $numsalts++;
144 }
145 }
146 $this->Ln(5);
147
148 $this->Checkheader('Mout afwegen en schroten');
149 foreach($ferms as $item) {
150 if ($item['f_added'] == 0) { // to mash
151 $s = sprintf("%.3f",floatval($item['f_amount'] * $factor)).' kg `';
152 $s .= iconv('UTF-8','windows-1252',$item['f_name']);
153 $s .= '` ('.iconv('UTF-8','windows-1252',$item['f_supplier']).')';
154 $this->Checkline($s);
155 }
156 }
157 $this->Checkline('mout schroten');
158 $this->Ln(5);
159
160 $this->Checkheader('Maischen');
161 $mvol = 0;
162 $msugars = 0; // mash sugars
163 $grainabsorbtion = 0;
164 $arr = json_decode($row['json_mashs'], true);
165 if (count($arr) > 0) {
166 $loop = 0;
167 foreach($arr as $item) {
168 if ($item['step_type'] == 0)
169 $mvol += $item['step_infuse_amount'] * $factor; // We need this later.
170 if ($loop == 0) {
171 if ($item['step_type'] == 0)
172 $l = $item['step_infuse_amount'] * $factor;
173 else
174 $l = $mashwater;
175 $s = sprintf("%.1f",$l).' liter water opwarmen tot ';
176 $s .= sprintf("%.1f",$item['step_infuse_temp']).DEG.'C (';
177 $s .= sprintf("%.1f",kettle_cm($l,$row['eq_tun_volume'],$row['eq_tun_height']));
178 $s .= ' cm onder de rand)';
179 $this->Checkline($s);
180 if ($numsalts > 0)
181 $this->Checkline('brouwzouten en -zuren toevoegen');
182 $this->Checkline('mout storten en inmaischen');
183 foreach($hops as $item2) {
184 if ($item2['h_useat'] == 0) {
185 $s = sprintf("%.1f",$item2['h_amount']*1000 * $factor).' gr `';
186 $s .= iconv('UTF-8','windows-1252',$item2['h_name']).'` toevoegen';
187 $this->Checkline($s);
188 }
189 }
190 foreach($miscs as $item3) {
191 if ($item3['m_use_use'] == 1 && $item3['m_type'] != 4) { // Only if not a water agent
192 $unit = ($item3['m_amount_is_weight']) ? " gr ":" ml ";
193 $s = sprintf("%.2f",$item3['m_amount']*1000 * $factor).$unit.'`';
194 $s .= iconv('UTF-8','windows-1252',$item3['m_name']).'` toevoegen';
195 $this->Checkline($s);
196 }
197 }
198 if ($item['step_temp'] != $item['end_temp']) {
199 $this->CheckInput($item['step_time'].' minuten bij '.$item['step_temp'].DEG.'C'.' tot '.$item['end_temp'].DEG.'C', 'Brix');
200 } else {
201 $this->CheckInput($item['step_time'].' minuten bij '.$item['step_temp'].DEG.'C', 'Brix');
202 }
203 $this->CheckInput('pH meten en bijstellen (doel pH beslag: '.sprintf("%.1f",$row['mash_ph']).' pH)', 'pH');
204 } else {
205 if ($item['step_type'] == 0) { // Infusion
206 $s = 'toevoegen '.sprintf("%.1f",$item['step_infuse_amount'] * $factor).' liter water van ';
207 $s .= $item['step_infuse_temp'].DEG.'C';
208 } else if ($item['step_type'] == 1) { // Direct heat
209 $s = 'opwarmen tot '.$item['step_temp'].DEG.'C';
210 } else { // Decoction
211 $s = 'uitnemen, opwarmen, koken en terugstorten van '.sprintf("%.1f",$item['step_infuse_amount']*$factor);
212 $s .= ' liter deelbeslag';
213 }
214 $this->Checkline($s);
215 if ($item['step_temp'] != $item['end_temp']) {
216 $this->CheckInput($item['step_time'].' minuten bij '.$item['step_temp'].DEG.'C'.' tot '.$item['end_temp'].DEG.'C', 'Brix');
217 } else {
218 $this->CheckInput($item['step_time'].' minuten bij '.$item['step_temp'].DEG.'C', 'Brix');
219 }
220 }
221 $loop++;
222 }
223 $est_mash_sg = 0;
224 foreach($ferms as $item) {
225 if ($item['f_added'] == 0) {
226 $d = $item['f_amount'] * $factor * ($item['f_yield'] / 100) * (1 - $item['f_moisture'] / 100);
227 $mvol += $item['f_amount'] * $factor * $item['f_moisture'] / 100;
228 $grainabsorbtion += $my_grain_absorbtion * $item['f_amount'] * $factor;
229 $msugars += $d;
230 }
231 }
232 $sugardensity = 1.611;
233 $v = $msugars / $sugardensity + $mvol;
234 $plato = 1000 * $msugars / ($v * 10); // deg. Plato
235 $mash_sg = plato_to_sg($plato);
236 $this->CheckInput('doel SG eind maischen: '.density_str($mash_sg), 'SG');
237 }
238 if ($this->GetY() > 200)
239 $this->AddPage();
240 else
241 $this->Ln(5);
242
243 $this->Checkheader('Filteren en spoelen');
244 $s = sprintf("%.1f",$row['sparge_volume'] * $factor).' liter spoelwater opwarmen tot '.sprintf("%.1f",$row['sparge_temp']).DEG.'C';
245 $this->Checkline($s);
246 $s = 'spoelwater aanzuren tot pH <= '.sprintf("%.1f",$row['sparge_ph']).' met ';
247 $s .= sprintf("%.2f",$row['sparge_acid_amount']*1000*$factor).' ml. '.$acidtype[$row['sparge_acid_type']];
248 $this->CheckInput($s, 'pH');
249 $spoelw = (($row['boil_size']*$factor) - $mashwater + $grainabsorbtion + $row['eq_lauter_deadspace']) * 1.03; // A small heat correction
250 $this->Checkline('spoelen met ongeveer '.sprintf("%.1f",$spoelw).' liter spoelwater');
251 $s = 'doelvolume in kookketel: '.sprintf("%.1f",$row['boil_size'] * $factor * 1.04).' liter (';
252 $s .= sprintf("%.1f",kettle_cm($row['boil_size'] * $factor * 1.04,$row['eq_kettle_volume'],$row['eq_kettle_height'])).' cm onder de rand)';
253 $this->CheckInput($s, 'cm');
254 $pre_sg = estimate_sg($msugars * floatval($row['efficiency']) / 100,floatval($row['boil_size'] * $factor));
255 $this->CheckInput('doel SG in kookketel: '.density_str($pre_sg), 'SG');
256 $this->CheckInput('', 'pH');
257 foreach($hops as $item2) {
258 if ($item2['h_useat'] == 1) {
259 $s = sprintf("%.1f",$item2['h_amount']*1000*$factor).' gr `';
260 $s .= iconv('UTF-8','windows-1252',$item2['h_name']).'` toevoegen na het spoelen';
261 $this->Checkline($s);
262 }
263 }
264 if ($this->Checksplit(1, $row))
265 $factor = 1;
266 if ($this->GetY() > 200 && $row['boil_time'] > 0)
267 $this->AddPage();
268 else if ($this->GetY() > 270 && $row['boil_time'] == 0)
269 $this->AddPage();
270 else
271 $this->Ln(5);
272
273 $this->Checkheader('Koken');
274 if ($row['boil_time'] > 0) {
275 $this->Checkline('totale kooktijd: '.$row['boil_time'].' min.');
276 for ($i = $row['boil_time']; $i >= 0; $i--) {
277 if ($i == 10) {
278 foreach($ferms as $item1) {
279 if ($item1['f_added'] == 1) {
280 $s = sprintf("%.3f",$item1['f_amount']*$factor).' kg `';
281 $s .= iconv('UTF-8','windows-1252',$item1['f_name']).'` bij 10 minuten voor einde koken';
282 $this->Checkline($s);
283 }
284 }
285 if ($row['brew_cooling_method'] == 1)
286 $this->Checkline('Plaats dompelkoeler bij 10 minuten voor einde koken');
287 }
288 foreach($hops as $item2) {
289 if (($item2['h_useat'] == 2 || $item2['h_useat'] == 3) && ($item2['h_time'] == $i)) {
290 $s = sprintf("%.2f",$item2['h_amount']*1000*$factor).' gr `';
291 $s .= iconv('UTF-8','windows-1252',$item2['h_name']).'` bij ';
292 if ($i > 0)
293 $s .= $i.' minuten voor einde koken';
294 else
295 $s .= 'vlamuit';
296 $this->Checkline($s);
297 }
298 }
299 foreach($miscs as $item3) {
300 if ($item3['m_use_use'] == 2 && $item3['m_time'] == $i) {
301 $unit = ($item3['m_amount_is_weight']) ? " gr ":" ml ";
302 $s = sprintf("%.2f",$item3['m_amount']*1000*$factor).$unit.'`';
303 $s .= iconv('UTF-8','windows-1252',$item3['m_name']).'` bij ';
304 if ($i > 0)
305 $s .= $i.' minuten voor einde koken';
306 else
307 $s .= 'vlamuit';
308 $this->Checkline($s);
309 }
310 }
311
312 }
313 $s = 'doelvolume einde koken: '.sprintf("%.1f",$row['batch_size']*$factor*1.04).' liter (';
314 $s .= sprintf("%.1f",kettle_cm($row['batch_size']*$factor*1.04,$row['eq_kettle_volume'],$row['eq_kettle_height']));
315 $s .= ' cm onder de rand)';
316 $this->CheckInput($s, 'cm');
317 $this->CheckInput('doel SG einde koken: '.density_str($row['est_og3']), 'SG');
318 $this->CheckInput('', 'pH');
319 if ($this->Checksplit(2, $row))
320 $factor = 1;
321 } else {
322 $this->Checkline('Dit is een `no-boil\' recept');
323 }
324 if ($this->GetY() > 200)
325 $this->AddPage();
326 else
327 $this->Ln(5);
328
329 if (($row['brew_whirlpool9'] + $row['brew_whirlpool7'] + $row['brew_whirlpool6'] + $row['brew_whirlpool2']) > 0) {
330 $this->Checkheader('Whirlpool en koelen');
331 if ($row['brew_whirlpool9'] > 0) {
332 $s = 'Whirlpool voor '.$row['brew_whirlpool9'].' min. Temperatuur boven 85'.DEG.'C houden';
333 $this->Checkline($s);
334 }
335 if ($row['brew_whirlpool7'] > 0) {
336 $this->Checkline('koelen tot 79'.DEG.'C');
337 $s = 'Whirlpool voor '.$row['brew_whirlpool7'].' min. Temperatuur tussen 72 en 79'.DEG.'C houden';
338 $this->Checkline($s);
339 }
340 if ($row['brew_whirlpool6'] > 0) {
341 $this->Checkline('koelen tot 66'.DEG.'C');
342 $s = 'Whirlpool voor '.$row['brew_whirlpool6'].' min. Temperatuur tussen 60 en 66'.DEG.'C houden';
343 $this->Checkline($s);
344 }
345 foreach($hops as $item2) {
346 if ($item2['h_useat'] == 4) {
347 $s = sprintf("%.1f",$item2['h_amount']*1000*$factor).' gr `';
348 $s .= iconv('UTF-8','windows-1252',$item2['h_name']).'` voor ';
349 $s .= $item2['h_time'].' minuten in de whirlpool';
350 $this->Checkline($s);
351 }
352 }
353 $this->Checkline('koelen tot '.sprintf("%.1f",$row['brew_cooling_to']).DEG.'C');
354 if ($row['brew_whirlpool2'] > 0) {
355 $s = 'Whirlpool voor '.$row['brew_whirlpool2'].' min.';
356 $this->Checkline($s);
357 }
358 } else {
359 $this->Checkheader('Koelen');
360 $this->Checkline('koelen tot '.sprintf("%.1f",$row['brew_cooling_to']).DEG.'C');
361 }
362 $this->Checkline('gistvat ontsmetten en evt. pomp en slangen ontsmetten');
363 $this->CheckInput('wort naar gistvat overbrengen', 'Liter');
364 if ($this->Checksplit(3, $row))
365 $factor = 1;
366 if ($this->GetY() > 240)
367 $this->AddPage();
368 else
369 $this->Ln(5);
370
371 $climate = $row['brew_cooling_to'];
372 $this->Checkheader('Gist enten');
373 $dry = 0;
374 foreach ($yeasts as $item) {
375 $name = iconv('UTF-8','windows-1252',$item['y_name']);
376 $product_id = iconv('UTF-8','windows-1252',$item['y_product_id']);
377 if ($item['y_use'] == 0) { // primary
378 if ($item['y_form'] == 0) { // Liquid
379 $this->Checkline(($item['y_amount']*$factor).' pak '.$product_id.', '.$name.' gist');
380 } else if ($item['y_form'] == 1 || $item['y_form'] == 6) { // Dry or dried Kveik
381 $s = sprintf("%.1f",$item['y_amount']*$factor*1000).' gram '.$product_id.', '.$name;
382 $s .= ' gist';
383 if ($item['y_form'] == 1)
384 $dry += $item['y_amount']*$factor*10000;
385 $this->Checkline($s);
386 } else { // Slant/Culture/Frozen/Bottle
387 $s = sprintf("%.0f",$item['y_amount']*$factor*1000).' ml '.$product_id.', '.$name.' gist';
388 $this->Checkline($s);
389 }
390 if ($item['y_type'] == 6 && floatval($item['y_pitch_temperature']) > 0) {
391 $s = 'Gist enten bij ' . sprintf("%.1f",floatval($item['y_pitch_temperature'])).DEG.'C';
392 $this->Checkline($s);
393 $climate = $item['y_pitch_temperature'];
394 }
395 }
396 }
397 if ($dry > 0) {
398 $this->Checkline('Gist rechtstreeks over het wort strooien');
399 } else {
400 if ($row['starter_enable'] && $row['prop1_volume'])
401 $this->Checkline('giststarter toevoegen');
402 else
403 $this->Checkline('gist toevoegen');
404 }
405 if ($row['brew_fermenter_extrawater'] > 0)
406 $this->Checkline(sprintf("%.1f", $row['brew_fermenter_extrawater']*$factor).' liter water toevoegen in gistvat');
407 if ($row['brew_aeration_type'] > 0) {
408 $s = 'wort '.$row['brew_aeration_time'].' minuten beluchten met ';
409 $s .= ($row['brew_aeration_type'] == 1) ? "lucht":"zuurstof";
410 $this->Checkline($s);
411 }
412 if ($this->GetY() > 200)
413 $this->AddPage();
414 else
415 $this->Ln(5);
416
417 $this->Checkheader('Vergisting starten');
418 $this->Checkline('klimaatkast instellen op '.sprintf("%.1f",$climate).DEG.'C');
419
420 /*
421 * During primary fermentation: fermentables, misc
422 */
423 $lines = 0;
424 foreach($ferms as $item1) {
425 if ($item1['f_added'] == 2)
426 $lines++;
427 }
428 foreach($miscs as $item3) {
429 if ($item3['m_use_use'] == 3)
430 $lines++;
431 }
432 if ($lines) {
433 if ($this->GetY() > (270 - (5 * $lines)))
434 $this->AddPage();
435 else
436 $this->Ln(5);
437 $this->Checkheader('Hoofdgisting');
438 }
439 foreach($ferms as $item1) {
440 if ($item1['f_added'] == 2) {
441 $s = sprintf("%.3f",$item1['f_amount']*$factor).' kg `';
442 $s .= iconv('UTF-8','windows-1252',$item1['f_name']).'` op dag 3 of 4 toevoegen';
443 $this->Checkline($s);
444 }
445 }
446 foreach($miscs as $item3) {
447 if ($item3['m_use_use'] == 3) {
448 $unit = ($item3['m_amount_is_weight']) ? " gr ":" ml ";
449 $s = sprintf("%.1f",$item3['m_amount']*$factor*1000).$unit.'`';
450 $s .= iconv('UTF-8','windows-1252',$item3['m_name']).'` op dag 3 of 4 toevoegen';
451 $this->Checkline($s);
452 }
453 }
454 if ($this->Checksplit(4, $row))
455 $factor = 1;
456
457 /*
458 * During secondary fermentation: yeast
459 */
460 $lines = 0;
461 foreach ($yeasts as $item4) {
462 if ($item4['y_use'] == 1)
463 $lines++;
464 if ($item4['y_harvest_time'] > 0)
465 $lines++;
466 }
467 if ($lines) {
468 if ($this->GetY() > (270 - (5 * $lines)))
469 $this->AddPage();
470 else
471 $this->Ln(5);
472 $this->Checkheader('Nagisting');
473 }
474 foreach ($yeasts as $item4) {
475 if ($item4['y_use'] == 1) {
476 $name = iconv('UTF-8','windows-1252',$item4['y_name']);
477 $product_id = iconv('UTF-8','windows-1252',$item4['y_product_id']);
478 if ($item4['y_form'] == 0) { // Liquid
479 $this->Checkline(($item4['y_amount']*$factor).' pak '.$product_id.', '.$name.' gist (eventueel met starter)');
480 } else if ($item['y_form'] == 1) { // Dry
481 $s = sprintf("%.1f",$item4['y_amount']*$factor*1000).' gram '.$product_id.', '.$name;
482 $s .= ' gist';
483 $this->Checkline($s);
484 } else { // Slant/Culture/Frozen/Bottle
485 $s = sprintf("%.0f",$item4['y_amount']*$factor*1000).' ml '.$product_id.', '.$name.' gist (eventueel met starter)';
486 $this->Checkline($s);
487 }
488 }
489 if ($item4['y_harvest_time'] > 0) {
490 $s = 'Na ' . $item4['y_harvest_time'] . ' uur gist oogsten vanaf de ';
491 if ($item4['y_harvest_top'] > 0)
492 $s .= 'bovenzijde';
493 else
494 $s .= 'bodem';
495 $this->Checkline($s);
496 }
497 }
498 if ($this->Checksplit(5, $row))
499 $factor = 1;
500
501 /*
502 * During tertiary fermentation: fermentables, hop, yeast, misc
503 */
504 $lines = 0;
505 foreach($ferms as $item1) {
506 if ($item1['f_added'] == 3)
507 $lines++;
508 }
509 foreach($hops as $item2) {
510 if ($item2['h_useat'] == 5)
511 $lines++;
512 }
513 foreach ($yeasts as $item4) {
514 if ($item4['y_use'] == 2)
515 $lines++;
516 }
517 foreach($miscs as $item3) {
518 if ($item3['m_use_use'] == 4)
519 $lines++;
520 }
521 if ($lines) {
522 if ($this->GetY() > (270 - (5 * $lines)))
523 $this->AddPage();
524 else
525 $this->Ln(5);
526 $this->Checkheader('Lagering');
527 }
528 foreach($ferms as $item1) {
529 if ($item1['f_added'] == 3) {
530 $s = sprintf("%.3f",$item1['f_amount']*$factor).' kg `';
531 $s .= iconv('UTF-8','windows-1252',$item1['f_name']).'` toevoegen';
532 $this->Checkline($s);
533 }
534 }
535 foreach($hops as $item2) {
536 if ($item2['h_useat'] == 5) {
537 $s = sprintf("%.1f",$item2['h_amount']*$factor*1000).' gr `';
538 $s .= iconv('UTF-8','windows-1252',$item2['h_name']).'` voor ';
539 $s .= sprintf("%.0f",$item2['h_time']/1440).' dagen toevoegen';
540 $this->Checkline($s);
541 }
542 }
543 foreach ($yeasts as $item4) {
544 if ($item4['y_use'] == 2) {
545 $name = iconv('UTF-8','windows-1252',$item4['y_name']);
546 $product_id = iconv('UTF-8','windows-1252',$item4['y_product_id']);
547 if ($item4['y_form'] == 0) { // Liquid
548 $s = ($item4['y_amount']*$factor).' pak '.$product_id.', '.$name.' gist (eventueel met starter)';
549 } else if ($item4['y_form'] == 1) { // Dry
550 $s = sprintf("%.1f",$item4['y_amount']*$factor*1000).' gram '.$product_id.', '.$name;
551 $s .= ' gist';
552 } else { // Slant/Culture/Frozen/Bottle
553 $s = sprintf("%.0f",$item4['y_amount']*$factor*1000).' ml '.$product_id.', '.$name;
554 $s .= ' gist (eventueel met starter)';
555 }
556 $this->Checkline($s);
557 }
558 }
559 foreach($miscs as $item3) {
560 if ($item3['m_use_use'] == 4) {
561 $unit = ($item3['m_amount_is_weight']) ? " gr ":" ml ";
562 $s = sprintf("%.1f",$item3['m_amount']*$factor*1000).$unit.'`';
563 $s .= iconv('UTF-8','windows-1252',$item3['m_name']).'` voor ';
564 $s .= sprintf("%.0f",$item3['m_time']/1440).' dagen toevoegen';
565 $this->Checkline($s);
566 }
567 }
568 if ($this->Checksplit(6, $row))
569 $factor = 1;
570
571 /*
572 * During packaging: fermentables, yeast, misc
573 */
574 $lines = 0;
575 foreach($ferms as $item1) {
576 if ($item1['f_added'] >= 4)
577 $lines++;
578 }
579 $yeasts = json_decode($row['json_yeasts'], true);
580 foreach ($yeasts as $item4) {
581 if ($item4['y_use'] == 3)
582 $lines++;
583 }
584 $miscs = json_decode($row['json_miscs'], true);
585 foreach($miscs as $item3) {
586 if ($item3['m_use_use'] == 5)
587 $lines++;
588 }
589 if ($lines) {
590 if ($this->GetY() > (270 - (5 * $lines)))
591 $this->AddPage();
592 else
593 $this->Ln(5);
594 $this->Checkheader('Verpakken');
595 }
596 foreach($ferms as $item1) {
597 if ($item1['f_added'] == 4) {
598 $s = sprintf("%.3f",$item1['f_amount']*$factor).' kg `';
599 $s .= iconv('UTF-8','windows-1252',$item1['f_name']).'`';
600 if ($row['bottle_priming_water'] > 0)
601 $s .= ' met '.sprintf("%.3f",$row['bottle_priming_water']*$factor).' liter water';
602 $s .= ' bij bottelen';
603 $this->Checkline($s);
604 }
605 if ($item1['f_added'] == 5) {
606 $s = sprintf("%.3f",$item1['f_amount']*$factor).' kg `';
607 $s .= iconv('UTF-8','windows-1252',$item1['f_name']).'`';
608 if ($row['keg_priming_water'] > 0)
609 $s .= ' met '.sprintf("%.3f",$row['keg_priming_water']*$factor).' liter water';
610 $s .= ' bij op fust zetten';
611 $this->Checkline($s);
612 }
613 }
614 foreach ($yeasts as $item4) {
615 if ($item4['y_use'] == 3) {
616 $name = iconv('UTF-8','windows-1252',$item4['y_name']);
617 $product_id = iconv('UTF-8','windows-1252',$item4['y_product_id']);
618 if ($item4['y_form'] == 0) { // Liquid
619 $s = '`'.$product_id.', '.$name;
620 } else if ($item4['y_form'] == 1) { // Dry
621 $s = sprintf("%.1f",$item4['y_amount']*$factor*1000).' gram `'.$product_id.', '.$name;
622 } else { // Slant/Culture/Frozen/Bottle
623 $s = sprintf("%.0f",$item4['y_amount']*$factor*1000).' ml `'.$product_id.', '.$name;
624 }
625 $s .= '` als bottelgist';
626 $this->Checkline($s);
627 }
628 }
629 foreach($miscs as $item3) {
630 if ($item3['m_use_use'] == 5) {
631 $unit = ($item3['m_amount_is_weight']) ? " gr ":" ml ";
632 $s = sprintf("%.1f",$item3['m_amount']*$factor*1000).$unit.'`';
633 $s .= iconv('UTF-8','windows-1252',$item3['m_name']).'` bij bottelen toevoegen';
634 $this->Checkline($s);
635 }
636 }
637 }
638 }
639
640
641
642 class PDF extends PDF_MySQL_Table {
643 function Header() {
644 global $row;
645 global $prdate;
646 global $stage;
647 $this->Image('images/logo.png',10,10,30);
648 // Title
649 $this->SetFont('Helvetica','B',18);
650 $this->SetX(45);
651 $this->Cell(0,8,$row['code'].' '.$row['name'],0,1,'L');
652 $this->Ln(1);
653 $this->SetFont('Helvetica','',10);
654 $this->SetX(45);
655 $this->Cell(17,5,'Datum:',0,0,'L');
656 $this->Cell(0,5,$prdate,0,1,'L');
657 $this->SetX(45);
658 $this->Cell(17,5,'Stijl:',0,0,'L');
659 $st_name = iconv('UTF-8','windows-1252',$row['st_name']);
660 $this->Cell(0,5,$st_name,0,1,'L');
661 $this->SetX(45);
662 $this->Cell(17,5,'Fase:',0,0,'L');
663 $this->Cell(0,5,$stage[$row['stage']],0,1,'L');
664 $this->SetX(45);
665 $this->Cell(17,5,'Batch:',0,0,'L');
666 if ($row['divide_parts'] == 0)
667 $this->Cell(0,5,"Niet gespitst",0,1,'L');
668 else
669 $this->Cell(0,5,"Split batch ".($row['divide_part'] + 1)." van ".($row['divide_parts'] + 1),0,1,'L');
670 $this->Ln(2);
671 // Ensure table header is printed
672 parent::Header();
673 }
674 }
675
676
677 /*
678 * Generate checklist PDF from recipe data
679 */
680 $pdf = new PDF();
681 $pdf->Checklist($row);
682 $pdf->Output();

mercurial