www/includes/db_product.php

changeset 292
90cd3798edc2
parent 290
12aa92828e24
child 296
69fadd1aded2
equal deleted inserted replaced
291:869247533c5f 292:90cd3798edc2
435 echo json_encode($brews, JSON_UNESCAPED_UNICODE); 435 echo json_encode($brews, JSON_UNESCAPED_UNICODE);
436 return; 436 return;
437 } 437 }
438 438
439 if (isset($_GET['select']) && ($_GET['select'] == "archname")) { 439 if (isset($_GET['select']) && ($_GET['select'] == "archname")) {
440 $query = "SELECT record,name,code,birth,batch_size FROM products WHERE stage = '11' ORDER BY name,birth;"; 440 $query = "SELECT record,name,code,brew_date_start,st_name,og,fg,batch_size FROM products WHERE stage = '11' ORDER BY name,brew_date_start;";
441 $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect)); 441 $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect));
442 while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { 442 while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
443 $brews[] = array( 443 $brews[] = array(
444 'record' => $row['record'], 444 'record' => $row['record'],
445 'name' => $row['name'], 445 'name' => $row['name'],
446 'code' => $row['code'], 446 'code' => $row['code'],
447 'birth' => $row['birth'], 447 'date' => substr($row['brew_date_start'], 0, 10),
448 'style' => $row['st_name'],
449 'og' => $row['og'],
450 'fg' => $row['fg'],
448 'batch_size' => $row['batch_size'] 451 'batch_size' => $row['batch_size']
449 ); 452 );
450 } 453 }
454 syslog(LOG_NOTICE, json_encode($brews, JSON_UNESCAPED_UNICODE));
451 echo json_encode($brews, JSON_UNESCAPED_UNICODE); 455 echo json_encode($brews, JSON_UNESCAPED_UNICODE);
452 return; 456 return;
457 }
458
459 if (isset($_GET['select']) && ($_GET['select'] == "archcode")) {
460 $query = "SELECT record,name,code,brew_date_start,st_name,og,fg,batch_size FROM products WHERE stage = '11' ORDER BY code;";
461 $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect));
462 while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
463 $brews[] = array(
464 'record' => $row['record'],
465 'name' => $row['name'],
466 'code' => $row['code'],
467 'date' => substr($row['brew_date_start'], 0, 10),
468 'style' => $row['st_name'],
469 'og' => $row['og'],
470 'fg' => $row['fg'],
471 'batch_size' => $row['batch_size']
472 );
473 }
474 echo json_encode($brews, JSON_UNESCAPED_UNICODE);
475 return;
476 }
477
478 if (isset($_GET['select']) && ($_GET['select'] == "archdate")) {
479 $query = "SELECT record,name,code,brew_date_start,st_name,og,fg,batch_size FROM products WHERE stage = '11' ORDER BY brew_date_start;";
480 $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect));
481 while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
482 $brews[] = array(
483 'record' => $row['record'],
484 'name' => $row['name'],
485 'code' => $row['code'],
486 'year' => substr($row['brew_date_start'], 0, 4),
487 'date' => substr($row['brew_date_start'], 0, 10),
488 'style' => $row['st_name'],
489 'og' => $row['og'],
490 'fg' => $row['fg'],
491 'batch_size' => $row['batch_size']
492 );
493 }
494 echo json_encode($brews, JSON_UNESCAPED_UNICODE);
495 return;
453 } 496 }
454 497
455 /* 498 /*
456 * SELECT, produce a list of products that can be fermented. 499 * SELECT, produce a list of products that can be fermented.
457 */ 500 */

mercurial