www/includes/db_product.php

changeset 292
90cd3798edc2
parent 290
12aa92828e24
child 296
69fadd1aded2
--- a/www/includes/db_product.php	Sun Feb 24 23:26:51 2019 +0100
+++ b/www/includes/db_product.php	Mon Feb 25 13:27:41 2019 +0100
@@ -437,19 +437,62 @@
 	}
 
 	if (isset($_GET['select']) && ($_GET['select'] == "archname")) {
-		$query = "SELECT record,name,code,birth,batch_size FROM products WHERE stage = '11' ORDER BY name,birth;";
+		$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;";
+		$result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect));
+		while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
+			$brews[] = array(
+				'record' => $row['record'],
+				'name' => $row['name'],
+				'code' => $row['code'],
+				'date' => substr($row['brew_date_start'], 0, 10),
+				'style' => $row['st_name'],
+				'og' => $row['og'],
+				'fg' => $row['fg'],
+				'batch_size' => $row['batch_size']
+			);
+		}
+		syslog(LOG_NOTICE, json_encode($brews, JSON_UNESCAPED_UNICODE));
+	        echo json_encode($brews, JSON_UNESCAPED_UNICODE);
+	        return;
+	}
+
+	if (isset($_GET['select']) && ($_GET['select'] == "archcode")) {
+		$query = "SELECT record,name,code,brew_date_start,st_name,og,fg,batch_size FROM products WHERE stage = '11' ORDER BY code;";
 		$result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect));
 		while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
 			$brews[] = array(
 				'record' => $row['record'],
 				'name' => $row['name'],
 				'code' => $row['code'],
-				'birth' => $row['birth'],
+				'date' => substr($row['brew_date_start'], 0, 10),
+				'style' => $row['st_name'],
+				'og' => $row['og'],
+				'fg' => $row['fg'],
 				'batch_size' => $row['batch_size']
 			);
 		}
-	        echo json_encode($brews, JSON_UNESCAPED_UNICODE);
-	        return;
+		echo json_encode($brews, JSON_UNESCAPED_UNICODE);
+		return;
+	}
+
+	if (isset($_GET['select']) && ($_GET['select'] == "archdate")) {
+		$query = "SELECT record,name,code,brew_date_start,st_name,og,fg,batch_size FROM products WHERE stage = '11' ORDER BY brew_date_start;";
+		$result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect));
+		while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
+			$brews[] = array(
+				'record' => $row['record'],
+				'name' => $row['name'],
+				'code' => $row['code'],
+				'year' => substr($row['brew_date_start'], 0, 4),
+				'date' => substr($row['brew_date_start'], 0, 10),
+				'style' => $row['st_name'],
+				'og' => $row['og'],
+				'fg' => $row['fg'],
+				'batch_size' => $row['batch_size']
+			);
+		}
+		echo json_encode($brews, JSON_UNESCAPED_UNICODE);
+		return;
 	}
 
 	/*

mercurial