diff -r 74d56bed75b9 -r 3be8c2278fd7 www/js/prod_edit.js
--- a/www/js/prod_edit.js Sat May 11 17:25:58 2019 +0200
+++ b/www/js/prod_edit.js Sat May 11 23:13:40 2019 +0200
@@ -57,6 +57,12 @@
var pitchrate = 0.75; // Yeast pitch rate default
var initcells = 0; // Initial yeast cell count
+ var ok_fermentables = 1; // Fermentables are in stock
+ var ok_hops = 1; // Hops are in stock
+ var ok_miscs = 1; // Miscs are in stock
+ var ok_yeasts = 1; // Yeasts are in stock
+ var ok_waters = 1; // Waters are in stock
+
var hop_flavour = 0;
var hop_aroma = 0;
var mash_infuse = 0;
@@ -104,18 +110,31 @@
theme: theme
});
+ function calcSupplies() {
+
+ if (dataRecord.inventory_reduced > 6) {
+ $("#ok_pmpt").hide();
+ return;
+ }
+ if (ok_fermentables && ok_hops && ok_miscs && ok_yeasts && ok_waters)
+ $("#ok_supplies").html("");
+ else
+ $("#ok_supplies").html("");
+ }
+
/*
* All calculations that depend on changes in the fermentables,
* volumes and equipments.
*/
function calcFermentables() {
- console.log("calcFermentables()");
var sugarsf = 0; // fermentable sugars mash + boil
var sugarsm = 0; // fermentable sugars in mash
psugar = 0;
pcara = 0;
mashkg = 0;
+ ok_fermentables = 1; // All is in stock.
+ ok_yeasts = 1;
var vol = 0; // Volume sugars after boil
var addedS = 0; // Added sugars after boil
var addedmass = 0; // Added mass after boil
@@ -170,7 +189,16 @@
vol += (x * sugardensity + (1 - x) * 1) * row.f_amount;
}
colort += row.f_amount * ebc_to_srm(row.f_color);
+ // Check supplies.
+ if ((((dataRecord.inventory_reduced <= 2) && (row.f_added <= 1)) || // Mash or boil
+ ((dataRecord.inventory_reduced <= 3) && (row.f_added == 2)) || // Primary
+ ((dataRecord.inventory_reduced <= 5) && (row.f_added == 3)) || // Secondary or Tertiary
+ ((dataRecord.inventory_reduced <= 6) && (row.f_added == 4))) && row.f_inventory < row.f_amount) {
+ ok_fermentables = 0;
+ }
}
+ $("#mash_kg").val(mashkg);
+ console.log("calcFermentables() supplies:"+ok_fermentables);
to_100 = my_100;
if (to_100) {
$("#wf_amount").jqxNumberInput({ width: 90, readOnly: true, spinButtons: false });
@@ -221,7 +249,6 @@
if (dataRecord.brew_fermenter_volume > 0) {
var sug = sg_to_plato(ogx) * dataRecord.brew_fermenter_volume * ogx / 100; //kg of sugar in
sug += addedS; //kg
- //console.log("Contents ferm_vol:"+dataRecord.brew_fermenter_volume+" top:"+top+" vol:"+vol+" addedS:"+addedS+" addedmass:"+addedmass);
if ((dataRecord.brew_fermenter_volume * ogx + addedmass) > 0) {
var pt = 100 * sug / (dataRecord.brew_fermenter_volume * ogx + addedmass + top);
@@ -234,7 +261,6 @@
var scolor = ebc_to_color(dataRecord.brew_fermenter_color);
$("#bcolorf").show();
document.getElementById("bcolorf").style.background= scolor;
- //console.log("OG in fermenter:"+dataRecord.brew_fermenter_sg+" color:"+dataRecord.brew_fermenter_color);
}
} else {
// Negative volume
@@ -256,7 +282,6 @@
// Progress bars
pmalts = mashkg / dataRecord.eq_mash_max * 100;
- //console.log("mash kg: "+mashkg+" max: "+dataRecord.eq_mash_max+" perc: "+pmalts);
$("#perc_malts").jqxProgressBar('val', pmalts);
$("#perc_sugars").jqxProgressBar('val', psugar);
$("#perc_cara").jqxProgressBar('val', pcara);
@@ -277,7 +302,15 @@
initcells += (parseFloat(row.y_cells) / 1000000) * parseFloat(row.y_amount);
}
// TODO: brett in secondary ??
+ if ((((dataRecord.inventory_reduced <= 3) && (row.y_use == 0)) || // Primary
+ ((dataRecord.inventory_reduced <= 4) && (row.y_use == 1)) || // Secondary
+ ((dataRecord.inventory_reduced <= 5) && (row.y_use == 2)) || // Tertiary
+ ((dataRecord.inventory_reduced <= 6) && (row.y_use == 3))) && // Bottle
+ (row.y_inventory < row.y_amount)) {
+ ok_yeasts = 0;
+ }
}
+ calcSupplies();
if (svg == 0)
svg = 77;
@@ -297,7 +330,6 @@
// Calculate the final svg if available use the real value.
if ((dataRecord.stage >= 6) && (dataRecord.fg > 0.990) && (dataRecord.fg < dataRecord.brew_fermenter_sg)) {
svg = 100 * (dataRecord.brew_fermenter_sg - dataRecord.fg) / (dataRecord.brew_fermenter_sg - 1);
- //console.log("real svg:"+svg);
}
$("#yeast_cells").val(initcells);
@@ -364,9 +396,7 @@
if (volume <= 0)
volume = dataRecord.batch_size - dataRecord.eq_trub_chiller_loss;
- //console.log("getNeededYeastCells f:"+f+" volume:"+volume+" plato:"+plato+" sg:"+sg);
var result = pitchrate * volume * plato;
- //console.log("getNeededYeastCells("+pitchrate+"): "+result+" billion cells");
return result;
}
@@ -412,6 +442,7 @@
if (!(rows = $('#hopGrid').jqxGrid('getrows'))) {
return;
}
+ ok_hops = 1;
for (var i = 0; i < rows.length; i++) {
var row = rows[i];
total_ibus += toIBU(row.h_useat, row.h_form, preboil_sg, parseFloat(dataRecord.batch_size),
@@ -423,6 +454,10 @@
row.h_useat, parseFloat(row.h_amount));
hop_aroma += hopAromaContribution(parseFloat(row.h_time), parseFloat(dataRecord.batch_size),
row.h_useat, parseFloat(row.h_amount));
+ if ((((dataRecord.inventory_reduced <= 2) && (row.h_useat <= 4)) || // Mash, FW, Boil, Aroma, Whirlpool
+ ((dataRecord.inventory_reduced <= 6) && (row.h_useat == 5))) && // Dry-hop
+ (row.h_inventory < row.h_amount))
+ ok_hops = 0;
}
total_ibus = Math.round(total_ibus * 10) / 10;
ferm_ibus = Math.round(ferm_ibus * 10) / 10;
@@ -432,7 +467,7 @@
hop_flavour = 100;
if (hop_aroma > 100)
hop_aroma = 100;
- console.log("calcIBUs(): " + total_ibus + " flavour: " + hop_flavour + " aroma: " + hop_aroma+" fermenter:"+ferm_ibus);
+ console.log("calcIBUs(): " + total_ibus + " flavour: " + hop_flavour + " aroma: " + hop_aroma+" fermenter:"+ferm_ibus+" supplies:"+ok_hops);
dataRecord.est_ibu = total_ibus;
$('#est_ibu').val(total_ibus);
$('#est_ibu2').val(total_ibus);
@@ -440,6 +475,7 @@
$("#hop_aroma").jqxProgressBar('val', hop_aroma);
$("#brew_fermenter_ibu").val(ferm_ibus);
calcStage();
+ calcSupplies();
};
/*
@@ -728,7 +764,6 @@
var needed = getNeededYeastCells();
console.log("calcYeast() pitchrate:"+pitchrate+" start:"+initcells+" needed:"+needed);
calcSteps(dataRecord.starter_type, initcells, needed);
- //console.log("calcYeast() pitchrate:"+pitchrate+" needed:"+needed);
$("#need_cells").val(needed);
$("#r1_irate").html("");
@@ -814,6 +849,27 @@
}
};
+ function calcMiscs() {
+
+ ok_miscs = 1;
+ var rowscount = $("#miscGrid").jqxGrid('getdatainformation').rowscount;
+
+ if (rowscount == 0)
+ return;
+
+ for (var i = 0; i < rowscount; i++) {
+ var row = $("#miscGrid").jqxGrid('getrowdata', i);
+ if ((((dataRecord.inventory_reduced <= 2) && (row.m_use_use <= 2)) || // Starter, Mash, Boil
+ ((dataRecord.inventory_reduced <= 3) && (row.m_use_use == 3)) || // Primary
+ ((dataRecord.inventory_reduced <= 5) && (row.m_use_use == 4)) || // Secondary, Teriary
+ ((dataRecord.inventory_reduced <= 6) && (row.m_use_use == 5))) && // Bottle
+ (row.m_inventory < row.m_amount)) {
+ ok_miscs = 0;
+ }
+ }
+ calcSupplies();
+ };
+
function adjustMiscs(factor) {
console.log("adjustMiscs("+factor+")");
@@ -904,7 +960,6 @@
return;
var c = sg_to_plato(est_mash_sg);
var m = sg_to_plato(parseFloat($("#brew_mash_sg").jqxNumberInput('decimal')));
- //console.log("calcMashEfficiency() c "+ c + " m " + m + " in " + parseFloat($("#brew_mash_sg").jqxNumberInput('decimal')));
if (c > 0.5)
$("#brew_mash_efficiency").val(100 * m / c);
else
@@ -929,7 +984,6 @@
result = Math.round((tot / m * 100) * 10) / 10;
if (result < 0)
result = 0;
- //console.log("calcEfficiencyBeforeBoil(): "+result);
$("#brew_preboil_efficiency").val(result);
}
@@ -955,7 +1009,6 @@
result = Math.round((tot / m * 100) * 10) / 10;
if (result < 0)
result = 0;
- //console.log("calcEfficiencyAfterBoil(): "+result);
dataRecord.brew_aboil_efficiency = result;
$("#brew_aboil_efficiency").val(result);
@@ -975,7 +1028,6 @@
}
function setWaterAgent(name, amount) {
- //console.log("setWaterAgent(" + name + ", " + amount + ")");
var rows = $('#miscGrid').jqxGrid('getrows');
if (amount == 0) {
for (var i = 0; i < rows.length; i++) {
@@ -1259,7 +1311,6 @@
// Einde noot.
if ($("#wa_acid_name").val() < 0 || $("#wa_acid_name").val() > 3) {
- console.log("fix wa_acid_name");
$("#wa_acid_name").val(0);
dataRecord.wa_acid_name = 0;
}
@@ -1267,7 +1318,6 @@
last_acid = AcidTypeData[$("#wa_acid_name").val()].nl;
if ($("#wa_base_name").val() < 0 || $("#wa_base_name").val() > 3) {
- console.log("fix wa_base_name");
$("#wa_base_name").val(0);
dataRecord.wa_base_name = 0;
}
@@ -1529,7 +1579,6 @@
else if (RA > piCLSO4_high)
Res = 'hoog';
setRangeIndicator('cl_so4', Res);
-// console.log("low: "+piCLSO4_low+" val: "+RA+" high: "+piCLSO4_high);
$('#wb_calcium').val(Math.round(calcium * 10) / 10);
$('#wb_magnesium').val(Math.round(magnesium * 10) / 10);
@@ -1579,6 +1628,8 @@
setRangeIndicator("ph", "normaal");
}
calcSparge();
+ calcMiscs();
+ calcSupplies();
}
function calcSparge() {
@@ -1605,7 +1656,6 @@
$("#sparge_source").val(0);
}
}
- //console.log("calcSparge() target pH: "+TargetpH+" Source: "+Source_pH+" alkalinity: "+Source_alkalinity);
// Step 1: Compute the mole fractions of carbonic (f1o), bicarbonate (f2o) and carbonate(f3o) at the water pH
var r1 = Math.pow(10, Source_pH - 6.38);
@@ -1784,7 +1834,6 @@
// This is the calculated difference in seconds
var timeDifference = date1_unixtime - date2_unixtime;
var timeDifferenceInDays = timeDifference / 60 / 60 / 24;
- //console.log(date1+' '+date2+' days: '+timeDifferenceInDays);
if (timeDifferenceInDays > 0) { // At least one day
if (timeDifferenceInDays >= 42) // 6 weeks
newstage = 9; // Ready to taste
@@ -3237,10 +3286,17 @@
{ text: 'Voorraad Kg', datafield: 'f_inventory', width: 120, align: 'right',
cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties, rowdata) {
var color = '#ffffff';
- if (value < rowdata.f_amount)
- color = '#ff4040';
- return '' +fermentableAdapter.formatNumber(value, "f3") + '';
+ if (((dataRecord.inventory_reduced <= 2) && (rowdata.f_added <= 1)) || // Mash or boil
+ ((dataRecord.inventory_reduced <= 3) && (rowdata.f_added == 2)) || // Primary
+ ((dataRecord.inventory_reduced <= 5) && (rowdata.f_added == 3)) || // Secondary or Tertiary
+ ((dataRecord.inventory_reduced <= 6) && (rowdata.f_added == 4))) { // Bottle
+ if (value < rowdata.f_amount)
+ color = '#ff4040';
+ return '' +fermentableAdapter.formatNumber(value, "f3") + '';
+ } else {
+ return '';
+ }
}
},
{ text: 'Procent', datafield: 'f_percentage', width: 90, align: 'right',
@@ -3441,13 +3497,18 @@
},
{ text: 'Voorraad', datafield: 'h_inventory', width: 110, align: 'right',
cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
- var color = '#ffffff';
- if (value < rowdata.h_amount)
- color = '#ff4040';
- var amount = dataAdapter.formatNumber(value, "f1") + ' kg';
- if (value < 1)
- amount = dataAdapter.formatNumber(value * 1000, "f1") + ' gr';
- return '' + amount + '';
+ if (((dataRecord.inventory_reduced <= 2) && (rowdata.h_useat <= 4)) || // Mash, FW, Boil, Aroma, Whirlpool
+ ((dataRecord.inventory_reduced <= 6) && (rowdata.h_useat == 5))) { // Dry hop
+ var color = '#ffffff';
+ if (value < rowdata.h_amount)
+ color = '#ff4040';
+ var amount = dataAdapter.formatNumber(value, "f1") + ' kg';
+ if (value < 1)
+ amount = dataAdapter.formatNumber(value * 1000, "f1") + ' gr';
+ return ''+amount+'';
+ } else {
+ return '';
+ }
}
},
{ text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () {
@@ -3625,6 +3686,7 @@
});
},
ready: function() {
+ calcMiscs();
$('#jqxTabs').jqxTabs('next');
},
columns: [
@@ -3658,12 +3720,19 @@
},
{ text: 'Voorraad', datafield: 'm_inventory', width: 110, align: 'right',
cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
- var vstr = rowdata.m_amount_is_weight ? "gr":"ml";
- var color = '#ffffff';
- if (value < rowdata.m_amount)
- color = '#ff4040';
- var amount = dataAdapter.formatNumber(value * 1000,"f2")+" "+vstr;
- return '' + amount + '';
+ if (((dataRecord.inventory_reduced <= 2) && (rowdata.m_use_use <= 2)) || // Starter, Mash, Boil
+ ((dataRecord.inventory_reduced <= 3) && (rowdata.m_use_use == 3)) || // Primary
+ ((dataRecord.inventory_reduced <= 5) && (rowdata.m_use_use == 4)) || // Secondary, Teriary
+ ((dataRecord.inventory_reduced <= 6) && (rowdata.m_use_use == 5))) { // Bottle
+ var vstr = rowdata.m_amount_is_weight ? "gr":"ml";
+ var color = '#ffffff';
+ if (value < rowdata.m_amount)
+ color = '#ff4040';
+ var amount = dataAdapter.formatNumber(value * 1000,"f2")+" "+vstr;
+ return ''+amount+'';
+ } else {
+ return '';
+ }
}
},
{ text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () {
@@ -3847,15 +3916,22 @@
},
{ text: 'Voorraad', datafield: 'y_inventory', width: 90, align: 'right',
cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
- var color = '#ffffff';
- if (value < rowdata.y_amount)
- color = '#ff4040';
- var amount = dataAdapter.formatNumber(value*1000, "f0")+" ml";
- if (rowdata.y_form == 0) // Liquid
- amount = dataAdapter.formatNumber(value, "f0")+" pk";
- else if (rowdata.y_form == 1) // Dry
- amount = dataAdapter.formatNumber(value*1000, "f1")+" gr";
- return '' + amount + '';
+ if (((dataRecord.inventory_reduced <= 3) && (rowdata.y_use == 0)) || // Primary
+ ((dataRecord.inventory_reduced <= 4) && (rowdata.y_use == 1)) || // Secondary
+ ((dataRecord.inventory_reduced <= 5) && (rowdata.y_use == 2)) || // Tertiary
+ ((dataRecord.inventory_reduced <= 6) && (rowdata.y_use == 3))) { // Bottle
+ var color = '#ffffff';
+ if (value < rowdata.y_amount)
+ color = '#ff4040';
+ var amount = dataAdapter.formatNumber(value*1000, "f0")+" ml";
+ if (rowdata.y_form == 0) // Liquid
+ amount = dataAdapter.formatNumber(value, "f0")+" pk";
+ else if (rowdata.y_form == 1) // Dry
+ amount = dataAdapter.formatNumber(value*1000, "f1")+" gr";
+ return ''+amount+'';
+ } else {
+ return '';
+ }
}
},
{ text: '', datafield: 'Edit', columntype: 'button', width: 90, align: 'center', cellsrenderer: function () {
@@ -4180,6 +4256,8 @@
$("#est_color2").jqxNumberInput( Show0dec );
$("#est_og2").jqxTooltip({ content: 'Het geschatte begin SG van dit product.' });
$("#est_og2").jqxNumberInput( Show3dec );
+ $("#mash_kg").jqxTooltip({ content: 'Het gewicht van alle mouten in de maisch.' });
+ $("#mash_kg").jqxNumberInput( Show3dec );
$("#perc_malts").jqxProgressBar({
width: 300,
height: 23,
@@ -4594,6 +4672,7 @@
$("#MiscReady").jqxButton({ template: "success", width: '90px', theme: theme });
$("#MiscReady").click(function () {
$("#miscGrid").jqxGrid('sortby', 'm_use_use', 'asc');
+ calcMiscs();
});
$("#wm_name").jqxInput({ theme: theme, width: 320, height: 23 });
$("#wm_instock").jqxCheckBox({ theme: theme, height: 23 });