More weight/volmes standards in the database.

Sun, 19 Aug 2018 21:46:56 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 19 Aug 2018 21:46:56 +0200
changeset 33
2ee6ad5d6f14
parent 32
8bb369f32ef9
child 34
a720353fada9

More weight/volmes standards in the database.

www/includes/db_inventory_hops.php file | annotate | diff | comparison | revisions
www/includes/db_inventory_yeasts.php file | annotate | diff | comparison | revisions
www/inv_instock.php file | annotate | diff | comparison | revisions
www/inv_yeasts.php file | annotate | diff | comparison | revisions
www/js/inv_yeasts.js file | annotate | diff | comparison | revisions
--- a/www/includes/db_inventory_hops.php	Sun Aug 19 17:35:16 2018 +0200
+++ b/www/includes/db_inventory_hops.php	Sun Aug 19 21:46:56 2018 +0200
@@ -28,7 +28,7 @@
 	$sql .= "', origin='" . mysqli_real_escape_string($connect, $_GET['origin']);
 	$sql .= "', substitutes='" . mysqli_real_escape_string($connect, $_GET['substitutes']);
 	($_GET['always_on_stock'] == 'true') ? $sql .= "', always_on_stock='1" : $sql .= "', always_on_stock='0";
-	$sql .= "', inventory='" . $_GET['inventory'] / 1000.0;
+	$sql .= "', inventory='" . floatval($_GET['inventory']) / 1000.0;
 	$sql .= "', cost='" . $_GET['cost'];
 	$sql .= "', production_date='" . $_GET['production_date'];
 	$sql .= "', tht_date='" . $_GET['tht_date'];
@@ -58,7 +58,7 @@
 	$sql .= "', origin='" . mysqli_real_escape_string($connect, $_GET['origin']);
 	$sql .= "', substitutes='" . mysqli_real_escape_string($connect, $_GET['substitutes']);
 	($_GET['always_on_stock'] == 'true') ? $sql .= "', always_on_stock='1" : $sql .= "', always_on_stock='0";
-	$sql .= "', inventory='" . $_GET['inventory'] / 1000.0;
+	$sql .= "', inventory='" . floatval($_GET['inventory']) / 1000.0;
 	$sql .= "', cost='" . $_GET['cost'];
 	$sql .= "', production_date='" . $_GET['production_date'];
 	$sql .= "', tht_date='" . $_GET['tht_date'];
@@ -103,7 +103,7 @@
 			'origin' => $row['origin'],
 			'substitutes' => $row['substitutes'],
 			'always_on_stock' => $row['always_on_stock'],
-			'inventory' => $row['inventory'] * 1000,
+			'inventory' => floatval($row['inventory']) * 1000.0,
 			'cost' => $row['cost'],
 			'production_date' => $row['production_date'],
 			'tht_date' => $row['tht_date'],
--- a/www/includes/db_inventory_yeasts.php	Sun Aug 19 17:35:16 2018 +0200
+++ b/www/includes/db_inventory_yeasts.php	Sun Aug 19 21:46:56 2018 +0200
@@ -25,7 +25,7 @@
 	$sql .= "', notes='" . mysqli_real_escape_string($connect, $_GET['notes']);
 	$sql .= "', best_for='" . mysqli_real_escape_string($connect, $_GET['best_for']);
 	$sql .= "', max_reuse='" . $_GET['max_reuse'];
-	$sql .= "', inventory='" . $_GET['inventory'];
+	$sql .= "', inventory='" . floatval($_GET['inventory']) / 1000.0;
 	$sql .= "', cost='" . $_GET['cost'];
 	$sql .= "', production_date='" . $_GET['production_date'];
 	$sql .= "', tht_date='" . $_GET['tht_date'];
@@ -52,7 +52,7 @@
 	$sql .= "', notes='" . mysqli_real_escape_string($connect, $_GET['notes']);
 	$sql .= "', best_for='" . mysqli_real_escape_string($connect, $_GET['best_for']);
 	$sql .= "', max_reuse='" . $_GET['max_reuse'];
-	$sql .= "', inventory='" . $_GET['inventory'];
+	$sql .= "', inventory='" . floatval($_GET['inventory']) / 1000.0;
 	$sql .= "', cost='" . $_GET['cost'];
 	$sql .= "', production_date='" . $_GET['production_date'];
 	$sql .= "', tht_date='" . $_GET['tht_date'];
@@ -94,7 +94,7 @@
 			'notes' => $row['notes'],
 			'best_for' => $row['best_for'],
 			'max_reuse' => $row['max_reuse'],
-			'inventory' => $row['inventory'],
+			'inventory' => floatval($row['inventory']) * 1000.0,
 			'cost' => $row['cost'],
 			'production_date' => $row['production_date'],
 			'tht_date' => $row['tht_date']
--- a/www/inv_instock.php	Sun Aug 19 17:35:16 2018 +0200
+++ b/www/inv_instock.php	Sun Aug 19 21:46:56 2018 +0200
@@ -10,41 +10,59 @@
 $mysqli = new mysqli(DBASE_HOST,DBASE_USER,DBASE_PASS,DBASE_NAME);
 $result = $mysqli->query("SELECT name,inventory,cost FROM inventory_fermentables WHERE inventory > 0");
 $tot_fermentables = 0.0;
-printf("Vergistbaar ingredient                     Voorraad     Prijs/kg    Waarde\n");
-printf("---------------------------------------- ----------     --------  --------\n");
+printf("Vergistbaar ingredient                                         Voorraad     Prijs/kg    Waarde\n");
+printf("------------------------------------------------------------ ----------     --------  --------\n");
 while($row = $result->fetch_array(MYSQLI_ASSOC)) {
 	$value = $row['inventory'] * $row['cost'];
 	$tot_fermentables += $value;
-//	printf("%-40s %10.5f kg  %8.2f  %8.2f \n", $row['name'], $row['inventory'], $row['cost'], $value);
+//	printf("%-60s %10.5f kg  %8.2f  %8.2f \n", $row['name'], $row['inventory'], $row['cost'], $value);
 }
-printf("----------------------------------------                          --------\n");
-printf("Totaal                                                            %8.2f\n\n", $tot_fermentables);
+printf("                                                                                      --------\n");
+printf("Totaal                                                                                %8.2f\n\n", $tot_fermentables);
 
 $tot_hops = 0.0;
-$result = $mysqli->query("SELECT name,inventory,cost FROM inventory_hops WHERE inventory > 0");
-$tot_fermentables = 0.0;
-printf("Hoppen                                     Voorraad     Prijs/kg    Waarde\n");
-printf("---------------------------------------- ----------     --------  --------\n");
+$result = $mysqli->query("SELECT name,form,origin,inventory,cost FROM inventory_hops WHERE inventory > 0");
+printf("Hoppen                                                         Voorraad     Prijs/kg    Waarde\n");
+printf("------------------------------------------------------------ ----------     --------  --------\n");
 while($row = $result->fetch_array(MYSQLI_ASSOC)) {
         $value = $row['inventory'] * $row['cost'];
-        $tot_hops += $value;
-	printf("%-40s %10.5f kg  %8.2f  %8.2f \n", $row['name'], $row['inventory'], $row['cost'], $value);
+	$tot_hops += $value;
+	$hop = $row['form'] . " " . $row['origin'] . " - " . $row['name'];
+	$stock = floatval($row['inventory']) * 1000.0;
+//	printf("%-60s %10.1f gr  %8.2f  %8.2f \n", $hop, $stock, $row['cost'], $value);
 }
-printf("----------------------------------------                          --------\n\n");
-printf("Totaal                                                            %8.2f\n", $tot_hops );
+printf("                                                                                      --------\n");
+printf("Totaal                                                                                %8.2f\n\n", $tot_hops );
 
-$tot_yeats = 0.0;
-$result = $mysqli->query("SELECT name,inventory,cost FROM inventory_yeasts WHERE inventory > 0");
-$tot_fermentables = 0.0;
-printf("Hoppen                                     Voorraad     Prijs/kg    Waarde\n");
-printf("---------------------------------------- ----------     --------  --------\n");
+$tot_yeasts = 0.0;
+$result = $mysqli->query("SELECT name,laboratory,product_id,form,inventory,cost FROM inventory_yeasts WHERE inventory > 0");
+printf("Gisten                                                         Voorraad     Prijs/kg    Waarde\n");
+printf("------------------------------------------------------------ ----------     --------  --------\n");
+while($row = $result->fetch_array(MYSQLI_ASSOC)) {
+	$value = $row['inventory'] * $row['cost'];
+	$yeast = $row['laboratory'] . " " .$row['product_id'] . " - " . $row['name'];
+	$tot_yeasts += $value;
+	$stock = floatval($row['inventory']) * 1000.0;
+	($row['form'] == 'Dry') ? $amount = "gr" : $amount = "ml";
+//        printf("%-60s %10.1f %s  %8.2f  %8.2f \n", $yeast, $stock, $amount, $row['cost'], $value);
+}
+printf("                                                                                      --------\n");
+printf("Totaal                                                                                %8.2f\n\n", $tot_yeasts );
+
+$tot_miscs = 0.0;
+$result = $mysqli->query("SELECT name,type,amount_is_weight,inventory,cost FROM inventory_miscs WHERE inventory > 0");
+printf("Diverse ingredienten                                           Voorraad     Prijs/kg    Waarde\n");
+printf("------------------------------------------------------------ ----------     --------  --------\n");
 while($row = $result->fetch_array(MYSQLI_ASSOC)) {
         $value = $row['inventory'] * $row['cost'];
-        $tot_yeasts += $value;
-        printf("%-40s %10.5f kg  %8.2f  %8.2f \n", $row['name'], $row['inventory'], $row['cost'], $value);
+        $misc  = $row['type'] . " " . $row['name'];
+        $tot_miscs += $value;
+        $stock = floatval($row['inventory']) * 1000.0;
+        ($row['amount_is_weight']) ? $amount = "gr" : $amount = "ml";
+        printf("%-60s %10.1f %s  %8.2f  %8.2f \n", $misc, $stock, $amount, $row['cost'], $value);
 }
-printf("----------------------------------------                          --------\n\n");
-printf("Totaal                                                            %8.2f\n", $tot_yeasts );
+printf("                                                                                      --------\n");
+printf("Totaal                                                                                %8.2f\n\n", $tot_miscs );
 ?>
     </pre>
    </div>
--- a/www/inv_yeasts.php	Sun Aug 19 17:35:16 2018 +0200
+++ b/www/inv_yeasts.php	Sun Aug 19 21:46:56 2018 +0200
@@ -53,9 +53,9 @@
        <td align="left" colspan="3"><input id="best_for" /></td>
       </tr>
       <tr>
-       <td align="right" style="vertical-align: top;">Voorraad:</td>
+       <td align="right" style="vertical-align: top;">Voorraad gr/ml:</td>
        <td align="left"><div id="inventory"></div></td>
-       <td align="right" style="vertical-align: top;">Prijs per gram:</td>
+       <td align="right" style="vertical-align: top;">Prijs per kg:</td>
        <td align="left"><div id="cost"></div></td>
       </tr>
       <tr>
--- a/www/js/inv_yeasts.js	Sun Aug 19 17:35:16 2018 +0200
+++ b/www/js/inv_yeasts.js	Sun Aug 19 21:46:56 2018 +0200
@@ -129,7 +129,7 @@
 	$("#form").jqxDropDownList({ theme: theme, source: srcForm, selectedIndex: 0, width: 90, height: 23, dropDownHeight: 195 });
 	$("#notes").jqxInput({ theme: theme, width: 640, height: 120 });
 	$("#best_for").jqxInput({ theme: theme, width: 640, height: 23 });
-	$("#inventory").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true });
+	$("#inventory").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 1, spinButtons: true });
 	$("#production_date").jqxDateTimeInput({ theme: theme, width: 100, height: 23, formatString: 'yyyy-MM-dd' });
 
 	$("#min_temperature").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, max: 35, decimalDigits: 0, spinButtons: true });
@@ -138,7 +138,7 @@
 	$("#attenuation").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 50, max: 100, decimalDigits: 1, spinButtons: true });
 
 	$("#max_reuse").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, max: 10, decimalDigits: 0, spinButtons: true });
-	$("#cost").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 2, spinButtons: true });
+	$("#cost").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 2, spinButtons: true });
 	$("#tht_date").jqxDateTimeInput({ theme: theme, width: 100, height: 23, formatString: 'yyyy-MM-dd' });
 
 	var dataAdapter = new $.jqx.dataAdapter(source);
@@ -183,14 +183,15 @@
 		filterable: true,
 		filtermode: 'excel',
 		columns: [
-			{ text: 'Gist naam', datafield: 'name', width: 250 },
+			{ text: 'Gist naam', datafield: 'name', width: 350 },
 			{ text: 'Laboratorium', datafield: 'laboratory', width: 150 },
 			{ text: 'Product ID', datafield: 'product_id', width: 120 },
-			{ text: 'Type', datafield: 'type', width: 90 },
-			{ text: 'Vorm', datafield: 'form', width: 90 },
-			{ text: 'Voorraad', datafield: 'inventory', width: 70, cellsalign: 'right' },
-			{ text: 'Prijs', datafield: 'cost', width: 70, cellsalign: 'right', cellsformat: 'c2' },
-			{ text: 'Edit', datafield: 'Edit', columntype: 'button', cellsrenderer: function () {
+			{ text: 'Type', datafield: 'type', align: 'center', cellsalign: 'center', width: 90 },
+			{ text: 'Vorm', datafield: 'form', align: 'center', cellsalign: 'center', width: 90 },
+			{ text: 'Vergistingsgraad', datafield: 'attenuation', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'p0' },
+			{ text: 'Voor. gr/ml', datafield: 'inventory', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
+			{ text: 'Prijs kg/l', datafield: 'cost', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'c2' },
+			{ text: 'Edit', datafield: 'Edit', columntype: 'button', align: 'center', cellsrenderer: function () {
 				return "Edit";
 				}, buttonclick: function (row) {
 					// open the popup window when the user clicks a button.

mercurial