122 |
122 |
123 $fermentables = '['; |
123 $fermentables = '['; |
124 $comma = FALSE; |
124 $comma = FALSE; |
125 if (isset($_POST['fermentables'])) { |
125 if (isset($_POST['fermentables'])) { |
126 $array = $_POST['fermentables']; |
126 $array = $_POST['fermentables']; |
|
127 // Sort the array |
|
128 $added = array(); |
|
129 $amount = array(); |
|
130 for ($i = 0; $i < count($array); $i++) { |
|
131 $added[] = $array[$i]['f_added']; |
|
132 $amount[] = $array[$i]['f_amount']; |
|
133 } |
|
134 array_multisort($added, SORT_ASC, SORT_NUMERIC, |
|
135 $amount, SORT_DESC, SORT_NUMERIC, |
|
136 $array); |
|
137 // Write the sorted array. |
127 foreach($array as $key => $item){ |
138 foreach($array as $key => $item){ |
128 /* |
139 /* |
129 * Manual encode to json. |
140 * Manual encode to json. |
130 */ |
141 */ |
131 if ($comma) |
142 if ($comma) |
162 |
173 |
163 $hops = '['; |
174 $hops = '['; |
164 $comma = FALSE; |
175 $comma = FALSE; |
165 if (isset($_POST['hops'])) { |
176 if (isset($_POST['hops'])) { |
166 $array = $_POST['hops']; |
177 $array = $_POST['hops']; |
|
178 // Sort the array |
|
179 $useat = array(); |
|
180 $time = array(); |
|
181 $amount = array(); |
|
182 for ($i = 0; $i < count($array); $i++) { |
|
183 $useat[] = $array[$i]['h_useat']; |
|
184 $time[] = $array[$i]['h_time']; |
|
185 $amount[] = $array[$i]['h_amount']; |
|
186 } |
|
187 array_multisort($useat, SORT_ASC, SORT_NUMERIC, |
|
188 $time, SORT_DESC, SORT_NUMERIC, |
|
189 $amount, SORT_DESC, SORT_NUMERIC, |
|
190 $array); |
|
191 // Write the sorted array. |
167 foreach($array as $key => $item){ |
192 foreach($array as $key => $item){ |
168 if ($comma) |
193 if ($comma) |
169 $hops .= ','; |
194 $hops .= ','; |
170 $comma = TRUE; |
195 $comma = TRUE; |
171 $hop = '{"h_name":"' . str_replace($rescapers,$rreplacements,$item['h_name']); |
196 $hop = '{"h_name":"' . str_replace($rescapers,$rreplacements,$item['h_name']); |
193 |
218 |
194 $miscs = '['; |
219 $miscs = '['; |
195 $comma = FALSE; |
220 $comma = FALSE; |
196 if (isset($_POST['miscs'])) { |
221 if (isset($_POST['miscs'])) { |
197 $array = $_POST['miscs']; |
222 $array = $_POST['miscs']; |
|
223 // Sort the array |
|
224 $use = array(); |
|
225 $type = array(); |
|
226 $amount = array(); |
|
227 for ($i = 0; $i < count($array); $i++) { |
|
228 $use[] = $array[$i]['m_use_use']; |
|
229 $type[] = $array[$i]['m_type']; |
|
230 $amount[] = $array[$i]['m_amount']; |
|
231 } |
|
232 array_multisort($use, SORT_ASC, SORT_NUMERIC, |
|
233 $type, SORT_ASC, SORT_NUMERIC, |
|
234 $amount, SORT_DESC, SORT_NUMERIC, |
|
235 $array); |
|
236 // Write the sorted array. |
198 foreach($array as $key => $item) { |
237 foreach($array as $key => $item) { |
199 if ($comma) |
238 if ($comma) |
200 $miscs .= ','; |
239 $miscs .= ','; |
201 $comma = TRUE; |
240 $comma = TRUE; |
202 $misc = '{"m_name":"' . str_replace($rescapers,$rreplacements,$item['m_name']); |
241 $misc = '{"m_name":"' . str_replace($rescapers,$rreplacements,$item['m_name']); |
215 |
254 |
216 $yeasts = '['; |
255 $yeasts = '['; |
217 $comma = FALSE; |
256 $comma = FALSE; |
218 if (isset($_POST['yeasts'])) { |
257 if (isset($_POST['yeasts'])) { |
219 $array = $_POST['yeasts']; |
258 $array = $_POST['yeasts']; |
220 syslog(LOG_NOTICE, $_POST['yeasts']); |
259 // Sort the array |
|
260 $use = array(); |
|
261 $amount = array(); |
|
262 for ($i = 0; $i < count($array); $i++) { |
|
263 $use[] = $array[$i]['y_use']; |
|
264 $amount[] = $array[$i]['y_amount']; |
|
265 } |
|
266 array_multisort($use, SORT_ASC, SORT_NUMERIC, |
|
267 $amount, SORT_DESC, SORT_NUMERIC, |
|
268 $array); |
|
269 // Write the sorted array. |
221 foreach($array as $key => $item) { |
270 foreach($array as $key => $item) { |
222 if ($comma) |
271 if ($comma) |
223 $yeasts .= ','; |
272 $yeasts .= ','; |
224 $comma = TRUE; |
273 $comma = TRUE; |
225 $yeast = '{"y_name":"' . str_replace($rescapers,$rreplacements,$item['y_name']); |
274 $yeast = '{"y_name":"' . str_replace($rescapers,$rreplacements,$item['y_name']); |
246 |
295 |
247 $mashs = '['; |
296 $mashs = '['; |
248 $comma = FALSE; |
297 $comma = FALSE; |
249 if (isset($_POST['mashs'])) { |
298 if (isset($_POST['mashs'])) { |
250 $array = $_POST['mashs']; |
299 $array = $_POST['mashs']; |
|
300 // Sort the array |
|
301 $temp = array(); |
|
302 for ($i = 0; $i < count($array); $i++) { |
|
303 $temp[] = $array[$i]['step_temp']; |
|
304 } |
|
305 array_multisort($temp, SORT_ASC, SORT_NUMERIC, $array); |
|
306 // Write the sorted array. |
251 foreach($array as $key => $item) { |
307 foreach($array as $key => $item) { |
252 if ($comma) |
308 if ($comma) |
253 $mashs .= ','; |
309 $mashs .= ','; |
254 $comma = TRUE; |
310 $comma = TRUE; |
255 $mash = '{"step_name":"' . str_replace($rescapers,$rreplacements,$item['step_name']); |
311 $mash = '{"step_name":"' . str_replace($rescapers,$rreplacements,$item['step_name']); |