# HG changeset patch # User Michiel Broek # Date 1545050775 -3600 # Node ID 2a6c00d325b2184f05c6254c9c4c39be25d8aee7 # Parent 2662720e194987b9bd7795adb6859ef21c641011 In dropdown inventory lists you can now choose to display only ingredients that rae on stock or all. Fix the hops amount editor that loses the decimal digits. diff -r 2662720e1949 -r 2a6c00d325b2 www/getwatersources.php --- a/www/getwatersources.php Sun Dec 16 13:53:48 2018 +0100 +++ b/www/getwatersources.php Mon Dec 17 13:46:15 2018 +0100 @@ -20,6 +20,7 @@ 'magnesium' => $row['magnesium'], 'ph' => $row['ph'], 'total_alkalinity' => $row['total_alkalinity'], + 'inventory' => $row['inventory'], 'cost' => $row['cost'] ); } diff -r 2662720e1949 -r 2a6c00d325b2 www/js/global.js --- a/www/js/global.js Sun Dec 16 13:53:48 2018 +0100 +++ b/www/js/global.js Mon Dec 17 13:46:15 2018 +0100 @@ -58,7 +58,6 @@ var styleslist = new $.jqx.dataAdapter(stylesSource); // dropdownlist datasource from inventory_fermentables -var fermentableUrl = "getfermentablesources.php"; var fermentableInvSource = { datatype: "json", datafields: [ @@ -81,13 +80,26 @@ { name: 'inventory', type: 'float' }, { name: 'cost', type: 'float' } ], - url: fermentableUrl, + url: "getfermentablesources.php", async: true }; -var fermentablelist = new $.jqx.dataAdapter(fermentableInvSource); +var fermentableinstock = false; +var fermentablelist = new $.jqx.dataAdapter(fermentableInvSource, { + beforeLoadComplete: function (records) { + var data = new Array(); + for (var i = 0; i < records.length; i++) { + var row = records[i]; + if (row.inventory || ! fermentableinstock) + data.push(row); + } + return data; + }, + loadError: function(jqXHR, status, error) { + $('#err').text(status + ' ' + error); + }, +}); // dropdownlist datasource from inventory_hops -var hopUrl = "gethopsources.php"; var hopInvSource = { datatype: "json", datafields: [ @@ -105,15 +117,29 @@ { name: 'useat', type: 'string' }, { name: 'form', type: 'string' }, { name: 'total_oil', type: 'float' }, + { name: 'inventory', type: 'float' }, { name: 'cost', type: 'float' } ], - url: hopUrl, + url: "gethopsources.php", async: true }; -var hoplist = new $.jqx.dataAdapter(hopInvSource); +var hopinstock = false; +var hoplist = new $.jqx.dataAdapter(hopInvSource, { + beforeLoadComplete: function (records) { + var data = new Array(); + for (var i = 0; i < records.length; i++) { + var row = records[i]; + if (row.inventory || ! hopinstock) + data.push(row); + } + return data; + }, + loadError: function(jqXHR, status, error) { + $('#err').text(status + ' ' + error); + }, +}); // dropdownlist datasource from inventory_miscs -var miscUrl = "getmiscsources.php"; var miscInvSource = { datatype: "json", datafields: [ @@ -123,15 +149,29 @@ { name: 'use_use', type: 'string' }, { name: 'amount_is_weight', type: 'bool' }, { name: 'time', type: 'float' }, + { name: 'inventory', type: 'float' }, { name: 'cost', type: 'float' } ], - url: miscUrl, + url: "getmiscsources.php", async: true }; -var misclist = new $.jqx.dataAdapter(miscInvSource); +var miscinstock = false; +var misclist = new $.jqx.dataAdapter(miscInvSource, { + beforeLoadComplete: function (records) { + var data = new Array(); + for (var i = 0; i < records.length; i++) { + var row = records[i]; + if (row.inventory || ! miscinstock) + data.push(row); + } + return data; + }, + loadError: function(jqXHR, status, error) { + $('#err').text(status + ' ' + error); + }, +}); // dropdownlist datasource from inventory_yeasts -var yeastUrl = "getyeastsources.php"; var yeastInvSource = { datatype: "json", datafields: [ @@ -144,15 +184,29 @@ { name: 'min_temperature', type: 'float' }, { name: 'max_temperature', type: 'float' }, { name: 'attenuation', type: 'float' }, + { name: 'inventory', type: 'float' }, { name: 'cost', type: 'float' } ], - url: yeastUrl, + url: "getyeastsources.php", async: true }; -var yeastlist = new $.jqx.dataAdapter(yeastInvSource); +var yeastinstock = false; +var yeastlist = new $.jqx.dataAdapter(yeastInvSource, { + beforeLoadComplete: function (records) { + var data = new Array(); + for (var i = 0; i < records.length; i++) { + var row = records[i]; + if (row.inventory || ! yeastinstock) + data.push(row); + } + return data; + }, + loadError: function(jqXHR, status, error) { + $('#err').text(status + ' ' + error); + }, +}); // dropdownlist datasource from inventory_waters -var waterUrl = "getwatersources.php"; var waterInvSource = { datatype: "json", datafields: [ @@ -166,15 +220,29 @@ { name: 'magnesium', type: 'float' }, { name: 'ph', type: 'float' }, { name: 'total_alkalinity', type: 'float' }, + { name: 'inventory', type: 'float' }, { name: 'cost', type: 'float' }, ], - url: waterUrl, + url: "getwatersources.php", async: true }; -var waterlist = new $.jqx.dataAdapter(waterInvSource); +var waterinstock = false; +var waterlist = new $.jqx.dataAdapter(waterInvSource, { + beforeLoadComplete: function (records) { + var data = new Array(); + for (var i = 0; i < records.length; i++) { + var row = records[i]; + if (row.inventory || row.unlimited_stock || ! waterinstock) + data.push(row); + } + return data; + }, + loadError: function(jqXHR, status, error) { + $('#err').text(status + ' ' + error); + }, +}); // dropdownlist datasource from profile_mash -var mashUrl = "include/db_profile_mash.php"; var mashInvSource = { datatype: "json", datafields: [ @@ -182,7 +250,7 @@ { name: 'name', type: 'string' }, { name: 'steps', type: 'array' } ], - url: mashUrl, + url: "include/db_profile_mash.php", async: true }; var mashlist = new $.jqx.dataAdapter(mashInvSource); diff -r 2662720e1949 -r 2a6c00d325b2 www/js/rec_edit.js --- a/www/js/rec_edit.js Sun Dec 16 13:53:48 2018 +0100 +++ b/www/js/rec_edit.js Mon Dec 17 13:46:15 2018 +0100 @@ -502,7 +502,9 @@ var container = $("
"); toolbar.append(container); container.append('
'); - container.append(''); + container.append('
In voorraad:
'); + container.append('
'); + container.append(''); // add fermentable from dropdownlist. $("#faddrowbutton").jqxDropDownList({ placeHolder: "Kies mout:", @@ -561,6 +563,12 @@ } }); + $("#finstockbutton").jqxCheckBox({ theme: theme, height: 27 }); + $("#finstockbutton").on('change', function (event) { + fermentableinstock = event.args.checked; + fermentablelist.dataBind(); + }); + // delete selected fermentable. $("#fdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); $("#fdeleterowbutton").on('click', function () { @@ -802,7 +810,9 @@ var container = $("
"); toolbar.append(container); container.append('
'); - container.append(''); + container.append('
In voorraad:
'); + container.append('
'); + container.append(''); // add hop from dropdownlist. $("#haddrowbutton").jqxDropDownList({ placeHolder: "Kies hop:", @@ -844,6 +854,12 @@ } }); + $("#hinstockbutton").jqxCheckBox({ theme: theme, height: 27 }); + $("#hinstockbutton").on('change', function (event) { + hopinstock = event.args.checked; + hoplist.dataBind(); + }); + // delete selected hop. $("#hdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); $("#hdeleterowbutton").on('click', function () { @@ -870,17 +886,14 @@ { text: 'Vorm', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_form' }, { text: 'Alpha', editable: false, datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, { text: 'Amount', hidden: true, datafield: 'h_amount' }, - { text: 'Gewicht gr', datafield: 'h_weight', width: 120, align: 'right', cellsalign: 'right', + { text: 'Gewicht gr', datafield: 'h_weight', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f1', columntype: 'numberinput', cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { return "
" + dataAdapter.formatNumber(value, "f1") + " gr
"; }, initeditor: function (row, cellvalue, editor, celltext, pressedChar) { editor.jqxNumberInput({ - inputMode: 'simple', - symbol: ' gr', symbolPosition: 'right', - decimalDigits: 1, - min: 0, max: parseFloat(dataRecord.batch_size * 200), + inputMode: 'simple', decimalDigits: 1, min: 0, max: parseFloat(dataRecord.batch_size * 200), spinButtons: false }); }, @@ -1008,7 +1021,9 @@ var container = $("
"); toolbar.append(container); container.append('
'); - container.append(''); + container.append('
In voorraad:
'); + container.append('
'); + container.append(''); // add misc from dropdownlist. $("#maddrowbutton").jqxDropDownList({ placeHolder: "Kies ingredient:", @@ -1017,7 +1032,8 @@ displayMember: "name", width: 150, height: 27, - dropDownWidth: 300 + dropDownWidth: 500, + dropDownHeight: 500 }); $("#maddrowbutton").on('select', function (event) { if (event.args) { @@ -1035,6 +1051,11 @@ var commit = $("#miscGrid").jqxGrid('addrow', null, row); } }); + $("#minstockbutton").jqxCheckBox({ theme: theme, height: 27 }); + $("#minstockbutton").on('change', function (event) { + miscinstock = event.args.checked; + misclist.dataBind(); + }); // delete selected misc. $("#mdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); $("#mdeleterowbutton").on('click', function () { @@ -1150,7 +1171,8 @@ { name: 'y_max_temperature', type: 'float' }, { name: 'y_attenuation', type: 'float' }, { name: 'y_amount_is_weight', type: 'bool' }, - { name: 'y_use', type: 'string' } + { name: 'y_use', type: 'string' }, + { name: 'y_weight', type: 'float' } ], addrow: function (rowid, rowdata, position, commit) { commit(true); @@ -1159,7 +1181,23 @@ commit(true); } }; - var yeastAdapter = new $.jqx.dataAdapter(yeastSource); + var yeastAdapter = new $.jqx.dataAdapter(yeastSource, { + beforeLoadComplete: function (records) { + var data = new Array(); + for (var i = 0; i < records.length; i++) { + var row = records[i]; + if (row.y_form == 'Liquid') + row.y_weight = Math.round(row.y_amount * 17); + else + row.y_weight = row.y_amount * 1000; + data.push(row); + } + return data; + }, + loadError: function(jqXHR, status, error) { + $('#err').text(status + ' ' + error); + }, + }); $("#yeastGrid").jqxGrid({ width: 1050, height: 300, @@ -1175,6 +1213,8 @@ var container = $("
"); toolbar.append(container); container.append('
'); + container.append('
In voorraad:
'); + container.append('
'); container.append(''); // add yeast from dropdownlist. $("#yaddrowbutton").jqxDropDownList({ @@ -1213,9 +1253,15 @@ row["y_min_temperature"] = datarecord.min_temperature; row["y_max_temperature"] = datarecord.max_temperature; row["y_attenuation"] = datarecord.attenuation; + row["y_weight"] = 0; var commit = $("#yeastGrid").jqxGrid('addrow', null, row); } }); + $("#yinstockbutton").jqxCheckBox({ theme: theme, height: 27 }); + $("#yinstockbutton").on('change', function (event) { + yeastinstock = event.args.checked; + yeastlist.dataBind(); + }); // delete selected yeast. $("#ydeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); $("#ydeleterowbutton").on('click', function () { @@ -1246,30 +1292,28 @@ } }, { datafield: 'y_amount', width: 90 }, - { text: 'Hoeveel', datafield: 'amount', width: 110, align: 'right', cellsalign: 'right', columntype: 'numberinput', + { text: 'Hoeveel', datafield: 'y_weight', width: 110, align: 'right', cellsalign: 'right', + cellsformat: 'f1', columntype: 'numberinput', cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { if (rowdata.y_form == 'Liquid') { - var hoeveel = rowdata.y_amount * 17; - return "
"+dataAdapter.formatNumber(hoeveel, "f0")+" pk
"; + return "
"+dataAdapter.formatNumber(value, "f0")+" pk
"; } else if (rowdata.y_form == 'Dry') { - var hoeveel = rowdata.y_amount * 1000; - return "
"+dataAdapter.formatNumber(hoeveel, "f1")+" gr
"; + return "
"+dataAdapter.formatNumber(value, "f1")+" gr
"; } else { - var hoeveel = rowdata.y_amount * 1000; - return "
"+dataAdapter.formatNumber(hoeveel, "f0")+" ml
"; + return "
"+dataAdapter.formatNumber(value, "f0")+" ml
"; } }, initeditor: function (row, cellvalue, editor, celltext, pressedChar) { var form = $("#yeastGrid").jqxGrid('getcellvalue', args.rowindex, 'y_form'); - if (form == 'Liquid') { - editor.jqxNumberInput({ decimalDigits: 0, min: 0 }); + if (form == 'Dry') { + editor.jqxNumberInput({ decimalDigits: 1, min: 0, spinButtons: false }); } else { - editor.jqxNumberInput({ decimalDigits: 1, min: 0 }); + editor.jqxNumberInput({ decimalDigits: 0, min: 0, spinButtons: false }); } }, validation: function (cell, value) { if (value < 0 || value > 100000000000 ) { - return { result: false, message: "Volume moet 0-~ zijn" }; + return { result: false, message: "Hoeveelheid moet 0-~ zijn" }; } return true; } @@ -1279,14 +1323,13 @@ $("#yeastGrid").on('cellendedit', function (event) { var args = event.args; console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value); - if (args.datafield == 'amount') { + $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value); + if (args.datafield == 'y_weight') { var form = $("#yeastGrid").jqxGrid('getcellvalue', args.rowindex, 'y_form'); if (form == 'Liquid') $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, 'y_amount', parseFloat(args.value * 0.0588)); else $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, 'y_amount', parseFloat(args.value / 1000)); - } else { - $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value); } }); }; @@ -1331,7 +1374,9 @@ var container = $("
"); toolbar.append(container); container.append('
'); - container.append(''); + container.append('
In voorraad:
'); + container.append('
'); + container.append(''); // add water from dropdownlist. $("#waddrowbutton").jqxDropDownList({ placeHolder: "Kies water:", @@ -1340,7 +1385,8 @@ displayMember: "name", width: 150, height: 27, - dropDownWidth: 300 + dropDownWidth: 400, + dropDownHeight: 400 }); $("#waddrowbutton").on('select', function (event) { if (event.args) { @@ -1360,7 +1406,11 @@ var commit = $("#waterGrid").jqxGrid('addrow', null, row); } }); - + $("#winstockbutton").jqxCheckBox({ theme: theme, height: 27 }); + $("#winstockbutton").on('change', function (event) { + waterinstock = event.args.checked; + waterlist.dataBind(); + }); // delete selected water. // Overgebleven waters in volume verhogen met het verwijderde water. $("#wdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 });