# HG changeset patch # User Michiel Broek # Date 1544285498 -3600 # Node ID 71f1ca48c5511d6589220a70f112eb16bf7842c6 # Parent 601920b902e5925fb54efa6db68ef3b7c47d2078 When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time. diff -r 601920b902e5 -r 71f1ca48c551 www/import/from_brouwhulp.php --- a/www/import/from_brouwhulp.php Sat Dec 08 15:20:03 2018 +0100 +++ b/www/import/from_brouwhulp.php Sat Dec 08 17:11:38 2018 +0100 @@ -685,9 +685,13 @@ $comma = TRUE; $yeasts .= '{"y_name":"' . mysqli_real_escape_string($db, $yeast->NAME) . '"'; $yeasts .= ',"y_amount":' . floatval($yeast->AMOUNT); - if ($yeast->COST) - $yeasts .= ',"y_cost":' . floatval($yeast->COST); - else + 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'; $yeasts .= ',"y_laboratory":"' . mysqli_real_escape_string($db, $yeast->LABORATORY) . '"'; $yeasts .= ',"y_product_id":"' . mysqli_real_escape_string($db, $yeast->PRODUCT_ID) . '"'; diff -r 601920b902e5 -r 71f1ca48c551 www/js/rec_edit.js --- a/www/js/rec_edit.js Sat Dec 08 15:20:03 2018 +0100 +++ b/www/js/rec_edit.js Sat Dec 08 17:11:38 2018 +0100 @@ -785,11 +785,11 @@ { text: 'Hop', editable: false, datafield: 'h_name' }, { text: 'Type', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_type' }, { text: 'Vorm', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_form' }, - { text: 'Alpha', datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, - { text: 'Gewicht', datafield: 'h_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f3', + { text: 'Alpha', editable: false, datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, + { text: 'Gewicht Kg', datafield: 'h_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f4', columntype: 'numberinput', initeditor: function (row, cellvalue, editor, celltext, pressedChar) { - editor.jqxNumberInput({ decimalDigits: 3, min: 0, spinButtons: false }); + editor.jqxNumberInput({ decimalDigits: 4, min: 0, spinButtons: false }); }, validation: function (cell, value) { if (value < 0 || value > 100000000000 ) { @@ -802,15 +802,25 @@ createeditor: function (row, column, editor) { var srcUse = [ "Boil", "Dry Hop", "Mash", "First Wort", "Aroma" ]; editor.jqxDropDownList({ autoDropDownHeight: true, source: srcUse }); + }, + cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { + if ((newvalue == "Mash") || (newvalue == "First Wort")) { + $("#hopGrid").jqxGrid('setcellvalue', row, "h_time", parseFloat($("#boil_time").jqxNumberInput('decimal'))); + } else if (newvalue == "Aroma") { + $("#hopGrid").jqxGrid('setcellvalue', row, "h_time", 0); + } } - // cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { - // do iets met de h_time. }, { text: 'Tijd', datafield: 'h_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0', columntype: 'numberinput', initeditor: function (row, cellvalue, editor, celltext, pressedChar) { editor.jqxNumberInput({ decimalDigits: 0, digits: 3, min: 0 }); }, + cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { + var use = $("#hopGrid").jqxGrid('getcellvalue', row, "h_useat"); + if (use != "Boil") + return oldvalue; + }, validation: function (cell, value) { var high = parseFloat($("#boil_time").jqxNumberInput('decimal')); if (value < 0 || value > high ) { @@ -837,9 +847,12 @@ } ] }); -// $("#hopGrid").on('cellendedit', function (event) { + $("#hopGrid").on('cellendedit', function (event) { + var args = event.args; + console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value); + $("#hopGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value); // //$('#hopGrid').jqxGrid('sortby', 'f_amount', 'desc'); -// }); + }); }; // Inline miscs editor