45 |
45 |
46 |
46 |
47 $(document).ready(function () { |
47 $(document).ready(function () { |
48 |
48 |
49 var brewstage = 0; // Numeric value of stage |
49 var brewstage = 0; // Numeric value of stage |
50 var this_uuid = ''; |
50 var preboil_sg = 0; |
|
51 var est_mash_sg = 0; |
|
52 var sugarsm = 0; // Sugars after mash |
|
53 var sugarsf = 0; // Sugars after boil |
|
54 var psugar = 0; // Percentage real sugars |
|
55 var pcara = 0; // Percentage cara/crystal malts |
|
56 var old_efficiency; |
|
57 var old_batch_size; |
|
58 var old_boil_time; |
51 |
59 |
52 console.log("record:" + my_record + " return:" + my_return + " theme:" + theme); |
60 console.log("record:" + my_record + " return:" + my_return + " theme:" + theme); |
|
61 |
|
62 function calcFermentables() { |
|
63 console.log("calcFermentables()"); |
|
64 sugarsf = 0; |
|
65 sugarsm = 0; |
|
66 psugar = 0; |
|
67 pcara = 0; |
|
68 var colorw = 0; // Colors working |
|
69 |
|
70 for (var i = 0; i < dataRecord.fermentables.length; i++) { |
|
71 var row = dataRecord.fermentables[i]; |
|
72 if (row.f_type == "Sugar") |
|
73 psugar += row.f_percentage; |
|
74 if (row.f_type == "Crystal") |
|
75 pcara += row.f_percentage; |
|
76 var d = row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); |
|
77 if (row.f_added == "Mash") { |
|
78 d = parseFloat(dataRecord.efficiency) / 100 * d; |
|
79 sugarsm += d; |
|
80 } |
|
81 sugarsf += d; |
|
82 colorw += row.f_amount * ebc_to_srm(row.f_color) / parseFloat(dataRecord.batch_size) * 8.34436; |
|
83 } |
|
84 console.log("sugarsm: " + sugarsm + " sugarsf: " + sugarsf + " batch: " + dataRecord.batch_size); |
|
85 console.log("est_og: " + estimate_sg(sugarsf, parseFloat(dataRecord.batch_size))); |
|
86 preboil_sg = estimate_sg(sugarsm, parseFloat(dataRecord.boil_size)); |
|
87 console.log("preboil_sg: " + preboil_sg); |
|
88 console.log("est_color: " + kw_to_ebc(dataRecord.color_method, colorw)); |
|
89 $("#est_og").val(estimate_sg(sugarsf, parseFloat(dataRecord.batch_size))); |
|
90 $('#est_color').val(kw_to_ebc(dataRecord.color_method, colorw)); |
|
91 }; |
|
92 |
|
93 function calcIBUs() { |
|
94 var total_ibus = 0; |
|
95 for (var i = 0; i < dataRecord.hops.length; i++) { |
|
96 var row = dataRecord.hops[i]; |
|
97 total_ibus += toIBU(row.h_useat, row.h_form, preboil_sg, parseFloat(dataRecord.batch_size), |
|
98 parseFloat(row.h_amount), parseFloat(row.h_time), parseFloat(row.h_alpha), dataRecord.ibu_method); |
|
99 } |
|
100 console.log("calcIBUs(): " + total_ibus); |
|
101 $('#est_ibu').val(total_ibus); |
|
102 }; |
|
103 |
|
104 function calcSGendMash() { |
|
105 est_mash_sg = 0; |
|
106 var mvol = 0; // Mash volume |
|
107 var s = 0; |
|
108 var gs = 0; // Grain absorbtion |
|
109 for (var i = 0; i < dataRecord.mashs.length; i++) { |
|
110 var row = dataRecord.mashs[i]; |
|
111 // console.log("step " + i + " " + row.step_name + " " + row.step_type); |
|
112 if (row.step_type == 'Infusion') |
|
113 mvol += parseFloat(row.step_infuse_amount); |
|
114 } |
|
115 if (mvol > 0) { |
|
116 // console.log("mash volume: " + mvol); |
|
117 for (var i = 0; i < dataRecord.fermentables.length; i++) { |
|
118 var row = dataRecord.fermentables[i]; |
|
119 |
|
120 if (row.f_added == "Mash") { |
|
121 var d = row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); |
|
122 mvol += row.f_amount * row.f_moisture / 100; |
|
123 gs += my_grain_absorbtion * row.f_amount; |
|
124 s += d; |
|
125 } |
|
126 } |
|
127 // console.log("mash volume: " + mvol + " gs: " + gs + " s: " + s); |
|
128 var v = s / sugardensity + mvol; |
|
129 s = 1000 * s / (v * 10); //deg. Plato |
|
130 est_mash_sg = plato_to_sg(s); |
|
131 } |
|
132 console.log("calcSGendMash(): " + est_mash_sg); |
|
133 $('#est_mash_sg').val(est_mash_sg); |
|
134 }; |
|
135 |
|
136 function calcMashEfficiency() { |
|
137 // console.log("calcMashEfficiency()"); |
|
138 var c = sg_to_plato(est_mash_sg); |
|
139 var m = sg_to_plato(parseFloat($("#brew_mash_sg").jqxNumberInput('decimal'))); |
|
140 // console.log("c "+ c + " m " + m + " in " + parseFloat($("#brew_mash_sg").jqxNumberInput('decimal'))); |
|
141 if (c > 0.5) |
|
142 $("#brew_mash_efficiency").val(100 * m / c); |
|
143 else |
|
144 $("#brew_mash_efficiency").val(0); |
|
145 }; |
53 |
146 |
54 // Equipemnt dropdown list |
147 // Equipemnt dropdown list |
55 var equipmentUrl = "includes/db_inventory_equipments.php"; |
148 var equipmentUrl = "includes/db_inventory_equipments.php"; |
56 var equipmentSource = { |
149 var equipmentSource = { |
57 datatype: "json", |
150 datatype: "json", |
199 { name: 'brew_date_start', type: 'string' }, |
292 { name: 'brew_date_start', type: 'string' }, |
200 { name: 'brew_mash_ph', type: 'float' }, |
293 { name: 'brew_mash_ph', type: 'float' }, |
201 { name: 'brew_mash_sg', type: 'float' }, |
294 { name: 'brew_mash_sg', type: 'float' }, |
202 { name: 'brew_sparge_temperature', type: 'float' }, |
295 { name: 'brew_sparge_temperature', type: 'float' }, |
203 { name: 'brew_sparge_volume', type: 'float' }, |
296 { name: 'brew_sparge_volume', type: 'float' }, |
|
297 { name: 'brew_sparge_ph', type: 'float' }, |
204 { name: 'brew_preboil_volume', type: 'float' }, |
298 { name: 'brew_preboil_volume', type: 'float' }, |
205 { name: 'brew_preboil_sg', type: 'float' }, |
299 { name: 'brew_preboil_sg', type: 'float' }, |
206 { name: 'brew_preboil_ph', type: 'float' }, |
300 { name: 'brew_preboil_ph', type: 'float' }, |
207 { name: 'brew_aboil_volume', type: 'float' }, |
301 { name: 'brew_aboil_volume', type: 'float' }, |
208 { name: 'brew_aboil_sg', type: 'float' }, |
302 { name: 'brew_aboil_sg', type: 'float' }, |
344 $("#eq_kettle_height").val(dataRecord.eq_kettle_height); |
437 $("#eq_kettle_height").val(dataRecord.eq_kettle_height); |
345 $("#eq_mash_volume").val(dataRecord.eq_mash_volume); |
438 $("#eq_mash_volume").val(dataRecord.eq_mash_volume); |
346 $("#eq_efficiency").val(dataRecord.eq_efficiency); |
439 $("#eq_efficiency").val(dataRecord.eq_efficiency); |
347 // Brewdate |
440 // Brewdate |
348 $("#brew_date_start").val(dataRecord.brew_date_start); |
441 $("#brew_date_start").val(dataRecord.brew_date_start); |
349 |
|
350 $("#brew_mash_ph").val(dataRecord.brew_mash_ph); |
442 $("#brew_mash_ph").val(dataRecord.brew_mash_ph); |
351 $("#brew_mash_sg").val(dataRecord.brew_mash_sg); |
443 $("#brew_mash_sg").val(dataRecord.brew_mash_sg); |
352 // brew_mash_efficiency to calculate on th fly. |
444 // brew_mash_efficiency to calculate on th fly. |
353 // Header Spoelen en filteren |
445 // Header Spoelen en filteren |
354 $("#brew_sparge_temperature").val(dataRecord.brew_sparge_temperature); |
446 $("#brew_sparge_temperature").val(dataRecord.brew_sparge_temperature); |
355 $("#brew_sparge_volume").val(dataRecord.brew_sparge_volume); |
447 $("#brew_sparge_volume").val(dataRecord.brew_sparge_volume); |
356 //$("#brew_sparge_ph").val(dataRecord.brew_sparge_ph); |
448 $("#brew_sparge_ph").val(dataRecord.brew_sparge_ph); |
357 // Header Beluchten |
449 // Header Beluchten |
358 $("#brew_aeration_type").val(dataRecord.brew_aeration_type); |
450 $("#brew_aeration_type").val(dataRecord.brew_aeration_type); |
359 $("#brew_aeration_time").val(dataRecord.brew_aeration_time); |
451 $("#brew_aeration_time").val(dataRecord.brew_aeration_time); |
360 $("#brew_aeration_speed").val(dataRecord.brew_aeration_speed); |
452 $("#brew_aeration_speed").val(dataRecord.brew_aeration_speed); |
361 |
453 |
489 $("#eq_mash_volume").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); |
612 $("#eq_mash_volume").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); |
490 $("#eq_efficiency").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); |
613 $("#eq_efficiency").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); |
491 // Brewday |
614 // Brewday |
492 $("#brew_date_start").jqxDateTimeInput({ theme: theme, width: 230, height: 23, formatString: 'yyyy-MM-dd HH:mm:ss', showTimeButton: true }); |
615 $("#brew_date_start").jqxDateTimeInput({ theme: theme, width: 230, height: 23, formatString: 'yyyy-MM-dd HH:mm:ss', showTimeButton: true }); |
493 $("#brew_mash_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); |
616 $("#brew_mash_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); |
494 $("#brew_mash_sg").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 }); |
617 $("#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 }); |
|
618 $("#brew_mash_sg").on('valueChanged', function () { calcMashEfficiency(); }); |
495 $("#brew_mash_efficiency").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); |
619 $("#brew_mash_efficiency").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); |
496 $("#brew_sparge_temperature").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); |
620 $("#brew_sparge_temperature").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); |
497 $("#brew_sparge_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); |
621 $("#brew_sparge_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); |
498 $("#brew_sparge_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); |
622 $("#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 }); |
499 $("#brew_preboil_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); |
623 $("#brew_preboil_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); |
500 $("#brew_preboil_sg").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 }); |
624 $("#brew_preboil_sg").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 }); |
501 $("#brew_preboil_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); |
625 $("#brew_preboil_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); |
502 $("#brew_preboil_efficiency").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); |
626 $("#brew_preboil_efficiency").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); |
503 $("#brew_aboil_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); |
627 $("#brew_aboil_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); |