www/includes/db_product.php

changeset 394
ccd85f0ed96c
parent 393
5020feba78ec
child 408
a93c9473a7c3
equal deleted inserted replaced
393:5020feba78ec 394:ccd85f0ed96c
256 $sql .= "', prop3_type='" . $_POST['prop3_type']; 256 $sql .= "', prop3_type='" . $_POST['prop3_type'];
257 $sql .= "', prop3_volume='" . $_POST['prop3_volume']; 257 $sql .= "', prop3_volume='" . $_POST['prop3_volume'];
258 $sql .= "', prop4_type='" . $_POST['prop4_type']; 258 $sql .= "', prop4_type='" . $_POST['prop4_type'];
259 $sql .= "', prop4_volume='" . $_POST['prop4_volume']; 259 $sql .= "', prop4_volume='" . $_POST['prop4_volume'];
260 } 260 }
261 syslog(LOG_NOTICE, $sql); 261 // syslog(LOG_NOTICE, $sql);
262 262
263 $fermentables = '['; 263 $fermentables = '[';
264 $comma = FALSE; 264 $comma = FALSE;
265 if (isset($_POST['fermentables'])) { 265 if (isset($_POST['fermentables'])) {
266 $array = $_POST['fermentables']; 266 $array = $_POST['fermentables'];
267 // Sort the array
268 $added = array();
269 $amount = array();
270 for ($i = 0; $i < count($array); $i++) {
271 $added[] = $array[$i]['f_added'];
272 $amount[] = $array[$i]['f_amount'];
273 }
274 array_multisort($added, SORT_ASC, SORT_NUMERIC,
275 $amount, SORT_DESC, SORT_NUMERIC,
276 $array);
277 // Write the sorted array.
267 foreach($array as $key => $item){ 278 foreach($array as $key => $item){
268 /* 279 /*
269 * Manual encode to json. 280 * Manual encode to json.
270 */ 281 */
271 if ($comma) 282 if ($comma)
302 313
303 $hops = '['; 314 $hops = '[';
304 $comma = FALSE; 315 $comma = FALSE;
305 if (isset($_POST['hops'])) { 316 if (isset($_POST['hops'])) {
306 $array = $_POST['hops']; 317 $array = $_POST['hops'];
318 // Sort the array
319 $useat = array();
320 $time = array();
321 $amount = array();
322 for ($i = 0; $i < count($array); $i++) {
323 $useat[] = $array[$i]['h_useat'];
324 $time[] = $array[$i]['h_time'];
325 $amount[] = $array[$i]['h_amount'];
326 }
327 array_multisort($useat, SORT_ASC, SORT_NUMERIC,
328 $time, SORT_DESC, SORT_NUMERIC,
329 $amount, SORT_DESC, SORT_NUMERIC,
330 $array);
331 // Write the sorted array.
307 foreach($array as $key => $item){ 332 foreach($array as $key => $item){
308 if ($comma) 333 if ($comma)
309 $hops .= ','; 334 $hops .= ',';
310 $comma = TRUE; 335 $comma = TRUE;
311 $hop = '{"h_name":"' . str_replace($rescapers,$rreplacements,$item['h_name']); 336 $hop = '{"h_name":"' . str_replace($rescapers,$rreplacements,$item['h_name']);
333 358
334 $miscs = '['; 359 $miscs = '[';
335 $comma = FALSE; 360 $comma = FALSE;
336 if (isset($_POST['miscs'])) { 361 if (isset($_POST['miscs'])) {
337 $array = $_POST['miscs']; 362 $array = $_POST['miscs'];
363 // Sort the array
364 $use = array();
365 $type = array();
366 $amount = array();
367 for ($i = 0; $i < count($array); $i++) {
368 $use[] = $array[$i]['m_use_use'];
369 $type[] = $array[$i]['m_type'];
370 $amount[] = $array[$i]['m_amount'];
371 }
372 array_multisort($use, SORT_ASC, SORT_NUMERIC,
373 $type, SORT_ASC, SORT_NUMERIC,
374 $amount, SORT_DESC, SORT_NUMERIC,
375 $array);
376 // Write the sorted array.
338 foreach($array as $key => $item){ 377 foreach($array as $key => $item){
339 if ($comma) 378 if ($comma)
340 $miscs .= ','; 379 $miscs .= ',';
341 $comma = TRUE; 380 $comma = TRUE;
342 $misc = '{"m_name":"' . str_replace($rescapers,$rreplacements,$item['m_name']); 381 $misc = '{"m_name":"' . str_replace($rescapers,$rreplacements,$item['m_name']);
355 394
356 $yeasts = '['; 395 $yeasts = '[';
357 $comma = FALSE; 396 $comma = FALSE;
358 if (isset($_POST['yeasts'])) { 397 if (isset($_POST['yeasts'])) {
359 $array = $_POST['yeasts']; 398 $array = $_POST['yeasts'];
399 // Sort the array
400 $use = array();
401 $amount = array();
402 for ($i = 0; $i < count($array); $i++) {
403 $use[] = $array[$i]['y_use'];
404 $amount[] = $array[$i]['y_amount'];
405 }
406 array_multisort($use, SORT_ASC, SORT_NUMERIC,
407 $amount, SORT_DESC, SORT_NUMERIC,
408 $array);
409 // Write the sorted array.
360 foreach($array as $key => $item){ 410 foreach($array as $key => $item){
361 if ($comma) 411 if ($comma)
362 $yeasts .= ','; 412 $yeasts .= ',';
363 $comma = TRUE; 413 $comma = TRUE;
364 $yeast = '{"y_name":"' . str_replace($rescapers,$rreplacements,$item['y_name']); 414 $yeast = '{"y_name":"' . str_replace($rescapers,$rreplacements,$item['y_name']);
385 435
386 $mashs = '['; 436 $mashs = '[';
387 $comma = FALSE; 437 $comma = FALSE;
388 if (isset($_POST['mashs'])) { 438 if (isset($_POST['mashs'])) {
389 $array = $_POST['mashs']; 439 $array = $_POST['mashs'];
440 // Sort the array
441 $temp = array();
442 for ($i = 0; $i < count($array); $i++) {
443 $temp[] = $array[$i]['step_temp'];
444 }
445 array_multisort($temp, SORT_ASC, SORT_NUMERIC, $array);
446 // Write the sorted array.
390 foreach($array as $key => $item){ 447 foreach($array as $key => $item){
391 if ($comma) 448 if ($comma)
392 $mashs .= ','; 449 $mashs .= ',';
393 $comma = TRUE; 450 $comma = TRUE;
394 $mash = '{"step_name":"' . str_replace($rescapers,$rreplacements,$item['step_name']); 451 $mash = '{"step_name":"' . str_replace($rescapers,$rreplacements,$item['step_name']);

mercurial