www/inv_instock.php

changeset 33
2ee6ad5d6f14
parent 30
f5ab22446aa5
child 77
a9f8de2d7b2b
--- 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>

mercurial