www/js/prod_edit.js

changeset 236
4b8e5478d08f
parent 223
0de4455bd2a1
child 237
9337b5ff8698
equal deleted inserted replaced
235:0a063ac5d7f5 236:4b8e5478d08f
44 44
45 45
46 46
47 $(document).ready(function () { 47 $(document).ready(function () {
48 48
49 var brewstage = 0; // Numeric value of stage 49 var to_100 = false; // Fermentables adjust to 100%
50 var preboil_sg = 0; 50 var preboil_sg = 0;
51 var est_mash_sg = 0; 51 var est_mash_sg = 0;
52 var sugarsm = 0; // Sugars after mash 52 var sugarsm = 0; // Sugars after mash
53 var sugarsf = 0; // Sugars after boil 53 var sugarsf = 0; // Sugars after boil
54 var psugar = 0; // Percentage real sugars 54 var psugar = 0; // Percentage real sugars
55 var pcara = 0; // Percentage cara/crystal malts 55 var pcara = 0; // Percentage cara/crystal malts
56 var svg = 77; // Default attenuation 56 var svg = 77; // Default attenuation
57 var mashkg = 0; // Malt in mash weight 57 var mashkg = 0; // Malt in mash weight
58 var hop_flavour = 0; 58 var hop_flavour = 0;
59 var hop_aroma = 0; 59 var hop_aroma = 0;
60 var mash_infuse = 0; 60 var mash_infuse = 0;
75 var MMNaHCO3 = 84.007; 75 var MMNaHCO3 = 84.007;
76 var MMNa2CO3 = 105.996; 76 var MMNa2CO3 = 105.996;
77 var MMNaCl = 58.443; 77 var MMNaCl = 58.443;
78 var MMCaOH2 = 74.06268; 78 var MMCaOH2 = 74.06268;
79 79
80 var fermentableRow = 0;
81 var fermentableData = {};
82 var hopRow = 0;
83 var hopData = {};
84 var miscRow = 0;
85 var miscData = {};
86 var yeastRow = 0;
87 var yeastData = {};
88 var mashRow = 0;
89 var mashData = {};
90
80 console.log("record:" + my_record + " return:" + my_return + " theme:" + theme); 91 console.log("record:" + my_record + " return:" + my_return + " theme:" + theme);
81 $("#jqxLoader").jqxLoader({ 92 $("#jqxLoader").jqxLoader({
82 width: 250, 93 width: 250,
83 height: 150, 94 height: 150,
84 isModal: true, 95 isModal: true,
99 var rows = $('#fermentableGrid').jqxGrid('getrows'); 110 var rows = $('#fermentableGrid').jqxGrid('getrows');
100 for (var i = 0; i < rows.length; i++) { 111 for (var i = 0; i < rows.length; i++) {
101 var row = rows[i]; 112 var row = rows[i];
102 if (row.f_adjust_to_total_100) 113 if (row.f_adjust_to_total_100)
103 my_100 = true; 114 my_100 = true;
104 if (row.f_type == "Sugar") 115 if (row.f_type == 1) // Sugar
105 psugar += row.f_percentage; 116 psugar += row.f_percentage;
106 if (row.f_graintype == "Crystal") 117 if (row.f_graintype == 2) // Crystal
107 pcara += row.f_percentage; 118 pcara += row.f_percentage;
108 var d = row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); 119 var d = row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100);
109 if (row.f_added == "Mash") { 120 if (row.f_added == 0) { // Mash
110 d = parseFloat(dataRecord.efficiency) / 100 * d; 121 d = parseFloat(dataRecord.efficiency) / 100 * d;
111 sugarsm += d; 122 sugarsm += d;
112 mashkg += row.f_amount; 123 mashkg += row.f_amount;
113 } 124 }
114 sugarsf += d; 125 sugarsf += d;
115 colorw += row.f_amount * ebc_to_srm(row.f_color) / parseFloat(dataRecord.batch_size) * 8.34436; 126 colorw += row.f_amount * ebc_to_srm(row.f_color) / parseFloat(dataRecord.batch_size) * 8.34436;
116 } 127 }
117 to_100 = my_100; 128 to_100 = my_100;
129 if (to_100) {
130 $("#wf_amount").jqxNumberInput({ width: 90, readOnly: true, spinButtons: false });
131 } else {
132 $("#wf_amount").jqxNumberInput({ width: 110, readOnly: false, spinButtons: true });
133 }
118 var est_og = estimate_sg(sugarsf, parseFloat(dataRecord.batch_size)); 134 var est_og = estimate_sg(sugarsf, parseFloat(dataRecord.batch_size));
119 $('#est_og').val(est_og); 135 $('#est_og').val(est_og);
120 $('#est_og2').val(est_og); 136 $('#est_og2').val(est_og);
121 $('#est_og3').val(est_og); 137 $('#est_og3').val(est_og);
122 preboil_sg = estimate_sg(sugarsm, parseFloat(dataRecord.boil_size)); 138 preboil_sg = estimate_sg(sugarsm, parseFloat(dataRecord.boil_size));
125 $('#est_color2').val(color); 141 $('#est_color2').val(color);
126 var scolor = ebc_to_color(color); 142 var scolor = ebc_to_color(color);
127 document.getElementById("bcolor").style.background= scolor; 143 document.getElementById("bcolor").style.background= scolor;
128 document.getElementById("bcolor2").style.background= scolor; 144 document.getElementById("bcolor2").style.background= scolor;
129 pmalts = mashkg / dataRecord.eq_mash_max * 100; 145 pmalts = mashkg / dataRecord.eq_mash_max * 100;
130 console.log("mash kg: "+mashkg+" max: "+dataRecord.eq_mash_max+" perc: "+pmalts); 146 // console.log("mash kg: "+mashkg+" max: "+dataRecord.eq_mash_max+" perc: "+pmalts);
131 $("#perc_malts").jqxProgressBar('val', pmalts); 147 $("#perc_malts").jqxProgressBar('val', pmalts);
132 $("#perc_sugars").jqxProgressBar('val', psugar); 148 $("#perc_sugars").jqxProgressBar('val', psugar);
133 $("#perc_cara").jqxProgressBar('val', pcara); 149 $("#perc_cara").jqxProgressBar('val', pcara);
134 }; 150 };
135 151
145 sug2 = 0; 161 sug2 = 0;
146 efficiency = parseFloat(dataRecord.efficiency); 162 efficiency = parseFloat(dataRecord.efficiency);
147 var rows = $('#fermentableGrid').jqxGrid('getrows'); 163 var rows = $('#fermentableGrid').jqxGrid('getrows');
148 for (i = 0; i < rows.length; i++) { 164 for (i = 0; i < rows.length; i++) {
149 var row = rows[i]; 165 var row = rows[i];
150 if ((row.f_added == "Fermentation") || (row.f_added == "Lagering") || (row.f_added == "Bottle")) { 166 if ((row.f_added == 2) || (row.f_added == 3) || (row.f_added == 4)) { // Fermentation, Lagering or Bottle
151 var x = (row.f_yield / 100) * (1 - row.f_moisture / 100); 167 var x = (row.f_yield / 100) * (1 - row.f_moisture / 100);
152 vol += row.f_amount / (x * sugardensity + (1 - x) * 1); 168 vol += row.f_amount / (x * sugardensity + (1 - x) * 1);
153 sug2 += row.f_amount * x; 169 sug2 += row.f_amount * x;
154 } 170 }
155 } 171 }
166 tot = 0; 182 tot = 0;
167 d = 0; 183 d = 0;
168 for (i = 0; i < rows.length; i++) { 184 for (i = 0; i < rows.length; i++) {
169 var row = rows[i]; 185 var row = rows[i];
170 d = row.f_percentage / 100 * (row.f_yield / 100) * (1 - row.f_moisture / 100); 186 d = row.f_percentage / 100 * (row.f_yield / 100) * (1 - row.f_moisture / 100);
171 if (row.f_added == "Mash") 187 if (row.f_added == 0) // Mash
172 d = efficiency / 100 * d; 188 d = efficiency / 100 * d;
173 tot += d; 189 tot += d;
174 } 190 }
175 if (tot) 191 if (tot)
176 totmass = sug / tot; 192 totmass = sug / tot;
187 } 203 }
188 }; 204 };
189 //CalcWaterBalance; 205 //CalcWaterBalance;
190 }; 206 };
191 207
208 function calcFG() {
209 var fg = estimate_fg(psugar, pcara, 0, 0, 0, svg, parseFloat(parseFloat($("#est_og").jqxNumberInput('decimal'))));
210 dataRecord.est_fg = fg;
211 $('#est_fg').val(fg);
212 $('#est_fg2').val(fg);
213 }
214
192 function calcABV() { 215 function calcABV() {
193 $("#est_abv").val(abvol(parseFloat($("#est_og").jqxNumberInput('decimal')), parseFloat($("#est_fg").jqxNumberInput('decimal')))); 216 var abv = abvol(parseFloat($("#est_og").jqxNumberInput('decimal')), parseFloat($("#est_fg").jqxNumberInput('decimal')));
217 $("#est_abv").val(abv);
218 $("#est_abv2").val(abv);
194 }; 219 };
195 220
196 function hopFlavourContribution(bt, vol, use, amount) { 221 function hopFlavourContribution(bt, vol, use, amount) {
197 var result; 222 var result;
198 223
199 if ((use == "First Wort") || (use == "First wort")) { 224 if (use == 1) { // First wort
200 result = 0.15; // assume 15% flavourcontribution for fwh 225 result = 0.15; // assume 15% flavourcontribution for fwh
201 } else if (bt > 50) { 226 } else if (bt > 50) {
202 result = 0.10; // assume 10% flavourcontribution as a minimum 227 result = 0.10; // assume 10% flavourcontribution as a minimum
203 } else { 228 } else {
204 result = 15.25 / (6 * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((bt - 21) /6, 2)); 229 result = 15.25 / (6 * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((bt - 21) /6, 2));
215 240
216 if (bt > 20) { 241 if (bt > 20) {
217 result = 0; 242 result = 0;
218 } else if (bt > 7.5) { 243 } else if (bt > 7.5) {
219 result = 10.03 / (4 * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((bt - 7.5) /4, 2)); 244 result = 10.03 / (4 * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((bt - 7.5) /4, 2));
220 } else if (use == "Boil") { 245 } else if (use == 2) { // Boil
221 result = 1; 246 result = 1;
222 } else if (use == "Aroma") { 247 } else if (use == 3) { // Aroma
223 result = 1.2; 248 result = 1.2;
224 } else if (use == "Whirlpool") { 249 } else if (use == 4) { // Whirlpool
225 result = 1.2; 250 result = 1.2;
226 } else if ((use == "Dry Hop") || (use == "Dry hop")) { 251 } else if (use == 5) { // Drt hop
227 result = 1.33; 252 result = 1.33;
228 } 253 }
229 result = (result * amount * 1000) / vol; 254 result = (result * amount * 1000) / vol;
230 // console.log("hopAromaContribution("+bt+","+vol+","+use+","+amount+"): "+result); 255 // console.log("hopAromaContribution("+bt+","+vol+","+use+","+amount+"): "+result);
231 return result; 256 return result;
255 280
256 function calcSVG() { 281 function calcSVG() {
257 var rows = $('#yeastGrid').jqxGrid('getrows'); 282 var rows = $('#yeastGrid').jqxGrid('getrows');
258 for (var i = 0; i < rows.length; i++) { 283 for (var i = 0; i < rows.length; i++) {
259 var row = rows[i]; 284 var row = rows[i];
260 if (row.y_use == "Primary") 285 if (row.y_use == 0) // Primary
261 svg = parseFloat(row.y_attenuation); 286 svg = parseFloat(row.y_attenuation);
262 } 287 }
263 } 288 }
264 289
265 function calcSGendMash() { 290 function calcSGendMash() {
269 var gs = 0; // Grain absorbtion 294 var gs = 0; // Grain absorbtion
270 var rows = $('#mashGrid').jqxGrid('getrows'); 295 var rows = $('#mashGrid').jqxGrid('getrows');
271 for (var i = 0; i < rows.length; i++) { 296 for (var i = 0; i < rows.length; i++) {
272 var row = rows[i]; 297 var row = rows[i];
273 // console.log("step " + i + " " + row.step_name + " " + row.step_type); 298 // console.log("step " + i + " " + row.step_name + " " + row.step_type);
274 if (row.step_type == 'Infusion') 299 if (row.step_type == 0) // Infusion
275 mvol += parseFloat(row.step_infuse_amount); 300 mvol += parseFloat(row.step_infuse_amount);
276 } 301 }
277 if (mvol > 0) { 302 if (mvol > 0) {
278 // console.log("mash volume: " + mvol); 303 // console.log("mash volume: " + mvol);
279 var rows = $('#fermentableGrid').jqxGrid('getrows'); 304 var rows = $('#fermentableGrid').jqxGrid('getrows');
280 for (var i = 0; i < rows.length; i++) { 305 for (var i = 0; i < rows.length; i++) {
281 var row = rows[i]; 306 var row = rows[i];
282 if (row.f_added == "Mash") { 307 if (row.f_added == 0) { // Mash
283 var d = row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); 308 var d = row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100);
284 mvol += row.f_amount * row.f_moisture / 100; 309 mvol += row.f_amount * row.f_moisture / 100;
285 gs += my_grain_absorbtion * row.f_amount; 310 gs += my_grain_absorbtion * row.f_amount;
286 s += d; 311 s += d;
287 } 312 }
334 var found = false; 359 var found = false;
335 for (var i = 0; i < rows.length; i++) { 360 for (var i = 0; i < rows.length; i++) {
336 var row = rows[i]; 361 var row = rows[i];
337 if (row.m_name == name) { 362 if (row.m_name == name) {
338 found = true; 363 found = true;
339 $("#miscGrid").jqxGrid('setcellvalue', i, 'm_weight', amount);
340 $("#miscGrid").jqxGrid('setcellvalue', i, 'm_amount', amount / 1000); 364 $("#miscGrid").jqxGrid('setcellvalue', i, 'm_amount', amount / 1000);
341 break; 365 break;
342 } 366 }
343 } 367 }
344 if (! found) { 368 if (! found) {
353 row["m_amount"] = amount / 1000; 377 row["m_amount"] = amount / 1000;
354 row["m_cost"] = record.cost; 378 row["m_cost"] = record.cost;
355 row["m_type"] = record.type; 379 row["m_type"] = record.type;
356 row["m_use_use"] = record.use_use; 380 row["m_use_use"] = record.use_use;
357 row["m_time"] = 0; 381 row["m_time"] = 0;
358 row["m_weight"] = amount;
359 row["m_amount_is_weight"] = record.amount_is_weight; 382 row["m_amount_is_weight"] = record.amount_is_weight;
383 row["m_inventory"] = record.inventory;
384 row["m_avail"] = 1;
360 var commit = $("#miscGrid").jqxGrid('addrow', null, row); 385 var commit = $("#miscGrid").jqxGrid('addrow', null, row);
361 } 386 }
362 } 387 }
363 } 388 }
364 }); 389 });
426 var Result = ZRA(pHZ) * parseFloat($("#wg_amount").jqxNumberInput('decimal')); 451 var Result = ZRA(pHZ) * parseFloat($("#wg_amount").jqxNumberInput('decimal'));
427 // proton deficit for the grist 452 // proton deficit for the grist
428 var rows = $('#fermentableGrid').jqxGrid('getrows'); 453 var rows = $('#fermentableGrid').jqxGrid('getrows');
429 for (var i = 0; i < rows.length; i++) { 454 for (var i = 0; i < rows.length; i++) {
430 var row = rows[i]; 455 var row = rows[i];
431 if (row.f_added == 'Mash' && row.f_graintype != 'No malt') { 456 if (row.f_added == 0 && row.f_graintype != 6) { // Added == Mash && graintype != No Malt
432 // Check if acid is required 457 // Check if acid is required
433 var C1 = 0; 458 var C1 = 0;
434 if ((row.f_di_ph != 5.7) && ((row.f_acid_to_ph_57 < - 0.1) || (row.f_acid_to_ph_57 > 0.1))) { 459 if ((row.f_di_ph != 5.7) && ((row.f_acid_to_ph_57 < - 0.1) || (row.f_acid_to_ph_57 > 0.1))) {
435 C1 = row.f_acid_to_ph_57 / (row.f_di_ph - 5.7); 460 C1 = row.f_acid_to_ph_57 / (row.f_di_ph - 5.7);
436 } else { 461 } else {
437 // If the acid_to_ph_5.7 is unknown from the maltster, guess the required acid. 462 // If the acid_to_ph_5.7 is unknown from the maltster, guess the required acid.
438 var ebc = row.f_color; 463 var ebc = row.f_color;
439 switch (row.f_graintype) { 464 switch (row.f_graintype) {
440 case 'Base': 465 case 0: // Base, Special, Kilned
441 case 'Special': 466 case 3:
442 case 'Kilned': C1 = 0.014 * ebc - 34.192; 467 case 5: C1 = 0.014 * ebc - 34.192;
443 break; 468 break;
444 case 'Crystal': C1 = -0.0597 * ebc - 32.457; 469 case 2: C1 = -0.0597 * ebc - 32.457; // Crystal
445 break; 470 break;
446 case 'Roast': C1 = 0.0107 * ebc - 54.768; 471 case 1: C1 = 0.0107 * ebc - 54.768; // Roast
447 break; 472 break;
448 case 'Sour': C1 = -149; 473 case 4: C1 = -149; // Sour malt
449 break; 474 break;
450 } 475 }
451 } 476 }
452 x = C1 * (pHZ - row.f_di_ph); // AcidRequired(ZpH) 477 x = C1 * (pHZ - row.f_di_ph); // AcidRequired(ZpH)
453 Result += x * row.f_amount; 478 Result += x * row.f_amount;
454 } 479 }
474 return pH; 499 return pH;
475 } 500 }
476 501
477 function GetAcidSpecs(AT) { 502 function GetAcidSpecs(AT) {
478 switch(AT) { 503 switch(AT) {
479 case 'Melkzuur': return { 504 case 0: return { // Melkzuur
480 pK1: 3.08, 505 pK1: 3.08,
481 pK2: 20, 506 pK2: 20,
482 pK3: 20, 507 pK3: 20,
483 MolWt: 90.08, 508 MolWt: 90.08,
484 AcidSG: 1214, 509 AcidSG: 1214,
485 AcidPrc: 0.88 510 AcidPrc: 0.88
486 }; 511 };
487 case 'Zoutzuur': return { 512 case 1: return { // Zoutzuur
488 pK1: -10, 513 pK1: -10,
489 pK2: 20, 514 pK2: 20,
490 pK3: 20, 515 pK3: 20,
491 MolWt: 36.46, 516 MolWt: 36.46,
492 AcidSG: 1142, 517 AcidSG: 1142,
493 AcidPrc: 0.28 518 AcidPrc: 0.28
494 }; 519 };
495 case 'Fosforzuur': return { 520 case 2: return { // Fosforzuur
496 pK1: 2.12, 521 pK1: 2.12,
497 pK2: 7.20, 522 pK2: 7.20,
498 pK3: 12.44, 523 pK3: 12.44,
499 MolWt: 98.00, 524 MolWt: 98.00,
500 AcidSG: 1170, 525 AcidSG: 1170,
501 AcidPrc: 0.25 526 AcidPrc: 0.25
502 }; 527 };
503 case 'Zwavelzuur': return { 528 case 3: return { // Zwavelzuur
504 pK1: -10, 529 pK1: -10,
505 pK2: 1.92, 530 pK2: 1.92,
506 pK3: 20, 531 pK3: 20,
507 MolWt: 98.07, 532 MolWt: 98.07,
508 AcidSG: 1700, 533 AcidSG: 1700,
509 AcidPrc: 0.93 534 AcidPrc: 0.93
510 }; 535 };
511 } 536 }
512 } 537 }
513 538
514 539
515 function calcWater() { 540 function calcWater() {
525 var sulfate = 0; 550 var sulfate = 0;
526 var ph = 0; 551 var ph = 0;
527 var RA = 0; 552 var RA = 0;
528 var frac = 0; 553 var frac = 0;
529 var TpH = 0; 554 var TpH = 0;
530 var Acid = 0;
531 var Acidmg = 0;
532 var protonDeficit = 0; 555 var protonDeficit = 0;
533 556
534 if (dataRecord.w1_name == "") { 557 if (dataRecord.w1_name == "") {
535 return; 558 return;
536 } 559 }
600 RA = 2 * parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCl / MMCaCl2 + 623 RA = 2 * parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCl / MMCaCl2 +
601 parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMCl / MMNaCl; 624 parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMCl / MMNaCl;
602 chloride += 1000 * RA / liters; 625 chloride += 1000 * RA / liters;
603 // Einde noot. 626 // Einde noot.
604 627
605 if ($("#wa_acid_name").val() == "") { 628 if ($("#wa_acid_name").val() < 0 || $("#wa_acid_name").val() > 3) {
606 $("#wa_acid_name").val('Melkzuur'); 629 console.log("fix wa_acid_name");
607 last_acid = 'Melkzuur'; 630 $("#wa_acid_name").val(0);
608 } 631 dataRecord.wa_acid_name = 0;
609 if ($("#wa_base_name").val() == "") { 632 }
610 $("#wa_base_name").val('NaHCO3'); 633 if (last_acid == '')
611 last_base = 'NaHCO3'; 634 last_acid = AcidTypeData[$("#wa_acid_name").val()].nl;
612 } 635
613 636 if ($("#wa_base_name").val() < 0 || $("#wa_base_name").val() > 3) {
614 var AT = $("#wa_acid_name").val(); 637 console.log("fix wa_base_name");
615 var BT = $("#wa_base_name").val(); 638 $("#wa_base_name").val(0);
639 dataRecord.wa_base_name = 0;
640 }
641 if (last_base == '')
642 last_base = BaseTypeData[$("#wa_base_name").val()].nl;
643
644 var AT = dataRecord.wa_acid_name;
645 var BT = dataRecord.wa_base_name;
616 646
617 var result = GetAcidSpecs(AT); 647 var result = GetAcidSpecs(AT);
618 var pK1 = result.pK1; 648 var pK1 = result.pK1;
619 var pK2 = result.pK2; 649 var pK2 = result.pK2;
620 var pK3 = result.pK3; 650 var pK3 = result.pK3;
638 if (parseFloat($("#wa_acid_perc").jqxNumberInput('decimal')) == 0) 668 if (parseFloat($("#wa_acid_perc").jqxNumberInput('decimal')) == 0)
639 $("#wa_acid_perc").val(AcidPrc); 669 $("#wa_acid_perc").val(AcidPrc);
640 Acid = Acid * AcidPrc / (parseFloat($("#wa_acid_perc").jqxNumberInput('decimal')) / 100); // ml 670 Acid = Acid * AcidPrc / (parseFloat($("#wa_acid_perc").jqxNumberInput('decimal')) / 100); // ml
641 console.log("Final ml: "+Acid); 671 console.log("Final ml: "+Acid);
642 $("#wa_acid").val(Math.round(Acid * 100) / 100); 672 $("#wa_acid").val(Math.round(Acid * 100) / 100);
643 setWaterAgent(AT, Math.round(Acid * 100) / 100); 673 setWaterAgent(AcidTypeData[AT].nl, Math.round(Acid * 100) / 100);
644 674
645 bicarbonate = bicarbonate - protonDeficit * frac / liters; 675 bicarbonate = bicarbonate - protonDeficit * frac / liters;
646 total_alkalinity = bicarbonate * 50 / 61; 676 total_alkalinity = bicarbonate * 50 / 61;
647 } else if (protonDeficit < 0) { //Add base 677 } else if (protonDeficit < 0) { //Add base
648 $("#wa_acid").val(0); 678 $("#wa_acid").val(0);
651 var r2d = Math.pow(10, (TpH - 10.38)); 681 var r2d = Math.pow(10, (TpH - 10.38));
652 var f1d = 1 / (1 + r1d + r1d * r2d); 682 var f1d = 1 / (1 + r1d + r1d * r2d);
653 var f2d = f1d * r1d; 683 var f2d = f1d * r1d;
654 var f3d = f2d * r2d; 684 var f3d = f2d * r2d;
655 switch (BT) { 685 switch (BT) {
656 case 'NaHCO3': RA = -protonDeficit / (f1d - f3d); //mmol totaal 686 case 0: RA = -protonDeficit / (f1d - f3d); // Sodiumbicarbonate, mmol totaal
657 RA = RA * MMNaHCO3/1000; //gram 687 RA = RA * MMNaHCO3/1000; //gram
658 $("#wa_base").val(Math.round(RA * 100) / 100); 688 $("#wa_base").val(Math.round(RA * 100) / 100);
659 setWaterAgent(BT, Math.round(RA * 100) / 100); 689 setWaterAgent('NaHCO3', Math.round(RA * 100) / 100);
660 if (liters > 0) { 690 if (liters > 0) {
661 // Na 691 // Na
662 RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl + 692 RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl +
663 parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMNa / MMNaHCO3; 693 parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMNa / MMNaHCO3;
664 RA = 1000 * RA / liters; 694 RA = 1000 * RA / liters;
665 sodium = wg_sodium + RA; 695 sodium = wg_sodium + RA;
666 // HCO3 696 // HCO3
667 RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNaHCO3; 697 RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNaHCO3;
668 RA = 1000 * RA / liters; 698 RA = 1000 * RA / liters;
669 bicarbonate = wg_bicarbonate + RA; 699 bicarbonate = wg_bicarbonate + RA;
670 total_alkalinity = bicarbonate * 50 / 61; 700 total_alkalinity = bicarbonate * 50 / 61;
671 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); 701 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
672 } 702 }
673 break; 703 break;
674 case 'Na2CO3': RA = -protonDeficit / (2 * f1d + f2d); //mmol totaal 704 case 1: RA = -protonDeficit / (2 * f1d + f2d); // Sodiumcarbonate, mmol totaal
675 RA = RA * MMNa2CO3/1000; //gram 705 RA = RA * MMNa2CO3/1000; //gram
676 $("#wa_base").val(Math.round(RA * 100) / 100); 706 $("#wa_base").val(Math.round(RA * 100) / 100);
677 setWaterAgent(BT, Math.round(RA * 100) / 100); 707 setWaterAgent('Na2CO3', Math.round(RA * 100) / 100);
678 if (liters > 0) { 708 if (liters > 0) {
679 RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl + 709 RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl +
680 parseFloat($("#wa_base").jqxNumberInput('decimal')) * 2 * MMNa / MMNa2CO3; 710 parseFloat($("#wa_base").jqxNumberInput('decimal')) * 2 * MMNa / MMNa2CO3;
681 RA = 1000 * RA / liters; 711 RA = 1000 * RA / liters;
682 sodium = wg_sodium + RA; 712 sodium = wg_sodium + RA;
683 // HCO3 713 // HCO3
684 RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNa2CO3; 714 RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNa2CO3;
685 RA = 1000 * RA / liters; 715 RA = 1000 * RA / liters;
686 bicarbonate = wg_bicarbonate + RA; 716 bicarbonate = wg_bicarbonate + RA;
687 total_alkalinity = bicarbonate * 50 / 61; 717 total_alkalinity = bicarbonate * 50 / 61;
688 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); 718 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
689 } 719 }
690 break; 720 break;
691 case 'CaCO3': RA = -protonDeficit * (f1d - f3d); //mmol totaal 721 case 2: RA = -protonDeficit * (f1d - f3d); // Calciumcarbonate, mmol totaal
692 RA = RA * MMCaCO3/1000; //gram 722 RA = RA * MMCaCO3/1000; //gram
693 //but only 1/3 is effective, so add 3 times as much 723 //but only 1/3 is effective, so add 3 times as much
694 RA = 3 * RA; 724 RA = 3 * RA;
695 $("#wa_base").val(Math.round(RA * 100) / 100); 725 $("#wa_base").val(Math.round(RA * 100) / 100);
696 setWaterAgent(BT, Math.round(RA * 100) / 100); 726 setWaterAgent('CaCO3', Math.round(RA * 100) / 100);
697 if (liters > 0) { 727 if (liters > 0) {
698 //Bicarbonate 728 //Bicarbonate
699 RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) / 3 * MMHCO3 / MMCaCO3; 729 RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) / 3 * MMHCO3 / MMCaCO3;
700 RA = 1000 * RA / liters; 730 RA = 1000 * RA / liters;
701 bicarbonate = wg_bicarbonate + RA; 731 bicarbonate = wg_bicarbonate + RA;
702 total_alkalinity = bicarbonate * 50 / 61; 732 total_alkalinity = bicarbonate * 50 / 61;
703 //Ca precipitates out as Ca10(PO4)6(OH)2 733 //Ca precipitates out as Ca10(PO4)6(OH)2
704 RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 + 734 RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 +
705 parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4 + 735 parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4 +
706 parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMCa / MMCaCO3; 736 parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMCa / MMCaCO3;
707 RA = 1000 * RA / liters; 737 RA = 1000 * RA / liters;
708 calcium = wg_calcium + RA; 738 calcium = wg_calcium + RA;
709 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); 739 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
710 } 740 }
711 break; 741 break;
712 case 'Ca(OH)2': RA = -protonDeficit / 19.3; // g 742 case 3: RA = -protonDeficit / 19.3; // Calciumhydroxide
713 $("#wa_base").val(Math.round(RA * 100) / 100); 743 $("#wa_base").val(Math.round(RA * 100) / 100);
714 setWaterAgent(BT, Math.round(RA * 100) / 100); 744 setWaterAgent('Ca(OH)2', Math.round(RA * 100) / 100);
715 if (liters > 0) { 745 if (liters > 0) {
716 // Bicarbonate 746 // Bicarbonate
717 RA = -protonDeficit / liters; 747 RA = -protonDeficit / liters;
718 total_alkalinity = wg_total_alkalinity + RA; 748 total_alkalinity = wg_total_alkalinity + RA;
719 bicarbonate = total_alkalinity * 61 / 50; 749 bicarbonate = total_alkalinity * 61 / 50;
720 // Calcium 750 // Calcium
721 RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 + 751 RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 +
722 parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4 + 752 parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4 +
723 parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMCa / MMCaOH2; 753 parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMCa / MMCaOH2;
724 RA = 1000 * RA / liters; 754 RA = 1000 * RA / liters;
725 calcium = wg_calcium + RA; 755 calcium = wg_calcium + RA;
726 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); 756 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
727 } 757 }
728 break; 758 break;
729 } 759 }
730 } 760 }
731 ph = TpH; 761 ph = TpH;
732 $('#wb_ph').val(Math.round(ph * 10) / 10); 762 $('#wb_ph').val(Math.round(ph * 10) / 10);
733 $('#est_mash_ph').val(Math.round(ph * 10) / 10); 763 $('#est_mash_ph').val(Math.round(ph * 10) / 10);
735 console.log("calc_acid no"); 765 console.log("calc_acid no");
736 // First add base salts 766 // First add base salts
737 if (parseFloat($("#wa_base").jqxNumberInput('decimal')) > 0) { 767 if (parseFloat($("#wa_base").jqxNumberInput('decimal')) > 0) {
738 if (liters > 0) { 768 if (liters > 0) {
739 switch (BT) { 769 switch (BT) {
740 case 'NaHCO3': // Na 770 case 0: // Sodiumbicarbonate, Na
741 RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl + 771 RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl +
742 parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMNa / MMNaHCO3; 772 parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMNa / MMNaHCO3;
743 RA = 1000 * RA / liters; 773 RA = 1000 * RA / liters;
744 sodium = wg_sodium + RA; 774 sodium = wg_sodium + RA;
745 // HCO3 775 // HCO3
746 RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNaHCO3; 776 RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNaHCO3;
747 RA = 1000 * RA / liters; 777 RA = 1000 * RA / liters;
748 bicarbonate = wg_bicarbonate + RA; 778 bicarbonate = wg_bicarbonate + RA;
749 total_alkalinity = bicarbonate * 50 / 61; 779 total_alkalinity = bicarbonate * 50 / 61;
750 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); 780 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
751 break; 781 break;
752 case 'Na2CO3': RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl + 782 case 1: // Sodiumcarbonate
753 parseFloat($("#wa_base").jqxNumberInput('decimal')) * 2 * MMNa / MMNa2CO3; 783 RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl +
754 RA = 1000 * RA / liters; 784 parseFloat($("#wa_base").jqxNumberInput('decimal')) * 2 * MMNa / MMNa2CO3;
755 sodium = wg_sodium + RA; 785 RA = 1000 * RA / liters;
756 // HCO3 786 sodium = wg_sodium + RA;
757 RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNa2CO3; 787 // HCO3
758 RA = 1000 * RA / liters; 788 RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNa2CO3;
759 bicarbonate = wg_bicarbonate + RA; 789 RA = 1000 * RA / liters;
760 total_alkalinity = bicarbonate * 50 / 61; 790 bicarbonate = wg_bicarbonate + RA;
761 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); 791 total_alkalinity = bicarbonate * 50 / 61;
762 break; 792 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
763 case 'CaCO3': // Bicarbonate 793 break;
764 RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) / 3 * MMHCO3 / MMCaCO3; 794 case 2: // Calciumcarbonate: Bicarbonate
765 RA = 1000 * RA / liters; 795 RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) / 3 * MMHCO3 / MMCaCO3;
766 bicarbonate = wg_bicarbonate + RA; 796 RA = 1000 * RA / liters;
767 total_alkalinity = bicarbonate * 50 / 61; 797 bicarbonate = wg_bicarbonate + RA;
768 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); 798 total_alkalinity = bicarbonate * 50 / 61;
769 // Ca 799 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
770 RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 + 800 // Ca
771 parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4 + 801 RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 +
772 parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMCa / MMCaCO3; 802 parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4 +
773 RA = 1000 * RA / liters; 803 parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMCa / MMCaCO3;
774 calcium = wg_calcium + RA; 804 RA = 1000 * RA / liters;
775 break; 805 calcium = wg_calcium + RA;
806 break;
776 } 807 }
777 } 808 }
778 } 809 }
779 810
780 TpH = parseFloat(dataRecord.mash_ph); 811 TpH = parseFloat(dataRecord.mash_ph);
816 $('#wb_ph').val(Math.round(ph * 10) / 10); 847 $('#wb_ph').val(Math.round(ph * 10) / 10);
817 $('#est_mash_ph').val(Math.round(ph * 10) / 10); 848 $('#est_mash_ph').val(Math.round(ph * 10) / 10);
818 } 849 }
819 } 850 }
820 851
821 if ((AT == 'Zwavelzuur') && (liters > 0)) { 852 if ((AT == 3) && (liters > 0)) { // Sulfuctic / Zwavelzuur
822 RA = parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMSO4 / MMCaSO4 + 853 RA = parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMSO4 / MMCaSO4 +
823 parseFloat($("#wa_mgso4").jqxNumberInput('decimal')) * MMSO4 / MMMgSO4 + 854 parseFloat($("#wa_mgso4").jqxNumberInput('decimal')) * MMSO4 / MMMgSO4 +
824 Acidmg / 1000 * MMSO4 / (MMSO4 + 2); 855 Acidmg / 1000 * MMSO4 / (MMSO4 + 2);
825 RA = 1000 * RA / liters; 856 RA = 1000 * RA / liters;
826 sulfate = wg_sulfate + RA; // Not add to sulfate?? 857 sulfate = wg_sulfate + RA; // Not add to sulfate??
827 } else if ((AT == 'Zoutzuur') && (liters > 0)) { 858 } else if ((AT == 1) && (liters > 0)) { // Hydrochloric, Zoutzuur
828 RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCl / MMCaCl2 + 859 RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCl / MMCaCl2 +
829 parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMCl / MMNaCl + 860 parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMCl / MMNaCl +
830 Acidmg / 1000 * MMCl / (MMCL + 1); 861 Acidmg / 1000 * MMCl / (MMCl + 1);
831 RA = 1000 * RA / liters; 862 RA = 1000 * RA / liters;
832 chloride = wg_chloride + RA; 863 chloride = wg_chloride + RA;
833 } 864 }
834 865
835 // 2:1 Sulfate to Chroride IPA's, Pale Ales. 866 // 2:1 Sulfate to Chroride IPA's, Pale Ales.
894 // Code from BrewBuddy/Brouwhulp, who got it from http://www.brewery.org/brewery/library/Acidi0,00fWaterAJD0497.html 925 // Code from BrewBuddy/Brouwhulp, who got it from http://www.brewery.org/brewery/library/Acidi0,00fWaterAJD0497.html
895 var TargetpH = dataRecord.sparge_ph; 926 var TargetpH = dataRecord.sparge_ph;
896 var Source_pH = dataRecord.w1_ph; 927 var Source_pH = dataRecord.w1_ph;
897 var Source_alkalinity = dataRecord.w1_total_alkalinity; 928 var Source_alkalinity = dataRecord.w1_total_alkalinity;
898 // Select watersource or fallback to the first source. 929 // Select watersource or fallback to the first source.
899 if (dataRecord.sparge_source == 'Bron 2') { 930 if (dataRecord.sparge_source == 1) { // Source 2
900 if (dataRecord.w2_ph > 0.0) { 931 if (dataRecord.w2_ph > 0.0) {
901 Source_pH = dataRecord.w2_ph; 932 Source_pH = dataRecord.w2_ph;
902 Source_alkalinity = dataRecord.w2_total_alkalinity; 933 Source_alkalinity = dataRecord.w2_total_alkalinity;
903 } else { 934 } else {
904 dataRecord.sparge_source = 'Bron 1'; 935 dataRecord.sparge_source = 0; // Source 1
905 $("#sparge_source").val('Bron 1'); 936 $("#sparge_source").val(0);
906 } 937 }
907 } else if (dataRecord.sparge_source == 'Gemengd') { 938 } else if (dataRecord.sparge_source == 2) { // Mixed
908 if (dataRecord.w2_ph > 0.0) { 939 if (dataRecord.w2_ph > 0.0) {
909 Source_pH = parseFloat($("#wg_ph").jqxNumberInput('decimal')); 940 Source_pH = parseFloat($("#wg_ph").jqxNumberInput('decimal'));
910 Source_alkalinity = parseFloat($("#wg_total_alkalinity").jqxNumberInput('decimal')); 941 Source_alkalinity = parseFloat($("#wg_total_alkalinity").jqxNumberInput('decimal'));
911 } else { 942 } else {
912 dataRecord.sparge_source = 'Bron 1'; 943 dataRecord.sparge_source = 0;
913 $("#sparge_source").val('Bron 1'); 944 $("#sparge_source").val(0);
914 } 945 }
915 } 946 }
916 947
917 console.log("calcSparge() target pH: "+TargetpH+" Source: "+Source_pH+" alkalinity: "+Source_alkalinity); 948 console.log("calcSparge() target pH: "+TargetpH+" Source: "+Source_pH+" alkalinity: "+Source_alkalinity);
918 949
945 var f2g = r1g / dg; 976 var f2g = r1g / dg;
946 var f3g = r1g * r2g / dg; 977 var f3g = r1g * r2g / dg;
947 978
948 //Step 6. Use these to compute the milliequivalents acid required per liter (mEq/L) 979 //Step 6. Use these to compute the milliequivalents acid required per liter (mEq/L)
949 var Acid = alkalinity * ((f1g-f1)+(f3-f3g)) + Math.pow(10, -TargetpH) - Math.pow(10, -Source_pH); //mEq/l 980 var Acid = alkalinity * ((f1g-f1)+(f3-f3g)) + Math.pow(10, -TargetpH) - Math.pow(10, -Source_pH); //mEq/l
950 981 if (dataRecord.sparge_acid_type < 0 || dataRecord.sparge_acid_type > 3) {
951 if ($("#sparge_acid_type").val() == "") { 982 dataRecord.sparge_acid_type = 0;
952 $("#sparge_acid_type").val('Melkzuur'); 983 $("#sparge_acid_type").val(0);
953 dataRecord.sparge_acid_type = 'Melkzuur';
954 } 984 }
955 var AT = dataRecord.sparge_acid_type; 985 var AT = dataRecord.sparge_acid_type;
956 var result = GetAcidSpecs(AT); 986 var result = GetAcidSpecs(AT);
957 var pK1 = result.pK1; 987 var pK1 = result.pK1;
958 var pK2 = result.pK2; 988 var pK2 = result.pK2;
1011 0.000362999168 * T * T - 0.064872987645 * T + 1.641145175049)) / 1041 0.000362999168 * T * T - 0.064872987645 * T + 1.641145175049)) /
1012 (0.00000498031 * Math.pow(T, 4) - 0.00024358267 * Math.pow(T, 3) + 1042 (0.00000498031 * Math.pow(T, 4) - 0.00024358267 * Math.pow(T, 3) +
1013 0.00385867329 * T * T - 0.05671206825 * T + 1.53801423376); 1043 0.00385867329 * T * T - 0.05671206825 * T + 1.53801423376);
1014 } 1044 }
1015 1045
1016 function getSFactor(Sugar) {
1017 switch (Sugar) {
1018 case 'Kristalsuiker': return 1;
1019 case 'Glucose/dextrose': return 1.16;
1020 case 'Honing': return 1.28;
1021 case 'Moutextract': return 1.74;
1022 case 'Melasse': return 3.83;
1023 }
1024 return 1;
1025 }
1026
1027 function calcCarbonation() { 1046 function calcCarbonation() {
1028 1047
1029 var TSec = dataRecord.secondary_temp; // End fermentation temperature. 1048 var TSec = dataRecord.secondary_temp; // End fermentation temperature.
1030 if (TSec < 1) 1049 if (TSec < 1)
1031 TSec = dataRecord.primary_end_temp; // Fallback 1050 TSec = dataRecord.primary_end_temp; // Fallback
1036 var ABV = abvol(dataRecord.brew_fermenter_sg, parseFloat($("#est_fg").jqxNumberInput('decimal'))); 1055 var ABV = abvol(dataRecord.brew_fermenter_sg, parseFloat($("#est_fg").jqxNumberInput('decimal')));
1037 else 1056 else
1038 var ABV = abvol(dataRecord.brew_fermenter_sg, dataRecord.fg); 1057 var ABV = abvol(dataRecord.brew_fermenter_sg, dataRecord.fg);
1039 1058
1040 // Bottles 1059 // Bottles
1041 var SFactor = getSFactor(dataRecord.bottle_priming_sugar); 1060 var SFactor = PrimingSugarData[dataRecord.bottle_priming_sugar].factor;
1042 var Amount = CarbCO2toS(dataRecord.bottle_carbonation, TSec, SFactor); 1061 var Amount = CarbCO2toS(dataRecord.bottle_carbonation, TSec, SFactor);
1043 dataRecord.bottle_priming_amount = Amount; 1062 dataRecord.bottle_priming_amount = Amount;
1044 $("#bottle_priming_amount").val(Math.round(dataRecord.bottle_priming_amount * 10) / 10); 1063 $("#bottle_priming_amount").val(Math.round(dataRecord.bottle_priming_amount * 10) / 10);
1045 $("#bottle_priming_total").val(Math.round(dataRecord.bottle_amount * dataRecord.bottle_priming_amount * 10) / 10); 1064 $("#bottle_priming_total").val(Math.round(dataRecord.bottle_amount * dataRecord.bottle_priming_amount * 10) / 10);
1046 $("#bottle_abv").val(Math.round((ABV + Amount * 0.47 / 7.907) * 10) / 10); 1065 $("#bottle_abv").val(Math.round((ABV + Amount * 0.47 / 7.907) * 10) / 10);
1047 1066
1048 // Kegs 1067 // Kegs
1049 SFactor = getSFactor(dataRecord.keg_priming_sugar); 1068 SFactor = PrimingSugarData[dataRecord.keg_priming_sugar].factor;
1050 Amount = CarbCO2toS(dataRecord.keg_carbonation, TSec, SFactor); 1069 Amount = CarbCO2toS(dataRecord.keg_carbonation, TSec, SFactor);
1051 var Pressure = CarbCO2ToPressure(dataRecord.keg_carbonation, dataRecord.keg_carbonation_temp); 1070 var Pressure = CarbCO2ToPressure(dataRecord.keg_carbonation, dataRecord.keg_carbonation_temp);
1052 if (Pressure < 0) 1071 if (Pressure < 0)
1053 Pressure = 0; 1072 Pressure = 0;
1054 dataRecord.keg_pressure = Pressure; 1073 dataRecord.keg_pressure = Pressure;
1105 dataRecord.w2_amount = newval; 1124 dataRecord.w2_amount = newval;
1106 console.log("new: "+event.args.value+" w1: "+dataRecord.w1_amount+" w2: "+dataRecord.w2_amount); 1125 console.log("new: "+event.args.value+" w1: "+dataRecord.w1_amount+" w2: "+dataRecord.w2_amount);
1107 calcWater(); 1126 calcWater();
1108 }); 1127 });
1109 $('#wa_cacl2').on('change', function (event) { 1128 $('#wa_cacl2').on('change', function (event) {
1110 setWaterAgent('CaCl2', event.args.value); 1129 if (event.args) {
1111 calcWater(); 1130 setWaterAgent('CaCl2', 0); // This can prevent double entries.
1131 setWaterAgent('CaCl2', event.args.value);
1132 calcWater();
1133 }
1112 }); 1134 });
1113 $('#wa_caso4').on('change', function (event) { 1135 $('#wa_caso4').on('change', function (event) {
1114 setWaterAgent('CaSO4', event.args.value); 1136 if (event.args) {
1115 calcWater(); 1137 setWaterAgent('CaSO4', 0);
1138 setWaterAgent('CaSO4', event.args.value);
1139 calcWater();
1140 }
1116 }); 1141 });
1117 $('#wa_mgso4').on('change', function (event) { 1142 $('#wa_mgso4').on('change', function (event) {
1118 setWaterAgent('MgSO4', event.args.value); 1143 if (event.args) {
1119 calcWater(); 1144 setWaterAgent('MgSO4', 0);
1145 setWaterAgent('MgSO4', event.args.value);
1146 calcWater();
1147 }
1120 }); 1148 });
1121 $('#wa_nacl').on('change', function (event) { 1149 $('#wa_nacl').on('change', function (event) {
1122 setWaterAgent('NaCl', event.args.value); 1150 if (event.args) {
1123 calcWater(); 1151 setWaterAgent('NaCl', 0);
1152 setWaterAgent('NaCl', event.args.value);
1153 calcWater();
1154 }
1124 }); 1155 });
1125 $('#wa_base_name').on('change', function (event) { 1156 $('#wa_base_name').on('change', function (event) {
1126 setWaterAgent(last_base, 0); 1157 if (event.args) {
1127 last_base = event.args.item.value; 1158 var index = event.args.index;
1128 setWaterAgent(last_base, parseFloat($("#wa_base").jqxNumberInput('decimal'))); 1159 console.log("wa_base_name "+index);
1129 calcWater(); 1160 setWaterAgent(last_base, 0);
1161 last_base = BaseTypeData[index].nl;
1162 setWaterAgent(last_base, parseFloat($("#wa_base").jqxNumberInput('decimal')));
1163 dataRecord.wa_base_name = index;
1164 calcWater();
1165 }
1130 }); 1166 });
1131 $('#wa_base').on('change', function (event) { 1167 $('#wa_base').on('change', function (event) {
1132 setWaterAgent($("#wa_base_name").val(), parseFloat(event.args.value)); 1168 var name = BaseTypeData[$("#wa_base_name").val()].nl;
1169 setWaterAgent(name, parseFloat(event.args.value));
1133 calcWater(); 1170 calcWater();
1134 }); 1171 });
1135 $('#wa_acid_name').on('change', function (event) { 1172 $('#wa_acid_name').on('change', function (event) {
1136 setWaterAgent(last_acid, 0); 1173 if (event.args) {
1137 last_acid = event.args.item.value; 1174 var index = event.args.index;
1138 setWaterAgent(last_acid, parseFloat($("#wa_acid").jqxNumberInput('decimal'))); 1175 console.log("wa_acid_name "+index);
1139 calcWater(); 1176 setWaterAgent(last_acid, 0);
1177 last_acid = AcidTypeData[index].nl;
1178 setWaterAgent(last_acid, parseFloat($("#wa_acid").jqxNumberInput('decimal')));
1179 dataRecord.wa_acid_name = index;
1180 calcWater();
1181 }
1140 }); 1182 });
1141 $('#wa_acid').on('change', function (event) { 1183 $('#wa_acid').on('change', function (event) {
1142 setWaterAgent($("#wa_acid_name").val(), parseFloat(event.args.value)); 1184 var name = AcidTypeData[$("#wa_acid_name").val()].nl;
1185 setWaterAgent(name, parseFloat(event.args.value));
1143 calcWater(); 1186 calcWater();
1144 }); 1187 });
1145 $('#wa_acid_perc').on('change', function (event) { calcWater(); }); 1188 $('#wa_acid_perc').on('change', function (event) { calcWater(); });
1146 1189
1147 $('#color_method').on('change', function (event) { calcFermentables(); }); 1190 $('#color_method').on('change', function (event) {
1191 dataRecord.color_method = event.args.index;
1192 calcFermentables();
1193 });
1148 $('#ibu_method').on('change', function (event) { 1194 $('#ibu_method').on('change', function (event) {
1195 dataRecord.ibu_method = event.args.index;
1149 calcFermentables(); 1196 calcFermentables();
1150 calcIBUs(); 1197 calcIBUs();
1151 }); 1198 });
1152 1199
1153 $('#batch_size').on('change', function (event) { 1200 $('#batch_size').on('change', function (event) {
1157 $("#boil_size").val(Math.round(new_boil * 100) / 100); 1204 $("#boil_size").val(Math.round(new_boil * 100) / 100);
1158 dataRecord.batch_size = parseFloat(event.args.value); 1205 dataRecord.batch_size = parseFloat(event.args.value);
1159 calcFermentablesFromOG(parseFloat($("#est_og").jqxNumberInput('decimal'))); // Keep the OG 1206 calcFermentablesFromOG(parseFloat($("#est_og").jqxNumberInput('decimal'))); // Keep the OG
1160 calcFermentables(); 1207 calcFermentables();
1161 calcSVG(); 1208 calcSVG();
1209 calcFG();
1162 calcABV(); 1210 calcABV();
1163 // TODO: adjust the hops, miscs, yeast, water. 1211 // TODO: adjust the hops, miscs, yeast, water.
1164 calcIBUs(); 1212 calcIBUs();
1165 }); 1213 });
1166 $('#boil_time').on('change', function (event) { 1214 $('#boil_time').on('change', function (event) {
1171 dataRecord.boil_time = parseFloat(event.args.value); 1219 dataRecord.boil_time = parseFloat(event.args.value);
1172 dataRecord.boil_size = new_boil; 1220 dataRecord.boil_size = new_boil;
1173 $("#boil_size").val(Math.round(new_boil * 100) / 100); 1221 $("#boil_size").val(Math.round(new_boil * 100) / 100);
1174 calcFermentables(); 1222 calcFermentables();
1175 calcSVG(); 1223 calcSVG();
1224 calcFG();
1176 calcABV(); 1225 calcABV();
1177 // TODO: adjust the hops, miscs, yeast, water. 1226 // TODO: adjust the hops, miscs, yeast, water.
1178 calcIBUs(); 1227 calcIBUs();
1179 }); 1228 });
1180 $('#efficiency').on('change', function (event) { 1229 $('#efficiency').on('change', function (event) {
1181 console.log("efficiency change:"+event.args.value); 1230 console.log("efficiency change:"+event.args.value);
1182 calcFermentables(); 1231 calcFermentables();
1183 calcSVG(); 1232 calcSVG();
1233 calcFG();
1184 calcABV(); 1234 calcABV();
1185 calcIBUs(); 1235 calcIBUs();
1186 }); 1236 });
1187 $('#est_og').on('change', function (event) { 1237 $('#est_og').on('change', function (event) {
1188 console.log("est_og change:"+event.args.value); 1238 console.log("est_og change:"+event.args.value);
1189 $('#est_og2').val(event.args.value); 1239 $('#est_og2').val(event.args.value);
1190 $('#est_og3').val(event.args.value); 1240 $('#est_og3').val(event.args.value);
1191 calcFermentablesFromOG(event.args.value); // Adjust fermentables amounts 1241 calcFermentablesFromOG(event.args.value); // Adjust fermentables amounts
1192 calcFermentables(); // Update the recipe details 1242 calcFermentables(); // Update the recipe details
1193 calcSVG(); 1243 calcSVG();
1244 calcFG();
1194 calcABV(); // and ABV 1245 calcABV(); // and ABV
1195 calcIBUs(); // and the IBU's. 1246 calcIBUs(); // and the IBU's.
1196 }); 1247 });
1197 $('#mash_ph').on('change', function (event) { 1248 $('#mash_ph').on('change', function (event) {
1198 dataRecord.mash_ph = parseFloat(event.args.value); 1249 dataRecord.mash_ph = parseFloat(event.args.value);
1206 $('#sparge_volume').on('change', function (event) { 1257 $('#sparge_volume').on('change', function (event) {
1207 dataRecord.sparge_volume = parseFloat(event.args.value); 1258 dataRecord.sparge_volume = parseFloat(event.args.value);
1208 calcSparge(); 1259 calcSparge();
1209 }); 1260 });
1210 $('#sparge_source').on('change', function (event) { 1261 $('#sparge_source').on('change', function (event) {
1211 dataRecord.sparge_source= event.args.item.value; 1262 if (event.args) {
1212 calcSparge(); 1263 var index = event.args.index;
1264 dataRecord.sparge_source= index;
1265 calcSparge();
1266 }
1213 }); 1267 });
1214 $('#sparge_acid_type').on('change', function (event) { 1268 $('#sparge_acid_type').on('change', function (event) {
1215 dataRecord.sparge_acid_type = event.args.item.value; 1269 if (event.args) {
1216 console.log("new sparge_acid_type: "+dataRecord.sparge_acid_type); 1270 var index = event.args.index;
1217 calcSparge(); 1271 dataRecord.sparge_acid_type = index;
1272 console.log("new sparge_acid_type: "+dataRecord.sparge_acid_type);
1273 calcSparge();
1274 }
1218 }); 1275 });
1219 $('#sparge_acid_perc').on('change', function (event) { 1276 $('#sparge_acid_perc').on('change', function (event) {
1220 dataRecord.sparge_acid_perc = parseFloat(event.args.value); 1277 dataRecord.sparge_acid_perc = parseFloat(event.args.value);
1221 calcSparge(); 1278 calcSparge();
1222 }); 1279 });
1267 $("#styleSelect").jqxDropDownList({ 1324 $("#styleSelect").jqxDropDownList({
1268 placeHolder: "Kies bierstijl:", 1325 placeHolder: "Kies bierstijl:",
1269 theme: theme, 1326 theme: theme,
1270 source: styleslist, 1327 source: styleslist,
1271 displayMember: "name", 1328 displayMember: "name",
1272 width: 150, 1329 width: 180,
1273 height: 27, 1330 height: 23,
1274 dropDownVerticalAlignment: 'top', 1331 dropDownVerticalAlignment: 'top',
1275 dropDownWidth: 500, 1332 dropDownWidth: 500,
1276 dropDownHeight: 380, 1333 dropDownHeight: 380,
1277 renderer: function (index, label, value) { 1334 renderer: function (index, label, value) {
1278 var datarecord = styleslist.records[index]; 1335 var datarecord = styleslist.records[index];
1286 $("#st_name").val(datarecord.name); 1343 $("#st_name").val(datarecord.name);
1287 $("#st_category").val(datarecord.category); 1344 $("#st_category").val(datarecord.category);
1288 $("#st_category_number").val(datarecord.category_number); 1345 $("#st_category_number").val(datarecord.category_number);
1289 $("#st_letter").val(datarecord.style_letter); 1346 $("#st_letter").val(datarecord.style_letter);
1290 $("#st_guide").val(datarecord.style_guide); 1347 $("#st_guide").val(datarecord.style_guide);
1291 $("#st_type").val(datarecord.type); 1348 $("#st_type").val(StyleTypeData[datarecord.type].nl);
1292 $("#st_og_min").val(datarecord.og_min); 1349 $("#st_og_min").val(datarecord.og_min);
1293 $("#st_og_max").val(datarecord.og_max); 1350 $("#st_og_max").val(datarecord.og_max);
1294 $("#st_fg_min").val(datarecord.fg_min); 1351 $("#st_fg_min").val(datarecord.fg_min);
1295 $("#st_fg_max").val(datarecord.fg_max); 1352 $("#st_fg_max").val(datarecord.fg_max);
1296 $("#st_ibu_min").val(datarecord.ibu_min); 1353 $("#st_ibu_min").val(datarecord.ibu_min);
1310 $("#equipmentSelect").jqxDropDownList({ 1367 $("#equipmentSelect").jqxDropDownList({
1311 placeHolder: "Kies apparatuur:", 1368 placeHolder: "Kies apparatuur:",
1312 theme: theme, 1369 theme: theme,
1313 source: equipmentlist, 1370 source: equipmentlist,
1314 displayMember: "name", 1371 displayMember: "name",
1315 width: 150, 1372 width: 170,
1316 height: 27, 1373 height: 23,
1317 dropDownWidth: 300, 1374 dropDownWidth: 300,
1318 renderer: function (index, label, value) { 1375 renderer: function (index, label, value) {
1319 var datarecord = equipmentlist.records[index]; 1376 var datarecord = equipmentlist.records[index];
1320 return datarecord.batch_size + " liter " + datarecord.name; 1377 return datarecord.batch_size + " liter " + datarecord.name;
1321 } 1378 }
1366 } 1423 }
1367 }); 1424 });
1368 1425
1369 var dataRecord = {}; 1426 var dataRecord = {};
1370 var url = "includes/db_product.php"; 1427 var url = "includes/db_product.php";
1428
1371 // Prepare the data 1429 // Prepare the data
1372 var source = { 1430 var source = {
1373 datatype: "json", 1431 datatype: "json",
1374 cache: false, 1432 cache: false,
1375 datafields: [ 1433 datafields: [
1377 { name: 'record', type: 'number' }, 1435 { name: 'record', type: 'number' },
1378 { name: 'uuid', type: 'string' }, 1436 { name: 'uuid', type: 'string' },
1379 { name: 'name', type: 'string' }, 1437 { name: 'name', type: 'string' },
1380 { name: 'code', type: 'string' }, 1438 { name: 'code', type: 'string' },
1381 { name: 'birth', type: 'string' }, 1439 { name: 'birth', type: 'string' },
1382 { name: 'stage', type: 'string' }, 1440 { name: 'stage', type: 'int' },
1383 { name: 'notes', type: 'string' }, 1441 { name: 'notes', type: 'string' },
1384 { name: 'log_brew', type: 'bool' }, 1442 { name: 'log_brew', type: 'int' },
1385 { name: 'log_fermentation', type: 'bool' }, 1443 { name: 'log_fermentation', type: 'int' },
1386 { name: 'inventory_reduced', type: 'bool' }, 1444 { name: 'inventory_reduced', type: 'int' },
1387 { name: 'locked', type: 'bool' }, 1445 { name: 'locked', type: 'int' },
1388 { name: 'eq_name', type: 'string' }, 1446 { name: 'eq_name', type: 'string' },
1389 { name: 'eq_boil_size', type: 'float' }, 1447 { name: 'eq_boil_size', type: 'float' },
1390 { name: 'eq_batch_size', type: 'float' }, 1448 { name: 'eq_batch_size', type: 'float' },
1391 { name: 'eq_tun_volume', type: 'float' }, 1449 { name: 'eq_tun_volume', type: 'float' },
1392 { name: 'eq_tun_weight', type: 'float' }, 1450 { name: 'eq_tun_weight', type: 'float' },
1393 { name: 'eq_tun_specific_heat', type: 'float' }, 1451 { name: 'eq_tun_specific_heat', type: 'float' },
1394 { name: 'eq_tun_material', type: 'string' }, 1452 { name: 'eq_tun_material', type: 'int' },
1395 { name: 'eq_tun_height', type: 'float' }, 1453 { name: 'eq_tun_height', type: 'float' },
1396 { name: 'eq_top_up_water', type: 'float' }, 1454 { name: 'eq_top_up_water', type: 'float' },
1397 { name: 'eq_trub_chiller_loss', type: 'float' }, 1455 { name: 'eq_trub_chiller_loss', type: 'float' },
1398 { name: 'eq_evap_rate', type: 'float' }, 1456 { name: 'eq_evap_rate', type: 'float' },
1399 { name: 'eq_boil_time', type: 'float' }, 1457 { name: 'eq_boil_time', type: 'float' },
1400 { name: 'eq_calc_boil_volume', type: 'bool' }, 1458 { name: 'eq_calc_boil_volume', type: 'int' },
1401 { name: 'eq_top_up_kettle', type: 'float' }, 1459 { name: 'eq_top_up_kettle', type: 'float' },
1402 { name: 'eq_hop_utilization', type: 'float' }, 1460 { name: 'eq_hop_utilization', type: 'float' },
1403 { name: 'eq_notes', type: 'string' }, 1461 { name: 'eq_notes', type: 'string' },
1404 { name: 'eq_lauter_volume', type: 'float' }, 1462 { name: 'eq_lauter_volume', type: 'float' },
1405 { name: 'eq_lauter_height', type: 'float' }, 1463 { name: 'eq_lauter_height', type: 'float' },
1420 { name: 'brew_preboil_ph', type: 'float' }, 1478 { name: 'brew_preboil_ph', type: 'float' },
1421 { name: 'brew_aboil_volume', type: 'float' }, 1479 { name: 'brew_aboil_volume', type: 'float' },
1422 { name: 'brew_aboil_sg', type: 'float' }, 1480 { name: 'brew_aboil_sg', type: 'float' },
1423 { name: 'brew_aboil_ph', type: 'float' }, 1481 { name: 'brew_aboil_ph', type: 'float' },
1424 { name: 'brew_aboil_efficiency', type: 'float' }, 1482 { name: 'brew_aboil_efficiency', type: 'float' },
1425 { name: 'brew_cooling_method', type: 'string' }, 1483 { name: 'brew_cooling_method', type: 'int' },
1426 { name: 'brew_cooling_time', type: 'float' }, 1484 { name: 'brew_cooling_time', type: 'float' },
1427 { name: 'brew_cooling_to', type: 'float' }, 1485 { name: 'brew_cooling_to', type: 'float' },
1428 { name: 'brew_whirlpool9', type: 'float' }, 1486 { name: 'brew_whirlpool9', type: 'float' },
1429 { name: 'brew_whirlpool7', type: 'float' }, 1487 { name: 'brew_whirlpool7', type: 'float' },
1430 { name: 'brew_whirlpool6', type: 'float' }, 1488 { name: 'brew_whirlpool6', type: 'float' },
1431 { name: 'brew_whirlpool2', type: 'float' }, 1489 { name: 'brew_whirlpool2', type: 'float' },
1432 { name: 'brew_fermenter_volume', type: 'float' }, 1490 { name: 'brew_fermenter_volume', type: 'float' },
1433 { name: 'brew_fermenter_extrawater', type: 'float' }, 1491 { name: 'brew_fermenter_extrawater', type: 'float' },
1434 { name: 'brew_aeration_time', type: 'float' }, 1492 { name: 'brew_aeration_time', type: 'float' },
1435 { name: 'brew_aeration_speed', type: 'float' }, 1493 { name: 'brew_aeration_speed', type: 'float' },
1436 { name: 'brew_aeration_type', type: 'string' }, 1494 { name: 'brew_aeration_type', type: 'int' },
1437 { name: 'brew_fermenter_sg', type: 'float' }, 1495 { name: 'brew_fermenter_sg', type: 'float' },
1438 { name: 'brew_fermenter_ibu', type: 'float' }, 1496 { name: 'brew_fermenter_ibu', type: 'float' },
1439 { name: 'brew_date_end', type: 'string' }, 1497 { name: 'brew_date_end', type: 'string' },
1440 { name: 'brew_log_available', type: 'bool' }, 1498 { name: 'brew_log_available', type: 'int' },
1441 { name: 'og', type: 'float' }, 1499 { name: 'og', type: 'float' },
1442 { name: 'fg', type: 'float' }, 1500 { name: 'fg', type: 'float' },
1443 { name: 'primary_start_temp', type: 'float' }, 1501 { name: 'primary_start_temp', type: 'float' },
1444 { name: 'primary_max_temp', type: 'float' }, 1502 { name: 'primary_max_temp', type: 'float' },
1445 { name: 'primary_end_temp', type: 'float' }, 1503 { name: 'primary_end_temp', type: 'float' },
1449 { name: 'secondary_end_date', type: 'string' }, 1507 { name: 'secondary_end_date', type: 'string' },
1450 { name: 'tertiary_temp', type: 'float' }, 1508 { name: 'tertiary_temp', type: 'float' },
1451 { name: 'package_date', type: 'string' }, 1509 { name: 'package_date', type: 'string' },
1452 { name: 'bottle_amount', type: 'float' }, 1510 { name: 'bottle_amount', type: 'float' },
1453 { name: 'bottle_carbonation', type: 'float' }, 1511 { name: 'bottle_carbonation', type: 'float' },
1454 { name: 'bottle_priming_sugar', type: 'string' }, 1512 { name: 'bottle_priming_sugar', type: 'int' },
1455 { name: 'bottle_priming_amount', type: 'float' }, 1513 { name: 'bottle_priming_amount', type: 'float' },
1456 { name: 'bottle_carbonation_temp', type: 'float' }, 1514 { name: 'bottle_carbonation_temp', type: 'float' },
1457 { name: 'keg_amount', type: 'float' }, 1515 { name: 'keg_amount', type: 'float' },
1458 { name: 'keg_carbonation', type: 'float' }, 1516 { name: 'keg_carbonation', type: 'float' },
1459 { name: 'keg_priming_sugar', type: 'string' }, 1517 { name: 'keg_priming_sugar', type: 'int' },
1460 { name: 'keg_priming_amount', type: 'float' }, 1518 { name: 'keg_priming_amount', type: 'float' },
1461 { name: 'keg_carbonation_temp', type: 'float' }, 1519 { name: 'keg_carbonation_temp', type: 'float' },
1462 { name: 'keg_forced_carb', type: 'bool' }, 1520 { name: 'keg_forced_carb', type: 'int' },
1463 { name: 'keg_pressure', type: 'float' }, 1521 { name: 'keg_pressure', type: 'float' },
1464 { name: 'taste_notes', type: 'string' }, 1522 { name: 'taste_notes', type: 'string' },
1465 { name: 'taste_rate', type: 'float' }, 1523 { name: 'taste_rate', type: 'float' },
1466 { name: 'taste_date', type: 'string' }, 1524 { name: 'taste_date', type: 'string' },
1467 { name: 'taste_color', type: 'string' }, 1525 { name: 'taste_color', type: 'string' },
1474 { name: 'st_name', type: 'string' }, 1532 { name: 'st_name', type: 'string' },
1475 { name: 'st_letter', type: 'string' }, 1533 { name: 'st_letter', type: 'string' },
1476 { name: 'st_guide', type: 'string' }, 1534 { name: 'st_guide', type: 'string' },
1477 { name: 'st_category', type: 'string' }, 1535 { name: 'st_category', type: 'string' },
1478 { name: 'st_category_number', type: 'float' }, 1536 { name: 'st_category_number', type: 'float' },
1479 { name: 'st_type', type: 'string' }, 1537 { name: 'st_type', type: 'int' },
1480 { name: 'st_og_min', type: 'float' }, 1538 { name: 'st_og_min', type: 'float' },
1481 { name: 'st_og_max', type: 'float' }, 1539 { name: 'st_og_max', type: 'float' },
1482 { name: 'st_fg_min', type: 'float' }, 1540 { name: 'st_fg_min', type: 'float' },
1483 { name: 'st_fg_max', type: 'float' }, 1541 { name: 'st_fg_max', type: 'float' },
1484 { name: 'st_ibu_min', type: 'float' }, 1542 { name: 'st_ibu_min', type: 'float' },
1487 { name: 'st_color_max', type: 'float' }, 1545 { name: 'st_color_max', type: 'float' },
1488 { name: 'st_carb_min', type: 'float' }, 1546 { name: 'st_carb_min', type: 'float' },
1489 { name: 'st_carb_max', type: 'float' }, 1547 { name: 'st_carb_max', type: 'float' },
1490 { name: 'st_abv_min', type: 'float' }, 1548 { name: 'st_abv_min', type: 'float' },
1491 { name: 'st_abv_max', type: 'float' }, 1549 { name: 'st_abv_max', type: 'float' },
1492 { name: 'type', type: 'string' }, 1550 { name: 'type', type: 'int' },
1493 { name: 'batch_size', type: 'float' }, 1551 { name: 'batch_size', type: 'float' },
1494 { name: 'boil_size', type: 'float' }, 1552 { name: 'boil_size', type: 'float' },
1495 { name: 'boil_time', type: 'float' }, 1553 { name: 'boil_time', type: 'float' },
1496 { name: 'efficiency', type: 'float' }, 1554 { name: 'efficiency', type: 'float' },
1497 { name: 'est_og', type: 'float' }, 1555 { name: 'est_og', type: 'float' },
1498 { name: 'est_fg', type: 'float' }, 1556 { name: 'est_fg', type: 'float' },
1499 { name: 'est_abv', type: 'float' }, 1557 { name: 'est_abv', type: 'float' },
1500 { name: 'est_color', type: 'float' }, 1558 { name: 'est_color', type: 'float' },
1501 { name: 'color_method', type: 'string' }, 1559 { name: 'color_method', type: 'int' },
1502 { name: 'est_ibu', type: 'float' }, 1560 { name: 'est_ibu', type: 'float' },
1503 { name: 'ibu_method', type: 'string' }, 1561 { name: 'ibu_method', type: 'int' },
1504 { name: 'est_carb', type: 'float' }, 1562 { name: 'est_carb', type: 'float' },
1505 { name: 'sparge_temp', type: 'float' }, 1563 { name: 'sparge_temp', type: 'float' },
1506 { name: 'sparge_ph', type: 'float' }, 1564 { name: 'sparge_ph', type: 'float' },
1507 { name: 'sparge_volume', type: 'float' }, 1565 { name: 'sparge_volume', type: 'float' },
1508 { name: 'sparge_source', type: 'string' }, 1566 { name: 'sparge_source', type: 'int' },
1509 { name: 'sparge_acid_type', type: 'string' }, 1567 { name: 'sparge_acid_type', type: 'int' },
1510 { name: 'sparge_acid_perc', type: 'float' }, 1568 { name: 'sparge_acid_perc', type: 'float' },
1511 { name: 'sparge_acid_amount', type: 'float' }, 1569 { name: 'sparge_acid_amount', type: 'float' },
1512 { name: 'mash_ph', type: 'float' }, 1570 { name: 'mash_ph', type: 'float' },
1513 { name: 'mash_name', type: 'string' }, 1571 { name: 'mash_name', type: 'string' },
1514 { name: 'calc_acid', type: 'bool' }, 1572 { name: 'calc_acid', type: 'int' },
1515 { name: 'w1_name', type: 'string' }, 1573 { name: 'w1_name', type: 'string' },
1516 { name: 'w1_amount', type: 'float' }, 1574 { name: 'w1_amount', type: 'float' },
1517 { name: 'w1_calcium', type: 'float' }, 1575 { name: 'w1_calcium', type: 'float' },
1518 { name: 'w1_sulfate', type: 'float' }, 1576 { name: 'w1_sulfate', type: 'float' },
1519 { name: 'w1_chloride', type: 'float' }, 1577 { name: 'w1_chloride', type: 'float' },
1530 { name: 'w2_sodium', type: 'float' }, 1588 { name: 'w2_sodium', type: 'float' },
1531 { name: 'w2_magnesium', type: 'float' }, 1589 { name: 'w2_magnesium', type: 'float' },
1532 { name: 'w2_total_alkalinity', type: 'float' }, 1590 { name: 'w2_total_alkalinity', type: 'float' },
1533 { name: 'w2_ph', type: 'float' }, 1591 { name: 'w2_ph', type: 'float' },
1534 { name: 'w2_cost', type: 'float' }, 1592 { name: 'w2_cost', type: 'float' },
1593 { name: 'wa_acid_name', type: 'int' },
1594 { name: 'wa_acid_perc', type: 'int' },
1595 { name: 'wa_base_name', type: 'int' },
1535 { name: 'fermentables', type: 'array' }, 1596 { name: 'fermentables', type: 'array' },
1536 { name: 'hops', type: 'string' }, 1597 { name: 'hops', type: 'array' },
1537 { name: 'miscs', type: 'string' }, 1598 { name: 'miscs', type: 'array' },
1538 { name: 'yeasts', type: 'string' }, 1599 { name: 'yeasts', type: 'array' },
1539 { name: 'mashs', type: 'string' } 1600 { name: 'mashs', type: 'array' }
1540 ], 1601 ],
1541 id: 'record', 1602 id: 'record',
1542 url: url + '?record=' + my_record 1603 url: url + '?record=' + my_record
1543 }; 1604 };
1544 // Load data and select one record. 1605 // Load data and select one record.
1715 $("#w2_sodium").val(dataRecord.w2_sodium); 1776 $("#w2_sodium").val(dataRecord.w2_sodium);
1716 $("#w2_magnesium").val(dataRecord.w2_magnesium); 1777 $("#w2_magnesium").val(dataRecord.w2_magnesium);
1717 $("#w2_total_alkalinity").val(dataRecord.w2_total_alkalinity); 1778 $("#w2_total_alkalinity").val(dataRecord.w2_total_alkalinity);
1718 $("#w2_ph").val(dataRecord.w2_ph); 1779 $("#w2_ph").val(dataRecord.w2_ph);
1719 $("#w2_cost").val(dataRecord.w2_cost); 1780 $("#w2_cost").val(dataRecord.w2_cost);
1781 $("#wa_acid_name").val(dataRecord.wa_acid_name);
1782 $("#wa_acid_perc").val(dataRecord.wa_acid_perc);
1783 $("#wa_base_name").val(dataRecord.wa_base_name);
1720 editFermentable(dataRecord); 1784 editFermentable(dataRecord);
1721 editHop(dataRecord); 1785 editHop(dataRecord);
1722 editMisc(dataRecord); 1786 editMisc(dataRecord);
1723 editYeast(dataRecord); 1787 editYeast(dataRecord);
1724 editMash(dataRecord); 1788 editMash(dataRecord);
1725 1789
1726 switch (dataRecord.stage) { 1790 if (dataRecord.stage >= 10) {
1727 case 'Plan': brewstage = 0; break; 1791 $("#locked").jqxCheckBox({ disabled:false });
1728 case 'Wait': brewstage = 1; break;
1729 case 'Brew': brewstage = 2; break;
1730 case 'Primary': brewstage = 3; break;
1731 case 'Secondary': brewstage = 4; break;
1732 case 'Tertiary': brewstage = 5; break;
1733 case 'Package': brewstage = 6; break;
1734 case 'Carbonation': brewstage = 7; break;
1735 case 'Mature': brewstage = 8; break;
1736 case 'Taste': brewstage = 9; break;
1737 case 'Ready': brewstage = 10;
1738 $("#locked").jqxCheckBox({ disabled:false });
1739 break;
1740 case 'Closed': brewstage = 11;
1741 $("#locked").jqxCheckBox({ disabled:false });
1742 break;
1743 } 1792 }
1744 // Enable or Disable settings depending on the stage. 1793 // Enable or Disable settings depending on the stage.
1745 if (brewstage > 1) 1794 if (dataRecord.stage > 1)
1746 $("#equipmentSelect").jqxDropDownList({ disabled: true }); 1795 $("#equipmentSelect").jqxDropDownList({ disabled: true });
1747 if (brewstage > 0) { 1796 if (dataRecord.stage > 0) {
1748 $("#Delete").jqxButton({ disabled: true }); 1797 $("#Delete").jqxButton({ disabled: true });
1749 } 1798 }
1750 if (brewstage < 3) { 1799 if (dataRecord.stage < 3) {
1751 $('#jqxTabs').jqxTabs('disableAt', 9); 1800 $('#jqxTabs').jqxTabs('disableAt', 9);
1752 // If recipe not complete, disable 8 too. 1801 // If recipe not complete, disable 8 too.
1753 } else { 1802 } else {
1754 $('#jqxTabs').jqxTabs('enableAt', 9); 1803 $('#jqxTabs').jqxTabs('enableAt', 9);
1755 } 1804 }
1756 if (brewstage < 4) { // At least primary 1805 if (dataRecord.stage < 4) { // At least primary
1757 $('#jqxTabs').jqxTabs('disableAt', 10); 1806 $('#jqxTabs').jqxTabs('disableAt', 10);
1758 } else { 1807 } else {
1759 $('#jqxTabs').jqxTabs('enableAt', 10); 1808 $('#jqxTabs').jqxTabs('enableAt', 10);
1760 } 1809 }
1761 if (brewstage < 6) { 1810 if (dataRecord.stage < 6) {
1762 $("#inventory_reduced").jqxCheckBox({ disabled : true }); 1811 $("#inventory_reduced").jqxCheckBox({ disabled : true });
1763 } else { 1812 } else {
1764 if ($('#inventory_reduced').jqxCheckBox('checked')) 1813 if ($('#inventory_reduced').jqxCheckBox('checked'))
1765 $("#inventory_reduced").jqxCheckBox({ disabled : true }); 1814 $("#inventory_reduced").jqxCheckBox({ disabled : true });
1766 } 1815 }
1767 if (brewstage < 8) { // Taste when at least Mature. 1816 if (dataRecord.stage < 8) { // Taste when at least Mature.
1768 $('#jqxTabs').jqxTabs('disableAt', 11); 1817 $('#jqxTabs').jqxTabs('disableAt', 11);
1769 } else { 1818 } else {
1770 $('#jqxTabs').jqxTabs('enableAt', 11); 1819 $('#jqxTabs').jqxTabs('enableAt', 11);
1771 } 1820 }
1772 1821
1783 // Inline fermentables editor 1832 // Inline fermentables editor
1784 var editFermentable = function (data) { 1833 var editFermentable = function (data) {
1785 var fermentableSource = { 1834 var fermentableSource = {
1786 localdata: data.fermentables, 1835 localdata: data.fermentables,
1787 datatype: "local", 1836 datatype: "local",
1837 cache: false,
1838 async: false,
1788 datafields: [ 1839 datafields: [
1789 { name: 'f_name', type: 'string' }, 1840 { name: 'f_name', type: 'string' },
1790 { name: 'f_origin', type: 'string' }, 1841 { name: 'f_origin', type: 'string' },
1791 { name: 'f_supplier', type: 'string' }, 1842 { name: 'f_supplier', type: 'string' },
1792 { name: 'f_amount', type: 'float' }, 1843 { name: 'f_amount', type: 'float' },
1793 { name: 'f_cost', type: 'float' }, 1844 { name: 'f_cost', type: 'float' },
1794 { name: 'f_type', type: 'string' }, 1845 { name: 'f_type', type: 'int' },
1795 { name: 'f_yield', type: 'float' }, 1846 { name: 'f_yield', type: 'float' },
1796 { name: 'f_color', type: 'float' }, 1847 { name: 'f_color', type: 'float' },
1797 { name: 'f_coarse_fine_diff', type: 'float' }, 1848 { name: 'f_coarse_fine_diff', type: 'float' },
1798 { name: 'f_moisture', type: 'float' }, 1849 { name: 'f_moisture', type: 'float' },
1799 { name: 'f_diastatic_power', type: 'float' }, 1850 { name: 'f_diastatic_power', type: 'float' },
1800 { name: 'f_protein', type: 'float' }, 1851 { name: 'f_protein', type: 'float' },
1801 { name: 'f_max_in_batch', type: 'float' }, 1852 { name: 'f_max_in_batch', type: 'float' },
1802 { name: 'f_graintype', type: 'string' }, 1853 { name: 'f_graintype', type: 'int' },
1803 { name: 'f_added', type: 'string' }, 1854 { name: 'f_added', type: 'int' },
1804 { name: 'f_dissolved_protein', type: 'float' }, 1855 { name: 'f_dissolved_protein', type: 'float' },
1805 { name: 'f_recommend_mash', type: 'bool' }, 1856 { name: 'f_recommend_mash', type: 'int' },
1806 { name: 'f_add_after_boil', type: 'bool' }, 1857 { name: 'f_add_after_boil', type: 'int' },
1807 { name: 'f_adjust_to_total_100', type: 'bool' }, 1858 { name: 'f_adjust_to_total_100', type: 'int' },
1808 { name: 'f_percentage', type: 'float' }, 1859 { name: 'f_percentage', type: 'float' },
1809 { name: 'f_di_ph', type: 'float' } 1860 { name: 'f_di_ph', type: 'float' },
1861 { name: 'f_acid_to_ph_57', type: 'float' },
1862 { name: 'f_inventory', type: 'float' },
1863 { name: 'f_avail', type: 'int' }
1810 ], 1864 ],
1811 addrow: function (rowid, rowdata, position, commit) { 1865 addrow: function (rowid, rowdata, position, commit) {
1812 commit(true); 1866 commit(true);
1813 }, 1867 },
1814 deleterow: function (rowid, commit) { 1868 deleterow: function (rowid, commit) {
1815 commit(true); 1869 commit(true);
1816 } 1870 }
1817 }; 1871 };
1818 var fermentableAdapter = new $.jqx.dataAdapter(fermentableSource); 1872 var fermentableAdapter = new $.jqx.dataAdapter(fermentableSource);
1819 $("#fermentableGrid").jqxGrid({ 1873 $("#fermentableGrid").jqxGrid({
1820 width: 1150, 1874 width: 1240,
1821 height: 400, 1875 height: 450,
1822 source: fermentableAdapter, 1876 source: fermentableAdapter,
1823 theme: theme, 1877 theme: theme,
1824 selectionmode: 'singlerow', 1878 selectionmode: 'singlerow',
1825 editmode: 'selectedcell',
1826 editable: true,
1827 localization: getLocalization(), 1879 localization: getLocalization(),
1828 showtoolbar: true, 1880 showtoolbar: true,
1829 rendertoolbar: function (toolbar) { 1881 rendertoolbar: function (toolbar) {
1830 var me = this; 1882 var me = this;
1831 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); 1883 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
1836 container.append('<input style="float: left; margin-left: 400px;" id="fdeleterowbutton" type="button" value="Verwijder mout" />'); 1888 container.append('<input style="float: left; margin-left: 400px;" id="fdeleterowbutton" type="button" value="Verwijder mout" />');
1837 // add fermentable from dropdownlist. 1889 // add fermentable from dropdownlist.
1838 $("#faddrowbutton").jqxDropDownList({ 1890 $("#faddrowbutton").jqxDropDownList({
1839 placeHolder: "Kies mout:", 1891 placeHolder: "Kies mout:",
1840 theme: theme, 1892 theme: theme,
1893 template: "primary",
1841 source: fermentablelist, 1894 source: fermentablelist,
1842 displayMember: "name", 1895 displayMember: "name",
1843 width: 150, 1896 width: 150,
1844 height: 27, 1897 height: 27,
1845 dropDownWidth: 500, 1898 dropDownWidth: 500,
1868 row["f_diastatic_power"] = datarecord.diastatic_power; 1921 row["f_diastatic_power"] = datarecord.diastatic_power;
1869 row["f_protein"] = datarecord.protein; 1922 row["f_protein"] = datarecord.protein;
1870 row["f_max_in_batch"] = datarecord.max_in_batch; 1923 row["f_max_in_batch"] = datarecord.max_in_batch;
1871 row["f_graintype"] = datarecord.graintype; 1924 row["f_graintype"] = datarecord.graintype;
1872 if (datarecord.add_after_boil) { 1925 if (datarecord.add_after_boil) {
1873 row["f_added"] = "Primary"; 1926 row["f_added"] = 2; // Fermentation
1874 } else if ((datarecord.type == "Sugar") || (datarecord.type == "Adjunct")) { 1927 } else if ((datarecord.type == 1) || (datarecord.type == 4)) { // Sugar or Adjunct
1875 row["f_added"] = "Boil"; 1928 row["f_added"] = 1; // Boil
1876 } else { 1929 } else {
1877 row["f_added"] = "Mash"; 1930 row["f_added"] = 0; // Mash
1878 } 1931 }
1879 row["f_dissolved_protein"] = 0; 1932 row["f_dissolved_protein"] = datarecord.dissolved_protein;
1880 row["f_recommend_mash"] = datarecord.recommend_mash; 1933 row["f_recommend_mash"] = datarecord.recommend_mash;
1881 row["f_add_after_boil"] = datarecord.add_after_boil; 1934 row["f_add_after_boil"] = datarecord.add_after_boil;
1882 if (rowscount == 0) { 1935 if (rowscount == 0) {
1883 // The first fermentable 1936 // The first fermentable
1884 row["f_adjust_to_total_100"] = 1; 1937 row["f_adjust_to_total_100"] = 1;
1886 } else { 1939 } else {
1887 row["f_adjust_to_total_100"] = 0; 1940 row["f_adjust_to_total_100"] = 0;
1888 row["f_percentage"] = 0; 1941 row["f_percentage"] = 0;
1889 } 1942 }
1890 row["f_di_ph"] = datarecord.di_ph; 1943 row["f_di_ph"] = datarecord.di_ph;
1944 row["f_acid_to_ph_57"] = datarecord.acid_to_ph_57;
1945 row["f_inventory"] = datarecord.inventory;
1891 var commit = $("#fermentableGrid").jqxGrid('addrow', null, row); 1946 var commit = $("#fermentableGrid").jqxGrid('addrow', null, row);
1892 } 1947 }
1893 }); 1948 });
1894 1949
1895 $("#finstockbutton").jqxCheckBox({ theme: theme, height: 27 }); 1950 $("#finstockbutton").jqxCheckBox({ theme: theme, height: 27 });
1897 fermentableinstock = event.args.checked; 1952 fermentableinstock = event.args.checked;
1898 fermentablelist.dataBind(); 1953 fermentablelist.dataBind();
1899 }); 1954 });
1900 1955
1901 // delete selected fermentable. 1956 // delete selected fermentable.
1902 $("#fdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); 1957 $("#fdeleterowbutton").jqxButton({ template: "danger", theme: theme, height: 27, width: 150 });
1903 $("#fdeleterowbutton").on('click', function () { 1958 $("#fdeleterowbutton").on('click', function () {
1904 var selectedrowindex = $("#fermentableGrid").jqxGrid('getselectedrowindex'); 1959 var selectedrowindex = $("#fermentableGrid").jqxGrid('getselectedrowindex');
1905 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; 1960 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
1906 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { 1961 if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
1907 var id = $("#fermentableGrid").jqxGrid('getrowid', selectedrowindex); 1962 var id = $("#fermentableGrid").jqxGrid('getrowid', selectedrowindex);
1934 } else { 1989 } else {
1935 $("#fermentableGrid").jqxGrid('setcellvalue', 0, "f_percentage", 100); 1990 $("#fermentableGrid").jqxGrid('setcellvalue', 0, "f_percentage", 100);
1936 } 1991 }
1937 calcFermentables(); 1992 calcFermentables();
1938 calcSVG(); 1993 calcSVG();
1994 calcFG();
1939 calcABV(); 1995 calcABV();
1940 calcIBUs(); 1996 calcIBUs();
1941 }); 1997 });
1942 }, 1998 },
1943 ready: function() { 1999 ready: function() {
1944 calcFermentables(); 2000 calcFermentables();
1945 $('#jqxTabs').jqxTabs('next'); 2001 $('#jqxTabs').jqxTabs('next');
1946 }, 2002 },
1947 columns: [ 2003 columns: [
1948 { text: 'Vergistbaar ingredi&euml;nt', editable: false, datafield: 'f_name', 2004 { text: 'Vergistbaar ingredi&euml;nt', datafield: 'f_name',
1949 cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties) { 2005 cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties) {
1950 var rowData = $("#fermentableGrid").jqxGrid('getrowdata', row); 2006 var rowData = $("#fermentableGrid").jqxGrid('getrowdata', row);
1951 return "<span style='margin: 3px; margin-top: 6px; float: "+ 2007 return "<span style='margin: 3px; margin-top: 6px; float: "+
1952 columnproperties.cellsalign+"'>" +rowData.f_supplier+" / "+rowData.f_name+" ("+rowData.f_color+" EBC)</span>"; 2008 columnproperties.cellsalign+"'>" +rowData.f_supplier+" / "+rowData.f_name+" ("+rowData.f_color+" EBC)</span>";
1953 } 2009 }
1954 }, 2010 },
1955 { text: 'Type', editable: false, align: 'center', cellsalign: 'center', width: 100, datafield: 'f_type' }, 2011 { text: 'Type', width: 100, datafield: 'f_type',
1956 { text: 'Moment', width: 110, align: 'center', cellsalign: 'center', datafield: 'f_added', columntype: 'dropdownlist', 2012 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
1957 createeditor: function (row, column, editor) { 2013 return "<div style='margin: 4px;'>" + FermentableTypeData[value].nl + "</div>";
1958 var srcAdded = [ "Mash", "Boil", "Fermentation", "Lagering", "Bottle" ]; 2014 }
1959 editor.jqxDropDownList({ autoDropDownHeight: true, source: srcAdded }); 2015 },
2016 { text: 'Moment', width: 110, datafield: 'f_added',
2017 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
2018 return "<div style='margin: 4px;'>" + AddedData[value].nl + "</div>";
1960 } 2019 }
1961 }, 2020 },
1962 { text: 'Opbrengst', editable: false, datafield: 'f_yield', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, 2021 { text: 'Opbrengst', datafield: 'f_yield', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'p1' },
1963 { text: 'Gewicht Kg', datafield: 'f_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f3', 2022 { text: 'Gewicht Kg', datafield: 'f_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f3' },
1964 columntype: 'numberinput', 2023 { text: 'Percent', datafield: 'f_percentage', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'p1' },
1965 validation: function (cell, value) { 2024 { text: '100%', align: 'center', datafield: 'f_adjust_to_total_100', columntype: 'checkbox', width: 70 },
1966 // Maximum weight is the batch_size, just a simple check. 2025 { text: 'Wijzig', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () {
1967 var maxmout = parseFloat($("#batch_size").jqxNumberInput('decimal')); 2026 return "Wijzig";
1968 if (value < 0 || value > maxmout) { 2027 }, buttonclick: function (row) {
1969 return { result: false, message: "Gewicht moet 0-"+maxmout+" zijn" }; 2028 fermentableRow = row;
1970 } 2029 fermentableData = $("#fermentableGrid").jqxGrid('getrowdata', fermentableRow);
1971 return true; 2030 $("#wf_name").val(fermentableData.f_name);
1972 }, 2031 $("#wf_amount").val(fermentableData.f_amount);
1973 initeditor: function (row, cellvalue, editor) { 2032 $("#wf_percentage").val(fermentableData.f_percentage);
1974 editor.jqxNumberInput({ inputMode: 'simple', min: 0, decimalDigits: 3, spinButtons: false }); 2033 $("#wf_adjust_to_total_100").val(fermentableData.f_adjust_to_total_100);
1975 }, 2034 $("#wf_added").val(fermentableData.f_added);
1976 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { 2035 // show the popup window.
1977 if (to_100) { 2036 $("#popupFermentable").jqxWindow('open');
1978 return oldvalue; // When using percentages, don't allow edited results. 2037 }
1979 } 2038 }
1980 }
1981 },
1982 { text: 'Percentage', datafield: 'f_percentage', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'p1',
1983 columntype: 'numberinput',
1984 validation: function (cell, value) {
1985 if (value < 0 || value > 100) {
1986 return { result: false, message: "Percentage moet 0-100 zijn" };
1987 }
1988 return true;
1989 },
1990 initeditor: function (row, cellvalue, editor) {
1991 editor.jqxNumberInput({ decimalDigits: 1, min: 0, max: 100, spinButtons: false });
1992 },
1993 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
1994 oldvalue = Math.round(oldvalue * 10) / 10.0;
1995 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
1996 if ((oldvalue != newvalue) && (rowscount > 1)) {
1997 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', row);
1998 if (rowdata.f_adjust_to_total_100) {
1999 return oldvalue;
2000 }
2001 var diff = newvalue - oldvalue;
2002 var tw = 0; // total weight
2003 for (i = 0; i < rowscount; i++) {
2004 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
2005 tw += rowdata.f_amount;
2006 }
2007 if (to_100) {
2008 // Adjust this row and the 100% row.
2009 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', row);
2010 rowdata.f_amount += tw * diff / 100;
2011 for (i = 0; i < rowscount; i++) {
2012 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
2013 if (rowdata.f_adjust_to_total_100) {
2014 rowdata.f_percentage -= diff;
2015 rowdata.f_amount -= tw * diff / 100;
2016 }
2017 }
2018 } else {
2019 // Adjust all the rows.
2020 var nw = tw * diff / 100;
2021 for (i = 0; i < rowscount; i++) {
2022 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
2023 if (i == row) {
2024 rowdata.f_amount += nw;
2025 } else {
2026 rowdata.f_amount -= nw / (rowscount - 1);
2027 rowdata.f_percentage = Math.round((rowdata.f_amount / tw) * 1000) / 10.0;
2028 }
2029 }
2030 }
2031 }
2032 }
2033 },
2034 { text: '100%', align: 'center', datafield: 'f_adjust_to_total_100', columntype: 'checkbox', width: 80,
2035 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
2036 if (to_100) {
2037 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
2038 for (i = 0; i < rowscount; i++) {
2039 if (i != row) {
2040 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
2041 rowdata.f_adjust_to_total_100 = false;
2042 }
2043 }
2044 }
2045 }
2046 }
2047 ] 2039 ]
2048 });
2049 $("#fermentableGrid").on('cellendedit', function (event) {
2050 var args = event.args;
2051 console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value);
2052 // Make sure the grid itself is updated.
2053 $("#fermentableGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value);
2054 if ((args.datafield == 'f_amount') && (! to_100)) {
2055 // If one of the amounts is changed, recalculate the percentages.
2056 console.log("adjust percentages");
2057 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
2058 if (rowscount > 1) {
2059 var tw = 0;
2060 for (i = 0; i < rowscount; i++) {
2061 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
2062 tw += rowdata.f_amount;
2063 };
2064 for (i = 0; i < rowscount; i++) {
2065 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
2066 var percentage = Math.round(rowdata.f_amount / tw * 1000) / 10.0;
2067 $("#fermentableGrid").jqxGrid('setcellvalue', i, "f_percentage", percentage);
2068 };
2069 } else {
2070 $("#fermentableGrid").jqxGrid('setcellvalue', 0, "f_percentage", 100);
2071 }
2072 };
2073 $('#fermentableGrid').jqxGrid('sortby', 'f_amount', 'desc'); // TODO: not reliable
2074 calcFermentables();
2075 calcSVG();
2076 calcABV();
2077 calcIBUs(); // Depends on gravity, so recalculate.
2078 }); 2040 });
2079 }; 2041 };
2080 2042
2081 // Inline hops editor 2043 // Inline hops editor
2082 var editHop = function (data) { 2044 var editHop = function (data) {
2083 var hopSource = { 2045 var hopSource = {
2084 localdata: data.hops, 2046 localdata: data.hops,
2085 datatype: "local", 2047 datatype: "local",
2086 cache: false, 2048 cache: false,
2049 async: false,
2087 datafields: [ 2050 datafields: [
2088 { name: 'h_name', type: 'string' }, 2051 { name: 'h_name', type: 'string' },
2089 { name: 'h_origin', type: 'string' }, 2052 { name: 'h_origin', type: 'string' },
2090 { name: 'h_amount', type: 'float' }, 2053 { name: 'h_amount', type: 'float' },
2091 { name: 'h_cost', type: 'float' }, 2054 { name: 'h_cost', type: 'float' },
2092 { name: 'h_type', type: 'string' }, 2055 { name: 'h_type', type: 'int' },
2093 { name: 'h_form', type: 'string' }, 2056 { name: 'h_form', type: 'int' },
2094 { name: 'h_useat', type: 'string' }, 2057 { name: 'h_useat', type: 'int' },
2095 { name: 'h_time', type: 'float' }, 2058 { name: 'h_time', type: 'float' },
2096 { name: 'h_alpha', type: 'float' }, 2059 { name: 'h_alpha', type: 'float' },
2097 { name: 'h_beta', type: 'float' }, 2060 { name: 'h_beta', type: 'float' },
2098 { name: 'h_hsi', type: 'float' }, 2061 { name: 'h_hsi', type: 'float' },
2099 { name: 'h_humulene', type: 'float' }, 2062 { name: 'h_humulene', type: 'float' },
2100 { name: 'h_caryophyllene', type: 'float' }, 2063 { name: 'h_caryophyllene', type: 'float' },
2101 { name: 'h_cohumulone', type: 'float' }, 2064 { name: 'h_cohumulone', type: 'float' },
2102 { name: 'h_myrcene', type: 'float' }, 2065 { name: 'h_myrcene', type: 'float' },
2103 { name: 'h_total_oil', type: 'float' }, 2066 { name: 'h_total_oil', type: 'float' },
2104 { name: 'h_weight', type: 'float' } 2067 { name: 'h_inventory', type: 'float' },
2068 { name: 'h_avail', type: 'int' }
2105 ], 2069 ],
2106 addrow: function (rowid, rowdata, position, commit) { 2070 addrow: function (rowid, rowdata, position, commit) {
2107 commit(true); 2071 commit(true);
2108 }, 2072 },
2109 deleterow: function (rowid, commit) { 2073 deleterow: function (rowid, commit) {
2110 commit(true); 2074 commit(true);
2111 } 2075 }
2112 }; 2076 };
2113 var hopAdapter = new $.jqx.dataAdapter(hopSource, { 2077 var hopAdapter = new $.jqx.dataAdapter(hopSource);
2114 beforeLoadComplete: function (records) {
2115 var data = new Array();
2116 for (var i = 0; i < records.length; i++) {
2117 var row = records[i];
2118 row.h_weight = row.h_amount * 1000;
2119 data.push(row);
2120 }
2121 return data;
2122 },
2123 loadError: function(jqXHR, status, error) {
2124 $('#err').text(status + ' ' + error);
2125 },
2126 });
2127 $("#hopGrid").jqxGrid({ 2078 $("#hopGrid").jqxGrid({
2128 width: 1050, 2079 width: 1240,
2129 height: 400, 2080 height: 510,
2130 source: hopAdapter, 2081 source: hopAdapter,
2131 theme: theme, 2082 theme: theme,
2132 selectionmode: 'singlerow', 2083 selectionmode: 'singlerow',
2133 editmode: 'selectedcell',
2134 editable: true,
2135 localization: getLocalization(), 2084 localization: getLocalization(),
2136 showtoolbar: true, 2085 showtoolbar: true,
2137 rendertoolbar: function (toolbar) { 2086 rendertoolbar: function (toolbar) {
2138 var me = this; 2087 var me = this;
2139 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); 2088 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
2140 toolbar.append(container); 2089 toolbar.append(container);
2141 container.append('<div style="float: left; margin-left: 165px;" id="haddrowbutton"></div>'); 2090 container.append('<div style="float: left; margin-left: 165px;" id="haddrowbutton"></div>');
2142 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>'); 2091 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>');
2143 container.append('<div style="float: left; margin-left: 10px;" id="hinstockbutton"></div>'); 2092 container.append('<div style="float: left; margin-left: 10px;" id="hinstockbutton"></div>');
2144 container.append('<input style="float: left; margin-left: 280px;" id="hdeleterowbutton" type="button" value="Verwijder hop" />'); 2093 container.append('<input style="float: left; margin-left: 400px;" id="hdeleterowbutton" type="button" value="Verwijder hop" />');
2145 // add hop from dropdownlist. 2094 // add hop from dropdownlist.
2146 $("#haddrowbutton").jqxDropDownList({ 2095 $("#haddrowbutton").jqxDropDownList({
2147 placeHolder: "Kies hop:", 2096 placeHolder: "Kies hop:",
2148 theme: theme, 2097 theme: theme,
2098 template: "primary",
2149 source: hoplist, 2099 source: hoplist,
2150 displayMember: "name", 2100 displayMember: "name",
2151 width: 150, 2101 width: 150,
2152 height: 27, 2102 height: 27,
2153 dropDownWidth: 500, 2103 dropDownWidth: 500,
2166 row["h_origin"] = datarecord.origin; 2116 row["h_origin"] = datarecord.origin;
2167 row["h_amount"] = 0; 2117 row["h_amount"] = 0;
2168 row["h_cost"] = datarecord.cost; 2118 row["h_cost"] = datarecord.cost;
2169 row["h_type"] = datarecord.type; 2119 row["h_type"] = datarecord.type;
2170 row["h_form"] = datarecord.form; 2120 row["h_form"] = datarecord.form;
2171 row["h_useat"] = datarecord.useat; 2121 row["h_useat"] = 2; // Boil
2172 row["h_time"] = 0; 2122 row["h_time"] = 0;
2173 row["h_alpha"] = datarecord.alpha; 2123 row["h_alpha"] = datarecord.alpha;
2174 row["h_beta"] = datarecord.beta; 2124 row["h_beta"] = datarecord.beta;
2175 row["h_hsi"] = datarecord.hsi; 2125 row["h_hsi"] = datarecord.hsi;
2176 row["h_humulene"] = datarecord.humulene; 2126 row["h_humulene"] = datarecord.humulene;
2177 row["h_caryophyllene"] = datarecord.caryophyllene; 2127 row["h_caryophyllene"] = datarecord.caryophyllene;
2178 row["h_cohumulone"] = datarecord.cohumulone; 2128 row["h_cohumulone"] = datarecord.cohumulone;
2179 row["h_myrcene"] = datarecord.myrcene; 2129 row["h_myrcene"] = datarecord.myrcene;
2180 row["h_total_oil"] = datarecord.total_oil; 2130 row["h_total_oil"] = datarecord.total_oil;
2181 row["h_weight"] = 0; 2131 row["h_inventory"] = datarecord.inventory;
2182 var commit = $("#hopGrid").jqxGrid('addrow', null, row); 2132 var commit = $("#hopGrid").jqxGrid('addrow', null, row);
2183 } 2133 }
2184 }); 2134 });
2185 2135
2186 $("#hinstockbutton").jqxCheckBox({ theme: theme, height: 27 }); 2136 $("#hinstockbutton").jqxCheckBox({ theme: theme, height: 27 });
2188 hopinstock = event.args.checked; 2138 hopinstock = event.args.checked;
2189 hoplist.dataBind(); 2139 hoplist.dataBind();
2190 }); 2140 });
2191 2141
2192 // delete selected hop. 2142 // delete selected hop.
2193 $("#hdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); 2143 $("#hdeleterowbutton").jqxButton({ template: "danger", theme: theme, height: 27, width: 150 });
2194 $("#hdeleterowbutton").on('click', function () { 2144 $("#hdeleterowbutton").on('click', function () {
2195 var selectedrowindex = $("#hopGrid").jqxGrid('getselectedrowindex'); 2145 var selectedrowindex = $("#hopGrid").jqxGrid('getselectedrowindex');
2196 var rowscount = $("#hopGrid").jqxGrid('getdatainformation').rowscount; 2146 var rowscount = $("#hopGrid").jqxGrid('getdatainformation').rowscount;
2197 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { 2147 if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
2198 var id = $("#hopGrid").jqxGrid('getrowid', selectedrowindex); 2148 var id = $("#hopGrid").jqxGrid('getrowid', selectedrowindex);
2199 var commit = $("#hopGrid").jqxGrid('deleterow', id); 2149 var commit = $("#hopGrid").jqxGrid('deleterow', id);
2200 } 2150 }
2151 calcIBUs();
2201 }); 2152 });
2202 }, 2153 },
2203 ready: function() { 2154 ready: function() {
2155 calcIBUs();
2204 $('#jqxTabs').jqxTabs('next'); 2156 $('#jqxTabs').jqxTabs('next');
2205 }, 2157 },
2206 columns: [ 2158 columns: [
2207 { text: 'Hop', editable: false, datafield: 'h_name', 2159 { text: 'Hop', datafield: 'h_name',
2208 cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties) { 2160 cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties) {
2209 var rowData = $("#hopGrid").jqxGrid('getrowdata', row); 2161 var rowData = $("#hopGrid").jqxGrid('getrowdata', row);
2210 return "<span style='margin: 3px; margin-top: 6px; float: "+ 2162 return "<span style='margin: 3px; margin-top: 6px; float: "+
2211 columnproperties.cellsalign+"'>" +rowData.h_origin+" / "+rowData.h_name+"</span>"; 2163 columnproperties.cellsalign+"'>" +rowData.h_origin+" / "+rowData.h_name+"</span>";
2212 }, 2164 },
2213 }, 2165 },
2214 { text: 'Type', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_type' }, 2166 { text: 'Type', width: 90, datafield: 'h_type',
2215 { text: 'Vorm', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_form' }, 2167 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
2216 { text: 'Alpha', editable: false, datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, 2168 return "<div style='margin: 4px;'>" + HopTypeData[value].nl + "</div>";
2217 { text: 'Amount', hidden: true, datafield: 'h_amount' }, 2169 }
2218 { text: 'Gewicht gr', datafield: 'h_weight', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f1', 2170 },
2219 columntype: 'numberinput', 2171 { text: 'Vorm', width: 90, datafield: 'h_form',
2220 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { 2172 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
2221 return "<div style='margin: 4px;' class='jqx-right-align'>" + dataAdapter.formatNumber(value, "f1") + " gr</div>"; 2173 return "<div style='margin: 4px;'>" + HopFormData[value].nl + "</div>";
2222 }, 2174 }
2223 initeditor: function (row, cellvalue, editor, celltext, pressedChar) { 2175 },
2224 editor.jqxNumberInput({ 2176 { text: 'Alpha', datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' },
2225 inputMode: 'simple', decimalDigits: 1, min: 0, max: parseFloat(dataRecord.batch_size * 200), 2177 { text: 'Gebruik', width: 110, datafield: 'h_useat',
2226 spinButtons: false 2178 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
2227 }); 2179 return "<div style='margin: 4px;'>" + HopUseData[value].nl + "</div>";
2228 }, 2180 }
2229 validation: function (cell, value) { 2181 },
2230 var maxhops = parseFloat(dataRecord.batch_size) * 200; 2182 { text: 'Tijdsduur', datafield: 'h_time', width: 90, align: 'right',
2231 if (value < 0 || value > maxhops ) { 2183 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
2232 return { result: false, message: "Gewicht moet tussen 0 en "+maxhops+" gram zijn" }; 2184 if ((rowdata.h_useat == 2) || (rowdata.h_useat == 4)) // Boil, Whirlpool
2233 } 2185 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" min.</div>";
2234 return true; 2186 if (rowdata.h_useat == 5) // Dry hop
2235 } 2187 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value/1440, "f0")+" dagen</div>";
2236 }, 2188 else
2237 { text: 'Gebruik', width: 110, align: 'center', cellsalign: 'center', datafield: 'h_useat', columntype: 'dropdownlist', 2189 return "<div style='margin: 4px;'></div>";
2238 createeditor: function (row, column, editor) { 2190 }
2239 var srcUse = [ "Boil", "Dry Hop", "Mash", "First Wort", "Aroma" ]; 2191 },
2240 editor.jqxDropDownList({ autoDropDownHeight: true, source: srcUse }); 2192 { text: 'IBU', datafield: 'ibu', width: 80, align: 'right',
2241 },
2242 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
2243 if ((newvalue == "Mash") || (newvalue == "First Wort")) {
2244 $("#hopGrid").jqxGrid('setcellvalue', row, "h_time", parseFloat(dataRecord.boil_time));
2245 } else if (newvalue == "Aroma") {
2246 $("#hopGrid").jqxGrid('setcellvalue', row, "h_time", 0);
2247 }
2248 }
2249 },
2250 { text: 'Tijd', datafield: 'h_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0',
2251 columntype: 'numberinput',
2252 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
2253 if ((rowdata.h_useat == "Boil") || (rowdata.h_useat == "Dry Hop") || (rowdata.h_useat == "Dry hop"))
2254 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+"</div>";
2255 else
2256 return "<div style='margin: 4px;' class='jqx-right-align'> </div>";
2257 },
2258 initeditor: function (row, cellvalue, editor, celltext, pressedChar) {
2259 editor.jqxNumberInput({ decimalDigits: 0, digits: 3, min: 0, max: parseFloat(dataRecord.boil_time) });
2260 },
2261 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
2262 var use = $("#hopGrid").jqxGrid('getcellvalue', row, "h_useat");
2263 if ((use == "Mash") || (use == "First Wort") || (use == "First wort") || (use == "Aroma"))
2264 return oldvalue;
2265 },
2266 validation: function (cell, value) {
2267 var high = parseFloat(dataRecord.boil_time);
2268 if (value < 0 || value > high ) {
2269 return { result: false, message: "De tijd moet 0-"+high+" zijn" };
2270 }
2271 return true;
2272 }
2273 },
2274 { text: 'IBU', editable: false, datafield: 'ibu', width: 80, align: 'right',
2275 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { 2193 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
2276 var ibu = toIBU(rowdata.h_useat, 2194 var ibu = toIBU(rowdata.h_useat,
2277 rowdata.h_form, 2195 rowdata.h_form,
2278 preboil_sg, 2196 preboil_sg,
2279 parseFloat($("#batch_size").jqxNumberInput('decimal')), 2197 parseFloat($("#batch_size").jqxNumberInput('decimal')),
2280 parseFloat(rowdata.h_amount), 2198 parseFloat(rowdata.h_amount),
2281 parseFloat(rowdata.h_time), 2199 parseFloat(rowdata.h_time),
2282 parseFloat(rowdata.h_alpha), 2200 parseFloat(rowdata.h_alpha),
2283 $("#ibu_method").val() 2201 $("#ibu_method").val()
2284 ); 2202 );
2285 calcIBUs();
2286 return "<div style='margin: 4px;' class='jqx-right-align'>" + dataAdapter.formatNumber(ibu, "f1") + "</div>"; 2203 return "<div style='margin: 4px;' class='jqx-right-align'>" + dataAdapter.formatNumber(ibu, "f1") + "</div>";
2287 } 2204 }
2288 } 2205 },
2206 { text: 'Gewicht', datafield: 'h_amount', width: 110, align: 'right', cellsalign: 'right',
2207 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
2208 if (value < 1)
2209 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value * 1000, "f1")+" gr</div>";
2210 else
2211 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f1")+" kg</div>";
2212 }
2213 },
2214 { text: 'Voorraad', datafield: 'h_inventory', width: 110, align: 'right', cellsalign: 'right',
2215 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
2216 if (value < 1)
2217 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value * 1000, "f1")+" gr</div>";
2218 else
2219 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f1")+" kg</div>";
2220 }
2221 },
2222 { text: 'Wijzig', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () {
2223 return "Wijzig";
2224 }, buttonclick: function (row) {
2225 hopRow = row;
2226 hopData = $("#hopGrid").jqxGrid('getrowdata', hopRow);
2227 $("#wh_name").val(hopData.h_name);
2228 $("#wh_amount").val(hopData.h_amount * 1000);
2229 var ibu = toIBU(hopData.h_useat, hopData.h_form, preboil_sg,
2230 parseFloat($("#batch_size").jqxNumberInput('decimal')),
2231 parseFloat(hopData.h_amount), parseFloat(hopData.h_time),
2232 parseFloat(hopData.h_alpha), $("#ibu_method").val()
2233 );
2234 $("#wh_ibu").val(ibu);
2235 if (hopData.h_useat == 5) // Dry hop
2236 $("#wh_time").val(hopData.h_time / 1440);
2237 else
2238 $("#wh_time").val(hopData.h_time);
2239 $("#wh_useat").val(hopData.h_useat);
2240 // show the popup window.
2241 $("#popupHop").jqxWindow('open');
2242 }
2243 }
2289 ] 2244 ]
2290 });
2291 $("#hopGrid").on('cellendedit', function (event) {
2292 var args = event.args;
2293 console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value);
2294 $("#hopGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value);
2295 if (args.datafield == 'h_weight')
2296 $("#hopGrid").jqxGrid('setcellvalue', args.rowindex, 'h_amount', args.value / 1000);
2297 //$('#hopGrid').jqxGrid('sortby', 'f_amount', 'desc');
2298 }); 2245 });
2299 }; 2246 };
2300 2247
2301 // Inline miscs editor 2248 // Inline miscs editor
2302 var editMisc = function (data) { 2249 var editMisc = function (data) {
2303 var miscSource = { 2250 var miscSource = {
2304 localdata: data.miscs, 2251 localdata: data.miscs,
2305 datatype: "local", 2252 datatype: "local",
2306 cache: false, 2253 cache: false,
2254 async: false,
2307 datafields: [ 2255 datafields: [
2308 { name: 'm_name', type: 'string' }, 2256 { name: 'm_name', type: 'string' },
2309 { name: 'm_amount', type: 'float' }, 2257 { name: 'm_amount', type: 'float' },
2310 { name: 'm_cost', type: 'float' }, 2258 { name: 'm_cost', type: 'float' },
2311 { name: 'm_type', type: 'string' }, 2259 { name: 'm_type', type: 'int' },
2312 { name: 'm_use_use', type: 'string' }, 2260 { name: 'm_use_use', type: 'int' },
2313 { name: 'm_time', type: 'float' }, 2261 { name: 'm_time', type: 'float' },
2314 { name: 'm_amount_is_weight', type: 'bool' }, 2262 { name: 'm_amount_is_weight', type: 'int' },
2315 { name: 'm_weight', type: 'float' } 2263 { name: 'm_inventory', type: 'float' },
2264 { name: 'm_avail', type: 'int' }
2316 ], 2265 ],
2317 addrow: function (rowid, rowdata, position, commit) { 2266 addrow: function (rowid, rowdata, position, commit) {
2318 commit(true); 2267 commit(true);
2319 }, 2268 },
2320 deleterow: function (rowid, commit) { 2269 deleterow: function (rowid, commit) {
2324 var miscAdapter = new $.jqx.dataAdapter(miscSource, { 2273 var miscAdapter = new $.jqx.dataAdapter(miscSource, {
2325 beforeLoadComplete: function (records) { 2274 beforeLoadComplete: function (records) {
2326 var data = new Array(); 2275 var data = new Array();
2327 for (var i = 0; i < records.length; i++) { 2276 for (var i = 0; i < records.length; i++) {
2328 var row = records[i]; 2277 var row = records[i];
2329 row.m_weight = row.m_amount * 1000;
2330 data.push(row); 2278 data.push(row);
2331 // Initial set water agent values. 2279 // Initial set water agent values.
2332 switch (row.m_name) { 2280 switch (row.m_name) {
2333 case 'CaCl2': $("#wa_cacl2").val(row.m_weight); 2281 case 'CaCl2': $("#wa_cacl2").val(row.m_amount * 1000);
2334 break; 2282 break;
2335 case 'CaSO4': $("#wa_caso4").val(row.m_weight); 2283 case 'CaSO4': $("#wa_caso4").val(row.m_amount * 1000);
2336 break; 2284 break;
2337 case 'MgSO4': $("#wa_mgso4").val(row.m_weight); 2285 case 'MgSO4': $("#wa_mgso4").val(row.m_amount * 1000);
2338 break; 2286 break;
2339 case 'NaCl': $("#wa_nacl").val(row.m_weight); 2287 case 'NaCl': $("#wa_nacl").val(row.m_amount * 1000);
2340 break; 2288 break;
2341 case 'Melkzuur': $("#wa_acid_name").val('Melkzuur'); 2289 case 'Melkzuur': $("#wa_acid_name").val(0);
2342 $("#wa_acid").val(row.m_weight); 2290 $("#wa_acid").val(row.m_amount * 1000);
2343 $("#wa_acid_perc").val(80); 2291 $("#wa_acid_perc").val(80);
2344 last_acid = 'Melkzuur'; 2292 last_acid = 'Melkzuur';
2345 break; 2293 break;
2346 case 'Zoutzuur': $("#wa_acid_name").val('Zoutzuur'); 2294 case 'Zoutzuur': $("#wa_acid_name").val(1);
2347 $("#wa_acid").val(row.m_weight); 2295 $("#wa_acid").val(row.m_amount * 1000);
2348 $("#wa_acid_perc").val(80); 2296 $("#wa_acid_perc").val(80);
2349 last_acid = 'Zoutzuur'; 2297 last_acid = 'Zoutzuur';
2350 break; 2298 break;
2351 case 'Fosforzuur': $("#wa_acid_name").val('Fosforzuur'); 2299 case 'Fosforzuur': $("#wa_acid_name").val(2);
2352 $("#wa_acid").val(row.m_weight); 2300 $("#wa_acid").val(row.m_amount * 1000);
2353 $("#wa_acid_perc").val(80); 2301 $("#wa_acid_perc").val(80);
2354 last_acid = 'Fosforzuur'; 2302 last_acid = 'Fosforzuur';
2355 break; 2303 break;
2356 case 'Zwavelzuur': $("#wa_acid_name").val('Zwavelzuur'); 2304 case 'Zwavelzuur': $("#wa_acid_name").val(3);
2357 $("#wa_acid").val(row.m_weight); 2305 $("#wa_acid").val(row.m_amount * 1000);
2358 $("#wa_acid_perc").val(80); 2306 $("#wa_acid_perc").val(80);
2359 last_acid = 'Zwavelzuur'; 2307 last_acid = 'Zwavelzuur';
2360 break; 2308 break;
2361 case 'NaHCO3': $("#wa_base_name").val('NaHCO3'); 2309 case 'NaHCO3': $("#wa_base_name").val(0);
2362 $("#wa_base").val(row.m_weight); 2310 $("#wa_base").val(row.m_amount * 1000);
2363 last_base = 'NaHCO3'; 2311 last_base = 'NaHCO3';
2364 break; 2312 break;
2365 case 'Na2CO3': $("#wa_base_name").val('Na2CO3'); 2313 case 'Na2CO3': $("#wa_base_name").val(1);
2366 $("#wa_base").val(row.m_weight); 2314 $("#wa_base").val(row.m_amount * 1000);
2367 last_base = 'Na2CO3'; 2315 last_base = 'Na2CO3';
2368 break; 2316 break;
2369 case 'CaCO3': $("#wa_base_name").val('CaCO3'); 2317 case 'CaCO3': $("#wa_base_name").val(2);
2370 $("#wa_base").val(row.m_weight); 2318 $("#wa_base").val(row.m_amount * 1000);
2371 last_base = 'CaCO3'; 2319 last_base = 'CaCO3';
2372 break; 2320 break;
2373 case 'Ca(OH)2': $("#wa_base_name").val('Ca(OH)2'); 2321 case 'Ca(OH)2': $("#wa_base_name").val(3);
2374 $("#wa_base").val(row.m_weight); 2322 $("#wa_base").val(row.m_amount * 1000);
2375 last_base = 'Ca(OH)2'; 2323 last_base = 'Ca(OH)2';
2376 break; 2324 break;
2377 } 2325 }
2378 } 2326 }
2379 return data; 2327 return data;
2381 loadError: function(jqXHR, status, error) { 2329 loadError: function(jqXHR, status, error) {
2382 $('#err').text(status + ' ' + error); 2330 $('#err').text(status + ' ' + error);
2383 }, 2331 },
2384 }); 2332 });
2385 $("#miscGrid").jqxGrid({ 2333 $("#miscGrid").jqxGrid({
2386 width: 960, 2334 width: 1240,
2387 height: 400, 2335 height: 525,
2388 source: miscAdapter, 2336 source: miscAdapter,
2389 theme: theme, 2337 theme: theme,
2390 selectionmode: 'singlerow', 2338 selectionmode: 'singlerow',
2391 editmode: 'selectedcell',
2392 editable: true,
2393 localization: getLocalization(), 2339 localization: getLocalization(),
2394 showtoolbar: true, 2340 showtoolbar: true,
2395 rendertoolbar: function (toolbar) { 2341 rendertoolbar: function (toolbar) {
2396 var me = this; 2342 var me = this;
2397 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); 2343 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
2398 toolbar.append(container); 2344 toolbar.append(container);
2399 container.append('<div style="float: left; margin-left: 165px;" id="maddrowbutton"></div>'); 2345 container.append('<div style="float: left; margin-left: 165px;" id="maddrowbutton"></div>');
2400 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>'); 2346 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>');
2401 container.append('<div style="float: left; margin-left: 10px;" id="minstockbutton"></div>'); 2347 container.append('<div style="float: left; margin-left: 10px;" id="minstockbutton"></div>');
2402 container.append('<input style="float: left; margin-left: 200px;" id="mdeleterowbutton" type="button" value="Verwijder ingredient" />'); 2348 container.append('<input style="float: left; margin-left: 400px;" id="mdeleterowbutton" type="button" value="Verwijder ingredient" />');
2403 // add misc from dropdownlist. 2349 // add misc from dropdownlist.
2404 $("#maddrowbutton").jqxDropDownList({ 2350 $("#maddrowbutton").jqxDropDownList({
2405 placeHolder: "Kies ingredient:", 2351 placeHolder: "Kies ingredi&euml;nt:",
2406 theme: theme, 2352 theme: theme,
2353 template: "primary",
2407 source: misclist, 2354 source: misclist,
2408 displayMember: "name", 2355 displayMember: "name",
2409 width: 150, 2356 width: 150,
2410 height: 27, 2357 height: 27,
2411 dropDownWidth: 500, 2358 dropDownWidth: 500,
2420 row["m_amount"] = 0; 2367 row["m_amount"] = 0;
2421 row["m_cost"] = datarecord.cost; 2368 row["m_cost"] = datarecord.cost;
2422 row["m_type"] = datarecord.type; 2369 row["m_type"] = datarecord.type;
2423 row["m_use_use"] = datarecord.use_use; 2370 row["m_use_use"] = datarecord.use_use;
2424 row["m_time"] = 0; 2371 row["m_time"] = 0;
2425 row["m_weight"] = 0;
2426 row["m_amount_is_weight"] = datarecord.amount_is_weight; 2372 row["m_amount_is_weight"] = datarecord.amount_is_weight;
2373 row["m_inventory"] = datarecord.inventory;
2427 var commit = $("#miscGrid").jqxGrid('addrow', null, row); 2374 var commit = $("#miscGrid").jqxGrid('addrow', null, row);
2428 } 2375 }
2429 }); 2376 });
2430 $("#minstockbutton").jqxCheckBox({ theme: theme, height: 27 }); 2377 $("#minstockbutton").jqxCheckBox({ theme: theme, height: 27 });
2431 $("#minstockbutton").on('change', function (event) { 2378 $("#minstockbutton").on('change', function (event) {
2432 miscinstock = event.args.checked; 2379 miscinstock = event.args.checked;
2433 misclist.dataBind(); 2380 misclist.dataBind();
2434 }); 2381 });
2435 // delete selected misc. 2382 // delete selected misc.
2436 $("#mdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); 2383 $("#mdeleterowbutton").jqxButton({ template: "danger", theme: theme, height: 27, width: 150 });
2437 $("#mdeleterowbutton").on('click', function () { 2384 $("#mdeleterowbutton").on('click', function () {
2438 var selectedrowindex = $("#miscGrid").jqxGrid('getselectedrowindex'); 2385 var selectedrowindex = $("#miscGrid").jqxGrid('getselectedrowindex');
2439 var rowscount = $("#miscGrid").jqxGrid('getdatainformation').rowscount; 2386 var rowscount = $("#miscGrid").jqxGrid('getdatainformation').rowscount;
2440 var type = $("#miscGrid").jqxGrid('getcellvalue', selectedrowindex, "m_type"); 2387 var type = $("#miscGrid").jqxGrid('getcellvalue', selectedrowindex, "m_type");
2441 if (selectedrowindex >= 0 && selectedrowindex < rowscount && type != "Water agent") { 2388 if (selectedrowindex >= 0 && selectedrowindex < rowscount && type != 4) { // Water agent
2442 var id = $("#miscGrid").jqxGrid('getrowid', selectedrowindex); 2389 var id = $("#miscGrid").jqxGrid('getrowid', selectedrowindex);
2443 var commit = $("#miscGrid").jqxGrid('deleterow', id); 2390 var commit = $("#miscGrid").jqxGrid('deleterow', id);
2444 } 2391 }
2445 }); 2392 });
2446 }, 2393 },
2447 ready: function() { 2394 ready: function() {
2448 $('#jqxTabs').jqxTabs('next'); 2395 $('#jqxTabs').jqxTabs('next');
2449 }, 2396 },
2450 columns: [ 2397 columns: [
2451 { text: 'Ingredient', editable: false, datafield: 'm_name' }, 2398 { text: 'Ingredient', datafield: 'm_name' },
2452 { text: 'Type', editable: false, width: 120, align: 'center', cellsalign: 'center', datafield: 'm_type' }, 2399 { text: 'Type', width: 140, datafield: 'm_type',
2453 { text: 'Gebruik', width: 110, align: 'center', cellsalign: 'center', datafield: 'm_use_use', columntype: 'dropdownlist', 2400 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
2454 createeditor: function (row, column, editor) { 2401 return "<div style='margin: 4px;'>" + MiscTypeData[value].nl + "</div>";
2455 var srcUseUse = [ "Mash", "Boil", "Primary", "Secondary", "Bottling" ]; 2402 }
2456 editor.jqxDropDownList({ autoDropDownHeight: true, source: srcUseUse }); 2403 },
2457 }, 2404 { text: 'Gebruik', width: 140, datafield: 'm_use_use',
2458 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { 2405 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
2459 var type = $("#miscGrid").jqxGrid('getcellvalue', row, "m_type"); 2406 return "<div style='margin: 4px;'>" + MiscUseData[value].nl + "</div>";
2460 if (type == "Water agent")
2461 return oldvalue;
2462 } 2407 }
2408 },
2409 { text: 'Tijd', datafield: 'm_time', width: 90, align: 'right',
2410 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
2411 if (rowdata.m_use_use == 2) { // Boil
2412 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" min.</div>";
2413 } else if ((rowdata.m_use_use == 3) || (rowdata.m_use_use == 4)) { // Primary or Secondary
2414 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value/1440, "f0")+" dagen</div>";
2415 } else {
2416 var tijd = 0;
2417 return "<div style='margin: 4px;'> </div>";
2418 }
2419 },
2463 }, 2420 },
2464 { datafield: 'm_amount_is_weight', hidden: true }, // We need to declare this column 2421 { text: 'Hoeveel', datafield: 'm_amount', width: 110, align: 'right',
2465 { datafield: 'm_amount', hidden: true }, // We need to declare this column 2422 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
2466 { text: 'Hoeveelheid', datafield: 'm_weight', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f2', 2423 var vstr = rowdata.m_amount_is_weight ? "gr":"ml";
2467 columntype: 'numberinput', 2424 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value * 1000,"f2")+" "+vstr+"</div>";
2468 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { 2425 }
2469 var vstr = rowdata.m_amount_is_weight ? "gr":"ml"; 2426 },
2470 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value,"f2")+" "+vstr+"</div>"; 2427 { text: 'Voorraad', datafield: 'm_inventory', width: 110, align: 'right',
2471 }, 2428 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
2472 validation: function (cell, value) { 2429 var vstr = rowdata.m_amount_is_weight ? "gr":"ml";
2473 var high = parseFloat(dataRecord.boil_size) * 1000; 2430 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value * 1000,"f2")+" "+vstr+"</div>";
2474 if (value < 0 || value > high) { 2431 }
2475 return { result: false, message: "Hoeveelheid moet tussen 0 en "+high+" zijn" }; 2432 },
2476 } 2433 { text: 'Wijzig', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () {
2477 return true; 2434 return "Wijzig";
2478 }, 2435 }, buttonclick: function (row) {
2479 initeditor: function (row, cellvalue, editor) { 2436 miscRow = row;
2480 editor.jqxNumberInput({ 2437 miscData = $("#miscGrid").jqxGrid('getrowdata', miscRow);
2481 inputMode: 'simple', min: 0, max: parseFloat(dataRecord.boil_size) * 1000, 2438 if (miscData.m_amount_is_weight)
2482 decimalDigits: 2, spinButtons: false 2439 $("#wm_pmpt_amount").html("Gewicht gram:");
2483 }); 2440 else
2484 }, 2441 $("#wm_pmpt_amount").html("Volume ml:");
2485 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { 2442 $("#wm_name").val(miscData.m_name);
2486 var type = $("#miscGrid").jqxGrid('getcellvalue', row, "m_type"); 2443 $("#wm_amount").val(miscData.m_amount * 1000);
2487 if (type == "Water agent") 2444 if ((miscData.m_use_use == 3) || (miscData.m_use_use == 4)) // Primary or Secondary
2488 return oldvalue; 2445 $("#wm_time").val(miscData.m_time / 1440);
2489 } 2446 else
2490 }, 2447 $("#wm_time").val(miscData.m_time);
2491 { text: 'Tijd', datafield: 'm_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0', 2448 $("#wm_use_use").val(miscData.m_use_use);
2492 columntype: 'numberinput', 2449 // show the popup window.
2493 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { 2450 if (miscData.m_type != 4)
2494 if (rowdata.m_use_use == 'Boil') { 2451 $("#popupMisc").jqxWindow('open');
2495 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" m</div>"; 2452 }
2496 } else if (rowdata.m_use_use == 'Secondary') { 2453 }
2497 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" d</div>";
2498 } else {
2499 var tijd = 0;
2500 return "<div style='margin: 4px;' class='jqx-right-align'> </div>";
2501 }
2502 },
2503 initeditor: function (row, cellvalue, editor, celltext, pressedChar) {
2504 editor.jqxNumberInput({ decimalDigits: 0, digits: 3, min: 0, max: parseFloat(dataRecord.boil_time) });
2505 },
2506 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
2507 var use = $("#miscGrid").jqxGrid('getcellvalue', row, "m_use_use");
2508 if ((use != "Boil") && (use != "Secondary"))
2509 return oldvalue;
2510 },
2511 validation: function (cell, value) {
2512 var high = parseFloat(dataRecord.boil_time);
2513 if (value < 0 || value > high ) {
2514 return { result: false, message: "De tijd moet 0-"+high+" zijn" };
2515 }
2516 return true;
2517 }
2518 }
2519 ] 2454 ]
2520 });
2521 $("#miscGrid").on('cellendedit', function (event) {
2522 var args = event.args;
2523 console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value);
2524 $("#miscGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value);
2525 if (args.datafield == 'm_weight') {
2526 $("#miscGrid").jqxGrid('setcellvalue', args.rowindex, 'm_amount', parseFloat(args.value) / 1000);
2527 }
2528 }); 2455 });
2529 }; 2456 };
2530 2457
2531 // Inline yeasts editor 2458 // Inline yeasts editor
2532 var editYeast = function (data) { 2459 var editYeast = function (data) {
2533 var yeastSource = { 2460 var yeastSource = {
2534 localdata: data.yeasts, 2461 localdata: data.yeasts,
2535 datatype: "local", 2462 datatype: "local",
2536 cache: false, 2463 cache: false,
2464 async: false,
2537 datafields: [ 2465 datafields: [
2538 { name: 'y_name', type: 'string' }, 2466 { name: 'y_name', type: 'string' },
2539 { name: 'y_laboratory', type: 'string' }, 2467 { name: 'y_laboratory', type: 'string' },
2540 { name: 'y_product_id', type: 'string' }, 2468 { name: 'y_product_id', type: 'string' },
2541 { name: 'y_amount', type: 'float' }, 2469 { name: 'y_amount', type: 'float' },
2542 { name: 'y_cost', type: 'float' }, 2470 { name: 'y_cost', type: 'float' },
2543 { name: 'y_type', type: 'string' }, 2471 { name: 'y_type', type: 'int' },
2544 { name: 'y_form', type: 'string' }, 2472 { name: 'y_form', type: 'int' },
2545 { name: 'y_time', type: 'float' }, 2473 { name: 'y_flocculation', type: 'int' },
2546 { name: 'y_min_temperature', type: 'float' }, 2474 { name: 'y_min_temperature', type: 'float' },
2547 { name: 'y_max_temperature', type: 'float' }, 2475 { name: 'y_max_temperature', type: 'float' },
2548 { name: 'y_attenuation', type: 'float' }, 2476 { name: 'y_attenuation', type: 'float' },
2549 { name: 'y_amount_is_weight', type: 'bool' }, 2477 { name: 'y_use', type: 'int' },
2550 { name: 'y_use', type: 'string' }, 2478 { name: 'y_cells', type: 'float' },
2551 { name: 'y_weight', type: 'float' } 2479 { name: 'y_inventory', type: 'float' },
2480 { name: 'y_avail', type: 'int' }
2552 ], 2481 ],
2553 addrow: function (rowid, rowdata, position, commit) { 2482 addrow: function (rowid, rowdata, position, commit) {
2554 commit(true); 2483 commit(true);
2555 }, 2484 },
2556 deleterow: function (rowid, commit) { 2485 deleterow: function (rowid, commit) {
2557 commit(true); 2486 commit(true);
2558 } 2487 }
2559 }; 2488 };
2560 var yeastAdapter = new $.jqx.dataAdapter(yeastSource, { 2489 var yeastAdapter = new $.jqx.dataAdapter(yeastSource);
2561 beforeLoadComplete: function (records) {
2562 var data = new Array();
2563 for (var i = 0; i < records.length; i++) {
2564 var row = records[i];
2565 if (row.y_form == 'Liquid')
2566 row.y_weight = Math.round(row.y_amount * 17);
2567 else
2568 row.y_weight = row.y_amount * 1000;
2569 data.push(row);
2570 }
2571 return data;
2572 },
2573 loadError: function(jqXHR, status, error) {
2574 $('#err').text(status + ' ' + error);
2575 },
2576 });
2577 $("#yeastGrid").jqxGrid({ 2490 $("#yeastGrid").jqxGrid({
2578 width: 1050, 2491 width: 1240,
2579 height: 300, 2492 height: 400,
2580 source: yeastAdapter, 2493 source: yeastAdapter,
2581 theme: theme, 2494 theme: theme,
2582 selectionmode: 'singlerow', 2495 selectionmode: 'singlerow',
2583 editmode: 'selectedcell',
2584 editable: true,
2585 localization: getLocalization(), 2496 localization: getLocalization(),
2586 showtoolbar: true, 2497 showtoolbar: true,
2587 rendertoolbar: function (toolbar) { 2498 rendertoolbar: function (toolbar) {
2588 var me = this; 2499 var me = this;
2589 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); 2500 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
2590 toolbar.append(container); 2501 toolbar.append(container);
2591 container.append('<div style="float: left; margin-left: 165px;" id="yaddrowbutton"></div>'); 2502 container.append('<div style="float: left; margin-left: 165px;" id="yaddrowbutton"></div>');
2592 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>'); 2503 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>');
2593 container.append('<div style="float: left; margin-left: 10px;" id="yinstockbutton"></div>'); 2504 container.append('<div style="float: left; margin-left: 10px;" id="yinstockbutton"></div>');
2594 container.append('<input style="float: left; margin-left: 230px;" id="ydeleterowbutton" type="button" value="Verwijder gist" />'); 2505 container.append('<input style="float: left; margin-left: 400px;" id="ydeleterowbutton" type="button" value="Verwijder gist" />');
2595 // add yeast from dropdownlist. 2506 // add yeast from dropdownlist.
2596 $("#yaddrowbutton").jqxDropDownList({ 2507 $("#yaddrowbutton").jqxDropDownList({
2597 placeHolder: "Kies gist:", 2508 placeHolder: "Kies gist:",
2598 theme: theme, 2509 theme: theme,
2599 source: yeastlist, 2510 source: yeastlist,
2511 template: "primary",
2600 displayMember: "name", 2512 displayMember: "name",
2601 width: 150, 2513 width: 150,
2602 height: 27, 2514 height: 27,
2603 dropDownWidth: 500, 2515 dropDownWidth: 500,
2604 dropDownHeight: 500, 2516 dropDownHeight: 500,
2617 row["y_product_id"] = datarecord.product_id; 2529 row["y_product_id"] = datarecord.product_id;
2618 row["y_type"] = datarecord.type; 2530 row["y_type"] = datarecord.type;
2619 row["y_form"] = datarecord.form; 2531 row["y_form"] = datarecord.form;
2620 row["y_amount"] = 0; 2532 row["y_amount"] = 0;
2621 row["y_cost"] = datarecord.cost; 2533 row["y_cost"] = datarecord.cost;
2622 row["y_use"] = "Primary"; 2534 row["y_use"] = 0;
2623 row["y_time"] = 0;
2624 if (datarecord.form == "Dry") {
2625 row["y_amount_is_weight"] = 1;
2626 } else {
2627 row["y_amount_is_weight"] = 0;
2628 }
2629 row["y_min_temperature"] = datarecord.min_temperature; 2535 row["y_min_temperature"] = datarecord.min_temperature;
2630 row["y_max_temperature"] = datarecord.max_temperature; 2536 row["y_max_temperature"] = datarecord.max_temperature;
2631 row["y_attenuation"] = datarecord.attenuation; 2537 row["y_attenuation"] = datarecord.attenuation;
2632 row["y_weight"] = 0; 2538 row["y_flocculation"] = datarecord.flocculation;
2539 row["y_cells"] = datarecord.cells;
2540 row["y_inventory"] = datarecord.inventory;
2633 var commit = $("#yeastGrid").jqxGrid('addrow', null, row); 2541 var commit = $("#yeastGrid").jqxGrid('addrow', null, row);
2634 } 2542 }
2635 }); 2543 });
2636 $("#yinstockbutton").jqxCheckBox({ theme: theme, height: 27 }); 2544 $("#yinstockbutton").jqxCheckBox({ theme: theme, height: 27 });
2637 $("#yinstockbutton").on('change', function (event) { 2545 $("#yinstockbutton").on('change', function (event) {
2638 yeastinstock = event.args.checked; 2546 yeastinstock = event.args.checked;
2639 yeastlist.dataBind(); 2547 yeastlist.dataBind();
2640 }); 2548 });
2641 // delete selected yeast. 2549 // delete selected yeast.
2642 $("#ydeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); 2550 $("#ydeleterowbutton").jqxButton({ template: "danger", theme: theme, height: 27, width: 150 });
2643 $("#ydeleterowbutton").on('click', function () { 2551 $("#ydeleterowbutton").on('click', function () {
2644 var selectedrowindex = $("#yeastGrid").jqxGrid('getselectedrowindex'); 2552 var selectedrowindex = $("#yeastGrid").jqxGrid('getselectedrowindex');
2645 var rowscount = $("#yeastGrid").jqxGrid('getdatainformation').rowscount; 2553 var rowscount = $("#yeastGrid").jqxGrid('getdatainformation').rowscount;
2646 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { 2554 if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
2647 var id = $("#yeastGrid").jqxGrid('getrowid', selectedrowindex); 2555 var id = $("#yeastGrid").jqxGrid('getrowid', selectedrowindex);
2652 ready: function() { 2560 ready: function() {
2653 calcSVG(); 2561 calcSVG();
2654 $('#jqxTabs').jqxTabs('next'); 2562 $('#jqxTabs').jqxTabs('next');
2655 }, 2563 },
2656 columns: [ 2564 columns: [
2657 { text: 'Gist', editable: false, datafield: 'y_name' }, 2565 { text: 'Gist', datafield: 'y_name' },
2658 { text: 'Laboratorium', editable: false, width: 150, datafield: 'y_laboratory' }, 2566 { text: 'Laboratorium', width: 150, datafield: 'y_laboratory' },
2659 { text: 'Code', editable: false, width: 90, datafield: 'y_product_id' }, 2567 { text: 'Code', width: 90, datafield: 'y_product_id' },
2660 { text: 'Soort', editable: false, width: 80, align: 'center', cellsalign: 'center', datafield: 'y_form' }, 2568 { text: 'Soort', width: 100, datafield: 'y_form',
2661 { text: 'Min.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_min_temperature' }, 2569 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
2662 { text: 'Max.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_max_temperature' }, 2570 return "<div style='margin: 4px;'>" + YeastFormData[value].nl + "</div>";
2663 { text: 'Attn.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_attenuation', cellsformat: 'f1' }, 2571 }
2664 { text: 'Voor', width: 100, align: 'center', cellsalign: 'center', datafield: 'y_use', columntype: 'dropdownlist', 2572 },
2665 createeditor: function (row, column, editor) { 2573 { text: 'Min. &deg;C', width: 70, align: 'right', cellsalign: 'right', datafield: 'y_min_temperature' },
2666 var srcYUse = [ "Primary", "Secondary", "Bottle" ]; 2574 { text: 'Max. &deg;C', width: 70, align: 'right', cellsalign: 'right', datafield: 'y_max_temperature' },
2667 editor.jqxDropDownList({ autoDropDownHeight: true, source: srcYUse }); 2575 { text: 'Attn. %', width: 70, align: 'right', cellsalign: 'right', datafield: 'y_attenuation', cellsformat: 'f1' },
2576 { text: 'Voor', width: 120, datafield: 'y_use',
2577 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
2578 return "<div style='margin: 4px;'>" + YeastUseData[value].nl + "</div>";
2668 } 2579 }
2669 }, 2580 },
2670 { datafield: 'y_amount', width: 90 }, 2581 { text: 'Hoeveel', datafield: 'y_amount', width: 100, align: 'right',
2671 { text: 'Hoeveel', datafield: 'y_weight', width: 110, align: 'right', cellsalign: 'right', 2582 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
2672 cellsformat: 'f1', columntype: 'numberinput', 2583 if (rowdata.y_form == 0) { // Liquid
2673 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { 2584 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" pk</div>";
2674 if (rowdata.y_form == 'Liquid') { 2585 } else if (rowdata.y_form == 1) { // Dry
2675 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" pk</div>"; 2586 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value*1000, "f1")+" gr</div>";
2676 } else if (rowdata.y_form == 'Dry') { 2587 } else {
2677 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f1")+" gr</div>"; 2588 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value*1000, "f0")+" ml</div>";
2678 } else { 2589 }
2679 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" ml</div>"; 2590 }
2680 } 2591 },
2681 }, 2592 { text: 'Voorraad', datafield: 'y_inventory', width: 100, align: 'right',
2682 initeditor: function (row, cellvalue, editor, celltext, pressedChar) { 2593 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
2683 var form = $("#yeastGrid").jqxGrid('getcellvalue', args.rowindex, 'y_form'); 2594 if (rowdata.y_form == 0) { // Liquid
2684 if (form == 'Dry') { 2595 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" pk</div>";
2685 editor.jqxNumberInput({ decimalDigits: 1, min: 0, spinButtons: false }); 2596 } else if (rowdata.y_form == 1) { // Dry
2686 } else { 2597 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value*1000, "f1")+" gr</div>";
2687 editor.jqxNumberInput({ decimalDigits: 0, min: 0, spinButtons: false }); 2598 } else {
2688 } 2599 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value*1000, "f0")+" ml</div>";
2689 }, 2600 }
2690 validation: function (cell, value) { 2601 }
2691 if (value < 0 || value > 100000000000 ) { 2602 },
2692 return { result: false, message: "Hoeveelheid moet 0-~ zijn" }; 2603 { text: 'Wijzig', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () {
2693 } 2604 return "Wijzig";
2694 return true; 2605 }, buttonclick: function (row) {
2695 } 2606 yeastRow = row;
2696 } 2607 yeastData = $("#yeastGrid").jqxGrid('getrowdata', yeastRow);
2608 if (yeastData.y_form == 0) {
2609 $("#wy_pmpt_amount").html("Pak(ken):");
2610 $("#wy_amount").val(yeastData.y_amount);
2611 $("#wy_amount").jqxNumberInput({ decimalDigits: 0, spinButtonsStep: 1 });
2612 } else if (yeastData.y_form == 1) {
2613 $("#wy_pmpt_amount").html("Gewicht gram:");
2614 $("#wy_amount").val(yeastData.y_amount * 1000);
2615 $("#wy_amount").jqxNumberInput({ decimalDigits: 1, spinButtonsStep: 0.5 });
2616 } else {
2617 $("#wy_pmpt_amount").html("Volume ml:");
2618 $("#wy_amount").val(yeastData.y_amount * 1000);
2619 $("#wy_amount").jqxNumberInput({ decimalDigits: 0, spinButtonsStep: 1 });
2620 }
2621 $("#wy_name").val(yeastData.y_name);
2622 $("#wy_laboratory").val(yeastData.y_laboratory);
2623 $("#wy_product_id").val(yeastData.y_product_id);
2624 $("#wy_use").val(yeastData.y_use);
2625 // show the popup window.
2626 $("#popupYeast").jqxWindow('open');
2627 }
2628 }
2697 ] 2629 ]
2698 });
2699 $("#yeastGrid").on('cellendedit', function (event) {
2700 var args = event.args;
2701 console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value);
2702 $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value);
2703 if (args.datafield == 'y_weight') {
2704 var form = $("#yeastGrid").jqxGrid('getcellvalue', args.rowindex, 'y_form');
2705 if (form == 'Liquid')
2706 $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, 'y_amount', parseFloat(args.value * 0.0588));
2707 else
2708 $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, 'y_amount', parseFloat(args.value / 1000));
2709 }
2710 }); 2630 });
2711 }; 2631 };
2712 2632
2713 // inline mash editor 2633 // inline mash editor
2714 var editMash = function (data) { 2634 var editMash = function (data) {
2725 } 2645 }
2726 var mashSource = { 2646 var mashSource = {
2727 localdata: data.mashs, 2647 localdata: data.mashs,
2728 datatype: "local", 2648 datatype: "local",
2729 cache: false, 2649 cache: false,
2650 async: false,
2730 datafields: [ 2651 datafields: [
2731 { name: 'step_name', type: 'string' }, 2652 { name: 'step_name', type: 'string' },
2732 { name: 'step_type', type: 'string' }, 2653 { name: 'step_type', type: 'int' },
2733 { name: 'step_infuse_amount', type: 'float' }, 2654 { name: 'step_infuse_amount', type: 'float' },
2734 { name: 'step_temp', type: 'float' }, 2655 { name: 'step_temp', type: 'float' },
2735 { name: 'step_time', type: 'float' }, 2656 { name: 'step_time', type: 'float' },
2736 { name: 'ramp_time', type: 'float' }, 2657 { name: 'ramp_time', type: 'float' },
2737 { name: 'end_temp', type: 'float' } 2658 { name: 'end_temp', type: 'float' }
2747 beforeLoadComplete: function (records) { 2668 beforeLoadComplete: function (records) {
2748 mash_infuse = 0; 2669 mash_infuse = 0;
2749 var data = new Array(); 2670 var data = new Array();
2750 for (var i = 0; i < records.length; i++) { 2671 for (var i = 0; i < records.length; i++) {
2751 var row = records[i]; 2672 var row = records[i];
2752 if (row.step_type == 'Infusion') 2673 if (row.step_type == 0) // Infusion
2753 mash_infuse += parseFloat(row.step_infuse_amount); 2674 mash_infuse += parseFloat(row.step_infuse_amount);
2754 } 2675 }
2755 }, 2676 },
2756 }); 2677 });
2757 $("#mashGrid").jqxGrid({ 2678 $("#mashGrid").jqxGrid({
2758 width: 960, 2679 width: 1240,
2759 height: 400, 2680 height: 400,
2760 source: mashAdapter, 2681 source: mashAdapter,
2761 theme: theme, 2682 theme: theme,
2762 selectionmode: 'singlerow', 2683 selectionmode: 'singlerow',
2763 editmode: 'selectedcell',
2764 editable: true,
2765 localization: getLocalization(), 2684 localization: getLocalization(),
2766 showtoolbar: true, 2685 showtoolbar: true,
2767 rendertoolbar: function (toolbar) { 2686 rendertoolbar: function (toolbar) {
2768 var me = this; 2687 var me = this;
2769 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); 2688 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
2770 toolbar.append(container); 2689 toolbar.append(container);
2771 container.append('<input style="float: left; margin-left: 165px;" id="saddrowbutton" type="button" value="Nieuwe stap" />'); 2690 container.append('<input style="float: left; margin-left: 165px;" id="saddrowbutton" type="button" value="Nieuwe stap" />');
2772 container.append('<input style="float: left; margin-left: 230px;" id="sdeleterowbutton" type="button" value="Verwijder stap" />'); 2691 container.append('<input style="float: left; margin-left: 565px;" id="sdeleterowbutton" type="button" value="Verwijder stap" />');
2773 $("#saddrowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); 2692 $("#saddrowbutton").jqxButton({ template: "primary", theme: theme, height: 27, width: 150 });
2774 $("#saddrowbutton").on('click', function () { 2693 $("#saddrowbutton").on('click', function () {
2775 var datarow = generaterow(); 2694 var datarow = generaterow();
2776 var commit = $("#mashGrid").jqxGrid('addrow', null, datarow); 2695 var commit = $("#mashGrid").jqxGrid('addrow', null, datarow);
2777 }); 2696 });
2778 // delete selected yeast. 2697 // delete selected step.
2779 $("#sdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); 2698 $("#sdeleterowbutton").jqxButton({ template: "danger", theme: theme, height: 27, width: 150 });
2780 $("#sdeleterowbutton").on('click', function () { 2699 $("#sdeleterowbutton").on('click', function () {
2781 var selectedrowindex = $("#mashGrid").jqxGrid('getselectedrowindex'); 2700 var selectedrowindex = $("#mashGrid").jqxGrid('getselectedrowindex');
2782 var rowscount = $("#mashGrid").jqxGrid('getdatainformation').rowscount; 2701 var rowscount = $("#mashGrid").jqxGrid('getdatainformation').rowscount;
2783 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { 2702 if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
2784 var id = $("#mashGrid").jqxGrid('getrowid', selectedrowindex); 2703 var id = $("#mashGrid").jqxGrid('getrowid', selectedrowindex);
2785 var commit = $("#mashGrid").jqxGrid('deleterow', id); 2704 var commit = $("#mashGrid").jqxGrid('deleterow', id);
2786 } 2705 }
2787 }); 2706 });
2788 }, 2707 },
2789 ready: function() { 2708 ready: function() {
2790 var fg = estimate_fg(psugar, pcara, 0, 0, 0, svg, parseFloat(parseFloat($("#est_og").jqxNumberInput('decimal')))); 2709 calcFG();
2791 dataRecord.est_fg = fg;
2792 $('#est_fg').val(fg);
2793 $('#est_fg2').val(fg);
2794 calcInit(); 2710 calcInit();
2795 $('#jqxLoader').jqxLoader('close'); 2711 $('#jqxLoader').jqxLoader('close');
2796 $('#jqxTabs').jqxTabs('first'); 2712 $('#jqxTabs').jqxTabs('first');
2797 }, 2713 },
2798 columns: [ 2714 columns: [
2799 { text: 'Stap naam', datafield: 'step_name' }, 2715 { text: 'Stap naam', datafield: 'step_name' },
2800 { text: 'Stap type', datafield: 'step_type', width: 110, columntype: 'dropdownlist', 2716 { text: 'Stap type', datafield: 'step_type', width: 175,
2801 createeditor: function (row, cellvalue, editor, celltext, cellwidth, cellheight) { 2717 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
2802 var dataSource = [ "Infusion", "Temperature", "Decoction" ]; 2718 return "<div style='margin: 4px;'>" + MashStepTypeData[value].nl + "</div>";
2803 editor.jqxDropDownList({ source: dataSource, dropDownHeight: 105 });
2804 } 2719 }
2805 }, 2720 },
2806 { text: 'Temperatuur', datafield: 'step_temp', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', 2721 { text: 'Start &deg;C', datafield: 'step_temp', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
2807 validation: function (cell, value) { 2722 { text: 'Eind &deg;C', datafield: 'end_temp', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
2808 if (value < 35 || value > 80) { 2723 { text: 'Tijd', datafield: 'step_time', width: 90, align: 'right', cellsalign: 'right' },
2809 return { result: false, message: "De temperatuur moet tussen 35 en 80 zijn." }; 2724 { text: 'Stap', datafield: 'ramp_time', width: 90, align: 'right', cellsalign: 'right' },
2810 } 2725 { text: 'Infuse', datafield: 'step_infuse_amount', width: 90, align: 'right', cellsalign: 'right' },
2811 return true; 2726 { text: 'Wijzig', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () {
2812 } 2727 return "Wijzig";
2813 }, 2728 }, buttonclick: function (row) {
2814 { text: 'Eind', datafield: 'end_temp', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', 2729 mashRow = row;
2815 validation: function (cell, value) { 2730 mashData = $("#mashGrid").jqxGrid('getrowdata', mashRow);
2816 if (value < 35 || value > 80) { 2731 $("#wstep_name").val(mashData.step_name);
2817 return { result: false, message: "De temperatuur moet tussen 35 en 80 zijn." }; 2732 $("#wstep_type").val(mashData.step_type);
2818 } 2733 $("#wstep_infuse_amount").val(mashData.step_infuse_amount);
2819 return true; 2734 $("#wstep_temp").val(mashData.step_temp);
2820 } 2735 $("#wend_temp").val(mashData.end_temp);
2821 }, 2736 $("#wstep_time").val(mashData.step_time);
2822 { text: 'Tijd', datafield: 'step_time', width: 70, align: 'right', cellsalign: 'right', 2737 $("#wramp_time").val(mashData.ramp_time);
2823 validation: function (cell, value) { 2738 if (mashData.step_type == 0) {
2824 if (value < 1 || value > 360) { 2739 $("#wstep_infuse_amount").show();
2825 return { result: false, message: "De tijd moet tussen 1 en 360 zijn." }; 2740 $("#wstep_pmpt").show();
2826 } 2741 } else {
2827 return true; 2742 $("#wstep_infuse_amount").hide();
2828 } 2743 $("#wstep_pmpt").hide();
2829 }, 2744 }
2830 { text: 'Stap', datafield: 'ramp_time', width: 70, align: 'right', cellsalign: 'right', 2745 // show the popup window.
2831 validation: function (cell, value) { 2746 $("#popupMash").jqxWindow('open');
2832 if (value < 1 || value > 60) { 2747 }
2833 return { result: false, message: "De tijd moet tussen 1 en 60 zijn." }; 2748 }
2834 }
2835 return true;
2836 }
2837 },
2838 { text: 'Infuse', datafield: 'step_infuse_amount', width: 70, align: 'right', cellsalign: 'right',
2839 validation: function (cell, value) {
2840 if (value < 0 || value > 60) {
2841 return { result: false, message: "De waarde moet tussen 0 en 60 zijn." };
2842 }
2843 return true;
2844 }
2845 }
2846 ] 2749 ]
2847 }); 2750 });
2848 $("#mashGrid").on('cellendedit', function (event) {
2849 $('#mashGrid').jqxGrid('sortby', 'step_temp', 'asc');
2850 });
2851 }; 2751 };
2852 2752
2853 // initialize the input fields. 2753 // initialize the input fields.
2854 var srcType = [ "All Grain", "Partial Mash", "Extract" ]; 2754 // var srcType = [ "All Grain", "Partial Mash", "Extract" ];
2855 var srcColor = [ "Morey", "Mosher", "Daniels" ]; 2755 var srcColor = [ "Morey", "Mosher", "Daniels" ];
2856 var srcIBU = [ "Tinseth", "Rager", "Daniels" ]; // Only these are supported at this time. 2756 var srcIBU = [ "Tinseth", "Rager", "Daniels" ]; // Only these are supported at this time.
2857 var srcBase = [ "NaHCO3", "Na2CO3", "CaCO3", "Ca(OH)2" ]; 2757 var srcBase = [ "NaHCO3", "Na2CO3", "CaCO3", "Ca(OH)2" ];
2858 var srcAcid = [ "Melkzuur", "Zoutzuur", "Fosforzuur", "Zwavelzuur" ]; 2758 var srcAcid = [ "Melkzuur", "Zoutzuur", "Fosforzuur", "Zwavelzuur" ];
2859 var srcSource = [ "Bron 1", "Bron 2", "Gemengd" ]; 2759 var srcSource = [ "Bron 1", "Bron 2", "Gemengd" ];
2892 } 2792 }
2893 }); 2793 });
2894 $("#notes").jqxTooltip({ content: 'De uitgebreide opmerkingen over dit product.' }); 2794 $("#notes").jqxTooltip({ content: 'De uitgebreide opmerkingen over dit product.' });
2895 $("#notes").jqxInput({ theme: theme, width: 960, height: 100 }); 2795 $("#notes").jqxInput({ theme: theme, width: 960, height: 100 });
2896 $("#type").jqxTooltip({ content: 'Het brouw type van dit recept.' }); 2796 $("#type").jqxTooltip({ content: 'Het brouw type van dit recept.' });
2897 $("#type").jqxDropDownList({ theme: theme, source: srcType, width: 125, height: 23, dropDownHeight: 95 }); 2797 $("#type").jqxDropDownList({
2798 theme: theme,
2799 source: RecipeTypeAdapter,
2800 valueMember: 'id',
2801 displayMember: 'nl',
2802 width: 180,
2803 height: 23,
2804 autoDropDownHeight: true
2805 });
2898 $("#efficiency").jqxTooltip({ content: 'Het rendement van maischen en koken.' }); 2806 $("#efficiency").jqxTooltip({ content: 'Het rendement van maischen en koken.' });
2899 $("#efficiency").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 40, max: 100, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); 2807 $("#efficiency").jqxNumberInput( Perc1dec5 );
2900
2901 $("#batch_size").jqxTooltip({ content: 'Het volume van het gekoelde wort na het koken.' }); 2808 $("#batch_size").jqxTooltip({ content: 'Het volume van het gekoelde wort na het koken.' });
2902 $("#batch_size").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: 'L', symbolPosition: 'right' }); 2809 $("#batch_size").jqxNumberInput( Spin1dec5 );
2810 $("#batch_size").jqxNumberInput({ min: 4 });
2903 $("#boil_time").jqxTooltip({ content: 'De kooktijd in minuten.' }); 2811 $("#boil_time").jqxTooltip({ content: 'De kooktijd in minuten.' });
2904 $("#boil_time").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 360, decimalDigits: 0, spinButtons: true }); 2812 $("#boil_time").jqxNumberInput( PosInt );
2813 $("#boil_time").jqxNumberInput({ min: 4, max: 360 });
2905 $("#boil_size").jqxTooltip({ content: 'Het volume van het wort voor het koken.' }); 2814 $("#boil_size").jqxTooltip({ content: 'Het volume van het wort voor het koken.' });
2906 $("#boil_size").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 2, readOnly: true, symbol: 'L', symbolPosition: 'right' }); 2815 $("#boil_size").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 2, readOnly: true });
2816
2907 $("#st_guide").jqxTooltip({ content: 'De bierstijl gids voor dit recept.'}); 2817 $("#st_guide").jqxTooltip({ content: 'De bierstijl gids voor dit recept.'});
2908 $("#st_guide").jqxInput({ theme: theme, width: 250, height: 23 }); 2818 $("#st_guide").jqxInput({ theme: theme, width: 250, height: 23 });
2909 $("#st_name").jqxTooltip({ content: 'De bierstijl naam voor dit recept.'}); 2819 $("#st_name").jqxTooltip({ content: 'De bierstijl naam voor dit recept.'});
2910 $("#st_name").jqxInput({ theme: theme, width: 250, height: 23 }); 2820 $("#st_name").jqxInput({ theme: theme, width: 250, height: 23 });
2911 $("#st_letter").jqxTooltip({ content: 'De bierstijl letter voor dit recept.'}); 2821 $("#st_letter").jqxTooltip({ content: 'De bierstijl letter voor dit recept.'});
2916 $("#st_category").jqxInput({ theme: theme, width: 250, height: 23 }); 2826 $("#st_category").jqxInput({ theme: theme, width: 250, height: 23 });
2917 $("#st_category_number").jqxTooltip({ content: 'De Amerikaanse bierstijl categorie sub nummer.'}); 2827 $("#st_category_number").jqxTooltip({ content: 'De Amerikaanse bierstijl categorie sub nummer.'});
2918 $("#st_category_number").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); 2828 $("#st_category_number").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
2919 2829
2920 $("#est_og").jqxTooltip({ content: 'Het begin SG wat je wilt bereiken. De moutstort wordt automatisch herberekend.' }); 2830 $("#est_og").jqxTooltip({ content: 'Het begin SG wat je wilt bereiken. De moutstort wordt automatisch herberekend.' });
2921 $("#est_og").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 1.000, max: 1.200, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 }); 2831 $("#est_og").jqxNumberInput( SGopts );
2922 $("#st_og_min").jqxTooltip({ content: 'Het minimum begin SG voor deze bierstijl.'}); 2832 $("#st_og_min").jqxTooltip({ content: 'Het minimum begin SG voor deze bierstijl.'});
2923 $("#st_og_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); 2833 $("#st_og_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true });
2924 $("#st_og_max").jqxTooltip({ content: 'Het maximum begin SG voor deze bierstijl.'}); 2834 $("#st_og_max").jqxTooltip({ content: 'Het maximum begin SG voor deze bierstijl.'});
2925 $("#st_og_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); 2835 $("#st_og_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true });
2836
2926 $("#est_fg").jqxTooltip({ content: 'Het eind SG. Dit wordt automatisch berekend.' }); 2837 $("#est_fg").jqxTooltip({ content: 'Het eind SG. Dit wordt automatisch berekend.' });
2927 $("#est_fg").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 3, readOnly: true }); 2838 $("#est_fg").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 3, readOnly: true });
2928 $("#est_fg2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 70, height: 23, decimalDigits: 3, readOnly: true });
2929 $("#st_fg_min").jqxTooltip({ content: 'Het minimum eind SG voor deze bierstijl.'}); 2839 $("#st_fg_min").jqxTooltip({ content: 'Het minimum eind SG voor deze bierstijl.'});
2930 $("#st_fg_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); 2840 $("#st_fg_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true });
2931 $("#st_fg_max").jqxTooltip({ content: 'Het maximum eind SG voor deze bierstijl.'}); 2841 $("#st_fg_max").jqxTooltip({ content: 'Het maximum eind SG voor deze bierstijl.'});
2932 $("#st_fg_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); 2842 $("#st_fg_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true });
2843
2933 $("#est_abv").jqxTooltip({ content: 'Alcohol volume %. Dit wordt automatisch berekend.' }); 2844 $("#est_abv").jqxTooltip({ content: 'Alcohol volume %. Dit wordt automatisch berekend.' });
2934 $("#est_abv").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); 2845 $("#est_abv").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
2935 $("#st_abv_min").jqxTooltip({ content: 'Het minimum alcohol volume % voor deze bierstijl.'}); 2846 $("#st_abv_min").jqxTooltip({ content: 'Het minimum alcohol volume % voor deze bierstijl.'});
2936 $("#st_abv_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); 2847 $("#st_abv_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
2937 $("#st_abv_max").jqxTooltip({ content: 'Het maximum alcohol volume % voor deze bierstijl.'}); 2848 $("#st_abv_max").jqxTooltip({ content: 'Het maximum alcohol volume % voor deze bierstijl.'});
2938 $("#st_abv_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); 2849 $("#st_abv_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
2850
2939 $("#est_color").jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' }); 2851 $("#est_color").jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' });
2940 $("#est_color").jqxNumberInput({ inputMode: 'simple', theme: theme, symbol: ' EBC', symbolPosition: 'right', width: 100, height: 23, decimalDigits: 0, readOnly: true }); 2852 $("#est_color").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 0, readOnly: true });
2941 $("#st_color_min").jqxTooltip({ content: 'De minimum kleur voor deze bierstijl.'}); 2853 $("#st_color_min").jqxTooltip({ content: 'De minimum kleur voor deze bierstijl.'});
2942 $("#st_color_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); 2854 $("#st_color_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
2943 $("#st_color_max").jqxTooltip({ content: 'De maximum kleur voor deze bierstijl.'}); 2855 $("#st_color_max").jqxTooltip({ content: 'De maximum kleur voor deze bierstijl.'});
2944 $("#st_color_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); 2856 $("#st_color_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
2945 $("#color_method").jqxDropDownList({ theme: theme, source: srcColor, width: 125, height: 23, dropDownHeight: 95 }); 2857 $("#color_method").jqxDropDownList({
2858 theme: theme,
2859 source: ColorMethodAdapter,
2860 valueMember: 'id',
2861 displayMember: 'nl',
2862 width: 180,
2863 height: 23,
2864 autoDropDownHeight: true
2865 });
2866
2946 $("#est_ibu").jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' }); 2867 $("#est_ibu").jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' });
2947 $("#est_ibu").jqxNumberInput({ inputMode: 'simple', theme: theme, symbol: ' IBU', symbolPosition: 'right', width: 100, height: 23, decimalDigits: 0, readOnly: true }); 2868 $("#est_ibu").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 0, readOnly: true });
2948 $("#st_ibu_min").jqxTooltip({ content: 'De minimum bitterheid voor deze bierstijl.'}); 2869 $("#st_ibu_min").jqxTooltip({ content: 'De minimum bitterheid voor deze bierstijl.'});
2949 $("#st_ibu_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); 2870 $("#st_ibu_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
2950 $("#st_ibu_max").jqxTooltip({ content: 'De maximum bitterheid voor deze bierstijl.'}); 2871 $("#st_ibu_max").jqxTooltip({ content: 'De maximum bitterheid voor deze bierstijl.'});
2951 $("#st_ibu_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); 2872 $("#st_ibu_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
2952 $("#ibu_method").jqxDropDownList({ theme: theme, source: srcIBU, width: 125, height: 23, dropDownHeight: 95, dropDownVerticalAlignment: 'top' }); 2873 $("#ibu_method").jqxDropDownList({
2874 theme: theme,
2875 source: IBUmethodAdapter,
2876 valueMember: 'id',
2877 displayMember: 'nl',
2878 width: 180,
2879 height: 23,
2880 autoDropDownHeight: true,
2881 dropDownVerticalAlignment: 'top'
2882 });
2883
2953 $("#est_carb").jqxTooltip({ content: 'Koolzuur volume. Dit wordt automatisch berekend.' }); 2884 $("#est_carb").jqxTooltip({ content: 'Koolzuur volume. Dit wordt automatisch berekend.' });
2954 $("#est_carb").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); 2885 $("#est_carb").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
2955 $("#st_carb_min").jqxTooltip({ content: 'Het minimum koolzuur volume voor deze bierstijl.'}); 2886 $("#st_carb_min").jqxTooltip({ content: 'Het minimum koolzuur volume voor deze bierstijl.'});
2956 $("#st_carb_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); 2887 $("#st_carb_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
2957 $("#st_carb_max").jqxTooltip({ content: 'Het maximum koolzuur volume voor deze bierstijl.'}); 2888 $("#st_carb_max").jqxTooltip({ content: 'Het maximum koolzuur volume voor deze bierstijl.'});
2993 $("#eq_efficiency").jqxTooltip({ content: 'Gemiddeld brouwzaal rendement.' }); 2924 $("#eq_efficiency").jqxTooltip({ content: 'Gemiddeld brouwzaal rendement.' });
2994 $("#eq_efficiency").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); 2925 $("#eq_efficiency").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 });
2995 2926
2996 // Tab 3, Fermentables 2927 // Tab 3, Fermentables
2997 $("#est_color2").jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' }); 2928 $("#est_color2").jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' });
2998 $("#est_color2").jqxNumberInput({ inputMode: 'simple', theme: theme, symbol: ' EBC', symbolPosition: 'right', width: 100, height: 23, decimalDigits: 0, readOnly: true }); 2929 $("#est_color2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 0, readOnly: true });
2930 $("#est_og2").jqxTooltip({ content: 'Het geschatte begin SG van dit product.' });
2931 $("#est_og2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 3, readOnly: true });
2999 $("#perc_malts").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); 2932 $("#perc_malts").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true });
3000 $("#est_og2").jqxTooltip({ content: 'Het geschatte begin SG van dit product.' });
3001 $("#est_og2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 3, readOnly: true });
3002 $("#perc_sugars").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); 2933 $("#perc_sugars").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true });
3003 $("#perc_cara").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); 2934 $("#perc_cara").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true });
2935 $("#popupFermentable").jqxWindow({
2936 width: 800,
2937 height: 300,
2938 position: { x: 230, y: 100 },
2939 resizable: false,
2940 theme: theme,
2941 isModal: true,
2942 autoOpen: false,
2943 cancelButton: $("#FermentableReady"),
2944 modalOpacity: 0.40
2945 });
2946 $("#FermentableReady").jqxButton({ template: "success", width: '90px', theme: theme });
2947 $("#FermentableReady").click(function () {
2948 $("#fermentableGrid").jqxGrid('sortby', 'f_amount', 'desc');
2949 // Recalc percentages
2950 calcFermentables();
2951 calcSVG();
2952 calcFG();
2953 calcABV();
2954 calcIBUs();
2955 // Waters: yes there is impact.
2956 });
2957 $("#wf_name").jqxInput({ theme: theme, width: 320, height: 23 });
2958 $("#wf_instock").jqxCheckBox({ theme: theme, height: 23 });
2959 $("#wf_instock").on('change', function (event) {
2960 fermentableinstock = event.args.checked;
2961 fermentablelist.dataBind();
2962 });
2963 $("#wf_select").jqxDropDownList({
2964 placeHolder: "Kies mout:",
2965 theme: theme,
2966 source: fermentablelist,
2967 displayMember: "name",
2968 width: 150,
2969 height: 23,
2970 dropDownWidth: 500,
2971 dropDownHeight: 500,
2972 renderer: function (index, label, value) {
2973 var datarecord = fermentablelist.records[index];
2974 return datarecord.supplier+ " / " + datarecord.name + " (" + datarecord.color + " EBC)";
2975 }
2976 });
2977 $("#wf_select").on('select', function (event) {
2978 if (event.args) {
2979 var index = event.args.index;
2980 var datarecord = fermentablelist.records[index];
2981 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', fermentableRow);
2982 $("#wf_name").val(datarecord.name);
2983 rowdata.f_name = datarecord.name;
2984 rowdata.f_origin = datarecord.origin;
2985 rowdata.f_supplier = datarecord.supplier;
2986 rowdata.f_type = datarecord.type;
2987 rowdata.f_cost = datarecord.cost;
2988 rowdata.f_yield = datarecord.yield;
2989 rowdata.f_color = datarecord.color;
2990 rowdata.f_coarse_fine_diff = datarecord.coarse_fine_diff;
2991 rowdata.f_moisture = datarecord.moisture;
2992 rowdata.f_diastatic_power = datarecord.diastatic_power;
2993 rowdata.f_protein = datarecord.protein;
2994 rowdata.f_max_in_batch = datarecord.max_in_batch;
2995 rowdata.f_graintype = datarecord.graintype;
2996 rowdata.f_dissolved_protein = datarecord.dissolved_protein;
2997 rowdata.f_recommend_mash = datarecord.recommend_mash;
2998 rowdata.f_add_after_boil = datarecord.add_after_boil;
2999 rowdata.f_di_ph = datarecord.di_ph;
3000 rowdata.f_acid_to_ph_57 = datarecord.acid_to_ph_57;
3001 rowdata.f_inventory = datarecord.inventory;
3002 }
3003 });
3004 $("#wf_amount").jqxNumberInput( Spin3dec5 );
3005 $('#wf_amount').on('change', function (event) {
3006 console.log("amount changed: "+event.args.value);
3007 $("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_amount', event.args.value);
3008 if (! to_100) {
3009 // Recalculate percentages
3010 console.log("adjust percentages");
3011 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
3012 if (rowscount > 1) {
3013 var tw = 0;
3014 for (i = 0; i < rowscount; i++) {
3015 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
3016 tw += rowdata.f_amount;
3017 };
3018 for (i = 0; i < rowscount; i++) {
3019 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
3020 var percentage = Math.round(rowdata.f_amount / tw * 1000) / 10.0;
3021 $("#fermentableGrid").jqxGrid('setcellvalue', i, "f_percentage", percentage);
3022 // if (i == fermentableRow) // Will crash the script.
3023 // $("#wf_percentage").val(percentage);
3024 };
3025 } else {
3026 $("#fermentableGrid").jqxGrid('setcellvalue', 0, "f_percentage", 100);
3027 }
3028 calcFermentables();
3029 };
3030 });
3031 $("#wf_percentage").jqxNumberInput( Perc1dec1 );
3032 $("#wf_percentage").on('change', function (event) {
3033 var oldvalue = Math.round(fermentableData.f_percentage * 10) / 10.0;
3034 var newvalue = event.args.value;
3035 console.log("percentage changed: "+newvalue+" old: "+oldvalue);
3036 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
3037 if ((oldvalue != newvalue) && (rowscount > 1)) {
3038 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', fermentableRow);
3039 if (rowdata.f_adjust_to_total_100) {
3040 $("#wf_percentage").val(oldvalue);
3041 } else {
3042 var diff = newvalue - oldvalue;
3043 var tw = 0; // total weight
3044 for (i = 0; i < rowscount; i++) {
3045 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
3046 tw += rowdata.f_amount;
3047 }
3048 if (to_100) {
3049 // Adjust this row and the 100% row.
3050 var damount = tw * diff / 100;
3051 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', fermentableRow);
3052 var namount = rowdata.f_amount + damount;
3053 $("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_amount', namount);
3054 $("#wf_amount").val(namount);
3055 $("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_percentage', rowdata.f_percentage + diff);
3056 for (i = 0; i < rowscount; i++) {
3057 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
3058 if (rowdata.f_adjust_to_total_100) {
3059 namount = rowdata.f_amount - damount;
3060 $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_percentage', rowdata.f_percentage - diff);
3061 $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_amount', namount);
3062 }
3063 }
3064 calcFermentables();
3065 } else {
3066 // Adjust all the rows.
3067 var nw = tw * diff / 100;
3068 for (i = 0; i < rowscount; i++) {
3069 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
3070 if (i == fermentableRow) {
3071 var namount = rowdata.f_amount + nw;
3072 $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_amount', namount);
3073 // $("#wf_amount").val(namount); // Will crash the script.
3074 $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_percentage', newvalue);
3075 } else {
3076 var namount = rowdata.f_amount - (nw / (rowscount - 1));
3077 var newperc = Math.round((namount / tw) * 1000) / 10.0;
3078 $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_amount', namount);
3079 $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_percentage', newperc);
3080 }
3081 }
3082 calcFermentables();
3083 }
3084 }
3085 }
3086 });
3087 $("#wf_adjust_to_total_100").jqxCheckBox({ theme: theme, width: 120, height: 23 });
3088 $("#wf_adjust_to_total_100").on('checked', function (event) {
3089 if (fermentableData.f_adjust_to_total_100 == 0) {
3090 if (to_100) {
3091 // Reset other flag first.
3092 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
3093 for (var i = 0; i < rowscount; i++) {
3094 if (i != fermentableRow) {
3095 $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_adjust_to_total_100', 0);
3096 }
3097 }
3098 }
3099 $("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_adjust_to_total_100', 1);
3100 calcFermentables();
3101 }
3102 });
3103 $("#wf_adjust_to_total_100").on('unchecked', function (event) {
3104 if (fermentableData.f_adjust_to_total_100 != 0) {
3105 $("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_adjust_to_total_100', 0);
3106 calcFermentables();
3107 }
3108 });
3109 $("#wf_added").jqxDropDownList({
3110 theme: theme,
3111 source: AddedAdapter,
3112 valueMember: 'id',
3113 displayMember: 'nl',
3114 width: 180,
3115 height: 23,
3116 autoDropDownHeight: true,
3117 dropDownVerticalAlignment: 'top'
3118 });
3004 3119
3005 // Tab 4, Hops 3120 // Tab 4, Hops
3006 $("#est_ibu2").jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' }); 3121 $("#est_ibu2").jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' });
3007 $("#est_ibu2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); 3122 $("#est_ibu2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
3008 $("#hop_flavour").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); 3123 $("#hop_flavour").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true });
3009 $("#hop_aroma").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); 3124 $("#hop_aroma").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true });
3125 $("#popupHop").jqxWindow({
3126 width: 800,
3127 height: 300,
3128 position: { x: 230, y: 100 },
3129 resizable: false,
3130 theme: theme,
3131 isModal: true,
3132 autoOpen: false,
3133 cancelButton: $("#HopReady"),
3134 modalOpacity: 0.40
3135 });
3136 $("#HopReady").jqxButton({ template: "success", width: '90px', theme: theme });
3137 $("#HopReady").click(function () {
3138 $("#hopGrid").jqxGrid('sortby', 'h_amount', 'asc');
3139 calcIBUs();
3140 });
3141 $("#wh_name").jqxInput({ theme: theme, width: 320, height: 23 });
3142 $("#wh_instock").jqxCheckBox({ theme: theme, height: 23 });
3143 $("#wh_instock").on('change', function (event) {
3144 hopinstock = event.args.checked;
3145 hoplist.dataBind();
3146 });
3147 $("#wh_select").jqxDropDownList({
3148 placeHolder: "Kies hop:",
3149 theme: theme,
3150 source: hoplist,
3151 displayMember: "name",
3152 width: 150,
3153 height: 23,
3154 dropDownWidth: 500,
3155 dropDownHeight: 500,
3156 renderer: function (index, label, value) {
3157 var datarecord = hoplist.records[index];
3158 return datarecord.origin+ " / " + datarecord.name + " (" + datarecord.alpha + " % &alpha;)";
3159 }
3160 });
3161 $("#wh_select").on('select', function (event) {
3162 if (event.args) {
3163 var index = event.args.index;
3164 var datarecord = hoplist.records[index];
3165 var rowdata = $("#hopGrid").jqxGrid('getrowdata', hopRow);
3166 $("#wh_name").val(datarecord.name);
3167 rowdata.h_name = datarecord.name;
3168 rowdata.h_origin = datarecord.origin;
3169 rowdata.h_cost = datarecord.cost;
3170 rowdata.h_type = datarecord.type;
3171 rowdata.h_form = datarecord.form;
3172 rowdata.h_alpha = datarecord.alpha;
3173 rowdata.h_beta = datarecord.beta;
3174 rowdata.h_hsi = datarecord.hsi;
3175 rowdata.h_humulene = datarecord.humulene;
3176 rowdata.h_caryophyllene = datarecord.caryophyllene;
3177 rowdata.h_cohumulone = datarecord.cohumulone;
3178 rowdata.h_myrcene = datarecord.myrcene;
3179 rowdata.h_total_oil = datarecord.total_oil;
3180 rowdata.h_inventory = datarecord.inventory;
3181 }
3182 });
3183 $("#wh_amount").jqxNumberInput( Spin1dec1 );
3184 $('#wh_amount').on('change', function (event) {
3185 console.log("amount changed: "+event.args.value);
3186 var amount = parseFloat(event.args.value) / 1000;
3187 var rowdata = $("#hopGrid").jqxGrid('getrowdata', hopRow);
3188 var ibu = toIBU(rowdata.h_useat, rowdata.h_form, preboil_sg,
3189 parseFloat($("#batch_size").jqxNumberInput('decimal')),
3190 amount, parseFloat(rowdata.h_time),
3191 parseFloat(rowdata.h_alpha), $("#ibu_method").val()
3192 );
3193 rowdata.h_amount = amount;
3194 calcIBUs();
3195 });
3196 $("#wh_ibu").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 1, readOnly: true });
3197 $("#wh_time").jqxNumberInput( PosInt );
3198 $("#wh_time").on('change', function (event) {
3199 console.log("time changed: "+event.args.value);
3200 var rowdata = $("#hopGrid").jqxGrid('getrowdata', hopRow);
3201 var newtime = parseFloat(event.args.value);
3202 // Check limits and correct
3203 if (rowdata.h_useat == 2) { // Boil
3204 if (newtime > parseFloat($("#boil_time").jqxNumberInput('decimal'))) {
3205 newtime = parseFloat($("#boil_time").jqxNumberInput('decimal'));
3206 $("#wh_time").val(newtime);
3207 }
3208 rowdata.h_time = newtime;
3209 } else if (rowdata.h_useat == 4) { // Whirlpool
3210 if (newtime > 120) {
3211 newtime = 120;
3212 $("#wh_time").val(newtime);
3213 }
3214 rowdata.h_time = newtime;
3215 } else if (rowdata.h_useat == 5) { // Dry hop
3216 if (newtime > 21) {
3217 newtime = 21;
3218 $("#wh_time").val(newtime);
3219 }
3220 rowdata.h_time = newtime * 1440;
3221 }
3222 var ibu = toIBU(rowdata.h_useat, rowdata.h_form, preboil_sg, parseFloat($("#batch_size").jqxNumberInput('decimal')),
3223 parseFloat(rowdata.h_amount), parseFloat(rowdata.h_time), parseFloat(rowdata.h_alpha), $("#ibu_method").val());
3224 $("#wh_ibu").val(ibu);
3225 calcIBUs();
3226 });
3227 $("#wh_useat").jqxDropDownList({
3228 theme: theme,
3229 source: HopUseAdapter,
3230 valueMember: 'id',
3231 displayMember: 'nl',
3232 width: 180,
3233 height: 23,
3234 autoDropDownHeight: true,
3235 dropDownVerticalAlignment: 'top'
3236 });
3237 $("#wh_useat").on('select', function (event) {
3238 if (event.args) {
3239 var index = event.args.index;
3240 var rowdata = $("#hopGrid").jqxGrid('getrowdata', hopRow);
3241 rowdata.h_useat = index;
3242 if ((index == 0) || (index == 1)) { // Mashhop or First wort hop
3243 rowdata.h_time = parseFloat(dataRecord.boil_time);
3244 $("#wh_time").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
3245 $("#wh_time").val(rowdata.h_time);
3246 } else if (index == 3) { // Aroma
3247 rowdata.h_time = 0;
3248 $("#wh_time").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
3249 $("#wh_time").val(0);
3250 } else { // Boil, Whirlpool or Dry hop
3251 $("#wh_time").jqxNumberInput({ spinButtons: true, readOnly: false, width: 110 });
3252 }
3253 if (index == 5) // Dry hop
3254 $("#wh_pmpt_time").html("Tijd in dagen");
3255 else
3256 $("#wh_pmpt_time").html("Tijd in minuten");
3257 }
3258 });
3010 3259
3011 // Tab 5, Miscs 3260 // Tab 5, Miscs
3261 $("#popupMisc").jqxWindow({
3262 width: 800,
3263 height: 275,
3264 position: { x: 230, y: 100 },
3265 resizable: false,
3266 theme: theme,
3267 isModal: true,
3268 autoOpen: false,
3269 cancelButton: $("#MiscReady"),
3270 modalOpacity: 0.40
3271 });
3272 $("#MiscReady").jqxButton({ template: "success", width: '90px', theme: theme });
3273 $("#MiscReady").click(function () {
3274 $("#miscGrid").jqxGrid('sortby', 'm_use_use', 'asc');
3275 });
3276 $("#wm_name").jqxInput({ theme: theme, width: 320, height: 23 });
3277 $("#wm_instock").jqxCheckBox({ theme: theme, height: 23 });
3278 $("#wm_instock").on('change', function (event) {
3279 miscinstock = event.args.checked;
3280 misclist.dataBind();
3281 });
3282 $("#wm_select").jqxDropDownList({
3283 placeHolder: "Kies ingredi&euml;nt:",
3284 theme: theme,
3285 source: misclist,
3286 displayMember: "name",
3287 width: 150,
3288 height: 23,
3289 dropDownWidth: 500,
3290 dropDownHeight: 500
3291 });
3292 $("#wm_select").on('select', function (event) {
3293 if (event.args) {
3294 var index = event.args.index;
3295 var datarecord = misclist.records[index];
3296 var rowdata = $("#miscGrid").jqxGrid('getrowdata', miscRow);
3297 $("#wm_name").val(datarecord.name);
3298 rowdata.m_name = datarecord.name;
3299 rowdata.m_cost = datarecord.cost;
3300 rowdata.m_type = datarecord.type;
3301 rowdata.m_use_use = datarecord.use_use;
3302 rowdata.m_amount_is_weight = datarecord.amount_is_weight;
3303 rowdata.m_inventory = datarecord.inventory;
3304 }
3305 });
3306 $("#wm_amount").jqxNumberInput( Spin1dec1 );
3307 $('#wm_amount').on('change', function (event) {
3308 console.log("amount changed: "+event.args.value);
3309 var amount = parseFloat(event.args.value) / 1000;
3310 var rowdata = $("#miscGrid").jqxGrid('getrowdata', miscRow);
3311 rowdata.m_amount = amount;
3312 });
3313 $("#wm_time").jqxNumberInput( PosInt );
3314 $("#wm_time").on('change', function (event) {
3315 console.log("time changed: "+event.args.value);
3316 var rowdata = $("#miscGrid").jqxGrid('getrowdata', miscRow);
3317 var newtime = parseFloat(event.args.value);
3318
3319 if (rowdata.m_use_use == 2) { // Boil
3320 if (newtime > parseFloat($("#boil_time").jqxNumberInput('decimal'))) {
3321 newtime = parseFloat($("#boil_time").jqxNumberInput('decimal'));
3322 $("#wm_time").val(newtime);
3323 }
3324 rowdata.m_time = newtime;
3325 } else if ((rowdata.m_use_use == 3) || (rowdata.m_use_use == 4)) { // Primary or Secondary
3326 if (newtime > 21) {
3327 newtime = 21;
3328 $("#wm_time").val(newtime);
3329 }
3330 rowdata.m_time = newtime * 1440;
3331 }
3332 });
3333 $("#wm_use_use").jqxDropDownList({
3334 theme: theme,
3335 source: MiscUseAdapter,
3336 valueMember: 'id',
3337 displayMember: 'nl',
3338 width: 180,
3339 height: 23,
3340 autoDropDownHeight: true,
3341 dropDownVerticalAlignment: 'top'
3342 });
3343 $("#wm_use_use").on('select', function (event) {
3344 if (event.args) {
3345 var index = event.args.index;
3346 var rowdata = $("#miscGrid").jqxGrid('getrowdata', miscRow);
3347 rowdata.m_use_use = index;
3348 if ((index == 2) || (index == 3) || (index == 4)) { // Boil, Primary or Secondary
3349 $("#wm_time").jqxNumberInput({ spinButtons: true, readOnly: false, width: 110 });
3350 } else {
3351 rowdata.m_time = 0;
3352 $("#wm_time").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
3353 $("#wm_time").val(0);
3354 }
3355 }
3356 });
3012 3357
3013 // Tab 6, Yeasts 3358 // Tab 6, Yeasts
3359 $("#est_fg2").jqxTooltip({ content: 'Het eind SG. Dit wordt automatisch berekend.' });
3360 $("#est_fg2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 3, readOnly: true });
3361 $("#est_abv2").jqxTooltip({ content: 'Alcohol volume %. Dit wordt automatisch berekend.' });
3362 $("#est_abv2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
3363 $("#popupYeast").jqxWindow({
3364 width: 800,
3365 height: 300,
3366 position: { x: 230, y: 100 },
3367 resizable: false,
3368 theme: theme,
3369 isModal: true,
3370 autoOpen: false,
3371 cancelButton: $("#YeastReady"),
3372 modalOpacity: 0.40
3373 });
3374 $("#YeastReady").jqxButton({ template: "success", width: '90px', theme: theme });
3375 $("#YeastReady").click(function () {
3376 calcSVG();
3377 calcFG();
3378 calcABV();
3379 $("#yeastGrid").jqxGrid('sortby', 'y_use', 'asc');
3380 });
3381 $("#wy_name").jqxInput({ theme: theme, width: 320, height: 23 });
3382 $("#wy_laboratory").jqxInput({ theme: theme, width: 320, height: 23 });
3383 $("#wy_product_id").jqxInput({ theme: theme, width: 320, height: 23 });
3384 $("#wy_instock").jqxCheckBox({ theme: theme, height: 23 });
3385 $("#wy_instock").on('change', function (event) {
3386 yeastinstock = event.args.checked;
3387 yeastlist.dataBind();
3388 });
3389 $("#wy_select").jqxDropDownList({
3390 placeHolder: "Kies gist:",
3391 theme: theme,
3392 source: yeastlist,
3393 displayMember: "name",
3394 width: 150,
3395 height: 23,
3396 dropDownWidth: 500,
3397 dropDownHeight: 500,
3398 renderer: function (index, label, value) {
3399 var datarecord = yeastlist.records[index];
3400 return datarecord.laboratory+" "+datarecord.product_id+" "+datarecord.name;
3401 }
3402 });
3403 $("#wy_select").on('select', function (event) {
3404 if (event.args) {
3405 var index = event.args.index;
3406 var datarecord = yeastlist.records[index];
3407 var rowdata = $("#yeastGrid").jqxGrid('getrowdata', yeastRow);
3408 $("#wy_name").val(datarecord.name);
3409 $("#wy_laboratory").val(datarecord.laboratory);
3410 $("#wy_product_id").val(datarecord.product_id);
3411 rowdata.y_name = datarecord.name;
3412 rowdata.y_cost = datarecord.cost;
3413 rowdata.y_type = datarecord.type;
3414 rowdata.y_form = datarecord.form;
3415 rowdata.y_laboratory = datarecord.laboratory;
3416 rowdata.y_product_id = datarecord.product_id;
3417 rowdata.y_min_temperature = datarecord.min_temperature;
3418 rowdata.y_max_temperature = datarecord.max_temperature;
3419 rowdata.y_flocculation = datarecord.flocculation;
3420 rowdata.y_attenuation = datarecord.attenuation;
3421 rowdata.y_cells = datarecord.cells;
3422 rowdata.y_inventory = datarecord.inventory;
3423 if (rowdata.y_form == 0) {
3424 $("#wy_pmpt_amount").html("Pak(ken):");
3425 } else if (rowdata.y_form == 1) {
3426 $("#wy_pmpt_amount").html("Gewicht gram:");
3427 } else {
3428 $("#wy_pmpt_amount").html("Volume ml:");
3429 }
3430 calcSVG();
3431 calcFG();
3432 calcABV();
3433 }
3434 });
3435 $("#wy_amount").jqxNumberInput( Spin1dec5 );
3436 $('#wy_amount').on('change', function (event) {
3437 console.log("amount changed: "+event.args.value);
3438 var rowdata = $("#yeastGrid").jqxGrid('getrowdata', yeastRow);
3439 if (rowdata.y_form == 0) // Liquid
3440 var amount = parseFloat(event.args.value);
3441 else
3442 var amount = parseFloat(event.args.value) / 1000;
3443 rowdata.y_amount = amount;
3444 calcSVG();
3445 calcFG();
3446 calcABV();
3447 });
3448 $("#wy_use").jqxDropDownList({
3449 theme: theme,
3450 source: YeastUseAdapter,
3451 valueMember: 'id',
3452 displayMember: 'nl',
3453 width: 180,
3454 height: 23,
3455 autoDropDownHeight: true,
3456 dropDownVerticalAlignment: 'top'
3457 });
3458 $("#wy_use").on('select', function (event) {
3459 if (event.args) {
3460 var index = event.args.index;
3461 var rowdata = $("#yeastGrid").jqxGrid('getrowdata', yeastRow);
3462 rowdata.y_use = index;
3463 calcSVG();
3464 calcFG();
3465 calcABV();
3466 }
3467 });
3014 3468
3015 // Tab 7, Mashing 3469 // Tab 7, Mashing
3016 $("#mash_name").jqxTooltip({ content: 'De omschrijving van dit maisch profiel.' }); 3470 $("#mash_name").jqxTooltip({ content: 'De omschrijving van dit maisch profiel.' });
3017 $("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 }); 3471 $("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 });
3472 $("#mash_select").jqxDropDownList({
3473 placeHolder: "Kies schema:",
3474 theme: theme,
3475 source: mashlist,
3476 displayMember: "name",
3477 width: 250,
3478 height: 23,
3479 dropDownWidth: 500,
3480 dropDownHeight: 500,
3481 dropDownHorizontalAlignment: 'right'
3482 });
3483 $("#mash_select").on('select', function (event) {
3484 if (event.args) {
3485 var index = event.args.index;
3486 // First delete all current steps
3487 var rowIDs = new Array();
3488 var rows = $("#mashGrid").jqxGrid('getdisplayrows');
3489 for (var i = 0; i < rows.length; i++) {
3490 var row = rows[i];
3491 rowIDs.push(row.uid);
3492 }
3493 $("#mashGrid").jqxGrid('deleterow', rowIDs);
3494 // Then add the new steps
3495 $("#mash_name").val(datarecord.name);
3496 for (var i = 0; i < datarecord.steps.length; i++) {
3497 var data = datarecord.steps[i];
3498 var row = {};
3499 row["step_name"] = data.step_name;
3500 row["step_type"] = data.step_type;
3501 // For now, but this must be smarter.
3502 if (mash_infuse == 0 && dataRecord.w1_amount > 0)
3503 mash_infuse = dataRecord.w1_amount;
3504 if (i == 0)
3505 row["step_infuse_amount"] = mash_infuse;
3506 else
3507 row["step_infuse_amount"] = 0;
3508 row["step_temp"] = data.step_temp;
3509 row["end_temp"] = data.end_temp;
3510 row["step_time"] = data.step_time;
3511 row["ramp_time"] = data.ramp_time;
3512 var commit = $("#mashGrid").jqxGrid('addrow', null, row);
3513 }
3514 }
3515 });
3516 $("#popupMash").jqxWindow({
3517 width: 800,
3518 height: 350,
3519 position: { x: 230, y: 100 },
3520 resizable: false,
3521 theme: theme,
3522 isModal: true,
3523 autoOpen: false,
3524 cancelButton: $("#MashReady"),
3525 modalOpacity: 0.40
3526 });
3527 $("#MashReady").jqxButton({ template: "success", width: '90px', theme: theme });
3528 $("#MashReady").click(function () {
3529 $("#mashGrid").jqxGrid('sortby', 'step_temp', 'asc');
3530 });
3531 $("#wstep_name").jqxInput({ theme: theme, width: 320, height: 23 });
3532 $("#wstep_type").jqxDropDownList({
3533 theme: theme,
3534 source: MashStepTypeAdapter,
3535 valueMember: 'id',
3536 displayMember: 'nl',
3537 width: 180,
3538 height: 23,
3539 autoDropDownHeight: true
3540 });
3541 $("#wstep_type").on('select', function (event) {
3542 if (event.args) {
3543 var index = event.args.index;
3544 var rowdata = $("#mashGrid").jqxGrid('getrowdata', mashRow);
3545 rowdata.step_type = index;
3546 if (index == 0) {
3547 $("#wstep_infuse_amount").show();
3548 $("#wstep_pmpt").show();
3549 } else {
3550 rowdata.step_infuse_amount = 0;
3551 $("#wstep_infuse_amount").hide();
3552 $("#wstep_pmpt").hide();
3553 }
3554 mash_infuse = 0;
3555 var rows = $('#mashGrid').jqxGrid('getrows');
3556 for (var i = 0; i < rows.length; i++) {
3557 var row = rows[i];
3558 if (row.step_type == 0) // Infusion
3559 mash_infuse += parseFloat(row.step_infuse_amount);
3560 }
3561 }
3562 });
3563 $("#wstep_temp").jqxNumberInput( Spin1dec5 );
3564 $('#wstep_temp').on('change', function (event) {
3565 var rowdata = $("#mashGrid").jqxGrid('getrowdata', mashRow);
3566 rowdata.step_temp = parseFloat(event.args.value);
3567 });
3568 $("#wend_temp").jqxNumberInput( Spin1dec5 );
3569 $('#wend_temp').on('change', function (event) {
3570 var rowdata = $("#mashGrid").jqxGrid('getrowdata', mashRow);
3571 rowdata.end_temp = parseFloat(event.args.value);
3572 });
3573 $("#wstep_time").jqxNumberInput( PosInt );
3574 $('#wstep_time').on('change', function (event) {
3575 var rowdata = $("#mashGrid").jqxGrid('getrowdata', mashRow);
3576 rowdata.step_time = parseFloat(event.args.value);
3577 });
3578 $("#wramp_time").jqxNumberInput( PosInt );
3579 $('#wramp_time').on('change', function (event) {
3580 var rowdata = $("#mashGrid").jqxGrid('getrowdata', mashRow);
3581 rowdata.ramp_time = parseFloat(event.args.value);
3582 });
3583 $("#wstep_infuse_amount").jqxNumberInput( Spin1dec5 );
3584 $('#wstep_infuse_amount').on('change', function (event) {
3585 var rowdata = $("#mashGrid").jqxGrid('getrowdata', mashRow);
3586 rowdata.step_infuse_amount = parseFloat(event.args.value);
3587 mash_infuse = 0;
3588 var rows = $('#mashGrid').jqxGrid('getrows');
3589 for (var i = 0; i < rows.length; i++) {
3590 var row = rows[i];
3591 if (row.step_type == 0) // Infusion
3592 mash_infuse += parseFloat(row.step_infuse_amount);
3593 }
3594 });
3018 3595
3019 // Tab 8, Water 3596 // Tab 8, Water
3020 $("#tgt_bu").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 2, readOnly: true }); 3597 $("#tgt_bu").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 2, readOnly: true });
3021 $("#tgt_cl_so4").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3598 $("#tgt_cl_so4").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3599
3600 // Water source 1
3022 $("#w1_name").jqxDropDownList({ 3601 $("#w1_name").jqxDropDownList({
3023 placeHolder: "Kies hoofd water:", 3602 placeHolder: "Kies hoofd water:",
3024 theme: theme, 3603 theme: theme,
3025 source: waterlist, 3604 source: waterlist,
3026 displayMember: "name", 3605 displayMember: "name",
3059 $("#w1_sodium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3638 $("#w1_sodium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3060 $("#w1_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3639 $("#w1_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3061 $("#w1_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3640 $("#w1_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3062 $("#w1_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3641 $("#w1_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3063 $("#w1_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3642 $("#w1_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3643 // Water source 2
3064 $("#w2_name").jqxDropDownList({ 3644 $("#w2_name").jqxDropDownList({
3065 placeHolder: "Kies meng water:", 3645 placeHolder: "Kies meng water:",
3066 theme: theme, 3646 theme: theme,
3067 source: waterlist, 3647 source: waterlist,
3068 displayMember: "name", 3648 displayMember: "name",
3103 $("#w2_sodium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3683 $("#w2_sodium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3104 $("#w2_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3684 $("#w2_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3105 $("#w2_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3685 $("#w2_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3106 $("#w2_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3686 $("#w2_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3107 $("#w2_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3687 $("#w2_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3108 3688 // Water mixed
3109 $("#wg_amount").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3689 $("#wg_amount").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3110 $("#wg_calcium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3690 $("#wg_calcium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3111 $("#wg_magnesium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3691 $("#wg_magnesium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3112 $("#wg_sodium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3692 $("#wg_sodium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3113 $("#wg_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3693 $("#wg_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3114 $("#wg_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3694 $("#wg_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3115 $("#wg_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3695 $("#wg_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3116 $("#wg_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3696 $("#wg_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3117 3697 // Water treated
3118 $("#wb_calcium").jqxTooltip({ content: 'De ideale hoeveelheid Calcium is tussen 40 en 150.'}); 3698 $("#wb_calcium").jqxTooltip({ content: 'De ideale hoeveelheid Calcium is tussen 40 en 150.'});
3119 $("#wb_calcium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3699 $("#wb_calcium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3120 $("#wb_magnesium").jqxTooltip({ content: 'De ideale hoeveelheid Magnesium is lager dan 30.'}); 3700 $("#wb_magnesium").jqxTooltip({ content: 'De ideale hoeveelheid Magnesium is lager dan 30.'});
3121 $("#wb_magnesium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3701 $("#wb_magnesium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3122 $("#wb_sodium").jqxTooltip({ content: 'De ideale hoeveelheid Natrium is lager dan 150.'}); 3702 $("#wb_sodium").jqxTooltip({ content: 'De ideale hoeveelheid Natrium is lager dan 150.'});
3127 $("#wb_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3707 $("#wb_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3128 $("#wb_sulfate").jqxTooltip({ content: 'De ideale hoeveelheid Sulfaat is lager dan 350.'}); 3708 $("#wb_sulfate").jqxTooltip({ content: 'De ideale hoeveelheid Sulfaat is lager dan 350.'});
3129 $("#wb_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3709 $("#wb_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3130 3710
3131 $("#wb_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3711 $("#wb_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3132 3712 // Water target profile
3133 $("#pr_name").jqxDropDownList({ 3713 $("#pr_name").jqxDropDownList({
3134 placeHolder: "Kies doel profiel:", 3714 placeHolder: "Kies doel profiel:",
3135 theme: theme, 3715 theme: theme,
3136 source: waterprofiles, 3716 source: waterprofiles,
3137 displayMember: "name", 3717 displayMember: "name",
3157 $("#pr_sodium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3737 $("#pr_sodium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3158 $("#pr_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3738 $("#pr_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3159 $("#pr_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3739 $("#pr_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3160 $("#pr_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); 3740 $("#pr_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
3161 3741
3742 // Water agents
3162 $("#wa_cacl2").jqxTooltip({ content: 'Voor het maken van een ander waterprofiel. Voegt calcium en chloride toe. Voor het verbeteren van zoetere bieren.' }); 3743 $("#wa_cacl2").jqxTooltip({ content: 'Voor het maken van een ander waterprofiel. Voegt calcium en chloride toe. Voor het verbeteren van zoetere bieren.' });
3163 $("#wa_cacl2").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, max: 1000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' }); 3744 $("#wa_cacl2").jqxNumberInput( Spin1dec1 );
3745 $("#wa_caso4").jqxTooltip({ content: 'Gips. Voor het maken van een ander waterprofiel. Voegt calcium en sulfaat toe. Voor het verbeteren van bittere bieren.' });
3746 $("#wa_caso4").jqxNumberInput( Spin1dec1 );
3747 $("#wa_mgso4").jqxTooltip({ content: 'Epsom zout. Voor het maken van een ander waterprofiel. Voegt magnesium en sulfaat toe. Gebruik spaarzaam!' });
3748 $("#wa_mgso4").jqxNumberInput( Spin1dec1 );
3749 $("#wa_nacl").jqxTooltip({ content: 'Keukenzout. Voor het maken van een ander waterprofiel. Voegt natrium en chloride toe. Voor het accentueren van zoetheid. Bij hoge dosering wordt het bier ziltig.' });
3750 $("#wa_nacl").jqxNumberInput( Spin1dec1 );
3164 $("#mash_ph").jqxTooltip({ content: 'Maisch pH tussen 5.2 en 5.6. Gebruik 5.2 voor lichte en 5.5 voor donkere bieren.'}); 3751 $("#mash_ph").jqxTooltip({ content: 'Maisch pH tussen 5.2 en 5.6. Gebruik 5.2 voor lichte en 5.5 voor donkere bieren.'});
3165 $("#mash_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 8, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); 3752 $("#mash_ph").jqxNumberInput( SpinpH );
3166 $("#sparge_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 });
3167 $("#wa_caso4").jqxTooltip({ content: 'Gips. Voor het maken van een ander waterprofiel. Voegt calcium en sulfaat toe. Voor het verbeteren van bittere bieren.' });
3168 $("#wa_caso4").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, max: 1000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' });
3169 $("#calc_acid").jqxCheckBox({ theme: theme, width: 120, height: 23 }); 3753 $("#calc_acid").jqxCheckBox({ theme: theme, width: 120, height: 23 });
3170 $("#sparge_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 70, max: 98, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); 3754 $("#wa_base_name").jqxDropDownList({
3171 $("#wa_mgso4").jqxTooltip({ content: 'Epsom zout. Voor het maken van een ander waterprofiel. Voegt magnesium en sulfaat toe. Gebruik spaarzaam!' }); 3755 theme: theme,
3172 $("#wa_mgso4").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, max: 1000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' }); 3756 source: BaseTypeAdapter,
3173 $("#wa_base_name").jqxDropDownList({ theme: theme, source: srcBase, width: 100, height: 23, dropDownHeight: 128 }); 3757 valueMember: 'id',
3174 $("#wa_base").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.05, symbol: ' gr', symbolPosition: 'right' }); 3758 displayMember: 'nl',
3175 $("#sparge_source").jqxDropDownList({ theme: theme, source: srcSource, width: 100, height: 23, dropDownHeight: 95 }); 3759 width: 170,
3176 $("#wa_nacl").jqxTooltip({ content: 'Keukenzout. Voor het maken van een ander waterprofiel. Voegt natrium en chloride toe. Voor het accentueren van zoetheid. Bij hoge dosering wordt het bier ziltig.' }); 3760 height: 23,
3177 $("#wa_nacl").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, max: 1000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' }); 3761 autoDropDownHeight: true
3178 $("#wa_acid_name").jqxDropDownList({ theme: theme, source: srcAcid, width: 100, height: 23, dropDownHeight: 128 }) 3762 });
3179 $("#wa_acid").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.05, symbol: ' ml', symbolPosition: 'right' }); 3763 $("#wa_base").jqxNumberInput( Spin2dec5 );
3180 $("#wa_acid_perc").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 80, height: 23, min: 0, max: 100, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); 3764 $("#wa_base").jqxNumberInput({ symbol: ' gr', symbolPosition: 'right' });
3181 $("#sparge_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4.5, max: 6.5, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); 3765 $("#wa_acid_name").jqxDropDownList({
3182 $("#sparge_acid_type").jqxDropDownList({ theme: theme, source: srcAcid, width: 100, height: 23, dropDownHeight: 128 }); 3766 theme: theme,
3183 $("#sparge_acid_perc").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, spinButtons: true, decimalDigits: 0, symbol: '%', symbolPosition: 'right' }); 3767 source: AcidTypeAdapter,
3184 $("#sparge_acid_amount").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 2, readOnly: true, symbol: ' ml', symbolPosition: 'right' }); 3768 valueMember: 'id',
3769 displayMember: 'nl',
3770 width: 170,
3771 height: 23,
3772 autoDropDownHeight: true
3773 })
3774 $("#wa_acid").jqxNumberInput( Spin2dec5 );
3775 $("#wa_acid").jqxNumberInput({ symbol: ' ml', symbolPosition: 'right' });
3776 $("#wa_acid_perc").jqxNumberInput( Perc0 );
3777 $("#wa_acid_perc").jqxNumberInput({ width: 70, symbol: '%', symbolPosition: 'right' });
3778 // Sparge water
3779 $("#sparge_temp").jqxNumberInput( Spin1dec5 );
3780 $("#sparge_volume").jqxNumberInput( Spin1dec5 );
3781 $("#sparge_ph").jqxNumberInput( SpinpH );
3782 $("#sparge_source").jqxDropDownList({
3783 theme: theme,
3784 source: SpargeSourceAdapter,
3785 valueMember: 'id',
3786 displayMember: 'nl',
3787 width: 110,
3788 height: 23,
3789 autoDropDownHeight: true
3790 });
3791 $("#sparge_acid_amount").jqxNumberInput( Spin2dec1 );
3792 $("#sparge_acid_amount").jqxNumberInput({ spinButtons: false, readOnly: true, symbol: ' ml', symbolPosition: 'right' });
3793 $("#sparge_acid_type").jqxDropDownList({
3794 theme: theme,
3795 source: AcidTypeAdapter,
3796 valueMember: 'id',
3797 displayMember: 'nl',
3798 width: 110,
3799 height: 23,
3800 autoDropDownHeight: true
3801 });
3802 $("#sparge_acid_perc").jqxNumberInput( Perc0 );
3803 $("#sparge_acid_perc").jqxNumberInput({ symbol: '%', symbolPosition: 'right' });
3185 3804
3186 // Tab 9, Brewday 3805 // Tab 9, Brewday
3187 $("#brew_date_start").jqxDateTimeInput({ theme: theme, width: 230, height: 23, formatString: 'yyyy-MM-dd HH:mm:ss', showTimeButton: true }); 3806 $("#brew_date_start").jqxDateTimeInput({ theme: theme, width: 230, height: 23, formatString: 'yyyy-MM-dd HH:mm:ss', showTimeButton: true });
3188 $("#brew_date_end").jqxDateTimeInput({ theme: theme, width: 230, height: 23, formatString: 'yyyy-MM-dd HH:mm:ss', showTimeButton: true }); 3807 $("#brew_date_end").jqxDateTimeInput({ theme: theme, width: 230, height: 23, formatString: 'yyyy-MM-dd HH:mm:ss', showTimeButton: true });
3189 $("#brew_mash_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); 3808 $("#brew_mash_ph").jqxNumberInput( SpinpH );
3190 $("#est_mash_ph").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); 3809 $("#est_mash_ph").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 });
3191 $("#brew_preboil_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); 3810 $("#brew_preboil_ph").jqxNumberInput( SpinpH );
3192 // est_preboil_ph 3811 // est_preboil_ph
3193 $("#brew_aboil_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); 3812 $("#brew_aboil_ph").jqxNumberInput( SpinpH );
3194 // est_aboil_ph 3813 // est_aboil_ph
3195 $("#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 }); 3814 $("#brew_mash_sg").jqxNumberInput( SGopts );
3196 $("#brew_mash_sg").on('valueChanged', function () { calcMashEfficiency(); }); 3815 $("#brew_mash_sg").on('valueChanged', function () { calcMashEfficiency(); });
3197 $("#est_mash_sg").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 3 }); 3816 $("#est_mash_sg").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 3 });
3198 $("#brew_preboil_sg").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 }); 3817 $("#brew_preboil_sg").jqxNumberInput( SGopts );
3199 $("#brew_aboil_sg").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 }); 3818 $("#brew_aboil_sg").jqxNumberInput( SGopts );
3200 $("#est_og3").jqxTooltip({ content: 'Het geschatte begin SG van dit product.' }); 3819 $("#est_og3").jqxTooltip({ content: 'Het geschatte begin SG van dit product.' });
3201 $("#est_og3").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 70, height: 23, decimalDigits: 3, readOnly: true }); 3820 $("#est_og3").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 70, height: 23, decimalDigits: 3, readOnly: true });
3202 $("#brew_mash_efficiency").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); 3821 $("#brew_mash_efficiency").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 1 });
3203 $("#brew_preboil_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); 3822 $("#brew_preboil_volume").jqxNumberInput( Spin1dec5 );
3204 $("#brew_aboil_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); 3823 $("#brew_aboil_volume").jqxNumberInput( Spin1dec5 );
3205 $("#brew_preboil_efficiency").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); 3824 $("#brew_preboil_efficiency").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 1 });
3206 $("#brew_aboil_efficiency").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); 3825 $("#brew_aboil_efficiency").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 1 });
3207 $("#brew_sparge_temperature").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); 3826 $("#brew_sparge_temperature").jqxNumberInput( Spin1dec5 );
3208 $("#brew_sparge_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); 3827 $("#brew_sparge_volume").jqxNumberInput( Spin1dec5 );
3209 $("#brew_whirlpool9").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 120, decimalDigits: 0, spinButtons: true }); 3828 $("#brew_whirlpool9").jqxNumberInput( PosInt );
3210 $("#brew_cooling_to").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); 3829 $("#brew_whirlpool9").jqxNumberInput({ max: 120 });
3211 $("#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 }); 3830 $("#brew_cooling_to").jqxNumberInput( Spin1dec5 );
3212 $("#brew_whirlpool7").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 120, decimalDigits: 0, spinButtons: true }); 3831 $("#brew_sparge_ph").jqxNumberInput( SpinpH );
3213 $("#brew_cooling_method").jqxDropDownList({ theme: theme, source: srcCooling, width: 170, height: 23, dropDownHeight: 153 }); 3832 $("#brew_whirlpool7").jqxNumberInput( PosInt );
3214 $("#brew_whirlpool6").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 120, decimalDigits: 0, spinButtons: true }); 3833 $("#brew_whirlpool7").jqxNumberInput({ max: 120 });
3215 $("#brew_cooling_time").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 1440, decimalDigits: 0, spinButtons: true }); 3834 $("#brew_cooling_method").jqxDropDownList({
3216 $("#brew_whirlpool2").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 120, decimalDigits: 0, spinButtons: true }); 3835 theme: theme,
3217 $("#brew_aeration_type").jqxDropDownList({ theme: theme, source: srcAeration, width: 100, height: 23, dropDownHeight: 95 }); 3836 source: CoolingTypeAdapter,
3218 $("#brew_aeration_time").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 1440, decimalDigits: 0, spinButtons: true }); 3837 valueMember: 'id',
3219 $("#brew_aeration_speed").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 1440, decimalDigits: 0, spinButtons: true }); 3838 displayMember: 'nl',
3220 $("#brew_fermenter_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); 3839 width: 180,
3221 $("#brew_fermenter_extrawater").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); 3840 height: 23,
3222 $("#brew_fermenter_sg").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 3 }); 3841 autoDropDownHeight: true
3223 $("#brew_fermenter_extrasugar").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); 3842 });
3224 $("#brew_fermenter_ibu").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 0 }); 3843 $("#brew_whirlpool6").jqxNumberInput( PosInt );
3225 $("#brew_fermenter_color").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 0 }); 3844 $("#brew_whirlpool6").jqxNumberInput({ max: 120 });
3845 $("#brew_cooling_time").jqxNumberInput( PosInt );
3846 $("#brew_cooling_time").jqxNumberInput({ max: 1440 });
3847 $("#brew_whirlpool2").jqxNumberInput( PosInt );
3848 $("#brew_whirlpool2").jqxNumberInput({ max: 120 });
3849 $("#brew_aeration_type").jqxDropDownList({
3850 theme: theme,
3851 source: AerationTypeAdapter,
3852 valueMember: 'id',
3853 displayMember: 'nl',
3854 width: 180,
3855 height: 23,
3856 autoDropDownHeight: true
3857 });
3858 $("#brew_aeration_time").jqxNumberInput( PosInt );
3859 $("#brew_aeration_time").jqxNumberInput({ max: 1440 });
3860 $("#brew_aeration_speed").jqxNumberInput( PosInt );
3861 $("#brew_aeration_speed").jqxNumberInput({ max: 1440 });
3862 $("#brew_fermenter_volume").jqxNumberInput( Spin1dec5 );
3863 $("#brew_fermenter_extrawater").jqxNumberInput( Spin1dec1 );
3864 $("#brew_fermenter_sg").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 3 });
3865 $("#brew_fermenter_extrasugar").jqxNumberInput( Spin1dec1 );
3866 $("#brew_fermenter_ibu").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 0 });
3867 $("#brew_fermenter_color").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 0 });
3226 $("#BLog").jqxButton({ template: "info", width: '150px', theme: theme }); 3868 $("#BLog").jqxButton({ template: "info", width: '150px', theme: theme });
3227 $("#BLog").click(function () { 3869 $("#BLog").click(function () {
3228 // Open log in a new tab. 3870 // Open log in a new tab.
3229 var url="log_brew.php?code=" + dataRecord.code; 3871 var url="log_brew.php?code=" + dataRecord.code;
3230 window.open(url); 3872 window.open(url);
3271 var url="log_fermentation.php?code=" + dataRecord.code + "&name=" + dataRecord.name; 3913 var url="log_fermentation.php?code=" + dataRecord.code + "&name=" + dataRecord.name;
3272 window.open(url); 3914 window.open(url);
3273 }); 3915 });
3274 3916
3275 // Tab 11, Packaging 3917 // Tab 11, Packaging
3918 // TODO: high gravity packaging, extra water and recalc abv, color and ibu.
3276 $("#package_date").jqxTooltip({ content: 'De verpakkings datum van dit bier.' }); 3919 $("#package_date").jqxTooltip({ content: 'De verpakkings datum van dit bier.' });
3277 $("#package_date").jqxDateTimeInput({ 3920 $("#package_date").jqxDateTimeInput({
3278 theme: theme, 3921 theme: theme,
3279 width: 150, 3922 width: 150,
3280 height: 23, 3923 height: 23,
3402 record: my_record, 4045 record: my_record,
3403 uuid: dataRecord.uuid, 4046 uuid: dataRecord.uuid,
3404 name: $("#name").val(), 4047 name: $("#name").val(),
3405 code: $("#code").val(), 4048 code: $("#code").val(),
3406 birth: $("#birth").val(), 4049 birth: $("#birth").val(),
3407 stage: $("#stage").val(), 4050 stage: dataRecord.stage,
3408 notes: $("#notes").val(), 4051 notes: $("#notes").val(),
3409 log_brew: dataRecord.log_brew, 4052 log_brew: dataRecord.log_brew,
3410 log_fermentation: dataRecord.log_fermentation, 4053 log_fermentation: dataRecord.log_fermentation,
3411 inventory_reduced: $("#inventory_reduced").val(), 4054 inventory_reduced: $("#inventory_reduced").val(),
3412 locked: $("#locked").val(), 4055 locked: $("#locked").val(),
3497 taste_mouthfeel: $("#taste_mouthfeel").val(), 4140 taste_mouthfeel: $("#taste_mouthfeel").val(),
3498 taste_aftertaste: $("#taste_aftertaste").val(), 4141 taste_aftertaste: $("#taste_aftertaste").val(),
3499 st_name: $('#st_name').val(), 4142 st_name: $('#st_name').val(),
3500 st_letter: $('#st_letter').val(), 4143 st_letter: $('#st_letter').val(),
3501 st_guide: $('#st_guide').val(), 4144 st_guide: $('#st_guide').val(),
3502 st_type: $('#st_type').val(), 4145 st_type: dataRecord.st_type,
3503 st_category: $('#st_category').val(), 4146 st_category: $('#st_category').val(),
3504 st_category_number: parseFloat($("#st_category_number").jqxNumberInput('decimal')), 4147 st_category_number: parseFloat($("#st_category_number").jqxNumberInput('decimal')),
3505 st_og_min: parseFloat($("#st_og_min").jqxNumberInput('decimal')), 4148 st_og_min: parseFloat($("#st_og_min").jqxNumberInput('decimal')),
3506 st_og_max: parseFloat($("#st_og_max").jqxNumberInput('decimal')), 4149 st_og_max: parseFloat($("#st_og_max").jqxNumberInput('decimal')),
3507 st_fg_min: parseFloat($("#st_fg_min").jqxNumberInput('decimal')), 4150 st_fg_min: parseFloat($("#st_fg_min").jqxNumberInput('decimal')),
3555 w2_sodium: parseFloat($("#w2_sodium").jqxNumberInput('decimal')), 4198 w2_sodium: parseFloat($("#w2_sodium").jqxNumberInput('decimal')),
3556 w2_magnesium: parseFloat($("#w2_magnesium").jqxNumberInput('decimal')), 4199 w2_magnesium: parseFloat($("#w2_magnesium").jqxNumberInput('decimal')),
3557 w2_total_alkalinity: parseFloat($("#w2_total_alkalinity").jqxNumberInput('decimal')), 4200 w2_total_alkalinity: parseFloat($("#w2_total_alkalinity").jqxNumberInput('decimal')),
3558 w2_ph: parseFloat($("#w2_ph").jqxNumberInput('decimal')), 4201 w2_ph: parseFloat($("#w2_ph").jqxNumberInput('decimal')),
3559 w2_cost: dataRecord.w2_cost, 4202 w2_cost: dataRecord.w2_cost,
4203 wa_acid_name: $("#wa_acid_name").val(),
4204 wa_acid_perc: parseFloat($("#wa_acid_perc").jqxNumberInput('decimal')),
4205 wa_base_name: $("#wa_base_name").val(),
3560 fermentables: fermentablerow, 4206 fermentables: fermentablerow,
3561 hops: hoprow, 4207 hops: hoprow,
3562 miscs: miscrow, 4208 miscs: miscrow,
3563 yeasts: yeastrow, 4209 yeasts: yeastrow,
3564 mashs: mashrow 4210 mashs: mashrow

mercurial