# HG changeset patch # User Michiel Broek # Date 1557406390 -7200 # Node ID 9d2a4703bdac0225ac206897e5f5e0b8500df7c2 # Parent 58c350f286e57ae4cda33198282b391aa0659eda Version 0.1.2 Calculate mash thickness. diff -r 58c350f286e5 -r 9d2a4703bdac config.status --- a/config.status Wed May 08 22:23:52 2019 +0200 +++ b/config.status Thu May 09 14:53:10 2019 +0200 @@ -621,7 +621,7 @@ S["CC"]="gcc" S["CYEARS"]="2016-2019" S["COPYRIGHT"]="Copyright (C) 2016-2019 Michiel Broek, All Rights Reserved" -S["VERSION"]="0.1.1" +S["VERSION"]="0.1.2" S["PACKAGE"]="bms" S["SUBDIRS"]="bmsd doc script tools www" S["target_alias"]="" @@ -710,7 +710,7 @@ D["PACKAGE_STRING"]=" \"\"" D["PACKAGE_BUGREPORT"]=" \"\"" D["PACKAGE_URL"]=" \"\"" -D["VERSION"]=" \"0.1.1\"" +D["VERSION"]=" \"0.1.2\"" D["COPYRIGHT"]=" \"Copyright (C) 2016-2019 Michiel Broek, All Rights Reserved\"" D["STDC_HEADERS"]=" 1" D["HAVE_SYS_TYPES_H"]=" 1" diff -r 58c350f286e5 -r 9d2a4703bdac configure --- a/configure Wed May 08 22:23:52 2019 +0200 +++ b/configure Thu May 09 14:53:10 2019 +0200 @@ -2043,7 +2043,7 @@ PACKAGE="bms" -VERSION="0.1.1" +VERSION="0.1.2" COPYRIGHT="Copyright (C) 2016-2019 Michiel Broek, All Rights Reserved" CYEARS="2016-2019" diff -r 58c350f286e5 -r 9d2a4703bdac configure.ac --- a/configure.ac Wed May 08 22:23:52 2019 +0200 +++ b/configure.ac Thu May 09 14:53:10 2019 +0200 @@ -8,7 +8,7 @@ dnl General settings dnl After changeing the version number, run autoconf! PACKAGE="bms" -VERSION="0.1.1" +VERSION="0.1.2" COPYRIGHT="Copyright (C) 2016-2019 Michiel Broek, All Rights Reserved" CYEARS="2016-2019" AC_SUBST(PACKAGE) diff -r 58c350f286e5 -r 9d2a4703bdac www/includes/db_recipes.php --- a/www/includes/db_recipes.php Wed May 08 22:23:52 2019 +0200 +++ b/www/includes/db_recipes.php Thu May 09 14:53:10 2019 +0200 @@ -244,10 +244,10 @@ $mash .= ',"step_infuse_amount":0'; $mash .= ',"step_temp":' . $item['step_temp']; $mash .= ',"step_time":' . $item['step_time']; - $mash .= ',"step_thickness":' . $item['step_thickness']; $mash .= ',"ramp_time":' . $item['ramp_time']; $mash .= ',"end_temp":' . $item['end_temp'] . '}'; $mashs .= $mash; + syslog(LOG_NOTICE, $mash); } } $mashs .= ']'; @@ -297,7 +297,6 @@ $recipes = '['; $comma = FALSE; while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { - $mashkg = 0; // Manual encode to JSON. if ($comma) { $recipes .= ','; @@ -376,9 +375,6 @@ // Append stock information. $fermentables = json_decode($row['json_fermentables'], true); for ($i = 0; $i < count($fermentables); $i++) { - if ($fermentables[$i]['f_added'] == 0) { - $mashkg += $fermentables[$i]['f_amount']; - } $fermentables[$i]['f_inventory'] = 0; // Not in stock $fermentables[$i]['f_avail'] = 0; // Ingredient not in db $sql2 = "SELECT inventory FROM inventory_fermentables "; @@ -457,20 +453,7 @@ $recipes .= ',"miscs":' . $row['json_miscs']; $recipes .= ',"yeasts":' . $row['json_yeasts']; } - if (isset($_GET['record'])) { - $volume = 0; - $mashs = json_decode($row['json_mashs'], true); - for ($i = 0; $i < count($mashs); $i++) { - $volume += $mashs[$i]['step_infuse_amount']; - if ($mashkg > 0) - $mashs[$i]['step_thickness'] = floatval(sprintf("%.3f", $volume / $mashkg)); - else - $mashs[$i]['step_thickness'] = 0; - } - $recipes .= ',"mashs":' . json_encode($mashs, JSON_UNESCAPED_UNICODE); - } else { - $recipes .= ',"mashs":' . $row['json_mashs']; - } + $recipes .= ',"mashs":' . $row['json_mashs']; $recipes .= '}'; } $recipes .= ']'; diff -r 58c350f286e5 -r 9d2a4703bdac www/js/prod_edit.js --- a/www/js/prod_edit.js Wed May 08 22:23:52 2019 +0200 +++ b/www/js/prod_edit.js Thu May 09 14:53:10 2019 +0200 @@ -304,6 +304,22 @@ $("#need_cells").val(getNeededYeastCells()); }; + function calcMash() { + + if (!(rows = $('#mashGrid').jqxGrid('getrows'))) + return; + if (mashkg == 0) + return; + + var infused = 0; + for (var i = 0; i < rows.length; i++) { + var row = $("#mashGrid").jqxGrid('getrowdata', i); + if (row.step_type == 0) // Infusion + infused += row.step_infuse_amount; + $("#mashGrid").jqxGrid('setcellvalue', i, "step_thickness", infused / mashkg); + } + } + /* * Change OG of recipe but keep the water volumes. */ @@ -2155,6 +2171,7 @@ calcIBUs(); calcWater(); calcSparge(); + calcMash(); }); $('#boil_time').on('change', function (event) { console.log("boil_time change:"+parseFloat(event.args.value)+" old:"+dataRecord.boil_time); @@ -2186,6 +2203,7 @@ calcFermentablesFromOG(dataRecord.est_og); // Adjust fermentables amounts calcFermentables(); // Update the recipe details calcIBUs(); // and the IBU's. + calcMash(); calcYeast(); }); $('#mash_ph').on('change', function (event) { @@ -3890,6 +3908,7 @@ { name: 'step_infuse_amount', type: 'float' }, { name: 'step_temp', type: 'float' }, { name: 'step_time', type: 'float' }, + { name: 'step_thickness', type: 'float' }, { name: 'ramp_time', type: 'float' }, { name: 'end_temp', type: 'float' } ], @@ -3908,6 +3927,8 @@ var row = records[i]; if (row.step_type == 0) // Infusion mash_infuse += parseFloat(row.step_infuse_amount); + row.step_thickness = 0; // Init this field. + data.push(row); } }, }); @@ -3937,6 +3958,7 @@ } row["step_temp"] = 62.0; row['step_time'] = 20.0; + row['step_thickness'] = 0; row['ramp_time'] = 1.0; row['end_temp'] = 62.0; var commit = $("#mashGrid").jqxGrid('addrow', null, row); @@ -3954,6 +3976,7 @@ }, ready: function() { calcInit(); + calcMash(); $('#jqxLoader').jqxLoader('close'); $('#jqxTabs').jqxTabs('first'); }, @@ -3969,6 +3992,7 @@ { text: 'Rust min.', datafield: 'step_time', width: 90, align: 'right', cellsalign: 'right' }, { text: 'Stap min.', datafield: 'ramp_time', width: 90, align: 'right', cellsalign: 'right' }, { text: 'Infuse L.', datafield: 'step_infuse_amount', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, + { text: 'L/Kg.', datafield: 'step_thickness', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f2' }, { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () { return "Wijzig"; }, buttonclick: function (row) { @@ -4235,6 +4259,7 @@ // Recalc percentages calcFermentables(); calcIBUs(); + calcMash(); // Waters: yes there is impact. }); $("#wf_name").jqxInput({ theme: theme, width: 320, height: 23 }); @@ -4310,6 +4335,7 @@ } calcFermentables(); calcIBUs(); + calcMash(); }; }); $("#wf_percentage").jqxNumberInput( Perc1dec ); @@ -4347,6 +4373,7 @@ } calcFermentables(); calcIBUs(); + calcMash(); } else { // Adjust all the rows. var nw = tw * diff / 100; @@ -4366,6 +4393,7 @@ } calcFermentables(); calcIBUs(); + calcMash(); } } } @@ -4409,6 +4437,7 @@ $("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_added', index); calcFermentables(); calcIBUs(); + calcMash(); } }); @@ -4860,6 +4889,10 @@ row["step_infuse_amount"] = mash_infuse; else row["step_infuse_amount"] = 0; + if (mashkg > 0) + row['step_thickness'] = parseFloat(mash_infuse / mashkg); + else + row['step_thickness'] = 0; row["step_temp"] = data.step_temp; row["end_temp"] = data.end_temp; row["step_time"] = data.step_time; @@ -4882,6 +4915,7 @@ $("#MashReady").jqxButton({ template: "success", width: '90px', theme: theme }); $("#MashReady").click(function () { $("#mashGrid").jqxGrid('sortby', 'step_temp', 'asc'); + calcMash(); }); $("#wstep_name").jqxInput({ theme: theme, width: 320, height: 23 }); $("#wstep_name").on('change', function (event) { diff -r 58c350f286e5 -r 9d2a4703bdac www/js/rec_edit.js --- a/www/js/rec_edit.js Wed May 08 22:23:52 2019 +0200 +++ b/www/js/rec_edit.js Thu May 09 14:53:10 2019 +0200 @@ -311,6 +311,22 @@ return (result * amount * 1000) / vol; } + function calcMash() { + + if (!(rows = $('#mashGrid').jqxGrid('getrows'))) + return; + if (mashkg == 0) + return; + + var infused = 0; + for (var i = 0; i < rows.length; i++) { + var row = $("#mashGrid").jqxGrid('getrowdata', i); + if (row.step_type == 0) // Infusion + infused += row.step_infuse_amount; + $("#mashGrid").jqxGrid('setcellvalue', i, "step_thickness", infused / mashkg); + } + } + function calcIBUs() { var total_ibus = 0; hop_aroma = hop_flavour = 0; @@ -1304,6 +1320,7 @@ calcIBUs(); calcWater(); calcSparge(); + calcMash(); }); $('#boil_time').on('change', function (event) { console.log("boil_time change:"+parseFloat(event.args.value)+" old:"+dataRecord.boil_time); @@ -1332,6 +1349,7 @@ calcFermentablesFromOG(dataRecord.est_og); // Adjust fermentables amounts calcFermentables(); // Update the recipe details calcIBUs(); // and the IBU's. + calcMash(); }); $('#mash_ph').on('change', function (event) { dataRecord.mash_ph = parseFloat(event.args.value); @@ -2563,6 +2581,8 @@ var row = records[i]; if (row.step_type == 0) // Infusion mash_infuse += parseFloat(row.step_infuse_amount); + row.step_thickness = 0; // Init this field. + data.push(row); } }, }); @@ -2598,6 +2618,7 @@ ready: function() { calcFermentables(); calcInit(); + calcMash(); $('#jqxLoader').jqxLoader('close'); $('#jqxTabs').jqxTabs('first'); }, @@ -2799,6 +2820,7 @@ // Recalc percentages calcFermentables(); calcIBUs(); + calcMash(); // Waters: yes there is impact. }); $("#wf_name").jqxInput({ theme: theme, width: 320, height: 23 }); @@ -2873,6 +2895,7 @@ $("#fermentableGrid").jqxGrid('setcellvalue', 0, "f_percentage", 100); } calcFermentables(); + calcMash(); }; }); $("#wf_percentage").jqxNumberInput( Perc1dec ); @@ -2909,6 +2932,7 @@ } } calcFermentables(); + cacMash(); } else { // Adjust all the rows. var nw = tw * diff / 100; @@ -2927,6 +2951,7 @@ } } calcFermentables(); + calcMash(); } } } @@ -2971,6 +2996,7 @@ $("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_added', index); calcFermentables(); calcIBUs(); + calcMash(); } }); @@ -3410,18 +3436,7 @@ $("#MashReady").jqxButton({ template: "success", width: '90px', theme: theme }); $("#MashReady").click(function () { $("#mashGrid").jqxGrid('sortby', 'step_temp', 'asc'); - mash_infuse = 0; - var rows = $('#mashGrid').jqxGrid('getrows'); - for (var i = 0; i < rows.length; i++) { - var row = rows[i]; - if (row.step_type == 0) // Infusion - mash_infuse += parseFloat(row.step_infuse_amount); - var rowdata = $("#mashGrid").jqxGrid('getrowdata', i); - if (mashkg > 0) - rowdata.step_thickness = parseFloat(mash_infuse / mashkg); - else - rowdata.step_thickness = 0; - } + calcMash(); }); $("#wstep_name").jqxInput({ theme: theme, width: 320, height: 23 }); $("#wstep_name").on('change', function (event) {