1 <?php |
|
2 require_once($_SERVER['DOCUMENT_ROOT'].'/config.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 $result = mysqli_query($link, "SELECT * FROM inventory_equipments ORDER BY name"); |
|
16 |
|
17 |
|
18 /* |
|
19 * Create beerxml output |
|
20 */ |
|
21 $xw = xmlwriter_open_memory(); |
|
22 xmlwriter_set_indent($xw, 1); |
|
23 $res = xmlwriter_set_indent_string($xw, ' '); |
|
24 |
|
25 xmlwriter_start_document($xw, '1.0', 'UTF-8'); |
|
26 |
|
27 |
|
28 xmlwriter_start_element($xw, 'EQUIPMENTS'); |
|
29 while ($row = mysqli_fetch_array($result)) { |
|
30 |
|
31 xmlwriter_start_element($xw, 'EQUIPMENT'); |
|
32 |
|
33 xmlwriter_start_element($xw, 'VERSION'); |
|
34 xmlwriter_text($xw, '1'); |
|
35 xmlwriter_end_element($xw); |
|
36 |
|
37 xmlwriter_start_element($xw, 'NAME'); |
|
38 xmlwriter_text($xw, $row['name']); |
|
39 xmlwriter_end_element($xw); |
|
40 |
|
41 xmlwriter_start_element($xw, 'NOTES'); |
|
42 xmlwriter_text($xw, $row['notes']); |
|
43 xmlwriter_end_element($xw); |
|
44 |
|
45 xmlwriter_start_element($xw, 'BOIL_SIZE'); |
|
46 xmlwriter_text($xw, sprintf("%.4f", floatval($row['boil_size']))); |
|
47 xmlwriter_end_element($xw); |
|
48 |
|
49 xmlwriter_start_element($xw, 'BATCH_SIZE'); |
|
50 xmlwriter_text($xw, sprintf("%.4f", floatval($row['batch_size']))); |
|
51 xmlwriter_end_element($xw); |
|
52 |
|
53 xmlwriter_start_element($xw, 'TUN_VOLUME'); |
|
54 xmlwriter_text($xw, sprintf("%.5f", floatval($row['tun_volume']))); |
|
55 xmlwriter_end_element($xw); |
|
56 |
|
57 xmlwriter_start_element($xw, 'TUN_WEIGHT'); |
|
58 xmlwriter_text($xw, sprintf("%.5f", floatval($row['tun_weight']))); |
|
59 xmlwriter_end_element($xw); |
|
60 |
|
61 xmlwriter_start_element($xw, 'TUN_SPECIFIC_HEAT'); |
|
62 xmlwriter_text($xw, sprintf("%.5f", floatval($row['tun_specific_heat']))); |
|
63 xmlwriter_end_element($xw); |
|
64 |
|
65 xmlwriter_start_element($xw, 'TUN_HEIGHT'); |
|
66 xmlwriter_text($xw, sprintf("%.5f", floatval($row['tun_height']))); |
|
67 xmlwriter_end_element($xw); |
|
68 |
|
69 xmlwriter_start_element($xw, 'TRUB_CHILLER_LOSS'); |
|
70 xmlwriter_text($xw, sprintf("%.5f", floatval($row['trub_chiller_loss']))); |
|
71 xmlwriter_end_element($xw); |
|
72 |
|
73 xmlwriter_start_element($xw, 'EVAP_RATE'); |
|
74 xmlwriter_text($xw, sprintf("%.5f", floatval($row['evap_rate']))); |
|
75 xmlwriter_end_element($xw); |
|
76 |
|
77 xmlwriter_start_element($xw, 'BOIL_TIME'); |
|
78 xmlwriter_text($xw, sprintf("%.5f", floatval($row['boil_time']))); |
|
79 xmlwriter_end_element($xw); |
|
80 |
|
81 xmlwriter_start_element($xw, 'CALC_BOIL_VOLUME'); |
|
82 ($row['calc_boil_volume'] > 0) ? xmlwriter_text($xw, 'TRUE') : xmlwriter_text($xw, 'FALSE'); |
|
83 xmlwriter_end_element($xw); |
|
84 |
|
85 xmlwriter_start_element($xw, 'TOP_UP_KETTLE'); |
|
86 xmlwriter_text($xw, sprintf("%.5f", floatval($row['top_up_kettle']))); |
|
87 xmlwriter_end_element($xw); |
|
88 |
|
89 xmlwriter_start_element($xw, 'HOP_UTILIZATION'); |
|
90 xmlwriter_text($xw, sprintf("%.5f", floatval($row['hop_utilization']))); |
|
91 xmlwriter_end_element($xw); |
|
92 |
|
93 xmlwriter_start_element($xw, 'LAUTER_VOLUME'); |
|
94 xmlwriter_text($xw, sprintf("%.5f", floatval($row['lauter_volume']))); |
|
95 xmlwriter_end_element($xw); |
|
96 |
|
97 xmlwriter_start_element($xw, 'LAUTER_HEIGHT'); |
|
98 xmlwriter_text($xw, sprintf("%.5f", floatval($row['lauter_height']))); |
|
99 xmlwriter_end_element($xw); |
|
100 |
|
101 xmlwriter_start_element($xw, 'LAUTER_DEADSPACE'); |
|
102 xmlwriter_text($xw, sprintf("%.5f", floatval($row['lauter_deadspace']))); |
|
103 xmlwriter_end_element($xw); |
|
104 |
|
105 xmlwriter_start_element($xw, 'KETTLE_VOLUME'); |
|
106 xmlwriter_text($xw, sprintf("%.5f", floatval($row['kettle_volume']))); |
|
107 xmlwriter_end_element($xw); |
|
108 |
|
109 xmlwriter_start_element($xw, 'KETTLE_HEIGHT'); |
|
110 xmlwriter_text($xw, sprintf("%.5f", floatval($row['kettle_height']))); |
|
111 xmlwriter_end_element($xw); |
|
112 |
|
113 xmlwriter_start_element($xw, 'MASH_VOLUME'); |
|
114 xmlwriter_text($xw, sprintf("%.5f", floatval($row['mash_volume']))); |
|
115 xmlwriter_end_element($xw); |
|
116 |
|
117 xmlwriter_start_element($xw, 'EFFICIENCY'); |
|
118 xmlwriter_text($xw, sprintf("%.5f", floatval($row['efficiency']))); |
|
119 xmlwriter_end_element($xw); |
|
120 |
|
121 xmlwriter_end_element($xw); // EQUIPMENT |
|
122 } |
|
123 xmlwriter_end_element($xw); // EQUIPMENTS |
|
124 |
|
125 $beerxml = xmlwriter_output_memory($xw); |
|
126 |
|
127 Header('Content-type: text/xml'); |
|
128 header('Content-Disposition: attachment; filename="equipments.xml"'); |
|
129 header('Content-Transfer-Encoding: binary'); |
|
130 header('Expires: 0'); |
|
131 header('Pragma: no-cache'); |
|
132 header('Content-Length: '.strlen($beerxml)); |
|
133 exit($beerxml); |
|