# HG changeset patch # User Michiel Broek # Date 1548970776 -3600 # Node ID 40e68b18b50d40c2223eae81a34e0d5c2814225c # Parent ad2e1e3ccaca0e2497d9c6194f23ce07da8bec46 The recipes yeast grid now uses a popup editor. diff -r ad2e1e3ccaca -r 40e68b18b50d www/import/from_brouwhulp.php --- a/www/import/from_brouwhulp.php Thu Jan 31 17:16:51 2019 +0100 +++ b/www/import/from_brouwhulp.php Thu Jan 31 22:39:36 2019 +0100 @@ -971,15 +971,14 @@ $yeasts .= ','; $comma = TRUE; $yeasts .= '{"y_name":"' . mysqli_real_escape_string($db, $yeast->NAME) . '"'; - $yeasts .= ',"y_amount":' . floatval($yeast->AMOUNT); - if ($yeast->COST) { - if (($yeast->FORM == "Liquid") && ($yeast->AMOUNT == "0.0588")) { // Packs - $yeasts .= ',"y_cost":' . floatval($yeast->COST) / 58.8; - } else { - $yeasts .= ',"y_cost":' . floatval($yeast->COST); - } - } else - $yeasts .= ',"y_cost":0'; + if ($yeast->FORM == "Liquid") { + $paks = floatval($yeast->AMOUNT) / 0.0588; + $yeasts .= ',"y_amount":' . $paks; + } else { + $yeasts .= ',"y_amount":' . floatval($yeast->AMOUNT); + } + + $yeasts .= ',"y_cost":' . floatval($yeast->COST); $yeasts .= ',"y_laboratory":"' . mysqli_real_escape_string($db, $yeast->LABORATORY) . '"'; $yeasts .= ',"y_product_id":"' . mysqli_real_escape_string($db, $yeast->PRODUCT_ID) . '"'; @@ -1014,7 +1013,17 @@ else echo "Unknown FORM " . $yeast->FORM . PHP_EOL; - ($yeast->AMOUNT_IS_WEIGHT== "TRUE") ? $yeasts .= ',"y_amount_is_weight":1' : $yeasts.= ',"y_amount_is_weight":0'; + if ($yeast->FLOCCULATION == 'Low') + $yeasts .= ',"y_flocculation":0'; + else if ($yeast->FLOCCULATION == 'Medium') + $yeasts .= ',"y_flocculation":1'; + else if ($yeast->FLOCCULATION == 'High') + $yeasts .= ',"y_flocculation":2'; + else if ($yeast->FLOCCULATION == 'Very high') + $yeasts .= ',"y_flocculation":3'; + else + echo "Unknown FLOCCULATION " . $yeast->FLOCCULATION . PHP_EOL; + if ($yeast->ADD_TO_SECONDARY=="FALSE") { $yeasts .= ',"y_use":0'; // Primary $svg = floatval($yeast->ATTENUATION); diff -r ad2e1e3ccaca -r 40e68b18b50d www/includes/db_recipes.php --- a/www/includes/db_recipes.php Thu Jan 31 17:16:51 2019 +0100 +++ b/www/includes/db_recipes.php Thu Jan 31 22:39:36 2019 +0100 @@ -191,23 +191,41 @@ $misc .= ',"m_time":' . $item['m_time']; $misc .= ',"m_amount_is_weight":' . $item['m_amount_is_weight']; $misc .= ',"m_cost":' . $item['m_cost'] . '}'; - syslog(LOG_NOTICE, $misc); + //syslog(LOG_NOTICE, $misc); $miscs .= $misc; } } $miscs .= ']'; $sql .= "', json_miscs='" . $miscs; + $yeasts = '['; + $comma = FALSE; if (isset($_POST['yeasts'])) { $array = $_POST['yeasts']; - foreach($array as $key => $item){ - foreach ($disallowed as $disallowed_key) { - unset($array[$key]["$disallowed_key"]); - } + foreach($array as $key => $item) { + if ($comma) + $yeasts .= ','; + $comma = TRUE; + $yeast = '{"y_name":"' . str_replace($rescapers,$rreplacements,$item['y_name']); + $yeast .= '","y_laboratory":"' . str_replace($rescapers,$rreplacements,$item['y_laboratory']); + $yeast .= '","y_product_id":"' . str_replace($rescapers,$rreplacements,$item['y_product_id']); + $yeast .= '","y_amount":' . $item['y_amount']; + $yeast .= ',"y_type":' . $item['y_type']; + $yeast .= ',"y_form":' . $item['y_form']; + $yeast .= ',"y_min_temperature":' . $item['y_min_temperature']; + $yeast .= ',"y_max_temperature":' . $item['y_max_temperature']; + $yeast .= ',"y_flocculation":' . $item['y_flocculation']; + $yeast .= ',"y_attenuation":' . $item['y_attenuation']; + $yeast .= ',"y_cells":' . $item['y_cells']; + $yeast .= ',"y_inventory":' . $item['y_inventory']; + $yeast .= ',"y_use":' . $item['y_use']; + $yeast .= ',"y_cost":' . $item['y_cost'] . '}'; + syslog(LOG_NOTICE, $yeast); + $yeasts .= $yeast; } - syslog(LOG_NOTICE, "json_yeasts: ". str_replace($rescapers,$rreplacements,json_encode($array))); - $sql .= "', json_yeasts='" . str_replace($rescapers,$rreplacements,json_encode($array)); } + $yeasts .= ']'; + $sql .= "', json_yeasts='" . $yeasts; if (isset($_POST['mashs'])) { $array = $_POST['mashs']; diff -r ad2e1e3ccaca -r 40e68b18b50d www/js/rec_edit.js --- a/www/js/rec_edit.js Thu Jan 31 17:16:51 2019 +0100 +++ b/www/js/rec_edit.js Thu Jan 31 22:39:36 2019 +0100 @@ -2031,13 +2031,14 @@ { name: 'y_cost', type: 'float' }, { name: 'y_type', type: 'int' }, { name: 'y_form', type: 'int' }, - { name: 'y_time', type: 'float' }, + { name: 'y_flocculation', type: 'int' }, { name: 'y_min_temperature', type: 'float' }, { name: 'y_max_temperature', type: 'float' }, { name: 'y_attenuation', type: 'float' }, - { name: 'y_amount_is_weight', type: 'int' }, { name: 'y_use', type: 'int' }, - { name: 'y_weight', type: 'float' } + { name: 'y_cells', type: 'float' }, + { name: 'y_inventory', type: 'float' }, + { name: 'y_avail', type: 'int' } ], addrow: function (rowid, rowdata, position, commit) { commit(true); @@ -2046,31 +2047,13 @@ commit(true); } }; - 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); - }, - }); + var yeastAdapter = new $.jqx.dataAdapter(yeastSource); $("#yeastGrid").jqxGrid({ - width: 1050, - height: 300, + width: 1240, + height: 525, source: yeastAdapter, theme: theme, selectionmode: 'singlerow', - editmode: 'selectedcell', - editable: true, localization: getLocalization(), showtoolbar: true, rendertoolbar: function (toolbar) { @@ -2080,11 +2063,12 @@ container.append('
'); container.append('
In voorraad:
'); container.append('
'); - container.append(''); + container.append(''); // add yeast from dropdownlist. $("#yaddrowbutton").jqxDropDownList({ placeHolder: "Kies gist:", theme: theme, + template: "primary", source: yeastlist, displayMember: "name", width: 150, @@ -2109,16 +2093,12 @@ row["y_amount"] = 0; row["y_cost"] = datarecord.cost; row["y_use"] = 0; - row["y_time"] = 0; - if (datarecord.form == 1) { - row["y_amount_is_weight"] = 1; - } else { - row["y_amount_is_weight"] = 0; - } row["y_min_temperature"] = datarecord.min_temperature; row["y_max_temperature"] = datarecord.max_temperature; row["y_attenuation"] = datarecord.attenuation; - row["y_weight"] = 0; + row["y_flocculation"] = datarecord.flocculation; + row["y_cells"] = datarecord.cells; + row["y_inventory"] = datarecord.inventory; var commit = $("#yeastGrid").jqxGrid('addrow', null, row); } }); @@ -2128,7 +2108,7 @@ yeastlist.dataBind(); }); // delete selected yeast. - $("#ydeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); + $("#ydeleterowbutton").jqxButton({ template: "danger", theme: theme, height: 27, width: 150 }); $("#ydeleterowbutton").on('click', function () { var selectedrowindex = $("#yeastGrid").jqxGrid('getselectedrowindex'); var rowscount = $("#yeastGrid").jqxGrid('getdatainformation').rowscount; @@ -2143,60 +2123,73 @@ $('#jqxTabs').jqxTabs('next'); }, columns: [ - { text: 'Gist', editable: false, datafield: 'y_name' }, - { text: 'Laboratorium', editable: false, width: 150, datafield: 'y_laboratory' }, - { text: 'Code', editable: false, width: 90, datafield: 'y_product_id' }, - { text: 'Soort', editable: false, width: 80, align: 'center', cellsalign: 'center', datafield: 'y_form' }, - { text: 'Min.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_min_temperature' }, - { text: 'Max.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_max_temperature' }, - { text: 'Attn.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_attenuation', cellsformat: 'f1' }, - { text: 'Voor', width: 100, align: 'center', cellsalign: 'center', datafield: 'y_use', columntype: 'dropdownlist', - createeditor: function (row, column, editor) { - var srcYUse = [ "Primary", "Secondary", "Bottle" ]; - editor.jqxDropDownList({ autoDropDownHeight: true, source: srcYUse }); + { text: 'Gist', datafield: 'y_name' }, + { text: 'Laboratorium', width: 150, datafield: 'y_laboratory' }, + { text: 'Code', width: 90, datafield: 'y_product_id' }, + { text: 'Soort', width: 100, datafield: 'y_form', + cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { + return "
" + YeastFormData[value].nl + "
"; + } + }, + { text: 'Min. °C', width: 70, align: 'right', cellsalign: 'right', datafield: 'y_min_temperature' }, + { text: 'Max. °C', width: 70, align: 'right', cellsalign: 'right', datafield: 'y_max_temperature' }, + { text: 'Attn. %', width: 70, align: 'right', cellsalign: 'right', datafield: 'y_attenuation', cellsformat: 'f1' }, + { text: 'Voor', width: 120, datafield: 'y_use', + cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { + return "
" + YeastUseData[value].nl + "
"; } }, - { datafield: 'y_amount', width: 90 }, - { text: 'Hoeveel', datafield: 'y_weight', width: 110, align: 'right', cellsalign: 'right', - cellsformat: 'f1', columntype: 'numberinput', + { text: 'Hoeveel', datafield: 'y_amount', width: 100, align: 'right', cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { - if (rowdata.y_form == 'Liquid') { + if (rowdata.y_form == 0) { // Liquid return "
"+dataAdapter.formatNumber(value, "f0")+" pk
"; - } else if (rowdata.y_form == 'Dry') { - return "
"+dataAdapter.formatNumber(value, "f1")+" gr
"; + } else if (rowdata.y_form == 1) { // Dry + return "
"+dataAdapter.formatNumber(value*1000, "f1")+" gr
"; } else { - return "
"+dataAdapter.formatNumber(value, "f0")+" ml
"; + return "
"+dataAdapter.formatNumber(value*1000, "f0")+" ml
"; + } + } + }, + { text: 'Voorraad', datafield: 'y_inventory', width: 100, align: 'right', + cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { + if (rowdata.y_form == 0) { // Liquid + return "
"+dataAdapter.formatNumber(value, "f0")+" pk
"; + } else if (rowdata.y_form == 1) { // Dry + return "
"+dataAdapter.formatNumber(value*1000, "f1")+" gr
"; + } else { + return "
"+dataAdapter.formatNumber(value*1000, "f0")+" ml
"; } - }, - initeditor: function (row, cellvalue, editor, celltext, pressedChar) { - var form = $("#yeastGrid").jqxGrid('getcellvalue', args.rowindex, 'y_form'); - if (form == 'Dry') { - editor.jqxNumberInput({ decimalDigits: 1, min: 0, spinButtons: false }); - } else { - editor.jqxNumberInput({ decimalDigits: 0, min: 0, spinButtons: false }); + } + }, + { text: 'Wijzig', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () { + return "Wijzig"; + }, buttonclick: function (row) { + yeastRow = row; + yeastData = $("#yeastGrid").jqxGrid('getrowdata', yeastRow); + if (yeastData.y_form == 0) { + $("#wy_pmpt_amount").html("Pak(ken):"); + $("#wy_amount").val(yeastData.y_amount); + $("#wy_amount").jqxNumberInput({ decimalDigits: 0, spinButtonsStep: 1 }); + } else if (yeastData.y_form == 1) { + $("#wy_pmpt_amount").html("Gewicht gram:"); + $("#wy_amount").val(yeastData.y_amount * 1000); + $("#wy_amount").jqxNumberInput({ decimalDigits: 1, spinButtonsStep: 0.5 }); + } else { + $("#wy_pmpt_amount").html("Volume ml:"); + $("#wy_amount").val(yeastData.y_amount * 1000); + $("#wy_amount").jqxNumberInput({ decimalDigits: 0, spinButtonsStep: 1 }); + } + $("#wy_name").val(yeastData.y_name); + $("#wy_laboratory").val(yeastData.y_laboratory); + $("#wy_product_id").val(yeastData.y_product_id); + $("#wy_use").val(yeastData.y_use); + // show the popup window. + $("#popupYeast").jqxWindow('open'); } - }, - validation: function (cell, value) { - if (value < 0 || value > 100000000000 ) { - return { result: false, message: "Hoeveelheid moet 0-~ zijn" }; - } - return true; - } - } + } ] }); - $("#yeastGrid").on('cellendedit', function (event) { - var args = event.args; - console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value); - $("#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)); - } - }); +// $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, 'y_amount', parseFloat(args.value * 0.0588)); }; // inline mash editor @@ -2879,6 +2872,99 @@ }); // Tab 5, Gist + $("#popupYeast").jqxWindow({ + width: 800, + height: 300, + position: { x: 230, y: 100 }, + resizable: false, + theme: theme, + isModal: true, + autoOpen: false, + cancelButton: $("#YeastReady"), + modalOpacity: 0.40 + }); + $("#YeastReady").jqxButton({ template: "success", width: '90px', theme: theme }); + $("#YeastReady").click(function () { + $("#yeastGrid").jqxGrid('sortby', 'y_use', 'asc'); + }); + $("#wy_name").jqxInput({ theme: theme, width: 320, height: 23 }); + $("#wy_laboratory").jqxInput({ theme: theme, width: 320, height: 23 }); + $("#wy_product_id").jqxInput({ theme: theme, width: 320, height: 23 }); + $("#wy_instock").jqxCheckBox({ theme: theme, height: 23 }); + $("#wy_instock").on('change', function (event) { + yeastinstock = event.args.checked; + yeastlist.dataBind(); + }); + $("#wy_select").jqxDropDownList({ + placeHolder: "Kies gist:", + theme: theme, + source: yeastlist, + displayMember: "name", + width: 150, + height: 23, + dropDownWidth: 500, + dropDownHeight: 500, + renderer: function (index, label, value) { + var datarecord = yeastlist.records[index]; + return datarecord.laboratory+" "+datarecord.product_id+" "+datarecord.name; + } + }); + $("#wy_select").on('select', function (event) { + if (event.args) { + var index = event.args.index; + var datarecord = yeastlist.records[index]; + var rowdata = $("#yeastGrid").jqxGrid('getrowdata', yeastRow); + $("#wy_name").val(datarecord.name); + $("#wy_laboratory").val(datarecord.laboratory); + $("#wy_product_id").val(datarecord.product_id); + rowdata.y_name = datarecord.name; + rowdata.y_cost = datarecord.cost; + rowdata.y_type = datarecord.type; + rowdata.y_form = datarecord.form; + rowdata.y_laboratory = datarecord.laboratory; + rowdata.y_product_id = datarecord.product_id; + rowdata.y_min_temperature = datarecord.min_temperature; + rowdata.y_max_temperature = datarecord.max_temperature; + rowdata.y_flocculation = datarecord.flocculation; + rowdata.y_attenuation = datarecord.attenuation; + rowdata.y_cells = datarecord.cells; + rowdata.y_inventory = datarecord.inventory; + if (rowdata.y_form == 0) { + $("#wy_pmpt_amount").html("Pak(ken):"); + } else if (rowdata.y_form == 1) { + $("#wy_pmpt_amount").html("Gewicht gram:"); + } else { + $("#wy_pmpt_amount").html("Volume ml:"); + } + } + }); + $("#wy_amount").jqxNumberInput( Spin1dec5 ); + $('#wy_amount').on('change', function (event) { + console.log("amount changed: "+event.args.value); + var rowdata = $("#yeastGrid").jqxGrid('getrowdata', yeastRow); + if (rowdata.y_form == 0) // Liquid + var amount = parseFloat(event.args.value); + else + var amount = parseFloat(event.args.value) / 1000; + rowdata.y_amount = amount; + }); + $("#wy_use").jqxDropDownList({ + theme: theme, + source: YeastUseAdapter, + valueMember: 'id', + displayMember: 'nl', + width: 180, + height: 23, + autoDropDownHeight: true, + dropDownVerticalAlignment: 'top' + }); + $("#wy_use").on('select', function (event) { + if (event.args) { + var index = event.args.index; + var rowdata = $("#yeastGrid").jqxGrid('getrowdata', yeastRow); + rowdata.y_use = index; + } + }); // Tab 6, Maischen $("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 }); diff -r ad2e1e3ccaca -r 40e68b18b50d www/rec_edit.php --- a/www/rec_edit.php Thu Jan 31 17:16:51 2019 +0100 +++ b/www/rec_edit.php Thu Jan 31 22:39:36 2019 +0100 @@ -160,10 +160,8 @@
- - - - + +
Gisten:
Graat
 
@@ -451,6 +449,47 @@ +
+
Wijzig gist detail.
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Gist naam:
Product code:
Leverancier:
Andere gist:
+
+
In voorraad:
+
+
Hoeveelheid:
Gebruik voor:
+ +
+
+
+