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