www/prod_forum.php

changeset 341
9c4bc199be9e
child 357
74d56bed75b9
equal deleted inserted replaced
340:fa4eb830c151 341:9c4bc199be9e
1 <?php
2 require_once($_SERVER['DOCUMENT_ROOT'].'/includes/global.inc.php');
3 require_once($_SERVER['DOCUMENT_ROOT'].'/includes/formulas.php');
4
5
6 $link = mysqli_connect(DBASE_HOST,DBASE_USER,DBASE_PASS,DBASE_NAME);
7 if (! $link) {
8 die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
9 }
10 if (! mysqli_set_charset($link, "utf8" )) {
11 echo "error";
12 return 1;
13 }
14
15 setlocale ( LC_ALL, 'nl_NL.UTF-8');
16 $record = $_GET["record"];
17 $result = mysqli_query($link, "SELECT * FROM products WHERE record='".$record."'");
18 $row = mysqli_fetch_array($result);
19
20 $preboil_sg = 0;
21 date_default_timezone_set('Europe/Amsterdam');
22 $prdate = date(DATE_RFC2822);
23
24 ?>
25 <!DOCTYPE html>
26 <html lang=nl-NL>
27 <head>
28 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
29 <title>BMS v<?php echo $my_version;?> - Export recipe</title>
30 <meta name="viewport" content="width=device-width, initial-scale=1 maximum-scale=1 minimum-scale=1" />
31 </head>
32 <body>
33 <pre>
34 <?php
35
36 $recipetype = array( 'Extract', 'Deelmaisch', 'Mout' );
37 $colormethod = array( 'Morey', 'Mosher', 'Daniels' );
38 $ibumethod = array( 'Tinseth', 'Rager', 'Daniels' );
39 $added = array( 'Maischen', 'Koken', 'Vergisten', 'Nagisten/lageren', 'Bottelen' );
40 $hopform = array( 'Pellets', 'Plugs', 'Bellen', 'Hop nat' );
41 $hopuse = array( 'Maischen', 'First wort', 'Koken', 'Vlamuit', 'Whirlpool', 'Koudhop' );
42 $misctype = array( 'Specerij', 'Kruid', 'Smaakstof', 'Klaringsmiddel', 'Brouwzout', 'Gistvoeding', 'Anders' );
43 $miscuse = array( 'Starter', 'Maischen', 'Koken', 'Hoofdvergisting', 'Nagisting/lagering', 'Bottelen' );
44 $yeastform = array( 'Vloeibaar', 'Droog', 'Schuine buis', 'Slurry', 'Ingevroren', 'Depot' );
45 $yeastuse = array( 'Hoofdgisting', 'Nagisting', 'Lagering', 'Bottelen' );
46 $steptype = array( 'Infusie', 'Directe verwarming', 'Decoctie' );
47 $acidtype = array( 'Melkzuur', 'Zoutzuur', 'Fosforzuur', 'Zwavelzuur' );
48
49
50 function itemline($item, $content) {
51
52 echo $item . " ";
53 for ($i = strlen($item); $i < 40; $i++)
54 echo ".";
55 echo ": " . $content . PHP_EOL;
56 }
57
58
59 function formatstr($strin, $len) {
60
61 $strout = null;
62 $cnt = 0;
63
64 for ($i = 0; $i < strlen($strin); $i++) {
65 $ord = ord($strin[$i]);
66 if ($ord != 195)
67 $cnt++;
68
69 switch ($strin[$i]) {
70 case '<':
71 $strout .= '&lt;';
72 break;
73 case '>':
74 $strout .= '&gt;';
75 break;
76 case '&':
77 $strout .= '&amp;';
78 break;
79 case '"':
80 $strout .= '&quot;';
81 break;
82 default:
83 $strout .= $strin[$i];
84 }
85
86 if ($cnt >= $len)
87 break;
88 }
89
90 for ($i = $cnt; $i < $len; $i++)
91 $strout .= " ";
92 return $strout;
93 }
94
95
96 echo "BMS v" . $my_version . " - Datum export: " . $prdate . PHP_EOL;
97 echo "----------------------------------------------------------" . PHP_EOL;
98 itemline("Bier naam", $row['code'].' '.$row['name']);
99 itemline("Bier stijl", $row['st_name']);
100 itemline("Recept type", $recipetype[$row['type']]);
101 itemline("Batch grootte", $row['batch_size'].' liter');
102 itemline("Kooktijd", $row['boil_time'].' minuten');
103 itemline("Brouwzaal rendement", $row['efficiency'].' %');
104 itemline("Geschatte begin densiteit", sprintf("%.3f",$row['est_og']).' SG/ '.sprintf("%.1f", sg_to_plato($row['est_og'])).'&deg;P');
105 itemline("Geschatte eind densiteit", sprintf("%.3f",$row['est_fg']).' SG/ '.sprintf("%.1f", sg_to_plato($row['est_fg'])).'&deg;P');
106 itemline("Geschat alcohol", sprintf("%.1f",$row['est_abv']).'% vol');
107 itemline("Kleur (" . $colormethod[$row['color_method']] . ")", $row['est_color'] . ' EBC');
108 itemline("Bitterheid (" . $ibumethod[$row['ibu_method']] . ")", $row['est_ibu'] . ' IBU');
109 echo PHP_EOL . PHP_EOL;
110
111 $sugarsm = 0;
112 $grainabsorbtion = 0;
113 $mashwater = 0;
114
115 $arr = json_decode($row['json_fermentables'], true);
116 echo "Mout, granen en suikers EBC Gewicht kg % Gebruik tijdens" . PHP_EOL;
117 echo "---------------------------------------- --- ---------- ----- ----------------" . PHP_EOL;
118 foreach($arr as $item) {
119 $name = formatstr($item['f_name'] . " (" . $item['f_supplier'] . ")", 40);
120 $amount = floatval($item['f_amount']);
121 $d = $amount * (floatval($item['f_yield']) / 100) * (1 - floatval($item['f_moisture']) / 100);
122 if ($item['f_added'] == 0) {
123 $d = floatval($row['efficiency']) / 100 * $d;
124 $sugarsm += $d;
125 $grainabsorbtion += $item['f_amount'];
126 }
127 echo sprintf("%s %3.0f %10.3f %5.1f ", $name, floatval($item['f_color']), $amount, floatval($item['f_percentage']));
128 echo $added[$item['f_added']] . PHP_EOL;
129 }
130 $preboil_sg = estimate_sg($sugarsm, floatval($row['boil_size']));
131 echo PHP_EOL . PHP_EOL;
132
133
134 echo "Hop Vorm &alpha; % IBU Gram Toevoegen moment" . PHP_EOL;
135 echo "---------------------------------------- ------- ----- ----- ------ --------------------" . PHP_EOL;
136 $arr = json_decode($row['json_hops'], true);
137 foreach($arr as $item) {
138 $name = formatstr($item['h_name'] . " (" . $item['h_origin'] . ")", 40);
139 $amount = floatval($item['h_amount']) * 1000;
140 $time = floatval($item['h_time']);
141 $alpha = floatval($item['h_alpha']);
142 $ibu = calc_IBU($item['h_useat'], $item['h_form'], $preboil_sg, floatval($row['batch_size']), $amount, $time, $alpha, $row['ibu_method']);
143 $moment = $hopuse[$item['h_useat']];
144 if ($item['h_useat'] == 2) { // Boil
145 $moment = "Kook ".$time." minuten";
146 }
147
148 echo sprintf("%s %-7s %5.1f %5.1f %6.1f %-20s", $name, $hopform[$item['h_form']], $alpha, $ibu, $amount, $moment);
149 echo PHP_EOL;
150 }
151 echo PHP_EOL . PHP_EOL;
152
153 echo "Specerij, kruid, brouwzout etc Type grondstof Gebruik tijdens Hoeveel" . PHP_EOL;
154 echo "------------------------------ --------------- -------------------- ----------" . PHP_EOL;
155 $arr = json_decode($row['json_miscs'], true);
156 foreach($arr as $item) {
157 $amount = floatval($item['m_amount']) * 1000;
158 $aiw = $item['m_amount_is_weight'];
159 $use_use = $item['m_use_use'];
160 $time = floatval($item['m_time']);
161
162 if ($use_use == 2) // Boil
163 $gebruik = sprintf("%s %d min",$miscuse[$use_use],$time);
164 else
165 $gebruik = $miscuse[$use_use];
166 $hoeveel = sprintf("%.1f %s",$amount,$aiw ? "gr":"ml");
167
168 echo sprintf("%s %-15s %-20s %10s", formatstr($item['m_name'], 30), $misctype[$item['m_type']], $gebruik, $hoeveel) . PHP_EOL;
169 }
170 echo PHP_EOL . PHP_EOL;
171
172 echo "Gistlab en code Omschrijving Gebruik Vorm Hoeveel" . PHP_EOL;
173 echo "-------------------- ------------------------------ ------------ ------------ ----------" . PHP_EOL;
174 $arr = json_decode($row['json_yeasts'], true);
175 foreach($arr as $item) {
176 $name = formatstr($item['y_name'], 30);
177 $product = formatstr($item['y_laboratory']." ".$item['y_product_id'], 20);
178
179 if ($item['y_form'] == 0) // Liquid
180 $amount = sprintf("%.0f",floatval($item['y_amount']))." pak";
181 else if ($item['y_form'] == 1) // Dry
182 $amount = sprintf("%.1f",floatval($item['y_amount'])*1000)." gr";
183 else
184 $amount = sprintf("%.0f",floatval($item['y_amount'])*1000)." ml";
185
186 echo sprintf("%s %s %-12s %-12s %10s", $product, $name, $yeastuse[$item['y_use']], $yeastform[$item['y_form']], $amount) . PHP_EOL;
187 }
188 if ($row['starter_enable'] && $row['prop1_volume']) {
189 $sv = 0;
190 for ($i = 1; $i < 5; $i++) {
191 $pv = "prop".$i."_volume";
192 if (floatval($row[$pv]) && (floatval($row[$pv]) > $sv)) {
193 $sv = floatval($row[$pv]);
194 }
195 }
196 echo PHP_EOL . "Maak een giststarter van " . sprintf("%.1f", $sv) . " liter." . PHP_EOL;
197 }
198 echo PHP_EOL . PHP_EOL;
199
200 if ($row['w1_name'])
201 $mashwater += floatval($row['w1_amount']);
202 if ($row['w2_name'])
203 $mashwater += floatval($row['w2_amount']);
204
205 echo "Maisch stap stap type stap temp rusten opwarmen" . PHP_EOL;
206 echo "-------------------- ---------------------- --------- --------- ---------" . PHP_EOL;
207 $arr = json_decode($row['json_mashs'], true);
208 foreach($arr as $item) {
209
210 if ($item['step_type'] == 1) {
211 $stype = formatstr($steptype[$item['step_type']], 22);
212 } else {
213 $stype = formatstr($steptype[$item['step_type']].' '.sprintf("%.1f", $item['step_infuse_amount']).' liter', 22);
214 }
215 echo sprintf("%s %s %s %s %s",
216 formatstr($item['step_name'], 20), $stype, sprintf("%6.1f &deg;C", $item['step_temp']),
217 sprintf("%4.0f min.", $item['step_time']), sprintf("%4.0f min.", $item['ramp_time'])) . PHP_EOL;
218 }
219 echo PHP_EOL;
220 if ($row['w1_name'] && $row['w2_name']) {
221 itemline("Maischwater 1", sprintf("%.1f",floatval($row['w1_amount'])).' liter water '.$row['w1_name']);
222 itemline("Maischwater 2", sprintf("%.1f",floatval($row['w2_amount'])).' liter water '.$row['w2_name']);
223 } else {
224 itemline("Maischwater", sprintf("%.1f",floatval($row['w1_amount'])).' liter water '.$row['w1_name']);
225 }
226 itemline("Maischwater aanzuren tot pH", $row['mash_ph'].' pH');
227 $spoelw = ($row['boil_size'] - $mashwater + $grainabsorbtion + $row['eq_lauter_deadspace']) * 1.03; // A small heat correction
228 itemline("Spoelwater geschat", sprintf("%.1f", $spoelw)." liter");
229 itemline("Spoelwater temperatuur", $row['sparge_temp'].' &deg;C');
230 itemline("Spoelwater aanzuren tot pH", sprintf("%.1f",$row['sparge_ph']).' pH');
231 echo PHP_EOL . PHP_EOL;
232
233
234 ?>
235 </pre>
236 </body>
237 </html>

mercurial