# HG changeset patch # User Michiel Broek # Date 1544017395 -3600 # Node ID 875aeb365e1ca365a1a0d1dd72379c0d0eaf5f29 # Parent b28a3d6143bca97b857351ec9832ead58a82e479 Added sparge pH during import. Added several calculations. Added calculated estimates to the brewday screen. diff -r b28a3d6143bc -r 875aeb365e1c www/import/from_brouwhulp.php --- a/www/import/from_brouwhulp.php Wed Dec 05 14:16:39 2018 +0100 +++ b/www/import/from_brouwhulp.php Wed Dec 05 14:43:15 2018 +0100 @@ -1210,6 +1210,8 @@ $psql .= "', brew_mash_sg='" . floatval($recipe->SG_END_MASH); if ($recipe->MASH->SPARGE_TEMP) $psql .= "', brew_sparge_temperature='" . floatval($recipe->MASH->SPARGE_TEMP); + if ($recipe->MASH->PH) + $psql .= "', brew_sparge_ph='" . floatval($recipe->MASH->PH); if ($recipe->VOLUME_HLT) $psql .= "', brew_sparge_volume='" . floatval($recipe->VOLUME_HLT); if ($recipe->VOLUME_BEFORE_BOIL) diff -r b28a3d6143bc -r 875aeb365e1c www/includes/db_product.php --- a/www/includes/db_product.php Wed Dec 05 14:16:39 2018 +0100 +++ b/www/includes/db_product.php Wed Dec 05 14:43:15 2018 +0100 @@ -179,6 +179,7 @@ $brew .= ',"brew_mash_sg":' . floatval($row['brew_mash_sg']); $brew .= ',"brew_sparge_temperature":' . floatval($row['brew_sparge_temperature']); $brew .= ',"brew_sparge_volume":' . floatval($row['brew_sparge_volume']); + $brew .= ',"brew_sparge_ph":' . floatval($row['brew_sparge_ph']); $brew .= ',"brew_preboil_volume":' . floatval($row['brew_preboil_volume']); $brew .= ',"brew_preboil_sg":' . floatval($row['brew_preboil_sg']); $brew .= ',"brew_preboil_ph":' . floatval($row['brew_preboil_ph']); diff -r b28a3d6143bc -r 875aeb365e1c www/js/global.js --- a/www/js/global.js Wed Dec 05 14:16:39 2018 +0100 +++ b/www/js/global.js Wed Dec 05 14:43:15 2018 +0100 @@ -21,6 +21,9 @@ *****************************************************************************/ +var sugardensity = 1.611; //kg/l in solution + + function getLocalization() { var localizationobj = {}; localizationobj.pagerGoToPageString = "Gehe zu:"; @@ -215,7 +218,7 @@ plato = 100 * sugars / (batch_size * sg); sg = plato_to_sg(plato); } - console.log("estimate_sg(" + sugars + "," + batch_size + ") : " + sg); +// console.log("estimate_sg(" + sugars + "," + batch_size + ") : " + sg); return sg; } diff -r b28a3d6143bc -r 875aeb365e1c www/js/prod_edit.js --- a/www/js/prod_edit.js Wed Dec 05 14:16:39 2018 +0100 +++ b/www/js/prod_edit.js Wed Dec 05 14:43:15 2018 +0100 @@ -47,10 +47,103 @@ $(document).ready(function () { var brewstage = 0; // Numeric value of stage - var this_uuid = ''; + var preboil_sg = 0; + var est_mash_sg = 0; + var sugarsm = 0; // Sugars after mash + var sugarsf = 0; // Sugars after boil + var psugar = 0; // Percentage real sugars + var pcara = 0; // Percentage cara/crystal malts + var old_efficiency; + var old_batch_size; + var old_boil_time; console.log("record:" + my_record + " return:" + my_return + " theme:" + theme); + function calcFermentables() { + console.log("calcFermentables()"); + sugarsf = 0; + sugarsm = 0; + psugar = 0; + pcara = 0; + var colorw = 0; // Colors working + + for (var i = 0; i < dataRecord.fermentables.length; i++) { + var row = dataRecord.fermentables[i]; + if (row.f_type == "Sugar") + psugar += row.f_percentage; + if (row.f_type == "Crystal") + pcara += row.f_percentage; + var d = row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); + if (row.f_added == "Mash") { + d = parseFloat(dataRecord.efficiency) / 100 * d; + sugarsm += d; + } + sugarsf += d; + colorw += row.f_amount * ebc_to_srm(row.f_color) / parseFloat(dataRecord.batch_size) * 8.34436; + } + console.log("sugarsm: " + sugarsm + " sugarsf: " + sugarsf + " batch: " + dataRecord.batch_size); + console.log("est_og: " + estimate_sg(sugarsf, parseFloat(dataRecord.batch_size))); + preboil_sg = estimate_sg(sugarsm, parseFloat(dataRecord.boil_size)); + console.log("preboil_sg: " + preboil_sg); + console.log("est_color: " + kw_to_ebc(dataRecord.color_method, colorw)); + $("#est_og").val(estimate_sg(sugarsf, parseFloat(dataRecord.batch_size))); + $('#est_color').val(kw_to_ebc(dataRecord.color_method, colorw)); + }; + + function calcIBUs() { + var total_ibus = 0; + for (var i = 0; i < dataRecord.hops.length; i++) { + var row = dataRecord.hops[i]; + total_ibus += toIBU(row.h_useat, row.h_form, preboil_sg, parseFloat(dataRecord.batch_size), + parseFloat(row.h_amount), parseFloat(row.h_time), parseFloat(row.h_alpha), dataRecord.ibu_method); + } + console.log("calcIBUs(): " + total_ibus); + $('#est_ibu').val(total_ibus); + }; + + function calcSGendMash() { + est_mash_sg = 0; + var mvol = 0; // Mash volume + var s = 0; + var gs = 0; // Grain absorbtion + for (var i = 0; i < dataRecord.mashs.length; i++) { + var row = dataRecord.mashs[i]; +// console.log("step " + i + " " + row.step_name + " " + row.step_type); + if (row.step_type == 'Infusion') + mvol += parseFloat(row.step_infuse_amount); + } + if (mvol > 0) { +// console.log("mash volume: " + mvol); + for (var i = 0; i < dataRecord.fermentables.length; i++) { + var row = dataRecord.fermentables[i]; + + if (row.f_added == "Mash") { + var d = row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); + mvol += row.f_amount * row.f_moisture / 100; + gs += my_grain_absorbtion * row.f_amount; + s += d; + } + } +// console.log("mash volume: " + mvol + " gs: " + gs + " s: " + s); + var v = s / sugardensity + mvol; + s = 1000 * s / (v * 10); //deg. Plato + est_mash_sg = plato_to_sg(s); + } + console.log("calcSGendMash(): " + est_mash_sg); + $('#est_mash_sg').val(est_mash_sg); + }; + + function calcMashEfficiency() { +// console.log("calcMashEfficiency()"); + var c = sg_to_plato(est_mash_sg); + var m = sg_to_plato(parseFloat($("#brew_mash_sg").jqxNumberInput('decimal'))); +// console.log("c "+ c + " m " + m + " in " + parseFloat($("#brew_mash_sg").jqxNumberInput('decimal'))); + if (c > 0.5) + $("#brew_mash_efficiency").val(100 * m / c); + else + $("#brew_mash_efficiency").val(0); + }; + // Equipemnt dropdown list var equipmentUrl = "includes/db_inventory_equipments.php"; var equipmentSource = { @@ -127,7 +220,7 @@ } }); - var dataReecord = {}; + var dataRecord = {}; var url = "includes/db_product.php"; // tooltips $("#pname").jqxTooltip({ content: 'De naam voor dit product.' }); @@ -201,6 +294,7 @@ { name: 'brew_mash_sg', type: 'float' }, { name: 'brew_sparge_temperature', type: 'float' }, { name: 'brew_sparge_volume', type: 'float' }, + { name: 'brew_sparge_ph', type: 'float' }, { name: 'brew_preboil_volume', type: 'float' }, { name: 'brew_preboil_sg', type: 'float' }, { name: 'brew_preboil_ph', type: 'float' }, @@ -311,7 +405,6 @@ var records = dataAdapter.records; dataRecord = records[0]; // Hidden record uuid - this_uuid = dataRecord.puuid; $("#pname").val(dataRecord.pname); $("#code").val(dataRecord.code); $("#birth").val(dataRecord.birth); @@ -346,14 +439,13 @@ $("#eq_efficiency").val(dataRecord.eq_efficiency); // Brewdate $("#brew_date_start").val(dataRecord.brew_date_start); - $("#brew_mash_ph").val(dataRecord.brew_mash_ph); $("#brew_mash_sg").val(dataRecord.brew_mash_sg); // brew_mash_efficiency to calculate on th fly. // Header Spoelen en filteren $("#brew_sparge_temperature").val(dataRecord.brew_sparge_temperature); $("#brew_sparge_volume").val(dataRecord.brew_sparge_volume); - //$("#brew_sparge_ph").val(dataRecord.brew_sparge_ph); + $("#brew_sparge_ph").val(dataRecord.brew_sparge_ph); // Header Beluchten $("#brew_aeration_type").val(dataRecord.brew_aeration_type); $("#brew_aeration_time").val(dataRecord.brew_aeration_time); @@ -386,8 +478,34 @@ $("#brew_fermenter_extrawater").val(dataRecord.brew_fermenter_extrawater); $("#brew_fermenter_extrasugar").val(dataRecord.brew_fermenter_extrasugar); $("#brew_fermenter_color").val(dataRecord.brew_fermenter_color); + $("#brew_date_end").val(dataRecord.brew_date_end); - $("#brew_date_end").val(dataRecord.brew_date_end); + // Recipe + // locked + // st_ style settings. + // name + // notes + // type + old_batch_size = dataRecord.batch_size; + // boil_size + old_boil_time = dataRecord.boil_time; + old_efficiency = dataRecord.efficiency; + // est_og + // est_fg + // est_abv + // est_color + // color_method + // est_ibu + // ibu_method + // mash_sparge_temp + // mash_ph + // mash_name + // fermentables + // hops + // miscs + // yeasts + // waters + // mashs switch (dataRecord.stage) { case 'Plan': brewstage = 0; break; @@ -427,6 +545,11 @@ $("#inventory_reduced").jqxCheckBox({ disabled : true }); else if ($('#inventory_reduced').jqxCheckBox('checked')) $("#inventory_reduced").jqxCheckBox({ disabled : true }); + + calcFermentables(); + calcIBUs(); + calcSGendMash(); + calcMashEfficiency(); }, loadError: function (jqXHR, status, error) { } @@ -491,11 +614,12 @@ // Brewday $("#brew_date_start").jqxDateTimeInput({ theme: theme, width: 230, height: 23, formatString: 'yyyy-MM-dd HH:mm:ss', showTimeButton: true }); $("#brew_mash_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); - $("#brew_mash_sg").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 }); + $("#brew_mash_sg").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 1.000, max: 1.200, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 }); + $("#brew_mash_sg").on('valueChanged', function () { calcMashEfficiency(); }); $("#brew_mash_efficiency").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); $("#brew_sparge_temperature").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); $("#brew_sparge_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); - $("#brew_sparge_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); + $("#brew_sparge_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 14, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); $("#brew_preboil_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); $("#brew_preboil_sg").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 }); $("#brew_preboil_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); @@ -525,6 +649,12 @@ // Packaging // Tasting + // Recipe + $("#est_og").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 3 }); + $("#est_ibu").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 0 }); + $("#est_color").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 0 }); + $("#est_mash_sg").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 3 }); + $('#jqxTabs').jqxTabs({ theme: theme, width: 1280, @@ -544,7 +674,7 @@ // Open a popup to confirm this action. $('#eventWindow').jqxWindow('open'); $("#delOk").click(function () { - var data = "delete=true&" + $.param({ uuid: this_uuid }); + var data = "delete=true&" + $.param({ uuid: dataRecord.puuid }); $.ajax({ dataType: 'json', url: url, @@ -568,9 +698,11 @@ $("#Save").jqxButton({ template: "success", width: '90px', theme: theme }); $("#Save").click(function () { + console.log(dataRecord.puuid); + var row = { record: my_record, - puuid: this_uuid, + puuid: dataRecord.puuid, pname: $("#pname").val(), code: $("#code").val(), birth: $("#birth").val(), diff -r b28a3d6143bc -r 875aeb365e1c www/prod_edit.php --- a/www/prod_edit.php Wed Dec 05 14:16:39 2018 +0100 +++ b/www/prod_edit.php Wed Dec 05 14:43:15 2018 +0100 @@ -154,7 +154,7 @@ -
+
@@ -179,11 +179,11 @@ - + - + @@ -266,9 +266,9 @@ - + - +
Brouwdag start:
Maisch SG:
SG voor koken:
SG na koken:
Maisch rendement:
IBU in gistvat:
Kleur in gistvat: