Sat, 18 Jan 2020 19:45:22 +0100
Added missing beerxml fields
177 | 1 | <?php |
563
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
515
diff
changeset
|
2 | //require_once('config.php'); |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
515
diff
changeset
|
3 | //require_once('includes/formulas.php'); |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
515
diff
changeset
|
4 | require_once($_SERVER['DOCUMENT_ROOT'].'/config.php'); |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
515
diff
changeset
|
5 | require_once($_SERVER['DOCUMENT_ROOT'].'/includes/formulas.php'); |
177 | 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' ); |
449
a1d6b9eec988
Added Cryo Hop support to the export scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
429
diff
changeset
|
29 | $hopform = array( 'Pellet', 'Plug', 'Leaf', 'Leaf', 'Leaf' ); |
242
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' ); |
429
0d2cf505957c
Prepared for new yeast types.
Michiel Broek <mbroek@mbse.eu>
parents:
401
diff
changeset
|
33 | $yeasttype = array( 'Lager', 'Ale', 'Wheat', 'Wine', 'Champagne', 'Other', 'Other', 'Other', 'Other', 'Other' ); |
515
9d771385a8a0
Added dried yeast form. Pitch rate for Kveik initially set at 0.25. Dried Kveik cells set to 9000000000 cells/gram.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
34 | $yeastform = array( 'Liquid', 'Dry', 'Slant', 'Culture', 'Frozen', 'Bottle', 'Dry' ); |
242
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 | ||
598
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
99 | if (floatval($row['est_og']) > 0) { |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
100 | xmlwriter_start_element($xw, 'EST_OG'); |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
101 | xmlwriter_text($xw, sprintf("%.3f",floatval($row['est_og']))); |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
102 | xmlwriter_end_element($xw); |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
103 | } |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
104 | |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
105 | if (floatval($row['est_fg']) > 0) { |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
106 | xmlwriter_start_element($xw, 'EST_FG'); |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
107 | xmlwriter_text($xw, sprintf("%.3f",floatval($row['est_fg']))); |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
108 | xmlwriter_end_element($xw); |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
109 | } |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
110 | |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
111 | if (floatval($row['est_abv']) > 0) { |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
112 | xmlwriter_start_element($xw, 'EST_ABV'); |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
113 | xmlwriter_text($xw, sprintf("%.1f",floatval($row['est_abv']))); |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
114 | xmlwriter_end_element($xw); |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
115 | } |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
116 | |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
117 | if (floatval($row['est_color']) > 0) { |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
118 | xmlwriter_start_element($xw, 'EST_COLOR'); |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
119 | xmlwriter_text($xw, sprintf("%.1f",floatval($row['est_color']))); |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
120 | xmlwriter_end_element($xw); |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
121 | } |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
122 | |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
123 | if (floatval($row['est_ibu']) > 0) { |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
124 | xmlwriter_start_element($xw, 'EST_IBU'); |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
125 | xmlwriter_text($xw, sprintf("%.1f",floatval($row['est_ibu']))); |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
126 | xmlwriter_end_element($xw); |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
127 | } |
890a532701e8
Added missing beerxml fields
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
128 | |
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
|
129 | 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
|
130 | 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
|
131 | 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
|
132 | 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
|
133 | } |
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
|
134 | |
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
|
135 | 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
|
136 | 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
|
137 | 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
|
138 | 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
|
139 | } |
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
|
140 | 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
|
141 | 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
|
142 | 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
|
143 | 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
|
144 | } |
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
|
145 | 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
|
146 | 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
|
147 | 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
|
148 | 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
|
149 | } |
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
|
150 | 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
|
151 | 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
|
152 | 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
|
153 | 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
|
154 | } |
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
|
155 | |
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
|
156 | |
177 | 157 | // Style |
158 | xmlwriter_start_element($xw, 'STYLE'); | |
159 | ||
160 | xmlwriter_start_element($xw, 'VERSION'); | |
161 | xmlwriter_text($xw, '1'); | |
162 | xmlwriter_end_element($xw); | |
163 | ||
164 | xmlwriter_start_element($xw, 'NAME'); | |
165 | xmlwriter_text($xw, $row['st_name']); | |
166 | xmlwriter_end_element($xw); | |
167 | ||
168 | xmlwriter_start_element($xw, 'CATEGORY'); | |
169 | xmlwriter_text($xw, $row['st_category']); | |
170 | xmlwriter_end_element($xw); | |
171 | ||
172 | xmlwriter_start_element($xw, 'CATEGORY_NUMBER'); | |
173 | xmlwriter_text($xw, $row['st_category_number']); | |
174 | xmlwriter_end_element($xw); | |
175 | ||
176 | xmlwriter_start_element($xw, 'STYLE_LETTER'); | |
177 | xmlwriter_text($xw, $row['st_letter']); | |
178 | xmlwriter_end_element($xw); | |
179 | ||
180 | xmlwriter_start_element($xw, 'STYLE_GUIDE'); | |
181 | xmlwriter_text($xw, $row['st_guide']); | |
182 | xmlwriter_end_element($xw); | |
183 | ||
184 | 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
|
185 | xmlwriter_text($xw, $styletype[$row['st_type']]); |
177 | 186 | xmlwriter_end_element($xw); |
187 | ||
188 | xmlwriter_start_element($xw, 'OG_MIN'); | |
189 | xmlwriter_text($xw, sprintf("%.3f",floatval($row['st_og_min']))); | |
190 | xmlwriter_end_element($xw); | |
191 | ||
192 | xmlwriter_start_element($xw, 'OG_MAX'); | |
193 | xmlwriter_text($xw, sprintf("%.3f",floatval($row['st_og_max']))); | |
194 | xmlwriter_end_element($xw); | |
195 | ||
196 | xmlwriter_start_element($xw, 'FG_MIN'); | |
563
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
515
diff
changeset
|
197 | xmlwriter_text($xw, sprintf("%.3f",floatval($row['st_fg_min']))); |
177 | 198 | xmlwriter_end_element($xw); |
199 | ||
563
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
515
diff
changeset
|
200 | xmlwriter_start_element($xw, 'FG_MAX'); |
177 | 201 | xmlwriter_text($xw, sprintf("%.3f",floatval($row['st_fg_max']))); |
202 | xmlwriter_end_element($xw); | |
203 | ||
204 | xmlwriter_start_element($xw, 'IBU_MIN'); | |
205 | xmlwriter_text($xw, sprintf("%.0f",floatval($row['st_ibu_min']))); | |
206 | xmlwriter_end_element($xw); | |
207 | ||
208 | xmlwriter_start_element($xw, 'IBU_MAX'); | |
209 | xmlwriter_text($xw, sprintf("%.0f",floatval($row['st_ibu_max']))); | |
210 | xmlwriter_end_element($xw); | |
211 | ||
212 | xmlwriter_start_element($xw, 'COLOR_MIN'); | |
213 | xmlwriter_text($xw, sprintf("%.2f",ebc_to_srm(floatval($row['st_color_min'])))); | |
214 | xmlwriter_end_element($xw); | |
215 | ||
216 | xmlwriter_start_element($xw, 'COLOR_MAX'); | |
217 | xmlwriter_text($xw, sprintf("%.2f",ebc_to_srm(floatval($row['st_color_max'])))); | |
218 | xmlwriter_end_element($xw); | |
219 | ||
220 | xmlwriter_start_element($xw, 'CARB_MIN'); | |
221 | xmlwriter_text($xw, sprintf("%.1f",floatval($row['st_carb_min']))); | |
222 | xmlwriter_end_element($xw); | |
223 | ||
224 | xmlwriter_start_element($xw, 'CARB_MAX'); | |
225 | xmlwriter_text($xw, sprintf("%.1f",floatval($row['st_carb_max']))); | |
226 | xmlwriter_end_element($xw); | |
227 | ||
228 | xmlwriter_start_element($xw, 'ABV_MIN'); | |
229 | xmlwriter_text($xw, sprintf("%.1f",floatval($row['st_abv_min']))); | |
230 | xmlwriter_end_element($xw); | |
231 | ||
232 | xmlwriter_start_element($xw, 'ABV_MAX'); | |
233 | xmlwriter_text($xw, sprintf("%.1f",floatval($row['st_abv_max']))); | |
234 | xmlwriter_end_element($xw); | |
235 | ||
236 | xmlwriter_end_element($xw); // STYLE | |
237 | ||
238 | xmlwriter_start_element($xw, 'EQUIPMENT'); | |
239 | ||
240 | xmlwriter_start_element($xw, 'VERSION'); | |
241 | xmlwriter_text($xw, '1'); | |
242 | xmlwriter_end_element($xw); | |
243 | ||
244 | xmlwriter_start_element($xw, 'NAME'); | |
245 | xmlwriter_text($xw, $row['eq_name']); | |
246 | xmlwriter_end_element($xw); | |
247 | ||
248 | xmlwriter_start_element($xw, 'NOTES'); | |
249 | xmlwriter_text($xw, $row['eq_notes']); | |
250 | xmlwriter_end_element($xw); | |
251 | ||
252 | xmlwriter_start_element($xw, 'BATCH_SIZE'); | |
253 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['eq_batch_size']))); | |
254 | xmlwriter_end_element($xw); | |
255 | ||
256 | xmlwriter_start_element($xw, 'BOIL_SIZE'); | |
257 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['eq_boil_size']))); | |
258 | xmlwriter_end_element($xw); | |
259 | ||
260 | xmlwriter_start_element($xw, 'BOIL_TIME'); | |
261 | xmlwriter_text($xw, sprintf("%.0f",floatval($row['eq_boil_time']))); | |
262 | xmlwriter_end_element($xw); | |
263 | ||
264 | xmlwriter_end_element($xw); // EQUIPMENT | |
265 | ||
266 | xmlwriter_start_element($xw, 'HOPS'); | |
267 | $arr = json_decode($row['json_hops'], true); | |
268 | foreach($arr as $item) { //foreach element in $arr | |
269 | ||
270 | xmlwriter_start_element($xw, 'HOP'); | |
271 | ||
272 | xmlwriter_start_element($xw, 'VERSION'); | |
273 | xmlwriter_text($xw, '1'); | |
274 | xmlwriter_end_element($xw); | |
275 | ||
276 | xmlwriter_start_element($xw, 'NAME'); | |
277 | xmlwriter_text($xw, $item['h_name']); | |
278 | xmlwriter_end_element($xw); | |
279 | ||
280 | xmlwriter_start_element($xw, 'ALPHA'); | |
281 | xmlwriter_text($xw, sprintf("%.1f",floatval($item['h_alpha']))); | |
282 | xmlwriter_end_element($xw); | |
283 | ||
284 | xmlwriter_start_element($xw, 'AMOUNT'); | |
285 | xmlwriter_text($xw, sprintf("%.4f",floatval($item['h_amount']))); | |
286 | xmlwriter_end_element($xw); | |
287 | ||
288 | 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
|
289 | xmlwriter_text($xw, $hopuse[$item['h_useat']]); |
177 | 290 | xmlwriter_end_element($xw); |
291 | ||
292 | xmlwriter_start_element($xw, 'TIME'); | |
293 | xmlwriter_text($xw, $item['h_time']); | |
294 | xmlwriter_end_element($xw); | |
295 | ||
296 | 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
|
297 | xmlwriter_text($xw, $hoptype[$item['h_type']]); |
177 | 298 | xmlwriter_end_element($xw); |
299 | ||
300 | 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
|
301 | xmlwriter_text($xw, $hopform[$item['h_form']]); |
177 | 302 | xmlwriter_end_element($xw); |
303 | ||
304 | xmlwriter_start_element($xw, 'BETA'); | |
305 | xmlwriter_text($xw, sprintf("%.1f",floatval($item['h_beta']))); | |
306 | xmlwriter_end_element($xw); | |
307 | ||
308 | xmlwriter_start_element($xw, 'HSI'); | |
309 | xmlwriter_text($xw, sprintf("%.1f",floatval($item['h_hsi']))); | |
310 | xmlwriter_end_element($xw); | |
311 | ||
312 | xmlwriter_start_element($xw, 'ORIGIN'); | |
313 | xmlwriter_text($xw, $item['h_origin']); | |
314 | xmlwriter_end_element($xw); | |
315 | ||
316 | xmlwriter_end_element($xw); // HOP | |
317 | } | |
318 | xmlwriter_end_element($xw); // HOPS | |
319 | ||
320 | xmlwriter_start_element($xw, 'FERMENTABLES'); | |
321 | $arr = json_decode($row['json_fermentables'], true); | |
322 | foreach($arr as $item) { //foreach element in $arr | |
323 | xmlwriter_start_element($xw, 'FERMENTABLE'); | |
324 | ||
325 | xmlwriter_start_element($xw, 'VERSION'); | |
326 | xmlwriter_text($xw, '1'); | |
327 | xmlwriter_end_element($xw); | |
328 | ||
329 | xmlwriter_start_element($xw, 'NAME'); | |
330 | xmlwriter_text($xw, $item['f_name']); | |
331 | xmlwriter_end_element($xw); | |
332 | ||
333 | 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
|
334 | xmlwriter_text($xw, $fermentabletype[$item['f_type']]); |
177 | 335 | xmlwriter_end_element($xw); |
336 | ||
337 | xmlwriter_start_element($xw, 'AMOUNT'); | |
338 | xmlwriter_text($xw, sprintf("%.4f",floatval($item['f_amount']))); | |
339 | xmlwriter_end_element($xw); | |
340 | ||
341 | xmlwriter_start_element($xw, 'YIELD'); | |
342 | xmlwriter_text($xw, sprintf("%.1f",floatval($item['f_yield']))); | |
343 | xmlwriter_end_element($xw); | |
344 | ||
345 | xmlwriter_start_element($xw, 'COLOR'); | |
346 | xmlwriter_text($xw, sprintf("%.1f",ebc_to_srm(floatval($item['f_color'])))); | |
347 | xmlwriter_end_element($xw); | |
348 | ||
349 | 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
|
350 | ($item['f_added'] > 1) ? xmlwriter_text($xw, 'TRUE') : xmlwriter_text($xw, 'FALSE'); |
177 | 351 | xmlwriter_end_element($xw); |
352 | ||
353 | xmlwriter_start_element($xw, 'ORIGIN'); | |
354 | xmlwriter_text($xw, $item['f_origin']); | |
355 | xmlwriter_end_element($xw); | |
356 | ||
357 | xmlwriter_start_element($xw, 'SUPPLIER'); | |
358 | xmlwriter_text($xw, $item['f_supplier']); | |
359 | xmlwriter_end_element($xw); | |
360 | ||
361 | if (floatval($item['f_coarse_fine_diff'])) { | |
362 | xmlwriter_start_element($xw, 'COARSE_FINE_DIFF'); | |
363 | xmlwriter_text($xw, sprintf("%.4f",floatval($item['f_coarse_fine_diff']))); | |
364 | xmlwriter_end_element($xw); | |
365 | } | |
366 | ||
367 | if (floatval($item['f_moisture'])) { | |
368 | xmlwriter_start_element($xw, 'MOISTURE'); | |
369 | xmlwriter_text($xw, sprintf("%.4f",floatval($item['f_moisture']))); | |
370 | xmlwriter_end_element($xw); | |
371 | } | |
372 | ||
373 | if (floatval($item['f_diastatic_power'])) { | |
374 | xmlwriter_start_element($xw, 'DIASTATIC_POWER'); | |
375 | xmlwriter_text($xw, sprintf("%.4f",floatval($item['f_diastatic_power']))); | |
376 | xmlwriter_end_element($xw); | |
377 | } | |
378 | ||
379 | if (floatval($item['f_protein'])) { | |
380 | xmlwriter_start_element($xw, 'PROTEIN'); | |
381 | xmlwriter_text($xw, sprintf("%.4f",floatval($item['f_protein']))); | |
382 | xmlwriter_end_element($xw); | |
383 | } | |
384 | ||
385 | if (floatval($item['f_max_in_batch'])) { | |
386 | xmlwriter_start_element($xw, 'MAX_IN_BATCH'); | |
387 | xmlwriter_text($xw, sprintf("%.1f",floatval($item['f_max_in_batch']))); | |
388 | xmlwriter_end_element($xw); | |
389 | } | |
390 | ||
391 | xmlwriter_start_element($xw, 'RECOMMEND_MASH'); | |
392 | ($item['f_recommend_mash']) ? xmlwriter_text($xw, 'TRUE') : xmlwriter_text($xw, 'FALSE'); | |
393 | xmlwriter_end_element($xw); | |
394 | ||
395 | 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
|
396 | xmlwriter_text($xw, $graintype[$item['f_graintype']]); |
177 | 397 | xmlwriter_end_element($xw); |
398 | ||
399 | xmlwriter_end_element($xw); // FERMENTABLE | |
400 | } | |
401 | xmlwriter_end_element($xw); // FERMENTABLES | |
402 | ||
403 | xmlwriter_start_element($xw, 'MISCS'); | |
404 | $arr = json_decode($row['json_miscs'], true); | |
405 | foreach($arr as $item) { | |
406 | ||
407 | xmlwriter_start_element($xw, 'MISC'); | |
408 | ||
409 | xmlwriter_start_element($xw, 'VERSION'); | |
410 | xmlwriter_text($xw, '1'); | |
411 | xmlwriter_end_element($xw); | |
412 | ||
413 | xmlwriter_start_element($xw, 'NAME'); | |
414 | xmlwriter_text($xw, $item['m_name']); | |
415 | xmlwriter_end_element($xw); | |
416 | ||
417 | 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
|
418 | xmlwriter_text($xw, $misctype[$item['m_type']]); |
177 | 419 | xmlwriter_end_element($xw); |
420 | ||
421 | xmlwriter_start_element($xw, 'AMOUNT'); | |
422 | xmlwriter_text($xw, sprintf("%.5f",floatval($item['m_amount']))); | |
423 | xmlwriter_end_element($xw); | |
424 | ||
425 | xmlwriter_start_element($xw, 'AMOUNT_IS_WEIGHT'); | |
426 | ($item['m_amount_is_weight']) ? xmlwriter_text($xw, 'TRUE') : xmlwriter_text($xw, 'FALSE'); | |
427 | xmlwriter_end_element($xw); | |
428 | ||
429 | 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
|
430 | xmlwriter_text($xw, $miscuse[$item['m_use_use']]); |
177 | 431 | xmlwriter_end_element($xw); |
432 | ||
433 | xmlwriter_start_element($xw, 'TIME'); | |
434 | xmlwriter_text($xw, sprintf("%.0f",floatval($item['m_time']))); | |
435 | xmlwriter_end_element($xw); | |
436 | ||
437 | xmlwriter_end_element($xw); // MISC | |
438 | } | |
439 | xmlwriter_end_element($xw); // MISCS | |
440 | ||
441 | xmlwriter_start_element($xw, 'YEASTS'); | |
442 | $arr = json_decode($row['json_yeasts'], true); | |
443 | foreach($arr as $item) { //foreach element in $arr | |
444 | ||
445 | xmlwriter_start_element($xw, 'YEAST'); | |
446 | ||
447 | xmlwriter_start_element($xw, 'VERSION'); | |
448 | xmlwriter_text($xw, '1'); | |
449 | xmlwriter_end_element($xw); | |
450 | ||
451 | xmlwriter_start_element($xw, 'NAME'); | |
452 | xmlwriter_text($xw, $item['y_name']); | |
453 | xmlwriter_end_element($xw); | |
454 | ||
455 | 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
|
456 | xmlwriter_text($xw, $yeasttype[$item['y_type']]); |
177 | 457 | xmlwriter_end_element($xw); |
458 | ||
459 | 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
|
460 | xmlwriter_text($xw, $yeastform[$item['y_form']]); |
177 | 461 | xmlwriter_end_element($xw); |
462 | ||
463 | xmlwriter_start_element($xw, 'AMOUNT'); | |
464 | xmlwriter_text($xw, sprintf("%.5f",floatval($item['y_amount']))); | |
465 | xmlwriter_end_element($xw); | |
466 | ||
467 | 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
|
468 | ($item['y_form'] == 1) ? xmlwriter_text($xw, 'TRUE') : xmlwriter_text($xw, 'FALSE'); |
177 | 469 | xmlwriter_end_element($xw); |
470 | ||
471 | xmlwriter_start_element($xw, 'LABORATORY'); | |
472 | xmlwriter_text($xw, $item['y_laboratory']); | |
473 | xmlwriter_end_element($xw); | |
474 | ||
475 | xmlwriter_start_element($xw, 'PRODUCT_ID'); | |
476 | xmlwriter_text($xw, $item['y_product_id']); | |
477 | xmlwriter_end_element($xw); | |
478 | ||
479 | xmlwriter_start_element($xw, 'MIN_TEMPERATURE'); | |
480 | xmlwriter_text($xw, sprintf("%.1f",floatval($item['y_min_temperature']))); | |
481 | xmlwriter_end_element($xw); | |
482 | ||
483 | xmlwriter_start_element($xw, 'MAX_TEMPERATURE'); | |
484 | xmlwriter_text($xw, sprintf("%.1f",floatval($item['y_max_temperature']))); | |
485 | xmlwriter_end_element($xw); | |
486 | ||
487 | xmlwriter_start_element($xw, 'ATTENUATION'); | |
488 | xmlwriter_text($xw, sprintf("%.1f",floatval($item['y_attenuation']))); | |
489 | xmlwriter_end_element($xw); | |
490 | ||
491 | 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
|
492 | ($item['y_use'] == 0) ? xmlwriter_text($xw, 'FALSE') : xmlwriter_text($xw, 'TRUE'); |
177 | 493 | xmlwriter_end_element($xw); |
494 | ||
495 | xmlwriter_end_element($xw); // YEAST | |
496 | } | |
497 | xmlwriter_end_element($xw); // YEASTS | |
498 | ||
499 | xmlwriter_start_element($xw, 'WATERS'); | |
500 | xmlwriter_start_element($xw, 'WATER'); // Source 1 | |
501 | ||
502 | xmlwriter_start_element($xw, 'VERSION'); | |
503 | xmlwriter_text($xw, '1'); | |
504 | xmlwriter_end_element($xw); | |
505 | ||
506 | xmlwriter_start_element($xw, 'NAME'); | |
507 | xmlwriter_text($xw, $row['w1_name']); | |
508 | xmlwriter_end_element($xw); | |
509 | ||
510 | xmlwriter_start_element($xw, 'AMOUNT'); | |
511 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w1_amount']))); | |
512 | xmlwriter_end_element($xw); | |
513 | ||
514 | xmlwriter_start_element($xw, 'CALCIUM'); | |
515 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w1_calcium']))); | |
516 | xmlwriter_end_element($xw); | |
517 | ||
518 | xmlwriter_start_element($xw, 'BICARBONATE'); | |
519 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w1_total_alkalinity']) * 1.22)); | |
520 | xmlwriter_end_element($xw); | |
521 | ||
522 | xmlwriter_start_element($xw, 'SULFATE'); | |
523 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w1_sulfate']))); | |
524 | xmlwriter_end_element($xw); | |
525 | ||
526 | xmlwriter_start_element($xw, 'CHLORIDE'); | |
527 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w1_chloride']))); | |
528 | xmlwriter_end_element($xw); | |
529 | ||
530 | xmlwriter_start_element($xw, 'SODIUM'); | |
531 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w1_sodium']))); | |
532 | xmlwriter_end_element($xw); | |
533 | ||
534 | xmlwriter_start_element($xw, 'PH'); | |
535 | xmlwriter_text($xw, sprintf("%.1f",floatval($row['w1_ph']))); | |
536 | xmlwriter_end_element($xw); | |
537 | ||
538 | xmlwriter_start_element($xw, 'TOTAL_ALKALINITY'); | |
539 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w1_total_alkalinity']))); | |
540 | xmlwriter_end_element($xw); | |
541 | ||
542 | xmlwriter_end_element($xw); // WATER | |
543 | ||
544 | if (strlen($row['w2_name'])) { | |
545 | xmlwriter_start_element($xw, 'WATER'); // Source 2 | |
546 | ||
547 | xmlwriter_start_element($xw, 'VERSION'); | |
548 | xmlwriter_text($xw, '1'); | |
549 | xmlwriter_end_element($xw); | |
550 | ||
551 | xmlwriter_start_element($xw, 'NAME'); | |
552 | xmlwriter_text($xw, $row['w2_name']); | |
553 | xmlwriter_end_element($xw); | |
554 | ||
555 | xmlwriter_start_element($xw, 'AMOUNT'); | |
556 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w2_amount']))); | |
557 | xmlwriter_end_element($xw); | |
558 | ||
559 | xmlwriter_start_element($xw, 'CALCIUM'); | |
560 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w2_calcium']))); | |
561 | xmlwriter_end_element($xw); | |
562 | ||
563 | xmlwriter_start_element($xw, 'BICARBONATE'); | |
564 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w2_total_alkalinity']) * 1.22)); | |
565 | xmlwriter_end_element($xw); | |
566 | ||
567 | xmlwriter_start_element($xw, 'SULFATE'); | |
568 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w2_sulfate']))); | |
569 | xmlwriter_end_element($xw); | |
570 | ||
571 | xmlwriter_start_element($xw, 'CHLORIDE'); | |
572 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w2_chloride']))); | |
573 | xmlwriter_end_element($xw); | |
574 | ||
575 | xmlwriter_start_element($xw, 'SODIUM'); | |
576 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w2_sodium']))); | |
577 | xmlwriter_end_element($xw); | |
578 | ||
579 | xmlwriter_start_element($xw, 'PH'); | |
580 | xmlwriter_text($xw, sprintf("%.1f",floatval($row['w2_ph']))); | |
581 | xmlwriter_end_element($xw); | |
582 | ||
583 | xmlwriter_start_element($xw, 'TOTAL_ALKALINITY'); | |
584 | xmlwriter_text($xw, sprintf("%.2f",floatval($row['w2_total_alkalinity']))); | |
585 | xmlwriter_end_element($xw); | |
586 | ||
587 | xmlwriter_end_element($xw); // WATER | |
588 | } | |
589 | xmlwriter_end_element($xw); // WATERS | |
590 | ||
591 | xmlwriter_start_element($xw, 'MASH'); | |
592 | ||
593 | xmlwriter_start_element($xw, 'VERSION'); | |
594 | xmlwriter_text($xw, '1'); | |
595 | xmlwriter_end_element($xw); | |
596 | ||
597 | xmlwriter_start_element($xw, 'NAME'); | |
598 | xmlwriter_text($xw, $row['mash_name']); | |
599 | xmlwriter_end_element($xw); | |
600 | ||
601 | xmlwriter_start_element($xw, 'GRAIN_TEMP'); | |
602 | xmlwriter_text($xw, '10.0'); | |
603 | xmlwriter_end_element($xw); | |
604 | ||
605 | xmlwriter_start_element($xw, 'PH'); | |
606 | xmlwriter_text($xw, sprintf("%.1f",floatval($row['sparge_ph']))); | |
607 | xmlwriter_end_element($xw); | |
608 | ||
609 | xmlwriter_start_element($xw, 'SPARGE_TEMP'); | |
610 | xmlwriter_text($xw, sprintf("%.1f",floatval($row['sparge_temp']))); | |
611 | xmlwriter_end_element($xw); | |
612 | ||
613 | xmlwriter_start_element($xw, 'MASH_STEPS'); | |
614 | $arr = json_decode($row['json_mashs'], true); | |
615 | foreach($arr as $item) { //foreach element in $arr | |
616 | xmlwriter_start_element($xw, 'MASH_STEP'); | |
617 | ||
618 | xmlwriter_start_element($xw, 'VERSION'); | |
619 | xmlwriter_text($xw, '1'); | |
620 | xmlwriter_end_element($xw); | |
621 | ||
622 | xmlwriter_start_element($xw, 'NAME'); | |
623 | xmlwriter_text($xw, $item['step_name']); | |
624 | xmlwriter_end_element($xw); | |
625 | ||
626 | 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
|
627 | xmlwriter_text($xw, $mashsteptype[$item['step_type']]); |
177 | 628 | xmlwriter_end_element($xw); |
629 | ||
242
97c237654ddd
Product export to beerxml produces a clean recipe. No brewing information added.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
630 | if ($item['step_type'] == 0) { |
177 | 631 | xmlwriter_start_element($xw, 'INFUSE_AMOUNT'); |
632 | xmlwriter_text($xw, sprintf("%.1f",floatval($item['step_infuse_amount']))); | |
633 | xmlwriter_end_element($xw); | |
634 | } | |
635 | ||
636 | xmlwriter_start_element($xw, 'STEP_TEMP'); | |
637 | xmlwriter_text($xw, sprintf("%.1f",floatval($item['step_temp']))); | |
638 | xmlwriter_end_element($xw); | |
639 | ||
640 | xmlwriter_start_element($xw, 'STEP_TIME'); | |
641 | xmlwriter_text($xw, sprintf("%.1f",floatval($item['step_time']))); | |
642 | xmlwriter_end_element($xw); | |
643 | ||
644 | xmlwriter_start_element($xw, 'RAMP_TIME'); | |
645 | xmlwriter_text($xw, sprintf("%.1f",floatval($item['ramp_time']))); | |
646 | xmlwriter_end_element($xw); | |
647 | ||
648 | xmlwriter_start_element($xw, 'END_TEMP'); | |
649 | xmlwriter_text($xw, sprintf("%.1f",floatval($item['end_temp']))); | |
650 | xmlwriter_end_element($xw); | |
651 | ||
652 | xmlwriter_start_element($xw, 'PH'); | |
653 | xmlwriter_text($xw, sprintf("%.1f",floatval($row['mash_ph']))); | |
654 | xmlwriter_end_element($xw); | |
655 | ||
656 | xmlwriter_end_element($xw); // MASH_STEP | |
657 | } | |
658 | xmlwriter_end_element($xw); // MASH_STEPS | |
659 | xmlwriter_end_element($xw); // MASH | |
660 | xmlwriter_end_element($xw); // RECIPE | |
661 | xmlwriter_end_element($xw); // RECIPES | |
662 | xmlwriter_end_document($xw); | |
663 | ||
664 | $beerxml = xmlwriter_output_memory($xw); | |
665 | ||
666 | Header('Content-type: text/xml'); | |
272
0c2ea1c2b858
Product beerxml export filename includes beer code.
Michiel Broek <mbroek@mbse.eu>
parents:
242
diff
changeset
|
667 | header('Content-Disposition: attachment; filename="' . $row['code'] . ' ' . $row['name'] . '.xml"'); |
177 | 668 | header('Content-Transfer-Encoding: binary'); |
669 | header('Expires: 0'); | |
670 | header('Pragma: no-cache'); | |
671 | header('Content-Length: '.strlen($beerxml)); | |
672 | exit($beerxml); |