www/rec_print.php

Thu, 15 Nov 2018 22:22:51 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 15 Nov 2018 22:22:51 +0100
changeset 96
107c12c3e49d
parent 94
295c3af2a421
child 98
92d6bc8a4cdd
permissions
-rw-r--r--

Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.

80
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 <?php
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 require_once($_SERVER['DOCUMENT_ROOT'].'/includes/global.inc.php');
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
3 require_once($_SERVER['DOCUMENT_ROOT'].'/includes/formulas.php');
80
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 require_once($_SERVER['DOCUMENT_ROOT'].'/fpdf/fpdf.php');
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 $link = mysqli_connect(DBASE_HOST,DBASE_USER,DBASE_PASS,DBASE_NAME);
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
8 if (! $link) {
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
9 die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
10 }
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
11 if (! mysqli_set_charset($link, "utf8" )) {
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
12 echo "error";
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
13 return 1;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
14 }
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
15
80
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 setlocale ( LC_ALL, 'nl_NL.UTF-8');
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 $record = $_GET["record"];
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 $result = mysqli_query($link, "SELECT * FROM recipes WHERE record='".$record."'");
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 $row = mysqli_fetch_array($result);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
21 $total_fermentables = 0.0;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
22 $cost_fermentables = 0.0;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
23 $total_hops = 0.0;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
24 $cost_hops = 0.0;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
25 $cost_yeasts = 0.0;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
26 $cost_miscs = 0.0;
87
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
27 $pSugar = 0;
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
28 $pCara = 0;
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
29 $svg = 77;
89
082c23b26055 Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents: 88
diff changeset
30 $colorw = 0;
93
357d59d8ec5e Added IBU and cost totals.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
31 $total_ibus = 0;
94
295c3af2a421 Include boil_size field in the recipes table. Calculate pre-boil SG. Use that in the IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 93
diff changeset
32 $preboil_sg = 0;
80
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 class PDF_MySQL_Table extends FPDF
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 {
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 protected $ProcessingTable=false;
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 protected $aCols=array();
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 protected $TableX;
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 function Header() {
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 // Print the table header if necessary
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 if ($this->ProcessingTable)
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 $this->TableHeader();
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 }
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46 function TableHeader() {
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47 $this->SetFont('Helvetica','B',9);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48 $this->SetX($this->TableX);
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
49 $this->SetFillColor(255,150,100);
80
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 foreach($this->aCols as $col)
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51 $this->Cell($col['w'],5,$col['c'],0,0,$col['a'],true);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 $this->Ln();
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53 }
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 function AddCol($width=-1, $caption='', $align='L') {
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56 $this->aCols[]=array('c'=>$caption,'w'=>$width,'a'=>$align);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 }
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
59 function TableGlobal($row) {
80
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60 /* 2 Columns */
89
082c23b26055 Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents: 88
diff changeset
61 $vul = $this->w - $this->rMargin - $this->lMargin - 120;
80
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62 $cMargin=$this->cMargin;
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
63 $this->cMargin=2;
80
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 $this->TableX=$this->lMargin;
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
65 $this->SetFont('Helvetica','B',9);
80
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66 $this->SetX($this->TableX);
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
67 $this->SetFillColor(255,150,100);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
68 $this->Cell(0, 5, 'Recept overzicht',0,0,'C',true);
80
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69 $this->Ln();
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 $this->SetFont('Helvetica','',9);
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
72 $this->SetFillColor(210,245,255);
80
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74 $this->SetX($this->TableX);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75 $this->Cell(35,5,'Type',0,0,'L',true);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76 $this->Cell(25,5,$row['type'],0,0,'L',true);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 $this->Cell($vul,5,'',0,0,'L',false);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78 $this->Cell(35,5,'Batch grootte',0,0,'L',true);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79 $this->Cell(25,5,$row['batch_size'].' liter',0,0,'L',true);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80 $this->Ln();
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 $this->SetX($this->TableX);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83 $this->Cell(35,5,'Kooktijd',0,0,'L',true);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84 $this->Cell(25,5,$row['boil_time'].' minuten',0,0,'L',true);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85 $this->Cell($vul,5,'',0,0,'L',false);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 $this->Cell(35,5,'Brouwzaal rendement',0,0,'L',true);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 $this->Cell(25,5,$row['efficiency'].' %',0,0,'L',true);
84
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
88 $this->Ln(10);
80
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 $this->cMargin=$cMargin;
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 }
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
93 function TableFermentables($row) {
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
94 global $cost_fermentables;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
95 global $total_fermentables;
87
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
96 global $pSugar;
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
97 global $pCara;
89
082c23b26055 Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents: 88
diff changeset
98 global $colorw;
94
295c3af2a421 Include boil_size field in the recipes table. Calculate pre-boil SG. Use that in the IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 93
diff changeset
99 global $preboil_sg;
84
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
100 $vul = $this->w - $this->rMargin - $this->lMargin - 132;
80
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 $this->AddCol($vul,'Grondstof','L');
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
102 $this->AddCol(30,'Leverancier','L');
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
103 $this->AddCol(15,'EBC','R');
84
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
104 $this->AddCol(17,'Moment','L');
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
105 $this->AddCol(20,'Kg','R');
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
106 $this->AddCol(15,'Procent','R');
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
107 $this->AddCol(15,'Opbr.','R');
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
108 $this->AddCol(20,'Prijs','R');
80
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 $cMargin=$this->cMargin;
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
111 $this->cMargin=2;
80
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112 $this->TableX=$this->lMargin;
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113 $this->TableHeader();
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 $this->ProcessingTable=true;
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115
85
ca7a37586551 Added SG/Plato formulas for PHP. Added OG calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 84
diff changeset
116 $sugf = 0;
80
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 $this->SetFont('Helvetica','',9);
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
118 $this->SetFillColor(250, 195, 65);
80
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119 $arr = json_decode($row['json_fermentables'], true);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120 foreach($arr as $item) { //foreach element in $arr
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
121 $name = iconv('UTF-8','windows-1252',$item['f_name']);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
122 $supplier = iconv('UTF-8','windows-1252',$item['f_supplier']);
84
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
123 $added = iconv('UTF-8','windows-1252',$item['f_added']);
87
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
124 $type = iconv('UTF-8','windows-1252',$item['f_type']);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
125 $graintype = iconv('UTF-8','windows-1252',$item['f_graintype']);
80
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
126 $amount = floatval($item['f_amount']);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
127 $costkg = floatval($item['f_cost']);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
128 $yield = floatval($item['f_yield']);
85
ca7a37586551 Added SG/Plato formulas for PHP. Added OG calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 84
diff changeset
129 $moisture = floatval($item['f_moisture']);
80
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
130 $color = floatval($item['f_color']);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
131 $percent = floatval($item['f_percentage']);
87
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
132
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
133 if ($type == "Sugar")
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
134 $pSugar += $percent;
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
135 if ($graintype == "Crystal")
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
136 $pCara += $percent;
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
137
80
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138 $cost = $amount * $costkg;
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
139 $cost_fermentables += $cost;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
140 $total_fermentables += $amount;
85
ca7a37586551 Added SG/Plato formulas for PHP. Added OG calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 84
diff changeset
141 /* Calculate the amount of sugars */
ca7a37586551 Added SG/Plato formulas for PHP. Added OG calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 84
diff changeset
142 $d = $amount * ($yield / 100) * (1 - $moisture / 100);
ca7a37586551 Added SG/Plato formulas for PHP. Added OG calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 84
diff changeset
143 if ($added == "Mash")
ca7a37586551 Added SG/Plato formulas for PHP. Added OG calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 84
diff changeset
144 $d = floatval($row['efficiency']) / 100 * $d;
ca7a37586551 Added SG/Plato formulas for PHP. Added OG calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 84
diff changeset
145 $sugf += $d;
89
082c23b26055 Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents: 88
diff changeset
146 $colorw += ($amount * ebc_to_srm($color) / $row['batch_size']) * 8.34436;
85
ca7a37586551 Added SG/Plato formulas for PHP. Added OG calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 84
diff changeset
147
80
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148 $this->Cell($vul,5,$name,0,0,'L',true);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149 $this->Cell(30,5,$supplier,0,0,'L',true);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150 $this->Cell(15,5,sprintf("%.0f",$color),0,0,'R',true);
84
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
151 $this->Cell(17,5,added_type_names($added),0,0,'L',true);
80
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152 $this->Cell(20,5,sprintf("%8.3f",$amount),0,0,'R',true);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
153 $this->Cell(15,5,sprintf("%.1f%%",$percent),0,0,'R',true);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154 $this->Cell(15,5,sprintf("%.1f%%",$yield),0,0,'R',true);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
155 $this->Cell(20,5,sprintf("%8.3f",$cost).EURO,0,0,'R',true);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156 $this->Ln();
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
157 }
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
158
96
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 94
diff changeset
159 $row['est_og'] = estimate_sg($sugf, floatval($row['batch_size']));
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 94
diff changeset
160 $preboil_sg = estimate_sg($sugf, floatval($row['boil_size']));
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
161 $this->SetFillColor(210,245,255);
87
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
162 $this->Cell($vul+62,5,'',0,0,'L',false);
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
163 $this->Cell(20,5,sprintf("%8.3f",$total_fermentables),0,0,'R',true);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
164 $this->Cell(30,5,'',0,0,'L',false);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
165 $this->Cell(20,5,sprintf("%8.3f",$cost_fermentables).EURO,0,0,'R',true);
84
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
166 $this->Ln(10);
80
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
167 $this->ProcessingTable=false;
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
168 $this->cMargin=$cMargin;
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
169 $this->aCols=array();
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
170 }
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
171
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
172 function TableHops($row) {
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
173 global $total_hops;
93
357d59d8ec5e Added IBU and cost totals.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
174 global $total_ibus;
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
175 global $cost_hops;
94
295c3af2a421 Include boil_size field in the recipes table. Calculate pre-boil SG. Use that in the IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 93
diff changeset
176 global $preboil_sg;
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
177 $vul = $this->w - $this->rMargin - $this->lMargin - 135;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
178 $this->AddCol($vul,'Hop','L');
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
179 $this->AddCol(35,'Land','L');
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
180 $this->AddCol(15,'Soort','L');
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
181 $this->AddCol(20,'Moment','L');
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
182 $this->AddCol(15,'Alpha','R');
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
183 $this->AddCol(12,'IBU','R');
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
184 $this->AddCol(18,'Gram','R');
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
185 $this->AddCol(20,'Prijs','R');
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
186
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
187 $cMargin=$this->cMargin;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
188 $this->cMargin=2;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
189 $this->TableX=$this->lMargin;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
190 $this->TableHeader();
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
191 $this->ProcessingTable=true;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
192
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
193 $this->SetFont('Helvetica','',9);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
194 $this->SetFillColor(100, 250, 65);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
195
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
196 $arr = json_decode($row['json_hops'], true);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
197 foreach($arr as $item) { //foreach element in $arr
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
198 $name = iconv('UTF-8','windows-1252',$item['h_name']);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
199 $origin = iconv('UTF-8','windows-1252',$item['h_origin']);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
200 $useat = iconv('UTF-8','windows-1252',$item['h_useat']);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
201 $form = iconv('UTF-8','windows-1252',$item['h_form']);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
202 $amount = floatval($item['h_amount']) * 1000;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
203 $mass = $amount;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
204 $costkg = floatval($item['h_cost']);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
205 $time = floatval($item['h_time']);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
206 $alpha = floatval($item['h_alpha']);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
207
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
208 $cost = ($amount * $costkg) / 1000;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
209 $cost_hops += $cost;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
210 $total_hops += $amount;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
211
84
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
212 $moment = hop_useat_names($useat);
90
d4246abee34e IBU calculation moved to formulas.php and added Daniels and Rager methods.
Michiel Broek <mbroek@mbse.eu>
parents: 89
diff changeset
213 if ($useat == "Boil") {
84
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
214 $moment = "Kook@".$time;
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
215 }
94
295c3af2a421 Include boil_size field in the recipes table. Calculate pre-boil SG. Use that in the IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 93
diff changeset
216 $ibu = calc_IBU($useat, $form, /*floatval($row['est_og'])*/ $preboil_sg, floatval($row['batch_size']), $mass, $time, $alpha, $row['ibu_method']);
93
357d59d8ec5e Added IBU and cost totals.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
217 $total_ibus += $ibu;
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
218
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
219 $this->Cell($vul,5,$name,0,0,'L',true);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
220 $this->Cell(35,5,$origin,0,0,'L',true);
84
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
221 $this->Cell(15,5,hop_form_names($form),0,0,'L',true);
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
222 $this->Cell(20,5,$moment,0,0,'L',true);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
223 $this->Cell(15,5,sprintf("%.1f%%",$alpha),0,0,'R',true);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
224 $this->Cell(12,5,sprintf("%.1f",$ibu),0,0,'R',true);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
225 $this->Cell(18,5,sprintf("%.1f",$amount),0,0,'R',true);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
226 $this->Cell(20,5,sprintf("%8.3f",$cost).EURO,0,0,'R',true);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
227 $this->Ln();
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
228 }
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
229
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
230 $this->SetFillColor(210,245,255);
93
357d59d8ec5e Added IBU and cost totals.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
231 $this->Cell($vul+85,5,'',0,0,'L',false);
357d59d8ec5e Added IBU and cost totals.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
232 $this->Cell(12,5,sprintf("%.1f",$total_ibus),0,0,'R',true);
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
233 $this->Cell(18,5,sprintf("%.1f",$total_hops),0,0,'R',true);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
234 $this->Cell(20,5,sprintf("%8.3f",$cost_hops).EURO,0,0,'R',true);
84
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
235 $this->Ln(10);
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
236 $this->ProcessingTable=false;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
237 $this->cMargin=$cMargin;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
238 $this->aCols=array();
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
239 }
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
240
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
241 function TableYeasts($row) {
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
242 global $cost_yeasts;
87
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
243 global $svg;
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
244 $vul = $this->w - $this->rMargin - $this->lMargin - 140;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
245 $this->AddCol(27,'Laboratorium','L');
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
246 $this->AddCol(18,'Product','L');
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
247 $this->AddCol($vul,'Gist','L');
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
248 $this->AddCol(20,'Gebruik','L');
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
249 $this->AddCol(15,'Attn','R');
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
250 $this->AddCol(22,'Vorm','L');
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
251 $this->AddCol(18,'Gram','R');
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
252 $this->AddCol(20,'Prijs','R');
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
253
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
254 $cMargin=$this->cMargin;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
255 $this->cMargin=2;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
256 $this->TableX=$this->lMargin;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
257 $this->TableHeader();
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
258 $this->ProcessingTable=true;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
259
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
260 $this->SetFont('Helvetica','',9);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
261 $this->SetFillColor(175, 175, 255);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
262
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
263 $arr = json_decode($row['json_yeasts'], true);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
264 foreach($arr as $item) { //foreach element in $arr
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
265 $name = iconv('UTF-8','windows-1252',$item['y_name']);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
266 $laboratory = iconv('UTF-8','windows-1252',$item['y_laboratory']);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
267 $product_id = iconv('UTF-8','windows-1252',$item['y_product_id']);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
268 $form = iconv('UTF-8','windows-1252',$item['y_form']);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
269 $use = iconv('UTF-8','windows-1252',$item['y_use']);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
270 $amount = floatval($item['y_amount']) * 1000;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
271 $costg = floatval($item['y_cost']);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
272 $attenuation = floatval($item['y_attenuation']);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
273 $cost = $amount * $costg;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
274 $cost_yeasts += $cost;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
275
84
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
276 if ($use == "Primary")
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
277 $svg = $attenuation;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
278
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
279 $this->Cell(27,5,$laboratory,0,0,'L',true);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
280 $this->Cell(18,5,$product_id,0,0,'L',true);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
281 $this->Cell($vul,5,$name,0,0,'L',true);
84
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
282 $this->Cell(20,5,yeast_use_names($use),0,0,'L',true);
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
283 $this->Cell(15,5,sprintf("%.1f%%",$attenuation),0,0,'R',true);
84
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
284 $this->Cell(22,5,yeast_form_names($form),0,0,'L',true);
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
285 $this->Cell(18,5,sprintf("%.1f",$amount),0,0,'R',true);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
286 $this->Cell(20,5,sprintf("%8.3f",$cost).EURO,0,0,'R',true);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
287 $this->Ln();
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
288 }
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
289
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
290 $this->SetFillColor(210,245,255);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
291 $this->Cell($vul+120,5,'',0,0,'L',false);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
292 $this->Cell(20,5,sprintf("%8.3f",$cost_yeasts).EURO,0,0,'R',true);
84
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
293 $this->Ln(10);
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
294 $this->ProcessingTable=false;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
295 $this->cMargin=$cMargin;
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
296 $this->aCols=array();
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
297 }
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
298
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
299 function TableMiscs($row) {
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
300 global $cost_miscs;
84
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
301 $vul = $this->w - $this->rMargin - $this->lMargin - 95;
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
302 $this->AddCol($vul,'Naam','L');
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
303 $this->AddCol(30,'Soort','L');
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
304 $this->AddCol(25,'Gebruik','L');
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
305 $this->AddCol(20,'Hoeveel','R');
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
306 $this->AddCol(20,'Prijs','R');
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
307
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
308 $cMargin=$this->cMargin;
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
309 $this->cMargin=2;
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
310 $this->TableX=$this->lMargin;
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
311 $this->TableHeader();
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
312 $this->ProcessingTable=true;
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
313
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
314 $this->SetFont('Helvetica','',9);
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
315 $this->SetFillColor(175, 175, 255);
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
316
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
317 $arr = json_decode($row['json_miscs'], true);
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
318 foreach($arr as $item) {
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
319 $name = iconv('UTF-8','windows-1252',$item['m_name']);
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
320 $type = iconv('UTF-8','windows-1252',$item['m_type']);
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
321 $use_use = iconv('UTF-8','windows-1252',$item['m_use_use']);
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
322 $amount = floatval($item['m_amount']) * 1000;
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
323 $costg = floatval($item['m_cost']) / 1000;
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
324 $time = floatval($item['m_time']);
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
325 $aiw = $item['m_amount_is_weight'];
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
326 $cost = $amount * $costg;
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
327 $cost_miscs += $cost;
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
328
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
329 if ($type == "Water agent")
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
330 $this->SetFillColor(240,140,130);
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
331 else if ($type == "Fining")
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
332 $this->SetFillColor(95,180,25);
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
333 else if (($type == "Spice") || ($type == "Herb") || ($type == "Flavor") || ($type == "Yeast nutrient"))
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
334 $this->SetFillColor(240,250,65);
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
335 else
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
336 $this->SetFillColor(210,245,255);
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
337
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
338 if ($use_use == "Boil")
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
339 $gebruik = sprintf("%s %d min",misc_use_names($use_use),$time);
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
340 else
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
341 $gebruik = misc_use_names($use_use);
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
342
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
343 $hoeveel = sprintf("%.1f %s",$amount,$aiw ? "gr":"ml");
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
344 $this->Cell($vul,5,$name,0,0,'L',true);
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
345 $this->Cell(30,5,misc_type_names($type),0,0,'L',true);
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
346 $this->Cell(25,5,$gebruik,0,0,'L',true);
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
347 $this->Cell(20,5,$hoeveel,0,0,'R',true);
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
348 $this->Cell(20,5,sprintf("%8.3f",$cost).EURO,0,0,'R',true);
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
349 $this->Ln();
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
350 }
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
351
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
352 $this->SetFillColor(210,245,255);
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
353 $this->Cell($vul+75,5,'',0,0,'L',false);
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
354 $this->Cell(20,5,sprintf("%8.3f",$cost_miscs).EURO,0,0,'R',true);
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
355 $this->Ln(10);
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
356
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
357 $this->ProcessingTable=false;
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
358 $this->cMargin=$cMargin;
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
359 $this->aCols=array();
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
360 }
84
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
361
3e5e87f1818d Added miscs ingredients to the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
362 // Watercolor $this->SetFillColor(120,255,250);
87
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
363
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
364 function TableSummary($row) {
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
365 global $pSugar;
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
366 global $pCara;
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
367 global $svg;
89
082c23b26055 Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents: 88
diff changeset
368 global $colorw;
93
357d59d8ec5e Added IBU and cost totals.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
369 global $cost_fermentables;
357d59d8ec5e Added IBU and cost totals.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
370 global $cost_hops;
357d59d8ec5e Added IBU and cost totals.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
371 global $cost_miscs;
357d59d8ec5e Added IBU and cost totals.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
372 global $cost_yeasts;
87
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
373 /* 2 Columns */
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
374 $vul = $this->w - $this->rMargin - $this->lMargin - 170;
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
375 $cMargin=$this->cMargin;
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
376 $this->cMargin=2;
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
377 $this->TableX=$this->lMargin;
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
378 $this->SetFont('Helvetica','B',9);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
379 $this->SetX($this->TableX);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
380 $this->SetFillColor(255,150,100);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
381 $this->Cell(0, 5, 'Recept samenvatting',0,0,'C',true);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
382 $this->Ln();
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
383
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
384 $this->SetFont('Helvetica','',9);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
385 $this->SetFillColor(210,245,255);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
386
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
387 $row['est_fg'] = estimate_fg($pSugar, $pCara, 0, 0, 0, $svg, $row['est_og']);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
388
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
389 $this->SetX($this->TableX);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
390 $this->Cell(35,5,'Start SG',0,0,'L',true);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
391 $this->Cell(25,5,sprintf("%.3f",$row['est_og']),0,0,'L',true);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
392 $this->Cell(25,5,'('.sprintf("%.3f",$row['st_og_min']).' - '.sprintf("%.3f",$row['st_og_max']).')',0,0,'L',true);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
393 $this->Cell($vul,5,'',0,0,'L',false);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
394 $this->Cell(35,5,'Eind SG',0,0,'L',true);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
395 $this->Cell(25,5,sprintf("%.3f",$row['est_fg']),0,0,'L',true);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
396 $this->Cell(25,5,'('.sprintf("%.3f",$row['st_fg_min']).' - '.sprintf("%.3f",$row['st_fg_max']).')',0,0,'L',true);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
397 $this->Ln();
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
398
88
0a39cbdcf085 Added ABV clculation.
Michiel Broek <mbroek@mbse.eu>
parents: 87
diff changeset
399 $row['est_abv'] = abvol($row['est_og'], $row['est_fg']);
87
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
400 $this->SetX($this->TableX);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
401 $this->Cell(35,5,'Geschat alcohol',0,0,'L',true);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
402 $this->Cell(25,5,sprintf("%.1f",$row['est_abv']).'%',0,0,'L',true);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
403 $this->Cell(25,5,'('.sprintf("%.1f",$row['st_abv_min']).' - '.sprintf("%.1f",$row['st_abv_max']).'%)',0,0,'L',true);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
404 $this->Cell($vul,5,'',0,0,'L',false);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
405 $this->Cell(35,5,'CO2',0,0,'L',true);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
406 $this->Cell(25,5,sprintf("%.1f",$row['est_carb']).'%',0,0,'L',true);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
407 $this->Cell(25,5,'('.sprintf("%.1f",$row['st_carb_min']).' - '.sprintf("%.1f",$row['st_carb_max']).'%)',0,0,'L',true);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
408 $this->Ln();
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
409
89
082c23b26055 Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents: 88
diff changeset
410 $row['est_color'] = kw_to_ebc($row['color_method'], $colorw);
87
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
411 $this->SetX($this->TableX);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
412 $this->Cell(35,5,'Kleur ('.$row['color_method'].')',0,0,'L',true);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
413 $beercolor = ebc_to_color($row['est_color']);
89
082c23b26055 Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents: 88
diff changeset
414 if ($row['est_color'] > 30)
082c23b26055 Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents: 88
diff changeset
415 $this->SetTextColor(250);
87
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
416 $this->SetFillColor($beercolor[0],$beercolor[1],$beercolor[2]);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
417 $this->Cell(25,5,$row['est_color'].' EBC',0,0,'L',true);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
418 $this->Cell(25,5,'('.$row['st_color_min'].' - '.$row['st_color_max'].' EBC)',0,0,'L',true);
89
082c23b26055 Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents: 88
diff changeset
419 $this->SetTextColor(0);
87
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
420 $this->SetFillColor(210,245,255);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
421 $this->Cell($vul,5,'',0,0,'L',false);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
422 $this->Cell(35,5,'Bitterheid ('.$row['ibu_method'].')',0,0,'L',true);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
423 $this->Cell(25,5,sprintf("%.0f",$row['est_ibu']).' IBU',0,0,'L',true);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
424 $this->Cell(25,5,'('.$row['st_ibu_min'].' - '.$row['st_ibu_max'].' IBU)',0,0,'L',true);
93
357d59d8ec5e Added IBU and cost totals.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
425 $this->Ln();
357d59d8ec5e Added IBU and cost totals.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
426
357d59d8ec5e Added IBU and cost totals.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
427 $this->SetX($this->TableX);
357d59d8ec5e Added IBU and cost totals.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
428 $cost_total = $cost_fermentables + $cost_hops + $cost_miscs + $cost_yeasts;
357d59d8ec5e Added IBU and cost totals.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
429 $this->Cell(35,5,'Kosten',0,0,'L',true);
357d59d8ec5e Added IBU and cost totals.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
430 $this->Cell(25,5,sprintf("%.2f",$cost_total).EURO,0,0,'L',true);
357d59d8ec5e Added IBU and cost totals.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
431 $this->Cell(25,5,sprintf("%.2f",$cost_total/$row['batch_size']).EURO.' / liter',0,0,'L',true);
87
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
432 $this->Ln(10);
93
357d59d8ec5e Added IBU and cost totals.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
433
357d59d8ec5e Added IBU and cost totals.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
434
87
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
435 // Kostprijs per liter, calorieren
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
436 $this->cMargin=$cMargin;
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
437 }
80
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
438 }
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
439
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
440
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
441
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
442 class PDF extends PDF_MySQL_Table {
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
443 function Header() {
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
444 global $row;
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
445 $this->Image('images/logo.png',10,6,30);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
446 // Title
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
447 $this->SetFont('Helvetica','B',18);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
448 $this->SetX(45);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
449 $this->Cell(0,8,$row['name'],1,1,'L');
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
450 $this->Ln(20);
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
451 // Ensure table header is printed
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
452 parent::Header();
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
453 }
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
454 }
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
455
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
456
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
457 /*
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
458 * Generate PDF from recipe data
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
459 */
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
460 $pdf = new PDF();
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
461 $pdf->AddPage();
83
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
462 $pdf->TableGlobal($row);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
463 $pdf->TableFermentables($row);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
464 $pdf->TableHops($row);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
465 $pdf->TableYeasts($row);
85521c6e0022 Added recipe print yeasts section.
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
466 $pdf->TableMiscs($row);
87
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
467 $pdf->TableSummary($row);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
468 if (strlen($row['notes'])) {
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
469 $pdf->SetFillColor(255,150,100);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
470 $pdf->Cell(0, 5, 'Recept opmerkingen',0,0,'C',true);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
471 $pdf->Ln();
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
472 $pdf->SetFillColor(210,245,255);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
473 $pdf->MultiCell(0,4,$row['notes'],0,'L',true);
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
474 }
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
475 // Disclaimer toevoegen dat dit alleen recept ontwikkeling is. Uitkomsten zoals IBU zijn een berekende schatting.
7f1d0abe5571 OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
476 // Footer sectie met berekende/geschatte uitkomsten zoals ABV, kostprijs per liter enz.
80
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
477 $pdf->Output();

mercurial