Thu, 20 Jun 2019 13:55:12 +0200
Added packaging volume and add water or liquer to the beer after fermentation. Auto divide changing volumes between bottles and fusts. Upgrade the database in the crontask. Added these fields to the packaging tab screen.
177 | 1 | <?php |
2 | require_once('config.php'); | |
3 | require_once('includes/formulas.php'); | |
4 | //require_once($_SERVER['DOCUMENT_ROOT'].'/config.php'); | |
5 | //require_once($_SERVER['DOCUMENT_ROOT'].'/includes/formulas.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 | if (isset($_GET["record"])) | |
19 | $record = $_GET["record"]; | |
20 | else | |
242
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
21 | $record = 78; |
177 | 22 | $result = mysqli_query($link, "SELECT * FROM products WHERE record='".$record."'"); |
23 | $row = mysqli_fetch_array($result); | |
24 | ||
25 | ||
242
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
26 | $recipetype = array( 'Extract', 'Partial Mash', 'All Grain' ); |
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
27 | $styletype = array( 'Lager', 'Ale', 'Mead', 'Wheat', 'Mixed', 'Cider' ); |
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
28 | $hoptype = array( 'Bittering', 'Aroma', 'Both' ); |
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
29 | $hopform = array( 'Pellet', 'Plug', 'Leaf' ); |
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
30 | $hopuse = array( 'Mash', 'First wort', 'Boil', 'Aroma', 'Whirlpool', 'Dry hop' ); |
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
31 | $fermentabletype = array( 'Grain', 'Sugar', 'Extract', 'Dry extract', 'Adjunct' ); |
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
32 | $graintype = array( 'Base', 'Roast', 'Crystal', 'Kilned', 'Sour malt', 'Special', 'No malt' ); |
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
33 | $yeasttype = array( 'Lager', 'Ale', 'Wheat', 'Wine', 'Champagne' ); |
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
34 | $yeastform = array( 'Liquid', 'Dry', 'Slant', 'Culture', 'Frozen', 'Bottle' ); |
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
35 | $yeastuse = array( 'Primary', 'Secondary', 'Tertiary', 'Bottle' ); |
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
36 | $misctype = array( 'Spice', 'Herb', 'Flavor', 'Fining', 'Water agent', 'Yeast nutrient', 'Other' ); |
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
37 | $miscuse = array( 'Starter', 'Mash', 'Boil', 'Primary', 'Secondary', 'Bottling' ); |
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
38 | $mashsteptype = array( 'Infusion', 'Temperature', 'Decoction' ); |
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
39 | |
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
40 | |
177 | 41 | |
42 | /* | |
43 | * Create beerxml output | |
44 | */ | |
45 | $xw = xmlwriter_open_memory(); | |
46 | xmlwriter_set_indent($xw, 1); | |
47 | $res = xmlwriter_set_indent_string($xw, ' '); | |
48 | ||
49 | xmlwriter_start_document($xw, '1.0', 'UTF-8'); | |
50 | ||
51 | xmlwriter_start_element($xw, 'RECIPES'); | |
52 | xmlwriter_start_element($xw, 'RECIPE'); | |
53 | ||
54 | // Recipe basics | |
55 | xmlwriter_start_element($xw, 'VERSION'); | |
56 | xmlwriter_text($xw, '1'); | |
57 | xmlwriter_end_element($xw); | |
58 | ||
59 | xmlwriter_start_element($xw, 'NAME'); | |
60 | xmlwriter_text($xw, $row['name']); | |
61 | xmlwriter_end_element($xw); | |
62 | ||
63 | xmlwriter_start_element($xw, 'NOTES'); | |
64 | xmlwriter_text($xw, $row['notes']); | |
65 | xmlwriter_end_element($xw); | |
66 | ||
67 | xmlwriter_start_element($xw, 'TYPE'); | |
242
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
68 | xmlwriter_text($xw, $recipetype[$row['type']]); |
177 | 69 | xmlwriter_end_element($xw); |
70 | ||
71 | xmlwriter_start_element($xw, 'BREWER'); | |
72 | xmlwriter_text($xw, 'Anonymous'); | |
73 | xmlwriter_end_element($xw); | |
74 | ||
75 | xmlwriter_start_element($xw, 'BATCH_SIZE'); | |
76 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['batch_size']))); | |
77 | xmlwriter_end_element($xw); | |
78 | ||
79 | xmlwriter_start_element($xw, 'BOIL_SIZE'); | |
80 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['boil_size']))); | |
81 | xmlwriter_end_element($xw); | |
82 | ||
83 | xmlwriter_start_element($xw, 'BOIL_TIME'); | |
84 | xmlwriter_text($xw, sprintf("%.0f",floatval($row['boil_time']))); | |
85 | xmlwriter_end_element($xw); | |
86 | ||
87 | xmlwriter_start_element($xw, 'EFFICIENCY'); | |
88 | xmlwriter_text($xw, sprintf("%.1f",floatval($row['efficiency']))); | |
89 | xmlwriter_end_element($xw); | |
90 | ||
91 | xmlwriter_start_element($xw, 'OG'); | |
92 | xmlwriter_text($xw, sprintf("%.3f",floatval($row['og']))); | |
93 | xmlwriter_end_element($xw); | |
94 | ||
95 | xmlwriter_start_element($xw, 'FG'); | |
96 | xmlwriter_text($xw, sprintf("%.3f",floatval($row['fg']))); | |
97 | xmlwriter_end_element($xw); | |
98 | ||
401
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
99 | if ($row['brew_cooling_to'] > 0) { |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
100 | xmlwriter_start_element($xw, 'BMS_COOLING_TO'); |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
101 | xmlwriter_text($xw, sprintf("%.1f",floatval($row['brew_cooling_to']))); |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
102 | xmlwriter_end_element($xw); |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
103 | } |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
104 | |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
105 | if ($row['brew_whirlpool9'] > 0) { |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
106 | xmlwriter_start_element($xw, 'BMS_WHIRLPOOL9'); |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
107 | xmlwriter_text($xw, sprintf("%.0f",floatval($row['brew_whirlpool9']))); |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
108 | xmlwriter_end_element($xw); |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
109 | } |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
110 | if ($row['brew_whirlpool7'] > 0) { |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
111 | xmlwriter_start_element($xw, 'BMS_WHIRLPOOL7'); |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
112 | xmlwriter_text($xw, sprintf("%.0f",floatval($row['brew_whirlpool7']))); |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
113 | xmlwriter_end_element($xw); |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
114 | } |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
115 | if ($row['brew_whirlpool6'] > 0) { |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
116 | xmlwriter_start_element($xw, 'BMS_WHIRLPOOL6'); |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
117 | xmlwriter_text($xw, sprintf("%.0f",floatval($row['brew_whirlpool6']))); |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
118 | xmlwriter_end_element($xw); |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
119 | } |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
120 | if ($row['brew_whirlpool2'] > 0) { |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
121 | xmlwriter_start_element($xw, 'BMS_WHIRLPOOL2'); |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
122 | xmlwriter_text($xw, sprintf("%.0f",floatval($row['brew_whirlpool2']))); |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
123 | xmlwriter_end_element($xw); |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
124 | } |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
125 | |
4aad74bde00b
In product beerxml export added BMS specific items: cooling_to and whirlpool stages. These should be picked up by the brew computer and should do no harm to the rest of the world.
Michiel Broek <mbroek@mbse.eu>
parents:
400
diff
changeset
|
126 | |
177 | 127 | // Style |
128 | xmlwriter_start_element($xw, 'STYLE'); | |
129 | ||
130 | xmlwriter_start_element($xw, 'VERSION'); | |
131 | xmlwriter_text($xw, '1'); | |
132 | xmlwriter_end_element($xw); | |
133 | ||
134 | xmlwriter_start_element($xw, 'NAME'); | |
135 | xmlwriter_text($xw, $row['st_name']); | |
136 | xmlwriter_end_element($xw); | |
137 | ||
138 | xmlwriter_start_element($xw, 'CATEGORY'); | |
139 | xmlwriter_text($xw, $row['st_category']); | |
140 | xmlwriter_end_element($xw); | |
141 | ||
142 | xmlwriter_start_element($xw, 'CATEGORY_NUMBER'); | |
143 | xmlwriter_text($xw, $row['st_category_number']); | |
144 | xmlwriter_end_element($xw); | |
145 | ||
146 | xmlwriter_start_element($xw, 'STYLE_LETTER'); | |
147 | xmlwriter_text($xw, $row['st_letter']); | |
148 | xmlwriter_end_element($xw); | |
149 | ||
150 | xmlwriter_start_element($xw, 'STYLE_GUIDE'); | |
151 | xmlwriter_text($xw, $row['st_guide']); | |
152 | xmlwriter_end_element($xw); | |
153 | ||
154 | xmlwriter_start_element($xw, 'TYPE'); | |
242
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
155 | xmlwriter_text($xw, $styletype[$row['st_type']]); |
177 | 156 | xmlwriter_end_element($xw); |
157 | ||
158 | xmlwriter_start_element($xw, 'OG_MIN'); | |
159 | xmlwriter_text($xw, sprintf("%.3f",floatval($row['st_og_min']))); | |
160 | xmlwriter_end_element($xw); | |
161 | ||
162 | xmlwriter_start_element($xw, 'OG_MAX'); | |
163 | xmlwriter_text($xw, sprintf("%.3f",floatval($row['st_og_max']))); | |
164 | xmlwriter_end_element($xw); | |
165 | ||
166 | xmlwriter_start_element($xw, 'FG_MIN'); | |
167 | xmlwriter_text($xw, sprintf("%.3f",floatval($row['st_og_min']))); | |
168 | xmlwriter_end_element($xw); | |
169 | ||
170 | xmlwriter_start_element($xw, 'OG_MAX'); | |
171 | xmlwriter_text($xw, sprintf("%.3f",floatval($row['st_fg_max']))); | |
172 | xmlwriter_end_element($xw); | |
173 | ||
174 | xmlwriter_start_element($xw, 'IBU_MIN'); | |
175 | xmlwriter_text($xw, sprintf("%.0f",floatval($row['st_ibu_min']))); | |
176 | xmlwriter_end_element($xw); | |
177 | ||
178 | xmlwriter_start_element($xw, 'IBU_MAX'); | |
179 | xmlwriter_text($xw, sprintf("%.0f",floatval($row['st_ibu_max']))); | |
180 | xmlwriter_end_element($xw); | |
181 | ||
182 | xmlwriter_start_element($xw, 'COLOR_MIN'); | |
183 | xmlwriter_text($xw, sprintf("%.2f",ebc_to_srm(floatval($row['st_color_min'])))); | |
184 | xmlwriter_end_element($xw); | |
185 | ||
186 | xmlwriter_start_element($xw, 'COLOR_MAX'); | |
187 | xmlwriter_text($xw, sprintf("%.2f",ebc_to_srm(floatval($row['st_color_max'])))); | |
188 | xmlwriter_end_element($xw); | |
189 | ||
190 | xmlwriter_start_element($xw, 'CARB_MIN'); | |
191 | xmlwriter_text($xw, sprintf("%.1f",floatval($row['st_carb_min']))); | |
192 | xmlwriter_end_element($xw); | |
193 | ||
194 | xmlwriter_start_element($xw, 'CARB_MAX'); | |
195 | xmlwriter_text($xw, sprintf("%.1f",floatval($row['st_carb_max']))); | |
196 | xmlwriter_end_element($xw); | |
197 | ||
198 | xmlwriter_start_element($xw, 'ABV_MIN'); | |
199 | xmlwriter_text($xw, sprintf("%.1f",floatval($row['st_abv_min']))); | |
200 | xmlwriter_end_element($xw); | |
201 | ||
202 | xmlwriter_start_element($xw, 'ABV_MAX'); | |
203 | xmlwriter_text($xw, sprintf("%.1f",floatval($row['st_abv_max']))); | |
204 | xmlwriter_end_element($xw); | |
205 | ||
206 | xmlwriter_end_element($xw); // STYLE | |
207 | ||
208 | xmlwriter_start_element($xw, 'EQUIPMENT'); | |
209 | ||
210 | xmlwriter_start_element($xw, 'VERSION'); | |
211 | xmlwriter_text($xw, '1'); | |
212 | xmlwriter_end_element($xw); | |
213 | ||
214 | xmlwriter_start_element($xw, 'NAME'); | |
215 | xmlwriter_text($xw, $row['eq_name']); | |
216 | xmlwriter_end_element($xw); | |
217 | ||
218 | xmlwriter_start_element($xw, 'NOTES'); | |
219 | xmlwriter_text($xw, $row['eq_notes']); | |
220 | xmlwriter_end_element($xw); | |
221 | ||
222 | xmlwriter_start_element($xw, 'BATCH_SIZE'); | |
223 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['eq_batch_size']))); | |
224 | xmlwriter_end_element($xw); | |
225 | ||
226 | xmlwriter_start_element($xw, 'BOIL_SIZE'); | |
227 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['eq_boil_size']))); | |
228 | xmlwriter_end_element($xw); | |
229 | ||
230 | xmlwriter_start_element($xw, 'BOIL_TIME'); | |
231 | xmlwriter_text($xw, sprintf("%.0f",floatval($row['eq_boil_time']))); | |
232 | xmlwriter_end_element($xw); | |
233 | ||
234 | xmlwriter_end_element($xw); // EQUIPMENT | |
235 | ||
236 | xmlwriter_start_element($xw, 'HOPS'); | |
237 | $arr = json_decode($row['json_hops'], true); | |
238 | foreach($arr as $item) { //foreach element in $arr | |
239 | ||
240 | xmlwriter_start_element($xw, 'HOP'); | |
241 | ||
242 | xmlwriter_start_element($xw, 'VERSION'); | |
243 | xmlwriter_text($xw, '1'); | |
244 | xmlwriter_end_element($xw); | |
245 | ||
246 | xmlwriter_start_element($xw, 'NAME'); | |
247 | xmlwriter_text($xw, $item['h_name']); | |
248 | xmlwriter_end_element($xw); | |
249 | ||
250 | xmlwriter_start_element($xw, 'ALPHA'); | |
251 | xmlwriter_text($xw, sprintf("%.1f",floatval($item['h_alpha']))); | |
252 | xmlwriter_end_element($xw); | |
253 | ||
254 | xmlwriter_start_element($xw, 'AMOUNT'); | |
255 | xmlwriter_text($xw, sprintf("%.4f",floatval($item['h_amount']))); | |
256 | xmlwriter_end_element($xw); | |
257 | ||
258 | xmlwriter_start_element($xw, 'USE'); | |
242
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
259 | xmlwriter_text($xw, $hopuse[$item['h_useat']]); |
177 | 260 | xmlwriter_end_element($xw); |
261 | ||
262 | xmlwriter_start_element($xw, 'TIME'); | |
263 | xmlwriter_text($xw, $item['h_time']); | |
264 | xmlwriter_end_element($xw); | |
265 | ||
266 | xmlwriter_start_element($xw, 'TYPE'); | |
242
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
267 | xmlwriter_text($xw, $hoptype[$item['h_type']]); |
177 | 268 | xmlwriter_end_element($xw); |
269 | ||
270 | xmlwriter_start_element($xw, 'FORM'); | |
242
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
271 | xmlwriter_text($xw, $hopform[$item['h_form']]); |
177 | 272 | xmlwriter_end_element($xw); |
273 | ||
274 | xmlwriter_start_element($xw, 'BETA'); | |
275 | xmlwriter_text($xw, sprintf("%.1f",floatval($item['h_beta']))); | |
276 | xmlwriter_end_element($xw); | |
277 | ||
278 | xmlwriter_start_element($xw, 'HSI'); | |
279 | xmlwriter_text($xw, sprintf("%.1f",floatval($item['h_hsi']))); | |
280 | xmlwriter_end_element($xw); | |
281 | ||
282 | xmlwriter_start_element($xw, 'ORIGIN'); | |
283 | xmlwriter_text($xw, $item['h_origin']); | |
284 | xmlwriter_end_element($xw); | |
285 | ||
286 | xmlwriter_end_element($xw); // HOP | |
287 | } | |
288 | xmlwriter_end_element($xw); // HOPS | |
289 | ||
290 | xmlwriter_start_element($xw, 'FERMENTABLES'); | |
291 | $arr = json_decode($row['json_fermentables'], true); | |
292 | foreach($arr as $item) { //foreach element in $arr | |
293 | xmlwriter_start_element($xw, 'FERMENTABLE'); | |
294 | ||
295 | xmlwriter_start_element($xw, 'VERSION'); | |
296 | xmlwriter_text($xw, '1'); | |
297 | xmlwriter_end_element($xw); | |
298 | ||
299 | xmlwriter_start_element($xw, 'NAME'); | |
300 | xmlwriter_text($xw, $item['f_name']); | |
301 | xmlwriter_end_element($xw); | |
302 | ||
303 | xmlwriter_start_element($xw, 'TYPE'); | |
242
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
304 | xmlwriter_text($xw, $fermentabletype[$item['f_type']]); |
177 | 305 | xmlwriter_end_element($xw); |
306 | ||
307 | xmlwriter_start_element($xw, 'AMOUNT'); | |
308 | xmlwriter_text($xw, sprintf("%.4f",floatval($item['f_amount']))); | |
309 | xmlwriter_end_element($xw); | |
310 | ||
311 | xmlwriter_start_element($xw, 'YIELD'); | |
312 | xmlwriter_text($xw, sprintf("%.1f",floatval($item['f_yield']))); | |
313 | xmlwriter_end_element($xw); | |
314 | ||
315 | xmlwriter_start_element($xw, 'COLOR'); | |
316 | xmlwriter_text($xw, sprintf("%.1f",ebc_to_srm(floatval($item['f_color'])))); | |
317 | xmlwriter_end_element($xw); | |
318 | ||
319 | xmlwriter_start_element($xw, 'ADD_AFTER_BOIL'); | |
400
6d07c51e7540
Fixed beerxml output for fermentables added after the boil.
Michiel Broek <mbroek@mbse.eu>
parents:
301
diff
changeset
|
320 | ($item['f_added'] > 1) ? xmlwriter_text($xw, 'TRUE') : xmlwriter_text($xw, 'FALSE'); |
177 | 321 | xmlwriter_end_element($xw); |
322 | ||
323 | xmlwriter_start_element($xw, 'ORIGIN'); | |
324 | xmlwriter_text($xw, $item['f_origin']); | |
325 | xmlwriter_end_element($xw); | |
326 | ||
327 | xmlwriter_start_element($xw, 'SUPPLIER'); | |
328 | xmlwriter_text($xw, $item['f_supplier']); | |
329 | xmlwriter_end_element($xw); | |
330 | ||
331 | if (floatval($item['f_coarse_fine_diff'])) { | |
332 | xmlwriter_start_element($xw, 'COARSE_FINE_DIFF'); | |
333 | xmlwriter_text($xw, sprintf("%.4f",floatval($item['f_coarse_fine_diff']))); | |
334 | xmlwriter_end_element($xw); | |
335 | } | |
336 | ||
337 | if (floatval($item['f_moisture'])) { | |
338 | xmlwriter_start_element($xw, 'MOISTURE'); | |
339 | xmlwriter_text($xw, sprintf("%.4f",floatval($item['f_moisture']))); | |
340 | xmlwriter_end_element($xw); | |
341 | } | |
342 | ||
343 | if (floatval($item['f_diastatic_power'])) { | |
344 | xmlwriter_start_element($xw, 'DIASTATIC_POWER'); | |
345 | xmlwriter_text($xw, sprintf("%.4f",floatval($item['f_diastatic_power']))); | |
346 | xmlwriter_end_element($xw); | |
347 | } | |
348 | ||
349 | if (floatval($item['f_protein'])) { | |
350 | xmlwriter_start_element($xw, 'PROTEIN'); | |
351 | xmlwriter_text($xw, sprintf("%.4f",floatval($item['f_protein']))); | |
352 | xmlwriter_end_element($xw); | |
353 | } | |
354 | ||
355 | if (floatval($item['f_max_in_batch'])) { | |
356 | xmlwriter_start_element($xw, 'MAX_IN_BATCH'); | |
357 | xmlwriter_text($xw, sprintf("%.1f",floatval($item['f_max_in_batch']))); | |
358 | xmlwriter_end_element($xw); | |
359 | } | |
360 | ||
361 | xmlwriter_start_element($xw, 'RECOMMEND_MASH'); | |
362 | ($item['f_recommend_mash']) ? xmlwriter_text($xw, 'TRUE') : xmlwriter_text($xw, 'FALSE'); | |
363 | xmlwriter_end_element($xw); | |
364 | ||
365 | xmlwriter_start_element($xw, 'GRAINTYPE'); | |
242
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
366 | xmlwriter_text($xw, $graintype[$item['f_graintype']]); |
177 | 367 | xmlwriter_end_element($xw); |
368 | ||
369 | xmlwriter_end_element($xw); // FERMENTABLE | |
370 | } | |
371 | xmlwriter_end_element($xw); // FERMENTABLES | |
372 | ||
373 | xmlwriter_start_element($xw, 'MISCS'); | |
374 | $arr = json_decode($row['json_miscs'], true); | |
375 | foreach($arr as $item) { | |
376 | ||
377 | xmlwriter_start_element($xw, 'MISC'); | |
378 | ||
379 | xmlwriter_start_element($xw, 'VERSION'); | |
380 | xmlwriter_text($xw, '1'); | |
381 | xmlwriter_end_element($xw); | |
382 | ||
383 | xmlwriter_start_element($xw, 'NAME'); | |
384 | xmlwriter_text($xw, $item['m_name']); | |
385 | xmlwriter_end_element($xw); | |
386 | ||
387 | xmlwriter_start_element($xw, 'TYPE'); | |
242
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
388 | xmlwriter_text($xw, $misctype[$item['m_type']]); |
177 | 389 | xmlwriter_end_element($xw); |
390 | ||
391 | xmlwriter_start_element($xw, 'AMOUNT'); | |
392 | xmlwriter_text($xw, sprintf("%.5f",floatval($item['m_amount']))); | |
393 | xmlwriter_end_element($xw); | |
394 | ||
395 | xmlwriter_start_element($xw, 'AMOUNT_IS_WEIGHT'); | |
396 | ($item['m_amount_is_weight']) ? xmlwriter_text($xw, 'TRUE') : xmlwriter_text($xw, 'FALSE'); | |
397 | xmlwriter_end_element($xw); | |
398 | ||
399 | xmlwriter_start_element($xw, 'USE'); | |
242
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
400 | xmlwriter_text($xw, $miscuse[$item['m_use_use']]); |
177 | 401 | xmlwriter_end_element($xw); |
402 | ||
403 | xmlwriter_start_element($xw, 'TIME'); | |
404 | xmlwriter_text($xw, sprintf("%.0f",floatval($item['m_time']))); | |
405 | xmlwriter_end_element($xw); | |
406 | ||
407 | xmlwriter_end_element($xw); // MISC | |
408 | } | |
409 | xmlwriter_end_element($xw); // MISCS | |
410 | ||
411 | xmlwriter_start_element($xw, 'YEASTS'); | |
412 | $arr = json_decode($row['json_yeasts'], true); | |
413 | foreach($arr as $item) { //foreach element in $arr | |
414 | ||
415 | xmlwriter_start_element($xw, 'YEAST'); | |
416 | ||
417 | xmlwriter_start_element($xw, 'VERSION'); | |
418 | xmlwriter_text($xw, '1'); | |
419 | xmlwriter_end_element($xw); | |
420 | ||
421 | xmlwriter_start_element($xw, 'NAME'); | |
422 | xmlwriter_text($xw, $item['y_name']); | |
423 | xmlwriter_end_element($xw); | |
424 | ||
425 | xmlwriter_start_element($xw, 'TYPE'); | |
242
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
426 | xmlwriter_text($xw, $yeasttype[$item['y_type']]); |
177 | 427 | xmlwriter_end_element($xw); |
428 | ||
429 | xmlwriter_start_element($xw, 'FORM'); | |
242
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
430 | xmlwriter_text($xw, $yeastform[$item['y_form']]); |
177 | 431 | xmlwriter_end_element($xw); |
432 | ||
433 | xmlwriter_start_element($xw, 'AMOUNT'); | |
434 | xmlwriter_text($xw, sprintf("%.5f",floatval($item['y_amount']))); | |
435 | xmlwriter_end_element($xw); | |
436 | ||
437 | xmlwriter_start_element($xw, 'AMOUNT_IS_WEIGHT'); | |
242
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
438 | ($item['y_form'] == 1) ? xmlwriter_text($xw, 'TRUE') : xmlwriter_text($xw, 'FALSE'); |
177 | 439 | xmlwriter_end_element($xw); |
440 | ||
441 | xmlwriter_start_element($xw, 'LABORATORY'); | |
442 | xmlwriter_text($xw, $item['y_laboratory']); | |
443 | xmlwriter_end_element($xw); | |
444 | ||
445 | xmlwriter_start_element($xw, 'PRODUCT_ID'); | |
446 | xmlwriter_text($xw, $item['y_product_id']); | |
447 | xmlwriter_end_element($xw); | |
448 | ||
449 | xmlwriter_start_element($xw, 'MIN_TEMPERATURE'); | |
450 | xmlwriter_text($xw, sprintf("%.1f",floatval($item['y_min_temperature']))); | |
451 | xmlwriter_end_element($xw); | |
452 | ||
453 | xmlwriter_start_element($xw, 'MAX_TEMPERATURE'); | |
454 | xmlwriter_text($xw, sprintf("%.1f",floatval($item['y_max_temperature']))); | |
455 | xmlwriter_end_element($xw); | |
456 | ||
457 | xmlwriter_start_element($xw, 'ATTENUATION'); | |
458 | xmlwriter_text($xw, sprintf("%.1f",floatval($item['y_attenuation']))); | |
459 | xmlwriter_end_element($xw); | |
460 | ||
461 | xmlwriter_start_element($xw, 'ADD_TO_SECONDARY'); | |
242
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
462 | ($item['y_use'] == 0) ? xmlwriter_text($xw, 'FALSE') : xmlwriter_text($xw, 'TRUE'); |
177 | 463 | xmlwriter_end_element($xw); |
464 | ||
465 | xmlwriter_end_element($xw); // YEAST | |
466 | } | |
467 | xmlwriter_end_element($xw); // YEASTS | |
468 | ||
469 | xmlwriter_start_element($xw, 'WATERS'); | |
470 | xmlwriter_start_element($xw, 'WATER'); // Source 1 | |
471 | ||
472 | xmlwriter_start_element($xw, 'VERSION'); | |
473 | xmlwriter_text($xw, '1'); | |
474 | xmlwriter_end_element($xw); | |
475 | ||
476 | xmlwriter_start_element($xw, 'NAME'); | |
477 | xmlwriter_text($xw, $row['w1_name']); | |
478 | xmlwriter_end_element($xw); | |
479 | ||
480 | xmlwriter_start_element($xw, 'AMOUNT'); | |
481 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w1_amount']))); | |
482 | xmlwriter_end_element($xw); | |
483 | ||
484 | xmlwriter_start_element($xw, 'CALCIUM'); | |
485 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w1_calcium']))); | |
486 | xmlwriter_end_element($xw); | |
487 | ||
488 | xmlwriter_start_element($xw, 'BICARBONATE'); | |
489 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w1_total_alkalinity']) * 1.22)); | |
490 | xmlwriter_end_element($xw); | |
491 | ||
492 | xmlwriter_start_element($xw, 'SULFATE'); | |
493 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w1_sulfate']))); | |
494 | xmlwriter_end_element($xw); | |
495 | ||
496 | xmlwriter_start_element($xw, 'CHLORIDE'); | |
497 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w1_chloride']))); | |
498 | xmlwriter_end_element($xw); | |
499 | ||
500 | xmlwriter_start_element($xw, 'SODIUM'); | |
501 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w1_sodium']))); | |
502 | xmlwriter_end_element($xw); | |
503 | ||
504 | xmlwriter_start_element($xw, 'PH'); | |
505 | xmlwriter_text($xw, sprintf("%.1f",floatval($row['w1_ph']))); | |
506 | xmlwriter_end_element($xw); | |
507 | ||
508 | xmlwriter_start_element($xw, 'TOTAL_ALKALINITY'); | |
509 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w1_total_alkalinity']))); | |
510 | xmlwriter_end_element($xw); | |
511 | ||
512 | xmlwriter_end_element($xw); // WATER | |
513 | ||
514 | if (strlen($row['w2_name'])) { | |
515 | xmlwriter_start_element($xw, 'WATER'); // Source 2 | |
516 | ||
517 | xmlwriter_start_element($xw, 'VERSION'); | |
518 | xmlwriter_text($xw, '1'); | |
519 | xmlwriter_end_element($xw); | |
520 | ||
521 | xmlwriter_start_element($xw, 'NAME'); | |
522 | xmlwriter_text($xw, $row['w2_name']); | |
523 | xmlwriter_end_element($xw); | |
524 | ||
525 | xmlwriter_start_element($xw, 'AMOUNT'); | |
526 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w2_amount']))); | |
527 | xmlwriter_end_element($xw); | |
528 | ||
529 | xmlwriter_start_element($xw, 'CALCIUM'); | |
530 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w2_calcium']))); | |
531 | xmlwriter_end_element($xw); | |
532 | ||
533 | xmlwriter_start_element($xw, 'BICARBONATE'); | |
534 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w2_total_alkalinity']) * 1.22)); | |
535 | xmlwriter_end_element($xw); | |
536 | ||
537 | xmlwriter_start_element($xw, 'SULFATE'); | |
538 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w2_sulfate']))); | |
539 | xmlwriter_end_element($xw); | |
540 | ||
541 | xmlwriter_start_element($xw, 'CHLORIDE'); | |
542 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w2_chloride']))); | |
543 | xmlwriter_end_element($xw); | |
544 | ||
545 | xmlwriter_start_element($xw, 'SODIUM'); | |
546 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w2_sodium']))); | |
547 | xmlwriter_end_element($xw); | |
548 | ||
549 | xmlwriter_start_element($xw, 'PH'); | |
550 | xmlwriter_text($xw, sprintf("%.1f",floatval($row['w2_ph']))); | |
551 | xmlwriter_end_element($xw); | |
552 | ||
553 | xmlwriter_start_element($xw, 'TOTAL_ALKALINITY'); | |
554 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w2_total_alkalinity']))); | |
555 | xmlwriter_end_element($xw); | |
556 | ||
557 | xmlwriter_end_element($xw); // WATER | |
558 | } | |
559 | xmlwriter_end_element($xw); // WATERS | |
560 | ||
561 | xmlwriter_start_element($xw, 'MASH'); | |
562 | ||
563 | xmlwriter_start_element($xw, 'VERSION'); | |
564 | xmlwriter_text($xw, '1'); | |
565 | xmlwriter_end_element($xw); | |
566 | ||
567 | xmlwriter_start_element($xw, 'NAME'); | |
568 | xmlwriter_text($xw, $row['mash_name']); | |
569 | xmlwriter_end_element($xw); | |
570 | ||
571 | xmlwriter_start_element($xw, 'GRAIN_TEMP'); | |
572 | xmlwriter_text($xw, '10.0'); | |
573 | xmlwriter_end_element($xw); | |
574 | ||
575 | xmlwriter_start_element($xw, 'PH'); | |
576 | xmlwriter_text($xw, sprintf("%.1f",floatval($row['sparge_ph']))); | |
577 | xmlwriter_end_element($xw); | |
578 | ||
579 | xmlwriter_start_element($xw, 'SPARGE_TEMP'); | |
580 | xmlwriter_text($xw, sprintf("%.1f",floatval($row['sparge_temp']))); | |
581 | xmlwriter_end_element($xw); | |
582 | ||
583 | xmlwriter_start_element($xw, 'MASH_STEPS'); | |
584 | $arr = json_decode($row['json_mashs'], true); | |
585 | foreach($arr as $item) { //foreach element in $arr | |
586 | xmlwriter_start_element($xw, 'MASH_STEP'); | |
587 | ||
588 | xmlwriter_start_element($xw, 'VERSION'); | |
589 | xmlwriter_text($xw, '1'); | |
590 | xmlwriter_end_element($xw); | |
591 | ||
592 | xmlwriter_start_element($xw, 'NAME'); | |
593 | xmlwriter_text($xw, $item['step_name']); | |
594 | xmlwriter_end_element($xw); | |
595 | ||
596 | xmlwriter_start_element($xw, 'TYPE'); | |
242
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
597 | xmlwriter_text($xw, $mashsteptype[$item['step_type']]); |
177 | 598 | xmlwriter_end_element($xw); |
599 | ||
242
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
600 | if ($item['step_type'] == 0) { |
177 | 601 | xmlwriter_start_element($xw, 'INFUSE_AMOUNT'); |
602 | xmlwriter_text($xw, sprintf("%.1f",floatval($item['step_infuse_amount']))); | |
603 | xmlwriter_end_element($xw); | |
604 | } | |
605 | ||
606 | xmlwriter_start_element($xw, 'STEP_TEMP'); | |
607 | xmlwriter_text($xw, sprintf("%.1f",floatval($item['step_temp']))); | |
608 | xmlwriter_end_element($xw); | |
609 | ||
610 | xmlwriter_start_element($xw, 'STEP_TIME'); | |
611 | xmlwriter_text($xw, sprintf("%.1f",floatval($item['step_time']))); | |
612 | xmlwriter_end_element($xw); | |
613 | ||
614 | xmlwriter_start_element($xw, 'RAMP_TIME'); | |
615 | xmlwriter_text($xw, sprintf("%.1f",floatval($item['ramp_time']))); | |
616 | xmlwriter_end_element($xw); | |
617 | ||
618 | xmlwriter_start_element($xw, 'END_TEMP'); | |
619 | xmlwriter_text($xw, sprintf("%.1f",floatval($item['end_temp']))); | |
620 | xmlwriter_end_element($xw); | |
621 | ||
622 | xmlwriter_start_element($xw, 'PH'); | |
623 | xmlwriter_text($xw, sprintf("%.1f",floatval($row['mash_ph']))); | |
624 | xmlwriter_end_element($xw); | |
625 | ||
626 | xmlwriter_end_element($xw); // MASH_STEP | |
627 | } | |
628 | xmlwriter_end_element($xw); // MASH_STEPS | |
629 | xmlwriter_end_element($xw); // MASH | |
630 | xmlwriter_end_element($xw); // RECIPE | |
631 | xmlwriter_end_element($xw); // RECIPES | |
632 | xmlwriter_end_document($xw); | |
633 | ||
634 | $beerxml = xmlwriter_output_memory($xw); | |
635 | ||
636 | Header('Content-type: text/xml'); | |
272
0c2ea1c2b858
Product beerxml export filename includes beer code.
Michiel Broek <mbroek@mbse.eu>
parents:
242
diff
changeset
|
637 | header('Content-Disposition: attachment; filename="' . $row['code'] . ' ' . $row['name'] . '.xml"'); |
177 | 638 | header('Content-Transfer-Encoding: binary'); |
639 | header('Expires: 0'); | |
640 | header('Pragma: no-cache'); | |
641 | header('Content-Length: '.strlen($beerxml)); | |
642 | exit($beerxml); |