www/js/prod_edit.js

changeset 358
3be8c2278fd7
parent 356
36c72e368948
child 372
1365b5e47130
equal deleted inserted replaced
357:74d56bed75b9 358:3be8c2278fd7
55 var svg = 77; // Default attenuation 55 var svg = 77; // Default attenuation
56 var mashkg = 0; // Malt in mash weight 56 var mashkg = 0; // Malt in mash weight
57 var pitchrate = 0.75; // Yeast pitch rate default 57 var pitchrate = 0.75; // Yeast pitch rate default
58 var initcells = 0; // Initial yeast cell count 58 var initcells = 0; // Initial yeast cell count
59 59
60 var ok_fermentables = 1; // Fermentables are in stock
61 var ok_hops = 1; // Hops are in stock
62 var ok_miscs = 1; // Miscs are in stock
63 var ok_yeasts = 1; // Yeasts are in stock
64 var ok_waters = 1; // Waters are in stock
65
60 var hop_flavour = 0; 66 var hop_flavour = 0;
61 var hop_aroma = 0; 67 var hop_aroma = 0;
62 var mash_infuse = 0; 68 var mash_infuse = 0;
63 var last_base = ''; 69 var last_base = '';
64 var last_acid = ''; 70 var last_acid = '';
102 isModal: true, 108 isModal: true,
103 text: "Laden product ...", 109 text: "Laden product ...",
104 theme: theme 110 theme: theme
105 }); 111 });
106 112
113 function calcSupplies() {
114
115 if (dataRecord.inventory_reduced > 6) {
116 $("#ok_pmpt").hide();
117 return;
118 }
119 if (ok_fermentables && ok_hops && ok_miscs && ok_yeasts && ok_waters)
120 $("#ok_supplies").html("<img src='images/dialog-ok-apply.png'>");
121 else
122 $("#ok_supplies").html("<img src='images/dialog-error.png'>");
123 }
124
107 /* 125 /*
108 * All calculations that depend on changes in the fermentables, 126 * All calculations that depend on changes in the fermentables,
109 * volumes and equipments. 127 * volumes and equipments.
110 */ 128 */
111 function calcFermentables() { 129 function calcFermentables() {
112 130
113 console.log("calcFermentables()");
114 var sugarsf = 0; // fermentable sugars mash + boil 131 var sugarsf = 0; // fermentable sugars mash + boil
115 var sugarsm = 0; // fermentable sugars in mash 132 var sugarsm = 0; // fermentable sugars in mash
116 psugar = 0; 133 psugar = 0;
117 pcara = 0; 134 pcara = 0;
118 mashkg = 0; 135 mashkg = 0;
136 ok_fermentables = 1; // All is in stock.
137 ok_yeasts = 1;
119 var vol = 0; // Volume sugars after boil 138 var vol = 0; // Volume sugars after boil
120 var addedS = 0; // Added sugars after boil 139 var addedS = 0; // Added sugars after boil
121 var addedmass = 0; // Added mass after boil 140 var addedmass = 0; // Added mass after boil
122 var mvol = 0; // mash volume 141 var mvol = 0; // mash volume
123 var colort = 0; // Colors srm * vol totals 142 var colort = 0; // Colors srm * vol totals
168 addedS += row.f_amount * x; 187 addedS += row.f_amount * x;
169 addedmass += row.f_amount; 188 addedmass += row.f_amount;
170 vol += (x * sugardensity + (1 - x) * 1) * row.f_amount; 189 vol += (x * sugardensity + (1 - x) * 1) * row.f_amount;
171 } 190 }
172 colort += row.f_amount * ebc_to_srm(row.f_color); 191 colort += row.f_amount * ebc_to_srm(row.f_color);
173 } 192 // Check supplies.
193 if ((((dataRecord.inventory_reduced <= 2) && (row.f_added <= 1)) || // Mash or boil
194 ((dataRecord.inventory_reduced <= 3) && (row.f_added == 2)) || // Primary
195 ((dataRecord.inventory_reduced <= 5) && (row.f_added == 3)) || // Secondary or Tertiary
196 ((dataRecord.inventory_reduced <= 6) && (row.f_added == 4))) && row.f_inventory < row.f_amount) {
197 ok_fermentables = 0;
198 }
199 }
200 $("#mash_kg").val(mashkg);
201 console.log("calcFermentables() supplies:"+ok_fermentables);
174 to_100 = my_100; 202 to_100 = my_100;
175 if (to_100) { 203 if (to_100) {
176 $("#wf_amount").jqxNumberInput({ width: 90, readOnly: true, spinButtons: false }); 204 $("#wf_amount").jqxNumberInput({ width: 90, readOnly: true, spinButtons: false });
177 } else { 205 } else {
178 $("#wf_amount").jqxNumberInput({ width: 110, readOnly: false, spinButtons: true }); 206 $("#wf_amount").jqxNumberInput({ width: 110, readOnly: false, spinButtons: true });
219 var top = dataRecord.brew_fermenter_extrawater; 247 var top = dataRecord.brew_fermenter_extrawater;
220 248
221 if (dataRecord.brew_fermenter_volume > 0) { 249 if (dataRecord.brew_fermenter_volume > 0) {
222 var sug = sg_to_plato(ogx) * dataRecord.brew_fermenter_volume * ogx / 100; //kg of sugar in 250 var sug = sg_to_plato(ogx) * dataRecord.brew_fermenter_volume * ogx / 100; //kg of sugar in
223 sug += addedS; //kg 251 sug += addedS; //kg
224 //console.log("Contents ferm_vol:"+dataRecord.brew_fermenter_volume+" top:"+top+" vol:"+vol+" addedS:"+addedS+" addedmass:"+addedmass);
225 252
226 if ((dataRecord.brew_fermenter_volume * ogx + addedmass) > 0) { 253 if ((dataRecord.brew_fermenter_volume * ogx + addedmass) > 0) {
227 var pt = 100 * sug / (dataRecord.brew_fermenter_volume * ogx + addedmass + top); 254 var pt = 100 * sug / (dataRecord.brew_fermenter_volume * ogx + addedmass + top);
228 dataRecord.brew_fermenter_sg = Math.round(plato_to_sg(pt) * 10000) / 10000; 255 dataRecord.brew_fermenter_sg = Math.round(plato_to_sg(pt) * 10000) / 10000;
229 $("#brew_fermenter_sg").val(dataRecord.brew_fermenter_sg); 256 $("#brew_fermenter_sg").val(dataRecord.brew_fermenter_sg);
232 dataRecord.brew_fermenter_color = kw_to_ebc(dataRecord.color_method, cw); 259 dataRecord.brew_fermenter_color = kw_to_ebc(dataRecord.color_method, cw);
233 $("#brew_fermenter_color").val(dataRecord.brew_fermenter_color); 260 $("#brew_fermenter_color").val(dataRecord.brew_fermenter_color);
234 var scolor = ebc_to_color(dataRecord.brew_fermenter_color); 261 var scolor = ebc_to_color(dataRecord.brew_fermenter_color);
235 $("#bcolorf").show(); 262 $("#bcolorf").show();
236 document.getElementById("bcolorf").style.background= scolor; 263 document.getElementById("bcolorf").style.background= scolor;
237 //console.log("OG in fermenter:"+dataRecord.brew_fermenter_sg+" color:"+dataRecord.brew_fermenter_color);
238 } 264 }
239 } else { 265 } else {
240 // Negative volume 266 // Negative volume
241 dataRecord.brew_fermenter_sg = dataRecord.brew_fermenter_color = 0; 267 dataRecord.brew_fermenter_sg = dataRecord.brew_fermenter_color = 0;
242 $("#brew_fermenter_sg").val(0); 268 $("#brew_fermenter_sg").val(0);
254 document.getElementById("bcolor").style.background= scolor; 280 document.getElementById("bcolor").style.background= scolor;
255 document.getElementById("bcolor2").style.background= scolor; 281 document.getElementById("bcolor2").style.background= scolor;
256 282
257 // Progress bars 283 // Progress bars
258 pmalts = mashkg / dataRecord.eq_mash_max * 100; 284 pmalts = mashkg / dataRecord.eq_mash_max * 100;
259 //console.log("mash kg: "+mashkg+" max: "+dataRecord.eq_mash_max+" perc: "+pmalts);
260 $("#perc_malts").jqxProgressBar('val', pmalts); 285 $("#perc_malts").jqxProgressBar('val', pmalts);
261 $("#perc_sugars").jqxProgressBar('val', psugar); 286 $("#perc_sugars").jqxProgressBar('val', psugar);
262 $("#perc_cara").jqxProgressBar('val', pcara); 287 $("#perc_cara").jqxProgressBar('val', pcara);
263 calcStage(); 288 calcStage();
264 289
275 initcells += (parseFloat(row.y_cells) / 1000000000) * parseFloat(row.y_amount); 300 initcells += (parseFloat(row.y_cells) / 1000000000) * parseFloat(row.y_amount);
276 else 301 else
277 initcells += (parseFloat(row.y_cells) / 1000000) * parseFloat(row.y_amount); 302 initcells += (parseFloat(row.y_cells) / 1000000) * parseFloat(row.y_amount);
278 } 303 }
279 // TODO: brett in secondary ?? 304 // TODO: brett in secondary ??
280 } 305 if ((((dataRecord.inventory_reduced <= 3) && (row.y_use == 0)) || // Primary
306 ((dataRecord.inventory_reduced <= 4) && (row.y_use == 1)) || // Secondary
307 ((dataRecord.inventory_reduced <= 5) && (row.y_use == 2)) || // Tertiary
308 ((dataRecord.inventory_reduced <= 6) && (row.y_use == 3))) && // Bottle
309 (row.y_inventory < row.y_amount)) {
310 ok_yeasts = 0;
311 }
312 }
313 calcSupplies();
281 if (svg == 0) 314 if (svg == 0)
282 svg = 77; 315 svg = 77;
283 316
284 if ((mashkg > 0) && (mash_infuse > 0) && (mashtime > 0) && (mashtemp > 0)) { 317 if ((mashkg > 0) && (mash_infuse > 0) && (mashtime > 0) && (mashtemp > 0)) {
285 dataRecord.est_fg = estimate_fg(psugar, pcara, mash_infuse / mashkg, mashtime, mashtemp, svg, dataRecord.est_og); 318 dataRecord.est_fg = estimate_fg(psugar, pcara, mash_infuse / mashkg, mashtime, mashtemp, svg, dataRecord.est_og);
295 $("#est_abv2").val(dataRecord.est_abv); 328 $("#est_abv2").val(dataRecord.est_abv);
296 329
297 // Calculate the final svg if available use the real value. 330 // Calculate the final svg if available use the real value.
298 if ((dataRecord.stage >= 6) && (dataRecord.fg > 0.990) && (dataRecord.fg < dataRecord.brew_fermenter_sg)) { 331 if ((dataRecord.stage >= 6) && (dataRecord.fg > 0.990) && (dataRecord.fg < dataRecord.brew_fermenter_sg)) {
299 svg = 100 * (dataRecord.brew_fermenter_sg - dataRecord.fg) / (dataRecord.brew_fermenter_sg - 1); 332 svg = 100 * (dataRecord.brew_fermenter_sg - dataRecord.fg) / (dataRecord.brew_fermenter_sg - 1);
300 //console.log("real svg:"+svg);
301 } 333 }
302 334
303 $("#yeast_cells").val(initcells); 335 $("#yeast_cells").val(initcells);
304 $("#need_cells").val(getNeededYeastCells()); 336 $("#need_cells").val(getNeededYeastCells());
305 }; 337 };
362 394
363 var volume = dataRecord.brew_fermenter_volume; 395 var volume = dataRecord.brew_fermenter_volume;
364 if (volume <= 0) 396 if (volume <= 0)
365 volume = dataRecord.batch_size - dataRecord.eq_trub_chiller_loss; 397 volume = dataRecord.batch_size - dataRecord.eq_trub_chiller_loss;
366 398
367 //console.log("getNeededYeastCells f:"+f+" volume:"+volume+" plato:"+plato+" sg:"+sg);
368 var result = pitchrate * volume * plato; 399 var result = pitchrate * volume * plato;
369 //console.log("getNeededYeastCells("+pitchrate+"): "+result+" billion cells");
370 return result; 400 return result;
371 } 401 }
372 402
373 function hopFlavourContribution(bt, vol, use, amount) { 403 function hopFlavourContribution(bt, vol, use, amount) {
374 var result; 404 var result;
410 var rows = {}; 440 var rows = {};
411 hop_aroma = hop_flavour = 0; 441 hop_aroma = hop_flavour = 0;
412 if (!(rows = $('#hopGrid').jqxGrid('getrows'))) { 442 if (!(rows = $('#hopGrid').jqxGrid('getrows'))) {
413 return; 443 return;
414 } 444 }
445 ok_hops = 1;
415 for (var i = 0; i < rows.length; i++) { 446 for (var i = 0; i < rows.length; i++) {
416 var row = rows[i]; 447 var row = rows[i];
417 total_ibus += toIBU(row.h_useat, row.h_form, preboil_sg, parseFloat(dataRecord.batch_size), 448 total_ibus += toIBU(row.h_useat, row.h_form, preboil_sg, parseFloat(dataRecord.batch_size),
418 parseFloat(row.h_amount), parseFloat(row.h_time), parseFloat(row.h_alpha), dataRecord.ibu_method); 449 parseFloat(row.h_amount), parseFloat(row.h_time), parseFloat(row.h_alpha), dataRecord.ibu_method);
419 ferm_ibus += toIBU(row.h_useat, row.h_form, preboil_sg, 450 ferm_ibus += toIBU(row.h_useat, row.h_form, preboil_sg,
421 parseFloat(row.h_amount), parseFloat(row.h_time), parseFloat(row.h_alpha), dataRecord.ibu_method); 452 parseFloat(row.h_amount), parseFloat(row.h_time), parseFloat(row.h_alpha), dataRecord.ibu_method);
422 hop_flavour += hopFlavourContribution(parseFloat(row.h_time), parseFloat(dataRecord.batch_size), 453 hop_flavour += hopFlavourContribution(parseFloat(row.h_time), parseFloat(dataRecord.batch_size),
423 row.h_useat, parseFloat(row.h_amount)); 454 row.h_useat, parseFloat(row.h_amount));
424 hop_aroma += hopAromaContribution(parseFloat(row.h_time), parseFloat(dataRecord.batch_size), 455 hop_aroma += hopAromaContribution(parseFloat(row.h_time), parseFloat(dataRecord.batch_size),
425 row.h_useat, parseFloat(row.h_amount)); 456 row.h_useat, parseFloat(row.h_amount));
457 if ((((dataRecord.inventory_reduced <= 2) && (row.h_useat <= 4)) || // Mash, FW, Boil, Aroma, Whirlpool
458 ((dataRecord.inventory_reduced <= 6) && (row.h_useat == 5))) && // Dry-hop
459 (row.h_inventory < row.h_amount))
460 ok_hops = 0;
426 } 461 }
427 total_ibus = Math.round(total_ibus * 10) / 10; 462 total_ibus = Math.round(total_ibus * 10) / 10;
428 ferm_ibus = Math.round(ferm_ibus * 10) / 10; 463 ferm_ibus = Math.round(ferm_ibus * 10) / 10;
429 hop_flavour = Math.round(hop_flavour * 100) / 10; 464 hop_flavour = Math.round(hop_flavour * 100) / 10;
430 hop_aroma = Math.round(hop_aroma * 100) / 10; 465 hop_aroma = Math.round(hop_aroma * 100) / 10;
431 if (hop_flavour > 100) 466 if (hop_flavour > 100)
432 hop_flavour = 100; 467 hop_flavour = 100;
433 if (hop_aroma > 100) 468 if (hop_aroma > 100)
434 hop_aroma = 100; 469 hop_aroma = 100;
435 console.log("calcIBUs(): " + total_ibus + " flavour: " + hop_flavour + " aroma: " + hop_aroma+" fermenter:"+ferm_ibus); 470 console.log("calcIBUs(): " + total_ibus + " flavour: " + hop_flavour + " aroma: " + hop_aroma+" fermenter:"+ferm_ibus+" supplies:"+ok_hops);
436 dataRecord.est_ibu = total_ibus; 471 dataRecord.est_ibu = total_ibus;
437 $('#est_ibu').val(total_ibus); 472 $('#est_ibu').val(total_ibus);
438 $('#est_ibu2').val(total_ibus); 473 $('#est_ibu2').val(total_ibus);
439 $("#hop_flavour").jqxProgressBar('val', hop_flavour); 474 $("#hop_flavour").jqxProgressBar('val', hop_flavour);
440 $("#hop_aroma").jqxProgressBar('val', hop_aroma); 475 $("#hop_aroma").jqxProgressBar('val', hop_aroma);
441 $("#brew_fermenter_ibu").val(ferm_ibus); 476 $("#brew_fermenter_ibu").val(ferm_ibus);
442 calcStage(); 477 calcStage();
478 calcSupplies();
443 }; 479 };
444 480
445 /* 481 /*
446 * http://braukaiser.com/blog/blog/2012/11/03/estimating-yeast-growth/ 482 * http://braukaiser.com/blog/blog/2012/11/03/estimating-yeast-growth/
447 * 483 *
726 } 762 }
727 } 763 }
728 var needed = getNeededYeastCells(); 764 var needed = getNeededYeastCells();
729 console.log("calcYeast() pitchrate:"+pitchrate+" start:"+initcells+" needed:"+needed); 765 console.log("calcYeast() pitchrate:"+pitchrate+" start:"+initcells+" needed:"+needed);
730 calcSteps(dataRecord.starter_type, initcells, needed); 766 calcSteps(dataRecord.starter_type, initcells, needed);
731 //console.log("calcYeast() pitchrate:"+pitchrate+" needed:"+needed);
732 $("#need_cells").val(needed); 767 $("#need_cells").val(needed);
733 768
734 $("#r1_irate").html(""); 769 $("#r1_irate").html("");
735 $("#r1_growf").html(""); 770 $("#r1_growf").html("");
736 $("#r1_tcells").html(""); 771 $("#r1_tcells").html("");
810 for (var i = 0; i < rowscount; i++) { 845 for (var i = 0; i < rowscount; i++) {
811 var row = $("#hopGrid").jqxGrid('getrowdata', i); 846 var row = $("#hopGrid").jqxGrid('getrowdata', i);
812 var amount = row.h_amount * factor; 847 var amount = row.h_amount * factor;
813 $("#hopGrid").jqxGrid('setcellvalue', i, "h_amount", amount); 848 $("#hopGrid").jqxGrid('setcellvalue', i, "h_amount", amount);
814 } 849 }
850 };
851
852 function calcMiscs() {
853
854 ok_miscs = 1;
855 var rowscount = $("#miscGrid").jqxGrid('getdatainformation').rowscount;
856
857 if (rowscount == 0)
858 return;
859
860 for (var i = 0; i < rowscount; i++) {
861 var row = $("#miscGrid").jqxGrid('getrowdata', i);
862 if ((((dataRecord.inventory_reduced <= 2) && (row.m_use_use <= 2)) || // Starter, Mash, Boil
863 ((dataRecord.inventory_reduced <= 3) && (row.m_use_use == 3)) || // Primary
864 ((dataRecord.inventory_reduced <= 5) && (row.m_use_use == 4)) || // Secondary, Teriary
865 ((dataRecord.inventory_reduced <= 6) && (row.m_use_use == 5))) && // Bottle
866 (row.m_inventory < row.m_amount)) {
867 ok_miscs = 0;
868 }
869 }
870 calcSupplies();
815 }; 871 };
816 872
817 function adjustMiscs(factor) { 873 function adjustMiscs(factor) {
818 874
819 console.log("adjustMiscs("+factor+")"); 875 console.log("adjustMiscs("+factor+")");
902 function calcMashEfficiency() { 958 function calcMashEfficiency() {
903 if (parseFloat($("#brew_mash_sg").jqxNumberInput('decimal')) < 1.002) 959 if (parseFloat($("#brew_mash_sg").jqxNumberInput('decimal')) < 1.002)
904 return; 960 return;
905 var c = sg_to_plato(est_mash_sg); 961 var c = sg_to_plato(est_mash_sg);
906 var m = sg_to_plato(parseFloat($("#brew_mash_sg").jqxNumberInput('decimal'))); 962 var m = sg_to_plato(parseFloat($("#brew_mash_sg").jqxNumberInput('decimal')));
907 //console.log("calcMashEfficiency() c "+ c + " m " + m + " in " + parseFloat($("#brew_mash_sg").jqxNumberInput('decimal')));
908 if (c > 0.5) 963 if (c > 0.5)
909 $("#brew_mash_efficiency").val(100 * m / c); 964 $("#brew_mash_efficiency").val(100 * m / c);
910 else 965 else
911 $("#brew_mash_efficiency").val(0); 966 $("#brew_mash_efficiency").val(0);
912 }; 967 };
927 var result = 0; 982 var result = 0;
928 if (m > 0) 983 if (m > 0)
929 result = Math.round((tot / m * 100) * 10) / 10; 984 result = Math.round((tot / m * 100) * 10) / 10;
930 if (result < 0) 985 if (result < 0)
931 result = 0; 986 result = 0;
932 //console.log("calcEfficiencyBeforeBoil(): "+result);
933 $("#brew_preboil_efficiency").val(result); 987 $("#brew_preboil_efficiency").val(result);
934 } 988 }
935 989
936 function calcEfficiencyAfterBoil() { 990 function calcEfficiencyAfterBoil() {
937 var m = 0; // Sugars added at mash 991 var m = 0; // Sugars added at mash
953 var result = 0; 1007 var result = 0;
954 if (m > 0) 1008 if (m > 0)
955 result = Math.round((tot / m * 100) * 10) / 10; 1009 result = Math.round((tot / m * 100) * 10) / 10;
956 if (result < 0) 1010 if (result < 0)
957 result = 0; 1011 result = 0;
958 //console.log("calcEfficiencyAfterBoil(): "+result);
959 dataRecord.brew_aboil_efficiency = result; 1012 dataRecord.brew_aboil_efficiency = result;
960 $("#brew_aboil_efficiency").val(result); 1013 $("#brew_aboil_efficiency").val(result);
961 1014
962 } 1015 }
963 1016
973 var BUGU = GetBUGU(); 1026 var BUGU = GetBUGU();
974 return (-1.2 * BUGU + 1.4); 1027 return (-1.2 * BUGU + 1.4);
975 } 1028 }
976 1029
977 function setWaterAgent(name, amount) { 1030 function setWaterAgent(name, amount) {
978 //console.log("setWaterAgent(" + name + ", " + amount + ")");
979 var rows = $('#miscGrid').jqxGrid('getrows'); 1031 var rows = $('#miscGrid').jqxGrid('getrows');
980 if (amount == 0) { 1032 if (amount == 0) {
981 for (var i = 0; i < rows.length; i++) { 1033 for (var i = 0; i < rows.length; i++) {
982 var row = rows[i]; 1034 var row = rows[i];
983 if (row.m_name == name) { 1035 if (row.m_name == name) {
1257 parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMCl / MMNaCl; 1309 parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMCl / MMNaCl;
1258 chloride += 1000 * RA / liters; 1310 chloride += 1000 * RA / liters;
1259 // Einde noot. 1311 // Einde noot.
1260 1312
1261 if ($("#wa_acid_name").val() < 0 || $("#wa_acid_name").val() > 3) { 1313 if ($("#wa_acid_name").val() < 0 || $("#wa_acid_name").val() > 3) {
1262 console.log("fix wa_acid_name");
1263 $("#wa_acid_name").val(0); 1314 $("#wa_acid_name").val(0);
1264 dataRecord.wa_acid_name = 0; 1315 dataRecord.wa_acid_name = 0;
1265 } 1316 }
1266 if (last_acid == '') 1317 if (last_acid == '')
1267 last_acid = AcidTypeData[$("#wa_acid_name").val()].nl; 1318 last_acid = AcidTypeData[$("#wa_acid_name").val()].nl;
1268 1319
1269 if ($("#wa_base_name").val() < 0 || $("#wa_base_name").val() > 3) { 1320 if ($("#wa_base_name").val() < 0 || $("#wa_base_name").val() > 3) {
1270 console.log("fix wa_base_name");
1271 $("#wa_base_name").val(0); 1321 $("#wa_base_name").val(0);
1272 dataRecord.wa_base_name = 0; 1322 dataRecord.wa_base_name = 0;
1273 } 1323 }
1274 if (last_base == '') 1324 if (last_base == '')
1275 last_base = BaseTypeData[$("#wa_base_name").val()].nl; 1325 last_base = BaseTypeData[$("#wa_base_name").val()].nl;
1527 if (RA < piCLSO4_low) 1577 if (RA < piCLSO4_low)
1528 Res = 'laag'; 1578 Res = 'laag';
1529 else if (RA > piCLSO4_high) 1579 else if (RA > piCLSO4_high)
1530 Res = 'hoog'; 1580 Res = 'hoog';
1531 setRangeIndicator('cl_so4', Res); 1581 setRangeIndicator('cl_so4', Res);
1532 // console.log("low: "+piCLSO4_low+" val: "+RA+" high: "+piCLSO4_high);
1533 1582
1534 $('#wb_calcium').val(Math.round(calcium * 10) / 10); 1583 $('#wb_calcium').val(Math.round(calcium * 10) / 10);
1535 $('#wb_magnesium').val(Math.round(magnesium * 10) / 10); 1584 $('#wb_magnesium').val(Math.round(magnesium * 10) / 10);
1536 $('#wb_sodium').val(Math.round(sodium * 10) / 10); 1585 $('#wb_sodium').val(Math.round(sodium * 10) / 10);
1537 $('#wb_sulfate').val(Math.round(sulfate * 10) / 10); 1586 $('#wb_sulfate').val(Math.round(sulfate * 10) / 10);
1577 setRangeIndicator("ph", "hoog"); 1626 setRangeIndicator("ph", "hoog");
1578 } else { 1627 } else {
1579 setRangeIndicator("ph", "normaal"); 1628 setRangeIndicator("ph", "normaal");
1580 } 1629 }
1581 calcSparge(); 1630 calcSparge();
1631 calcMiscs();
1632 calcSupplies();
1582 } 1633 }
1583 1634
1584 function calcSparge() { 1635 function calcSparge() {
1585 1636
1586 // Code from BrewBuddy/Brouwhulp, who got it from http://www.brewery.org/brewery/library/Acidi0,00fWaterAJD0497.html 1637 // Code from BrewBuddy/Brouwhulp, who got it from http://www.brewery.org/brewery/library/Acidi0,00fWaterAJD0497.html
1603 } else { 1654 } else {
1604 dataRecord.sparge_source = 0; 1655 dataRecord.sparge_source = 0;
1605 $("#sparge_source").val(0); 1656 $("#sparge_source").val(0);
1606 } 1657 }
1607 } 1658 }
1608 //console.log("calcSparge() target pH: "+TargetpH+" Source: "+Source_pH+" alkalinity: "+Source_alkalinity);
1609 1659
1610 // Step 1: Compute the mole fractions of carbonic (f1o), bicarbonate (f2o) and carbonate(f3o) at the water pH 1660 // Step 1: Compute the mole fractions of carbonic (f1o), bicarbonate (f2o) and carbonate(f3o) at the water pH
1611 var r1 = Math.pow(10, Source_pH - 6.38); 1661 var r1 = Math.pow(10, Source_pH - 6.38);
1612 var r2 = Math.pow(10, Source_pH - 10.373); 1662 var r2 = Math.pow(10, Source_pH - 10.373);
1613 var d = 1 + r1 + r1*r2; 1663 var d = 1 + r1 + r1*r2;
1782 date1_unixtime = parseInt(date1.getTime() / 1000); 1832 date1_unixtime = parseInt(date1.getTime() / 1000);
1783 date2_unixtime = parseInt(date2.getTime() / 1000); 1833 date2_unixtime = parseInt(date2.getTime() / 1000);
1784 // This is the calculated difference in seconds 1834 // This is the calculated difference in seconds
1785 var timeDifference = date1_unixtime - date2_unixtime; 1835 var timeDifference = date1_unixtime - date2_unixtime;
1786 var timeDifferenceInDays = timeDifference / 60 / 60 / 24; 1836 var timeDifferenceInDays = timeDifference / 60 / 60 / 24;
1787 //console.log(date1+' '+date2+' days: '+timeDifferenceInDays);
1788 if (timeDifferenceInDays > 0) { // At least one day 1837 if (timeDifferenceInDays > 0) { // At least one day
1789 if (timeDifferenceInDays >= 42) // 6 weeks 1838 if (timeDifferenceInDays >= 42) // 6 weeks
1790 newstage = 9; // Ready to taste 1839 newstage = 9; // Ready to taste
1791 else if (timeDifferenceInDays >= 14) // 14 days 1840 else if (timeDifferenceInDays >= 14) // 14 days
1792 newstage = 8; // Mature 1841 newstage = 8; // Mature
3235 { text: 'Opbrengst', datafield: 'f_yield', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, 3284 { text: 'Opbrengst', datafield: 'f_yield', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'p1' },
3236 { text: 'Gewicht Kg', datafield: 'f_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, 3285 { text: 'Gewicht Kg', datafield: 'f_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f3' },
3237 { text: 'Voorraad Kg', datafield: 'f_inventory', width: 120, align: 'right', 3286 { text: 'Voorraad Kg', datafield: 'f_inventory', width: 120, align: 'right',
3238 cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties, rowdata) { 3287 cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties, rowdata) {
3239 var color = '#ffffff'; 3288 var color = '#ffffff';
3240 if (value < rowdata.f_amount) 3289 if (((dataRecord.inventory_reduced <= 2) && (rowdata.f_added <= 1)) || // Mash or boil
3241 color = '#ff4040'; 3290 ((dataRecord.inventory_reduced <= 3) && (rowdata.f_added == 2)) || // Primary
3242 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + 3291 ((dataRecord.inventory_reduced <= 5) && (rowdata.f_added == 3)) || // Secondary or Tertiary
3243 color + ';">' +fermentableAdapter.formatNumber(value, "f3") + '</span>'; 3292 ((dataRecord.inventory_reduced <= 6) && (rowdata.f_added == 4))) { // Bottle
3293 if (value < rowdata.f_amount)
3294 color = '#ff4040';
3295 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' +
3296 color + ';">' +fermentableAdapter.formatNumber(value, "f3") + '</span>';
3297 } else {
3298 return '<span></span>';
3299 }
3244 } 3300 }
3245 }, 3301 },
3246 { text: 'Procent', datafield: 'f_percentage', width: 90, align: 'right', 3302 { text: 'Procent', datafield: 'f_percentage', width: 90, align: 'right',
3247 cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties, rowdata) { 3303 cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties, rowdata) {
3248 var color = '#ffffff'; 3304 var color = '#ffffff';
3439 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + amount + '</span>'; 3495 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + amount + '</span>';
3440 } 3496 }
3441 }, 3497 },
3442 { text: 'Voorraad', datafield: 'h_inventory', width: 110, align: 'right', 3498 { text: 'Voorraad', datafield: 'h_inventory', width: 110, align: 'right',
3443 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { 3499 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
3444 var color = '#ffffff'; 3500 if (((dataRecord.inventory_reduced <= 2) && (rowdata.h_useat <= 4)) || // Mash, FW, Boil, Aroma, Whirlpool
3445 if (value < rowdata.h_amount) 3501 ((dataRecord.inventory_reduced <= 6) && (rowdata.h_useat == 5))) { // Dry hop
3446 color = '#ff4040'; 3502 var color = '#ffffff';
3447 var amount = dataAdapter.formatNumber(value, "f1") + ' kg'; 3503 if (value < rowdata.h_amount)
3448 if (value < 1) 3504 color = '#ff4040';
3449 amount = dataAdapter.formatNumber(value * 1000, "f1") + ' gr'; 3505 var amount = dataAdapter.formatNumber(value, "f1") + ' kg';
3450 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + amount + '</span>'; 3506 if (value < 1)
3507 amount = dataAdapter.formatNumber(value * 1000, "f1") + ' gr';
3508 return '<span style="margin: 4px; margin-top: 6px; float: right; color: '+color+';">'+amount+'</span>';
3509 } else {
3510 return '<span></span>';
3511 }
3451 } 3512 }
3452 }, 3513 },
3453 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () { 3514 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () {
3454 return "Wijzig"; 3515 return "Wijzig";
3455 }, buttonclick: function (row) { 3516 }, buttonclick: function (row) {
3623 var commit = $("#miscGrid").jqxGrid('deleterow', id); 3684 var commit = $("#miscGrid").jqxGrid('deleterow', id);
3624 } 3685 }
3625 }); 3686 });
3626 }, 3687 },
3627 ready: function() { 3688 ready: function() {
3689 calcMiscs();
3628 $('#jqxTabs').jqxTabs('next'); 3690 $('#jqxTabs').jqxTabs('next');
3629 }, 3691 },
3630 columns: [ 3692 columns: [
3631 { text: 'Ingredient', datafield: 'm_name' }, 3693 { text: 'Ingredient', datafield: 'm_name' },
3632 { text: 'Type', width: 140, datafield: 'm_type', 3694 { text: 'Type', width: 140, datafield: 'm_type',
3656 dataAdapter.formatNumber(value * 1000,"f2")+" "+vstr + '</span>'; 3718 dataAdapter.formatNumber(value * 1000,"f2")+" "+vstr + '</span>';
3657 } 3719 }
3658 }, 3720 },
3659 { text: 'Voorraad', datafield: 'm_inventory', width: 110, align: 'right', 3721 { text: 'Voorraad', datafield: 'm_inventory', width: 110, align: 'right',
3660 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { 3722 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
3661 var vstr = rowdata.m_amount_is_weight ? "gr":"ml"; 3723 if (((dataRecord.inventory_reduced <= 2) && (rowdata.m_use_use <= 2)) || // Starter, Mash, Boil
3662 var color = '#ffffff'; 3724 ((dataRecord.inventory_reduced <= 3) && (rowdata.m_use_use == 3)) || // Primary
3663 if (value < rowdata.m_amount) 3725 ((dataRecord.inventory_reduced <= 5) && (rowdata.m_use_use == 4)) || // Secondary, Teriary
3664 color = '#ff4040'; 3726 ((dataRecord.inventory_reduced <= 6) && (rowdata.m_use_use == 5))) { // Bottle
3665 var amount = dataAdapter.formatNumber(value * 1000,"f2")+" "+vstr; 3727 var vstr = rowdata.m_amount_is_weight ? "gr":"ml";
3666 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + amount + '</span>'; 3728 var color = '#ffffff';
3729 if (value < rowdata.m_amount)
3730 color = '#ff4040';
3731 var amount = dataAdapter.formatNumber(value * 1000,"f2")+" "+vstr;
3732 return '<span style="margin: 4px; margin-top: 6px; float: right; color: '+color+';">'+amount+'</span>';
3733 } else {
3734 return '<span></span>';
3735 }
3667 } 3736 }
3668 }, 3737 },
3669 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () { 3738 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () {
3670 return "Wijzig"; 3739 return "Wijzig";
3671 }, buttonclick: function (row) { 3740 }, buttonclick: function (row) {
3845 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + amount + '</span>'; 3914 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + amount + '</span>';
3846 } 3915 }
3847 }, 3916 },
3848 { text: 'Voorraad', datafield: 'y_inventory', width: 90, align: 'right', 3917 { text: 'Voorraad', datafield: 'y_inventory', width: 90, align: 'right',
3849 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { 3918 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
3850 var color = '#ffffff'; 3919 if (((dataRecord.inventory_reduced <= 3) && (rowdata.y_use == 0)) || // Primary
3851 if (value < rowdata.y_amount) 3920 ((dataRecord.inventory_reduced <= 4) && (rowdata.y_use == 1)) || // Secondary
3852 color = '#ff4040'; 3921 ((dataRecord.inventory_reduced <= 5) && (rowdata.y_use == 2)) || // Tertiary
3853 var amount = dataAdapter.formatNumber(value*1000, "f0")+" ml"; 3922 ((dataRecord.inventory_reduced <= 6) && (rowdata.y_use == 3))) { // Bottle
3854 if (rowdata.y_form == 0) // Liquid 3923 var color = '#ffffff';
3855 amount = dataAdapter.formatNumber(value, "f0")+" pk"; 3924 if (value < rowdata.y_amount)
3856 else if (rowdata.y_form == 1) // Dry 3925 color = '#ff4040';
3857 amount = dataAdapter.formatNumber(value*1000, "f1")+" gr"; 3926 var amount = dataAdapter.formatNumber(value*1000, "f0")+" ml";
3858 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + amount + '</span>'; 3927 if (rowdata.y_form == 0) // Liquid
3928 amount = dataAdapter.formatNumber(value, "f0")+" pk";
3929 else if (rowdata.y_form == 1) // Dry
3930 amount = dataAdapter.formatNumber(value*1000, "f1")+" gr";
3931 return '<span style="margin: 4px; margin-top: 6px; float: right; color: '+color+';">'+amount+'</span>';
3932 } else {
3933 return '<span></span>';
3934 }
3859 } 3935 }
3860 }, 3936 },
3861 { text: '', datafield: 'Edit', columntype: 'button', width: 90, align: 'center', cellsrenderer: function () { 3937 { text: '', datafield: 'Edit', columntype: 'button', width: 90, align: 'center', cellsrenderer: function () {
3862 return "Wijzig"; 3938 return "Wijzig";
3863 }, buttonclick: function (row) { 3939 }, buttonclick: function (row) {
4178 // Tab 3, Fermentables 4254 // Tab 3, Fermentables
4179 $("#est_color2").jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' }); 4255 $("#est_color2").jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' });
4180 $("#est_color2").jqxNumberInput( Show0dec ); 4256 $("#est_color2").jqxNumberInput( Show0dec );
4181 $("#est_og2").jqxTooltip({ content: 'Het geschatte begin SG van dit product.' }); 4257 $("#est_og2").jqxTooltip({ content: 'Het geschatte begin SG van dit product.' });
4182 $("#est_og2").jqxNumberInput( Show3dec ); 4258 $("#est_og2").jqxNumberInput( Show3dec );
4259 $("#mash_kg").jqxTooltip({ content: 'Het gewicht van alle mouten in de maisch.' });
4260 $("#mash_kg").jqxNumberInput( Show3dec );
4183 $("#perc_malts").jqxProgressBar({ 4261 $("#perc_malts").jqxProgressBar({
4184 width: 300, 4262 width: 300,
4185 height: 23, 4263 height: 23,
4186 theme: theme, 4264 theme: theme,
4187 showText: true, 4265 showText: true,
4592 modalOpacity: 0.40 4670 modalOpacity: 0.40
4593 }); 4671 });
4594 $("#MiscReady").jqxButton({ template: "success", width: '90px', theme: theme }); 4672 $("#MiscReady").jqxButton({ template: "success", width: '90px', theme: theme });
4595 $("#MiscReady").click(function () { 4673 $("#MiscReady").click(function () {
4596 $("#miscGrid").jqxGrid('sortby', 'm_use_use', 'asc'); 4674 $("#miscGrid").jqxGrid('sortby', 'm_use_use', 'asc');
4675 calcMiscs();
4597 }); 4676 });
4598 $("#wm_name").jqxInput({ theme: theme, width: 320, height: 23 }); 4677 $("#wm_name").jqxInput({ theme: theme, width: 320, height: 23 });
4599 $("#wm_instock").jqxCheckBox({ theme: theme, height: 23 }); 4678 $("#wm_instock").jqxCheckBox({ theme: theme, height: 23 });
4600 $("#wm_instock").on('change', function (event) { 4679 $("#wm_instock").on('change', function (event) {
4601 miscinstock = event.args.checked; 4680 miscinstock = event.args.checked;

mercurial