# HG changeset patch # User Michiel Broek # Date 1548419590 -3600 # Node ID f9b7e3f6be7c38a3ec59e0e4598b54b8849fc66b # Parent 7b2f11652d67718008d42cad86b4a2e269e8ee2a Fixed yeast database import differences between grams, ml and packs. Added cells field filled with defaults. Some edit screen improvements. Dynamic prompts depending on the yeast type. Disable men and filter of most columns in the yeasts list. Friendlier display of inverntory. diff -r 7b2f11652d67 -r f9b7e3f6be7c www/import/from_brouwhulp.php --- a/www/import/from_brouwhulp.php Thu Jan 24 20:54:45 2019 +0100 +++ b/www/import/from_brouwhulp.php Fri Jan 25 13:33:10 2019 +0100 @@ -279,15 +279,23 @@ if ($yeast->FORM == 'Liquid') { $sql .= "', cells='100000000000"; // 100 billion cells per pack + if ($yeast->COST) + $sql .= "', cost='" . floatval($yeast->COST); + if ($yeast->INVENTORY) + $sql .= "', inventory='" . floatval($yeast->INVENTORY); } else if ($yeast->FORM == 'Dry') { $sql .= "', cells='15000000000"; // 6..15 billion per gram + if ($yeast->INVENTORY) + $sql .= "', inventory='" . floatval($yeast->INVENTORY) / 1000.0; // To kg + if ($yeast->COST) + $sql .= "', cost='" . floatval($yeast->COST) * 1000.0; // to Euro/kg } else { $sql .= "', cells='1700000000"; // 1.7 billion cells per ml. + if ($yeast->INVENTORY) + $sql .= "', inventory='" . floatval($yeast->INVENTORY) / 1000.0; // To liter + if ($yeast->COST) + $sql .= "', cost='" . floatval($yeast->COST) * 1000.0; // to Euro/liter } - if ($yeast->INVENTORY) - $sql .= "', inventory='" . floatval($yeast->INVENTORY) / 1000.0; // To kg or liter - if ($yeast->COST) - $sql .= "', cost='" . floatval($yeast->COST) * 1000.0; // to Euro/kg or liter if ($yeast->CULTURE_DATE) { $date = substr($yeast->CULTURE_DATE, 6, 4) . '-' . substr($yeast->CULTURE_DATE, 3, 2) . '-' . substr($yeast->CULTURE_DATE, 0, 2); $sql .= "', production_date='" . $date; diff -r 7b2f11652d67 -r f9b7e3f6be7c www/includes/db_inventory_yeasts.php --- a/www/includes/db_inventory_yeasts.php Thu Jan 24 20:54:45 2019 +0100 +++ b/www/includes/db_inventory_yeasts.php Fri Jan 25 13:33:10 2019 +0100 @@ -31,7 +31,8 @@ $sql .= "', notes='" . mysqli_real_escape_string($connect, $_POST['notes']); $sql .= "', best_for='" . mysqli_real_escape_string($connect, $_POST['best_for']); $sql .= "', max_reuse='" . $_POST['max_reuse']; - $sql .= "', inventory='" . floatval($_POST['inventory']) / 1000.0; + $sql .= "', cells='" . floatval($_POST['cells']) * 1000000000.0; + $sql .= "', inventory='" . $_POST['inventory']; $sql .= "', cost='" . $_POST['cost'] . "'"; if ($_POST['production_date'] == '') $sql .= ", production_date=NULL"; @@ -92,10 +93,11 @@ 'notes' => $row['notes'], 'best_for' => $row['best_for'], 'max_reuse' => $row['max_reuse'], - 'inventory' => floatval($row['inventory']) * 1000.0, + 'inventory' => $row['inventory'], 'cost' => $row['cost'], 'production_date' => $row['production_date'], - 'tht_date' => $row['tht_date'] + 'tht_date' => $row['tht_date'], + 'cells' => floatval($row['cells']) / 1000000000.0 ); } echo json_encode($yeasts); diff -r 7b2f11652d67 -r f9b7e3f6be7c www/inv_yeasts.php --- a/www/inv_yeasts.php Thu Jan 24 20:54:45 2019 +0100 +++ b/www/inv_yeasts.php Fri Jan 25 13:33:10 2019 +0100 @@ -29,24 +29,24 @@ Type:
- Minimum temperatuur: + Minimum temperatuur °C:
Gist vorm:
- Maximum temperatuur: + Maximum temperatuur °C:
Laboratorium: - Vergistingsgraad: + Vergistingsgraad %:
- Geschikt voor: - + Geschikt voor: + Maximum Hergebruik:
@@ -55,29 +55,33 @@
+
cells:
+
+ +
- Voorraad gr/ml: +
Voorraad xx:
Productie datum:
- Prijs per kg: +
Prijs per xx:
THT datum:
- Waarde voorraad: + Waarde voorraad €:
- + - + diff -r 7b2f11652d67 -r f9b7e3f6be7c www/js/inv_yeasts.js --- a/www/js/inv_yeasts.js Thu Jan 24 20:54:45 2019 +0100 +++ b/www/js/inv_yeasts.js Fri Jan 25 13:33:10 2019 +0100 @@ -46,9 +46,25 @@ var dataRecord = {}; - function calcTotal(cost, inventory) { + function calcTotal() { - $('#totval').val(cost * (inventory / 1000)); + $('#totval').val(dataRecord.cost * dataRecord.inventory); + if (dataRecord.form == 0) { // Liquid + $("#pmpt_cost").html('Prijs per pak:'); + $("#pmpt_inventory").html('Voorraad pak(ken):'); + $("#pmpt_cells").html('Biljoen cellen per pak:'); + $("#inventory").jqxNumberInput({ decimalDigits: 0, spinButtonsStep: 1 }); + } else if (dataRecord.form == 1) { // Dry + $("#pmpt_cost").html('Prijs per kg:'); + $("#pmpt_inventory").html('Voorraad gram:'); + $("#pmpt_cells").html('Biljoen cellen per gram:'); + $("#inventory").jqxNumberInput({ decimalDigits: 1, spinButtonsStep: 0.5 }); + } else { + $("#pmpt_cost").html('Prijs per liter:'); + $("#pmpt_inventory").html('Voorraad ml:'); + $("#pmpt_cells").html('Biljoen cellen per ml:'); + $("#inventory").jqxNumberInput({ decimalDigits: 1, spinButtonsStep: 0.5 }); + } } var url = "includes/db_inventory_yeasts.php"; @@ -154,7 +170,7 @@ autoDropDownHeight: true }); $("#notes").jqxInput({ theme: theme, width: 800, height: 120 }); - $("#best_for").jqxInput({ theme: theme, width: 320, height: 50 }); + $("#best_for").jqxInput({ theme: theme, width: 320, height: 75 }); $("#inventory").jqxNumberInput( Spin1dec1 ); $("#production_date").jqxDateTimeInput( Dateopts ); $("#min_temperature").jqxNumberInput( YeastT ); @@ -168,13 +184,14 @@ height: 23, autoDropDownHeight: true }); - $("#attenuation").jqxNumberInput( Perc1dec1 ); + $("#attenuation").jqxNumberInput( Perc1dec5 ); $("#max_reuse").jqxNumberInput( PosInt ); $("#max_reuse").jqxNumberInput({ max: 10 }); $("#cost").jqxNumberInput( Spin2dec1 ); $("#tht_date").jqxDateTimeInput( Dateopts ); $("#totval").jqxNumberInput( Spin2dec1 ); $("#totval").jqxNumberInput({ width: 90, readOnly: true, spinButtons: false }); + $("#cells").jqxNumberInput( Spin1dec1 ); var dataAdapter = new $.jqx.dataAdapter(source); var editrow = -1; @@ -212,6 +229,7 @@ $("#cost").val(0); $("#production_date").val(''); $("#tht_date").val(''); + $("#cells").val(1); $("#popupWindow").jqxWindow('open'); }); }, @@ -219,22 +237,33 @@ filtermode: 'excel', columns: [ { text: 'Laboratorium', datafield: 'laboratory', width: 150 }, - { text: 'Product ID', datafield: 'product_id', width: 120 }, - { text: 'Gist naam', datafield: 'name' }, - { text: 'Type', datafield: 'type', align: 'center', cellsalign: 'center', width: 90, + { text: 'Product ID', datafield: 'product_id', width: 120, menu: false }, + { text: 'Gist naam', datafield: 'name', menu: false }, + { text: 'Type', datafield: 'type', align: 'center', cellsalign: 'center', menu: false, width: 110, cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { return "
" + YeastTypeData[value].nl + "
"; } }, - { text: 'Vorm', datafield: 'form', align: 'center', cellsalign: 'center', width: 90, + { text: 'Vorm', datafield: 'form', align: 'center', cellsalign: 'center', menu: false, width: 110, cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { return "
" + YeastFormData[value].nl + "
"; } }, - { 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: 'Wijzig', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () { + { text: 'SVG', datafield: 'attenuation', width: 80, align: 'right', cellsalign: 'right', menu: false, cellsformat: 'p1' }, + { text: 'Voorraad', datafield: 'inventory', width: 100, align: 'right', menu: false, cellsalign: 'right', + cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { + if (value == 0) + return "
"; + if ((rowdata.form == 0) && (value > 1)) + return "
"+dataAdapter.formatNumber(value,"f0")+" pakken
"; + if (rowdata.form == 0) + return "
"+dataAdapter.formatNumber(value,"f0")+" pak
"; + if (rowdata.form == 1) + return "
"+dataAdapter.formatNumber(value * 1000,"f1")+" gram
"; + return "
"+dataAdapter.formatNumber(value * 1000,"f1")+" ml
"; + } + }, + { text: 'Wijzig', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', menu: false, cellsrenderer: function () { return "Wijzig"; }, buttonclick: function (row) { // open the popup window when the user clicks a button. @@ -254,11 +283,15 @@ $("#notes").val(dataRecord.notes); $("#best_for").val(dataRecord.best_for); $("#max_reuse").val(dataRecord.max_reuse); - $("#inventory").val(dataRecord.inventory); + if (dataRecord.form == 0) + $("#inventory").val(dataRecord.inventory); + else + $("#inventory").val(dataRecord.inventory * 1000); $("#cost").val(dataRecord.cost); $("#production_date").val(dataRecord.production_date); $("#tht_date").val(dataRecord.tht_date); - calcTotal(dataRecord.cost, dataRecord.inventory); + $("#cells").val(dataRecord.cells); + calcTotal(); // show the popup window. $("#popupWindow").jqxWindow('open'); } @@ -266,13 +299,23 @@ ] }); + $('#popupWindow').on('open', function (event) { calcTotal(); }); $("#cost").on('change', function (event) { dataRecord.cost = parseFloat(event.args.value); - calcTotal(dataRecord.cost, dataRecord.inventory); + calcTotal(); }); $("#inventory").on('change', function (event) { - dataRecord.inventory = parseFloat(event.args.value); - calcTotal(dataRecord.cost, dataRecord.inventory); + if (dataRecord.form == 0) + dataRecord.inventory = parseFloat(event.args.value); + else + dataRecord.inventory = parseFloat(event.args.value) / 1000.0; + calcTotal(); + }); + $("#form").on('select', function (event) { + if (event.args) { + dataRecord.form = event.args.index; + calcTotal(); + } }); // initialize the popup window and buttons. @@ -309,6 +352,10 @@ if (editrow >= 0) { rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); } + if (dataRecord.form == 0) + var n_inventory = parseFloat($("#inventory").jqxNumberInput('decimal')); + else + var n_inventory = parseFloat($("#inventory").jqxNumberInput('decimal')) / 1000.0; var row = { record: rowID, name: $("#name").val(), @@ -323,10 +370,11 @@ notes: $("#notes").val(), best_for: $("#best_for").val(), max_reuse: parseInt($("#max_reuse").jqxNumberInput('decimal')), - inventory: parseFloat($("#inventory").jqxNumberInput('decimal')), + inventory: n_inventory, cost: parseFloat($("#cost").jqxNumberInput('decimal')), production_date: $("#production_date").val(), - tht_date: $("#tht_date").val() + tht_date: $("#tht_date").val(), + cells: parseFloat($("#cells").jqxNumberInput('decimal')) }; if (editrow >= 0) { $('#jqxgrid').jqxGrid('updaterow', rowID, row);