# HG changeset patch # User Michiel Broek # Date 1558879790 -7200 # Node ID 7f5455806f2039e6c168a31f61eeeb14e6b4b795 # Parent f56c269dddfbd32ec4916770d501073b3b0ae7df Reset starter values when saving a product without a starter. The yeast calculator only calculates a starter when enabled. Calculate the cells/ml/plato field. Disable starter buttons when the product brewday is over. diff -r f56c269dddfb -r 7f5455806f20 www/includes/db_product.php --- a/www/includes/db_product.php Wed May 15 21:28:07 2019 +0200 +++ b/www/includes/db_product.php Sun May 26 16:09:50 2019 +0200 @@ -223,17 +223,23 @@ $sql .= "', wa_acid_name='" . $_POST['wa_acid_name']; $sql .= "', wa_acid_perc='" . $_POST['wa_acid_perc']; $sql .= "', wa_base_name='" . $_POST['wa_base_name']; - $sql .= "', starter_enable='" . $_POST['starter_enable']; - $sql .= "', starter_type='" . $_POST['starter_type']; - $sql .= "', starter_sg='" . $_POST['starter_sg']; - $sql .= "', prop1_type='" . $_POST['prop1_type']; - $sql .= "', prop1_volume='" . $_POST['prop1_volume']; - $sql .= "', prop2_type='" . $_POST['prop2_type']; - $sql .= "', prop2_volume='" . $_POST['prop2_volume']; - $sql .= "', prop3_type='" . $_POST['prop3_type']; - $sql .= "', prop3_volume='" . $_POST['prop3_volume']; - $sql .= "', prop4_type='" . $_POST['prop4_type']; - $sql .= "', prop4_volume='" . $_POST['prop4_volume']; + if ($_POST['starter_enable'] == 0) { + $sql .= "', starter_enable='0', starter_type='0', starter_sg='1.040"; + $sql .= "', prop1_type='0', prop1_volume='0', prop2_type='0', prop2_volume='0"; + $sql .= "', prop3_type='0', prop3_volume='0', prop4_type='0', prop4_volume='0"; + } else { + $sql .= "', starter_enable='1"; + $sql .= "', starter_type='" . $_POST['starter_type']; + $sql .= "', starter_sg='" . $_POST['starter_sg']; + $sql .= "', prop1_type='" . $_POST['prop1_type']; + $sql .= "', prop1_volume='" . $_POST['prop1_volume']; + $sql .= "', prop2_type='" . $_POST['prop2_type']; + $sql .= "', prop2_volume='" . $_POST['prop2_volume']; + $sql .= "', prop3_type='" . $_POST['prop3_type']; + $sql .= "', prop3_volume='" . $_POST['prop3_volume']; + $sql .= "', prop4_type='" . $_POST['prop4_type']; + $sql .= "', prop4_volume='" . $_POST['prop4_volume']; + } syslog(LOG_NOTICE, $sql); $fermentables = '['; diff -r f56c269dddfb -r 7f5455806f20 www/js/prod_edit.js --- a/www/js/prod_edit.js Wed May 15 21:28:07 2019 +0200 +++ b/www/js/prod_edit.js Sun May 26 16:09:50 2019 +0200 @@ -754,6 +754,22 @@ function calcYeast() { + // Calculate needed cells. + var sg = dataRecord.brew_fermenter_sg; + if (sg <= 1.0001 && dataRecord.fg > 1.000) + sg = dataRecord.fg; + else if (sg <= 1.0001) + sg = dataRecord.est_og; + var plato = sg_to_plato(sg); + + var volume = dataRecord.brew_fermenter_volume; + if (volume > 0) { + if (dataRecord.brew_fermenter_extrawater > 0) + volume += dataRecord.brew_fermenter_extrawater; + } else { + volume = dataRecord.batch_size - dataRecord.eq_trub_chiller_loss; + } + // Also in calcFermentables() $("#yeast_cells").val(initcells); @@ -780,77 +796,90 @@ } } } - var needed = getNeededYeastCells(); - console.log("calcYeast() pitchrate:"+pitchrate+" start:"+initcells+" needed:"+needed); - calcSteps(dataRecord.starter_type, initcells, needed); + var needed = pitchrate * volume * plato; + console.log("calcYeast() pitchrate:"+pitchrate+" start:"+initcells+" needed:"+needed+" volume:"+volume); $("#need_cells").val(needed); - - $("#r1_irate").html(""); - $("#r1_growf").html(""); - $("#r1_tcells").html(""); - if (parseFloat($("#prop1_volume").val()) > 0) { - if ((parseFloat($("#prop1_irate").val()) < 25) || (parseFloat($("#prop1_irate").val()) > 100)) { - $("#r1_irate").html(""); - } else { - $("#r1_irate").html(""); - } - if (parseFloat($("#prop1_growf").val()) < 1) - $("#r1_growf").html(""); - if (($("#prop1_type").val() > 0) && (parseFloat($("#prop1_growf").val()) > 3)) - $("#r1_growf").html(""); - if (parseFloat($("#prop1_tcells").val()) > needed) - $("#r1_tcells").html(""); - } - $("#r2_irate").html(""); - $("#r2_growf").html(""); - $("#r2_tcells").html(""); - if (parseFloat($("#prop2_volume").val()) > 0) { - if ((parseFloat($("#prop2_irate").val()) < 25) || (parseFloat($("#prop2_irate").val()) > 100)) { - $("#r2_irate").html(""); - } else { - $("#r2_irate").html(""); + var use_cells = initcells; + + if (dataRecord.starter_enable) { + calcSteps(dataRecord.starter_type, initcells, needed); + + $("#r1_irate").html(""); + $("#r1_growf").html(""); + $("#r1_tcells").html(""); + if (parseFloat($("#prop1_volume").val()) > 0) { + if ((parseFloat($("#prop1_irate").val()) < 25) || (parseFloat($("#prop1_irate").val()) > 100)) { + $("#r1_irate").html(""); + } else { + $("#r1_irate").html(""); + } + if (parseFloat($("#prop1_growf").val()) < 1) + $("#r1_growf").html(""); + if (($("#prop1_type").val() > 0) && (parseFloat($("#prop1_growf").val()) > 3)) + $("#r1_growf").html(""); + if (parseFloat($("#prop1_tcells").val()) > needed) { + $("#r1_tcells").html(""); + use_cells = parseFloat($("#prop1_tcells").val()); + } } - if (parseFloat($("#prop2_growf").val()) < 1) - $("#r2_growf").html(""); - if (($("#prop2_type").val() > 0) && (parseFloat($("#prop2_growf").val()) > 3)) - $("#r2_growf").html(""); - if (parseFloat($("#prop2_tcells").val()) > needed) - $("#r2_tcells").html(""); - } - $("#r3_irate").html(""); - $("#r3_growf").html(""); - $("#r3_tcells").html(""); - if (parseFloat($("#prop3_volume").val()) > 0) { - if ((parseFloat($("#prop3_irate").val()) < 25) || (parseFloat($("#prop3_irate").val()) > 100)) { - $("#r3_irate").html(""); - } else { - $("#r3_irate").html(""); + $("#r2_irate").html(""); + $("#r2_growf").html(""); + $("#r2_tcells").html(""); + if (parseFloat($("#prop2_volume").val()) > 0) { + if ((parseFloat($("#prop2_irate").val()) < 25) || (parseFloat($("#prop2_irate").val()) > 100)) { + $("#r2_irate").html(""); + } else { + $("#r2_irate").html(""); + } + if (parseFloat($("#prop2_growf").val()) < 1) + $("#r2_growf").html(""); + if (($("#prop2_type").val() > 0) && (parseFloat($("#prop2_growf").val()) > 3)) + $("#r2_growf").html(""); + if (parseFloat($("#prop2_tcells").val()) > needed) { + $("#r2_tcells").html(""); + use_cells = parseFloat($("#prop2_tcells").val()); + } } - if (parseFloat($("#prop3_growf").val()) < 1) - $("#r3_growf").html(""); - if (($("#prop3_type").val() > 0) && (parseFloat($("#prop3_growf").val()) > 3)) - $("#r3_growf").html(""); - if (parseFloat($("#prop3_tcells").val()) > needed) - $("#r3_tcells").html(""); + $("#r3_irate").html(""); + $("#r3_growf").html(""); + $("#r3_tcells").html(""); + if (parseFloat($("#prop3_volume").val()) > 0) { + if ((parseFloat($("#prop3_irate").val()) < 25) || (parseFloat($("#prop3_irate").val()) > 100)) { + $("#r3_irate").html(""); + } else { + $("#r3_irate").html(""); + } + if (parseFloat($("#prop3_growf").val()) < 1) + $("#r3_growf").html(""); + if (($("#prop3_type").val() > 0) && (parseFloat($("#prop3_growf").val()) > 3)) + $("#r3_growf").html(""); + if (parseFloat($("#prop3_tcells").val()) > needed) { + $("#r3_tcells").html(""); + use_cells = parseFloat($("#prop3_tcells").val()); + } + } + $("#r4_irate").html(""); + $("#r4_growf").html(""); + $("#r4_tcells").html(""); + if (parseFloat($("#prop4_volume").val()) > 0) { + if ((parseFloat($("#prop4_irate").val()) < 25) || (parseFloat($("#prop4_irate").val()) > 100)) { + $("#r4_irate").html(""); + } else { + $("#r4_irate").html(""); + } + if (parseFloat($("#prop4_growf").val()) < 1) + $("#r4_growf").html(""); + if (($("#prop4_type").val() > 0) && (parseFloat($("#prop4_growf").val()) > 3)) + $("#r4_growf").html(""); + if (parseFloat($("#prop4_tcells").val()) > needed) { + $("#r4_tcells").html(""); + use_cells = parseFloat($("#prop4_tcells").val()); + } + } else { + $("#r4_irate").html(""); + } } - $("#r4_irate").html(""); - $("#r4_growf").html(""); - $("#r4_tcells").html(""); - if (parseFloat($("#prop4_volume").val()) > 0) { - if ((parseFloat($("#prop4_irate").val()) < 25) || (parseFloat($("#prop4_irate").val()) > 100)) { - $("#r4_irate").html(""); - } else { - $("#r4_irate").html(""); - } - if (parseFloat($("#prop4_growf").val()) < 1) - $("#r4_growf").html(""); - if (($("#prop4_type").val() > 0) && (parseFloat($("#prop4_growf").val()) > 3)) - $("#r4_growf").html(""); - if (parseFloat($("#prop4_tcells").val()) > needed) - $("#r4_tcells").html(""); - } else { - $("#r4_irate").html(""); - } + $("#plato_cells").val(parseFloat(use_cells / (volume * plato) )); }; function adjustHops(factor) { @@ -1928,6 +1957,10 @@ $("#sparge_source").jqxDropDownList({ disabled: true }); $("#sparge_acid_type").jqxDropDownList({ disabled: true }); $("#sparge_acid_perc").jqxNumberInput({ spinButtons: false, readOnly: true, width: false }); + $("#starter_enable").jqxCheckBox({ disabled: true }); + $("#starter_type").jqxDropDownList({ disabled: true }); + $("#starter_try").jqxButton({ disabled: true }); + $("#starter_sg").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); } if (dataRecord.stage > 3) { // Primary fermentation done $("#brew_date_start").jqxDateTimeInput({ disabled: true }); @@ -2037,6 +2070,7 @@ $("#starter_enable").on('unchecked', function (event) { dataRecord.starter_enable = 0; showStarter(); + calcYeast(); }); $("#starter_try").click(function () { $("#prop1_volume").val(0); @@ -4782,7 +4816,7 @@ $("#est_abv2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); $("#yeast_cells").jqxNumberInput( Show1dec ); $("#need_cells").jqxNumberInput( Show1dec ); - $("#plato_cells").jqxNumberInput( Show1dec ); + $("#plato_cells").jqxNumberInput( Show2dec ); $("#popupYeast").jqxWindow({ width: 800, height: 300,