18 * You should have received a copy of the GNU General Public License |
18 * You should have received a copy of the GNU General Public License |
19 * along with ThermFerm; see the file COPYING. If not, write to the Free |
19 * along with ThermFerm; see the file COPYING. If not, write to the Free |
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
21 *****************************************************************************/ |
21 *****************************************************************************/ |
22 |
22 |
|
23 var psugar = 0, // Percentage real sugars |
|
24 pcara = 0, // Percentage cara/crystal malts |
|
25 svg = 77, // Default attenuation |
|
26 mashkg = 0, // Malt in mash weight |
|
27 mash_infuse = 0, |
|
28 dataRecord = {}, // Main recipe record |
|
29 hop_flavour = 0, |
|
30 hop_aroma = 0, |
|
31 preboil_sg = 0, |
|
32 last_base = '', |
|
33 last_acid = '', |
|
34 Ka1 = 0.0000004445, |
|
35 Ka2 = 0.0000000000468, |
|
36 MMCa = 40.048, |
|
37 MMMg = 24.305, |
|
38 MMNa = 22.98976928, |
|
39 MMCl = 35.453, |
|
40 MMSO4 = 96.0626, |
|
41 MMCO3 = 60.01684, |
|
42 MMHCO3 = 61.01684, |
|
43 MMCaSO4 = 172.171, |
|
44 MMCaCl2 = 147.015, |
|
45 MMCaCO3 = 100.087, |
|
46 MMMgSO4 = 246.475, |
|
47 MMNaHCO3 = 84.007, |
|
48 MMNa2CO3 = 105.996, |
|
49 MMNaCl = 58.443, |
|
50 MMCaOH2 = 74.06268; |
|
51 |
23 |
52 |
24 function createDelElements() { |
53 function createDelElements() { |
25 $('#eventWindow').jqxWindow({ |
54 $('#eventWindow').jqxWindow({ |
26 theme: theme, |
55 theme: theme, |
27 position: { x: 490, y: 210 }, |
56 position: { x: 490, y: 210 }, |
28 width: 300, |
57 width: 300, |
29 height: 175, |
58 height: 175, |
30 resizable: false, |
59 resizable: false, |
31 isModal: true, |
60 isModal: true, |
32 modalOpacity: 0.4, |
61 modalOpacity: 0.4, |
33 okButton: $('#delOk'), |
62 okButton: $('#delOk'), |
34 cancelButton: $('#delCancel'), |
63 cancelButton: $('#delCancel'), |
35 initContent: function () { |
64 initContent: function() { |
36 $('#delOk').jqxButton({ template: "danger", width: '65px', theme: theme }); |
65 $('#delOk').jqxButton({ template: 'danger', width: '65px', theme: theme }); |
37 $('#delCancel').jqxButton({ template: "success", width: '65px', theme: theme }); |
66 $('#delCancel').jqxButton({ template: 'success', width: '65px', theme: theme }); |
38 $('#delCancel').focus(); |
67 $('#delCancel').focus(); |
39 } |
68 } |
40 }); |
69 }); |
41 $('#eventWindow').jqxWindow('hide'); |
70 $('#eventWindow').jqxWindow('hide'); |
42 } |
71 } |
43 |
72 |
44 |
73 |
45 $(document).ready(function () { |
74 function hopFlavourContribution(bt, vol, use, amount) { |
46 |
75 var result; |
47 var to_100 = false; // Fermentables adjust to 100% |
76 |
48 var preboil_sg = 0; |
77 if (use == 1) { // First wort |
49 var psugar = 0; // Percentage real sugars |
78 result = 0.15; // assume 15% flavourcontribution for fwh |
50 var pcara = 0; // Percentage cara/crystal malts |
79 } else if (bt > 50) { |
51 var svg = 77; // Default attenuation |
80 result = 0.10; // assume 10% flavourcontribution as a minimum |
52 var mashkg = 0; // Malt in mash weight |
81 } else { |
53 var hop_flavour = 0; |
82 result = 15.25 / (6 * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((bt - 21) / 6, 2)); |
54 var hop_aroma = 0; |
83 if (result < 0.10) |
55 var mash_infuse = 0; |
84 result = 0.10; // assume 10% flavourcontribution as a minimum |
56 var last_base = ''; |
85 } |
57 var last_acid = ''; |
86 return (result * amount * 1000) / vol; |
58 |
87 } |
59 var MMCa = 40.048; |
88 |
60 var MMMg = 24.305; |
89 |
61 var MMNa = 22.98976928; |
90 function hopAromaContribution(bt, vol, use, amount) { |
62 var MMCl = 35.453; |
91 var result = 0; |
63 var MMSO4 = 96.0626; |
92 |
64 var MMCO3 = 60.01684; |
93 if (use == 5) { // Dry hop |
65 var MMHCO3 = 61.01684; |
94 result = 1.33; |
66 var MMCaSO4 = 172.171; |
95 } else if (bt > 20) { |
67 var MMCaCl2 = 147.015; |
96 result = 0; |
68 var MMCaCO3 = 100.087; |
97 } else if (bt > 7.5) { |
69 var MMMgSO4 = 246.475; |
98 result = 10.03 / (4 * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((bt - 7.5) / 4, 2)); |
70 var MMNaHCO3 = 84.007; |
99 } else if (use == 2) { // Boil |
71 var MMNa2CO3 = 105.996; |
100 result = 1; |
72 var MMNaCl = 58.443; |
101 } else if (use == 3) { // Aroma |
73 var MMCaOH2 = 74.06268; |
102 result = 1.2; |
74 |
103 } else if (use == 4) { // Whirlpool |
75 var fermentableRow = 0; |
104 result = 1.2; |
76 var fermentableData = {}; |
105 } |
77 var hopRow = 0; |
106 return (result * amount * 1000) / vol; |
78 var hopData = {}; |
107 } |
79 var miscRow = 0; |
108 |
80 var miscData = {}; |
109 |
81 var yeastRow = 0; |
110 function setReadonly(ro) { |
82 var yeastData = {}; |
111 var rw = ! ro, w100 = 110, w80 = 80; |
83 var mashRow = 0; |
112 if (ro) { // jqxNumberInput width -20 for no spinbuttons |
84 var mashData = {}; |
113 w100 = 90; |
85 |
114 w80 = 60; |
86 /* |
115 } |
87 * Remove the top menu so that we MUST use the buttons to leave the editor. |
116 $('#batch_size').jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
88 */ |
117 $('#boil_size').jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
89 $('#jqxMenu').jqxMenu('destroy'); |
118 $('#boil_time').jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
90 |
119 $('#efficiency').jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
91 console.log("record:" + my_record + " return:" + my_return + " theme:" + theme); |
120 $('#est_og').jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
92 $("#jqxLoader").jqxLoader({ |
121 // id="st_fg_min" margin-left 15/35 maken |
93 width: 250, |
122 $('#type').jqxDropDownList({ disabled: ro }); |
94 height: 150, |
123 $('#styleSelect').jqxDropDownList({ disabled: ro }); |
95 isModal: true, |
124 $('#color_method').jqxDropDownList({ disabled: ro }); |
96 text: "Laden recept ...", |
125 $('#ibu_method').jqxDropDownList({ disabled: ro }); |
97 theme: theme |
126 $('#Delete').jqxButton({ disabled: ro }); |
98 }); |
127 $('#fermentableGrid').jqxGrid({ editable: rw }); |
99 |
128 $('#faddrowbutton').jqxDropDownList({ disabled: ro }); |
100 function setReadonly(ro) { |
129 $('#finstockbutton').jqxCheckBox({ disabled: ro }); |
101 var rw = ! ro; |
130 $('#fdeleterowbutton').jqxButton({ disabled: ro }); |
102 var w100 = 110; |
131 $('#hopGrid').jqxGrid({ editable: rw }); |
103 var w80 = 80; |
132 $('#haddrowbutton').jqxDropDownList({ disabled: ro }); |
104 if (ro) { // jqxNumberInput width -20 for no spinbuttons |
133 $('#hinstockbutton').jqxCheckBox({ disabled: ro }); |
105 w100 = 90; |
134 $('#hdeleterowbutton').jqxButton({ disabled: ro }); |
106 w80 = 60; |
135 $('#miscGrid').jqxGrid({ editable: rw }); |
107 } |
136 $('#maddrowbutton').jqxDropDownList({ disabled: ro }); |
108 $("#batch_size").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
137 $('#minstockbutton').jqxCheckBox({ disabled: ro }); |
109 $("#boil_size").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
138 $('#mdeleterowbutton').jqxButton({ disabled: ro }); |
110 $("#boil_time").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
139 $('#yeastGrid').jqxGrid({ editable: rw }); |
111 $("#efficiency").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
140 $('#yaddrowbutton').jqxDropDownList({ disabled: ro }); |
112 $("#est_og").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
141 $('#yinstockbutton').jqxCheckBox({ disabled: ro }); |
113 // id="st_fg_min" margin-left 15/35 maken |
142 $('#ydeleterowbutton').jqxButton({ disabled: ro }); |
114 $("#type").jqxDropDownList({ disabled: ro }); |
143 $('#mashGrid').jqxGrid({ editable: rw }); |
115 $("#styleSelect").jqxDropDownList({ disabled: ro }); |
144 $('#saddrowbutton').jqxButton({ disabled: ro }); |
116 $("#color_method").jqxDropDownList({ disabled: ro }); |
145 $('#sdeleterowbutton').jqxButton({ disabled: ro }); |
117 $("#ibu_method").jqxDropDownList({ disabled: ro }); |
146 $('#w1_name').jqxDropDownList({ disabled: ro }); |
118 $("#Delete").jqxButton({ disabled: ro }); |
147 $('#w2_name').jqxDropDownList({ disabled: ro }); |
119 $("#fermentableGrid").jqxGrid({ editable: rw }); |
148 $('#pr_name').jqxDropDownList({ disabled: ro }); |
120 $("#faddrowbutton").jqxDropDownList({ disabled: ro }); |
149 $('#wa_cacl2').jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
121 $("#finstockbutton").jqxCheckBox({ disabled: ro }); |
150 $('#wa_caso4').jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
122 $("#fdeleterowbutton").jqxButton({ disabled: ro }); |
151 $('#wa_mgso4').jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
123 $("#hopGrid").jqxGrid({ editable: rw }); |
152 $('#wa_nacl').jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
124 $("#haddrowbutton").jqxDropDownList({ disabled: ro }); |
153 $('#mash_ph').jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
125 $("#hinstockbutton").jqxCheckBox({ disabled: ro }); |
154 $('#calc_acid').jqxCheckBox({ disabled: ro }); |
126 $("#hdeleterowbutton").jqxButton({ disabled: ro }); |
155 $('#wa_base_name').jqxDropDownList({ disabled: ro }); |
127 $("#miscGrid").jqxGrid({ editable: rw }); |
156 $('#wa_base').jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
128 $("#maddrowbutton").jqxDropDownList({ disabled: ro }); |
157 $('#wa_acid_name').jqxDropDownList({ disabled: ro }); |
129 $("#minstockbutton").jqxCheckBox({ disabled: ro }); |
158 $('#wa_acid').jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
130 $("#mdeleterowbutton").jqxButton({ disabled: ro }); |
159 $('#wa_acid_perc').jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w80 }); |
131 $("#yeastGrid").jqxGrid({ editable: rw }); |
160 $('#sparge_temp').jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
132 $("#yaddrowbutton").jqxDropDownList({ disabled: ro }); |
161 $('#sparge_volume').jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
133 $("#yinstockbutton").jqxCheckBox({ disabled: ro }); |
162 $('#sparge_ph').jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
134 $("#ydeleterowbutton").jqxButton({ disabled: ro }); |
163 $('#sparge_source').jqxDropDownList({ disabled: ro }); |
135 $("#mashGrid").jqxGrid({ editable: rw }); |
164 $('#sparge_acid_type').jqxDropDownList({ disabled: ro }); |
136 $("#saddrowbutton").jqxButton({ disabled: ro }); |
165 $('#sparge_acid_perc').jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
137 $("#sdeleterowbutton").jqxButton({ disabled: ro }); |
166 } |
138 $("#w1_name").jqxDropDownList({ disabled: ro }); |
167 |
139 $("#w2_name").jqxDropDownList({ disabled: ro }); |
168 |
140 $("#pr_name").jqxDropDownList({ disabled: ro }); |
169 function calcPercentages() { |
141 $("#wa_cacl2").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
170 |
142 $("#wa_caso4").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
171 console.log('calcPercentages()'); |
143 $("#wa_mgso4").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
172 var tw, rowdata, percentage, i, rowscount = $('#fermentableGrid').jqxGrid('getdatainformation').rowscount; |
144 $("#wa_nacl").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
173 if (rowscount > 1) { |
145 $("#mash_ph").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
174 tw = 0; |
146 $("#calc_acid").jqxCheckBox({ disabled: ro }); |
175 for (i = 0; i < rowscount; i++) { |
147 $("#wa_base_name").jqxDropDownList({ disabled: ro }); |
176 rowdata = $('#fermentableGrid').jqxGrid('getrowdata', i); |
148 $("#wa_base").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
177 if (rowdata.f_added < 4) |
149 $("#wa_acid_name").jqxDropDownList({ disabled: ro }); |
178 tw += Round(rowdata.f_amount, 3); |
150 $("#wa_acid").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
179 } |
151 $("#wa_acid_perc").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w80 }); |
180 tw = Round(tw, 3); |
152 $("#sparge_temp").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
181 |
153 $("#sparge_volume").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
182 for (i = 0; i < rowscount; i++) { |
154 $("#sparge_ph").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
183 rowdata = $('#fermentableGrid').jqxGrid('getrowdata', i); |
155 $("#sparge_source").jqxDropDownList({ disabled: ro }); |
184 if (rowdata.f_added < 4) { |
156 $("#sparge_acid_type").jqxDropDownList({ disabled: ro }); |
185 percentage = Round(rowdata.f_amount / tw * 100, 1); |
157 $("#sparge_acid_perc").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); |
186 $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_percentage', percentage); |
158 }; |
187 } else { |
159 |
188 $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_percentage', 0); |
160 function calcPercentages() { |
189 } |
161 |
190 } |
162 console.log("calcPercentages()"); |
191 } else { |
163 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; |
192 $('#fermentableGrid').jqxGrid('setcellvalue', 0, 'f_percentage', 100); |
164 if (rowscount > 1) { |
193 } |
165 var tw = 0; |
194 } |
166 for (i = 0; i < rowscount; i++) { |
195 |
167 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); |
196 |
168 if (rowdata.f_added < 4) |
197 function calcFermentables() { |
169 tw += Math.round(rowdata.f_amount * 1000) / 1000; |
198 console.log('calcFermentables()'); |
170 }; |
199 var i, row, rows, org, s = 0, d, x, |
171 tw = Math.round(tw * 1000) / 1000; |
200 sug, alc, cw, color, scolor, fig, |
172 |
201 sugarsf = 0, // fermentable sugars mash + boil |
173 for (i = 0; i < rowscount; i++) { |
202 sugarsm = 0; // fermentable sugars in mash |
174 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); |
203 vol = 0, // Volume sugars after boil |
175 if (rowdata.f_added < 4) { |
204 addedS = 0, // Added sugars after boil |
176 var percentage = Math.round(rowdata.f_amount / tw * 1000) / 10.0; |
205 addedmass = 0, // Added mass after boil |
177 $("#fermentableGrid").jqxGrid('setcellvalue', i, "f_percentage", percentage); |
206 mvol = 0, // mash volume |
178 } else { |
207 colort = 0, // Colors srm * vol totals |
179 $("#fermentableGrid").jqxGrid('setcellvalue', i, "f_percentage", 0); |
208 colorh = 0, // Colors ebc * vol * kt |
180 } |
209 colorn = 0, // Colors ebc * pt * pct |
181 }; |
210 my_100 = false, |
182 } else { |
211 mashtime = 0, // Total mash time |
183 $("#fermentableGrid").jqxGrid('setcellvalue', 0, "f_percentage", 100); |
212 mashtemp = 0, // Average mash temperature |
184 } |
213 bv = 0.925, // Bierverlies rendement |
185 } |
214 sr = 0.95, // Mash en spoel rendement |
186 |
215 lintner = 0; // Total recipe lintner |
187 function calcFermentables() { |
216 /* Init global variables */ |
188 console.log("calcFermentables()"); |
217 psugar = 0; |
189 sugarsf = 0; // fermentable sugars mash + boil |
218 pcara = 0; |
190 sugarsm = 0; // fermentable sugars in mash |
219 mashkg = 0; |
191 psugar = 0; |
220 |
192 pcara = 0; |
221 if ((rows = $('#mashGrid').jqxGrid('getrows'))) { |
193 mashkg = 0; |
222 for (i = 0; i < rows.length; i++) { |
194 var vol = 0; // Volume sugars after boil |
223 row = rows[i]; |
195 var addedS = 0; // Added sugars after boil |
224 if (row.step_type == 0) // Infusion |
196 var addedmass = 0; // Added mass after boil |
225 mvol += parseFloat(row.step_infuse_amount); |
197 var mvol = 0; // mash volume |
226 if (row.step_temp <= 75) { // Ignore mashout |
198 var colort = 0; // Colors srm * vol totals |
227 mashtime += row.step_time; |
199 var colorh = 0; // Colors ebc * vol * kt |
228 mashtemp += row.step_time * row.step_temp; |
200 var colorn = 0; // Colors ebc * pt * pct |
229 } |
201 var my_100 = false; |
230 } |
202 var mashtime = 0; // Total mash time |
231 mashtemp = mashtemp / mashtime; |
203 var mashtemp = 0; // Average mash temperature |
232 } |
204 var bv = 0.925; // Bierverlies rendement |
233 |
205 var sr = 0.95; // Mash en spoel rendement |
234 if (!(rows = $('#fermentableGrid').jqxGrid('getrows'))) { |
206 var lintner = 0; // Total recipe lintner |
235 return; // grid not yet loaded. |
207 |
236 } |
208 if ((rows = $('#mashGrid').jqxGrid('getrows'))) { |
237 |
209 for (var i = 0; i < rows.length; i++) { |
238 for (i = 0; i < rows.length; i++) { |
210 var row = rows[i]; |
239 row = rows[i]; |
211 if (row.step_type == 0) // Infusion |
240 if (row.f_adjust_to_total_100) |
212 mvol += parseFloat(row.step_infuse_amount); |
241 my_100 = true; |
213 if (row.step_temp <= 75) { // Ignore mashout |
242 if (row.f_type == 1 && row.f_added < 4) // Sugar |
214 mashtime += row.step_time; |
243 psugar += row.f_percentage; |
215 mashtemp += row.step_time * row.step_temp; |
244 if (row.f_graintype == 2 && row.f_added < 4) // Crystal |
216 } |
245 pcara += row.f_percentage; |
217 } |
246 d = row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); |
218 mashtemp = mashtemp / mashtime; |
247 if (row.f_added == 0) { // Mash |
219 } |
248 if (mvol > 0) { // Only if mash already known |
220 |
249 mvol += row.f_amount * row.f_moisture / 100; |
221 if (!(rows = $('#fermentableGrid').jqxGrid('getrows'))) { |
250 s += d; |
222 return; // grid not yet loaded. |
251 } |
223 } |
252 d = parseFloat(dataRecord.efficiency) / 100 * d; |
224 |
253 sugarsm += d; |
225 var s = 0; |
254 mashkg += row.f_amount; |
226 for (var i = 0; i < rows.length; i++) { |
255 } |
227 var row = rows[i]; |
256 if (row.f_added == 0 || row.f_added == 1) // Mash or Boil |
228 if (row.f_adjust_to_total_100) |
257 sugarsf += d; |
229 my_100 = true; |
258 if (row.f_added == 2 || row.f_added == 3) { // Fermentation or lagering |
230 if (row.f_type == 1 && row.f_added < 4) // Sugar |
259 x = (row.f_yield / 100) * (1 - row.f_moisture / 100); |
231 psugar += row.f_percentage; |
260 addedS += row.f_amount * x; |
232 if (row.f_graintype == 2 && row.f_added < 4) // Crystal |
261 addedmass += row.f_amount; |
233 pcara += row.f_percentage; |
262 vol += (x * sugardensity + (1 - x) * 1) * row.f_amount; |
234 var d = row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); |
263 } |
235 if (row.f_added == 0) { // Mash |
264 if (row.f_added == 0 && (row.f_type == 0 || row.f_type == 4) && row.f_color < 50) { // Mash and Grain/Adjunct and Color < 50 |
236 if (mvol > 0) { // Only if mash already known |
265 lintner += row.f_diastatic_power * row.f_amount; |
237 mvol += row.f_amount * row.f_moisture / 100; |
266 } |
238 s += d; |
267 if (row.f_added < 4) { |
239 } |
268 colort += row.f_amount * ebc_to_srm(row.f_color); |
240 d = parseFloat(dataRecord.efficiency) / 100 * d; |
269 colorh += row.f_amount * row.f_color * get_kt(row.f_color); |
241 sugarsm += d; |
270 colorn += (row.f_percentage / 100) * row.f_color; // For 8.6 Pt wort. |
242 mashkg += row.f_amount; |
271 } |
243 } |
272 } |
244 if (row.f_added == 0 || row.f_added == 1) // Mash or Boil |
273 $('#ferm_lintner').val(Math.round(parseFloat(lintner / mashkg))); |
245 sugarsf += d; |
274 //console.log('lintner:' + lintner + ' kg:' + mashkg); |
246 if (row.f_added == 2 || row.f_added == 3) { // Fermentation or lagering |
275 to_100 = my_100; |
247 var x = (row.f_yield / 100) * (1 - row.f_moisture / 100); |
276 if (to_100) { |
248 addedS += row.f_amount * x; |
277 $('#wf_amount').jqxNumberInput({ width: 90, readOnly: true, spinButtons: false }); |
249 addedmass += row.f_amount; |
278 } else { |
250 vol += (x * sugardensity + (1 - x) * 1) * row.f_amount; |
279 $('#wf_amount').jqxNumberInput({ width: 110, readOnly: false, spinButtons: true }); |
251 } |
280 } |
252 if (row.f_added == 0 && (row.f_type == 0 || row.f_type == 4) && row.f_color < 50) { // Mash and Grain/Adjunct and Color < 50 |
281 |
253 lintner += row.f_diastatic_power * row.f_amount; |
282 // Estimate total recipe OG. |
254 } |
283 dataRecord.est_og = estimate_sg(sugarsf + addedS, parseFloat(dataRecord.batch_size)); |
255 if (row.f_added < 4) { |
284 $('#est_og').val(dataRecord.est_og); |
256 colort += row.f_amount * ebc_to_srm(row.f_color); |
285 $('#est_og2').val(dataRecord.est_og); |
257 colorh += row.f_amount * row.f_color * get_kt(row.f_color); |
286 org = dataRecord.est_og; |
258 colorn += (row.f_percentage / 100) * row.f_color; // For 8.6 Pt wort. |
287 |
259 } |
288 // Estimate SG in kettle before boil |
260 } |
289 preboil_sg = estimate_sg(sugarsm, parseFloat(dataRecord.boil_size)); |
261 $("#ferm_lintner").val(Math.round(parseFloat(lintner / mashkg))); |
290 |
262 console.log("lintner:"+lintner+" kg:"+mashkg); |
291 // Color of the wort |
263 to_100 = my_100; |
292 if (dataRecord.color_method == 4) { |
264 if (to_100) { |
293 color = Math.round(((sg_to_plato(dataRecord.est_og) / 8.6) * colorn) + (dataRecord.boil_time / 60)); |
265 $("#wf_amount").jqxNumberInput({ width: 90, readOnly: true, spinButtons: false }); |
294 } else if (dataRecord.color_method == 3) { // Hans Halberstadt |
266 } else { |
295 color = Math.round((4.46 * bv * sr) / parseFloat(dataRecord.batch_size) * colorh); |
267 $("#wf_amount").jqxNumberInput({ width: 110, readOnly: false, spinButtons: true }); |
296 } else { |
268 } |
297 cw = colort / parseFloat(dataRecord.batch_size) * 8.34436; |
269 |
298 color = kw_to_ebc(dataRecord.color_method, cw); |
270 // Estimate total recipe OG. |
299 } |
271 dataRecord.est_og = estimate_sg(sugarsf + addedS, parseFloat(dataRecord.batch_size)); |
300 dataRecord.est_color = color; |
272 $('#est_og').val(dataRecord.est_og); |
301 $('#est_color').val(color); |
273 $('#est_og2').val(dataRecord.est_og); |
302 $('#est_color2').val(color); |
274 var org = dataRecord.est_og; |
303 scolor = ebc_to_color(color); |
275 |
304 document.getElementById('bcolor').style.background = scolor; |
276 // Estimate SG in kettle before boil |
305 document.getElementById('bcolor2').style.background = scolor; |
277 preboil_sg = estimate_sg(sugarsm, parseFloat(dataRecord.boil_size)); |
306 |
278 |
307 // Progress bars |
279 // Color of the wort |
308 pmalts = mashkg / (dataRecord.boil_size / 3) * 100; |
280 if (dataRecord.color_method == 4) { |
309 $('#perc_malts').jqxProgressBar('val', pmalts); |
281 var color = Math.round(((sg_to_plato(dataRecord.est_og) / 8.6) * colorn) + (dataRecord.boil_time / 60)); |
310 $('#perc_sugars').jqxProgressBar('val', psugar); |
282 } else if (dataRecord.color_method == 3) { // Hans Halberstadt |
311 $('#perc_cara').jqxProgressBar('val', pcara); |
283 var color = Math.round((4.46 * bv * sr) / parseFloat(dataRecord.batch_size) * colorh); |
312 |
284 } else { |
313 // Calculate estimated svg. |
285 var cw = colort / parseFloat(dataRecord.batch_size) * 8.34436; |
314 svg = 0; // default. |
286 var color = kw_to_ebc(dataRecord.color_method, cw); |
315 rows = $('#yeastGrid').jqxGrid('getrows'); |
287 } |
316 for (i = 0; i < rows.length; i++) { |
288 dataRecord.est_color = color; |
317 row = rows[i]; |
289 $('#est_color').val(color); |
318 if (row.y_use == 0) { // Primary |
290 $('#est_color2').val(color); |
319 if (parseFloat(row.y_attenuation) > svg) |
291 var scolor = ebc_to_color(color); |
320 svg = parseFloat(row.y_attenuation); // Take the highest if multiple yeasts. |
292 document.getElementById("bcolor").style.background= scolor; |
321 } |
293 document.getElementById("bcolor2").style.background= scolor; |
322 // TODO: brett in secondary ?? |
294 |
323 } |
295 // Progress bars |
324 if (svg == 0) |
296 pmalts = mashkg / (dataRecord.boil_size / 3) * 100; |
325 svg = 77; |
297 $("#perc_malts").jqxProgressBar('val', pmalts); |
326 |
298 $("#perc_sugars").jqxProgressBar('val', psugar); |
327 if ((mashkg > 0) && (mash_infuse > 0) && (mashtime > 0) && (mashtemp > 0)) { |
299 $("#perc_cara").jqxProgressBar('val', pcara); |
328 dataRecord.est_fg = estimate_fg(psugar, pcara, mash_infuse / mashkg, mashtime, mashtemp, svg, dataRecord.est_og); |
300 |
329 } else { |
301 // Calculate estimated svg. |
330 dataRecord.est_fg = estimate_fg(psugar, pcara, 0, 0, 0, svg, dataRecord.est_og); |
302 svg = 0; // default. |
331 } |
303 var rows = $('#yeastGrid').jqxGrid('getrows'); |
332 $('#est_fg').val(dataRecord.est_fg); |
304 for (var i = 0; i < rows.length; i++) { |
333 $('#est_fg2').val(dataRecord.est_fg); |
305 var row = rows[i]; |
334 fig = dataRecord.est_fg; |
306 if (row.y_use == 0) { // Primary |
335 |
307 if (parseFloat(row.y_attenuation) > svg) |
336 dataRecord.est_abv = abvol(dataRecord.est_og, dataRecord.est_fg); |
308 svg = parseFloat(row.y_attenuation); // Take the highest if multiple yeasts. |
337 $('#est_abv').val(dataRecord.est_abv); |
309 } |
338 $('#est_abv2').val(dataRecord.est_abv); |
310 // TODO: brett in secondary ?? |
339 |
311 } |
340 // Calculate the calories in kcal/l (from brouwhulp) |
312 if (svg == 0) |
341 alc = 1881.22 * fig * (org - fig) / (1.775 - org); |
313 svg = 77; |
342 sug = 3550 * fig * (0.1808 * org + 0.8192 * fig - 1.0004); |
314 |
343 $('#kcal').val(Math.round((alc + sug) / (12 * 0.0295735296))); |
315 if ((mashkg > 0) && (mash_infuse > 0) && (mashtime > 0) && (mashtemp > 0)) { |
344 } |
316 dataRecord.est_fg = estimate_fg(psugar, pcara, mash_infuse / mashkg, mashtime, mashtemp, svg, dataRecord.est_og); |
345 |
317 } else { |
346 |
318 dataRecord.est_fg = estimate_fg(psugar, pcara, 0, 0, 0, svg, dataRecord.est_og); |
347 function calcMash() { |
319 } |
348 var infused = 0, i, row, rows; |
320 $('#est_fg').val(dataRecord.est_fg); |
349 if (!(rows = $('#mashGrid').jqxGrid('getrows'))) |
321 $('#est_fg2').val(dataRecord.est_fg); |
350 return; |
322 var fig = dataRecord.est_fg; |
351 if (mashkg == 0) |
323 |
352 return; |
324 dataRecord.est_abv = abvol(dataRecord.est_og, dataRecord.est_fg); |
353 |
325 $("#est_abv").val(dataRecord.est_abv); |
354 for (i = 0; i < rows.length; i++) { |
326 $("#est_abv2").val(dataRecord.est_abv); |
355 row = $('#mashGrid').jqxGrid('getrowdata', i); |
327 |
356 if (row.step_type == 0) // Infusion |
328 // Calculate the calories in kcal/l (from brouwhulp) |
357 infused += row.step_infuse_amount; |
329 var alc = 1881.22 * fig * (org - fig) / (1.775 - org); |
358 $('#mashGrid').jqxGrid('setcellvalue', i, 'step_thickness', infused / mashkg); |
330 var sug = 3550 * fig * (0.1808 * org + 0.8192 * fig - 1.0004); |
359 } |
331 $("#kcal").val(Math.round((alc + sug) / (12 * 0.0295735296))); |
360 } |
332 }; |
361 |
333 |
362 |
334 function hopFlavourContribution(bt, vol, use, amount) { |
363 function calcIBUs() { |
335 var result; |
364 var total_ibus = 0, |
336 |
365 rows = {}, |
337 if (use == 1) { // First wort |
366 i, row; |
338 result = 0.15; // assume 15% flavourcontribution for fwh |
367 |
339 } else if (bt > 50) { |
368 hop_aroma = hop_flavour = 0; |
340 result = 0.10; // assume 10% flavourcontribution as a minimum |
369 if (!(rows = $('#hopGrid').jqxGrid('getrows'))) { |
341 } else { |
370 return; |
342 result = 15.25 / (6 * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((bt - 21) /6, 2)); |
371 } |
343 if (result < 0.10) |
372 for (i = 0; i < rows.length; i++) { |
344 result = 0.10; // assume 10% flavourcontribution as a minimum |
373 row = rows[i]; |
345 } |
374 total_ibus += toIBU(row.h_useat, row.h_form, preboil_sg, parseFloat(dataRecord.batch_size), |
346 return (result * amount * 1000) / vol; |
375 parseFloat(row.h_amount), parseFloat(row.h_time), parseFloat(row.h_alpha), dataRecord.ibu_method); |
347 } |
376 hop_flavour += hopFlavourContribution(parseFloat(row.h_time), parseFloat(dataRecord.batch_size), row.h_useat, parseFloat(row.h_amount)); |
348 |
377 hop_aroma += hopAromaContribution(parseFloat(row.h_time), parseFloat(dataRecord.batch_size), row.h_useat, parseFloat(row.h_amount)); |
349 function hopAromaContribution(bt, vol, use, amount) { |
378 } |
350 var result = 0; |
379 total_ibus = Round(total_ibus, 1); |
351 |
380 hop_flavour = Round(hop_flavour * 100 / 5, 1); |
352 if (use == 5) { // Dry hop |
381 hop_aroma = Round(hop_aroma * 100 / 6, 1); |
353 result = 1.33; |
382 if (hop_flavour > 100) |
354 } else if (bt > 20) { |
383 hop_flavour = 100; |
355 result = 0; |
384 if (hop_aroma > 100) |
356 } else if (bt > 7.5) { |
385 hop_aroma = 100; |
357 result = 10.03 / (4 * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((bt - 7.5) /4, 2)); |
386 console.log('calcIBUs(): ' + total_ibus + ' flavour: ' + hop_flavour + ' aroma: ' + hop_aroma); |
358 } else if (use == 2) { // Boil |
387 dataRecord.est_ibu = total_ibus; |
359 result = 1; |
388 $('#est_ibu').val(total_ibus); |
360 } else if (use == 3) { // Aroma / vlamuit |
389 $('#est_ibu2').val(total_ibus); |
361 result = 1.2; |
390 $('#hop_flavour').jqxProgressBar('val', hop_flavour); |
362 } else if (use == 4) { // Whirlpool |
391 $('#hop_aroma').jqxProgressBar('val', hop_aroma); |
363 result = 1.2; |
392 } |
364 } |
393 |
365 return (result * amount * 1000) / vol; |
394 |
366 } |
395 function adjustHops(factor) { |
367 |
396 |
368 function calcMash() { |
397 //console.log('adjustHops(' + factor + ')'); |
369 |
398 var i, row, amount, rowscount = $('#hopGrid').jqxGrid('getdatainformation').rowscount; |
370 if (!(rows = $('#mashGrid').jqxGrid('getrows'))) |
399 if (rowscount == 0) |
371 return; |
400 return; |
372 if (mashkg == 0) |
401 |
373 return; |
402 for (i = 0; i < rowscount; i++) { |
374 |
403 row = $('#hopGrid').jqxGrid('getrowdata', i); |
375 var infused = 0; |
404 amount = row.h_amount * factor; |
376 for (var i = 0; i < rows.length; i++) { |
405 $('#hopGrid').jqxGrid('setcellvalue', i, 'h_amount', amount); |
377 var row = $("#mashGrid").jqxGrid('getrowdata', i); |
406 } |
378 if (row.step_type == 0) // Infusion |
407 } |
379 infused += row.step_infuse_amount; |
408 |
380 $("#mashGrid").jqxGrid('setcellvalue', i, "step_thickness", infused / mashkg); |
409 |
381 } |
410 function adjustMiscs(factor) { |
382 } |
411 |
383 |
412 //console.log('adjustMiscs(' + factor + ')'); |
384 function calcIBUs() { |
413 var i, row, amount, rowscount = $('#miscGrid').jqxGrid('getdatainformation').rowscount; |
385 var total_ibus = 0; |
414 if (rowscount == 0) |
386 hop_aroma = hop_flavour = 0; |
415 return; |
387 var rows = {}; |
416 |
388 if (!(rows = $('#hopGrid').jqxGrid('getrows'))) { |
417 for (i = 0; i < rowscount; i++) { |
389 return; |
418 row = $('#miscGrid').jqxGrid('getrowdata', i); |
390 } |
419 amount = row.m_amount * factor; |
391 for (var i = 0; i < rows.length; i++) { |
420 $('#miscGrid').jqxGrid('setcellvalue', i, 'm_amount', amount); |
392 var row = rows[i]; |
421 switch (row.m_name) { |
393 total_ibus += toIBU(row.h_useat, row.h_form, preboil_sg, parseFloat(dataRecord.batch_size), |
422 case 'CaCl2': $('#wa_cacl2').val(row.m_amount * 1000); break; |
394 parseFloat(row.h_amount), parseFloat(row.h_time), parseFloat(row.h_alpha), dataRecord.ibu_method); |
423 case 'CaSO4': $('#wa_caso4').val(row.m_amount * 1000); break; |
395 hop_flavour += hopFlavourContribution(parseFloat(row.h_time), parseFloat(dataRecord.batch_size), |
424 case 'MgSO4': $('#wa_mgso4').val(row.m_amount * 1000); break; |
396 row.h_useat, parseFloat(row.h_amount)); |
425 case 'NaCl': $('#wa_nacl').val(row.m_amount * 1000); break; |
397 hop_aroma += hopAromaContribution(parseFloat(row.h_time), parseFloat(dataRecord.batch_size), |
426 case 'Melkzuur': |
398 row.h_useat, parseFloat(row.h_amount)); |
427 case 'Zoutzuur': |
399 } |
428 case 'Fosforzuur': |
400 total_ibus = Math.round(total_ibus * 10) / 10; |
429 case 'Zwavelzuur': $('#wa_acid').val(row.m_amount * 1000); break; |
401 hop_flavour = Math.round(hop_flavour * 1000 / 5) / 10; |
430 case 'NaHCO3': |
402 hop_aroma = Math.round(hop_aroma * 1000 / 6) / 10; |
431 case 'Na2CO3': |
403 if (hop_flavour > 100) |
432 case 'CaCO3': |
404 hop_flavour = 100; |
433 case 'Ca(OH)2': $('#wa_base').val(row.m_amount * 1000); break; |
405 if (hop_aroma > 100) |
434 } |
406 hop_aroma = 100; |
435 } |
407 console.log("calcIBUs(): " + total_ibus + " flavour: " + hop_flavour + " aroma: " + hop_aroma); |
436 } |
408 dataRecord.est_ibu = total_ibus; |
437 |
409 $('#est_ibu').val(total_ibus); |
438 |
410 $('#est_ibu2').val(total_ibus); |
439 function adjustYeasts(factor) { |
411 $("#hop_flavour").jqxProgressBar('val', hop_flavour); |
440 |
412 $("#hop_aroma").jqxProgressBar('val', hop_aroma); |
441 //console.log('adjustYeasts(' + factor + ')'); |
413 }; |
442 var i, row, amount, rowscount = $('#yeastGrid').jqxGrid('getdatainformation').rowscount; |
414 |
443 if (rowscount == 0) |
415 function adjustHops(factor) { |
444 return; |
416 |
445 |
417 console.log("adjustHops("+factor+")"); |
446 for (i = 0; i < rowscount; i++) { |
418 |
447 row = $('#yeastGrid').jqxGrid('getrowdata', i); |
419 var rowscount = $("#hopGrid").jqxGrid('getdatainformation').rowscount; |
448 if (row.y_form == 1) { // Only adjust dry yeast |
420 if (rowscount == 0) |
449 amount = row.y_amount * factor; |
421 return; |
450 $('#yeastGrid').jqxGrid('setcellvalue', i, 'y_amount', amount); |
422 |
451 } |
423 for (var i = 0; i < rowscount; i++) { |
452 } |
424 var row = $("#hopGrid").jqxGrid('getrowdata', i); |
453 } |
425 var amount = row.h_amount * factor; |
454 |
426 $("#hopGrid").jqxGrid('setcellvalue', i, "h_amount", amount); |
455 |
427 } |
456 function adjustWaters(factor) { |
428 }; |
457 |
429 |
458 //console.log('adjustWaters(' + factor + ')'); |
430 function adjustMiscs(factor) { |
459 var i, row, amount, rowscount = $('#mashGrid').jqxGrid('getdatainformation').rowscount; |
431 |
460 if (rowscount == 0) |
432 console.log("adjustMiscs("+factor+")"); |
461 return; |
433 |
462 mash_infuse = 0; |
434 var rowscount = $("#miscGrid").jqxGrid('getdatainformation').rowscount; |
463 for (i = 0; i < rowscount; i++) { |
435 if (rowscount == 0) |
464 row = $('#mashGrid').jqxGrid('getrowdata', i); |
436 return; |
465 if (row.step_type == 0) { // Infusion |
437 |
466 amount = Round(row.step_infuse_amount * factor, 1); |
438 for (var i = 0; i < rowscount; i++) { |
467 $('#mashGrid').jqxGrid('setcellvalue', i, 'step_infuse_amount', amount); |
439 var row = $("#miscGrid").jqxGrid('getrowdata', i); |
468 mash_infuse += amount; |
440 var amount = row.m_amount * factor; |
469 } |
441 $("#miscGrid").jqxGrid('setcellvalue', i, "m_amount", amount); |
470 } |
442 switch (row.m_name) { |
471 if (dataRecord.w2_amount == 0) { |
443 case 'CaCl2': $("#wa_cacl2").val(row.m_amount * 1000); |
472 dataRecord.w1_amount = mash_infuse; |
444 break; |
473 $('#w1_amount').val(mash_infuse); |
445 case 'CaSO4': $("#wa_caso4").val(row.m_amount * 1000); |
474 } else { |
446 break; |
475 dataRecord.w1_amount = (dataRecord.w1_amount / (dataRecord.w1_amount + dataRecord.w2_amount)) * mash_infuse; |
447 case 'MgSO4': $("#wa_mgso4").val(row.m_amount * 1000); |
476 dataRecord.w2_amount = (dataRecord.w2_amount / (dataRecord.w1_amount + dataRecord.w2_amount)) * mash_infuse; |
448 break; |
477 $('#w1_amount').val(dataRecord.w1_amount); |
449 case 'NaCl': $("#wa_nacl").val(row.m_amount * 1000); |
478 $('#w2_amount').val(dataRecord.w2_amount); |
450 break; |
479 } |
451 case 'Melkzuur': |
480 $('#wg_amount').val(mash_infuse); |
452 case 'Zoutzuur': |
481 } |
453 case 'Fosforzuur': |
482 |
454 case 'Zwavelzuur': $("#wa_acid").val(row.m_amount * 1000); |
483 |
455 break; |
484 function GetBUGU() { |
456 case 'NaHCO3': |
485 var gu = (dataRecord.est_og - 1) * 1000; |
457 case 'Na2CO3': |
486 if (gu > 0) |
458 case 'CaCO3': |
487 return dataRecord.est_ibu / gu; |
459 case 'Ca(OH)2': $("#wa_base").val(row.m_amount * 1000); |
488 else |
460 break; |
489 return 0.5; |
461 } |
490 } |
462 } |
491 |
463 }; |
492 |
464 |
493 function GetOptClSO4ratio() { |
465 function adjustYeasts(factor) { |
494 var BUGU = GetBUGU(); |
466 |
495 return (-1.2 * BUGU + 1.4); |
467 console.log("adjustYeasts("+factor+")"); |
496 } |
468 |
497 |
469 var rowscount = $("#yeastGrid").jqxGrid('getdatainformation').rowscount; |
498 |
470 if (rowscount == 0) |
499 |
471 return; |
500 function setRangeIndicator(ion, rangeCode) { |
472 |
501 if ((rangeCode == 'laag') || (rangeCode == 'hoog')) |
473 for (var i = 0; i < rowscount; i++) { |
502 $('#wr_' + ion).html('<img src="images/dialog-error.png"><span style="vertical-align: top; font-size: 10px; font-style: italic;">' + rangeCode + '</span>'); |
474 var row = $("#yeastGrid").jqxGrid('getrowdata', i); |
503 else |
475 if (row.y_form == 1) { // Only adjust dry yeast |
504 $('#wr_' + ion).html('<img src="images/dialog-ok-apply.png">'); |
476 var amount = row.y_amount * factor; |
505 } |
477 $("#yeastGrid").jqxGrid('setcellvalue', i, "y_amount", amount); |
506 |
478 } |
507 |
479 } |
508 function mix(v1, v2, c1, c2) { |
480 }; |
509 if ((v1 + v2) > 0) { |
481 |
510 return ((v1 * c1) + (v2 * c2)) / (v1 + v2); |
482 function adjustWaters(factor) { |
511 } |
483 |
512 return 0; |
484 console.log("adjustWaters("+factor+")"); |
513 } |
485 |
514 |
486 var rowscount = $("#mashGrid").jqxGrid('getdatainformation').rowscount; |
515 |
487 if (rowscount == 0) |
516 // mg/l as CaCO3 |
488 return; |
517 function ResidualAlkalinity(total_alkalinity, calcium, magnesium) { |
489 |
518 return total_alkalinity - (calcium / 1.4 + magnesium / 1.7); |
490 mash_infuse = 0; |
519 } |
491 for (var i = 0; i < rowscount; i++) { |
520 |
492 var row = $("#mashGrid").jqxGrid('getrowdata', i); |
521 |
493 if (row.step_type == 0) { // Infusion |
522 function PartCO3(pH) { |
494 var amount = Math.round(row.step_infuse_amount * factor * 10) / 10; |
523 var H = Math.pow(10, -pH); |
495 $("#mashGrid").jqxGrid('setcellvalue', i, "step_infuse_amount", amount); |
524 return 100 * Ka1 * Ka2 / (H * H + H * Ka1 + Ka1 * Ka2); |
496 mash_infuse += amount; |
525 } |
497 } |
526 |
498 } |
527 |
499 if (dataRecord.w2_amount == 0) { |
528 function PartHCO3(pH) { |
500 dataRecord.w1_amount = mash_infuse; |
529 var H = Math.pow(10, -pH); |
501 $("#w1_amount").val(mash_infuse); |
530 return 100 * Ka1 * H / (H * H + H * Ka1 + Ka1 * Ka2); |
502 } else { |
531 } |
503 dataRecord.w1_amount = (dataRecord.w1_amount / (dataRecord.w1_amount + dataRecord.w2_amount)) * mash_infuse; |
532 |
504 dataRecord.w2_amount = (dataRecord.w2_amount / (dataRecord.w1_amount + dataRecord.w2_amount)) * mash_infuse; |
533 |
505 $("#w1_amount").val(dataRecord.w1_amount); |
534 function Charge(pH) { |
506 $("#w2_amount").val(dataRecord.w2_amount); |
535 return (-2 * PartCO3(pH) - PartHCO3(pH)); |
507 } |
536 } |
508 $('#wg_amount').val(mash_infuse); |
537 |
509 }; |
538 |
510 |
539 //Z alkalinity is the amount of acid (in mEq/l) needed to bring water to the target pH (Z pH) |
511 function GetBUGU() { |
540 function ZAlkalinity(pHZ) { |
512 var gu = (dataRecord.est_og - 1) * 1000; |
541 var C43 = Charge(4.3), |
513 if (gu > 0) |
542 Cw = Charge(parseFloat($('#wg_ph').jqxNumberInput('decimal'))), |
514 return dataRecord.est_ibu / gu; |
543 Cz = Charge(pHZ), |
515 else |
544 DeltaCNaught = -C43 + Cw, |
516 return 0.5; |
545 CT = parseFloat($('#wg_total_alkalinity').jqxNumberInput('decimal')) / 50 / DeltaCNaught, |
517 } |
546 DeltaCZ = -Cz + Cw; |
518 |
547 return CT * DeltaCZ; |
519 function GetOptClSO4ratio() { |
548 } |
520 var BUGU = GetBUGU(); |
549 |
521 return (-1.2 * BUGU + 1.4); |
550 |
522 } |
551 //Z Residual alkalinity is the amount of acid (in mEq/l) needed to bring the water in the mash to the target pH (Z pH) |
523 |
552 function ZRA(pHZ) { |
524 function setWaterAgent(name, amount) { |
553 var Calc = parseFloat($('#wg_calcium').jqxNumberInput('decimal')) / (MMCa / 2), |
525 //console.log("setWaterAgent(" + name + ", " + amount + ")"); |
554 Magn = parseFloat($('#wg_magnesium').jqxNumberInput('decimal')) / (MMMg / 2), |
526 var rows = $('#miscGrid').jqxGrid('getrows'); |
555 Z = ZAlkalinity(pHZ); |
527 if (amount == 0) { |
556 return Z - (Calc / 3.5 + Magn / 7); |
528 for (var i = 0; i < rows.length; i++) { |
557 } |
529 var row = rows[i]; |
558 |
530 if (row.m_name == name) { |
559 |
531 var id = $("#miscGrid").jqxGrid('getrowid', i); |
560 function ProtonDeficit(pHZ) { |
532 var commit = $("#miscGrid").jqxGrid('deleterow', id); |
561 var ebc, C1, i, rows, row, Result = ZRA(pHZ) * parseFloat($('#wg_amount').jqxNumberInput('decimal')); |
533 } |
562 // proton deficit for the grist |
534 } |
563 rows = $('#fermentableGrid').jqxGrid('getrows'); |
535 } else { |
564 for (i = 0; i < rows.length; i++) { |
536 var found = false; |
565 row = rows[i]; |
537 for (var i = 0; i < rows.length; i++) { |
566 if (row.f_added == 0 && row.f_graintype != 6) { // Added == Mash && graintype != No Malt |
538 var row = rows[i]; |
567 // Check if acid is required |
539 if (row.m_name == name) { |
568 C1 = 0; |
540 found = true; |
569 if ((row.f_di_ph != 5.7) && ((row.f_acid_to_ph_57 < - 0.1) || (row.f_acid_to_ph_57 > 0.1))) { |
541 $("#miscGrid").jqxGrid('setcellvalue', i, 'm_amount', amount / 1000); |
570 C1 = row.f_acid_to_ph_57 / (row.f_di_ph - 5.7); |
542 break; |
571 } else { |
543 } |
572 // If the acid_to_ph_5.7 is unknown from the maltster, guess the required acid. |
544 } |
573 ebc = row.f_color; |
545 if (! found) { |
574 switch (row.f_graintype) { |
546 var miscs = new $.jqx.dataAdapter(miscInvSource, { |
575 case 0: // Base, Special, Kilned |
547 loadComplete: function () { |
576 case 3: |
548 var records = miscs.records; |
577 case 5: C1 = 0.014 * ebc - 34.192; |
549 for (var i = 0; i < records.length; i++) { |
578 break; |
550 var record = records[i]; |
579 case 2: C1 = -0.0597 * ebc - 32.457; // Crystal |
551 if (record.name == name) { |
580 break; |
552 var row = {}; |
581 case 1: C1 = 0.0107 * ebc - 54.768; // Roast |
553 row["m_name"] = record.name; |
582 break; |
554 row["m_amount"] = amount / 1000; |
583 case 4: C1 = -149; // Sour malt |
555 row["m_cost"] = record.cost; |
584 break; |
556 row["m_type"] = record.type; |
585 } |
557 row["m_use_use"] = record.use_use; |
586 } |
558 row["m_time"] = 0; |
587 x = C1 * (pHZ - row.f_di_ph); // AcidRequired(ZpH) |
559 row["m_amount_is_weight"] = record.amount_is_weight; |
588 Result += x * row.f_amount; |
560 row["m_inventory"] = record.inventory; |
589 } |
561 row["m_avail"] = 1; |
590 } |
562 var commit = $("#miscGrid").jqxGrid('addrow', null, row); |
591 return Result; |
563 } |
592 } |
564 } |
593 |
565 } |
594 |
566 }); |
595 function MashpH() { |
567 miscs.dataBind(); |
596 var n = 0, |
568 return; |
597 pH = 5.4, |
569 } |
598 deltapH = 0.001, |
570 } |
599 deltapd = 0.1, |
571 } |
600 pd = ProtonDeficit(pH); |
572 |
601 while (((pd < -deltapd) || (pd > deltapd)) && (n < 2000)) { |
573 function setRangeIndicator(ion, rangeCode) { |
602 n++; |
574 if ((rangeCode == "laag") || (rangeCode == "hoog")) |
603 if (pd < -deltapd) |
575 $("#wr_"+ion).html("<img src='images/dialog-error.png'><span style='vertical-align: top; font-size: 10px; font-style: italic;'>"+rangeCode + "</span>"); |
604 pH -= deltapH; |
576 else |
605 else if (pd > deltapd) |
577 $("#wr_"+ion).html("<img src='images/dialog-ok-apply.png'>"); |
606 pH += deltapH; |
578 } |
607 pd = ProtonDeficit(pH); |
579 |
608 } |
580 function mix(v1, v2, c1, c2) { |
609 //console.log('MashpH() n: ' + n + ' pH: ' + pH); |
581 if ((v1 + v2) > 0) { |
610 return pH; |
582 return ((v1 * c1) + (v2 * c2)) / (v1 + v2); |
611 } |
583 } |
612 |
584 return 0; |
613 |
585 } |
614 function GetAcidSpecs(AT) { |
586 |
615 switch (AT) { |
587 // mg/l as CaCO3 |
616 case 0: return { pK1: 3.86, pK2: 20, pK3: 20, MolWt: 90.08, AcidSG: 1214, AcidPrc: 0.88 }; // Melkzuur |
588 function ResidualAlkalinity(total_alkalinity, calcium, magnesium) { |
617 case 1: return { pK1: -7, pK2: 20, pK3: 20, MolWt: 36.46, AcidSG: 1142, AcidPrc: 0.28 }; // Zoutzuur |
589 return total_alkalinity - (calcium / 1.4 + magnesium / 1.7); |
618 case 2: return { pK1: 2.12, pK2: 7.20, pK3: 12.44, MolWt: 98.00, AcidSG: 1170, AcidPrc: 0.25 }; // Fosforzuur |
590 } |
619 case 3: return { pK1: -1, pK2: 1.92, pK3: 20, MolWt: 98.07, AcidSG: 1700, AcidPrc: 0.93 }; // Zwavelzuur |
591 |
620 } |
592 var Ka1 = 0.0000004445; |
621 } |
593 var Ka2 = 0.0000000000468; |
622 |
594 |
623 |
595 function PartCO3(pH) { |
624 |
596 var H = Math.pow(10, -pH); |
625 |
597 return 100 * Ka1 * Ka2 / (H*H + H * Ka1 + Ka1 * Ka2); |
626 |
598 } |
627 |
599 |
628 |
600 function PartHCO3(pH) { |
629 $(document).ready(function() { |
601 var H = Math.pow(10, -pH); |
630 |
602 return 100 * Ka1 * H / (H*H + H * Ka1 + Ka1 * Ka2); |
631 var to_100 = false, // Fermentables adjust to 100% |
603 } |
632 |
604 |
633 fermentableRow = 0, |
605 function Charge(pH) { |
634 fermentableData = {}, |
606 return (-2 * PartCO3(pH) - PartHCO3(pH)); |
635 hopRow = 0, |
607 } |
636 hopData = {}, |
608 |
637 miscRow = 0, |
609 //Z alkalinity is the amount of acid (in mEq/l) needed to bring water to the target pH (Z pH) |
638 miscData = {}, |
610 function ZAlkalinity(pHZ) { |
639 yeastRow = 0, |
611 var C43 = Charge(4.3); |
640 yeastData = {}, |
612 var Cw = Charge(parseFloat($("#wg_ph").jqxNumberInput('decimal'))); |
641 mashRow = 0, |
613 var Cz = Charge(pHZ); |
642 mashData = {}, |
614 var DeltaCNaught = -C43+Cw; |
643 |
615 var CT = parseFloat($("#wg_total_alkalinity").jqxNumberInput('decimal')) / 50 / DeltaCNaught; |
644 url = 'includes/db_recipes.php', |
616 var DeltaCZ = -Cz+Cw; |
645 // prepare the data |
617 return CT * DeltaCZ; |
646 source = { |
618 } |
647 datatype: 'json', |
619 |
648 cache: false, |
620 //Z Residual alkalinity is the amount of acid (in mEq/l) needed to bring the water in the mash to the target pH (Z pH) |
649 datafields: [ |
621 function ZRA(pHZ) { |
650 { name: 'record', type: 'number' }, |
622 |
651 { name: 'uuid', type: 'string' }, |
623 var Calc = parseFloat($("#wg_calcium").jqxNumberInput('decimal')) / (MMCa / 2); |
652 { name: 'locked', type: 'int' }, |
624 var Magn = parseFloat($("#wg_magnesium").jqxNumberInput('decimal')) / (MMMg / 2); |
653 { name: 'st_name', type: 'string' }, |
625 var Z = ZAlkalinity(pHZ); |
654 { name: 'st_letter', type: 'string' }, |
626 return Z - (Calc / 3.5 + Magn / 7); |
655 { name: 'st_guide', type: 'string' }, |
627 } |
656 { name: 'st_type', type: 'int' }, |
628 |
657 { name: 'st_category', type: 'string' }, |
629 function ProtonDeficit(pHZ) { |
658 { name: 'st_category_number', type: 'float' }, |
630 |
659 { name: 'st_og_min', type: 'float' }, |
631 var Result = ZRA(pHZ) * parseFloat($("#wg_amount").jqxNumberInput('decimal')); |
660 { name: 'st_og_max', type: 'float' }, |
632 // proton deficit for the grist |
661 { name: 'st_fg_min', type: 'float' }, |
633 var rows = $('#fermentableGrid').jqxGrid('getrows'); |
662 { name: 'st_fg_max', type: 'float' }, |
634 for (var i = 0; i < rows.length; i++) { |
663 { name: 'st_ibu_min', type: 'float' }, |
635 var row = rows[i]; |
664 { name: 'st_ibu_max', type: 'float' }, |
636 if (row.f_added == 0 && row.f_graintype != 6) { // Added == Mash && graintype != No Malt |
665 { name: 'st_color_min', type: 'float' }, |
637 // Check if acid is required |
666 { name: 'st_color_max', type: 'float' }, |
638 var C1 = 0; |
667 { name: 'st_carb_min', type: 'float' }, |
639 if ((row.f_di_ph != 5.7) && ((row.f_acid_to_ph_57 < - 0.1) || (row.f_acid_to_ph_57 > 0.1))) { |
668 { name: 'st_carb_max', type: 'float' }, |
640 C1 = row.f_acid_to_ph_57 / (row.f_di_ph - 5.7); |
669 { name: 'st_abv_min', type: 'float' }, |
641 } else { |
670 { name: 'st_abv_max', type: 'float' }, |
642 // If the acid_to_ph_5.7 is unknown from the maltster, guess the required acid. |
671 { name: 'name', type: 'string' }, |
643 var ebc = row.f_color; |
672 { name: 'notes', type: 'string' }, |
644 switch (row.f_graintype) { |
673 { name: 'type', type: 'int' }, |
645 case 0: // Base, Special, Kilned |
674 { name: 'batch_size', type: 'float' }, |
646 case 3: |
675 { name: 'boil_size', type: 'float' }, |
647 case 5: C1 = 0.014 * ebc - 34.192; |
676 { name: 'boil_time', type: 'float' }, |
648 break; |
677 { name: 'efficiency', type: 'float' }, |
649 case 2: C1 = -0.0597 * ebc - 32.457; // Crystal |
678 { name: 'est_og', type: 'float' }, |
650 break; |
679 { name: 'est_fg', type: 'float' }, |
651 case 1: C1 = 0.0107 * ebc - 54.768; // Roast |
680 { name: 'est_abv', type: 'float' }, |
652 break; |
681 { name: 'est_color', type: 'float' }, |
653 case 4: C1 = -149; // Sour malt |
682 { name: 'color_method', type: 'int' }, |
654 break; |
683 { name: 'est_ibu', type: 'float' }, |
655 } |
684 { name: 'ibu_method', type: 'int' }, |
656 } |
685 { name: 'est_carb', type: 'float' }, |
657 x = C1 * (pHZ - row.f_di_ph); // AcidRequired(ZpH) |
686 { name: 'sparge_temp', type: 'float' }, |
658 Result += x * row.f_amount; |
687 { name: 'sparge_ph', type: 'float' }, |
659 } |
688 { name: 'sparge_volume', type: 'float' }, |
660 } |
689 { name: 'sparge_source', type: 'int' }, |
661 return Result; |
690 { name: 'sparge_acid_type', type: 'int' }, |
662 } |
691 { name: 'sparge_acid_perc', type: 'float' }, |
663 |
692 { name: 'sparge_acid_amount', type: 'float' }, |
664 function MashpH() { |
693 { name: 'mash_ph', type: 'float' }, |
665 var n = 0; |
694 { name: 'mash_name', type: 'string' }, |
666 var pH = 5.4; |
695 { name: 'calc_acid', type: 'int' }, |
667 var deltapH = 0.001; |
696 { name: 'w1_name', type: 'string' }, |
668 var deltapd = 0.1; |
697 { name: 'w1_amount', type: 'float' }, |
669 var pd = ProtonDeficit(pH); |
698 { name: 'w1_calcium', type: 'float' }, |
670 while (((pd < -deltapd) || (pd > deltapd)) && (n < 2000)) { |
699 { name: 'w1_sulfate', type: 'float' }, |
671 n++; |
700 { name: 'w1_chloride', type: 'float' }, |
672 if (pd < -deltapd) |
701 { name: 'w1_sodium', type: 'float' }, |
673 pH -= deltapH; |
702 { name: 'w1_magnesium', type: 'float' }, |
674 else if (pd > deltapd) |
703 { name: 'w1_total_alkalinity', type: 'float' }, |
675 pH += deltapH; |
704 { name: 'w1_ph', type: 'float' }, |
676 pd = ProtonDeficit(pH); |
705 { name: 'w1_cost', type: 'float' }, |
677 } |
706 { name: 'w2_name', type: 'string' }, |
678 console.log("MashpH() n: "+n+" pH: "+pH); |
707 { name: 'w2_amount', type: 'float' }, |
679 return pH; |
708 { name: 'w2_calcium', type: 'float' }, |
680 } |
709 { name: 'w2_sulfate', type: 'float' }, |
681 |
710 { name: 'w2_chloride', type: 'float' }, |
682 function GetAcidSpecs(AT) { |
711 { name: 'w2_sodium', type: 'float' }, |
683 switch(AT) { |
712 { name: 'w2_magnesium', type: 'float' }, |
684 case 0: return { // Melkzuur |
713 { name: 'w2_total_alkalinity', type: 'float' }, |
685 pK1: 3.86, |
714 { name: 'w2_ph', type: 'float' }, |
686 pK2: 20, |
715 { name: 'w2_cost', type: 'float' }, |
687 pK3: 20, |
716 { name: 'wg_amount', type: 'float' }, |
688 MolWt: 90.08, |
717 { name: 'wg_calcium', type: 'float' }, |
689 AcidSG: 1214, |
718 { name: 'wg_sulfate', type: 'float' }, |
690 AcidPrc: 0.88 |
719 { name: 'wg_chloride', type: 'float' }, |
691 }; |
720 { name: 'wg_sodium', type: 'float' }, |
692 case 1: return { // Zoutzuur |
721 { name: 'wg_magnesium', type: 'float' }, |
693 pK1: -7, |
722 { name: 'wg_total_alkalinity', type: 'float' }, |
694 pK2: 20, |
723 { name: 'wg_ph', type: 'float' }, |
695 pK3: 20, |
724 { name: 'wb_calcium', type: 'float' }, |
696 MolWt: 36.46, |
725 { name: 'wb_sulfate', type: 'float' }, |
697 AcidSG: 1142, |
726 { name: 'wb_chloride', type: 'float' }, |
698 AcidPrc: 0.28 |
727 { name: 'wb_sodium', type: 'float' }, |
699 }; |
728 { name: 'wb_magnesium', type: 'float' }, |
700 case 2: return { // Fosforzuur |
729 { name: 'wb_total_alkalinity', type: 'float' }, |
701 pK1: 2.12, |
730 { name: 'wb_ph', type: 'float' }, |
702 pK2: 7.20, |
731 { name: 'wa_acid_name', type: 'int' }, |
703 pK3: 12.44, |
732 { name: 'wa_acid_perc', type: 'int' }, |
704 MolWt: 98.00, |
733 { name: 'wa_base_name', type: 'int' }, |
705 AcidSG: 1170, |
734 { name: 'fermentables', type: 'array' }, |
706 AcidPrc: 0.25 |
735 { name: 'hops', type: 'array' }, |
707 }; |
736 { name: 'miscs', type: 'array' }, |
708 case 3: return { // Zwavelzuur |
737 { name: 'yeasts', type: 'array' }, |
709 pK1: -1, |
738 { name: 'mashs', type: 'array' } |
710 pK2: 1.92, |
739 ], |
711 pK3: 20, |
740 id: 'record', |
712 MolWt: 98.07, |
741 url: url + '?record=' + my_record |
713 AcidSG: 1700, |
742 }, |
714 AcidPrc: 0.93 |
743 // Load data and select one record. |
715 }; |
744 dataAdapter = new $.jqx.dataAdapter(source, { |
716 } |
745 loadComplete: function() { |
717 console.log("Bummer, AT is " + AT); |
746 var records = dataAdapter.records; |
718 } |
747 dataRecord = records[0]; |
719 |
748 // Hidden record uuid |
720 // Procedure TFrmWaterAdjustment.CalcWater2; |
749 $('#name').val(dataRecord.name); |
721 function calcWater() { |
750 $('#notes').val(dataRecord.notes); |
722 |
751 $('#locked').val(dataRecord.locked); |
723 console.log("calcWater()"); |
752 $('#st_name').val(dataRecord.st_name); |
724 var liters = 0; |
753 $('#st_letter').val(dataRecord.st_letter); |
725 var calcium = 0; |
754 $('#st_guide').val(dataRecord.st_guide); |
726 var magnesium = 0; |
755 $('#st_category').val(dataRecord.st_category); |
727 var sodium = 0; |
756 $('#st_category_number').val(dataRecord.st_category_number); |
728 var total_alkalinity = 0; |
757 $('#st_type').val(StyleTypeData[dataRecord.st_type].nl); |
729 var bicarbonate = 0; |
758 $('#type').val(dataRecord.type); |
730 var chloride = 0; |
759 $('#batch_size').val(dataRecord.batch_size); |
731 var sulfate = 0; |
760 $('#boil_size').val(dataRecord.boil_size); |
732 var ph = 0; |
761 $('#boil_time').val(dataRecord.boil_time); |
733 var RA = 0; |
762 $('#efficiency').val(dataRecord.efficiency); |
734 var acid = 0; |
763 $('#est_og').val(dataRecord.est_og); |
735 var frac = 0; |
764 $('#est_og2').val(dataRecord.est_og); |
736 var TpH = 0; |
765 $('#st_og_min').val(dataRecord.st_og_min); |
737 var protonDeficit = 0; |
766 $('#st_og_max').val(dataRecord.st_og_max); |
738 |
767 $('#est_fg').val(dataRecord.est_fg); |
739 if (dataRecord.w1_name == "") { |
768 $('#est_fg2').val(dataRecord.est_fg); |
740 return; |
769 $('#st_fg_min').val(dataRecord.st_fg_min); |
741 } |
770 $('#st_fg_max').val(dataRecord.st_fg_max); |
742 // Check for a recipe too. Fermentables, Mash schedule? |
771 $('#est_fg').val(dataRecord.est_fg); |
743 |
772 $('#est_fg2').val(dataRecord.est_fg); |
744 // If there is a dillute water source, mix the waters. |
773 $('#st_fg_min').val(dataRecord.st_fg_min); |
745 if (dataRecord.w2_name != "") { |
774 $('#st_fg_max').val(dataRecord.st_fg_max); |
746 liters = dataRecord.w1_amount + dataRecord.w2_amount; |
775 $('#est_color').val(dataRecord.est_color); |
747 calcium = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_calcium, dataRecord.w2_calcium); |
776 $('#est_color2').val(dataRecord.est_color); |
748 magnesium = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_magnesium, dataRecord.w2_magnesium); |
777 $('#est_abv').val(dataRecord.est_abv); |
749 sodium = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_sodium, dataRecord.w2_sodium); |
778 $('#est_abv2').val(dataRecord.est_abv); |
750 chloride = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_chloride, dataRecord.w2_chloride); |
779 $('#st_abv_min').val(dataRecord.st_abv_min); |
751 sulfate = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_sulfate, dataRecord.w2_sulfate); |
780 $('#st_abv_max').val(dataRecord.st_abv_max); |
752 total_alkalinity = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_total_alkalinity, dataRecord.w2_total_alkalinity); |
781 $('#st_color_min').val(dataRecord.st_color_min); |
753 ph = -Math.log10(((Math.pow(10, -dataRecord.w1_ph) * dataRecord.w1_amount) + (Math.pow(10, -dataRecord.w2_ph) * dataRecord.w2_amount)) / liters); |
782 $('#st_color_max').val(dataRecord.st_color_max); |
754 } else { |
783 $('#color_method').val(dataRecord.color_method); |
755 liters = dataRecord.w1_amount; |
784 $('#est_ibu').val(dataRecord.est_ibu); |
756 calcium = dataRecord.w1_calcium; |
785 $('#est_ibu2').val(dataRecord.est_ibu); |
757 magnesium = dataRecord.w1_magnesium; |
786 $('#st_ibu_min').val(dataRecord.st_ibu_min); |
758 sodium = dataRecord.w1_sodium; |
787 $('#st_ibu_max').val(dataRecord.st_ibu_max); |
759 chloride = dataRecord.w1_chloride; |
788 $('#ibu_method').val(dataRecord.ibu_method); |
760 sulfate = dataRecord.w1_sulfate; |
789 $('#est_carb').val(dataRecord.est_carb); |
761 total_alkalinity = dataRecord.w1_total_alkalinity; |
790 $('#st_carb_min').val(dataRecord.st_carb_min); |
762 ph = dataRecord.w1_ph; |
791 $('#st_carb_max').val(dataRecord.st_carb_max); |
763 } |
792 $('#mash_name').val(dataRecord.mash_name); |
764 $('#wg_amount').val(liters); |
793 $('#mash_ph').val(dataRecord.mash_ph); |
765 var wg_calcium = calcium; |
794 $('#sparge_temp').val(dataRecord.sparge_temp); |
766 $('#wg_calcium').val(Math.round(calcium * 10) / 10); |
795 $('#sparge_ph').val(dataRecord.sparge_ph); |
767 var wg_magnesium = magnesium; |
796 $('#sparge_volume').val(dataRecord.sparge_volume); |
768 $('#wg_magnesium').val(Math.round(magnesium * 10) / 10); |
797 $('#sparge_source').val(dataRecord.sparge_source); |
769 var wg_sodium = sodium; |
798 $('#sparge_acid_type').val(dataRecord.sparge_acid_type); |
770 $('#wg_sodium').val(Math.round(sodium * 10) / 10); |
799 $('#sparge_acid_perc').val(dataRecord.sparge_acid_perc); |
771 var wg_total_alkalinity = total_alkalinity; |
800 $('#sparge_acid_amount').val(dataRecord.sparge_acid_amount * 1000); |
772 $('#wg_total_alkalinity').val(Math.round(total_alkalinity * 10) / 10); |
801 $('#calc_acid').val(dataRecord.calc_acid); |
773 var wg_chloride = chloride; |
802 $('#w1_name').val(dataRecord.w1_name); |
774 $('#wg_chloride').val(Math.round(chloride * 10) / 10); |
803 $('#w1_amount').val(dataRecord.w1_amount); |
775 var wg_sulfate = sulfate; |
804 $('#w1_calcium').val(dataRecord.w1_calcium); |
776 $('#wg_sulfate').val(Math.round(sulfate * 10) / 10); |
805 $('#w1_sulfate').val(dataRecord.w1_sulfate); |
777 // Note: brouwhulp has the malts included here in the result. |
806 $('#w1_chloride').val(dataRecord.w1_chloride); |
778 var wg_ph = ph; |
807 $('#w1_sodium').val(dataRecord.w1_sodium); |
779 $('#wg_ph').val(Math.round(ph * 10) / 10); |
808 $('#w1_magnesium').val(dataRecord.w1_magnesium); |
780 $('#wb_ph').val(Math.round(MashpH() * 10) / 10); |
809 $('#w1_total_alkalinity').val(dataRecord.w1_total_alkalinity); |
781 bicarbonate = total_alkalinity * 1.22; |
810 $('#w1_ph').val(dataRecord.w1_ph); |
782 var wg_bicarbonate = bicarbonate; |
811 $('#w1_cost').val(dataRecord.w1_cost); |
783 |
812 $('#w2_name').val(dataRecord.w2_name); |
784 // Noot: de volgende berekeningen geven bijna gelijke resultaten in Brun'water. |
813 $('#w2_amount').val(dataRecord.w2_amount); |
785 // Calculate Ca |
814 $('#w2_calcium').val(dataRecord.w2_calcium); |
786 RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 + |
815 $('#w2_sulfate').val(dataRecord.w2_sulfate); |
787 parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4; |
816 $('#w2_chloride').val(dataRecord.w2_chloride); |
788 calcium += 1000 * RA / liters; |
817 $('#w2_sodium').val(dataRecord.w2_sodium); |
789 |
818 $('#w2_magnesium').val(dataRecord.w2_magnesium); |
790 // Calculate Mg |
819 $('#w2_total_alkalinity').val(dataRecord.w2_total_alkalinity); |
791 RA = parseFloat($("#wa_mgso4").jqxNumberInput('decimal')) * MMMg / MMMgSO4; |
820 $('#w2_ph').val(dataRecord.w2_ph); |
792 magnesium += 1000 * RA / liters; |
821 $('#w2_cost').val(dataRecord.w2_cost); |
793 |
822 $('#wg_amount').val(dataRecord.wg_amount); |
794 // Calculate Na |
823 $('#wg_calcium').val(dataRecord.wg_calcium); |
795 RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl; |
824 $('#wg_sulfate').val(dataRecord.wg_sulfate); |
796 sodium += 1000 * RA / liters; |
825 $('#wg_chloride').val(dataRecord.wg_chloride); |
797 |
826 $('#wg_sodium').val(dataRecord.wg_sodium); |
798 // Calculate SO4 |
827 $('#wg_magnesium').val(dataRecord.wg_magnesium); |
799 RA = parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMSO4 / MMCaSO4 + |
828 $('#wg_total_alkalinity').val(dataRecord.wg_total_alkalinity); |
800 parseFloat($("#wa_mgso4").jqxNumberInput('decimal')) * MMSO4 / MMMgSO4; |
829 $('#wg_ph').val(dataRecord.wg_ph); |
801 sulfate += 1000 * RA / liters; |
830 $('#wb_calcium').val(dataRecord.wb_calcium); |
802 |
831 $('#wb_sulfate').val(dataRecord.wb_sulfate); |
803 // Calculate Cl |
832 $('#wb_chloride').val(dataRecord.wb_chloride); |
804 RA = 2 * parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCl / MMCaCl2 + |
833 $('#wb_sodium').val(dataRecord.wb_sodium); |
805 parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMCl / MMNaCl; |
834 $('#wb_magnesium').val(dataRecord.wb_magnesium); |
806 chloride += 1000 * RA / liters; |
835 $('#wb_total_alkalinity').val(dataRecord.wb_total_alkalinity); |
807 // Einde noot. |
836 $('#wb_ph').val(dataRecord.wb_ph); |
808 |
837 $('#wa_acid_name').val(dataRecord.wa_acid_name); |
809 if ($("#wa_acid_name").val() < 0 || $("#wa_acid_name").val() > 3) { |
838 $('#wa_acid_perc').val(dataRecord.wa_acid_perc); |
810 console.log("fix wa_acid_name"); |
839 $('#wa_base_name').val(dataRecord.wa_base_name); |
811 $("#wa_acid_name").val(0); |
840 editFermentable(dataRecord); |
812 dataRecord.wa_acid_name = 0; |
841 editHop(dataRecord); |
813 } |
842 editMisc(dataRecord); |
814 if (last_acid == '') |
843 editYeast(dataRecord); |
815 last_acid = AcidTypeData[$("#wa_acid_name").val()].nl; |
844 editMash(dataRecord); |
816 |
845 $('#jqxTabs').jqxTabs('next'); |
817 if ($("#wa_base_name").val() < 0 || $("#wa_base_name").val() > 3) { |
846 }, |
818 console.log("fix wa_base_name"); |
847 loadError: function(jqXHR, status, error) {}, |
819 $("#wa_base_name").val(0); |
848 beforeLoadComplete: function(records) { $('#jqxLoader').jqxLoader('open'); } |
820 dataRecord.wa_base_name = 0; |
849 }), |
821 } |
850 |
822 if (last_base == '') |
851 // Inline fermentables editor |
823 last_base = BaseTypeData[$("#wa_base_name").val()].nl; |
852 editFermentable = function(data) { |
824 |
853 var fermentableSource = { |
825 var AT = dataRecord.wa_acid_name; |
854 localdata: data.fermentables, |
826 var BT = dataRecord.wa_base_name; |
855 datatype: 'local', |
827 |
856 cache: false, |
828 var result = GetAcidSpecs(AT); |
857 async: false, |
829 var pK1 = result.pK1; |
858 datafields: [ |
830 var pK2 = result.pK2; |
859 { name: 'f_name', type: 'string' }, |
831 var pK3 = result.pK3; |
860 { name: 'f_origin', type: 'string' }, |
832 var MolWt = result.MolWt; |
861 { name: 'f_supplier', type: 'string' }, |
833 var AcidSG = result.AcidSG; |
862 { name: 'f_amount', type: 'float' }, |
834 var AcidPrc = result.AcidPrc; |
863 { name: 'f_cost', type: 'float' }, |
835 |
864 { name: 'f_type', type: 'int' }, |
836 if (dataRecord.calc_acid) { |
865 { name: 'f_yield', type: 'float' }, |
837 TpH = parseFloat(dataRecord.mash_ph); |
866 { name: 'f_color', type: 'float' }, |
838 protonDeficit = ProtonDeficit(TpH); |
867 { name: 'f_coarse_fine_diff', type: 'float' }, |
839 console.log("calc_acid tgt: "+TpH+" protonDeficit: "+protonDeficit); |
868 { name: 'f_moisture', type: 'float' }, |
840 if (protonDeficit > 0) { // Add acid |
869 { name: 'f_diastatic_power', type: 'float' }, |
841 $("#wa_base").val(0); |
870 { name: 'f_protein', type: 'float' }, |
842 setWaterAgent(last_base, 0); |
871 { name: 'f_max_in_batch', type: 'float' }, |
843 frac = CalcFrac(TpH, pK1, pK2, pK3); |
872 { name: 'f_graintype', type: 'int' }, |
844 Acid = protonDeficit / frac; |
873 { name: 'f_added', type: 'int' }, |
845 Acid *= MolWt; // mg |
874 { name: 'f_dissolved_protein', type: 'float' }, |
846 Acidmg = Acid; |
875 { name: 'f_recommend_mash', type: 'int' }, |
847 Acid = Acid / AcidSG; // ml |
876 { name: 'f_add_after_boil', type: 'int' }, |
848 |
877 { name: 'f_adjust_to_total_100', type: 'int' }, |
849 if (parseFloat($("#wa_acid_perc").jqxNumberInput('decimal')) == 0) |
878 { name: 'f_percentage', type: 'float' }, |
850 $("#wa_acid_perc").val(AcidPrc); |
879 { name: 'f_di_ph', type: 'float' }, |
851 Acid = Acid * AcidPrc / (parseFloat($("#wa_acid_perc").jqxNumberInput('decimal')) / 100); // ml |
880 { name: 'f_acid_to_ph_57', type: 'float' }, |
852 console.log("Final ml: "+Acid); |
881 { name: 'f_inventory', type: 'float' }, |
853 $("#wa_acid").val(Math.round(Acid * 100) / 100); |
882 { name: 'f_avail', type: 'int' } |
854 setWaterAgent(AcidTypeData[AT].nl, Math.round(Acid * 100) / 100); |
883 ], |
855 |
884 addrow: function(rowid, rowdata, position, commit) { |
856 bicarbonate = bicarbonate - protonDeficit * frac / liters; |
885 //console.log("fermentable addrow "+rowid); |
857 total_alkalinity = bicarbonate * 50 / 61; |
886 commit(true); |
858 } else if (protonDeficit < 0) { //Add base |
887 }, |
859 $("#wa_acid").val(0); |
888 deleterow: function(rowid, commit) { |
860 setWaterAgent(last_acid, 0); |
889 //console.log("fermentable deleterow "+rowid); |
861 var r1d = Math.pow(10, (TpH - 6.38)); |
890 commit(true); |
862 var r2d = Math.pow(10, (TpH - 10.38)); |
891 }, |
863 var f1d = 1 / (1 + r1d + r1d * r2d); |
892 updaterow: function(rowid, rowdata, commit) { |
864 var f2d = f1d * r1d; |
893 //console.log("fermentable updaterow "+rowid); |
865 var f3d = f2d * r2d; |
894 commit(true); |
866 switch (BT) { |
895 } |
867 case 0: RA = -protonDeficit / (f1d - f3d); //Sodiumbicarbonate, mmol totaal |
896 }, |
868 RA = RA * MMNaHCO3/1000; //gram |
897 fermentableAdapter = new $.jqx.dataAdapter(fermentableSource); |
869 $("#wa_base").val(Math.round(RA * 100) / 100); |
898 |
870 setWaterAgent('NaHCO3', Math.round(RA * 100) / 100); |
899 $('#fermentableGrid').jqxGrid({ |
871 if (liters > 0) { |
900 width: 1240, |
872 // Na |
901 height: 470, |
873 RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl + |
902 source: fermentableAdapter, |
874 parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMNa / MMNaHCO3; |
903 theme: theme, |
875 RA = 1000 * RA / liters; |
904 selectionmode: 'singlerow', |
876 sodium = wg_sodium + RA; |
905 showtoolbar: true, |
877 // HCO3 |
906 rendertoolbar: function(toolbar) { |
878 RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNaHCO3; |
907 //var me = this; |
879 RA = 1000 * RA / liters; |
908 var container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>'); |
880 bicarbonate = wg_bicarbonate + RA; |
909 toolbar.append(container); |
881 total_alkalinity = bicarbonate * 50 / 61; |
910 container.append('<div style="float: left; margin-left: 165px;" id="faddrowbutton"></div>'); |
882 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); |
911 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>'); |
883 } |
912 container.append('<div style="float: left; margin-left: 10px;" id="finstockbutton"></div>'); |
884 break; |
913 container.append('<input style="float: left; margin-left: 400px;" id="fdeleterowbutton" type="button" value="Verwijder mout" />'); |
885 case 1: RA = -protonDeficit / (2 * f1d + f2d); // Sodiumcarbonate, mmol totaal |
914 // add fermentable from dropdownlist. |
886 RA = RA * MMNa2CO3/1000; //gram |
915 $('#faddrowbutton').jqxDropDownList({ |
887 $("#wa_base").val(Math.round(RA * 100) / 100); |
916 placeHolder: 'Kies mout:', |
888 setWaterAgent('Na2CO3', Math.round(RA * 100) / 100); |
917 theme: theme, |
889 if (liters > 0) { |
918 template: 'primary', |
890 RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl + |
919 source: fermentablelist, |
891 parseFloat($("#wa_base").jqxNumberInput('decimal')) * 2 * MMNa / MMNa2CO3; |
920 displayMember: 'name', |
892 RA = 1000 * RA / liters; |
921 width: 150, |
893 sodium = wg_sodium + RA; |
922 height: 27, |
894 // HCO3 |
923 dropDownWidth: 500, |
895 RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNa2CO3; |
924 dropDownHeight: 500, |
896 RA = 1000 * RA / liters; |
925 renderer: function(index, label, value) { |
897 bicarbonate = wg_bicarbonate + RA; |
926 var datarecord = fermentablelist.records[index]; |
898 total_alkalinity = bicarbonate * 50 / 61; |
927 return datarecord.supplier + ' / ' + datarecord.name + ' (' + datarecord.color + ' EBC)'; |
899 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); |
928 } |
900 } |
929 }); |
901 break; |
930 $('#faddrowbutton').on('select', function(event) { |
902 case 2: RA = -protonDeficit * (f1d - f3d); // Calciumcarbonate, mmol totaal |
931 if (event.args) { |
903 RA = RA * MMCaCO3/1000; //gram |
932 var index, datarecord, row = {}, rowscount = $('#fermentableGrid').jqxGrid('getdatainformation').rowscount; |
904 //but only 1/3 is effective, so add 3 times as much |
933 index = event.args.index; |
905 RA = 3 * RA; |
934 datarecord = fermentablelist.records[index]; |
906 $("#wa_base").val(Math.round(RA * 100) / 100); |
935 row['f_name'] = datarecord.name; |
907 setWaterAgent('CaCO3', Math.round(RA * 100) / 100); |
936 row['f_origin'] = datarecord.origin; |
908 if (liters > 0) { |
937 row['f_supplier'] = datarecord.supplier; |
909 //Bicarbonate |
938 row['f_amount'] = 0; |
910 RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) / 3 * MMHCO3 / MMCaCO3; |
939 row['[_cost'] = datarecord.cost; |
911 RA = 1000 * RA / liters; |
940 row['f_type'] = datarecord.type; |
912 bicarbonate = wg_bicarbonate + RA; |
941 row['f_yield'] = datarecord.yield; |
913 total_alkalinity = bicarbonate * 50 / 61; |
942 row['f_color'] = datarecord.color; |
914 //Ca precipitates out as Ca10(PO4)6(OH)2 |
943 row['f_coarse_fine_diff'] = datarecord.coarse_fine_diff; |
915 RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 + |
944 row['f_moisture'] = datarecord.moisture; |
916 parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4 + |
945 row['f_diastatic_power'] = datarecord.diastatic_power; |
917 parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMCa / MMCaCO3; |
946 row['f_protein'] = datarecord.protein; |
918 RA = 1000 * RA / liters; |
947 row['f_max_in_batch'] = datarecord.max_in_batch; |
919 calcium = wg_calcium + RA; |
948 row['f_graintype'] = datarecord.graintype; |
920 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); |
949 if (datarecord.add_after_boil) { |
921 } |
950 row['f_added'] = 2; // Fermentation |
922 break; |
951 } else if ((datarecord.type == 1) || (datarecord.type == 4)) { // Sugar or Adjunct |
923 case 3: RA = -protonDeficit / 19.3; // Calciumhydroxide |
952 row['f_added'] = 1; // Boil |
924 $("#wa_base").val(Math.round(RA * 100) / 100); |
953 } else { |
925 setWaterAgent('Ca(OH)2', Math.round(RA * 100) / 100); |
954 row['f_added'] = 0; // Mash |
926 if (liters > 0) { |
955 } |
927 // Bicarbonate |
956 row['f_dissolved_protein'] = datarecord.dissolved_protein; |
928 RA = -protonDeficit / liters; |
957 row['f_recommend_mash'] = datarecord.recommend_mash; |
929 total_alkalinity = wg_total_alkalinity + RA; |
958 row['f_add_after_boil'] = datarecord.add_after_boil; |
930 bicarbonate = total_alkalinity * 61 / 50; |
959 if (rowscount == 0) { |
931 // Calcium |
960 // The first fermentable |
932 RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 + |
961 row['f_adjust_to_total_100'] = 1; |
933 parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4 + |
962 row['f_percentage'] = 100; |
934 parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMCa / MMCaOH2; |
963 } else { |
935 RA = 1000 * RA / liters; |
964 row['f_adjust_to_total_100'] = 0; |
936 calcium = wg_calcium + RA; |
965 row['f_percentage'] = 0; |
937 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); |
966 } |
938 } |
967 row['f_di_ph'] = datarecord.di_ph; |
939 break; |
968 row['f_acid_to_ph_57'] = datarecord.acid_to_ph_57; |
940 } |
969 row['f_inventory'] = datarecord.inventory; |
941 } |
970 $('#fermentableGrid').jqxGrid('addrow', null, row); |
942 ph = TpH; |
971 } |
943 $('#wb_ph').val(Math.round(ph * 10) / 10); |
972 }); |
944 } else { // Manual |
973 $('#finstockbutton').jqxCheckBox({ theme: theme, height: 27 }); |
945 console.log("calc_acid no"); |
974 $('#finstockbutton').on('change', function(event) { |
946 // First add base salts |
975 fermentableinstock = event.args.checked; |
947 if (parseFloat($("#wa_base").jqxNumberInput('decimal')) > 0) { |
976 fermentablelist.dataBind(); |
948 if (liters > 0) { |
977 }); |
949 switch (BT) { |
978 |
950 case 0: // Sodiumbicarbonate, Na |
979 // delete selected fermentable. |
951 RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl + |
980 $('#fdeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150 }); |
952 parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMNa / MMNaHCO3; |
981 $('#fdeleterowbutton').on('click', function() { |
953 RA = 1000 * RA / liters; |
982 var id, percent, amount, i, rowdata, rowscount, selectedrowindex = $('#fermentableGrid').jqxGrid('getselectedrowindex'); |
954 sodium = wg_sodium + RA; |
983 rowscount = $('#fermentableGrid').jqxGrid('getdatainformation').rowscount; |
955 // HCO3 |
984 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
956 RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNaHCO3; |
985 id = $('#fermentableGrid').jqxGrid('getrowid', selectedrowindex); |
957 RA = 1000 * RA / liters; |
986 percent = $('#fermentableGrid').jqxGrid('getcellvalue', id, 'f_percentage'); |
958 bicarbonate = wg_bicarbonate + RA; |
987 amount = $('#fermentableGrid').jqxGrid('getcellvalue', id, 'f_amount'); |
959 total_alkalinity = bicarbonate * 50 / 61; |
988 $('#fermentableGrid').jqxGrid('deleterow', id); |
960 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); |
989 } |
961 break; |
990 rowscount = $('#fermentableGrid').jqxGrid('getdatainformation').rowscount; |
962 case 1: // Sodiumcarbonate |
991 if (rowscount > 1) { |
963 RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl + |
992 if (to_100) { |
964 parseFloat($("#wa_base").jqxNumberInput('decimal')) * 2 * MMNa / MMNa2CO3; |
993 for (i = 0; i < rowscount; i++) { |
965 RA = 1000 * RA / liters; |
994 rowdata = $('#fermentableGrid').jqxGrid('getrowdata', i); |
966 sodium = wg_sodium + RA; |
995 if (rowdata.f_adjust_to_total_100) { |
967 // HCO3 |
996 rowdata.f_percentage += percent; |
968 RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNa2CO3; |
997 rowdata.f_amount += amount; |
969 RA = 1000 * RA / liters; |
998 } |
970 bicarbonate = wg_bicarbonate + RA; |
999 } |
971 total_alkalinity = bicarbonate * 50 / 61; |
1000 } else { |
972 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); |
1001 calcPercentages(); |
973 break; |
1002 } |
974 case 2: // Calciumcarbonate: Bicarbonate |
1003 } else { |
975 RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) / 3 * MMHCO3 / MMCaCO3; |
1004 $('#fermentableGrid').jqxGrid('setcellvalue', 0, 'f_percentage', 100); |
976 RA = 1000 * RA / liters; |
1005 } |
977 bicarbonate = wg_bicarbonate + RA; |
1006 calcFermentables(); |
978 total_alkalinity = bicarbonate * 50 / 61; |
1007 calcIBUs(); |
979 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); |
1008 }); |
980 // Ca |
1009 }, |
981 RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 + |
1010 ready: function() { |
982 parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4 + |
1011 calcFermentables(); |
983 parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMCa / MMCaCO3; |
1012 $('#jqxTabs').jqxTabs('next'); |
984 RA = 1000 * RA / liters; |
1013 }, |
985 calcium = wg_calcium + RA; |
1014 columns: [ |
986 break; |
1015 { text: 'Vergistbaar ingrediënt', datafield: 'f_name', |
987 } |
1016 cellsrenderer: function(index, datafield, value, defaulvalue, column, rowdata) { |
988 } |
1017 return '<span style="margin: 3px; margin-top: 6px; float: left;">' + |
989 } |
1018 rowdata.f_supplier + ' / ' + rowdata.f_name + ' (' + rowdata.f_color + ' EBC)</span>'; |
990 |
1019 } |
991 TpH = parseFloat(dataRecord.mash_ph); |
1020 }, |
992 pHa = MashpH(); // This one is in demi water, should be in adjusted water??? |
1021 { text: 'Type', width: 100, datafield: 'f_type', |
993 // Then calculate the new pH with added acids |
1022 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
994 if (parseFloat($("#wa_acid").jqxNumberInput('decimal')) > 0) { |
1023 return '<span style="margin: 3px; margin-top: 6px; float: left;">' + FermentableTypeData[value].nl + '</span>'; |
995 console.log("TpH: "+TpH+" water: "+pHa); |
1024 } |
996 Acid = parseFloat($("#wa_acid").jqxNumberInput('decimal')); |
1025 }, |
997 if (parseFloat($("#wa_acid_perc").jqxNumberInput('decimal')) == 0) |
1026 { text: 'Moment', width: 110, datafield: 'f_added', |
998 $("#wa_acid_perc").val(AcidPrc); |
1027 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
999 Acid = Acid / AcidPrc * (parseFloat($("#wa_acid_perc").jqxNumberInput('decimal')) / 100); // ml |
1028 return '<span style="margin: 3px; margin-top: 6px; float: left;">' + AddedData[value].nl + '</span>'; |
1000 Acid *= AcidSG; // ml |
1029 } |
1001 Acid /= MolWt; // mg |
1030 }, |
1002 Acidmg = Acid; |
1031 { text: 'Maxinbatch', datafield: 'f_max_in_batch', hidden: true }, |
1003 |
1032 { text: 'Opbrengst', editable: false, datafield: 'f_yield', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
1004 //find the pH where the protondeficit = protondeficit by the acid |
1033 { text: 'Gewicht Kg', datafield: 'f_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, |
1005 frac = CalcFrac(pHa, pK1, pK2, pK3); |
1034 { text: 'Voorr. Kg', datafield: 'f_inventory', width: 120, align: 'right', |
1006 protonDeficit = Acid * frac; |
1035 cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties, rowdata) { |
1007 |
1036 var color = '#ffffff'; |
1008 var deltapH = 0.001; |
1037 if (value < rowdata.f_amount) |
1009 var deltapd = 0.1; |
1038 color = '#ff4040'; |
1010 var pd = ProtonDeficit(pHa); |
1039 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + |
1011 var n = 0; |
1040 color + ';">' + fermentableAdapter.formatNumber(value, 'f3') + '</span>'; |
1012 while (((pd < (protonDeficit - deltapd)) || (pd > (protonDeficit + deltapd))) && (n < 2000)) { |
1041 } |
1013 n++; |
1042 }, |
1014 if (pd < (protonDeficit-deltapd)) |
1043 { text: 'Procent', datafield: 'f_percentage', width: 90, align: 'right', |
1015 pHa -= deltapH; |
1044 cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties, rowdata) { |
1016 else if (pd > (protonDeficit+deltapd)) |
1045 var color = '#ffffff'; |
1017 pHa += deltapH; |
1046 if (value > rowdata.f_max_in_batch) |
1018 frac = CalcFrac(pHa, pK1, pK2, pK3); |
1047 color = '#ff4040'; |
1019 protonDeficit = Acid * frac; |
1048 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + |
1020 pd = ProtonDeficit(pHa); |
1049 color + ';">' + fermentableAdapter.formatNumber(value, 'p1') + '</span>'; |
1021 } |
1050 } |
1022 console.log("n: "+n+" pd: "+pd+" protonDeficit: "+protonDeficit+" frac: "+frac+" pHa: "+pHa); |
1051 }, |
1023 RA = wg_bicarbonate - protonDeficit * frac / liters; |
1052 { text: '100%', align: 'center', datafield: 'f_adjust_to_total_100', columntype: 'checkbox', width: 70 }, |
1024 bicarbonate = RA; |
1053 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function() { |
1025 total_alkalinity = RA * 50 / 61; |
1054 return 'Wijzig'; |
1026 ph = pHa; |
1055 }, buttonclick: function(row) { |
1027 $('#wb_ph').val(Math.round(ph * 10) / 10); |
1056 fermentableRow = row; |
1028 } |
1057 fermentableData = $('#fermentableGrid').jqxGrid('getrowdata', fermentableRow); |
1029 } |
1058 $('#wf_name').val(fermentableData.f_name); |
1030 |
1059 $('#wf_amount').val(fermentableData.f_amount); |
1031 if ((AT == 3) && (liters > 0)) { // Sulfuctic / Zwavelzuur |
1060 $('#wf_percentage').val(fermentableData.f_percentage); |
1032 RA = parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMSO4 / MMCaSO4 + |
1061 $('#wf_max_in_batch').val(fermentableData.f_max_in_batch); |
1033 parseFloat($("#wa_mgso4").jqxNumberInput('decimal')) * MMSO4 / MMMgSO4 + |
1062 $('#wf_adjust_to_total_100').val(fermentableData.f_adjust_to_total_100); |
1034 Acidmg / 1000 * MMSO4 / (MMSO4 + 2); |
1063 $('#wf_added').val(fermentableData.f_added); |
1035 RA = 1000 * RA / liters; |
1064 // show the popup window. |
1036 sulfate = wg_sulfate + RA; // Not add to sulfate?? |
1065 $('#popupFermentable').jqxWindow('open'); |
1037 } else if ((AT == 1) && (liters > 0)) { // Hydrochloric, Zoutzuur |
1066 } |
1038 RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCl / MMCaCl2 + |
1067 } |
1039 parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMCl / MMNaCl + |
1068 ] |
1040 Acidmg / 1000 * MMCl / (MMCl + 1); |
1069 }); |
1041 RA = 1000 * RA / liters; |
1070 }; |
1042 chloride = wg_chloride + RA; |
1071 |
1043 } |
1072 // Inline hops editor |
1044 |
1073 var editHop = function(data) { |
1045 // 2:1 Sulfate to Chroride IPA's, Pale Ales. |
1074 var hopSource = { |
1046 // 1:1 Sulfate to Chloride Balanced |
1075 localdata: data.hops, |
1047 // 1:2 Sulfate to Chloride Malty |
1076 datatype: 'local', |
1048 // Note, values below are the other way, cl to so4! |
1077 cache: false, |
1049 // So: 0.5 is IPA's, Pale Ales. |
1078 async: false, |
1050 // 1 Balanced |
1079 datafields: [ |
1051 // 2 Malty. |
1080 { name: 'h_name', type: 'string' }, |
1052 $('#tgt_bu').val(Math.round(GetBUGU() * 100) / 100); |
1081 { name: 'h_origin', type: 'string' }, |
1053 // From brouwhulp. |
1082 { name: 'h_amount', type: 'float' }, |
1054 if (GetBUGU() < 0.32) |
1083 { name: 'h_cost', type: 'float' }, |
1055 $('#wr_bu').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Zeer moutig en zoet</span>"); |
1084 { name: 'h_type', type: 'int' }, |
1056 else if (GetBUGU() < 0.43) |
1085 { name: 'h_form', type: 'int' }, |
1057 $('#wr_bu').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Moutig, zoet</span>"); |
1086 { name: 'h_useat', type: 'int' }, |
1058 else if (GetBUGU() < 0.52) |
1087 { name: 'h_time', type: 'float' }, |
1059 $('#wr_bu').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Evenwichtig</span>"); |
1088 { name: 'h_alpha', type: 'float' }, |
1060 else if (GetBUGU() < 0.63) |
1089 { name: 'h_beta', type: 'float' }, |
1061 $('#wr_bu').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Licht hoppig, bitter</span>"); |
1090 { name: 'h_hsi', type: 'float' }, |
1062 else |
1091 { name: 'h_humulene', type: 'float' }, |
1063 $('#wr_bu').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Extra hoppig, zeer bitter</span>"); |
1092 { name: 'h_caryophyllene', type: 'float' }, |
1064 $('#tgt_cl_so4').val(Math.round(GetOptClSO4ratio() * 10) / 10); |
1093 { name: 'h_cohumulone', type: 'float' }, |
1065 if (sulfate > 0) |
1094 { name: 'h_myrcene', type: 'float' }, |
1066 RA = chloride / sulfate; |
1095 { name: 'h_total_oil', type: 'float' }, |
1067 else |
1096 { name: 'h_inventory', type: 'float' }, |
1068 RA = 10; |
1097 { name: 'h_avail', type: 'int' } |
1069 $('#got_cl_so4').val(Math.round(RA * 10) / 10); |
1098 ], |
1070 var piCLSO4_low = 0.8 * GetOptClSO4ratio(); |
1099 addrow: function(rowid, rowdata, position, commit) { |
1071 var piCLSO4_high = 1.2 * GetOptClSO4ratio(); |
1100 //console.log("hop addrow "+rowid); |
1072 var Res = 'normaal'; |
1101 commit(true); |
1073 if (RA < piCLSO4_low) |
1102 }, |
1074 Res = 'laag'; |
1103 deleterow: function(rowid, commit) { |
1075 else if (RA > piCLSO4_high) |
1104 //console.log("hop deleterow "+rowid); |
1076 Res = 'hoog'; |
1105 commit(true); |
1077 setRangeIndicator('cl_so4', Res); |
1106 }, |
1078 |
1107 updaterow: function(rowid, rowdata, commit) { |
1079 $('#wb_calcium').val(Math.round(calcium * 10) / 10); |
1108 //console.log("hop updaterow "+rowid); |
1080 $('#wb_magnesium').val(Math.round(magnesium * 10) / 10); |
1109 commit(true); |
1081 $('#wb_sodium').val(Math.round(sodium * 10) / 10); |
1110 } |
1082 $('#wb_sulfate').val(Math.round(sulfate * 10) / 10); |
1111 }, |
1083 $('#wb_chloride').val(Math.round(chloride * 10) / 10); |
1112 hopAdapter = new $.jqx.dataAdapter(hopSource); |
1084 $('#wb_total_alkalinity').val(Math.round(total_alkalinity * 10) / 10); |
1113 |
1085 |
1114 $('#hopGrid').jqxGrid({ |
1086 if (calcium < 40) { |
1115 width: 1240, |
1087 setRangeIndicator("calcium", "laag"); |
1116 height: 560, |
1088 } else if (calcium > 150) { |
1117 source: hopAdapter, |
1089 setRangeIndicator("calcium", "hoog"); |
1118 theme: theme, |
1090 } else { |
1119 selectionmode: 'singlerow', |
1091 setRangeIndicator("calcium", "normaal"); |
1120 showtoolbar: true, |
1092 } |
1121 rendertoolbar: function(toolbar) { |
1093 if (magnesium >= 0 && magnesium <= 30) { |
1122 //var me = this; |
1094 setRangeIndicator("magnesium", "normaal"); |
1123 var container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>'); |
1095 } else { |
1124 toolbar.append(container); |
1096 setRangeIndicator("magnesium", "hoog"); |
1125 container.append('<div style="float: left; margin-left: 165px;" id="haddrowbutton"></div>'); |
1097 } |
1126 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>'); |
1098 if (sodium <= 150) { |
1127 container.append('<div style="float: left; margin-left: 10px;" id="hinstockbutton"></div>'); |
1099 setRangeIndicator("sodium", "normaal"); |
1128 container.append('<input style="float: left; margin-left: 400px;" id="hdeleterowbutton" type="button" value="Verwijder hop" />'); |
1100 } else { |
1129 // add hop from dropdownlist. |
1101 setRangeIndicator("sodium", "hoog"); |
1130 $('#haddrowbutton').jqxDropDownList({ |
1102 } |
1131 placeHolder: 'Kies hop:', |
1103 // Both chloride and sulfate should be above 50 according to |
1132 theme: theme, |
1104 // John Palmer. So the Cl/SO4 ratio calculation will work. |
1133 template: 'primary', |
1105 if (chloride <= 50) { |
1134 source: hoplist, |
1106 setRangeIndicator("chloride", "laag"); |
1135 displayMember: 'name', |
1107 } else if (chloride <= 100) { |
1136 width: 150, |
1108 setRangeIndicator("chloride", "normaal"); |
1137 height: 27, |
1109 } else { |
1138 dropDownWidth: 500, |
1110 setRangeIndicator("chloride", "hoog"); |
1139 dropDownHeight: 500, |
1111 } |
1140 renderer: function(index, label, value) { |
1112 if (sulfate <= 50) { |
1141 var datarecord = hoplist.records[index]; |
1113 setRangeIndicator("sulfate", "laag"); |
1142 return datarecord.origin + ' / ' + datarecord.name + ' (' + datarecord.alpha + '% α)'; |
1114 } else if (sulfate <= 350) { |
1143 } |
1115 setRangeIndicator("sulfate", "normaal"); |
1144 }); |
1116 } else { |
1145 $('#haddrowbutton').on('select', function(event) { |
1117 setRangeIndicator("sulfate", "hoog"); |
1146 if (event.args) { |
1118 } |
1147 var datarecord, row = {}, index = event.args.index; |
1119 if (ph < 5.2) { |
1148 datarecord = hoplist.records[index]; |
1120 setRangeIndicator("ph", "laag"); |
1149 row['h_name'] = datarecord.name; |
1121 } else if (ph > 5.6) { |
1150 row['h_origin'] = datarecord.origin; |
1122 setRangeIndicator("ph", "hoog"); |
1151 row['h_amount'] = 0; |
1123 } else { |
1152 row['h_cost'] = datarecord.cost; |
1124 setRangeIndicator("ph", "normaal"); |
1153 row['h_type'] = datarecord.type; |
1125 } |
1154 row['h_form'] = datarecord.form; |
1126 calcSparge(); |
1155 row['h_useat'] = 2; // Boil |
1127 } |
1156 row['h_time'] = 0; |
1128 |
1157 row['h_alpha'] = datarecord.alpha; |
1129 function calcSparge() { |
1158 row['h_beta'] = datarecord.beta; |
1130 |
1159 row['h_hsi'] = datarecord.hsi; |
1131 // Code from BrewBuddy/Brouwhulp, who got it from http://www.brewery.org/brewery/library/Acidi0,00fWaterAJD0497.html |
1160 row['h_humulene'] = datarecord.humulene; |
1132 var TargetpH = dataRecord.sparge_ph; |
1161 row['h_caryophyllene'] = datarecord.caryophyllene; |
1133 var Source_pH = dataRecord.w1_ph; |
1162 row['h_cohumulone'] = datarecord.cohumulone; |
1134 var Source_alkalinity = dataRecord.w1_total_alkalinity; |
1163 row['h_myrcene'] = datarecord.myrcene; |
1135 // Select watersource or fallback to the first source. |
1164 row['h_total_oil'] = datarecord.total_oil; |
1136 if (dataRecord.sparge_source == 1) { // Source 2 |
1165 row['h_inventory'] = datarecord.inventory; |
1137 if (dataRecord.w2_ph > 0.0) { |
1166 $('#hopGrid').jqxGrid('addrow', null, row); |
1138 Source_pH = dataRecord.w2_ph; |
1167 } |
1139 Source_alkalinity = dataRecord.w2_total_alkalinity; |
1168 $('#haddrowbutton').jqxDropDownList('clearSelection'); |
1140 } else { |
1169 }); |
1141 dataRecord.sparge_source = 0; // Source 1 |
1170 |
1142 $("#sparge_source").val(0); |
1171 $('#hinstockbutton').jqxCheckBox({ theme: theme, height: 27 }); |
1143 } |
1172 $('#hinstockbutton').on('change', function(event) { |
1144 } else if (dataRecord.sparge_source == 2) { // Mixed |
1173 hopinstock = event.args.checked; |
1145 if (dataRecord.w2_ph > 0.0) { |
1174 hoplist.dataBind(); |
1146 Source_pH = parseFloat($("#wg_ph").jqxNumberInput('decimal')); |
1175 }); |
1147 Source_alkalinity = parseFloat($("#wg_total_alkalinity").jqxNumberInput('decimal')); |
1176 |
1148 } else { |
1177 // delete selected hop. |
1149 dataRecord.sparge_source = 0; |
1178 $('#hdeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150 }); |
1150 $("#sparge_source").val(0); |
1179 $('#hdeleterowbutton').on('click', function() { |
1151 } |
1180 var rowscount, id, selectedrowindex = $('#hopGrid').jqxGrid('getselectedrowindex'); |
1152 } |
1181 rowscount = $('#hopGrid').jqxGrid('getdatainformation').rowscount; |
1153 |
1182 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
1154 //console.log("calcSparge() target pH: "+TargetpH+" Source: "+Source_pH+" alkalinity: "+Source_alkalinity); |
1183 id = $('#hopGrid').jqxGrid('getrowid', selectedrowindex); |
1155 |
1184 $('#hopGrid').jqxGrid('deleterow', id); |
1156 // Step 1: Compute the mole fractions of carbonic (f1o), bicarbonate (f2o) and carbonate(f3o) at the water pH |
1185 } |
1157 var r1 = Math.pow(10, Source_pH - 6.38); |
1186 calcIBUs(); |
1158 var r2 = Math.pow(10, Source_pH - 10.373); |
1187 }); |
1159 var d = 1 + r1 + r1*r2; |
1188 }, |
1160 var f1 = 1/d; |
1189 ready: function() { |
1161 var f2 = r1/d; |
1190 calcIBUs(); |
1162 var f3 = r1 * r2 / d; |
1191 $('#jqxTabs').jqxTabs('next'); |
1163 |
1192 }, |
1164 //Step 2. Compute the mole fractions at pH = 4.3 (the pH which defines alkalinity) |
1193 columns: [ |
1165 var r143 = Math.pow(10, 4.3 - 6.38); |
1194 { text: 'Hop', datafield: 'h_name', |
1166 var r243 = Math.pow(10, 4.3 - 10.373); |
1195 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1167 var d43 = 1 + r143 + r143*r243; |
1196 return '<span style="margin: 3px; margin-top: 6px; float: left;">' + rowdata.h_origin + ' / ' + rowdata.h_name + '</span>'; |
1168 var f143 = 1/d43; |
1197 } |
1169 var f243 = r143 / d43; |
1198 }, |
1170 var f343 = r143 * r243 / d43; |
1199 { text: 'Type', width: 90, datafield: 'h_type', |
1171 |
1200 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1172 //Step 3. Convert the sample alkalinity to milliequivalents/L |
1201 return '<span style="margin: 4px; margin-top: 6px; float: left;">' + HopTypeData[value].nl + '</span>'; |
1173 var alkalinity = Source_alkalinity / 50; |
1202 } |
1174 //Step 4. Solve |
1203 }, |
1175 var Ct = (alkalinity - 1000 * (Math.pow(10, -4.3) - Math.pow(10, -Source_pH))) / ((f143-f1)+(f3-f343)); |
1204 { text: 'Vorm', width: 90, datafield: 'h_form', |
1176 |
1205 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1177 //Step 5. Compute mole fractions at desired pH |
1206 return '<span style="margin: 4px; margin-top: 6px; float: left;">' + HopFormData[value].nl + '</span>'; |
1178 var r1g = Math.pow(10, TargetpH - 6.38); |
1207 } |
1179 var r2g = Math.pow(10, TargetpH - 10.373); |
1208 }, |
1180 var dg = 1 + r1g + r1g*r2g; |
1209 { text: 'Alpha', datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
1181 var f1g = 1/dg; |
1210 { text: 'Gebruik', width: 110, datafield: 'h_useat', |
1182 var f2g = r1g / dg; |
1211 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1183 var f3g = r1g * r2g / dg; |
1212 return '<span style="margin: 4px; margin-top: 6px; float: left;">' + HopUseData[value].nl + '</span>'; |
1184 |
1213 } |
1185 //Step 6. Use these to compute the milliequivalents acid required per liter (mEq/L) |
1214 }, |
1186 var Acid = Ct * ((f1g-f1)+(f3-f3g)) + Math.pow(10, -TargetpH) - Math.pow(10, -Source_pH); //mEq/l |
1215 { text: 'Tijdsduur', datafield: 'h_time', width: 90, align: 'right', |
1187 Acid += 0.01; // Add acid that would be required for distilled water. |
1216 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1188 if (dataRecord.sparge_acid_type < 0 || dataRecord.sparge_acid_type > 3) { |
1217 var duration = ''; |
1189 dataRecord.sparge_acid_type = 0; |
1218 if ((rowdata.h_useat == 2) || (rowdata.h_useat == 4)) // Boil, Whirlpool |
1190 $("#sparge_acid_type").val(0); |
1219 duration = dataAdapter.formatNumber(value, 'f0') + ' min.'; |
1191 } |
1220 else if (rowdata.h_useat == 5) // Dry hop |
1192 |
1221 duration = dataAdapter.formatNumber(value / 1440, 'f0') + ' dagen'; |
1193 //Step 8. Get the acid data. |
1222 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + duration + '</span>'; |
1194 var AT = dataRecord.sparge_acid_type; |
1223 } |
1195 var result = GetAcidSpecs(AT); |
1224 }, |
1196 var pK1 = result.pK1; |
1225 { text: 'IBU', datafield: 'ibu', width: 80, align: 'right', |
1197 var pK2 = result.pK2; |
1226 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1198 var pK3 = result.pK3; |
1227 var ibu = toIBU(rowdata.h_useat, rowdata.h_form, preboil_sg, parseFloat($('#batch_size').jqxNumberInput('decimal')), |
1199 var MolWt = result.MolWt; |
1228 parseFloat(rowdata.h_amount), parseFloat(rowdata.h_time), |
1200 var AcidSG = result.AcidSG; |
1229 parseFloat(rowdata.h_alpha), $('#ibu_method').val()); |
1201 var AcidPrc = result.AcidPrc; |
1230 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + dataAdapter.formatNumber(ibu, 'f1') + '</span>'; |
1202 var fract = CalcFrac(TargetpH, pK1, pK2, pK3); |
1231 } |
1203 |
1232 }, |
1204 //Step 9. Now divide the mEq required by the "fraction". This is the required number of moles of acid. |
1233 { text: 'Gewicht', datafield: 'h_amount', width: 110, align: 'right', |
1205 Acid /= fract; |
1234 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1206 |
1235 var amount = dataAdapter.formatNumber(value, 'f1') + ' kg'; |
1207 //Step 10. Multiply by molecular weight of the acid |
1236 if (value < 1) |
1208 Acid *= MolWt; //mg |
1237 amount = dataAdapter.formatNumber(value * 1000, 'f1') + ' gr'; |
1209 |
1238 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + amount + '</span>'; |
1210 Acid = Acid / AcidSG; //ml ; 88% lactic solution |
1239 } |
1211 var f1 = dataRecord.sparge_acid_perc; |
1240 }, |
1212 if (f1 <= 0.1) |
1241 { text: 'Voorraad', datafield: 'h_inventory', width: 110, align: 'right', |
1213 f1 = AcidPrc; |
1242 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1214 Acid = Acid * AcidPrc / (f1 / 100); |
1243 var amount, color = '#ffffff'; |
1215 |
1244 if (value < rowdata.h_amount) |
1216 Acid *= dataRecord.sparge_volume; //ml lactic acid total |
1245 color = '#ff4040'; |
1217 Acid = Math.round(Acid * 100) / 100; |
1246 amount = dataAdapter.formatNumber(value, 'f1') + ' kg'; |
1218 dataRecord.sparge_acid_amount = Acid / 1000; |
1247 if (value < 1) |
1219 $("#sparge_acid_amount").val(Acid); |
1248 amount = dataAdapter.formatNumber(value * 1000, 'f1') + ' gr'; |
1220 } |
1249 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + amount + '</span>'; |
1221 |
1250 } |
1222 /* |
1251 }, |
1223 * Change OG of recipe but keep the water volumes. |
1252 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', |
1224 */ |
1253 cellsrenderer: function() { |
1225 function calcFermentablesFromOG(OG) { |
1254 return 'Wijzig'; |
1226 |
1255 }, buttonclick: function(row) { |
1227 console.log("calcFermentablesFromOG("+OG+")"); |
1256 hopRow = row; |
1228 var efficiency = parseFloat($("#efficiency").jqxNumberInput('decimal')); |
1257 hopData = $('#hopGrid').jqxGrid('getrowdata', hopRow); |
1229 var sug = sg_to_plato(OG) * parseFloat($("#batch_size").jqxNumberInput('decimal')) * OG / 100; //total amount of sugars in kg |
1258 $('#wh_name').val(hopData.h_name); |
1230 var tot = 0; |
1259 $('#wh_amount').val(hopData.h_amount * 1000); |
1231 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; |
1260 var ibu = toIBU(hopData.h_useat, hopData.h_form, preboil_sg, |
1232 |
1261 parseFloat($('#batch_size').jqxNumberInput('decimal')), |
1233 for (var i = 0; i < rowscount; i++) { |
1262 parseFloat(hopData.h_amount), parseFloat(hopData.h_time), |
1234 var row = $("#fermentableGrid").jqxGrid('getrowdata', i); |
1263 parseFloat(hopData.h_alpha), $('#ibu_method').val() |
1235 if (row.f_added < 4) { |
1264 ); |
1236 var d = row.f_percentage / 100 * (row.f_yield / 100) * (1 - row.f_moisture / 100); |
1265 $('#wh_ibu').val(ibu); |
1237 if (row.f_added == 0) // Mash |
1266 if (hopData.h_useat == 5) // Dry hop |
1238 d = efficiency / 100 * d; |
1267 $('#wh_time').val(hopData.h_time / 1440); |
1239 tot += d; |
1268 else |
1240 } |
1269 $('#wh_time').val(hopData.h_time); |
1241 } |
1270 $('#wh_useat').val(hopData.h_useat); |
1242 var totmass = 0; |
1271 // show the popup window. |
1243 if (tot) |
1272 $('#popupHop').jqxWindow('open'); |
1244 totmass = Math.round((sug / tot) * 1000) / 1000; |
1273 } |
1245 |
1274 } |
1246 if (totmass) { |
1275 ] |
1247 for (i = 0; i < rowscount; i++) { |
1276 }); |
1248 var row = $("#fermentableGrid").jqxGrid('getrowdata', i); |
1277 }; |
1249 if (row.f_added < 4) { |
1278 |
1250 var amount = Math.round(row.f_percentage * 10 * totmass) / 1000; |
1279 // Inline miscs editor |
1251 $("#fermentableGrid").jqxGrid('setcellvalue', i, "f_amount", amount); |
1280 var editMisc = function(data) { |
1252 } |
1281 var miscSource = { |
1253 } |
1282 localdata: data.miscs, |
1254 } |
1283 datatype: 'local', |
1255 }; |
1284 cache: false, |
1256 |
1285 async: false, |
1257 function calcInit () { |
1286 datafields: [ |
1258 console.log("calc.init()"); |
1287 { name: 'm_name', type: 'string' }, |
1259 |
1288 { name: 'm_amount', type: 'float' }, |
1260 $("#calc_acid").on('checked', function (event) { |
1289 { name: 'm_cost', type: 'float' }, |
1261 dataRecord.calc_acid = 1; |
1290 { name: 'm_type', type: 'int' }, |
1262 calcWater(); |
1291 { name: 'm_use_use', type: 'int' }, |
1263 }); |
1292 { name: 'm_time', type: 'float' }, |
1264 $("#calc_acid").on('unchecked', function (event) { |
1293 { name: 'm_amount_is_weight', type: 'int' }, |
1265 dataRecord.calc_acid = 0; |
1294 { name: 'm_inventory', type: 'float' }, |
1266 calcWater(); |
1295 { name: 'm_avail', type: 'int' } |
1267 }); |
1296 ], |
1268 $("#w1_name").jqxDropDownList('selectItem', dataRecord.w1_name); |
1297 addrow: function(rowid, rowdata, position, commit) { |
1269 $("#w2_name").jqxDropDownList('selectItem', dataRecord.w2_name); |
1298 //console.log("misc addrow "+rowid); |
1270 // Fix tap water if zero using mash infuse amount. |
1299 commit(true); |
1271 if (parseFloat($("#w1_amount").jqxNumberInput('decimal')) == 0 && mash_infuse > 0) { |
1300 }, |
1272 $("#w1_amount").val(mash_infuse); |
1301 deleterow: function(rowid, commit) { |
1273 dataRecord.w1_amount = mash_infuse; |
1302 //console.log("misc deleterow "+rowid); |
1274 $("#wg_amount").val(mash_infuse); |
1303 commit(true); |
1275 $("#w2_amount").val(0); |
1304 }, |
1276 dataRecord.w2_amount = 0; |
1305 updaterow: function(rowid, rowdata, commit) { |
1277 } |
1306 //console.log("misc updaterow "+rowid); |
1278 calcWater(); |
1307 commit(true); |
1279 $("#w2_amount").on('change', function (event) { |
1308 } |
1280 var newval = parseFloat(event.args.value); |
1309 }, |
1281 |
1310 miscAdapter = new $.jqx.dataAdapter(miscSource, { |
1282 if (newval > mash_infuse) { |
1311 beforeLoadComplete: function(records) { |
1283 $("#w2_amount").val(dataRecord.w2_amount); |
1312 var i, row, data = new Array(); |
1284 return; |
1313 for (i = 0; i < records.length; i++) { |
1285 } |
1314 row = records[i]; |
1286 dataRecord.w1_amount = parseFloat($("#wg_amount").jqxNumberInput('decimal')) - newval; |
1315 data.push(row); |
1287 $("#w1_amount").val(dataRecord.w1_amount); |
1316 // Initial set water agent values. |
1288 dataRecord.w2_amount = newval; |
1317 switch (row.m_name) { |
1289 console.log("new: "+event.args.value+" w1: "+dataRecord.w1_amount+" w2: "+dataRecord.w2_amount); |
1318 case 'CaCl2': |
1290 calcWater(); |
1319 $('#wa_cacl2').val(row.m_amount * 1000); |
1291 }); |
1320 break; |
1292 $('#wa_cacl2').on('change', function (event) { |
1321 case 'CaSO4': |
1293 if (event.args) { |
1322 $('#wa_caso4').val(row.m_amount * 1000); |
1294 setWaterAgent('CaCl2', 0); // This can prevent double entries. |
1323 break; |
1295 setWaterAgent('CaCl2', event.args.value); |
1324 case 'MgSO4': |
1296 calcWater(); |
1325 $('#wa_mgso4').val(row.m_amount * 1000); |
1297 } |
1326 break; |
1298 }); |
1327 case 'NaCl': |
1299 $('#wa_caso4').on('change', function (event) { |
1328 $('#wa_nacl').val(row.m_amount * 1000); |
1300 if (event.args) { |
1329 break; |
1301 setWaterAgent('CaSO4', 0); |
1330 case 'Melkzuur': |
1302 setWaterAgent('CaSO4', event.args.value); |
1331 $('#wa_acid_name').val(0); |
1303 calcWater(); |
1332 $('#wa_acid').val(row.m_amount * 1000); |
1304 } |
1333 $('#wa_acid_perc').val(80); |
1305 }); |
1334 last_acid = 'Melkzuur'; |
1306 $('#wa_mgso4').on('change', function (event) { |
1335 break; |
1307 if (event.args) { |
1336 case 'Zoutzuur': |
1308 setWaterAgent('MgSO4', 0); |
1337 $('#wa_acid_name').val(1); |
1309 setWaterAgent('MgSO4', event.args.value); |
1338 $('#wa_acid').val(row.m_amount * 1000); |
1310 calcWater(); |
1339 $('#wa_acid_perc').val(80); |
1311 } |
1340 last_acid = 'Zoutzuur'; |
1312 }); |
1341 break; |
1313 $('#wa_nacl').on('change', function (event) { |
1342 case 'Fosforzuur': |
1314 if (event.args) { |
1343 $('#wa_acid_name').val(2); |
1315 setWaterAgent('NaCl', 0); |
1344 $('#wa_acid').val(row.m_amount * 1000); |
1316 setWaterAgent('NaCl', event.args.value); |
1345 $('#wa_acid_perc').val(80); |
1317 calcWater(); |
1346 last_acid = 'Fosforzuur'; |
1318 } |
1347 break; |
1319 }); |
1348 case 'Zwavelzuur': |
1320 $('#wa_base_name').on('change', function (event) { |
1349 $('#wa_acid_name').val(3); |
1321 if (event.args) { |
1350 $('#wa_acid').val(row.m_amount * 1000); |
1322 var index = event.args.index; |
1351 $('#wa_acid_perc').val(80); |
1323 console.log("wa_base_name "+index); |
1352 last_acid = 'Zwavelzuur'; |
1324 setWaterAgent(last_base, 0); |
1353 break; |
1325 last_base = BaseTypeData[index].nl; |
1354 case 'NaHCO3': |
1326 setWaterAgent(last_base, parseFloat($("#wa_base").jqxNumberInput('decimal'))); |
1355 $('#wa_base_name').val(0); |
1327 dataRecord.wa_base_name = index; |
1356 $('#wa_base').val(row.m_amount * 1000); |
1328 calcWater(); |
1357 last_base = 'NaHCO3'; |
1329 } |
1358 break; |
1330 }); |
1359 case 'Na2CO3': |
1331 $('#wa_base').on('change', function (event) { |
1360 $('#wa_base_name').val(1); |
1332 var name = BaseTypeData[$("#wa_base_name").val()].nl; |
1361 $('#wa_base').val(row.m_amount * 1000); |
1333 setWaterAgent(name, parseFloat(event.args.value)); |
1362 last_base = 'Na2CO3'; |
1334 calcWater(); |
1363 break; |
1335 }); |
1364 case 'CaCO3': |
1336 $('#wa_acid_name').on('change', function (event) { |
1365 $('#wa_base_name').val(2); |
1337 if (event.args) { |
1366 $('#wa_base').val(row.m_amount * 1000); |
1338 var index = event.args.index; |
1367 last_base = 'CaCO3'; |
1339 console.log("wa_acid_name "+index); |
1368 break; |
1340 setWaterAgent(last_acid, 0); |
1369 case 'Ca(OH)2': |
1341 last_acid = AcidTypeData[index].nl; |
1370 $('#wa_base_name').val(3); |
1342 setWaterAgent(last_acid, parseFloat($("#wa_acid").jqxNumberInput('decimal'))); |
1371 $('#wa_base').val(row.m_amount * 1000); |
1343 dataRecord.wa_acid_name = index; |
1372 last_base = 'Ca(OH)2'; |
1344 calcWater(); |
1373 break; |
1345 } |
1374 } |
1346 }); |
1375 } |
1347 $('#wa_acid').on('change', function (event) { |
1376 return data; |
1348 var name = AcidTypeData[$("#wa_acid_name").val()].nl; |
1377 }, |
1349 setWaterAgent(name, parseFloat(event.args.value)); |
1378 loadError: function(jqXHR, status, error) {} |
1350 calcWater(); |
1379 }); |
1351 }); |
1380 $('#miscGrid').jqxGrid({ |
1352 $('#wa_acid_perc').on('change', function (event) { calcWater(); }); |
1381 width: 1240, |
1353 |
1382 height: 575, |
1354 $('#color_method').on('change', function (event) { |
1383 source: miscAdapter, |
1355 dataRecord.color_method = event.args.index; |
1384 theme: theme, |
1356 calcFermentables(); |
1385 selectionmode: 'singlerow', |
1357 }); |
1386 showtoolbar: true, |
1358 $('#ibu_method').on('change', function (event) { |
1387 rendertoolbar: function(toolbar) { |
1359 dataRecord.ibu_method = event.args.index; |
1388 //var me = this; |
1360 calcFermentables(); |
1389 var container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>'); |
1361 calcIBUs(); |
1390 toolbar.append(container); |
1362 }); |
1391 container.append('<div style="float: left; margin-left: 165px;" id="maddrowbutton"></div>'); |
1363 $('#batch_size').on('change', function (event) { |
1392 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>'); |
1364 console.log("batch_size change:"+event.args.value+" old:"+dataRecord.batch_size); |
1393 container.append('<div style="float: left; margin-left: 10px;" id="minstockbutton"></div>'); |
1365 var new_boil = parseFloat(event.args.value) + dataRecord.boil_size - dataRecord.batch_size; |
1394 container.append('<input style="float: left; margin-left: 400px;" id="mdeleterowbutton" type="button" value="Verwijder ingrediënt" />'); |
1366 var factor = parseFloat(event.args.value) / dataRecord.batch_size; |
1395 // add misc from dropdownlist. |
1367 dataRecord.boil_size = new_boil; |
1396 $('#maddrowbutton').jqxDropDownList({ |
1368 $("#boil_size").val(Math.round(new_boil * 100) / 100); |
1397 placeHolder: 'Kies ingrediënt:', |
1369 dataRecord.sparge_volume *= factor; |
1398 theme: theme, |
1370 $("#sparge_volume").val(dataRecord.sparge_volume); |
1399 template: 'primary', |
1371 dataRecord.batch_size = parseFloat(event.args.value); |
1400 source: misclist, |
1372 calcFermentablesFromOG(parseFloat($("#est_og").jqxNumberInput('decimal'))); // Keep the OG |
1401 displayMember: 'name', |
1373 adjustWaters(factor); |
1402 width: 150, |
1374 calcFermentables(); |
1403 height: 27, |
1375 adjustHops(factor); |
1404 dropDownWidth: 500, |
1376 adjustMiscs(factor); |
1405 dropDownHeight: 500 |
1377 adjustYeasts(factor); |
1406 }); |
1378 calcIBUs(); |
1407 $('#maddrowbutton').on('select', function(event) { |
1379 calcWater(); |
1408 if (event.args) { |
1380 calcSparge(); |
1409 var datarecord, row = {}, index = event.args.index; |
1381 calcMash(); |
1410 datarecord = misclist.records[index]; |
1382 }); |
1411 row['m_name'] = datarecord.name; |
1383 $('#boil_time').on('change', function (event) { |
1412 row['m_amount'] = 0; |
1384 console.log("boil_time change:"+parseFloat(event.args.value)+" old:"+dataRecord.boil_time); |
1413 row['m_cost'] = datarecord.cost; |
1385 var old_evap = parseFloat(dataRecord.boil_size) - parseFloat(dataRecord.batch_size); |
1414 row['m_type'] = datarecord.type; |
1386 var new_evap = old_evap * (parseFloat(event.args.value) / dataRecord.boil_time); |
1415 row['m_use_use'] = datarecord.use_use; |
1387 var new_boil = parseFloat(dataRecord.batch_size) + new_evap; |
1416 row['m_time'] = 0; |
1388 // console.log("old_evap:"+old_evap+" new_evap:"+new_evap+" new_boil:"+new_boil); |
1417 row['m_amount_is_weight'] = datarecord.amount_is_weight; |
1389 dataRecord.boil_time = parseFloat(event.args.value); |
1418 row['m_inventory'] = datarecord.inventory; |
1390 dataRecord.boil_size = new_boil; |
1419 $('#miscGrid').jqxGrid('addrow', null, row); |
1391 $("#boil_size").val(Math.round(new_boil * 100) / 100); |
1420 } |
1392 calcFermentables(); |
1421 }); |
1393 // TODO: adjust the hops, miscs, yeast, water. |
1422 $('#minstockbutton').jqxCheckBox({ theme: theme, height: 27 }); |
1394 calcIBUs(); |
1423 $('#minstockbutton').on('change', function(event) { |
1395 }); |
1424 miscinstock = event.args.checked; |
1396 $('#efficiency').on('change', function (event) { |
1425 misclist.dataBind(); |
1397 var estog = parseFloat($("#est_og").jqxNumberInput('decimal')); |
1426 }); |
1398 dataRecord.efficiency = parseFloat(event.args.value); |
1427 // delete selected misc. |
1399 console.log("efficiency change:"+dataRecord.efficiency); |
1428 $('#mdeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150 }); |
1400 calcFermentablesFromOG(estog); // Keep the OG |
1429 $('#mdeleterowbutton').on('click', function() { |
1401 calcFermentables(); |
1430 var rowscount, type, id, selectedrowindex = $('#miscGrid').jqxGrid('getselectedrowindex'); |
1402 calcIBUs(); |
1431 rowscount = $('#miscGrid').jqxGrid('getdatainformation').rowscount; |
1403 }); |
1432 type = $('#miscGrid').jqxGrid('getcellvalue', selectedrowindex, 'm_type'); |
1404 $('#est_og').on('change', function (event) { |
1433 if (selectedrowindex >= 0 && selectedrowindex < rowscount && type != 4) { // Water agent |
1405 dataRecord.est_og = parseFloat(event.args.value); |
1434 id = $('#miscGrid').jqxGrid('getrowid', selectedrowindex); |
1406 console.log("est_og change:"+dataRecord.est_og); |
1435 $('#miscGrid').jqxGrid('deleterow', id); |
1407 calcFermentablesFromOG(dataRecord.est_og); // Adjust fermentables amounts |
1436 } |
1408 calcFermentables(); // Update the recipe details |
1437 }); |
1409 calcIBUs(); // and the IBU's. |
1438 }, |
1410 calcMash(); |
1439 ready: function() { |
1411 }); |
1440 $('#jqxTabs').jqxTabs('next'); |
1412 $('#mash_ph').on('change', function (event) { |
1441 }, |
1413 dataRecord.mash_ph = parseFloat(event.args.value); |
1442 columns: [ |
1414 calcWater(); |
1443 { text: 'Ingredient', datafield: 'm_name' }, |
1415 }); |
1444 { text: 'Type', width: 140, datafield: 'm_type', |
1416 |
1445 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1417 $('#sparge_ph').on('change', function (event) { |
1446 return '<span style="margin: 3px; margin-top: 6px; float: left;">' + MiscTypeData[value].nl + '</span>'; |
1418 dataRecord.sparge_ph = parseFloat(event.args.value); |
1447 } |
1419 calcSparge(); |
1448 }, |
1420 }); |
1449 { text: 'Gebruik', width: 140, datafield: 'm_use_use', |
1421 $('#sparge_volume').on('change', function (event) { |
1450 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1422 dataRecord.sparge_volume = parseFloat(event.args.value); |
1451 return '<span style="margin: 3px; margin-top: 6px; float: left;">' + MiscUseData[value].nl + '</span>'; |
1423 calcSparge(); |
1452 } |
1424 }); |
1453 }, |
1425 $('#sparge_source').on('change', function (event) { |
1454 { text: 'Tijd', datafield: 'm_time', width: 90, align: 'right', |
1426 if (event.args) { |
1455 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1427 var index = event.args.index; |
1456 var duration = ''; |
1428 dataRecord.sparge_source= index; |
1457 if (rowdata.m_use_use == 2) // Boil |
1429 calcSparge(); |
1458 duration = dataAdapter.formatNumber(value, 'f0') + ' min.'; |
1430 } |
1459 else if ((rowdata.m_use_use == 3) || (rowdata.m_use_use == 4)) // Primary or Secondary |
1431 }); |
1460 duration = dataAdapter.formatNumber(value / 1440, 'f0') + ' dagen'; |
1432 $('#sparge_acid_type').on('change', function (event) { |
1461 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + duration + '</span>'; |
1433 if (event.args) { |
1462 } |
1434 var index = event.args.index; |
1463 }, |
1435 dataRecord.sparge_acid_type = index; |
1464 { text: 'Hoeveel', datafield: 'm_amount', width: 110, align: 'right', |
1436 console.log("new sparge_acid_type: "+dataRecord.sparge_acid_type); |
1465 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1437 calcSparge(); |
1466 var vstr = rowdata.m_amount_is_weight ? 'gr' : 'ml'; |
1438 } |
1467 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + |
1439 }); |
1468 dataAdapter.formatNumber(value * 1000, 'f2') + ' ' + vstr + '</span>'; |
1440 $('#sparge_acid_perc').on('change', function (event) { |
1469 } |
1441 dataRecord.sparge_acid_perc = parseFloat(event.args.value); |
1470 }, |
1442 calcSparge(); |
1471 { text: 'Voorraad', datafield: 'm_inventory', width: 110, align: 'right', |
1443 }); |
1472 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1444 $('#locked').on('checked', function (event) { |
1473 var amount, color = '#ffffff', vstr = rowdata.m_amount_is_weight ? 'gr' : 'ml'; |
1445 dataRecord.locked = 1; |
1474 if (value < rowdata.m_amount) |
1446 setReadonly(true); |
1475 color = '#ff4040'; |
1447 }); |
1476 amount = dataAdapter.formatNumber(value * 1000, 'f2') + ' ' + vstr; |
1448 $('#locked').on('unchecked', function (event) { |
1477 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + amount + '</span>'; |
1449 dataRecord.locked = 0; |
1478 }, |
1450 setReadonly(false); |
1479 }, |
1451 }); |
1480 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', |
1452 // setReadonly(false); |
1481 cellsrenderer: function() { |
1453 }; |
1482 return 'Wijzig'; |
1454 |
1483 }, buttonclick: function(row) { |
1455 $("#styleSelect").jqxDropDownList({ |
1484 miscRow = row; |
1456 placeHolder: "Kies bierstijl:", |
1485 miscData = $('#miscGrid').jqxGrid('getrowdata', miscRow); |
1457 theme: theme, |
1486 if (miscData.m_type == 4) { |
1458 source: styleslist, |
1487 alert('Brouwzouten wijzigen in de water tab.'); |
1459 displayMember: "name", |
1488 } else { |
1460 width: 180, |
1489 if (miscData.m_amount_is_weight) |
1461 height: 23, |
1490 $('#wm_pmpt_amount').html('Gewicht gram:'); |
1462 dropDownVerticalAlignment: 'top', |
1491 else |
1463 dropDownWidth: 500, |
1492 $('#wm_pmpt_amount').html('Volume ml:'); |
1464 dropDownHeight: 380, |
1493 $('#wm_name').val(miscData.m_name); |
1465 renderer: function (index, label, value) { |
1494 $('#wm_amount').val(miscData.m_amount * 1000); |
1466 var datarecord = styleslist.records[index]; |
1495 if ((miscData.m_use_use == 3) || (miscData.m_use_use == 4)) // Primary or Secondary |
1467 return datarecord.style_guide + " " + datarecord.style_letter+ " " + datarecord.name; |
1496 $('#wm_time').val(miscData.m_time / 1440); |
1468 } |
1497 else |
1469 }); |
1498 $('#wm_time').val(miscData.m_time); |
1470 $("#styleSelect").on('select', function (event) { |
1499 $('#wm_use_use').val(miscData.m_use_use); |
1471 if (event.args) { |
1500 // show the popup window. |
1472 var index = event.args.index; |
1501 $('#popupMisc').jqxWindow('open'); |
1473 var datarecord = styleslist.records[index]; |
1502 } |
1474 $("#st_name").val(datarecord.name); |
1503 } |
1475 $("#st_category").val(datarecord.category); |
1504 } |
1476 $("#st_category_number").val(datarecord.category_number); |
1505 ] |
1477 $("#st_letter").val(datarecord.style_letter); |
1506 }); |
1478 $("#st_guide").val(datarecord.style_guide); |
1507 }; |
1479 $("#st_type").val(StyleTypeData[datarecord.type].nl); |
1508 |
1480 $("#st_og_min").val(datarecord.og_min); |
1509 // Inline yeasts editor |
1481 $("#st_og_max").val(datarecord.og_max); |
1510 var editYeast = function(data) { |
1482 $("#st_fg_min").val(datarecord.fg_min); |
1511 var yeastSource = { |
1483 $("#st_fg_max").val(datarecord.fg_max); |
1512 localdata: data.yeasts, |
1484 $("#st_ibu_min").val(datarecord.ibu_min); |
1513 datatype: 'local', |
1485 $("#st_ibu_max").val(datarecord.ibu_max); |
1514 cache: false, |
1486 $("#st_color_min").val(datarecord.color_min); |
1515 async: false, |
1487 $("#st_color_max").val(datarecord.color_max); |
1516 datafields: [ |
1488 $("#st_carb_min").val(datarecord.carb_min); |
1517 { name: 'y_name', type: 'string' }, |
1489 $("#st_carb_max").val(datarecord.carb_max); |
1518 { name: 'y_laboratory', type: 'string' }, |
1490 $("#st_abv_min").val(datarecord.abv_min); |
1519 { name: 'y_product_id', type: 'string' }, |
1491 $("#st_abv_max").val(datarecord.abv_max); |
1520 { name: 'y_amount', type: 'float' }, |
1492 } |
1521 { name: 'y_cost', type: 'float' }, |
1493 }); |
1522 { name: 'y_type', type: 'int' }, |
1494 |
1523 { name: 'y_form', type: 'int' }, |
1495 function saveRecord() { |
1524 { name: 'y_flocculation', type: 'int' }, |
1496 var fermentablerow = $('#fermentableGrid').jqxGrid('getrows'); |
1525 { name: 'y_min_temperature', type: 'float' }, |
1497 var hoprow = $('#hopGrid').jqxGrid('getrows'); |
1526 { name: 'y_max_temperature', type: 'float' }, |
1498 var miscrow = $('#miscGrid').jqxGrid('getrows'); |
1527 { name: 'y_attenuation', type: 'float' }, |
1499 var yeastrow = $('#yeastGrid').jqxGrid('getrows'); |
1528 { name: 'y_use', type: 'int' }, |
1500 var mashrow = $('#mashGrid').jqxGrid('getrows'); |
1529 { name: 'y_cells', type: 'float' }, |
1501 var row = { |
1530 { name: 'y_tolerance', type: 'float' }, |
1502 record: my_record, |
1531 { name: 'y_inventory', type: 'float' }, |
1503 uuid: dataRecord.uuid, |
1532 { name: 'y_avail', type: 'int' } |
1504 name: $("#name").val(), |
1533 ], |
1505 locked: dataRecord.locked, |
1534 addrow: function(rowid, rowdata, position, commit) { |
1506 notes: $("#notes").val(), |
1535 //console.log("yeast addrow "+rowid); |
1507 st_name: $('#st_name').val(), |
1536 commit(true); |
1508 st_letter: $('#st_letter').val(), |
1537 }, |
1509 st_guide: $('#st_guide').val(), |
1538 deleterow: function(rowid, commit) { |
1510 st_type: dataRecord.st_type, |
1539 //console.log("yeast deleterow "+rowid); |
1511 st_category: $('#st_category').val(), |
1540 commit(true); |
1512 st_category_number: parseFloat($("#st_category_number").jqxNumberInput('decimal')), |
1541 }, |
1513 st_og_min: parseFloat($("#st_og_min").jqxNumberInput('decimal')), |
1542 updaterow: function(rowid, rowdata, commit) { |
1514 st_og_max: parseFloat($("#st_og_max").jqxNumberInput('decimal')), |
1543 //console.log("yeast updaterow "+rowid); |
1515 st_fg_min: parseFloat($("#st_fg_min").jqxNumberInput('decimal')), |
1544 commit(true); |
1516 st_fg_max: parseFloat($("#st_fg_max").jqxNumberInput('decimal')), |
1545 } |
1517 st_ibu_min: parseFloat($("#st_ibu_min").jqxNumberInput('decimal')), |
1546 }, |
1518 st_ibu_max: parseFloat($("#st_ibu_max").jqxNumberInput('decimal')), |
1547 yeastAdapter = new $.jqx.dataAdapter(yeastSource); |
1519 st_color_min: parseFloat($("#st_color_min").jqxNumberInput('decimal')), |
1548 |
1520 st_color_max: parseFloat($("#st_color_max").jqxNumberInput('decimal')), |
1549 $('#yeastGrid').jqxGrid({ |
1521 st_carb_min: parseFloat($("#st_carb_min").jqxNumberInput('decimal')), |
1550 width: 1240, |
1522 st_carb_max: parseFloat($("#st_carb_max").jqxNumberInput('decimal')), |
1551 height: 350, |
1523 st_abv_min: parseFloat($("#st_abv_min").jqxNumberInput('decimal')), |
1552 source: yeastAdapter, |
1524 st_abv_max: parseFloat($("#st_abv_max").jqxNumberInput('decimal')), |
1553 theme: theme, |
1525 type: $("#type").val(), |
1554 selectionmode: 'singlerow', |
1526 batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')), |
1555 showtoolbar: true, |
1527 boil_size: parseFloat($("#boil_size").jqxNumberInput('decimal')), |
1556 rendertoolbar: function(toolbar) { |
1528 boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')), |
1557 var container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>'); |
1529 efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')), |
1558 toolbar.append(container); |
1530 est_og: parseFloat($("#est_og").jqxNumberInput('decimal')), |
1559 container.append('<div style="float: left; margin-left: 165px;" id="yaddrowbutton"></div>'); |
1531 est_fg: parseFloat($("#est_fg").jqxNumberInput('decimal')), |
1560 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>'); |
1532 est_abv: parseFloat($("#est_abv").jqxNumberInput('decimal')), |
1561 container.append('<div style="float: left; margin-left: 10px;" id="yinstockbutton"></div>'); |
1533 est_color: parseFloat($("#est_color").jqxNumberInput('decimal')), |
1562 container.append('<input style="float: left; margin-left: 400px;" id="ydeleterowbutton" type="button" value="Verwijder gist" />'); |
1534 color_method: $("#color_method").val(), |
1563 // add yeast from dropdownlist. |
1535 est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')), |
1564 $('#yaddrowbutton').jqxDropDownList({ |
1536 ibu_method: $("#ibu_method").val(), |
1565 placeHolder: 'Kies gist:', |
1537 est_carb: parseFloat($("#est_carb").jqxNumberInput('decimal')), |
1566 theme: theme, |
1538 mash_name: $("#mash_name").val(), |
1567 source: yeastlist, |
1539 mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal')), |
1568 template: 'primary', |
1540 sparge_temp: parseFloat($("#sparge_temp").jqxNumberInput('decimal')), |
1569 displayMember: 'name', |
1541 sparge_ph: parseFloat($("#sparge_ph").jqxNumberInput('decimal')), |
1570 width: 150, |
1542 sparge_volume: parseFloat($("#sparge_volume").jqxNumberInput('decimal')), |
1571 height: 27, |
1543 sparge_source: $("#sparge_source").val(), |
1572 dropDownWidth: 500, |
1544 sparge_acid_type: $("#sparge_acid_type").val(), |
1573 dropDownHeight: 500, |
1545 sparge_acid_perc: parseFloat($("#sparge_acid_perc").jqxNumberInput('decimal')), |
1574 renderer: function(index, label, value) { |
1546 sparge_acid_amount: dataRecord.sparge_acid_amount, |
1575 var datarecord = yeastlist.records[index]; |
1547 calc_acid: dataRecord.calc_acid, |
1576 return datarecord.laboratory + ' ' + datarecord.product_id + ' ' + datarecord.name; |
1548 w1_name: $("#w1_name").val(), |
1577 } |
1549 w1_amount: parseFloat($("#w1_amount").jqxNumberInput('decimal')), |
1578 }); |
1550 w1_calcium: parseFloat($("#w1_calcium").jqxNumberInput('decimal')), |
1579 $('#yaddrowbutton').on('select', function(event) { |
1551 w1_sulfate: parseFloat($("#w1_sulfate").jqxNumberInput('decimal')), |
1580 if (event.args) { |
1552 w1_chloride: parseFloat($("#w1_chloride").jqxNumberInput('decimal')), |
1581 var datarecord, row = {}, index = event.args.index; |
1553 w1_sodium: parseFloat($("#w1_sodium").jqxNumberInput('decimal')), |
1582 datarecord = yeastlist.records[index]; |
1554 w1_magnesium: parseFloat($("#w1_magnesium").jqxNumberInput('decimal')), |
1583 row['y_name'] = datarecord.name; |
1555 w1_total_alkalinity: parseFloat($("#w1_total_alkalinity").jqxNumberInput('decimal')), |
1584 row['y_laboratory'] = datarecord.laboratory; |
1556 w1_ph: parseFloat($("#w1_ph").jqxNumberInput('decimal')), |
1585 row['y_product_id'] = datarecord.product_id; |
1557 w1_cost: dataRecord.w1_cost, |
1586 row['y_type'] = datarecord.type; |
1558 w2_name: $("#w2_name").val(), |
1587 row['y_form'] = datarecord.form; |
1559 w2_amount: parseFloat($("#w2_amount").jqxNumberInput('decimal')), |
1588 row['y_amount'] = 0; |
1560 w2_calcium: parseFloat($("#w2_calcium").jqxNumberInput('decimal')), |
1589 row['y_cost'] = datarecord.cost; |
1561 w2_sulfate: parseFloat($("#w2_sulfate").jqxNumberInput('decimal')), |
1590 row['y_use'] = 0; |
1562 w2_chloride: parseFloat($("#w2_chloride").jqxNumberInput('decimal')), |
1591 row['y_min_temperature'] = datarecord.min_temperature; |
1563 w2_sodium: parseFloat($("#w2_sodium").jqxNumberInput('decimal')), |
1592 row['y_max_temperature'] = datarecord.max_temperature; |
1564 w2_magnesium: parseFloat($("#w2_magnesium").jqxNumberInput('decimal')), |
1593 row['y_attenuation'] = datarecord.attenuation; |
1565 w2_total_alkalinity: parseFloat($("#w2_total_alkalinity").jqxNumberInput('decimal')), |
1594 row['y_flocculation'] = datarecord.flocculation; |
1566 w2_ph: parseFloat($("#w2_ph").jqxNumberInput('decimal')), |
1595 row['y_cells'] = datarecord.cells; |
1567 w2_cost: dataRecord.w2_cost, |
1596 row['y_tolerance'] = datarecord.tolerance; |
1568 wg_amount: parseFloat($("#wg_amount").jqxNumberInput('decimal')), |
1597 row['y_inventory'] = datarecord.inventory; |
1569 wg_calcium: parseFloat($("#wg_calcium").jqxNumberInput('decimal')), |
1598 $('#yeastGrid').jqxGrid('addrow', null, row); |
1570 wg_sulfate: parseFloat($("#wg_sulfate").jqxNumberInput('decimal')), |
1599 } |
1571 wg_chloride: parseFloat($("#wg_chloride").jqxNumberInput('decimal')), |
1600 $('#yaddrowbutton').jqxDropDownList('clearSelection'); |
1572 wg_sodium: parseFloat($("#wg_sodium").jqxNumberInput('decimal')), |
1601 }); |
1573 wg_magnesium: parseFloat($("#wg_magnesium").jqxNumberInput('decimal')), |
1602 $('#yinstockbutton').jqxCheckBox({ theme: theme, height: 27, disabled: (dataRecord.stage > 3) }); |
1574 wg_total_alkalinity: parseFloat($("#wg_total_alkalinity").jqxNumberInput('decimal')), |
1603 $('#yinstockbutton').on('change', function(event) { |
1575 wg_ph: parseFloat($("#wg_ph").jqxNumberInput('decimal')), |
1604 yeastinstock = event.args.checked; |
1576 wb_calcium: parseFloat($("#wb_calcium").jqxNumberInput('decimal')), |
1605 yeastlist.dataBind(); |
1577 wb_sulfate: parseFloat($("#wb_sulfate").jqxNumberInput('decimal')), |
1606 }); |
1578 wb_chloride: parseFloat($("#wb_chloride").jqxNumberInput('decimal')), |
1607 // delete selected yeast. |
1579 wb_sodium: parseFloat($("#wb_sodium").jqxNumberInput('decimal')), |
1608 $('#ydeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 3) }); |
1580 wb_magnesium: parseFloat($("#wb_magnesium").jqxNumberInput('decimal')), |
1609 $('#ydeleterowbutton').on('click', function() { |
1581 wb_total_alkalinity: parseFloat($("#wb_total_alkalinity").jqxNumberInput('decimal')), |
1610 var id, rowscount, selectedrowindex = $('#yeastGrid').jqxGrid('getselectedrowindex'); |
1582 wb_ph: parseFloat($("#wb_ph").jqxNumberInput('decimal')), |
1611 rowscount = $('#yeastGrid').jqxGrid('getdatainformation').rowscount; |
1583 wa_acid_name: $("#wa_acid_name").val(), |
1612 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
1584 wa_acid_perc: parseFloat($("#wa_acid_perc").jqxNumberInput('decimal')), |
1613 id = $('#yeastGrid').jqxGrid('getrowid', selectedrowindex); |
1585 wa_base_name: $("#wa_base_name").val(), |
1614 $('#yeastGrid').jqxGrid('deleterow', id); |
1586 fermentables: fermentablerow, |
1615 } |
1587 hops: hoprow, |
1616 }); |
1588 miscs: miscrow, |
1617 }, |
1589 yeasts: yeastrow, |
1618 ready: function() { |
1590 mashs: mashrow |
1619 calcFermentables(); |
1591 }; |
1620 $('#jqxTabs').jqxTabs('next'); |
1592 var data = "update=true&" + $.param(row); |
1621 }, |
1593 $.ajax({ |
1622 columns: [ |
1594 dataType: 'json', |
1623 { text: 'Gist', datafield: 'y_name' }, |
1595 url: url, |
1624 { text: 'Laboratorium', width: 150, datafield: 'y_laboratory' }, |
1596 cache: false, |
1625 { text: 'Code', width: 90, datafield: 'y_product_id' }, |
1597 async: false, |
1626 { text: 'Soort', width: 100, datafield: 'y_form', |
1598 data: data, |
1627 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1599 type: "POST", |
1628 return '<span style="margin: 4px; margin-top: 6px; float: left;">' + YeastFormData[value].nl + '</span>'; |
1600 success: function (data, status, xhr) { |
1629 } |
1601 console.log("saveRecord() success"); |
1630 }, |
1602 }, |
1631 { text: 'Min. °C', width: 70, align: 'right', cellsalign: 'right', datafield: 'y_min_temperature' }, |
1603 error: function(jqXHR, textStatus, errorThrown) { |
1632 { text: 'Max. °C', width: 70, align: 'right', cellsalign: 'right', datafield: 'y_max_temperature' }, |
1604 console.log("saveRecord() error"); |
1633 { text: 'Tol. %', width: 60, align: 'right', cellsalign: 'right', datafield: 'y_tolerance', |
1605 } |
1634 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1606 }); |
1635 var amount = '', color = '#ffffff'; |
1607 }; |
1636 if (value > 0) { |
1608 |
1637 amount = dataAdapter.formatNumber(value, 'f1'); |
1609 var dataRecord = {}; |
1638 if (dataRecord.est_abv > value) |
1610 var url = "includes/db_recipes.php"; |
1639 color = '#ff4040'; |
1611 |
1640 } |
1612 // prepare the data |
1641 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + amount + '</span>'; |
1613 var source = { |
1642 } |
1614 datatype: "json", |
1643 }, |
1615 cache: false, |
1644 { text: 'Attn. %', width: 70, align: 'right', cellsalign: 'right', datafield: 'y_attenuation', cellsformat: 'f1' }, |
1616 datafields: [ |
1645 { text: 'Voor', width: 120, datafield: 'y_use', |
1617 { name: 'record', type: 'number' }, |
1646 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1618 { name: 'uuid', type: 'string' }, |
1647 return '<span style="margin: 4px; margin-top: 6px; float: left;">' + YeastUseData[value].nl + '</span>'; |
1619 { name: 'locked', type: 'int' }, |
1648 } |
1620 { name: 'st_name', type: 'string' }, |
1649 }, |
1621 { name: 'st_letter', type: 'string' }, |
1650 { text: 'Hoeveel', datafield: 'y_amount', width: 90, align: 'right', |
1622 { name: 'st_guide', type: 'string' }, |
1651 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1623 { name: 'st_type', type: 'int' }, |
1652 var amount = dataAdapter.formatNumber(value * 1000, 'f0') + ' ml'; |
1624 { name: 'st_category', type: 'string' }, |
1653 if (rowdata.y_form == 0) // Liquid |
1625 { name: 'st_category_number', type: 'float' }, |
1654 amount = dataAdapter.formatNumber(value, 'f0') + ' pk'; |
1626 { name: 'st_og_min', type: 'float' }, |
1655 else if (rowdata.y_form == 1) // Dry |
1627 { name: 'st_og_max', type: 'float' }, |
1656 amount = dataAdapter.formatNumber(value * 1000, 'f1') + ' gr'; |
1628 { name: 'st_fg_min', type: 'float' }, |
1657 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + amount + '</span>'; |
1629 { name: 'st_fg_max', type: 'float' }, |
1658 } |
1630 { name: 'st_ibu_min', type: 'float' }, |
1659 }, |
1631 { name: 'st_ibu_max', type: 'float' }, |
1660 { text: 'Voorraad', datafield: 'y_inventory', width: 90, align: 'right', |
1632 { name: 'st_color_min', type: 'float' }, |
1661 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1633 { name: 'st_color_max', type: 'float' }, |
1662 var color, amount; |
1634 { name: 'st_carb_min', type: 'float' }, |
1663 color = '#ffffff'; |
1635 { name: 'st_carb_max', type: 'float' }, |
1664 if (value < rowdata.y_amount) |
1636 { name: 'st_abv_min', type: 'float' }, |
1665 color = '#ff4040'; |
1637 { name: 'st_abv_max', type: 'float' }, |
1666 amount = dataAdapter.formatNumber(value * 1000, 'f0') + ' ml'; |
1638 { name: 'name', type: 'string' }, |
1667 if (rowdata.y_form == 0) // Liquid |
1639 { name: 'notes', type: 'string' }, |
1668 amount = dataAdapter.formatNumber(value, 'f0') + ' pk'; |
1640 { name: 'type', type: 'int' }, |
1669 else if (rowdata.y_form == 1) // Dry |
1641 { name: 'batch_size', type: 'float' }, |
1670 amount = dataAdapter.formatNumber(value * 1000, 'f1') + ' gr'; |
1642 { name: 'boil_size', type: 'float' }, |
1671 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + amount + '</span>'; |
1643 { name: 'boil_time', type: 'float' }, |
1672 } |
1644 { name: 'efficiency', type: 'float' }, |
1673 }, |
1645 { name: 'est_og', type: 'float' }, |
1674 { text: '', datafield: 'Edit', columntype: 'button', width: 90, align: 'center', |
1646 { name: 'est_fg', type: 'float' }, |
1675 cellsrenderer: function() { |
1647 { name: 'est_abv', type: 'float' }, |
1676 return 'Wijzig'; |
1648 { name: 'est_color', type: 'float' }, |
1677 }, buttonclick: function(row) { |
1649 { name: 'color_method', type: 'int' }, |
1678 yeastRow = row; |
1650 { name: 'est_ibu', type: 'float' }, |
1679 yeastData = $('#yeastGrid').jqxGrid('getrowdata', yeastRow); |
1651 { name: 'ibu_method', type: 'int' }, |
1680 if (yeastData.y_form == 0) { |
1652 { name: 'est_carb', type: 'float' }, |
1681 $('#wy_pmpt_amount').html('Pak(ken):'); |
1653 { name: 'sparge_temp', type: 'float' }, |
1682 $('#wy_amount').val(yeastData.y_amount); |
1654 { name: 'sparge_ph', type: 'float' }, |
1683 $('#wy_amount').jqxNumberInput({ decimalDigits: 0 }); |
1655 { name: 'sparge_volume', type: 'float' }, |
1684 } else if (yeastData.y_form == 1) { |
1656 { name: 'sparge_source', type: 'int' }, |
1685 $('#wy_pmpt_amount').html('Gewicht gram:'); |
1657 { name: 'sparge_acid_type', type: 'int' }, |
1686 $('#wy_amount').val(yeastData.y_amount * 1000); |
1658 { name: 'sparge_acid_perc', type: 'float' }, |
1687 $('#wy_amount').jqxNumberInput({ decimalDigits: 1 }); |
1659 { name: 'sparge_acid_amount', type: 'float' }, |
1688 } else { |
1660 { name: 'mash_ph', type: 'float' }, |
1689 $('#wy_pmpt_amount').html('Volume ml:'); |
1661 { name: 'mash_name', type: 'string' }, |
1690 $('#wy_amount').val(yeastData.y_amount * 1000); |
1662 { name: 'calc_acid', type: 'int' }, |
1691 $('#wy_amount').jqxNumberInput({ decimalDigits: 0 }); |
1663 { name: 'w1_name', type: 'string' }, |
1692 } |
1664 { name: 'w1_amount', type: 'float' }, |
1693 $('#wy_name').val(yeastData.y_name); |
1665 { name: 'w1_calcium', type: 'float' }, |
1694 $('#wy_laboratory').val(yeastData.y_laboratory); |
1666 { name: 'w1_sulfate', type: 'float' }, |
1695 $('#wy_product_id').val(yeastData.y_product_id); |
1667 { name: 'w1_chloride', type: 'float' }, |
1696 $('#wy_use').val(yeastData.y_use); |
1668 { name: 'w1_sodium', type: 'float' }, |
1697 // show the popup window. |
1669 { name: 'w1_magnesium', type: 'float' }, |
1698 $('#popupYeast').jqxWindow('open'); |
1670 { name: 'w1_total_alkalinity', type: 'float' }, |
1699 } |
1671 { name: 'w1_ph', type: 'float' }, |
1700 } |
1672 { name: 'w1_cost', type: 'float' }, |
1701 ] |
1673 { name: 'w2_name', type: 'string' }, |
1702 }); |
1674 { name: 'w2_amount', type: 'float' }, |
1703 }; |
1675 { name: 'w2_calcium', type: 'float' }, |
1704 |
1676 { name: 'w2_sulfate', type: 'float' }, |
1705 // inline mash editor |
1677 { name: 'w2_chloride', type: 'float' }, |
1706 var editMash = function(data) { |
1678 { name: 'w2_sodium', type: 'float' }, |
1707 var generaterow = function() { |
1679 { name: 'w2_magnesium', type: 'float' }, |
1708 var row = {}; |
1680 { name: 'w2_total_alkalinity', type: 'float' }, |
1709 row['step_name'] = 'Stap 1'; |
1681 { name: 'w2_ph', type: 'float' }, |
1710 row['step_type'] = 0; |
1682 { name: 'w2_cost', type: 'float' }, |
1711 row['step_infuse_amount'] = 15; |
1683 { name: 'wg_amount', type: 'float' }, |
1712 row['step_temp'] = 62.0; |
1684 { name: 'wg_calcium', type: 'float' }, |
1713 row['step_time'] = 20.0; |
1685 { name: 'wg_sulfate', type: 'float' }, |
1714 row['step_thickness'] = 0; |
1686 { name: 'wg_chloride', type: 'float' }, |
1715 row['ramp_time'] = 1.0; |
1687 { name: 'wg_sodium', type: 'float' }, |
1716 row['end_temp'] = 62.0; |
1688 { name: 'wg_magnesium', type: 'float' }, |
1717 return row; |
1689 { name: 'wg_total_alkalinity', type: 'float' }, |
1718 }; |
1690 { name: 'wg_ph', type: 'float' }, |
1719 var mashSource = { |
1691 { name: 'wb_calcium', type: 'float' }, |
1720 localdata: data.mashs, |
1692 { name: 'wb_sulfate', type: 'float' }, |
1721 datatype: 'local', |
1693 { name: 'wb_chloride', type: 'float' }, |
1722 cache: false, |
1694 { name: 'wb_sodium', type: 'float' }, |
1723 async: false, |
1695 { name: 'wb_magnesium', type: 'float' }, |
1724 datafields: [ |
1696 { name: 'wb_total_alkalinity', type: 'float' }, |
1725 { name: 'step_name', type: 'string' }, |
1697 { name: 'wb_ph', type: 'float' }, |
1726 { name: 'step_type', type: 'int' }, |
1698 { name: 'wa_acid_name', type: 'int' }, |
1727 { name: 'step_infuse_amount', type: 'float' }, |
1699 { name: 'wa_acid_perc', type: 'int' }, |
1728 { name: 'step_temp', type: 'float' }, |
1700 { name: 'wa_base_name', type: 'int' }, |
1729 { name: 'step_time', type: 'float' }, |
1701 { name: 'fermentables', type: 'array' }, |
1730 { name: 'step_thickness', type: 'float' }, |
1702 { name: 'hops', type: 'array' }, |
1731 { name: 'ramp_time', type: 'float' }, |
1703 { name: 'miscs', type: 'array' }, |
1732 { name: 'end_temp', type: 'float' } |
1704 { name: 'yeasts', type: 'array' }, |
1733 ], |
1705 { name: 'mashs', type: 'array' } |
1734 addrow: function(rowid, rowdata, position, commit) { |
1706 ], |
1735 commit(true); |
1707 id: 'record', |
1736 }, |
1708 url: url + '?record=' + my_record |
1737 deleterow: function(rowid, commit) { |
1709 }; |
1738 commit(true); |
1710 // Load data and select one record. |
1739 } |
1711 var dataAdapter = new $.jqx.dataAdapter(source, { |
1740 }, |
1712 loadComplete: function () { |
1741 mashAdapter = new $.jqx.dataAdapter(mashSource, { |
1713 var records = dataAdapter.records; |
1742 beforeLoadComplete: function(records) { |
1714 dataRecord = records[0]; |
1743 mash_infuse = 0; |
1715 // Hidden record uuid |
1744 var row, i, data = new Array(); |
1716 $("#name").val(dataRecord.name); |
1745 for (i = 0; i < records.length; i++) { |
1717 $("#notes").val(dataRecord.notes); |
1746 row = records[i]; |
1718 $("#locked").val(dataRecord.locked); |
1747 if (row.step_type == 0) // Infusion |
1719 $("#st_name").val(dataRecord.st_name); |
1748 mash_infuse += parseFloat(row.step_infuse_amount); |
1720 $("#st_letter").val(dataRecord.st_letter); |
1749 row.step_thickness = 0; // Init this field. |
1721 $("#st_guide").val(dataRecord.st_guide); |
1750 data.push(row); |
1722 $("#st_category").val(dataRecord.st_category); |
1751 } |
1723 $("#st_category_number").val(dataRecord.st_category_number); |
1752 }, |
1724 $("#st_type").val(StyleTypeData[dataRecord.st_type].nl); |
1753 }); |
1725 $("#type").val(dataRecord.type); |
1754 $('#mashGrid').jqxGrid({ |
1726 $("#batch_size").val(dataRecord.batch_size); |
1755 width: 1240, |
1727 $("#boil_size").val(dataRecord.boil_size); |
1756 height: 400, |
1728 $("#boil_time").val(dataRecord.boil_time); |
1757 source: mashAdapter, |
1729 $("#efficiency").val(dataRecord.efficiency); |
1758 theme: theme, |
1730 $("#est_og").val(dataRecord.est_og); |
1759 selectionmode: 'singlerow', |
1731 $("#est_og2").val(dataRecord.est_og); |
1760 showtoolbar: true, |
1732 $("#st_og_min").val(dataRecord.st_og_min); |
1761 rendertoolbar: function(toolbar) { |
1733 $("#st_og_max").val(dataRecord.st_og_max); |
1762 //var me = this; |
1734 $("#est_fg").val(dataRecord.est_fg); |
1763 var container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>'); |
1735 $("#est_fg2").val(dataRecord.est_fg); |
1764 toolbar.append(container); |
1736 $("#st_fg_min").val(dataRecord.st_fg_min); |
1765 container.append('<input style="float: left; margin-left: 165px;" id="saddrowbutton" type="button" value="Nieuwe stap" />'); |
1737 $("#st_fg_max").val(dataRecord.st_fg_max); |
1766 container.append('<input style="float: left; margin-left: 565px;" id="sdeleterowbutton" type="button" value="Verwijder stap" />'); |
1738 $("#est_color").val(dataRecord.est_color); |
1767 $('#saddrowbutton').jqxButton({ template: 'primary', theme: theme, height: 27, width: 150 }); |
1739 $("#est_color2").val(dataRecord.est_color); |
1768 $('#saddrowbutton').on('click', function() { |
1740 $("#est_abv").val(dataRecord.est_abv); |
1769 var datarow = generaterow(); |
1741 $("#est_abv2").val(dataRecord.est_abv); |
1770 $('#mashGrid').jqxGrid('addrow', null, datarow); |
1742 $("#st_abv_min").val(dataRecord.st_abv_min); |
1771 }); |
1743 $("#st_abv_max").val(dataRecord.st_abv_max); |
1772 // delete selected yeast. |
1744 $("#st_color_min").val(dataRecord.st_color_min); |
1773 $('#sdeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150 }); |
1745 $("#st_color_max").val(dataRecord.st_color_max); |
1774 $('#sdeleterowbutton').on('click', function() { |
1746 $("#color_method").val(dataRecord.color_method); |
1775 var id, rowscount, selectedrowindex = $('#mashGrid').jqxGrid('getselectedrowindex'); |
1747 $("#est_ibu").val(dataRecord.est_ibu); |
1776 rowscount = $('#mashGrid').jqxGrid('getdatainformation').rowscount; |
1748 $("#est_ibu2").val(dataRecord.est_ibu); |
1777 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
1749 $("#st_ibu_min").val(dataRecord.st_ibu_min); |
1778 id = $('#mashGrid').jqxGrid('getrowid', selectedrowindex); |
1750 $("#st_ibu_max").val(dataRecord.st_ibu_max); |
1779 $('#mashGrid').jqxGrid('deleterow', id); |
1751 $("#ibu_method").val(dataRecord.ibu_method); |
1780 } |
1752 $("#est_carb").val(dataRecord.est_carb); |
1781 }); |
1753 $("#st_carb_min").val(dataRecord.st_carb_min); |
1782 }, |
1754 $("#st_carb_max").val(dataRecord.st_carb_max); |
1783 ready: function() { |
1755 $("#mash_name").val(dataRecord.mash_name); |
1784 calcFermentables(); |
1756 $("#mash_ph").val(dataRecord.mash_ph); |
1785 calcInit(); |
1757 $("#sparge_temp").val(dataRecord.sparge_temp); |
1786 calcMash(); |
1758 $("#sparge_ph").val(dataRecord.sparge_ph); |
1787 $('#jqxLoader').jqxLoader('close'); |
1759 $("#sparge_volume").val(dataRecord.sparge_volume); |
1788 $('#jqxTabs').jqxTabs('first'); |
1760 $("#sparge_source").val(dataRecord.sparge_source); |
1789 }, |
1761 $("#sparge_acid_type").val(dataRecord.sparge_acid_type); |
1790 columns: [ |
1762 $("#sparge_acid_perc").val(dataRecord.sparge_acid_perc); |
1791 { text: 'Stap naam', datafield: 'step_name' }, |
1763 $("#sparge_acid_amount").val(dataRecord.sparge_acid_amount * 1000); |
1792 { text: 'Stap type', datafield: 'step_type', width: 175, |
1764 $("#calc_acid").val(dataRecord.calc_acid); |
1793 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1765 $("#w1_name").val(dataRecord.w1_name); |
1794 return '<div style="margin: 4px;">' + MashStepTypeData[value].nl + '</div>'; |
1766 $("#w1_amount").val(dataRecord.w1_amount); |
1795 } |
1767 $("#w1_calcium").val(dataRecord.w1_calcium); |
1796 }, |
1768 $("#w1_sulfate").val(dataRecord.w1_sulfate); |
1797 { text: 'Start °C', datafield: 'step_temp', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
1769 $("#w1_chloride").val(dataRecord.w1_chloride); |
1798 { text: 'Eind °C', datafield: 'end_temp', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
1770 $("#w1_sodium").val(dataRecord.w1_sodium); |
1799 { text: 'Rust min.', datafield: 'step_time', width: 90, align: 'right', cellsalign: 'right' }, |
1771 $("#w1_magnesium").val(dataRecord.w1_magnesium); |
1800 { text: 'Stap min.', datafield: 'ramp_time', width: 90, align: 'right', cellsalign: 'right' }, |
1772 $("#w1_total_alkalinity").val(dataRecord.w1_total_alkalinity); |
1801 { text: 'Infuse L.', datafield: 'step_infuse_amount', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
1773 $("#w1_ph").val(dataRecord.w1_ph); |
1802 { text: 'L/Kg.', datafield: 'step_thickness', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f2' }, |
1774 $("#w1_cost").val(dataRecord.w1_cost); |
1803 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', |
1775 $("#w2_name").val(dataRecord.w2_name); |
1804 cellsrenderer: function() { |
1776 $("#w2_amount").val(dataRecord.w2_amount); |
1805 return 'Wijzig'; |
1777 $("#w2_calcium").val(dataRecord.w2_calcium); |
1806 }, buttonclick: function(row) { |
1778 $("#w2_sulfate").val(dataRecord.w2_sulfate); |
1807 mashRow = row; |
1779 $("#w2_chloride").val(dataRecord.w2_chloride); |
1808 mashData = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
1780 $("#w2_sodium").val(dataRecord.w2_sodium); |
1809 $('#wstep_name').val(mashData.step_name); |
1781 $("#w2_magnesium").val(dataRecord.w2_magnesium); |
1810 $('#wstep_type').val(mashData.step_type); |
1782 $("#w2_total_alkalinity").val(dataRecord.w2_total_alkalinity); |
1811 $('#wstep_infuse_amount').val(mashData.step_infuse_amount); |
1783 $("#w2_ph").val(dataRecord.w2_ph); |
1812 $('#wstep_temp').val(mashData.step_temp); |
1784 $("#w2_cost").val(dataRecord.w2_cost); |
1813 $('#wend_temp').val(mashData.end_temp); |
1785 $("#wg_amount").val(dataRecord.wg_amount); |
1814 $('#wstep_time').val(mashData.step_time); |
1786 $("#wg_calcium").val(dataRecord.wg_calcium); |
1815 $('#wramp_time').val(mashData.ramp_time); |
1787 $("#wg_sulfate").val(dataRecord.wg_sulfate); |
1816 if (mashData.step_type == 0) { |
1788 $("#wg_chloride").val(dataRecord.wg_chloride); |
1817 $('#wstep_infuse_amount').show(); |
1789 $("#wg_sodium").val(dataRecord.wg_sodium); |
1818 $('#wstep_pmpt').show(); |
1790 $("#wg_magnesium").val(dataRecord.wg_magnesium); |
1819 } else { |
1791 $("#wg_total_alkalinity").val(dataRecord.wg_total_alkalinity); |
1820 $('#wstep_infuse_amount').hide(); |
1792 $("#wg_ph").val(dataRecord.wg_ph); |
1821 $('#wstep_pmpt').hide(); |
1793 $("#wb_calcium").val(dataRecord.wb_calcium); |
1822 } |
1794 $("#wb_sulfate").val(dataRecord.wb_sulfate); |
1823 // show the popup window. |
1795 $("#wb_chloride").val(dataRecord.wb_chloride); |
1824 $('#popupMash').jqxWindow('open'); |
1796 $("#wb_sodium").val(dataRecord.wb_sodium); |
1825 } |
1797 $("#wb_magnesium").val(dataRecord.wb_magnesium); |
1826 } |
1798 $("#wb_total_alkalinity").val(dataRecord.wb_total_alkalinity); |
1827 ] |
1799 $("#wb_ph").val(dataRecord.wb_ph); |
1828 }); |
1800 $("#wa_acid_name").val(dataRecord.wa_acid_name); |
1829 }; |
1801 $("#wa_acid_perc").val(dataRecord.wa_acid_perc); |
1830 |
1802 $("#wa_base_name").val(dataRecord.wa_base_name); |
1831 |
1803 editFermentable(dataRecord); |
1832 |
1804 editHop(dataRecord); |
1833 |
1805 editMisc(dataRecord); |
1834 /* |
1806 editYeast(dataRecord); |
1835 * Remove the top menu so that we MUST use the buttons to leave the editor. |
1807 editMash(dataRecord); |
1836 */ |
1808 $('#jqxTabs').jqxTabs('next'); |
1837 $('#jqxMenu').jqxMenu('destroy'); |
1809 }, |
1838 |
1810 loadError: function (jqXHR, status, error) { |
1839 console.log('record:' + my_record + ' return:' + my_return + ' theme:' + theme); |
1811 }, |
1840 $('#jqxLoader').jqxLoader({ |
1812 beforeLoadComplete: function (records) { |
1841 width: 250, |
1813 $('#jqxLoader').jqxLoader('open'); |
1842 height: 150, |
1814 } |
1843 isModal: true, |
1815 }); |
1844 text: 'Laden recept ...', |
1816 dataAdapter.dataBind(); |
1845 theme: theme |
1817 |
1846 }); |
1818 // Inline fermentables editor |
1847 |
1819 var editFermentable = function (data) { |
1848 |
1820 var fermentableSource = { |
1849 function setWaterAgent(name, amount) { |
1821 localdata: data.fermentables, |
1850 |
1822 datatype: "local", |
1851 var record, records, miscs, i, id, row, found = false, rows = $('#miscGrid').jqxGrid('getrows'); |
1823 cache: false, |
1852 if (amount == 0) { |
1824 async: false, |
1853 for (i = 0; i < rows.length; i++) { |
1825 datafields: [ |
1854 row = rows[i]; |
1826 { name: 'f_name', type: 'string' }, |
1855 if (row.m_name == name) { |
1827 { name: 'f_origin', type: 'string' }, |
1856 id = $('#miscGrid').jqxGrid('getrowid', i); |
1828 { name: 'f_supplier', type: 'string' }, |
1857 $('#miscGrid').jqxGrid('deleterow', id); |
1829 { name: 'f_amount', type: 'float' }, |
1858 } |
1830 { name: 'f_cost', type: 'float' }, |
1859 } |
1831 { name: 'f_type', type: 'int' }, |
1860 } else { |
1832 { name: 'f_yield', type: 'float' }, |
1861 for (i = 0; i < rows.length; i++) { |
1833 { name: 'f_color', type: 'float' }, |
1862 row = rows[i]; |
1834 { name: 'f_coarse_fine_diff', type: 'float' }, |
1863 if (row.m_name == name) { |
1835 { name: 'f_moisture', type: 'float' }, |
1864 found = true; |
1836 { name: 'f_diastatic_power', type: 'float' }, |
1865 $('#miscGrid').jqxGrid('setcellvalue', i, 'm_amount', amount / 1000); |
1837 { name: 'f_protein', type: 'float' }, |
1866 break; |
1838 { name: 'f_max_in_batch', type: 'float' }, |
1867 } |
1839 { name: 'f_graintype', type: 'int' }, |
1868 } |
1840 { name: 'f_added', type: 'int' }, |
1869 if (! found) { |
1841 { name: 'f_dissolved_protein', type: 'float' }, |
1870 miscs = new $.jqx.dataAdapter(miscInvSource, { |
1842 { name: 'f_recommend_mash', type: 'int' }, |
1871 loadComplete: function() { |
1843 { name: 'f_add_after_boil', type: 'int' }, |
1872 records = miscs.records; |
1844 { name: 'f_adjust_to_total_100', type: 'int' }, |
1873 for (i = 0; i < records.length; i++) { |
1845 { name: 'f_percentage', type: 'float' }, |
1874 record = records[i]; |
1846 { name: 'f_di_ph', type: 'float' }, |
1875 if (record.name == name) { |
1847 { name: 'f_acid_to_ph_57', type: 'float' }, |
1876 row = {}; |
1848 { name: 'f_inventory', type: 'float' }, |
1877 row['m_name'] = record.name; |
1849 { name: 'f_avail', type: 'int' } |
1878 row['m_amount'] = amount / 1000; |
1850 ], |
1879 row['m_cost'] = record.cost; |
1851 addrow: function (rowid, rowdata, position, commit) { |
1880 row['m_type'] = record.type; |
1852 //console.log("fermentable addrow "+rowid); |
1881 row['m_use_use'] = record.use_use; |
1853 commit(true); |
1882 row['m_time'] = 0; |
1854 }, |
1883 row['m_amount_is_weight'] = record.amount_is_weight; |
1855 deleterow: function (rowid, commit) { |
1884 row['m_inventory'] = record.inventory; |
1856 //console.log("fermentable deleterow "+rowid); |
1885 row['m_avail'] = 1; |
1857 commit(true); |
1886 $('#miscGrid').jqxGrid('addrow', null, row); |
1858 }, |
1887 } |
1859 updaterow: function (rowid, rowdata, commit) { |
1888 } |
1860 //console.log("fermentable updaterow "+rowid); |
1889 } |
1861 commit(true); |
1890 }); |
1862 } |
1891 miscs.dataBind(); |
1863 }; |
1892 return; |
1864 var fermentableAdapter = new $.jqx.dataAdapter(fermentableSource); |
1893 } |
1865 $("#fermentableGrid").jqxGrid({ |
1894 } |
1866 width: 1240, |
1895 } |
1867 height: 470, |
1896 |
1868 source: fermentableAdapter, |
1897 |
1869 theme: theme, |
1898 // Procedure TFrmWaterAdjustment.CalcWater2; |
1870 selectionmode: 'singlerow', |
1899 function calcWater() { |
1871 showtoolbar: true, |
1900 |
1872 rendertoolbar: function (toolbar) { |
1901 console.log('calcWater()'); |
1873 var me = this; |
1902 var liters = 0, |
1874 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
1903 calcium = 0, |
1875 toolbar.append(container); |
1904 magnesium = 0, |
1876 container.append('<div style="float: left; margin-left: 165px;" id="faddrowbutton"></div>'); |
1905 sodium = 0, |
1877 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>'); |
1906 total_alkalinity = 0, |
1878 container.append('<div style="float: left; margin-left: 10px;" id="finstockbutton"></div>'); |
1907 bicarbonate = 0, |
1879 container.append('<input style="float: left; margin-left: 400px;" id="fdeleterowbutton" type="button" value="Verwijder mout" />'); |
1908 chloride = 0, |
1880 // add fermentable from dropdownlist. |
1909 sulfate = 0, |
1881 $("#faddrowbutton").jqxDropDownList({ |
1910 ph = 0, |
1882 placeHolder: "Kies mout:", |
1911 RA = 0, |
1883 theme: theme, |
1912 frac = 0, |
1884 template: "primary", |
1913 TpH = 0, |
1885 source: fermentablelist, |
1914 protonDeficit = 0, |
1886 displayMember: "name", |
1915 AT, BT, result, pK1, pK2, pK3, MolWt, AcidSG, AcidPrc, |
1887 width: 150, |
1916 r1d, r2d, f1d, f2d, f3d, |
1888 height: 27, |
1917 deltapH, deltapd, pd, n, |
1889 dropDownWidth: 500, |
1918 piCLSO4_low, piCLSO4_high, Res, |
1890 dropDownHeight: 500, |
1919 wg_calcium, wg_sodium, wg_total_alkalinity, wg_chloride, wg_sulfate, wg_bicarbonate; |
1891 renderer: function (index, label, value) { |
1920 |
1892 var datarecord = fermentablelist.records[index]; |
1921 if (dataRecord.w1_name == '') { |
1893 return datarecord.supplier+ " / " + datarecord.name + " (" + datarecord.color + " EBC)"; |
1922 return; |
1894 } |
1923 } |
1895 }); |
1924 |
1896 $("#faddrowbutton").on('select', function (event) { |
1925 // If there is a dillute water source, mix the waters. |
1897 if (event.args) { |
1926 if (dataRecord.w2_name != '') { |
1898 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; |
1927 liters = dataRecord.w1_amount + dataRecord.w2_amount; |
1899 var index = event.args.index; |
1928 calcium = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_calcium, dataRecord.w2_calcium); |
1900 var datarecord = fermentablelist.records[index]; |
1929 magnesium = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_magnesium, dataRecord.w2_magnesium); |
1901 var row = {}; |
1930 sodium = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_sodium, dataRecord.w2_sodium); |
1902 row["f_name"] = datarecord.name; |
1931 chloride = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_chloride, dataRecord.w2_chloride); |
1903 row["f_origin"] = datarecord.origin; |
1932 sulfate = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_sulfate, dataRecord.w2_sulfate); |
1904 row["f_supplier"] = datarecord.supplier; |
1933 total_alkalinity = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_total_alkalinity, dataRecord.w2_total_alkalinity); |
1905 row["f_amount"] = 0; |
1934 ph = -Math.log10(((Math.pow(10, -dataRecord.w1_ph) * dataRecord.w1_amount) + (Math.pow(10, -dataRecord.w2_ph) * dataRecord.w2_amount)) / liters); |
1906 row["f_cost"] = datarecord.cost; |
1935 } else { |
1907 row["f_type"] = datarecord.type; |
1936 liters = dataRecord.w1_amount; |
1908 row["f_yield"] = datarecord.yield; |
1937 calcium = dataRecord.w1_calcium; |
1909 row["f_color"] = datarecord.color; |
1938 magnesium = dataRecord.w1_magnesium; |
1910 row["f_coarse_fine_diff"] = datarecord.coarse_fine_diff; |
1939 sodium = dataRecord.w1_sodium; |
1911 row["f_moisture"] = datarecord.moisture; |
1940 chloride = dataRecord.w1_chloride; |
1912 row["f_diastatic_power"] = datarecord.diastatic_power; |
1941 sulfate = dataRecord.w1_sulfate; |
1913 row["f_protein"] = datarecord.protein; |
1942 total_alkalinity = dataRecord.w1_total_alkalinity; |
1914 row["f_max_in_batch"] = datarecord.max_in_batch; |
1943 ph = dataRecord.w1_ph; |
1915 row["f_graintype"] = datarecord.graintype; |
1944 } |
1916 if (datarecord.add_after_boil) { |
1945 $('#wg_amount').val(liters); |
1917 row["f_added"] = 2; // Fermentation |
1946 wg_calcium = calcium; |
1918 } else if ((datarecord.type == 1) || (datarecord.type == 4)) { // Sugar or Adjunct |
1947 $('#wg_calcium').val(Math.round(calcium * 10) / 10); |
1919 row["f_added"] = 1; // Boil |
1948 //wg_magnesium = magnesium; |
1920 } else { |
1949 $('#wg_magnesium').val(Math.round(magnesium * 10) / 10); |
1921 row["f_added"] = 0; // Mash |
1950 wg_sodium = sodium; |
1922 } |
1951 $('#wg_sodium').val(Math.round(sodium * 10) / 10); |
1923 row["f_dissolved_protein"] = datarecord.dissolved_protein; |
1952 wg_total_alkalinity = total_alkalinity; |
1924 row["f_recommend_mash"] = datarecord.recommend_mash; |
1953 $('#wg_total_alkalinity').val(Math.round(total_alkalinity * 10) / 10); |
1925 row["f_add_after_boil"] = datarecord.add_after_boil; |
1954 wg_chloride = chloride; |
1926 if (rowscount == 0) { |
1955 $('#wg_chloride').val(Math.round(chloride * 10) / 10); |
1927 // The first fermentable |
1956 wg_sulfate = sulfate; |
1928 row["f_adjust_to_total_100"] = 1; |
1957 $('#wg_sulfate').val(Math.round(sulfate * 10) / 10); |
1929 row["f_percentage"] = 100; |
1958 // Note: brouwhulp has the malts included here in the result. |
1930 } else { |
1959 //wg_ph = ph; |
1931 row["f_adjust_to_total_100"] = 0; |
1960 $('#wg_ph').val(Round(ph, 1)); |
1932 row["f_percentage"] = 0; |
1961 $('#wb_ph').val(Round(MashpH(), 1)); |
1933 } |
1962 bicarbonate = total_alkalinity * 1.22; |
1934 row["f_di_ph"] = datarecord.di_ph; |
1963 wg_bicarbonate = bicarbonate; |
1935 row["f_acid_to_ph_57"] = datarecord.acid_to_ph_57; |
1964 |
1936 row["f_inventory"] = datarecord.inventory; |
1965 // Noot: de volgende berekeningen geven bijna gelijke resultaten in Brun'water. |
1937 var commit = $("#fermentableGrid").jqxGrid('addrow', null, row); |
1966 // Calculate Ca |
1938 } |
1967 RA = parseFloat($('#wa_cacl2').jqxNumberInput('decimal')) * MMCa / MMCaCl2 + |
1939 }); |
1968 parseFloat($('#wa_caso4').jqxNumberInput('decimal')) * MMCa / MMCaSO4; |
1940 |
1969 calcium += 1000 * RA / liters; |
1941 $("#finstockbutton").jqxCheckBox({ theme: theme, height: 27 }); |
1970 |
1942 $("#finstockbutton").on('change', function (event) { |
1971 // Calculate Mg |
1943 fermentableinstock = event.args.checked; |
1972 RA = parseFloat($('#wa_mgso4').jqxNumberInput('decimal')) * MMMg / MMMgSO4; |
1944 fermentablelist.dataBind(); |
1973 magnesium += 1000 * RA / liters; |
1945 }); |
1974 |
1946 |
1975 // Calculate Na |
1947 // delete selected fermentable. |
1976 RA = parseFloat($('#wa_nacl').jqxNumberInput('decimal')) * MMNa / MMNaCl; |
1948 $("#fdeleterowbutton").jqxButton({ template: "danger", theme: theme, height: 27, width: 150 }); |
1977 sodium += 1000 * RA / liters; |
1949 $("#fdeleterowbutton").on('click', function () { |
1978 |
1950 var selectedrowindex = $("#fermentableGrid").jqxGrid('getselectedrowindex'); |
1979 // Calculate SO4 |
1951 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; |
1980 RA = parseFloat($('#wa_caso4').jqxNumberInput('decimal')) * MMSO4 / MMCaSO4 + |
1952 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
1981 parseFloat($('#wa_mgso4').jqxNumberInput('decimal')) * MMSO4 / MMMgSO4; |
1953 var id = $("#fermentableGrid").jqxGrid('getrowid', selectedrowindex); |
1982 sulfate += 1000 * RA / liters; |
1954 var percent = $('#fermentableGrid').jqxGrid('getcellvalue', id, "f_percentage"); |
1983 |
1955 var amount = $('#fermentableGrid').jqxGrid('getcellvalue', id, "f_amount"); |
1984 // Calculate Cl |
1956 var commit = $("#fermentableGrid").jqxGrid('deleterow', id); |
1985 RA = 2 * parseFloat($('#wa_cacl2').jqxNumberInput('decimal')) * MMCl / MMCaCl2 + |
1957 } |
1986 parseFloat($('#wa_nacl').jqxNumberInput('decimal')) * MMCl / MMNaCl; |
1958 rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; |
1987 chloride += 1000 * RA / liters; |
1959 if (rowscount > 1) { |
1988 // Einde noot. |
1960 if (to_100) { |
1989 |
1961 for (var i = 0; i < rowscount; i++) { |
1990 if ($('#wa_acid_name').val() < 0 || $('#wa_acid_name').val() > 3) { |
1962 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); |
1991 $('#wa_acid_name').val(0); |
1963 if (rowdata.f_adjust_to_total_100) { |
1992 dataRecord.wa_acid_name = 0; |
1964 rowdata.f_percentage += percent; |
1993 } |
1965 rowdata.f_amount += amount; |
1994 if (last_acid == '') |
1966 } |
1995 last_acid = AcidTypeData[$('#wa_acid_name').val()].nl; |
1967 } |
1996 |
1968 } else { |
1997 if ($('#wa_base_name').val() < 0 || $('#wa_base_name').val() > 3) { |
1969 calcPercentages(); |
1998 $('#wa_base_name').val(0); |
1970 } |
1999 dataRecord.wa_base_name = 0; |
1971 } else { |
2000 } |
1972 $("#fermentableGrid").jqxGrid('setcellvalue', 0, "f_percentage", 100); |
2001 if (last_base == '') |
1973 } |
2002 last_base = BaseTypeData[$('#wa_base_name').val()].nl; |
1974 calcFermentables(); |
2003 |
1975 calcIBUs(); |
2004 AT = dataRecord.wa_acid_name; |
1976 }); |
2005 BT = dataRecord.wa_base_name; |
1977 }, |
2006 |
1978 ready: function() { |
2007 result = GetAcidSpecs(AT); |
1979 calcFermentables(); |
2008 pK1 = result.pK1; |
1980 $('#jqxTabs').jqxTabs('next'); |
2009 pK2 = result.pK2; |
1981 }, |
2010 pK3 = result.pK3; |
1982 columns: [ |
2011 MolWt = result.MolWt; |
1983 { text: 'Vergistbaar ingrediënt', datafield: 'f_name', |
2012 AcidSG = result.AcidSG; |
1984 cellsrenderer: function (index, datafield, value, defaulvalue, column, rowdata) { |
2013 AcidPrc = result.AcidPrc; |
1985 return "<span style='margin: 3px; margin-top: 6px; float: left;'>" + |
2014 |
1986 rowdata.f_supplier+" / "+rowdata.f_name+" ("+rowdata.f_color+" EBC)</span>"; |
2015 if (dataRecord.calc_acid) { |
1987 } |
2016 TpH = parseFloat(dataRecord.mash_ph); |
1988 }, |
2017 protonDeficit = ProtonDeficit(TpH); |
1989 { text: 'Type', width: 100, datafield: 'f_type', |
2018 console.log('calc_acid tgt: ' + TpH + ' protonDeficit: ' + protonDeficit); |
1990 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
2019 if (protonDeficit > 0) { // Add acid |
1991 return "<span style='margin: 3px; margin-top: 6px; float: left;'>" + FermentableTypeData[value].nl + "</span>"; |
2020 $('#wa_base').val(0); |
1992 } |
2021 setWaterAgent(last_base, 0); |
1993 }, |
2022 frac = CalcFrac(TpH, pK1, pK2, pK3); |
1994 { text: 'Moment', width: 110, datafield: 'f_added', |
2023 Acid = protonDeficit / frac; |
1995 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
2024 Acid *= MolWt; // mg |
1996 return "<span style='margin: 3px; margin-top: 6px; float: left;'>" + AddedData[value].nl + "</span>"; |
2025 Acidmg = Acid; |
1997 } |
2026 Acid = Acid / AcidSG; // ml |
1998 }, |
2027 |
1999 { text:'Maxinbatch', datafield: 'f_max_in_batch', hidden: true }, |
2028 if (parseFloat($('#wa_acid_perc').jqxNumberInput('decimal')) == 0) |
2000 { text: 'Opbrengst', editable: false, datafield: 'f_yield', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
2029 $('#wa_acid_perc').val(AcidPrc); |
2001 { text: 'Gewicht Kg', datafield: 'f_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, |
2030 Acid = Acid * AcidPrc / (parseFloat($('#wa_acid_perc').jqxNumberInput('decimal')) / 100); // ml |
2002 { text: 'Voorr. Kg', datafield: 'f_inventory', width: 120, align: 'right', |
2031 console.log('Final ml: ' + Acid); |
2003 cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties, rowdata) { |
2032 $('#wa_acid').val(Math.round(Acid * 100) / 100); |
2004 var color = '#ffffff'; |
2033 setWaterAgent(AcidTypeData[AT].nl, Math.round(Acid * 100) / 100); |
2005 if (value < rowdata.f_amount) |
2034 |
2006 color = '#ff4040'; |
2035 bicarbonate = bicarbonate - protonDeficit * frac / liters; |
2007 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + |
2036 total_alkalinity = bicarbonate * 50 / 61; |
2008 color + ';">' +fermentableAdapter.formatNumber(value, "f3") + '</span>'; |
2037 } else if (protonDeficit < 0) { //Add base |
2009 } |
2038 $('#wa_acid').val(0); |
2010 }, |
2039 setWaterAgent(last_acid, 0); |
2011 { text: 'Procent', datafield: 'f_percentage', width: 90, align: 'right', |
2040 r1d = Math.pow(10, (TpH - 6.38)); |
2012 cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties, rowdata) { |
2041 r2d = Math.pow(10, (TpH - 10.38)); |
2013 var color = '#ffffff'; |
2042 f1d = 1 / (1 + r1d + r1d * r2d); |
2014 if (value > rowdata.f_max_in_batch) |
2043 f2d = f1d * r1d; |
2015 color = '#ff4040'; |
2044 f3d = f2d * r2d; |
2016 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + |
2045 switch (BT) { |
2017 color + ';">' +fermentableAdapter.formatNumber(value, "p1") + '</span>'; |
2046 case 0: RA = -protonDeficit / (f1d - f3d); //Sodiumbicarbonate, mmol totaal |
2018 } |
2047 RA = RA * MMNaHCO3 / 1000; //gram |
2019 }, |
2048 $('#wa_base').val(Round(RA, 2)); |
2020 { text: '100%', align: 'center', datafield: 'f_adjust_to_total_100', columntype: 'checkbox', width: 70 }, |
2049 setWaterAgent('NaHCO3', Round(RA, 2)); |
2021 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () { |
2050 if (liters > 0) { |
2022 return "Wijzig"; |
2051 // Na |
2023 }, buttonclick: function (row) { |
2052 RA = parseFloat($('#wa_nacl').jqxNumberInput('decimal')) * MMNa / MMNaCl + |
2024 fermentableRow = row; |
2053 parseFloat($('#wa_base').jqxNumberInput('decimal')) * MMNa / MMNaHCO3; |
2025 fermentableData = $("#fermentableGrid").jqxGrid('getrowdata', fermentableRow); |
2054 RA = 1000 * RA / liters; |
2026 $("#wf_name").val(fermentableData.f_name); |
2055 sodium = wg_sodium + RA; |
2027 $("#wf_amount").val(fermentableData.f_amount); |
2056 // HCO3 |
2028 $("#wf_percentage").val(fermentableData.f_percentage); |
2057 RA = parseFloat($('#wa_base').jqxNumberInput('decimal')) * MMHCO3 / MMNaHCO3; |
2029 $("#wf_max_in_batch").val(fermentableData.f_max_in_batch); |
2058 RA = 1000 * RA / liters; |
2030 $("#wf_adjust_to_total_100").val(fermentableData.f_adjust_to_total_100); |
2059 bicarbonate = wg_bicarbonate + RA; |
2031 $("#wf_added").val(fermentableData.f_added); |
2060 total_alkalinity = bicarbonate * 50 / 61; |
2032 // show the popup window. |
2061 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); |
2033 $("#popupFermentable").jqxWindow('open'); |
2062 } |
2034 } |
2063 break; |
2035 } |
2064 case 1: RA = -protonDeficit / (2 * f1d + f2d); // Sodiumcarbonate, mmol totaal |
2036 ] |
2065 RA = RA * MMNa2CO3 / 1000; //gram |
2037 }); |
2066 $('#wa_base').val(Round(RA, 2)); |
2038 }; |
2067 setWaterAgent('Na2CO3', Round(RA, 2)); |
2039 |
2068 if (liters > 0) { |
2040 // Inline hops editor |
2069 RA = parseFloat($('#wa_nacl').jqxNumberInput('decimal')) * MMNa / MMNaCl + |
2041 var editHop = function (data) { |
2070 parseFloat($('#wa_base').jqxNumberInput('decimal')) * 2 * MMNa / MMNa2CO3; |
2042 var hopSource = { |
2071 RA = 1000 * RA / liters; |
2043 localdata: data.hops, |
2072 sodium = wg_sodium + RA; |
2044 datatype: "local", |
2073 // HCO3 |
2045 cache: false, |
2074 RA = parseFloat($('#wa_base').jqxNumberInput('decimal')) * MMHCO3 / MMNa2CO3; |
2046 async: false, |
2075 RA = 1000 * RA / liters; |
2047 datafields: [ |
2076 bicarbonate = wg_bicarbonate + RA; |
2048 { name: 'h_name', type: 'string' }, |
2077 total_alkalinity = bicarbonate * 50 / 61; |
2049 { name: 'h_origin', type: 'string' }, |
2078 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); |
2050 { name: 'h_amount', type: 'float' }, |
2079 } |
2051 { name: 'h_cost', type: 'float' }, |
2080 break; |
2052 { name: 'h_type', type: 'int' }, |
2081 case 2: RA = -protonDeficit * (f1d - f3d); // Calciumcarbonate, mmol totaal |
2053 { name: 'h_form', type: 'int' }, |
2082 RA = RA * MMCaCO3 / 1000; //gram |
2054 { name: 'h_useat', type: 'int' }, |
2083 //but only 1/3 is effective, so add 3 times as much |
2055 { name: 'h_time', type: 'float' }, |
2084 RA = 3 * RA; |
2056 { name: 'h_alpha', type: 'float' }, |
2085 $('#wa_base').val(Round(RA, 2)); |
2057 { name: 'h_beta', type: 'float' }, |
2086 setWaterAgent('CaCO3', Round(RA, 2)); |
2058 { name: 'h_hsi', type: 'float' }, |
2087 if (liters > 0) { |
2059 { name: 'h_humulene', type: 'float' }, |
2088 //Bicarbonate |
2060 { name: 'h_caryophyllene', type: 'float' }, |
2089 RA = parseFloat($('#wa_base').jqxNumberInput('decimal')) / 3 * MMHCO3 / MMCaCO3; |
2061 { name: 'h_cohumulone', type: 'float' }, |
2090 RA = 1000 * RA / liters; |
2062 { name: 'h_myrcene', type: 'float' }, |
2091 bicarbonate = wg_bicarbonate + RA; |
2063 { name: 'h_total_oil', type: 'float' }, |
2092 total_alkalinity = bicarbonate * 50 / 61; |
2064 { name: 'h_inventory', type: 'float' }, |
2093 //Ca precipitates out as Ca10(PO4)6(OH)2 |
2065 { name: 'h_avail', type: 'int' } |
2094 RA = parseFloat($('#wa_cacl2').jqxNumberInput('decimal')) * MMCa / MMCaCl2 + |
2066 ], |
2095 parseFloat($('#wa_caso4').jqxNumberInput('decimal')) * MMCa / MMCaSO4 + |
2067 addrow: function (rowid, rowdata, position, commit) { |
2096 parseFloat($('#wa_base').jqxNumberInput('decimal')) * MMCa / MMCaCO3; |
2068 console.log("hop addrow "+rowid); |
2097 RA = 1000 * RA / liters; |
2069 commit(true); |
2098 calcium = wg_calcium + RA; |
2070 }, |
2099 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); |
2071 deleterow: function (rowid, commit) { |
2100 } |
2072 console.log("hop deleterow "+rowid); |
2101 break; |
2073 commit(true); |
2102 case 3: RA = -protonDeficit / 19.3; // Calciumhydroxide |
2074 }, |
2103 $('#wa_base').val(Round(RA, 2)); |
2075 updaterow: function (rowid, rowdata, commit) { |
2104 setWaterAgent('Ca(OH)2', Round(RA, 2)); |
2076 console.log("hop updaterow "+rowid); |
2105 if (liters > 0) { |
2077 commit(true); |
2106 // Bicarbonate |
2078 } |
2107 RA = -protonDeficit / liters; |
2079 }; |
2108 total_alkalinity = wg_total_alkalinity + RA; |
2080 var hopAdapter = new $.jqx.dataAdapter(hopSource); |
2109 bicarbonate = total_alkalinity * 61 / 50; |
2081 $("#hopGrid").jqxGrid({ |
2110 // Calcium |
2082 width: 1240, |
2111 RA = parseFloat($('#wa_cacl2').jqxNumberInput('decimal')) * MMCa / MMCaCl2 + |
2083 height: 560, |
2112 parseFloat($('#wa_caso4').jqxNumberInput('decimal')) * MMCa / MMCaSO4 + |
2084 source: hopAdapter, |
2113 parseFloat($('#wa_base').jqxNumberInput('decimal')) * MMCa / MMCaOH2; |
2085 theme: theme, |
2114 RA = 1000 * RA / liters; |
2086 selectionmode: 'singlerow', |
2115 calcium = wg_calcium + RA; |
2087 showtoolbar: true, |
2116 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); |
2088 rendertoolbar: function (toolbar) { |
2117 } |
2089 var me = this; |
2118 break; |
2090 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
2119 } |
2091 toolbar.append(container); |
2120 } |
2092 container.append('<div style="float: left; margin-left: 165px;" id="haddrowbutton"></div>'); |
2121 ph = TpH; |
2093 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>'); |
2122 $('#wb_ph').val(Math.round(ph * 10) / 10); |
2094 container.append('<div style="float: left; margin-left: 10px;" id="hinstockbutton"></div>'); |
2123 } else { // Manual |
2095 container.append('<input style="float: left; margin-left: 400px;" id="hdeleterowbutton" type="button" value="Verwijder hop" />'); |
2124 console.log('calc_acid no'); |
2096 // add hop from dropdownlist. |
2125 // First add base salts |
2097 $("#haddrowbutton").jqxDropDownList({ |
2126 if (parseFloat($('#wa_base').jqxNumberInput('decimal')) > 0) { |
2098 placeHolder: "Kies hop:", |
2127 if (liters > 0) { |
2099 theme: theme, |
2128 switch (BT) { |
2100 template: "primary", |
2129 case 0: // Sodiumbicarbonate, Na |
2101 source: hoplist, |
2130 RA = parseFloat($('#wa_nacl').jqxNumberInput('decimal')) * MMNa / MMNaCl + |
2102 displayMember: "name", |
2131 parseFloat($('#wa_base').jqxNumberInput('decimal')) * MMNa / MMNaHCO3; |
2103 width: 150, |
2132 RA = 1000 * RA / liters; |
2104 height: 27, |
2133 sodium = wg_sodium + RA; |
2105 dropDownWidth: 500, |
2134 // HCO3 |
2106 dropDownHeight: 500, |
2135 RA = parseFloat($('#wa_base').jqxNumberInput('decimal')) * MMHCO3 / MMNaHCO3; |
2107 renderer: function (index, label, value) { |
2136 RA = 1000 * RA / liters; |
2108 var datarecord = hoplist.records[index]; |
2137 bicarbonate = wg_bicarbonate + RA; |
2109 return datarecord.origin+ " / " + datarecord.name + " (" + datarecord.alpha + "% α)"; |
2138 total_alkalinity = bicarbonate * 50 / 61; |
2110 } |
2139 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); |
2111 }); |
2140 break; |
2112 $("#haddrowbutton").on('select', function (event) { |
2141 case 1: // Sodiumcarbonate |
2113 if (event.args) { |
2142 RA = parseFloat($('#wa_nacl').jqxNumberInput('decimal')) * MMNa / MMNaCl + |
2114 var index = event.args.index; |
2143 parseFloat($('#wa_base').jqxNumberInput('decimal')) * 2 * MMNa / MMNa2CO3; |
2115 var datarecord = hoplist.records[index]; |
2144 RA = 1000 * RA / liters; |
2116 var row = {}; |
2145 sodium = wg_sodium + RA; |
2117 row["h_name"] = datarecord.name; |
2146 // HCO3 |
2118 row["h_origin"] = datarecord.origin; |
2147 RA = parseFloat($('#wa_base').jqxNumberInput('decimal')) * MMHCO3 / MMNa2CO3; |
2119 row["h_amount"] = 0; |
2148 RA = 1000 * RA / liters; |
2120 row["h_cost"] = datarecord.cost; |
2149 bicarbonate = wg_bicarbonate + RA; |
2121 row["h_type"] = datarecord.type; |
2150 total_alkalinity = bicarbonate * 50 / 61; |
2122 row["h_form"] = datarecord.form; |
2151 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); |
2123 row["h_useat"] = 2; // Boil |
2152 break; |
2124 row["h_time"] = 0; |
2153 case 2: // Calciumcarbonate: Bicarbonate |
2125 row["h_alpha"] = datarecord.alpha; |
2154 RA = parseFloat($('#wa_base').jqxNumberInput('decimal')) / 3 * MMHCO3 / MMCaCO3; |
2126 row["h_beta"] = datarecord.beta; |
2155 RA = 1000 * RA / liters; |
2127 row["h_hsi"] = datarecord.hsi; |
2156 bicarbonate = wg_bicarbonate + RA; |
2128 row["h_humulene"] = datarecord.humulene; |
2157 total_alkalinity = bicarbonate * 50 / 61; |
2129 row["h_caryophyllene"] = datarecord.caryophyllene; |
2158 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); |
2130 row["h_cohumulone"] = datarecord.cohumulone; |
2159 // Ca |
2131 row["h_myrcene"] = datarecord.myrcene; |
2160 RA = parseFloat($('#wa_cacl2').jqxNumberInput('decimal')) * MMCa / MMCaCl2 + |
2132 row["h_total_oil"] = datarecord.total_oil; |
2161 parseFloat($('#wa_caso4').jqxNumberInput('decimal')) * MMCa / MMCaSO4 + |
2133 row["h_inventory"] = datarecord.inventory; |
2162 parseFloat($('#wa_base').jqxNumberInput('decimal')) * MMCa / MMCaCO3; |
2134 var commit = $("#hopGrid").jqxGrid('addrow', null, row); |
2163 RA = 1000 * RA / liters; |
2135 } |
2164 calcium = wg_calcium + RA; |
2136 $("#haddrowbutton").jqxDropDownList('clearSelection'); |
2165 break; |
2137 }); |
2166 } |
2138 |
2167 } |
2139 $("#hinstockbutton").jqxCheckBox({ theme: theme, height: 27 }); |
2168 } |
2140 $("#hinstockbutton").on('change', function (event) { |
2169 |
2141 hopinstock = event.args.checked; |
2170 TpH = parseFloat(dataRecord.mash_ph); |
2142 hoplist.dataBind(); |
2171 pHa = MashpH(); // This one is in demi water, should be in adjusted water??? |
2143 }); |
2172 // Then calculate the new pH with added acids |
2144 |
2173 if (parseFloat($('#wa_acid').jqxNumberInput('decimal')) > 0) { |
2145 // delete selected hop. |
2174 console.log('TpH: ' + TpH + ' water: ' + pHa); |
2146 $("#hdeleterowbutton").jqxButton({ template: "danger", theme: theme, height: 27, width: 150 }); |
2175 Acid = parseFloat($('#wa_acid').jqxNumberInput('decimal')); |
2147 $("#hdeleterowbutton").on('click', function () { |
2176 if (parseFloat($('#wa_acid_perc').jqxNumberInput('decimal')) == 0) |
2148 var selectedrowindex = $("#hopGrid").jqxGrid('getselectedrowindex'); |
2177 $('#wa_acid_perc').val(AcidPrc); |
2149 var rowscount = $("#hopGrid").jqxGrid('getdatainformation').rowscount; |
2178 Acid = Acid / AcidPrc * (parseFloat($('#wa_acid_perc').jqxNumberInput('decimal')) / 100); // ml |
2150 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
2179 Acid *= AcidSG; // ml |
2151 var id = $("#hopGrid").jqxGrid('getrowid', selectedrowindex); |
2180 Acid /= MolWt; // mg |
2152 var commit = $("#hopGrid").jqxGrid('deleterow', id); |
2181 Acidmg = Acid; |
2153 } |
2182 |
2154 calcIBUs(); |
2183 //find the pH where the protondeficit = protondeficit by the acid |
2155 }); |
2184 frac = CalcFrac(pHa, pK1, pK2, pK3); |
2156 }, |
2185 protonDeficit = Acid * frac; |
2157 ready: function() { |
2186 |
2158 calcIBUs(); |
2187 deltapH = 0.001; |
2159 $('#jqxTabs').jqxTabs('next'); |
2188 deltapd = 0.1; |
2160 }, |
2189 pd = ProtonDeficit(pHa); |
2161 columns: [ |
2190 n = 0; |
2162 { text: 'Hop', datafield: 'h_name', |
2191 while (((pd < (protonDeficit - deltapd)) || (pd > (protonDeficit + deltapd))) && (n < 2000)) { |
2163 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
2192 n++; |
2164 return "<span style='margin: 3px; margin-top: 6px; float: left;'>" +rowdata.h_origin+" / "+rowdata.h_name+"</span>"; |
2193 if (pd < (protonDeficit - deltapd)) |
2165 }, |
2194 pHa -= deltapH; |
2166 }, |
2195 else if (pd > (protonDeficit + deltapd)) |
2167 { text: 'Type', width: 90, datafield: 'h_type', |
2196 pHa += deltapH; |
2168 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
2197 frac = CalcFrac(pHa, pK1, pK2, pK3); |
2169 return '<span style="margin: 4px; margin-top: 6px; float: left;">' + HopTypeData[value].nl + '</span>'; |
2198 protonDeficit = Acid * frac; |
2170 } |
2199 pd = ProtonDeficit(pHa); |
2171 }, |
2200 } |
2172 { text: 'Vorm', width: 90, datafield: 'h_form', |
2201 console.log('n: ' + n + ' pd: ' + pd + ' protonDeficit: ' + protonDeficit + ' frac: ' + frac + ' pHa: ' + pHa); |
2173 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
2202 RA = wg_bicarbonate - protonDeficit * frac / liters; |
2174 return '<span style="margin: 4px; margin-top: 6px; float: left;">' + HopFormData[value].nl + '</span>'; |
2203 bicarbonate = RA; |
2175 } |
2204 total_alkalinity = RA * 50 / 61; |
2176 }, |
2205 ph = pHa; |
2177 { text: 'Alpha', datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
2206 $('#wb_ph').val(Round(ph, 1)); |
2178 { text: 'Gebruik', width: 110, datafield: 'h_useat', |
2207 } |
2179 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
2208 } |
2180 return '<span style="margin: 4px; margin-top: 6px; float: left;">' + HopUseData[value].nl + '</span>'; |
2209 |
2181 } |
2210 if ((AT == 3) && (liters > 0)) { // Sulfuctic / Zwavelzuur |
2182 }, |
2211 RA = parseFloat($('#wa_caso4').jqxNumberInput('decimal')) * MMSO4 / MMCaSO4 + |
2183 { text: 'Tijdsduur', datafield: 'h_time', width: 90, align: 'right', |
2212 parseFloat($('#wa_mgso4').jqxNumberInput('decimal')) * MMSO4 / MMMgSO4 + |
2184 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
2213 Acidmg / 1000 * MMSO4 / (MMSO4 + 2); |
2185 var duration = ''; |
2214 RA = 1000 * RA / liters; |
2186 if ((rowdata.h_useat == 2) || (rowdata.h_useat == 4)) // Boil, Whirlpool |
2215 sulfate = wg_sulfate + RA; // Not add to sulfate?? |
2187 duration = dataAdapter.formatNumber(value, "f0")+" min."; |
2216 } else if ((AT == 1) && (liters > 0)) { // Hydrochloric, Zoutzuur |
2188 else if (rowdata.h_useat == 5) // Dry hop |
2217 RA = parseFloat($('#wa_cacl2').jqxNumberInput('decimal')) * MMCl / MMCaCl2 + |
2189 duration = dataAdapter.formatNumber(value/1440, "f0")+" dagen"; |
2218 parseFloat($('#wa_nacl').jqxNumberInput('decimal')) * MMCl / MMNaCl + |
2190 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + duration + '</span>'; |
2219 Acidmg / 1000 * MMCl / (MMCl + 1); |
2191 } |
2220 RA = 1000 * RA / liters; |
2192 }, |
2221 chloride = wg_chloride + RA; |
2193 { text: 'IBU', datafield: 'ibu', width: 80, align: 'right', |
2222 } |
2194 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
2223 |
2195 var ibu = toIBU(rowdata.h_useat, rowdata.h_form, preboil_sg, parseFloat($("#batch_size").jqxNumberInput('decimal')), |
2224 // 2:1 Sulfate to Chroride IPA's, Pale Ales. |
2196 parseFloat(rowdata.h_amount), parseFloat(rowdata.h_time), |
2225 // 1:1 Sulfate to Chloride Balanced |
2197 parseFloat(rowdata.h_alpha), $("#ibu_method").val()); |
2226 // 1:2 Sulfate to Chloride Malty |
2198 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + dataAdapter.formatNumber(ibu, "f1") + '</span>'; |
2227 // Note, values below are the other way, cl to so4! |
2199 } |
2228 // So: 0.5 is IPA's, Pale Ales. |
2200 }, |
2229 // 1 Balanced |
2201 { text: 'Gewicht', datafield: 'h_amount', width: 110, align: 'right', |
2230 // 2 Malty. |
2202 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
2231 $('#tgt_bu').val(Math.round(GetBUGU() * 100) / 100); |
2203 var amount = dataAdapter.formatNumber(value, "f1") + ' kg'; |
2232 // From brouwhulp. |
2204 if (value < 1) |
2233 if (GetBUGU() < 0.32) |
2205 amount = dataAdapter.formatNumber(value * 1000, "f1") + ' gr'; |
2234 $('#wr_bu').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Zeer moutig en zoet</span>"); |
2206 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + amount + '</span>'; |
2235 else if (GetBUGU() < 0.43) |
2207 } |
2236 $('#wr_bu').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Moutig, zoet</span>"); |
2208 }, |
2237 else if (GetBUGU() < 0.52) |
2209 { text: 'Voorraad', datafield: 'h_inventory', width: 110, align: 'right', |
2238 $('#wr_bu').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Evenwichtig</span>"); |
2210 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
2239 else if (GetBUGU() < 0.63) |
2211 var color = '#ffffff'; |
2240 $('#wr_bu').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Licht hoppig, bitter</span>"); |
2212 if (value < rowdata.h_amount) |
2241 else |
2213 color = '#ff4040'; |
2242 $('#wr_bu').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Extra hoppig, zeer bitter</span>"); |
2214 var amount = dataAdapter.formatNumber(value, "f1") + ' kg'; |
2243 $('#tgt_cl_so4').val(Math.round(GetOptClSO4ratio() * 10) / 10); |
2215 if (value < 1) |
2244 if (sulfate > 0) |
2216 amount = dataAdapter.formatNumber(value * 1000, "f1") + ' gr'; |
2245 RA = chloride / sulfate; |
2217 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + amount + '</span>'; |
2246 else |
2218 } |
2247 RA = 10; |
2219 }, |
2248 $('#got_cl_so4').val(Math.round(RA * 10) / 10); |
2220 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () { |
2249 piCLSO4_low = 0.8 * GetOptClSO4ratio(); |
2221 return "Wijzig"; |
2250 piCLSO4_high = 1.2 * GetOptClSO4ratio(); |
2222 }, buttonclick: function (row) { |
2251 Res = 'normaal'; |
2223 hopRow = row; |
2252 if (RA < piCLSO4_low) |
2224 hopData = $("#hopGrid").jqxGrid('getrowdata', hopRow); |
2253 Res = 'laag'; |
2225 $("#wh_name").val(hopData.h_name); |
2254 else if (RA > piCLSO4_high) |
2226 $("#wh_amount").val(hopData.h_amount * 1000); |
2255 Res = 'hoog'; |
2227 var ibu = toIBU(hopData.h_useat, hopData.h_form, preboil_sg, |
2256 setRangeIndicator('cl_so4', Res); |
2228 parseFloat($("#batch_size").jqxNumberInput('decimal')), |
2257 |
2229 parseFloat(hopData.h_amount), parseFloat(hopData.h_time), |
2258 $('#wb_calcium').val(Round(calcium, 1)); |
2230 parseFloat(hopData.h_alpha), $("#ibu_method").val() |
2259 $('#wb_magnesium').val(Round(magnesium, 1)); |
2231 ); |
2260 $('#wb_sodium').val(Round(sodium, 1)); |
2232 $("#wh_ibu").val(ibu); |
2261 $('#wb_sulfate').val(Round(sulfate, 1)); |
2233 if (hopData.h_useat == 5) // Dry hop |
2262 $('#wb_chloride').val(Round(chloride, 1)); |
2234 $("#wh_time").val(hopData.h_time / 1440); |
2263 $('#wb_total_alkalinity').val(Round(total_alkalinity, 1)); |
2235 else |
2264 |
2236 $("#wh_time").val(hopData.h_time); |
2265 if (calcium < 40) { |
2237 $("#wh_useat").val(hopData.h_useat); |
2266 setRangeIndicator('calcium', 'laag'); |
2238 // show the popup window. |
2267 } else if (calcium > 150) { |
2239 $("#popupHop").jqxWindow('open'); |
2268 setRangeIndicator('calcium', 'hoog'); |
2240 } |
2269 } else { |
2241 } |
2270 setRangeIndicator('calcium', 'normaal'); |
2242 ] |
2271 } |
2243 }); |
2272 if (magnesium >= 0 && magnesium <= 30) { |
2244 }; |
2273 setRangeIndicator('magnesium', 'normaal'); |
2245 |
2274 } else { |
2246 // Inline miscs editor |
2275 setRangeIndicator('magnesium', 'hoog'); |
2247 var editMisc = function (data) { |
2276 } |
2248 var miscSource = { |
2277 if (sodium <= 150) { |
2249 localdata: data.miscs, |
2278 setRangeIndicator('sodium', 'normaal'); |
2250 datatype: "local", |
2279 } else { |
2251 cache: false, |
2280 setRangeIndicator('sodium', 'hoog'); |
2252 async: false, |
2281 } |
2253 datafields: [ |
2282 // Both chloride and sulfate should be above 50 according to |
2254 { name: 'm_name', type: 'string' }, |
2283 // John Palmer. So the Cl/SO4 ratio calculation will work. |
2255 { name: 'm_amount', type: 'float' }, |
2284 if (chloride <= 50) { |
2256 { name: 'm_cost', type: 'float' }, |
2285 setRangeIndicator('chloride', 'laag'); |
2257 { name: 'm_type', type: 'int' }, |
2286 } else if (chloride <= 100) { |
2258 { name: 'm_use_use', type: 'int' }, |
2287 setRangeIndicator('chloride', 'normaal'); |
2259 { name: 'm_time', type: 'float' }, |
2288 } else { |
2260 { name: 'm_amount_is_weight', type: 'int' }, |
2289 setRangeIndicator('chloride', 'hoog'); |
2261 { name: 'm_inventory', type: 'float' }, |
2290 } |
2262 { name: 'm_avail', type: 'int' } |
2291 if (sulfate <= 50) { |
2263 ], |
2292 setRangeIndicator('sulfate', 'laag'); |
2264 addrow: function (rowid, rowdata, position, commit) { |
2293 } else if (sulfate <= 350) { |
2265 console.log("misc addrow "+rowid); |
2294 setRangeIndicator('sulfate', 'normaal'); |
2266 commit(true); |
2295 } else { |
2267 }, |
2296 setRangeIndicator('sulfate', 'hoog'); |
2268 deleterow: function (rowid, commit) { |
2297 } |
2269 console.log("misc deleterow "+rowid); |
2298 if (ph < 5.2) { |
2270 commit(true); |
2299 setRangeIndicator('ph', 'laag'); |
2271 }, |
2300 } else if (ph > 5.6) { |
2272 updaterow: function (rowid, rowdata, commit) { |
2301 setRangeIndicator('ph', 'hoog'); |
2273 console.log("misc updaterow "+rowid); |
2302 } else { |
2274 commit(true); |
2303 setRangeIndicator('ph', 'normaal'); |
2275 } |
2304 } |
2276 }; |
2305 calcSparge(); |
2277 var miscAdapter = new $.jqx.dataAdapter(miscSource, { |
2306 } |
2278 beforeLoadComplete: function (records) { |
2307 |
2279 var data = new Array(); |
2308 |
2280 for (var i = 0; i < records.length; i++) { |
2309 function calcSparge() { |
2281 var row = records[i]; |
2310 var TargetpH, Source_pH, Source_alkalinity, r1, r2, d, f1, f3, |
2282 data.push(row); |
2311 r143, r243, d43, f143, f343, alkalinity, Ct, r1g, r2g, dg, f1g, f3g, |
2283 // Initial set water agent values. |
2312 Acid, AT, result, pK1, pK2, pK3, MolWt, AcidSG, AcidPrc, fract; |
2284 switch (row.m_name) { |
2313 |
2285 case 'CaCl2': $("#wa_cacl2").val(row.m_amount * 1000); |
2314 // Code from BrewBuddy/Brouwhulp, who got it from http://www.brewery.org/brewery/library/Acidi0,00fWaterAJD0497.html |
2286 break; |
2315 TargetpH = dataRecord.sparge_ph; |
2287 case 'CaSO4': $("#wa_caso4").val(row.m_amount * 1000); |
2316 Source_pH = dataRecord.w1_ph; |
2288 break; |
2317 Source_alkalinity = dataRecord.w1_total_alkalinity; |
2289 case 'MgSO4': $("#wa_mgso4").val(row.m_amount * 1000); |
2318 // Select watersource or fallback to the first source. |
2290 break; |
2319 if (dataRecord.sparge_source == 1) { // Source 2 |
2291 case 'NaCl': $("#wa_nacl").val(row.m_amount * 1000); |
2320 if (dataRecord.w2_ph > 0.0) { |
2292 break; |
2321 Source_pH = dataRecord.w2_ph; |
2293 case 'Melkzuur': $("#wa_acid_name").val(0); |
2322 Source_alkalinity = dataRecord.w2_total_alkalinity; |
2294 $("#wa_acid").val(row.m_amount * 1000); |
2323 } else { |
2295 $("#wa_acid_perc").val(80); |
2324 dataRecord.sparge_source = 0; // Source 1 |
2296 last_acid = 'Melkzuur'; |
2325 $('#sparge_source').val(0); |
2297 break; |
2326 } |
2298 case 'Zoutzuur': $("#wa_acid_name").val(1); |
2327 } else if (dataRecord.sparge_source == 2) { // Mixed |
2299 $("#wa_acid").val(row.m_amount * 1000); |
2328 if (dataRecord.w2_ph > 0.0) { |
2300 $("#wa_acid_perc").val(80); |
2329 Source_pH = parseFloat($('#wg_ph').jqxNumberInput('decimal')); |
2301 last_acid = 'Zoutzuur'; |
2330 Source_alkalinity = parseFloat($('#wg_total_alkalinity').jqxNumberInput('decimal')); |
2302 break; |
2331 } else { |
2303 case 'Fosforzuur': $("#wa_acid_name").val(2); |
2332 dataRecord.sparge_source = 0; |
2304 $("#wa_acid").val(row.m_amount * 1000); |
2333 $('#sparge_source').val(0); |
2305 $("#wa_acid_perc").val(80); |
2334 } |
2306 last_acid = 'Fosforzuur'; |
2335 } |
2307 break; |
2336 |
2308 case 'Zwavelzuur': $("#wa_acid_name").val(3); |
2337 // Step 1: Compute the mole fractions of carbonic (f1o), bicarbonate (f2o) and carbonate(f3o) at the water pH |
2309 $("#wa_acid").val(row.m_amount * 1000); |
2338 r1 = Math.pow(10, Source_pH - 6.38); |
2310 $("#wa_acid_perc").val(80); |
2339 r2 = Math.pow(10, Source_pH - 10.373); |
2311 last_acid = 'Zwavelzuur'; |
2340 d = 1 + r1 + r1 * r2; |
2312 break; |
2341 f1 = 1 / d; |
2313 case 'NaHCO3': $("#wa_base_name").val(0); |
2342 f3 = r1 * r2 / d; |
2314 $("#wa_base").val(row.m_amount * 1000); |
2343 |
2315 last_base = 'NaHCO3'; |
2344 //Step 2. Compute the mole fractions at pH = 4.3 (the pH which defines alkalinity) |
2316 break; |
2345 r143 = Math.pow(10, 4.3 - 6.38); |
2317 case 'Na2CO3': $("#wa_base_name").val(1); |
2346 r243 = Math.pow(10, 4.3 - 10.373); |
2318 $("#wa_base").val(row.m_amount * 1000); |
2347 d43 = 1 + r143 + r143 * r243; |
2319 last_base = 'Na2CO3'; |
2348 f143 = 1 / d43; |
2320 break; |
2349 f343 = r143 * r243 / d43; |
2321 case 'CaCO3': $("#wa_base_name").val(2); |
2350 |
2322 $("#wa_base").val(row.m_amount * 1000); |
2351 //Step 3. Convert the sample alkalinity to milliequivalents/L |
2323 last_base = 'CaCO3'; |
2352 alkalinity = Source_alkalinity / 50; |
2324 break; |
2353 //Step 4. Solve |
2325 case 'Ca(OH)2': $("#wa_base_name").val(3); |
2354 Ct = (alkalinity - 1000 * (Math.pow(10, -4.3) - Math.pow(10, -Source_pH))) / ((f143 - f1) + (f3 - f343)); |
2326 $("#wa_base").val(row.m_amount * 1000); |
2355 |
2327 last_base = 'Ca(OH)2'; |
2356 //Step 5. Compute mole fractions at desired pH |
2328 break; |
2357 r1g = Math.pow(10, TargetpH - 6.38); |
2329 } |
2358 r2g = Math.pow(10, TargetpH - 10.373); |
2330 } |
2359 dg = 1 + r1g + r1g * r2g; |
2331 return data; |
2360 f1g = 1 / dg; |
2332 }, |
2361 f3g = r1g * r2g / dg; |
2333 loadError: function(jqXHR, status, error) { |
2362 |
2334 $('#err').text(status + ' ' + error); |
2363 //Step 6. Use these to compute the milliequivalents acid required per liter (mEq/L) |
2335 }, |
2364 Acid = Ct * ((f1g - f1) + (f3 - f3g)) + Math.pow(10, -TargetpH) - Math.pow(10, -Source_pH); //mEq/l |
2336 }); |
2365 Acid += 0.01; // Add acid that would be required for distilled water. |
2337 $("#miscGrid").jqxGrid({ |
2366 if (dataRecord.sparge_acid_type < 0 || dataRecord.sparge_acid_type > 3) { |
2338 width: 1240, |
2367 dataRecord.sparge_acid_type = 0; |
2339 height: 575, |
2368 $('#sparge_acid_type').val(0); |
2340 source: miscAdapter, |
2369 } |
2341 theme: theme, |
2370 |
2342 selectionmode: 'singlerow', |
2371 //Step 8. Get the acid data. |
2343 showtoolbar: true, |
2372 AT = dataRecord.sparge_acid_type; |
2344 rendertoolbar: function (toolbar) { |
2373 result = GetAcidSpecs(AT); |
2345 var me = this; |
2374 pK1 = result.pK1; |
2346 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
2375 pK2 = result.pK2; |
2347 toolbar.append(container); |
2376 pK3 = result.pK3; |
2348 container.append('<div style="float: left; margin-left: 165px;" id="maddrowbutton"></div>'); |
2377 MolWt = result.MolWt; |
2349 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>'); |
2378 AcidSG = result.AcidSG; |
2350 container.append('<div style="float: left; margin-left: 10px;" id="minstockbutton"></div>'); |
2379 AcidPrc = result.AcidPrc; |
2351 container.append('<input style="float: left; margin-left: 400px;" id="mdeleterowbutton" type="button" value="Verwijder ingrediënt" />'); |
2380 fract = CalcFrac(TargetpH, pK1, pK2, pK3); |
2352 // add misc from dropdownlist. |
2381 |
2353 $("#maddrowbutton").jqxDropDownList({ |
2382 //Step 9. Now divide the mEq required by the "fraction". This is the required number of moles of acid. |
2354 placeHolder: "Kies ingrediënt:", |
2383 Acid /= fract; |
2355 theme: theme, |
2384 |
2356 template: "primary", |
2385 //Step 10. Multiply by molecular weight of the acid |
2357 source: misclist, |
2386 Acid *= MolWt; //mg |
2358 displayMember: "name", |
2387 |
2359 width: 150, |
2388 Acid = Acid / AcidSG; //ml ; 88% lactic solution |
2360 height: 27, |
2389 f1 = dataRecord.sparge_acid_perc; |
2361 dropDownWidth: 500, |
2390 if (f1 <= 0.1) |
2362 dropDownHeight: 500 |
2391 f1 = AcidPrc; |
2363 }); |
2392 Acid = Acid * AcidPrc / (f1 / 100); |
2364 $("#maddrowbutton").on('select', function (event) { |
2393 |
2365 if (event.args) { |
2394 Acid *= dataRecord.sparge_volume; //ml lactic acid total |
2366 var index = event.args.index; |
2395 Acid = Round(Acid, 2); |
2367 var datarecord = misclist.records[index]; |
2396 dataRecord.sparge_acid_amount = Acid / 1000; |
2368 var row = {}; |
2397 $('#sparge_acid_amount').val(Acid); |
2369 row["m_name"] = datarecord.name; |
2398 } |
2370 row["m_amount"] = 0; |
2399 |
2371 row["m_cost"] = datarecord.cost; |
2400 /* |
2372 row["m_type"] = datarecord.type; |
2401 * Change OG of recipe but keep the water volumes. |
2373 row["m_use_use"] = datarecord.use_use; |
2402 */ |
2374 row["m_time"] = 0; |
2403 function calcFermentablesFromOG(OG) { |
2375 row["m_amount_is_weight"] = datarecord.amount_is_weight; |
2404 |
2376 row["m_inventory"] = datarecord.inventory; |
2405 console.log('calcFermentablesFromOG(' + OG + ')'); |
2377 var commit = $("#miscGrid").jqxGrid('addrow', null, row); |
2406 var amount, row, d, i, sug, tot = 0, totmass = 0, rowscount, efficiency = parseFloat($('#efficiency').jqxNumberInput('decimal')); |
2378 } |
2407 sug = sg_to_plato(OG) * parseFloat($('#batch_size').jqxNumberInput('decimal')) * OG / 100; //total amount of sugars in kg |
2379 }); |
2408 rowscount = $('#fermentableGrid').jqxGrid('getdatainformation').rowscount; |
2380 $("#minstockbutton").jqxCheckBox({ theme: theme, height: 27 }); |
2409 |
2381 $("#minstockbutton").on('change', function (event) { |
2410 for (i = 0; i < rowscount; i++) { |
2382 miscinstock = event.args.checked; |
2411 row = $('#fermentableGrid').jqxGrid('getrowdata', i); |
2383 misclist.dataBind(); |
2412 if (row.f_added < 4) { |
2384 }); |
2413 d = row.f_percentage / 100 * (row.f_yield / 100) * (1 - row.f_moisture / 100); |
2385 // delete selected misc. |
2414 if (row.f_added == 0) // Mash |
2386 $("#mdeleterowbutton").jqxButton({ template: "danger", theme: theme, height: 27, width: 150 }); |
2415 d = efficiency / 100 * d; |
2387 $("#mdeleterowbutton").on('click', function () { |
2416 tot += d; |
2388 var selectedrowindex = $("#miscGrid").jqxGrid('getselectedrowindex'); |
2417 } |
2389 var rowscount = $("#miscGrid").jqxGrid('getdatainformation').rowscount; |
2418 } |
2390 var type = $("#miscGrid").jqxGrid('getcellvalue', selectedrowindex, "m_type"); |
2419 if (tot) |
2391 if (selectedrowindex >= 0 && selectedrowindex < rowscount && type != 4) { // Water agent |
2420 totmass = Math.round((sug / tot) * 1000) / 1000; |
2392 var id = $("#miscGrid").jqxGrid('getrowid', selectedrowindex); |
2421 |
2393 var commit = $("#miscGrid").jqxGrid('deleterow', id); |
2422 if (totmass) { |
2394 } |
2423 for (i = 0; i < rowscount; i++) { |
2395 }); |
2424 row = $('#fermentableGrid').jqxGrid('getrowdata', i); |
2396 }, |
2425 if (row.f_added < 4) { |
2397 ready: function() { |
2426 amount = Math.round(row.f_percentage * 10 * totmass) / 1000; |
2398 $('#jqxTabs').jqxTabs('next'); |
2427 $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_amount', amount); |
2399 }, |
2428 } |
2400 columns: [ |
2429 } |
2401 { text: 'Ingredient', datafield: 'm_name' }, |
2430 } |
2402 { text: 'Type', width: 140, datafield: 'm_type', |
2431 }; |
2403 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
2432 |
2404 return "<span style='margin: 3px; margin-top: 6px; float: left;'>" + MiscTypeData[value].nl + "</span>"; |
2433 function calcInit() { |
2405 } |
2434 console.log('calc.init()'); |
2406 }, |
2435 |
2407 { text: 'Gebruik', width: 140, datafield: 'm_use_use', |
2436 $('#calc_acid').on('checked', function(event) { |
2408 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
2437 dataRecord.calc_acid = 1; |
2409 return "<span style='margin: 3px; margin-top: 6px; float: left;'>" + MiscUseData[value].nl + "</span>"; |
2438 calcWater(); |
2410 } |
2439 }); |
2411 }, |
2440 $('#calc_acid').on('unchecked', function(event) { |
2412 { text: 'Tijd', datafield: 'm_time', width: 90, align: 'right', |
2441 dataRecord.calc_acid = 0; |
2413 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
2442 calcWater(); |
2414 var duration = ''; |
2443 }); |
2415 if (rowdata.m_use_use == 2) // Boil |
2444 $('#w1_name').jqxDropDownList('selectItem', dataRecord.w1_name); |
2416 duration = dataAdapter.formatNumber(value, "f0")+" min."; |
2445 $('#w2_name').jqxDropDownList('selectItem', dataRecord.w2_name); |
2417 else if ((rowdata.m_use_use == 3) || (rowdata.m_use_use == 4)) // Primary or Secondary |
2446 // Fix tap water if zero using mash infuse amount. |
2418 duration = dataAdapter.formatNumber(value/1440, "f0")+" dagen"; |
2447 if (parseFloat($('#w1_amount').jqxNumberInput('decimal')) == 0 && mash_infuse > 0) { |
2419 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + duration + '</span>'; |
2448 $('#w1_amount').val(mash_infuse); |
2420 }, |
2449 dataRecord.w1_amount = mash_infuse; |
2421 }, |
2450 $('#wg_amount').val(mash_infuse); |
2422 { text: 'Hoeveel', datafield: 'm_amount', width: 110, align: 'right', |
2451 $('#w2_amount').val(0); |
2423 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
2452 dataRecord.w2_amount = 0; |
2424 var vstr = rowdata.m_amount_is_weight ? "gr":"ml"; |
2453 } |
2425 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + |
2454 calcWater(); |
2426 dataAdapter.formatNumber(value * 1000,"f2")+" "+vstr + '</span>'; |
2455 $('#w2_amount').on('change', function(event) { |
2427 }, |
2456 var newval = parseFloat(event.args.value); |
2428 }, |
2457 |
2429 { text: 'Voorraad', datafield: 'm_inventory', width: 110, align: 'right', |
2458 if (newval > mash_infuse) { |
2430 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
2459 $('#w2_amount').val(dataRecord.w2_amount); |
2431 var vstr = rowdata.m_amount_is_weight ? "gr":"ml"; |
2460 return; |
2432 var color = '#ffffff'; |
2461 } |
2433 if (value < rowdata.m_amount) |
2462 dataRecord.w1_amount = parseFloat($('#wg_amount').jqxNumberInput('decimal')) - newval; |
2434 color = '#ff4040'; |
2463 $('#w1_amount').val(dataRecord.w1_amount); |
2435 var amount = dataAdapter.formatNumber(value * 1000,"f2")+" "+vstr; |
2464 dataRecord.w2_amount = newval; |
2436 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + amount + '</span>'; |
2465 console.log('new: ' + event.args.value + ' w1: ' + dataRecord.w1_amount + ' w2: ' + dataRecord.w2_amount); |
2437 }, |
2466 calcWater(); |
2438 }, |
2467 }); |
2439 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () { |
2468 $('#wa_cacl2').on('change', function(event) { |
2440 return "Wijzig"; |
2469 if (event.args) { |
2441 }, buttonclick: function (row) { |
2470 setWaterAgent('CaCl2', 0); // This can prevent double entries. |
2442 miscRow = row; |
2471 setWaterAgent('CaCl2', event.args.value); |
2443 miscData = $("#miscGrid").jqxGrid('getrowdata', miscRow); |
2472 calcWater(); |
2444 if (miscData.m_type == 4) { |
2473 } |
2445 alert("Brouwzouten wijzigen in de water tab."); |
2474 }); |
2446 } else { |
2475 $('#wa_caso4').on('change', function(event) { |
2447 if (miscData.m_amount_is_weight) |
2476 if (event.args) { |
2448 $("#wm_pmpt_amount").html("Gewicht gram:"); |
2477 setWaterAgent('CaSO4', 0); |
2449 else |
2478 setWaterAgent('CaSO4', event.args.value); |
2450 $("#wm_pmpt_amount").html("Volume ml:"); |
2479 calcWater(); |
2451 $("#wm_name").val(miscData.m_name); |
2480 } |
2452 $("#wm_amount").val(miscData.m_amount * 1000); |
2481 }); |
2453 if ((miscData.m_use_use == 3) || (miscData.m_use_use == 4)) // Primary or Secondary |
2482 $('#wa_mgso4').on('change', function(event) { |
2454 $("#wm_time").val(miscData.m_time / 1440); |
2483 if (event.args) { |
2455 else |
2484 setWaterAgent('MgSO4', 0); |
2456 $("#wm_time").val(miscData.m_time); |
2485 setWaterAgent('MgSO4', event.args.value); |
2457 $("#wm_use_use").val(miscData.m_use_use); |
2486 calcWater(); |
2458 // show the popup window. |
2487 } |
2459 $("#popupMisc").jqxWindow('open'); |
2488 }); |
2460 } |
2489 $('#wa_nacl').on('change', function(event) { |
2461 } |
2490 if (event.args) { |
2462 } |
2491 setWaterAgent('NaCl', 0); |
2463 ] |
2492 setWaterAgent('NaCl', event.args.value); |
2464 }); |
2493 calcWater(); |
2465 }; |
2494 } |
2466 |
2495 }); |
2467 // Inline yeasts editor |
2496 $('#wa_base_name').on('change', function(event) { |
2468 var editYeast = function (data) { |
2497 if (event.args) { |
2469 var yeastSource = { |
2498 var index = event.args.index; |
2470 localdata: data.yeasts, |
2499 setWaterAgent(last_base, 0); |
2471 datatype: "local", |
2500 last_base = BaseTypeData[index].nl; |
2472 cache: false, |
2501 setWaterAgent(last_base, parseFloat($('#wa_base').jqxNumberInput('decimal'))); |
2473 async: false, |
2502 dataRecord.wa_base_name = index; |
2474 datafields: [ |
2503 calcWater(); |
2475 { name: 'y_name', type: 'string' }, |
2504 } |
2476 { name: 'y_laboratory', type: 'string' }, |
2505 }); |
2477 { name: 'y_product_id', type: 'string' }, |
2506 $('#wa_base').on('change', function(event) { |
2478 { name: 'y_amount', type: 'float' }, |
2507 var name = BaseTypeData[$('#wa_base_name').val()].nl; |
2479 { name: 'y_cost', type: 'float' }, |
2508 setWaterAgent(name, parseFloat(event.args.value)); |
2480 { name: 'y_type', type: 'int' }, |
2509 calcWater(); |
2481 { name: 'y_form', type: 'int' }, |
2510 }); |
2482 { name: 'y_flocculation', type: 'int' }, |
2511 $('#wa_acid_name').on('change', function(event) { |
2483 { name: 'y_min_temperature', type: 'float' }, |
2512 if (event.args) { |
2484 { name: 'y_max_temperature', type: 'float' }, |
2513 var index = event.args.index; |
2485 { name: 'y_attenuation', type: 'float' }, |
2514 setWaterAgent(last_acid, 0); |
2486 { name: 'y_use', type: 'int' }, |
2515 last_acid = AcidTypeData[index].nl; |
2487 { name: 'y_cells', type: 'float' }, |
2516 setWaterAgent(last_acid, parseFloat($('#wa_acid').jqxNumberInput('decimal'))); |
2488 { name: 'y_tolerance', type: 'float' }, |
2517 dataRecord.wa_acid_name = index; |
2489 { name: 'y_inventory', type: 'float' }, |
2518 calcWater(); |
2490 { name: 'y_avail', type: 'int' } |
2519 } |
2491 ], |
2520 }); |
2492 addrow: function (rowid, rowdata, position, commit) { |
2521 $('#wa_acid').on('change', function(event) { |
2493 console.log("yeast addrow "+rowid); |
2522 var name = AcidTypeData[$('#wa_acid_name').val()].nl; |
2494 commit(true); |
2523 setWaterAgent(name, parseFloat(event.args.value)); |
2495 }, |
2524 calcWater(); |
2496 deleterow: function (rowid, commit) { |
2525 }); |
2497 console.log("yeast deleterow "+rowid); |
2526 $('#wa_acid_perc').on('change', function(event) { calcWater(); }); |
2498 commit(true); |
2527 |
2499 }, |
2528 $('#color_method').on('change', function(event) { |
2500 updaterow: function (rowid, rowdata, commit) { |
2529 dataRecord.color_method = event.args.index; |
2501 console.log("yeast updaterow "+rowid); |
2530 calcFermentables(); |
2502 commit(true); |
2531 }); |
2503 } |
2532 $('#ibu_method').on('change', function(event) { |
2504 }; |
2533 dataRecord.ibu_method = event.args.index; |
2505 var yeastAdapter = new $.jqx.dataAdapter(yeastSource); |
2534 calcFermentables(); |
2506 $("#yeastGrid").jqxGrid({ |
2535 calcIBUs(); |
2507 width: 1240, |
2536 }); |
2508 height: 350, |
2537 $('#batch_size').on('change', function(event) { |
2509 source: yeastAdapter, |
2538 console.log('batch_size change:' + event.args.value + ' old:' + dataRecord.batch_size); |
2510 theme: theme, |
2539 var factor, new_boil = parseFloat(event.args.value) + dataRecord.boil_size - dataRecord.batch_size; |
2511 selectionmode: 'singlerow', |
2540 factor = parseFloat(event.args.value) / dataRecord.batch_size; |
2512 showtoolbar: true, |
2541 dataRecord.boil_size = new_boil; |
2513 rendertoolbar: function (toolbar) { |
2542 $('#boil_size').val(Round(new_boil, 2)); |
2514 var me = this; |
2543 dataRecord.sparge_volume *= factor; |
2515 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
2544 $('#sparge_volume').val(dataRecord.sparge_volume); |
2516 toolbar.append(container); |
2545 dataRecord.batch_size = parseFloat(event.args.value); |
2517 container.append('<div style="float: left; margin-left: 165px;" id="yaddrowbutton"></div>'); |
2546 calcFermentablesFromOG(parseFloat($('#est_og').jqxNumberInput('decimal'))); // Keep the OG |
2518 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>'); |
2547 adjustWaters(factor); |
2519 container.append('<div style="float: left; margin-left: 10px;" id="yinstockbutton"></div>'); |
2548 calcFermentables(); |
2520 container.append('<input style="float: left; margin-left: 400px;" id="ydeleterowbutton" type="button" value="Verwijder gist" />'); |
2549 adjustHops(factor); |
2521 // add yeast from dropdownlist. |
2550 adjustMiscs(factor); |
2522 $("#yaddrowbutton").jqxDropDownList({ |
2551 adjustYeasts(factor); |
2523 placeHolder: "Kies gist:", |
2552 calcIBUs(); |
2524 theme: theme, |
2553 calcWater(); |
2525 template: "primary", |
2554 calcSparge(); |
2526 source: yeastlist, |
2555 calcMash(); |
2527 displayMember: "name", |
2556 }); |
2528 width: 150, |
2557 $('#boil_time').on('change', function(event) { |
2529 height: 27, |
2558 console.log('boil_time change:' + parseFloat(event.args.value) + ' old:' + dataRecord.boil_time); |
2530 dropDownWidth: 500, |
2559 var new_boil, new_evap, old_evap = parseFloat(dataRecord.boil_size) - parseFloat(dataRecord.batch_size); |
2531 dropDownHeight: 500, |
2560 new_evap = old_evap * (parseFloat(event.args.value) / dataRecord.boil_time); |
2532 renderer: function (index, label, value) { |
2561 new_boil = parseFloat(dataRecord.batch_size) + new_evap; |
2533 var datarecord = yeastlist.records[index]; |
2562 dataRecord.boil_time = parseFloat(event.args.value); |
2534 return datarecord.laboratory+" "+datarecord.product_id+" "+datarecord.name; |
2563 dataRecord.boil_size = new_boil; |
2535 } |
2564 $('#boil_size').val(Round(new_boil, 2)); |
2536 }); |
2565 calcFermentables(); |
2537 $("#yaddrowbutton").on('select', function (event) { |
2566 // TODO: adjust the hops, miscs, yeast, water. |
2538 if (event.args) { |
2567 calcIBUs(); |
2539 var index = event.args.index; |
2568 }); |
2540 var datarecord = yeastlist.records[index]; |
2569 $('#efficiency').on('change', function(event) { |
2541 var row = {}; |
2570 var estog = parseFloat($('#est_og').jqxNumberInput('decimal')); |
2542 row["y_name"] = datarecord.name; |
2571 dataRecord.efficiency = parseFloat(event.args.value); |
2543 row["y_laboratory"] = datarecord.laboratory; |
2572 console.log('efficiency change:' + dataRecord.efficiency); |
2544 row["y_product_id"] = datarecord.product_id; |
2573 calcFermentablesFromOG(estog); // Keep the OG |
2545 row["y_type"] = datarecord.type; |
2574 calcFermentables(); |
2546 row["y_form"] = datarecord.form; |
2575 calcIBUs(); |
2547 row["y_amount"] = 0; |
2576 }); |
2548 row["y_cost"] = datarecord.cost; |
2577 $('#est_og').on('change', function(event) { |
2549 row["y_use"] = 0; |
2578 dataRecord.est_og = parseFloat(event.args.value); |
2550 row["y_min_temperature"] = datarecord.min_temperature; |
2579 console.log('est_og change:' + dataRecord.est_og); |
2551 row["y_max_temperature"] = datarecord.max_temperature; |
2580 calcFermentablesFromOG(dataRecord.est_og); // Adjust fermentables amounts |
2552 row["y_attenuation"] = datarecord.attenuation; |
2581 calcFermentables(); // Update the recipe details |
2553 row["y_flocculation"] = datarecord.flocculation; |
2582 calcIBUs(); |
2554 row["y_cells"] = datarecord.cells; |
2583 calcMash(); |
2555 row["y_tolerance"] = datarecord.tolerance; |
2584 }); |
2556 row["y_inventory"] = datarecord.inventory; |
2585 $('#mash_ph').on('change', function(event) { |
2557 var commit = $("#yeastGrid").jqxGrid('addrow', null, row); |
2586 dataRecord.mash_ph = parseFloat(event.args.value); |
2558 } |
2587 calcWater(); |
2559 $("#yaddrowbutton").jqxDropDownList('clearSelection'); |
2588 }); |
2560 }); |
2589 |
2561 $("#yinstockbutton").jqxCheckBox({ theme: theme, height: 27 }); |
2590 $('#sparge_ph').on('change', function(event) { |
2562 $("#yinstockbutton").on('change', function (event) { |
2591 dataRecord.sparge_ph = parseFloat(event.args.value); |
2563 yeastinstock = event.args.checked; |
2592 calcSparge(); |
2564 yeastlist.dataBind(); |
2593 }); |
2565 }); |
2594 $('#sparge_volume').on('change', function(event) { |
2566 // delete selected yeast. |
2595 dataRecord.sparge_volume = parseFloat(event.args.value); |
2567 $("#ydeleterowbutton").jqxButton({ template: "danger", theme: theme, height: 27, width: 150 }); |
2596 calcSparge(); |
2568 $("#ydeleterowbutton").on('click', function () { |
2597 }); |
2569 var selectedrowindex = $("#yeastGrid").jqxGrid('getselectedrowindex'); |
2598 $('#sparge_source').on('change', function(event) { |
2570 var rowscount = $("#yeastGrid").jqxGrid('getdatainformation').rowscount; |
2599 if (event.args) { |
2571 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
2600 var index = event.args.index; |
2572 var id = $("#yeastGrid").jqxGrid('getrowid', selectedrowindex); |
2601 dataRecord.sparge_source = index; |
2573 var commit = $("#yeastGrid").jqxGrid('deleterow', id); |
2602 calcSparge(); |
2574 } |
2603 } |
2575 }); |
2604 }); |
2576 }, |
2605 $('#sparge_acid_type').on('change', function(event) { |
2577 ready: function() { |
2606 if (event.args) { |
2578 calcFermentables(); |
2607 var index = event.args.index; |
2579 $('#jqxTabs').jqxTabs('next'); |
2608 dataRecord.sparge_acid_type = index; |
2580 }, |
2609 console.log('new sparge_acid_type: ' + dataRecord.sparge_acid_type); |
2581 columns: [ |
2610 calcSparge(); |
2582 { text: 'Gist', datafield: 'y_name' }, |
2611 } |
2583 { text: 'Laboratorium', width: 150, datafield: 'y_laboratory' }, |
2612 }); |
2584 { text: 'Code', width: 90, datafield: 'y_product_id' }, |
2613 $('#sparge_acid_perc').on('change', function(event) { |
2585 { text: 'Soort', width: 100, datafield: 'y_form', |
2614 dataRecord.sparge_acid_perc = parseFloat(event.args.value); |
2586 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
2615 calcSparge(); |
2587 return '<span style="margin: 4px; margin-top: 6px; float: left;">' + YeastFormData[value].nl + '</span>'; |
2616 }); |
2588 } |
2617 $('#locked').on('checked', function(event) { |
2589 }, |
2618 dataRecord.locked = 1; |
2590 { text: 'Min. °C', width: 70, align: 'right', cellsalign: 'right', datafield: 'y_min_temperature' }, |
2619 setReadonly(true); |
2591 { text: 'Max. °C', width: 70, align: 'right', cellsalign: 'right', datafield: 'y_max_temperature' }, |
2620 }); |
2592 { text: 'Tol. %', width: 60, align: 'right', cellsalign: 'right', datafield: 'y_tolerance', |
2621 $('#locked').on('unchecked', function(event) { |
2593 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
2622 dataRecord.locked = 0; |
2594 var color = '#ffffff'; |
2623 setReadonly(false); |
2595 var amount = ""; |
2624 }); |
2596 if (value > 0) { |
2625 }; |
2597 amount = dataAdapter.formatNumber(value, "f1"); |
2626 |
2598 if (dataRecord.est_abv > value) |
2627 $('#styleSelect').jqxDropDownList({ |
2599 color = '#ff4040'; |
2628 placeHolder: 'Kies bierstijl:', |
2600 } |
2629 theme: theme, |
2601 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + amount + '</span>'; |
2630 source: styleslist, |
2602 } |
2631 displayMember: 'name', |
2603 }, |
2632 width: 180, |
2604 { text: 'Attn. %', width: 70, align: 'right', cellsalign: 'right', datafield: 'y_attenuation', cellsformat: 'f1' }, |
2633 height: 23, |
2605 { text: 'Voor', width: 120, datafield: 'y_use', |
2634 dropDownVerticalAlignment: 'top', |
2606 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
2635 dropDownWidth: 500, |
2607 return '<span style="margin: 4px; margin-top: 6px; float: left;">' + YeastUseData[value].nl + '</span>'; |
2636 dropDownHeight: 350, |
2608 } |
2637 renderer: function(index, label, value) { |
2609 }, |
2638 var datarecord = styleslist.records[index]; |
2610 { text: 'Hoeveel', datafield: 'y_amount', width: 90, align: 'right', |
2639 return datarecord.style_guide + ' ' + datarecord.style_letter + ' ' + datarecord.name; |
2611 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
2640 } |
2612 var amount = dataAdapter.formatNumber(value*1000, "f0")+" ml"; |
2641 }); |
2613 if (rowdata.y_form == 0) // Liquid |
2642 $('#styleSelect').on('select', function(event) { |
2614 amount = dataAdapter.formatNumber(value, "f0")+" pk"; |
2643 if (event.args) { |
2615 else if (rowdata.y_form == 1) // Dry |
2644 var datarecord, index = event.args.index; |
2616 amount = dataAdapter.formatNumber(value*1000, "f1")+" gr"; |
2645 datarecord = styleslist.records[index]; |
2617 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + amount + '</span>'; |
2646 $('#st_name').val(datarecord.name); |
2618 } |
2647 $('#st_category').val(datarecord.category); |
2619 }, |
2648 $('#st_category_number').val(datarecord.category_number); |
2620 { text: 'Voorraad', datafield: 'y_inventory', width: 90, align: 'right', |
2649 $('#st_letter').val(datarecord.style_letter); |
2621 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
2650 $('#st_guide').val(datarecord.style_guide); |
2622 var color = '#ffffff'; |
2651 $('#st_type').val(StyleTypeData[datarecord.type].nl); |
2623 if (value < rowdata.y_amount) |
2652 $('#st_og_min').val(datarecord.og_min); |
2624 color = '#ff4040'; |
2653 $('#st_og_max').val(datarecord.og_max); |
2625 var amount = dataAdapter.formatNumber(value*1000, "f0")+" ml"; |
2654 $('#st_fg_min').val(datarecord.fg_min); |
2626 if (rowdata.y_form == 0) // Liquid |
2655 $('#st_fg_max').val(datarecord.fg_max); |
2627 amount = dataAdapter.formatNumber(value, "f0")+" pk"; |
2656 $('#st_ibu_min').val(datarecord.ibu_min); |
2628 else if (rowdata.y_form == 1) // Dry |
2657 $('#st_ibu_max').val(datarecord.ibu_max); |
2629 amount = dataAdapter.formatNumber(value*1000, "f1")+" gr"; |
2658 $('#st_color_min').val(datarecord.color_min); |
2630 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + amount + '</span>'; |
2659 $('#st_color_max').val(datarecord.color_max); |
2631 } |
2660 $('#st_carb_min').val(datarecord.carb_min); |
2632 }, |
2661 $('#st_carb_max').val(datarecord.carb_max); |
2633 { text: '', datafield: 'Edit', columntype: 'button', width: 90, align: 'center', cellsrenderer: function () { |
2662 $('#st_abv_min').val(datarecord.abv_min); |
2634 return "Wijzig"; |
2663 $('#st_abv_max').val(datarecord.abv_max); |
2635 }, buttonclick: function (row) { |
2664 } |
2636 yeastRow = row; |
2665 }); |
2637 yeastData = $("#yeastGrid").jqxGrid('getrowdata', yeastRow); |
2666 |
2638 if (yeastData.y_form == 0) { |
2667 function saveRecord() { |
2639 $("#wy_pmpt_amount").html("Pak(ken):"); |
2668 var row = { |
2640 $("#wy_amount").val(yeastData.y_amount); |
2669 record: my_record, |
2641 $("#wy_amount").jqxNumberInput({ decimalDigits: 0 }); |
2670 uuid: dataRecord.uuid, |
2642 } else if (yeastData.y_form == 1) { |
2671 name: $('#name').val(), |
2643 $("#wy_pmpt_amount").html("Gewicht gram:"); |
2672 locked: dataRecord.locked, |
2644 $("#wy_amount").val(yeastData.y_amount * 1000); |
2673 notes: $('#notes').val(), |
2645 $("#wy_amount").jqxNumberInput({ decimalDigits: 1 }); |
2674 st_name: $('#st_name').val(), |
2646 } else { |
2675 st_letter: $('#st_letter').val(), |
2647 $("#wy_pmpt_amount").html("Volume ml:"); |
2676 st_guide: $('#st_guide').val(), |
2648 $("#wy_amount").val(yeastData.y_amount * 1000); |
2677 st_type: dataRecord.st_type, |
2649 $("#wy_amount").jqxNumberInput({ decimalDigits: 0 }); |
2678 st_category: $('#st_category').val(), |
2650 } |
2679 st_category_number: parseFloat($('#st_category_number').jqxNumberInput('decimal')), |
2651 $("#wy_name").val(yeastData.y_name); |
2680 st_og_min: parseFloat($('#st_og_min').jqxNumberInput('decimal')), |
2652 $("#wy_laboratory").val(yeastData.y_laboratory); |
2681 st_og_max: parseFloat($('#st_og_max').jqxNumberInput('decimal')), |
2653 $("#wy_product_id").val(yeastData.y_product_id); |
2682 st_fg_min: parseFloat($('#st_fg_min').jqxNumberInput('decimal')), |
2654 $("#wy_use").val(yeastData.y_use); |
2683 st_fg_max: parseFloat($('#st_fg_max').jqxNumberInput('decimal')), |
2655 // show the popup window. |
2684 st_ibu_min: parseFloat($('#st_ibu_min').jqxNumberInput('decimal')), |
2656 $("#popupYeast").jqxWindow('open'); |
2685 st_ibu_max: parseFloat($('#st_ibu_max').jqxNumberInput('decimal')), |
2657 } |
2686 st_color_min: parseFloat($('#st_color_min').jqxNumberInput('decimal')), |
2658 } |
2687 st_color_max: parseFloat($('#st_color_max').jqxNumberInput('decimal')), |
2659 ] |
2688 st_carb_min: parseFloat($('#st_carb_min').jqxNumberInput('decimal')), |
2660 }); |
2689 st_carb_max: parseFloat($('#st_carb_max').jqxNumberInput('decimal')), |
2661 }; |
2690 st_abv_min: parseFloat($('#st_abv_min').jqxNumberInput('decimal')), |
2662 |
2691 st_abv_max: parseFloat($('#st_abv_max').jqxNumberInput('decimal')), |
2663 // inline mash editor |
2692 type: $('#type').val(), |
2664 var editMash = function (data) { |
2693 batch_size: parseFloat($('#batch_size').jqxNumberInput('decimal')), |
2665 var generaterow = function () { |
2694 boil_size: parseFloat($('#boil_size').jqxNumberInput('decimal')), |
2666 var row = {}; |
2695 boil_time: parseFloat($('#boil_time').jqxNumberInput('decimal')), |
2667 row["step_name"] = "Stap 1"; |
2696 efficiency: parseFloat($('#efficiency').jqxNumberInput('decimal')), |
2668 row["step_type"] = 0; |
2697 est_og: parseFloat($('#est_og').jqxNumberInput('decimal')), |
2669 row["step_infuse_amount"] = 15; |
2698 est_fg: parseFloat($('#est_fg').jqxNumberInput('decimal')), |
2670 row["step_temp"] = 62.0; |
2699 est_abv: parseFloat($('#est_abv').jqxNumberInput('decimal')), |
2671 row['step_time'] = 20.0; |
2700 est_color: parseFloat($('#est_color').jqxNumberInput('decimal')), |
2672 row['step_thickness'] = 0; |
2701 color_method: $('#color_method').val(), |
2673 row['ramp_time'] = 1.0; |
2702 est_ibu: parseFloat($('#est_ibu').jqxNumberInput('decimal')), |
2674 row['end_temp'] = 62.0; |
2703 ibu_method: $('#ibu_method').val(), |
2675 return row; |
2704 est_carb: parseFloat($('#est_carb').jqxNumberInput('decimal')), |
2676 } |
2705 mash_name: $('#mash_name').val(), |
2677 var mashSource = { |
2706 mash_ph: parseFloat($('#mash_ph').jqxNumberInput('decimal')), |
2678 localdata: data.mashs, |
2707 sparge_temp: parseFloat($('#sparge_temp').jqxNumberInput('decimal')), |
2679 datatype: "local", |
2708 sparge_ph: parseFloat($('#sparge_ph').jqxNumberInput('decimal')), |
2680 cache: false, |
2709 sparge_volume: parseFloat($('#sparge_volume').jqxNumberInput('decimal')), |
2681 async: false, |
2710 sparge_source: $('#sparge_source').val(), |
2682 datafields: [ |
2711 sparge_acid_type: $('#sparge_acid_type').val(), |
2683 { name: 'step_name', type: 'string' }, |
2712 sparge_acid_perc: parseFloat($('#sparge_acid_perc').jqxNumberInput('decimal')), |
2684 { name: 'step_type', type: 'int' }, |
2713 sparge_acid_amount: dataRecord.sparge_acid_amount, |
2685 { name: 'step_infuse_amount', type: 'float' }, |
2714 calc_acid: dataRecord.calc_acid, |
2686 { name: 'step_temp', type: 'float' }, |
2715 w1_name: $('#w1_name').val(), |
2687 { name: 'step_time', type: 'float' }, |
2716 w1_amount: parseFloat($('#w1_amount').jqxNumberInput('decimal')), |
2688 { name: 'step_thickness', type: 'float' }, |
2717 w1_calcium: parseFloat($('#w1_calcium').jqxNumberInput('decimal')), |
2689 { name: 'ramp_time', type: 'float' }, |
2718 w1_sulfate: parseFloat($('#w1_sulfate').jqxNumberInput('decimal')), |
2690 { name: 'end_temp', type: 'float' } |
2719 w1_chloride: parseFloat($('#w1_chloride').jqxNumberInput('decimal')), |
2691 ], |
2720 w1_sodium: parseFloat($('#w1_sodium').jqxNumberInput('decimal')), |
2692 addrow: function (rowid, rowdata, position, commit) { |
2721 w1_magnesium: parseFloat($('#w1_magnesium').jqxNumberInput('decimal')), |
2693 commit(true); |
2722 w1_total_alkalinity: parseFloat($('#w1_total_alkalinity').jqxNumberInput('decimal')), |
2694 }, |
2723 w1_ph: parseFloat($('#w1_ph').jqxNumberInput('decimal')), |
2695 deleterow: function (rowid, commit) { |
2724 w1_cost: dataRecord.w1_cost, |
2696 commit(true); |
2725 w2_name: $('#w2_name').val(), |
2697 } |
2726 w2_amount: parseFloat($('#w2_amount').jqxNumberInput('decimal')), |
2698 }; |
2727 w2_calcium: parseFloat($('#w2_calcium').jqxNumberInput('decimal')), |
2699 var mashAdapter = new $.jqx.dataAdapter(mashSource, { |
2728 w2_sulfate: parseFloat($('#w2_sulfate').jqxNumberInput('decimal')), |
2700 beforeLoadComplete: function (records) { |
2729 w2_chloride: parseFloat($('#w2_chloride').jqxNumberInput('decimal')), |
2701 mash_infuse = 0; |
2730 w2_sodium: parseFloat($('#w2_sodium').jqxNumberInput('decimal')), |
2702 var data = new Array(); |
2731 w2_magnesium: parseFloat($('#w2_magnesium').jqxNumberInput('decimal')), |
2703 for (var i = 0; i < records.length; i++) { |
2732 w2_total_alkalinity: parseFloat($('#w2_total_alkalinity').jqxNumberInput('decimal')), |
2704 var row = records[i]; |
2733 w2_ph: parseFloat($('#w2_ph').jqxNumberInput('decimal')), |
2705 if (row.step_type == 0) // Infusion |
2734 w2_cost: dataRecord.w2_cost, |
2706 mash_infuse += parseFloat(row.step_infuse_amount); |
2735 wg_amount: parseFloat($('#wg_amount').jqxNumberInput('decimal')), |
2707 row.step_thickness = 0; // Init this field. |
2736 wg_calcium: parseFloat($('#wg_calcium').jqxNumberInput('decimal')), |
2708 data.push(row); |
2737 wg_sulfate: parseFloat($('#wg_sulfate').jqxNumberInput('decimal')), |
2709 } |
2738 wg_chloride: parseFloat($('#wg_chloride').jqxNumberInput('decimal')), |
2710 }, |
2739 wg_sodium: parseFloat($('#wg_sodium').jqxNumberInput('decimal')), |
2711 }); |
2740 wg_magnesium: parseFloat($('#wg_magnesium').jqxNumberInput('decimal')), |
2712 $("#mashGrid").jqxGrid({ |
2741 wg_total_alkalinity: parseFloat($('#wg_total_alkalinity').jqxNumberInput('decimal')), |
2713 width: 1240, |
2742 wg_ph: parseFloat($('#wg_ph').jqxNumberInput('decimal')), |
2714 height: 400, |
2743 wb_calcium: parseFloat($('#wb_calcium').jqxNumberInput('decimal')), |
2715 source: mashAdapter, |
2744 wb_sulfate: parseFloat($('#wb_sulfate').jqxNumberInput('decimal')), |
2716 theme: theme, |
2745 wb_chloride: parseFloat($('#wb_chloride').jqxNumberInput('decimal')), |
2717 selectionmode: 'singlerow', |
2746 wb_sodium: parseFloat($('#wb_sodium').jqxNumberInput('decimal')), |
2718 showtoolbar: true, |
2747 wb_magnesium: parseFloat($('#wb_magnesium').jqxNumberInput('decimal')), |
2719 rendertoolbar: function (toolbar) { |
2748 wb_total_alkalinity: parseFloat($('#wb_total_alkalinity').jqxNumberInput('decimal')), |
2720 var me = this; |
2749 wb_ph: parseFloat($('#wb_ph').jqxNumberInput('decimal')), |
2721 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
2750 wa_acid_name: $('#wa_acid_name').val(), |
2722 toolbar.append(container); |
2751 wa_acid_perc: parseFloat($('#wa_acid_perc').jqxNumberInput('decimal')), |
2723 container.append('<input style="float: left; margin-left: 165px;" id="saddrowbutton" type="button" value="Nieuwe stap" />'); |
2752 wa_base_name: $('#wa_base_name').val(), |
2724 container.append('<input style="float: left; margin-left: 565px;" id="sdeleterowbutton" type="button" value="Verwijder stap" />'); |
2753 fermentables: $('#fermentableGrid').jqxGrid('getrows'), |
2725 $("#saddrowbutton").jqxButton({ template: "primary", theme: theme, height: 27, width: 150 }); |
2754 hops: $('#hopGrid').jqxGrid('getrows'), |
2726 $("#saddrowbutton").on('click', function () { |
2755 miscs: $('#miscGrid').jqxGrid('getrows'), |
2727 var datarow = generaterow(); |
2756 yeasts: $('#yeastGrid').jqxGrid('getrows'), |
2728 var commit = $("#mashGrid").jqxGrid('addrow', null, datarow); |
2757 mashs: $('#mashGrid').jqxGrid('getrows') |
2729 }); |
2758 }, |
2730 // delete selected yeast. |
2759 data = 'update=true&' + $.param(row); |
2731 $("#sdeleterowbutton").jqxButton({ template: "danger", theme: theme, height: 27, width: 150 }); |
2760 $.ajax({ |
2732 $("#sdeleterowbutton").on('click', function () { |
2761 dataType: 'json', |
2733 var selectedrowindex = $("#mashGrid").jqxGrid('getselectedrowindex'); |
2762 url: url, |
2734 var rowscount = $("#mashGrid").jqxGrid('getdatainformation').rowscount; |
2763 cache: false, |
2735 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
2764 async: false, |
2736 var id = $("#mashGrid").jqxGrid('getrowid', selectedrowindex); |
2765 data: data, |
2737 var commit = $("#mashGrid").jqxGrid('deleterow', id); |
2766 type: 'POST', |
2738 } |
2767 success: function(data, status, xhr) { |
2739 }); |
2768 console.log('saveRecord() success'); |
2740 }, |
2769 }, |
2741 ready: function() { |
2770 error: function(jqXHR, textStatus, errorThrown) { |
2742 calcFermentables(); |
2771 console.log('saveRecord() error'); |
2743 calcInit(); |
2772 } |
2744 calcMash(); |
2773 }); |
2745 $('#jqxLoader').jqxLoader('close'); |
2774 }; |
2746 $('#jqxTabs').jqxTabs('first'); |
2775 |
2747 }, |
2776 dataAdapter.dataBind(); |
2748 columns: [ |
2777 |
2749 { text: 'Stap naam', datafield: 'step_name' }, |
2778 // initialize the input fields. |
2750 { text: 'Stap type', datafield: 'step_type', width: 175, |
2779 // Tab 1, Algemeen |
2751 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
2780 $('#name').jqxTooltip({ content: 'De naam voor dit recept.' }); |
2752 return "<div style='margin: 4px;'>" + MashStepTypeData[value].nl + "</div>"; |
2781 $('#name').jqxInput({ theme: theme, width: 640, height: 23 }); |
2753 } |
2782 $('#locked').jqxCheckBox({ theme: theme, width: 120, height: 23 }); |
2754 }, |
2783 $('#notes').jqxTooltip({ content: 'De uitgebreide opmerkingen over dit recept.' }); |
2755 { text: 'Start °C', datafield: 'step_temp', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
2784 $('#notes').jqxInput({ theme: theme, width: 960, height: 200 }); |
2756 { text: 'Eind °C', datafield: 'end_temp', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
2785 $('#type').jqxTooltip({ content: 'Het brouw type van dit recept.' }); |
2757 { text: 'Rust min.', datafield: 'step_time', width: 90, align: 'right', cellsalign: 'right' }, |
2786 $('#type').jqxDropDownList({ |
2758 { text: 'Stap min.', datafield: 'ramp_time', width: 90, align: 'right', cellsalign: 'right' }, |
2787 theme: theme, |
2759 { text: 'Infuse L.', datafield: 'step_infuse_amount', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
2788 source: RecipeTypeAdapter, |
2760 { text: 'L/Kg.', datafield: 'step_thickness', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f2' }, |
2789 valueMember: 'id', |
2761 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () { |
2790 displayMember: 'nl', |
2762 return "Wijzig"; |
2791 width: 180, |
2763 }, buttonclick: function (row) { |
2792 height: 23, |
2764 mashRow = row; |
2793 autoDropDownHeight: true |
2765 mashData = $("#mashGrid").jqxGrid('getrowdata', mashRow); |
2794 }); |
2766 $("#wstep_name").val(mashData.step_name); |
2795 $('#efficiency').jqxTooltip({ content: 'Het rendement van maischen en koken.' }); |
2767 $("#wstep_type").val(mashData.step_type); |
2796 $('#efficiency').jqxNumberInput(Perc1dec); |
2768 $("#wstep_infuse_amount").val(mashData.step_infuse_amount); |
2797 $('#batch_size').jqxTooltip({ content: 'Het volume van het gekoelde wort na het koken.' }); |
2769 $("#wstep_temp").val(mashData.step_temp); |
2798 $('#batch_size').jqxNumberInput(Spin1dec); |
2770 $("#wend_temp").val(mashData.end_temp); |
2799 $('#batch_size').jqxNumberInput({ min: 4 }); |
2771 $("#wstep_time").val(mashData.step_time); |
2800 $('#boil_size').jqxTooltip({ content: 'Het volume van het wort voor het koken.' }); |
2772 $("#wramp_time").val(mashData.ramp_time); |
2801 $('#boil_size').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 2, readOnly: true }); |
2773 if (mashData.step_type == 0) { |
2802 $('#boil_time').jqxTooltip({ content: 'De kooktijd in minuten.' }); |
2774 $("#wstep_infuse_amount").show(); |
2803 $('#boil_time').jqxNumberInput(PosInt); |
2775 $("#wstep_pmpt").show(); |
2804 $('#boil_time').jqxNumberInput({ min: 4, max: 360 }); |
2776 } else { |
2805 |
2777 $("#wstep_infuse_amount").hide(); |
2806 $('#st_name').jqxTooltip({ content: 'De bierstijl naam voor dit recept.'}); |
2778 $("#wstep_pmpt").hide(); |
2807 $('#st_name').jqxInput({ theme: theme, width: 250, height: 23 }); |
2779 } |
2808 $('#st_letter').jqxTooltip({ content: 'De bierstijl letter voor dit recept.'}); |
2780 // show the popup window. |
2809 $('#st_letter').jqxInput({ theme: theme, width: 90, height: 23 }); |
2781 $("#popupMash").jqxWindow('open'); |
2810 $('#st_guide').jqxTooltip({ content: 'De bierstijl gids voor dit recept.'}); |
2782 } |
2811 $('#st_guide').jqxInput({ theme: theme, width: 250, height: 23 }); |
2783 } |
2812 $('#st_category').jqxTooltip({ content: 'De Amerikaanse bierstijl categorie.'}); |
2784 ] |
2813 $('#st_category').jqxInput({ theme: theme, width: 250, height: 23 }); |
2785 }); |
2814 $('#st_category_number').jqxTooltip({ content: 'De Amerikaanse bierstijl categorie sub nummer.'}); |
2786 }; |
2815 $('#st_category_number').jqxNumberInput(Smal0dec); |
2787 |
2816 $('#st_type').jqxTooltip({ content: 'Het bierstijl type.'}); |
2788 // initialize the input fields. |
2817 $('#st_type').jqxInput({ theme: theme, width: 250, height: 23 }); |
2789 // Tab 1, Algemeen |
2818 |
2790 $("#name").jqxTooltip({ content: 'De naam voor dit recept.' }); |
2819 $('#est_og').jqxTooltip({ content: 'Het begin SG wat je wilt bereiken. De moutstort wordt automatisch herberekend.' }); |
2791 $("#name").jqxInput({ theme: theme, width: 640, height: 23 }); |
2820 $('#est_og').jqxNumberInput(SGopts); |
2792 $("#locked").jqxCheckBox({ theme: theme, width: 120, height: 23 }); |
2821 $('#st_og_min').jqxTooltip({ content: 'Het minimum begin SG voor deze bierstijl.'}); |
2793 $("#notes").jqxTooltip({ content: 'De uitgebreide opmerkingen over dit recept.' }); |
2822 $('#st_og_min').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
2794 $("#notes").jqxInput({ theme: theme, width: 960, height: 200 }); |
2823 $('#st_og_max').jqxTooltip({ content: 'Het maximum begin SG voor deze bierstijl.'}); |
2795 $("#type").jqxTooltip({ content: 'Het brouw type van dit recept.' }); |
2824 $('#st_og_max').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
2796 $("#type").jqxDropDownList({ |
2825 |
2797 theme: theme, |
2826 $('#est_fg').jqxTooltip({ content: 'Het eind SG. Dit wordt automatisch berekend.' }); |
2798 source: RecipeTypeAdapter, |
2827 $('#est_fg').jqxNumberInput(Show3dec); |
2799 valueMember: 'id', |
2828 $('#st_fg_min').jqxTooltip({ content: 'Het minimum eind SG voor deze bierstijl.'}); |
2800 displayMember: 'nl', |
2829 $('#st_fg_min').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
2801 width: 180, |
2830 $('#st_fg_max').jqxTooltip({ content: 'Het maximum eind SG voor deze bierstijl.'}); |
2802 height: 23, |
2831 $('#st_fg_max').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
2803 autoDropDownHeight: true |
2832 |
2804 }); |
2833 $('#est_abv').jqxTooltip({ content: 'Alcohol volume %. Dit wordt automatisch berekend.' }); |
2805 $("#efficiency").jqxTooltip({ content: 'Het rendement van maischen en koken.' }); |
2834 $('#est_abv').jqxNumberInput(Smal1dec); |
2806 $("#efficiency").jqxNumberInput( Perc1dec ); |
2835 $('#st_abv_min').jqxTooltip({ content: 'Het minimum alcohol volume % voor deze bierstijl.'}); |
2807 $("#batch_size").jqxTooltip({ content: 'Het volume van het gekoelde wort na het koken.' }); |
2836 $('#st_abv_min').jqxNumberInput(Smal1dec); |
2808 $("#batch_size").jqxNumberInput( Spin1dec ); |
2837 $('#st_abv_max').jqxTooltip({ content: 'Het maximum alcohol volume % voor deze bierstijl.'}); |
2809 $("#batch_size").jqxNumberInput({ min: 4 }); |
2838 $('#st_abv_max').jqxNumberInput(Smal1dec); |
2810 $("#boil_size").jqxTooltip({ content: 'Het volume van het wort voor het koken.' }); |
2839 |
2811 $("#boil_size").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 2, readOnly: true }); |
2840 $('#est_color').jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' }); |
2812 $("#boil_time").jqxTooltip({ content: 'De kooktijd in minuten.' }); |
2841 $('#est_color').jqxNumberInput(Show0dec); |
2813 $("#boil_time").jqxNumberInput( PosInt ); |
2842 $('#st_color_min').jqxTooltip({ content: 'De minimum kleur voor deze bierstijl.'}); |
2814 $("#boil_time").jqxNumberInput({ min: 4, max: 360 }); |
2843 $('#st_color_min').jqxNumberInput(Smal0dec); |
2815 |
2844 $('#st_color_max').jqxTooltip({ content: 'De maximum kleur voor deze bierstijl.'}); |
2816 $("#st_name").jqxTooltip({ content: 'De bierstijl naam voor dit recept.'}); |
2845 $('#st_color_max').jqxNumberInput(Smal0dec); |
2817 $("#st_name").jqxInput({ theme: theme, width: 250, height: 23 }); |
2846 $('#color_method').jqxDropDownList({ |
2818 $("#st_letter").jqxTooltip({ content: 'De bierstijl letter voor dit recept.'}); |
2847 theme: theme, |
2819 $("#st_letter").jqxInput({ theme: theme, width: 90, height: 23 }); |
2848 source: ColorMethodAdapter, |
2820 $("#st_guide").jqxTooltip({ content: 'De bierstijl gids voor dit recept.'}); |
2849 valueMember: 'id', |
2821 $("#st_guide").jqxInput({ theme: theme, width: 250, height: 23 }); |
2850 displayMember: 'nl', |
2822 $("#st_category").jqxTooltip({ content: 'De Amerikaanse bierstijl categorie.'}); |
2851 width: 180, |
2823 $("#st_category").jqxInput({ theme: theme, width: 250, height: 23 }); |
2852 height: 23, |
2824 $("#st_category_number").jqxTooltip({ content: 'De Amerikaanse bierstijl categorie sub nummer.'}); |
2853 autoDropDownHeight: true |
2825 $("#st_category_number").jqxNumberInput( Smal0dec ); |
2854 }); |
2826 $("#st_type").jqxTooltip({ content: 'Het bierstijl type.'}); |
2855 $('#est_ibu').jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' }); |
2827 $("#st_type").jqxInput({ theme: theme, width: 250, height: 23 }); |
2856 $('#est_ibu').jqxNumberInput(Show0dec); |
2828 |
2857 $('#st_ibu_min').jqxTooltip({ content: 'De minimum bitterheid voor deze bierstijl.'}); |
2829 $("#est_og").jqxTooltip({ content: 'Het begin SG wat je wilt bereiken. De moutstort wordt automatisch herberekend.' }); |
2858 $('#st_ibu_min').jqxNumberInput(Smal0dec); |
2830 $("#est_og").jqxNumberInput( SGopts ); |
2859 $('#st_ibu_max').jqxTooltip({ content: 'De maximum bitterheid voor deze bierstijl.'}); |
2831 $("#st_og_min").jqxTooltip({ content: 'Het minimum begin SG voor deze bierstijl.'}); |
2860 $('#st_ibu_max').jqxNumberInput(Smal0dec); |
2832 $("#st_og_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
2861 $('#ibu_method').jqxDropDownList({ |
2833 $("#st_og_max").jqxTooltip({ content: 'Het maximum begin SG voor deze bierstijl.'}); |
2862 theme: theme, |
2834 $("#st_og_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
2863 source: IBUmethodAdapter, |
2835 |
2864 valueMember: 'id', |
2836 $("#est_fg").jqxTooltip({ content: 'Het eind SG. Dit wordt automatisch berekend.' }); |
2865 displayMember: 'nl', |
2837 $("#est_fg").jqxNumberInput( Show3dec ); |
2866 width: 180, |
2838 $("#st_fg_min").jqxTooltip({ content: 'Het minimum eind SG voor deze bierstijl.'}); |
2867 height: 23, |
2839 $("#st_fg_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
2868 autoDropDownHeight: true, |
2840 $("#st_fg_max").jqxTooltip({ content: 'Het maximum eind SG voor deze bierstijl.'}); |
2869 dropDownVerticalAlignment: 'top' |
2841 $("#st_fg_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
2870 }); |
2842 |
2871 $('#kcal').jqxTooltip({ content: 'Energie-inhoud in kcal/liter.' }); |
2843 $("#est_abv").jqxTooltip({ content: 'Alcohol volume %. Dit wordt automatisch berekend.' }); |
2872 $('#kcal').jqxNumberInput(Smal0dec); |
2844 $("#est_abv").jqxNumberInput( Smal1dec ); |
2873 $('#est_carb').jqxTooltip({ content: 'Koolzuur volume. Dit wordt automatisch berekend.' }); |
2845 $("#st_abv_min").jqxTooltip({ content: 'Het minimum alcohol volume % voor deze bierstijl.'}); |
2874 $('#est_carb').jqxNumberInput(Smal1dec); |
2846 $("#st_abv_min").jqxNumberInput( Smal1dec ); |
2875 $('#st_carb_min').jqxTooltip({ content: 'Het minimum koolzuur volume voor deze bierstijl.'}); |
2847 $("#st_abv_max").jqxTooltip({ content: 'Het maximum alcohol volume % voor deze bierstijl.'}); |
2876 $('#st_carb_min').jqxNumberInput(Smal1dec); |
2848 $("#st_abv_max").jqxNumberInput( Smal1dec ); |
2877 $('#st_carb_max').jqxTooltip({ content: 'Het maximum koolzuur volume voor deze bierstijl.'}); |
2849 |
2878 $('#st_carb_max').jqxNumberInput(Smal1dec); |
2850 $("#est_color").jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' }); |
2879 |
2851 $("#est_color").jqxNumberInput( Show0dec ); |
2880 // Tab 2, Vergistbaar |
2852 $("#st_color_min").jqxTooltip({ content: 'De minimum kleur voor deze bierstijl.'}); |
2881 $('#est_color2').jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' }); |
2853 $("#st_color_min").jqxNumberInput( Smal0dec ); |
2882 $('#est_color2').jqxNumberInput(Show0dec); |
2854 $("#st_color_max").jqxTooltip({ content: 'De maximum kleur voor deze bierstijl.'}); |
2883 $('#est_og2').jqxTooltip({ content: 'Het begin SG wat je wilt bereiken. De moutstort wordt automatisch herberekend.' }); |
2855 $("#st_color_max").jqxNumberInput( Smal0dec ); |
2884 $('#est_og2').jqxNumberInput(Show3dec); |
2856 $("#color_method").jqxDropDownList({ |
2885 $('#perc_malts').jqxProgressBar({ |
2857 theme: theme, |
2886 width: 300, |
2858 source: ColorMethodAdapter, |
2887 height: 23, |
2859 valueMember: 'id', |
2888 theme: theme, |
2860 displayMember: 'nl', |
2889 showText: true, |
2861 width: 180, |
2890 max: 120, |
2862 height: 23, |
2891 animationDuration: 0, |
2863 autoDropDownHeight: true |
2892 colorRanges: [ |
2864 }); |
2893 { stop: 90, color: '#008C00' }, |
2865 $("#est_ibu").jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' }); |
2894 { stop: 100, color: '#EB7331' }, |
2866 $("#est_ibu").jqxNumberInput( Show0dec ); |
2895 { stop: 120, color: '#FF0000' } |
2867 $("#st_ibu_min").jqxTooltip({ content: 'De minimum bitterheid voor deze bierstijl.'}); |
2896 ], |
2868 $("#st_ibu_min").jqxNumberInput( Smal0dec ); |
2897 renderText: function(text) { |
2869 $("#st_ibu_max").jqxTooltip({ content: 'De maximum bitterheid voor deze bierstijl.'}); |
2898 return (Math.round(parseInt(text) * 1.2)) + '%'; |
2870 $("#st_ibu_max").jqxNumberInput( Smal0dec ); |
2899 } |
2871 $("#ibu_method").jqxDropDownList({ |
2900 }); |
2872 theme: theme, |
2901 $('#perc_sugars').jqxProgressBar({ |
2873 source: IBUmethodAdapter, |
2902 width: 300, |
2874 valueMember: 'id', |
2903 height: 23, |
2875 displayMember: 'nl', |
2904 theme: theme, |
2876 width: 180, |
2905 showText: true, |
2877 height: 23, |
2906 max: 50, |
2878 autoDropDownHeight: true, |
2907 animationDuration: 0, |
2879 dropDownVerticalAlignment: 'top' |
2908 colorRanges: [ |
2880 }); |
2909 { stop: 20, color: '#008C00' }, |
2881 $("#kcal").jqxTooltip({ content: 'Energie-inhoud in kcal/liter.' }); |
2910 { stop: 50, color: '#FF0000' } |
2882 $("#kcal").jqxNumberInput( Smal0dec ); |
2911 ], |
2883 $("#est_carb").jqxTooltip({ content: 'Koolzuur volume. Dit wordt automatisch berekend.' }); |
2912 renderText: function(text) { |
2884 $("#est_carb").jqxNumberInput( Smal1dec ); |
2913 return (Math.round(parseInt(text) * 5) / 10) + '%'; |
2885 $("#st_carb_min").jqxTooltip({ content: 'Het minimum koolzuur volume voor deze bierstijl.'}); |
2914 } |
2886 $("#st_carb_min").jqxNumberInput( Smal1dec ); |
2915 }); |
2887 $("#st_carb_max").jqxTooltip({ content: 'Het maximum koolzuur volume voor deze bierstijl.'}); |
2916 $('#perc_cara').jqxProgressBar({ |
2888 $("#st_carb_max").jqxNumberInput( Smal1dec ); |
2917 width: 300, |
2889 |
2918 height: 23, |
2890 // Tab 2, Vergistbaar |
2919 theme: theme, |
2891 $("#est_color2").jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' }); |
2920 showText: true, |
2892 $("#est_color2").jqxNumberInput( Show0dec ); |
2921 max: 50, |
2893 $("#est_og2").jqxTooltip({ content: 'Het begin SG wat je wilt bereiken. De moutstort wordt automatisch herberekend.' }); |
2922 animationDuration: 0, |
2894 $("#est_og2").jqxNumberInput( Show3dec ); |
2923 colorRanges: [ |
2895 $("#perc_malts").jqxProgressBar({ |
2924 { stop: 25, color: '#008C00' }, |
2896 width: 300, |
2925 { stop: 50, color: '#FF0000' } |
2897 height: 23, |
2926 ], |
2898 theme: theme, |
2927 renderText: function(text) { |
2899 showText: true, |
2928 return (Math.round(parseInt(text) * 5) / 10) + '%'; |
2900 max: 120, |
2929 } |
2901 animationDuration: 0, |
2930 }); |
2902 colorRanges: [ |
2931 $('#ferm_lintner').jqxProgressBar({ |
2903 { stop: 90, color: '#008C00' }, |
2932 width: 300, |
2904 { stop: 100, color: '#EB7331' }, |
2933 height: 23, |
2905 { stop: 120, color: '#FF0000' } |
2934 theme: theme, |
2906 ], |
2935 showText: true, |
2907 renderText: function (text) { |
2936 max: 200, |
2908 return (Math.round(parseInt(text) * 1.2)) + '%'; |
2937 animationDuration: 0, |
2909 } |
2938 colorRanges: [ |
2910 }); |
2939 { stop: 30, color: '#FF0000' }, |
2911 $("#perc_sugars").jqxProgressBar({ |
2940 { stop: 40, color: '#EB7331' }, |
2912 width: 300, |
2941 { stop: 200, color: '#008C00' } |
2913 height: 23, |
2942 ], |
2914 theme: theme, |
2943 renderText: function(text) { |
2915 showText: true, |
2944 return (parseInt(text) * 2) + ' lintner'; |
2916 max: 50, |
2945 } |
2917 animationDuration: 0, |
2946 }); |
2918 colorRanges: [ |
2947 $('#popupFermentable').jqxWindow({ |
2919 { stop: 20, color: '#008C00' }, |
2948 width: 800, |
2920 { stop: 50, color: '#FF0000' } |
2949 height: 300, |
2921 ], |
2950 position: { x: 230, y: 100 }, |
2922 renderText: function (text) { |
2951 resizable: false, |
2923 return (Math.round(parseInt(text) * 5) / 10) + '%'; |
2952 theme: theme, |
2924 } |
2953 isModal: true, |
2925 }); |
2954 autoOpen: false, |
2926 $("#perc_cara").jqxProgressBar({ |
2955 cancelButton: $('#FermentableReady'), |
2927 width: 300, |
2956 modalOpacity: 0.40 |
2928 height: 23, |
2957 }); |
2929 theme: theme, |
2958 $('#FermentableReady').jqxButton({ template: 'success', width: '90px', theme: theme }); |
2930 showText: true, |
2959 $('#FermentableReady').click(function() { |
2931 max: 50, |
2960 var row, rowID = $('#fermentableGrid').jqxGrid('getrowid', fermentableRow); |
2932 animationDuration: 0, |
2961 console.log('FermentableReady row:' + fermentableRow + ' ID:' + rowID); |
2933 colorRanges: [ |
2962 row = { |
2934 { stop: 25, color: '#008C00' }, |
2963 f_name: fermentableData.f_name, |
2935 { stop: 50, color: '#FF0000' } |
2964 f_origin: fermentableData.f_origin, |
2936 ], |
2965 f_supplier: fermentableData.f_supplier, |
2937 renderText: function (text) { |
2966 f_amount: fermentableData.f_amount, |
2938 return (Math.round(parseInt(text) * 5) / 10) + '%'; |
2967 f_cost: fermentableData.f_cost, |
2939 } |
2968 f_type: fermentableData.f_type, |
2940 }); |
2969 f_yield: fermentableData.f_yield, |
2941 $("#ferm_lintner").jqxProgressBar({ |
2970 f_color: fermentableData.f_color, |
2942 width: 300, |
2971 f_coarse_fine_diff: fermentableData.f_coarse_fine_diff, |
2943 height: 23, |
2972 f_moisture: fermentableData.f_moisture, |
2944 theme: theme, |
2973 f_diastatic_power: fermentableData.f_diastatic_power, |
2945 showText: true, |
2974 f_protein: fermentableData.f_protein, |
2946 max: 200, |
2975 f_max_in_batch: fermentableData.f_max_in_batch, |
2947 animationDuration: 0, |
2976 f_graintype: fermentableData.f_graintype, |
2948 colorRanges: [ |
2977 f_added: fermentableData.f_added, |
2949 { stop: 30, color: '#FF0000' }, |
2978 f_dissolved_protein: fermentableData.f_dissolved_protein, |
2950 { stop: 40, color: '#EB7331' }, |
2979 f_recommend_mash: fermentableData.f_recommend_mash, |
2951 { stop: 200, color: '#008C00' } |
2980 f_add_after_boil: fermentableData.f_add_after_boil, |
2952 ], |
2981 f_adjust_to_total_100: fermentableData.f_adjust_to_total_100, |
2953 renderText: function (text) { |
2982 f_percentage: fermentableData.f_percentage, |
2954 return (parseInt(text) * 2) + ' lintner'; |
2983 f_di_ph: fermentableData.f_di_ph, |
2955 } |
2984 f_acid_to_ph_57: fermentableData.f_acid_to_ph_57, |
2956 }); |
2985 f_inventory: fermentableData.f_inventory, |
2957 $("#popupFermentable").jqxWindow({ |
2986 f_avail: fermentableData.f_avail |
2958 width: 800, |
2987 }; |
2959 height: 300, |
2988 $('#fermentableGrid').jqxGrid('updaterow', rowID, row); |
2960 position: { x: 230, y: 100 }, |
2989 calcPercentages(); |
2961 resizable: false, |
2990 calcFermentables(); |
2962 theme: theme, |
2991 calcIBUs(); |
2963 isModal: true, |
2992 calcMash(); |
2964 autoOpen: false, |
2993 // Waters: yes there is impact. |
2965 cancelButton: $("#FermentableReady"), |
2994 }); |
2966 modalOpacity: 0.40 |
2995 $('#wf_name').jqxInput({ theme: theme, width: 320, height: 23 }); |
2967 }); |
2996 $('#wf_instock').jqxCheckBox({ theme: theme, height: 23 }); |
2968 $("#FermentableReady").jqxButton({ template: "success", width: '90px', theme: theme }); |
2997 $('#wf_instock').on('change', function(event) { |
2969 $("#FermentableReady").click(function () { |
2998 fermentableinstock = event.args.checked; |
2970 var rowID = $("#fermentableGrid").jqxGrid('getrowid', fermentableRow); |
2999 fermentablelist.dataBind(); |
2971 console.log("FermentableReady row:"+fermentableRow+" ID:"+rowID); |
3000 }); |
2972 var row = { |
3001 $('#wf_select').jqxDropDownList({ |
2973 f_name: fermentableData.f_name, |
3002 placeHolder: 'Kies mout:', |
2974 f_origin: fermentableData.f_origin, |
3003 theme: theme, |
2975 f_supplier: fermentableData.f_supplier, |
3004 source: fermentablelist, |
2976 f_amount: fermentableData.f_amount, |
3005 displayMember: 'name', |
2977 f_cost: fermentableData.f_cost, |
3006 width: 150, |
2978 f_type: fermentableData.f_type, |
3007 height: 23, |
2979 f_yield: fermentableData.f_yield, |
3008 dropDownWidth: 500, |
2980 f_color: fermentableData.f_color, |
3009 dropDownHeight: 500, |
2981 f_coarse_fine_diff: fermentableData.f_coarse_fine_diff, |
3010 renderer: function(index, label, value) { |
2982 f_moisture: fermentableData.f_moisture, |
3011 var datarecord = fermentablelist.records[index]; |
2983 f_diastatic_power: fermentableData.f_diastatic_power, |
3012 return datarecord.supplier + ' / ' + datarecord.name + ' (' + datarecord.color + ' EBC)'; |
2984 f_protein: fermentableData.f_protein, |
3013 } |
2985 f_max_in_batch: fermentableData.f_max_in_batch, |
3014 }); |
2986 f_graintype: fermentableData.f_graintype, |
3015 $('#wf_select').on('select', function(event) { |
2987 f_added: fermentableData.f_added, |
3016 if (event.args) { |
2988 f_dissolved_protein: fermentableData.f_dissolved_protein, |
3017 var datarecord, index = event.args.index; |
2989 f_recommend_mash: fermentableData.f_recommend_mash, |
3018 datarecord = fermentablelist.records[index]; |
2990 f_add_after_boil: fermentableData.f_add_after_boil, |
3019 $('#wf_name').val(datarecord.name); |
2991 f_adjust_to_total_100: fermentableData.f_adjust_to_total_100, |
3020 fermentableData.f_name = datarecord.name; |
2992 f_percentage: fermentableData.f_percentage, |
3021 fermentableData.f_origin = datarecord.origin; |
2993 f_di_ph: fermentableData.f_di_ph, |
3022 fermentableData.f_supplier = datarecord.supplier; |
2994 f_acid_to_ph_57: fermentableData.f_acid_to_ph_57, |
3023 fermentableData.f_type = datarecord.type; |
2995 f_inventory: fermentableData.f_inventory, |
3024 fermentableData.f_cost = datarecord.cost; |
2996 f_avail: fermentableData.f_avail |
3025 fermentableData.f_yield = datarecord.yield; |
2997 }; |
3026 fermentableData.f_color = datarecord.color; |
2998 $("#fermentableGrid").jqxGrid('updaterow', rowID, row); |
3027 fermentableData.f_coarse_fine_diff = datarecord.coarse_fine_diff; |
2999 calcPercentages(); |
3028 fermentableData.f_moisture = datarecord.moisture; |
3000 calcFermentables(); |
3029 fermentableData.f_diastatic_power = datarecord.diastatic_power; |
3001 calcIBUs(); |
3030 fermentableData.f_protein = datarecord.protein; |
3002 calcMash(); |
3031 fermentableData.f_max_in_batch = datarecord.max_in_batch; |
3003 // Waters: yes there is impact. |
3032 fermentableData.f_graintype = datarecord.graintype; |
3004 }); |
3033 fermentableData.f_dissolved_protein = datarecord.dissolved_protein; |
3005 $("#wf_name").jqxInput({ theme: theme, width: 320, height: 23 }); |
3034 fermentableData.f_recommend_mash = datarecord.recommend_mash; |
3006 $("#wf_instock").jqxCheckBox({ theme: theme, height: 23 }); |
3035 fermentableData.f_add_after_boil = datarecord.add_after_boil; |
3007 $("#wf_instock").on('change', function (event) { |
3036 fermentableData.f_di_ph = datarecord.di_ph; |
3008 fermentableinstock = event.args.checked; |
3037 fermentableData.f_acid_to_ph_57 = datarecord.acid_to_ph_57; |
3009 fermentablelist.dataBind(); |
3038 fermentableData.f_inventory = datarecord.inventory; |
3010 }); |
3039 } |
3011 $("#wf_select").jqxDropDownList({ |
3040 }); |
3012 placeHolder: "Kies mout:", |
3041 $('#wf_amount').jqxNumberInput(Spin3dec); |
3013 theme: theme, |
3042 $('#wf_amount').on('change', function(event) { |
3014 source: fermentablelist, |
3043 console.log('amount changed: ' + event.args.value); |
3015 displayMember: "name", |
3044 $('#fermentableGrid').jqxGrid('setcellvalue', fermentableRow, 'f_amount', event.args.value); |
3016 width: 150, |
3045 fermentableData.f_amount = event.args.value; |
3017 height: 23, |
3046 if (! to_100) { |
3018 dropDownWidth: 500, |
3047 calcPercentages(); |
3019 dropDownHeight: 500, |
3048 calcFermentables(); |
3020 renderer: function (index, label, value) { |
3049 calcMash(); |
3021 var datarecord = fermentablelist.records[index]; |
3050 } |
3022 return datarecord.supplier+ " / " + datarecord.name + " (" + datarecord.color + " EBC)"; |
3051 }); |
3023 } |
3052 $('#wf_percentage').jqxNumberInput(Perc1dec); |
3024 }); |
3053 $('#wf_percentage').on('change', function(event) { |
3025 $("#wf_select").on('select', function (event) { |
3054 var newperc, nw, damount, namount, rowscount, rowdata, diff, tw, i, newvalue, |
3026 if (event.args) { |
3055 oldvalue = Round(fermentableData.f_percentage, 1); |
3027 var index = event.args.index; |
3056 newvalue = event.args.value; |
3028 var datarecord = fermentablelist.records[index]; |
3057 console.log('percentage changed: ' + newvalue + ' old: ' + oldvalue); |
3029 $("#wf_name").val(datarecord.name); |
3058 fermentableData.f_percent = newvalue; |
3030 fermentableData.f_name = datarecord.name; |
3059 rowscount = $('#fermentableGrid').jqxGrid('getdatainformation').rowscount; |
3031 fermentableData.f_origin = datarecord.origin; |
3060 if ((oldvalue != newvalue) && (rowscount > 1)) { |
3032 fermentableData.f_supplier = datarecord.supplier; |
3061 rowdata = $('#fermentableGrid').jqxGrid('getrowdata', fermentableRow); |
3033 fermentableData.f_type = datarecord.type; |
3062 if (rowdata.f_adjust_to_total_100) { |
3034 fermentableData.f_cost = datarecord.cost; |
3063 $('#wf_percentage').val(oldvalue); |
3035 fermentableData.f_yield = datarecord.yield; |
3064 } else { |
3036 fermentableData.f_color = datarecord.color; |
3065 diff = newvalue - oldvalue; |
3037 fermentableData.f_coarse_fine_diff = datarecord.coarse_fine_diff; |
3066 tw = 0; // total weight |
3038 fermentableData.f_moisture = datarecord.moisture; |
3067 for (i = 0; i < rowscount; i++) { |
3039 fermentableData.f_diastatic_power = datarecord.diastatic_power; |
3068 rowdata = $('#fermentableGrid').jqxGrid('getrowdata', i); |
3040 fermentableData.f_protein = datarecord.protein; |
3069 if (rowdata.f_added < 4) |
3041 fermentableData.f_max_in_batch = datarecord.max_in_batch; |
3070 tw += Round(rowdata.f_amount, 3); |
3042 fermentableData.f_graintype = datarecord.graintype; |
3071 } |
3043 fermentableData.f_dissolved_protein = datarecord.dissolved_protein; |
3072 tw = Round(tw, 3); |
3044 fermentableData.f_recommend_mash = datarecord.recommend_mash; |
3073 if (to_100) { |
3045 fermentableData.f_add_after_boil = datarecord.add_after_boil; |
3074 // Adjust this row and the 100% row. |
3046 fermentableData.f_di_ph = datarecord.di_ph; |
3075 damount = Math.round(tw * diff * 10) / 1000; |
3047 fermentableData.f_acid_to_ph_57 = datarecord.acid_to_ph_57; |
3076 rowdata = $('#fermentableGrid').jqxGrid('getrowdata', fermentableRow); |
3048 fermentableData.f_inventory = datarecord.inventory; |
3077 namount = Round((rowdata.f_amount + damount), 3); |
3049 } |
3078 $('#fermentableGrid').jqxGrid('setcellvalue', fermentableRow, 'f_amount', namount); |
3050 }); |
3079 $('#wf_amount').val(namount); |
3051 $("#wf_amount").jqxNumberInput( Spin3dec ); |
3080 $('#fermentableGrid').jqxGrid('setcellvalue', fermentableRow, 'f_percentage', rowdata.f_percentage + diff); |
3052 $('#wf_amount').on('change', function (event) { |
3081 for (i = 0; i < rowscount; i++) { |
3053 console.log("amount changed: "+event.args.value); |
3082 rowdata = $('#fermentableGrid').jqxGrid('getrowdata', i); |
3054 $("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_amount', event.args.value); |
3083 if (rowdata.f_adjust_to_total_100) { |
3055 fermentableData.f_amount = event.args.value; |
3084 namount = rowdata.f_amount - damount; |
3056 if (! to_100) { |
3085 $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_percentage', rowdata.f_percentage - diff); |
3057 calcPercentages(); |
3086 $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_amount', namount); |
3058 calcFermentables(); |
3087 } |
3059 calcMash(); |
3088 } |
3060 }; |
3089 calcFermentables(); |
3061 }); |
3090 calcMash(); |
3062 $("#wf_percentage").jqxNumberInput( Perc1dec ); |
3091 } else { |
3063 $("#wf_percentage").on('change', function (event) { |
3092 // Adjust all the rows. |
3064 var oldvalue = Math.round(fermentableData.f_percentage * 10) / 10.0; |
3093 nw = tw * diff / 100; |
3065 var newvalue = event.args.value; |
3094 for (i = 0; i < rowscount; i++) { |
3066 console.log("percentage changed: "+newvalue+" old: "+oldvalue); |
3095 rowdata = $('#fermentableGrid').jqxGrid('getrowdata', i); |
3067 fermentableData.f_percent = newvalue; |
3096 if (rowdata.f_added < 4) { |
3068 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; |
3097 if (i == fermentableRow) { |
3069 if ((oldvalue != newvalue) && (rowscount > 1)) { |
3098 namount = Math.round((rowdata.f_amount + nw) * 1000) / 1000; |
3070 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', fermentableRow); |
3099 $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_amount', namount); |
3071 if (rowdata.f_adjust_to_total_100) { |
3100 // $('#wf_amount').val(namount); // Will crash the script. |
3072 $("#wf_percentage").val(oldvalue); |
3101 $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_percentage', newvalue); |
3073 } else { |
3102 } else { |
3074 var diff = newvalue - oldvalue; |
3103 namount = Round((rowdata.f_amount - (nw / (rowscount - 1))), 3); |
3075 var tw = 0; // total weight |
3104 newperc = Round((namount / tw) * 100, 1); |
3076 for (i = 0; i < rowscount; i++) { |
3105 $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_amount', namount); |
3077 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); |
3106 $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_percentage', newperc); |
3078 if (rowdata.f_added < 4) |
3107 } |
3079 tw += Math.round(rowdata.f_amount * 1000) / 1000; |
3108 } else { |
3080 } |
3109 $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_percentage', 0); |
3081 tw = Math.round(tw * 1000) / 1000; |
3110 } |
3082 if (to_100) { |
3111 } |
3083 // Adjust this row and the 100% row. |
3112 calcFermentables(); |
3084 var damount = Math.round(tw * diff *10) / 1000; |
3113 calcMash(); |
3085 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', fermentableRow); |
3114 } |
3086 var namount = Math.round((rowdata.f_amount + damount) * 1000) / 1000; |
3115 } |
3087 $("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_amount', namount); |
3116 } |
3088 $("#wf_amount").val(namount); |
3117 }); |
3089 $("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_percentage', rowdata.f_percentage + diff); |
3118 $('#wf_max_in_batch').jqxNumberInput(Show1dec); |
3090 for (i = 0; i < rowscount; i++) { |
3119 $('#wf_adjust_to_total_100').jqxCheckBox({ theme: theme, width: 120, height: 23 }); |
3091 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); |
3120 $('#wf_adjust_to_total_100').on('checked', function(event) { |
3092 if (rowdata.f_adjust_to_total_100) { |
3121 if (fermentableData.f_adjust_to_total_100 == 0) { |
3093 namount = rowdata.f_amount - damount; |
3122 if (to_100) { |
3094 $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_percentage', rowdata.f_percentage - diff); |
3123 // Reset other flag first. |
3095 $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_amount', namount); |
3124 rowscount = $('#fermentableGrid').jqxGrid('getdatainformation').rowscount; |
3096 } |
3125 for (i = 0; i < rowscount; i++) { |
3097 } |
3126 if (i != fermentableRow) { |
3098 calcFermentables(); |
3127 $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_adjust_to_total_100', 0); |
3099 cacMash(); |
3128 } |
3100 } else { |
3129 } |
3101 // Adjust all the rows. |
3130 } |
3102 var nw = tw * diff / 100; |
3131 $('#fermentableGrid').jqxGrid('setcellvalue', fermentableRow, 'f_adjust_to_total_100', 1); |
3103 for (i = 0; i < rowscount; i++) { |
3132 calcFermentables(); |
3104 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); |
3133 } |
3105 if (rowdata.f_added < 4) { |
3134 }); |
3106 if (i == fermentableRow) { |
3135 $('#wf_adjust_to_total_100').on('unchecked', function(event) { |
3107 var namount = Math.round((rowdata.f_amount + nw) * 1000) / 1000; |
3136 if (fermentableData.f_adjust_to_total_100 != 0) { |
3108 $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_amount', namount); |
3137 $('#fermentableGrid').jqxGrid('setcellvalue', fermentableRow, 'f_adjust_to_total_100', 0); |
3109 // $("#wf_amount").val(namount); // Will crash the script. |
3138 calcFermentables(); |
3110 $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_percentage', newvalue); |
3139 } |
3111 } else { |
3140 }); |
3112 var namount = Math.round((rowdata.f_amount - (nw / (rowscount - 1))) * 1000) / 1000; |
3141 $('#wf_added').jqxDropDownList({ |
3113 var newperc = Math.round((namount / tw) * 1000) / 10.0; |
3142 theme: theme, |
3114 $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_amount', namount); |
3143 source: AddedAdapter, |
3115 $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_percentage', newperc); |
3144 valueMember: 'id', |
3116 } |
3145 displayMember: 'nl', |
3117 } else { |
3146 width: 180, |
3118 $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_percentage', 0); |
3147 height: 23, |
3119 } |
3148 autoDropDownHeight: true, |
3120 } |
3149 dropDownVerticalAlignment: 'top' |
3121 calcFermentables(); |
3150 }); |
3122 calcMash(); |
3151 $('#wf_added').on('select', function(event) { |
3123 } |
3152 if (event.args) { |
3124 } |
3153 var index = event.args.index; |
3125 } |
3154 $('#fermentableGrid').jqxGrid('setcellvalue', fermentableRow, 'f_added', index); |
3126 |
3155 calcFermentables(); |
3127 }); |
3156 calcIBUs(); |
3128 $("#wf_max_in_batch").jqxNumberInput( Show1dec ); |
3157 calcMash(); |
3129 $("#wf_adjust_to_total_100").jqxCheckBox({ theme: theme, width: 120, height: 23 }); |
3158 } |
3130 $("#wf_adjust_to_total_100").on('checked', function (event) { |
3159 }); |
3131 if (fermentableData.f_adjust_to_total_100 == 0) { |
3160 |
3132 if (to_100) { |
3161 // Tab 3, Hoppen |
3133 // Reset other flag first. |
3162 $('#est_ibu2').jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' }); |
3134 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; |
3163 $('#est_ibu2').jqxNumberInput(Smal0dec); |
3135 for (var i = 0; i < rowscount; i++) { |
3164 $('#hop_flavour').jqxProgressBar({ |
3136 if (i != fermentableRow) { |
3165 width: 300, |
3137 $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_adjust_to_total_100', 0); |
3166 height: 23, |
3138 } |
3167 theme: theme, |
3139 } |
3168 showText: true, |
3140 } |
3169 animationDuration: 0, |
3141 $("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_adjust_to_total_100', 1); |
3170 colorRanges: [ |
3142 calcFermentables(); |
3171 { stop: 20, color: '#004D00' }, |
3143 } |
3172 { stop: 40, color: '#008C00' }, |
3144 }); |
3173 { stop: 60, color: '#00BF00' }, |
3145 $("#wf_adjust_to_total_100").on('unchecked', function (event) { |
3174 { stop: 80, color: '#00FF00' }, |
3146 if (fermentableData.f_adjust_to_total_100 != 0) { |
3175 { stop: 100, color: '#80FF80' } |
3147 $("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_adjust_to_total_100', 0); |
3176 ], |
3148 calcFermentables(); |
3177 renderText: function(text) { |
3149 } |
3178 var val = parseInt(text); |
3150 }); |
3179 if (val < 20) |
3151 $("#wf_added").jqxDropDownList({ |
3180 return 'Weinig'; |
3152 theme: theme, |
3181 else if (val < 40) |
3153 source: AddedAdapter, |
3182 return 'Matig'; |
3154 valueMember: 'id', |
3183 else if (val < 60) |
3155 displayMember: 'nl', |
3184 return 'Redelijk'; |
3156 width: 180, |
3185 else if (val < 80) |
3157 height: 23, |
3186 return 'Veel'; |
3158 autoDropDownHeight: true, |
3187 else |
3159 dropDownVerticalAlignment: 'top' |
3188 return 'Zeer veel'; |
3160 }); |
3189 } |
3161 $("#wf_added").on('select', function (event) { |
3190 }); |
3162 if (event.args) { |
3191 $('#hop_aroma').jqxProgressBar({ |
3163 var index = event.args.index; |
3192 width: 300, |
3164 $("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_added', index); |
3193 height: 23, |
3165 calcFermentables(); |
3194 theme: theme, |
3166 calcIBUs(); |
3195 showText: true, |
3167 calcMash(); |
3196 animationDuration: 0, |
3168 } |
3197 colorRanges: [ |
3169 }); |
3198 { stop: 20, color: '#004D00' }, |
3170 |
3199 { stop: 40, color: '#008C00' }, |
3171 // Tab 3, Hoppen |
3200 { stop: 60, color: '#00BF00' }, |
3172 $("#est_ibu2").jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' }); |
3201 { stop: 80, color: '#00FF00' }, |
3173 $("#est_ibu2").jqxNumberInput( Smal0dec ); |
3202 { stop: 100, color: '#80FF80' } |
3174 $("#hop_flavour").jqxProgressBar({ |
3203 ], |
3175 width: 300, |
3204 renderText: function(text) { |
3176 height: 23, |
3205 var val = parseInt(text); |
3177 theme: theme, |
3206 if (val < 20) |
3178 showText: true, |
3207 return 'Weinig'; |
3179 animationDuration: 0, |
3208 else if (val < 40) |
3180 colorRanges: [ |
3209 return 'Matig'; |
3181 { stop: 20, color: '#004D00' }, |
3210 else if (val < 60) |
3182 { stop: 40, color: '#008C00' }, |
3211 return 'Redelijk'; |
3183 { stop: 60, color: '#00BF00' }, |
3212 else if (val < 80) |
3184 { stop: 80, color: '#00FF00' }, |
3213 return 'Veel'; |
3185 { stop: 100, color: '#80FF80' } |
3214 else |
3186 ], |
3215 return 'Zeer veel'; |
3187 renderText: function (text) { |
3216 } |
3188 var val = parseInt(text); |
3217 }); |
3189 if (val < 20) |
3218 $('#popupHop').jqxWindow({ |
3190 return 'Weinig'; |
3219 width: 800, |
3191 else if (val < 40) |
3220 height: 300, |
3192 return 'Matig'; |
3221 position: { x: 230, y: 100 }, |
3193 else if (val < 60) |
3222 resizable: false, |
3194 return 'Redelijk'; |
3223 theme: theme, |
3195 else if (val < 80) |
3224 isModal: true, |
3196 return 'Veel'; |
3225 autoOpen: false, |
3197 else |
3226 cancelButton: $('#HopReady'), |
3198 return 'Zeer veel'; |
3227 modalOpacity: 0.40 |
3199 } |
3228 }); |
3200 }); |
3229 $('#HopReady').jqxButton({ template: 'success', width: '90px', theme: theme }); |
3201 $("#hop_aroma").jqxProgressBar({ |
3230 $('#HopReady').click(function() { |
3202 width: 300, |
3231 var row, rowID = $('#hopGrid').jqxGrid('getrowid', hopRow); |
3203 height: 23, |
3232 console.log('HopReady row:' + hopRow + ' ID:' + rowID); |
3204 theme: theme, |
3233 row = { |
3205 showText: true, |
3234 h_name: $('#wh_name').val(), |
3206 animationDuration: 0, |
3235 h_origin: hopData.h_origin, |
3207 colorRanges: [ |
3236 h_amount: parseFloat($('#wh_amount').jqxNumberInput('decimal')) / 1000, |
3208 { stop: 20, color: '#004D00' }, |
3237 h_cost: hopData.h_cost, |
3209 { stop: 40, color: '#008C00' }, |
3238 h_type: hopData.h_type, |
3210 { stop: 60, color: '#00BF00' }, |
3239 h_form: hopData.h_form, |
3211 { stop: 80, color: '#00FF00' }, |
3240 h_useat: $('#wh_useat').val(), |
3212 { stop: 100, color: '#80FF80' } |
3241 h_time: hopData.h_time, |
3213 ], |
3242 h_alpha: hopData.h_alpha, |
3214 renderText: function (text) { |
3243 h_beta: hopData.h_beta, |
3215 var val = parseInt(text); |
3244 h_hsi: hopData.h_hsi, |
3216 if (val < 20) |
3245 h_humulene: hopData.h_humulene, |
3217 return 'Weinig'; |
3246 h_caryophyllene: hopData.h_caryophyllene, |
3218 else if (val < 40) |
3247 h_cohumulone: hopData.h_cohumulone, |
3219 return 'Matig'; |
3248 h_myrcene: hopData.h_myrcene, |
3220 else if (val < 60) |
3249 h_total_oil: hopData.h_total_oil, |
3221 return 'Redelijk'; |
3250 h_inventory: hopData.h_inventory, |
3222 else if (val < 80) |
3251 h_avail: hopData.h_avail |
3223 return 'Veel'; |
3252 }; |
3224 else |
3253 $('#hopGrid').jqxGrid('updaterow', rowID, row); |
3225 return 'Zeer veel'; |
3254 calcIBUs(); |
3226 } |
3255 }); |
3227 }); |
3256 $('#wh_name').jqxInput({ theme: theme, width: 320, height: 23 }); |
3228 $("#popupHop").jqxWindow({ |
3257 $('#wh_instock').jqxCheckBox({ theme: theme, height: 23 }); |
3229 width: 800, |
3258 $('#wh_instock').on('change', function(event) { |
3230 height: 300, |
3259 hopinstock = event.args.checked; |
3231 position: { x: 230, y: 100 }, |
3260 hoplist.dataBind(); |
3232 resizable: false, |
3261 }); |
3233 theme: theme, |
3262 $('#wh_select').jqxDropDownList({ |
3234 isModal: true, |
3263 placeHolder: 'Kies hop:', |
3235 autoOpen: false, |
3264 theme: theme, |
3236 cancelButton: $("#HopReady"), |
3265 source: hoplist, |
3237 modalOpacity: 0.40 |
3266 displayMember: 'name', |
3238 }); |
3267 width: 150, |
3239 $("#HopReady").jqxButton({ template: "success", width: '90px', theme: theme }); |
3268 height: 23, |
3240 $("#HopReady").click(function () { |
3269 dropDownWidth: 500, |
3241 var rowID = $("#hopGrid").jqxGrid('getrowid', hopRow); |
3270 dropDownHeight: 500, |
3242 console.log("HopReady row:"+hopRow+" ID:"+rowID); |
3271 renderer: function(index, label, value) { |
3243 var row = { |
3272 var datarecord = hoplist.records[index]; |
3244 h_name: $("#wh_name").val(), |
3273 return datarecord.origin + ' / ' + datarecord.name + ' (' + datarecord.alpha + ' % α)'; |
3245 h_origin: hopData.h_origin, |
3274 } |
3246 h_amount: parseFloat($("#wh_amount").jqxNumberInput('decimal')) / 1000, |
3275 }); |
3247 h_cost: hopData.h_cost, |
3276 $('#wh_select').on('select', function(event) { |
3248 h_type: hopData.h_type, |
3277 if (event.args) { |
3249 h_form: hopData.h_form, |
3278 var datarecord, index = event.args.index; |
3250 h_useat: $("#wh_useat").val(), |
3279 datarecord = hoplist.records[index]; |
3251 h_time: hopData.h_time, |
3280 $('#wh_name').val(datarecord.name); |
3252 h_alpha: hopData.h_alpha, |
3281 hopData.h_name = datarecord.name; |
3253 h_beta: hopData.h_beta, |
3282 hopData.h_origin = datarecord.origin; |
3254 h_hsi: hopData.h_hsi, |
3283 hopData.h_cost = datarecord.cost; |
3255 h_humulene: hopData.h_humulene, |
3284 hopData.h_type = datarecord.type; |
3256 h_caryophyllene: hopData.h_caryophyllene, |
3285 hopData.h_form = datarecord.form; |
3257 h_cohumulone: hopData.h_cohumulone, |
3286 hopData.h_alpha = datarecord.alpha; |
3258 h_myrcene: hopData.h_myrcene, |
3287 hopData.h_beta = datarecord.beta; |
3259 h_total_oil: hopData.h_total_oil, |
3288 hopData.h_hsi = datarecord.hsi; |
3260 h_inventory: hopData.h_inventory, |
3289 hopData.h_humulene = datarecord.humulene; |
3261 h_avail: hopData.h_avail |
3290 hopData.h_caryophyllene = datarecord.caryophyllene; |
3262 }; |
3291 hopData.h_cohumulone = datarecord.cohumulone; |
3263 $("#hopGrid").jqxGrid('updaterow', rowID, row); |
3292 hopData.h_myrcene = datarecord.myrcene; |
3264 calcIBUs(); |
3293 hopData.h_total_oil = datarecord.total_oil; |
3265 }); |
3294 hopData.h_inventory = datarecord.inventory; |
3266 $("#wh_name").jqxInput({ theme: theme, width: 320, height: 23 }); |
3295 } |
3267 $("#wh_instock").jqxCheckBox({ theme: theme, height: 23 }); |
3296 }); |
3268 $("#wh_instock").on('change', function (event) { |
3297 $('#wh_amount').jqxNumberInput(Spin1dec); |
3269 hopinstock = event.args.checked; |
3298 $('#wh_amount').on('change', function(event) { |
3270 hoplist.dataBind(); |
3299 var ibu, amount = parseFloat(event.args.value) / 1000; |
3271 }); |
3300 ibu = toIBU(hopData.h_useat, hopData.h_form, preboil_sg, parseFloat($('#batch_size').jqxNumberInput('decimal')), |
3272 $("#wh_select").jqxDropDownList({ |
3301 amount, parseFloat(hopData.h_time), parseFloat(hopData.h_alpha), $('#ibu_method').val()); |
3273 placeHolder: "Kies hop:", |
3302 hopData.h_amount = amount; |
3274 theme: theme, |
3303 console.log('amount changed: ' + event.args.value + ' time:' + hopData.h_time + ' alpha:' + hopData.h_alpha + ' IBU:' + ibu); |
3275 source: hoplist, |
3304 $('#wh_ibu').val(ibu); |
3276 displayMember: "name", |
3305 }); |
3277 width: 150, |
3306 $('#wh_ibu').jqxNumberInput(Show1dec); |
3278 height: 23, |
3307 $('#wh_time').jqxNumberInput(PosInt); |
3279 dropDownWidth: 500, |
3308 $('#wh_time').on('change', function(event) { |
3280 dropDownHeight: 500, |
3309 var ibu, newtime = parseFloat(event.args.value); |
3281 renderer: function (index, label, value) { |
3310 // Check limits and correct |
3282 var datarecord = hoplist.records[index]; |
3311 if (hopData.h_useat == 2) { // Boil |
3283 return datarecord.origin+ " / " + datarecord.name + " (" + datarecord.alpha + " % α)"; |
3312 if (newtime > parseFloat($('#boil_time').jqxNumberInput('decimal'))) { |
3284 } |
3313 newtime = parseFloat($('#boil_time').jqxNumberInput('decimal')); |
3285 }); |
3314 $('#wh_time').val(newtime); |
3286 $("#wh_select").on('select', function (event) { |
3315 } |
3287 if (event.args) { |
3316 hopData.h_time = newtime; |
3288 var index = event.args.index; |
3317 } else if (hopData.h_useat == 4) { // Whirlpool |
3289 var datarecord = hoplist.records[index]; |
3318 if (newtime > 120) { |
3290 $("#wh_name").val(datarecord.name); |
3319 newtime = 120; |
3291 hopData.h_name = datarecord.name; |
3320 $('#wh_time').val(newtime); |
3292 hopData.h_origin = datarecord.origin; |
3321 } |
3293 hopData.h_cost = datarecord.cost; |
3322 hopData.h_time = newtime; |
3294 hopData.h_type = datarecord.type; |
3323 } else if (hopData.h_useat == 5) { // Dry hop |
3295 hopData.h_form = datarecord.form; |
3324 if (newtime > 21) { |
3296 hopData.h_alpha = datarecord.alpha; |
3325 newtime = 21; |
3297 hopData.h_beta = datarecord.beta; |
3326 $('#wh_time').val(newtime); |
3298 hopData.h_hsi = datarecord.hsi; |
3327 } |
3299 hopData.h_humulene = datarecord.humulene; |
3328 hopData.h_time = newtime * 1440; |
3300 hopData.h_caryophyllene = datarecord.caryophyllene; |
3329 } |
3301 hopData.h_cohumulone = datarecord.cohumulone; |
3330 ibu = toIBU(hopData.h_useat, hopData.h_form, preboil_sg, parseFloat($('#batch_size').jqxNumberInput('decimal')), |
3302 hopData.h_myrcene = datarecord.myrcene; |
3331 parseFloat(hopData.h_amount), parseFloat(hopData.h_time), parseFloat(hopData.h_alpha), $('#ibu_method').val()); |
3303 hopData.h_total_oil = datarecord.total_oil; |
3332 $('#wh_ibu').val(ibu); |
3304 hopData.h_inventory = datarecord.inventory; |
3333 }); |
3305 } |
3334 $('#wh_useat').jqxDropDownList({ |
3306 }); |
3335 theme: theme, |
3307 $("#wh_amount").jqxNumberInput( Spin1dec ); |
3336 source: HopUseAdapter, |
3308 $('#wh_amount').on('change', function (event) { |
3337 valueMember: 'id', |
3309 console.log("amount changed: "+event.args.value+" time:"+hopData.h_time+" alpha:"+hopData.h_alpha); |
3338 displayMember: 'nl', |
3310 var amount = parseFloat(event.args.value) / 1000; |
3339 width: 180, |
3311 |
3340 height: 23, |
3312 var ibu = toIBU(hopData.h_useat, hopData.h_form, preboil_sg, |
3341 autoDropDownHeight: true, |
3313 parseFloat($("#batch_size").jqxNumberInput('decimal')), |
3342 dropDownVerticalAlignment: 'top' |
3314 amount, parseFloat(hopData.h_time), |
3343 }); |
3315 parseFloat(hopData.h_alpha), $("#ibu_method").val() |
3344 $('#wh_useat').on('select', function(event) { |
3316 ); |
3345 if (event.args) { |
3317 hopData.h_amount = amount; |
3346 var index = event.args.index; |
3318 $("#wh_ibu").val(ibu); |
3347 hopData.h_useat = index; |
3319 }); |
3348 if ((index == 0) || (index == 1)) { // Mashhop or First wort hop |
3320 $("#wh_ibu").jqxNumberInput( Show1dec ); |
3349 hopData.h_time = parseFloat(dataRecord.boil_time); |
3321 $("#wh_time").jqxNumberInput( PosInt ); |
3350 $('#wh_time').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); |
3322 $("#wh_time").on('change', function (event) { |
3351 $('#wh_time').val(hopData.h_time); |
3323 var newtime = parseFloat(event.args.value); |
3352 } else if (index == 3) { // Aroma |
3324 // Check limits and correct |
3353 hopData.h_time = 0; |
3325 if (hopData.h_useat == 2) { // Boil |
3354 $('#wh_time').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); |
3326 if (newtime > parseFloat($("#boil_time").jqxNumberInput('decimal'))) { |
3355 $('#wh_time').val(0); |
3327 newtime = parseFloat($("#boil_time").jqxNumberInput('decimal')); |
3356 } else { // Boil, Whirlpool or Dry hop |
3328 $("#wh_time").val(newtime); |
3357 $('#wh_time').jqxNumberInput({ spinButtons: true, readOnly: false, width: 110 }); |
3329 } |
3358 } |
3330 hopData.h_time = newtime; |
3359 if (index == 5) // Dry hop |
3331 } else if (hopData.h_useat == 4) { // Whirlpool |
3360 $('#wh_pmpt_time').html('Tijd in dagen'); |
3332 if (newtime > 120) { |
3361 else |
3333 newtime = 120; |
3362 $('#wh_pmpt_time').html('Tijd in minuten'); |
3334 $("#wh_time").val(newtime); |
3363 } |
3335 } |
3364 }); |
3336 hopData.h_time = newtime; |
3365 |
3337 } else if (hopData.h_useat == 5) { // Dry hop |
3366 // Tab 4, Diversen |
3338 if (newtime > 21) { |
3367 $('#popupMisc').jqxWindow({ |
3339 newtime = 21; |
3368 width: 800, |
3340 $("#wh_time").val(newtime); |
3369 height: 275, |
3341 } |
3370 position: { x: 230, y: 100 }, |
3342 hopData.h_time = newtime * 1440; |
3371 resizable: false, |
3343 } |
3372 theme: theme, |
3344 var ibu = toIBU(hopData.h_useat, hopData.h_form, preboil_sg, parseFloat($("#batch_size").jqxNumberInput('decimal')), |
3373 isModal: true, |
3345 parseFloat(hopData.h_amount), parseFloat(hopData.h_time), parseFloat(hopData.h_alpha), $("#ibu_method").val()); |
3374 autoOpen: false, |
3346 $("#wh_ibu").val(ibu); |
3375 cancelButton: $('#MiscReady'), |
3347 }); |
3376 modalOpacity: 0.40 |
3348 $("#wh_useat").jqxDropDownList({ |
3377 }); |
3349 theme: theme, |
3378 $('#MiscReady').jqxButton({ template: 'success', width: '90px', theme: theme }); |
3350 source: HopUseAdapter, |
3379 $('#MiscReady').click(function() { |
3351 valueMember: 'id', |
3380 var row, rowID = $('#miscGrid').jqxGrid('getrowid', miscRow); |
3352 displayMember: 'nl', |
3381 console.log('MiscReady row:' + miscRow + ' ID:' + rowID); |
3353 width: 180, |
3382 row = { |
3354 height: 23, |
3383 m_name: miscData.m_name, |
3355 autoDropDownHeight: true, |
3384 m_amount: miscData.m_amount, |
3356 dropDownVerticalAlignment: 'top' |
3385 m_cost: miscData.m_cost, |
3357 }); |
3386 m_type: miscData.m_type, |
3358 $("#wh_useat").on('select', function (event) { |
3387 m_use_use: miscData.m_use_use, |
3359 if (event.args) { |
3388 m_time: miscData.m_time, |
3360 var index = event.args.index; |
3389 m_amount_is_weight: miscData.m_amount_is_weight, |
3361 hopData.h_useat = index; |
3390 m_inventory: miscData.m_inventory, |
3362 if ((index == 0) || (index == 1)) { // Mashhop or First wort hop |
3391 m_avail: miscData.m_avail |
3363 hopData.h_time = parseFloat(dataRecord.boil_time); |
3392 }; |
3364 $("#wh_time").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); |
3393 $('#miscGrid').jqxGrid('updaterow', rowID, row); |
3365 $("#wh_time").val(hopData.h_time); |
3394 }); |
3366 } else if (index == 3) { // Aroma |
3395 $('#wm_name').jqxInput({ theme: theme, width: 320, height: 23 }); |
3367 hopData.h_time = 0; |
3396 $('#wm_instock').jqxCheckBox({ theme: theme, height: 23 }); |
3368 $("#wh_time").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); |
3397 $('#wm_instock').on('change', function(event) { |
3369 $("#wh_time").val(0); |
3398 miscinstock = event.args.checked; |
3370 } else { // Boil, Whirlpool or Dry hop |
3399 misclist.dataBind(); |
3371 $("#wh_time").jqxNumberInput({ spinButtons: true, readOnly: false, width: 110 }); |
3400 }); |
3372 } |
3401 $('#wm_select').jqxDropDownList({ |
3373 if (index == 5) // Dry hop |
3402 placeHolder: 'Kies ingrediënt:', |
3374 $("#wh_pmpt_time").html("Tijd in dagen"); |
3403 theme: theme, |
3375 else |
3404 source: misclist, |
3376 $("#wh_pmpt_time").html("Tijd in minuten"); |
3405 displayMember: 'name', |
3377 } |
3406 width: 150, |
3378 }); |
3407 height: 23, |
3379 |
3408 dropDownWidth: 500, |
3380 // Tab 4, Diversen |
3409 dropDownHeight: 500 |
3381 $("#popupMisc").jqxWindow({ |
3410 }); |
3382 width: 800, |
3411 $('#wm_select').on('select', function(event) { |
3383 height: 275, |
3412 if (event.args) { |
3384 position: { x: 230, y: 100 }, |
3413 var datarecord, index = event.args.index; |
3385 resizable: false, |
3414 datarecord = misclist.records[index]; |
3386 theme: theme, |
3415 $('#wm_name').val(datarecord.name); |
3387 isModal: true, |
3416 miscData.m_name = datarecord.name; |
3388 autoOpen: false, |
3417 miscData.m_cost = datarecord.cost; |
3389 cancelButton: $("#MiscReady"), |
3418 miscData.m_type = datarecord.type; |
3390 modalOpacity: 0.40 |
3419 miscData.m_use_use = datarecord.use_use; |
3391 }); |
3420 miscData.m_amount_is_weight = datarecord.amount_is_weight; |
3392 $("#MiscReady").jqxButton({ template: "success", width: '90px', theme: theme }); |
3421 miscData.m_inventory = datarecord.inventory; |
3393 $("#MiscReady").click(function () { |
3422 } |
3394 var rowID = $("#miscGrid").jqxGrid('getrowid', miscRow); |
3423 }); |
3395 console.log("MiscReady row:"+miscRow+" ID:"+rowID); |
3424 $('#wm_amount').jqxNumberInput(Spin1dec); |
3396 var row = { |
3425 $('#wm_amount').on('change', function(event) { |
3397 m_name: miscData.m_name, |
3426 console.log('amount changed: ' + event.args.value); |
3398 m_amount: miscData.m_amount, |
3427 miscData.m_amount = parseFloat(event.args.value) / 1000; |
3399 m_cost: miscData.m_cost, |
3428 }); |
3400 m_type: miscData.m_type, |
3429 $('#wm_time').jqxNumberInput(PosInt); |
3401 m_use_use: miscData.m_use_use, |
3430 $('#wm_time').on('change', function(event) { |
3402 m_time: miscData.m_time, |
3431 console.log('time changed: ' + event.args.value); |
3403 m_amount_is_weight: miscData.m_amount_is_weight, |
3432 var newtime = parseFloat(event.args.value); |
3404 m_inventory: miscData.m_inventory, |
3433 |
3405 m_avail: miscData.m_avail |
3434 if (miscData.m_use_use == 2) { // Boil |
3406 }; |
3435 if (newtime > parseFloat($('#boil_time').jqxNumberInput('decimal'))) { |
3407 $("#miscGrid").jqxGrid('updaterow', rowID, row); |
3436 newtime = parseFloat($('#boil_time').jqxNumberInput('decimal')); |
3408 }); |
3437 $('#wm_time').val(newtime); |
3409 $("#wm_name").jqxInput({ theme: theme, width: 320, height: 23 }); |
3438 } |
3410 $("#wm_instock").jqxCheckBox({ theme: theme, height: 23 }); |
3439 miscData.m_time = newtime; |
3411 $("#wm_instock").on('change', function (event) { |
3440 } else if ((miscData.m_use_use == 3) || (miscData.m_use_use == 4)) { // Primary or Secondary |
3412 miscinstock = event.args.checked; |
3441 if (newtime > 21) { |
3413 misclist.dataBind(); |
3442 newtime = 21; |
3414 }); |
3443 $('#wm_time').val(newtime); |
3415 $("#wm_select").jqxDropDownList({ |
3444 } |
3416 placeHolder: "Kies ingrediënt:", |
3445 miscData.m_time = newtime * 1440; |
3417 theme: theme, |
3446 } |
3418 source: misclist, |
3447 }); |
3419 displayMember: "name", |
3448 $('#wm_use_use').jqxDropDownList({ |
3420 width: 150, |
3449 theme: theme, |
3421 height: 23, |
3450 source: MiscUseAdapter, |
3422 dropDownWidth: 500, |
3451 valueMember: 'id', |
3423 dropDownHeight: 500 |
3452 displayMember: 'nl', |
3424 }); |
3453 width: 180, |
3425 $("#wm_select").on('select', function (event) { |
3454 height: 23, |
3426 if (event.args) { |
3455 autoDropDownHeight: true, |
3427 var index = event.args.index; |
3456 dropDownVerticalAlignment: 'top' |
3428 var datarecord = misclist.records[index]; |
3457 }); |
3429 $("#wm_name").val(datarecord.name); |
3458 $('#wm_use_use').on('select', function(event) { |
3430 miscData.m_name = datarecord.name; |
3459 if (event.args) { |
3431 miscData.m_cost = datarecord.cost; |
3460 var index = event.args.index; |
3432 miscData.m_type = datarecord.type; |
3461 miscData.m_use_use = index; |
3433 miscData.m_use_use = datarecord.use_use; |
3462 if ((index == 2) || (index == 3) || (index == 4)) { // Boil, Primary or Secondary |
3434 miscData.m_amount_is_weight = datarecord.amount_is_weight; |
3463 $('#wm_time').jqxNumberInput({ spinButtons: true, readOnly: false, width: 110 }); |
3435 miscData.m_inventory = datarecord.inventory; |
3464 } else { |
3436 } |
3465 miscData.m_time = 0; |
3437 }); |
3466 $('#wm_time').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); |
3438 $("#wm_amount").jqxNumberInput( Spin1dec ); |
3467 $('#wm_time').val(0); |
3439 $('#wm_amount').on('change', function (event) { |
3468 } |
3440 console.log("amount changed: "+event.args.value); |
3469 } |
3441 miscData.m_amount = parseFloat(event.args.value) / 1000; |
3470 }); |
3442 }); |
3471 |
3443 $("#wm_time").jqxNumberInput( PosInt ); |
3472 // Tab 5, Gist |
3444 $("#wm_time").on('change', function (event) { |
3473 $('#est_fg2').jqxTooltip({ content: 'Het eind SG. Dit wordt automatisch berekend.' }); |
3445 console.log("time changed: "+event.args.value); |
3474 $('#est_fg2').jqxNumberInput(Show3dec); |
3446 var newtime = parseFloat(event.args.value); |
3475 $('#est_abv2').jqxTooltip({ content: 'Alcohol volume %. Dit wordt automatisch berekend.' }); |
3447 |
3476 $('#est_abv2').jqxNumberInput(Smal1dec); |
3448 if (miscData.m_use_use == 2) { // Boil |
3477 $('#popupYeast').jqxWindow({ |
3449 if (newtime > parseFloat($("#boil_time").jqxNumberInput('decimal'))) { |
3478 width: 800, |
3450 newtime = parseFloat($("#boil_time").jqxNumberInput('decimal')); |
3479 height: 300, |
3451 $("#wm_time").val(newtime); |
3480 position: { x: 230, y: 100 }, |
3452 } |
3481 resizable: false, |
3453 miscData.m_time = newtime; |
3482 theme: theme, |
3454 } else if ((miscData.m_use_use == 3) || (miscData.m_use_use == 4)) { // Primary or Secondary |
3483 isModal: true, |
3455 if (newtime > 21) { |
3484 autoOpen: false, |
3456 newtime = 21; |
3485 cancelButton: $('#YeastReady'), |
3457 $("#wm_time").val(newtime); |
3486 modalOpacity: 0.40 |
3458 } |
3487 }); |
3459 miscData.m_time = newtime * 1440; |
3488 $('#YeastReady').jqxButton({ template: 'success', width: '90px', theme: theme }); |
3460 } |
3489 $('#YeastReady').click(function() { |
3461 }); |
3490 var row, rowID = $('#yeastGrid').jqxGrid('getrowid', yeastRow); |
3462 $("#wm_use_use").jqxDropDownList({ |
3491 console.log('YeastReady row:' + yeastRow + ' ID:' + rowID); |
3463 theme: theme, |
3492 row = { |
3464 source: MiscUseAdapter, |
3493 y_name: yeastData.y_name, |
3465 valueMember: 'id', |
3494 y_laboratory: yeastData.y_laboratory, |
3466 displayMember: 'nl', |
3495 y_product_id: yeastData.y_product_id, |
3467 width: 180, |
3496 y_amount: yeastData.y_amount, |
3468 height: 23, |
3497 y_cost: yeastData.y_cost, |
3469 autoDropDownHeight: true, |
3498 y_type: yeastData.y_type, |
3470 dropDownVerticalAlignment: 'top' |
3499 y_form: yeastData.y_form, |
3471 }); |
3500 y_flocculation: yeastData.y_flocculation, |
3472 $("#wm_use_use").on('select', function (event) { |
3501 y_min_temperature: yeastData.y_min_temperature, |
3473 if (event.args) { |
3502 y_max_temperature: yeastData.y_max_temperature, |
3474 var index = event.args.index; |
3503 y_attenuation: yeastData.y_attenuation, |
3475 miscData.m_use_use = index; |
3504 y_use: yeastData.y_use, |
3476 if ((index == 2) || (index == 3) || (index == 4)) { // Boil, Primary or Secondary |
3505 y_cells: yeastData.y_cells, |
3477 $("#wm_time").jqxNumberInput({ spinButtons: true, readOnly: false, width: 110 }); |
3506 y_tolerance: yeastData.y_tolerance, |
3478 } else { |
3507 y_inventory: yeastData.y_inventory, |
3479 miscData.m_time = 0; |
3508 y_avail: yeastData.y_avail |
3480 $("#wm_time").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); |
3509 }; |
3481 $("#wm_time").val(0); |
3510 $('#yeastGrid').jqxGrid('updaterow', rowID, row); |
3482 } |
3511 calcFermentables(); |
3483 } |
3512 }); |
3484 }); |
3513 $('#wy_name').jqxInput({ theme: theme, width: 320, height: 23 }); |
3485 |
3514 $('#wy_laboratory').jqxInput({ theme: theme, width: 320, height: 23 }); |
3486 // Tab 5, Gist |
3515 $('#wy_product_id').jqxInput({ theme: theme, width: 320, height: 23 }); |
3487 $("#est_fg2").jqxTooltip({ content: 'Het eind SG. Dit wordt automatisch berekend.' }); |
3516 $('#wy_instock').jqxCheckBox({ theme: theme, height: 23 }); |
3488 $("#est_fg2").jqxNumberInput( Show3dec ); |
3517 $('#wy_instock').on('change', function(event) { |
3489 $("#est_abv2").jqxTooltip({ content: 'Alcohol volume %. Dit wordt automatisch berekend.' }); |
3518 yeastinstock = event.args.checked; |
3490 $("#est_abv2").jqxNumberInput( Smal1dec ); |
3519 yeastlist.dataBind(); |
3491 $("#popupYeast").jqxWindow({ |
3520 }); |
3492 width: 800, |
3521 $('#wy_select').jqxDropDownList({ |
3493 height: 300, |
3522 placeHolder: 'Kies gist:', |
3494 position: { x: 230, y: 100 }, |
3523 theme: theme, |
3495 resizable: false, |
3524 source: yeastlist, |
3496 theme: theme, |
3525 displayMember: 'name', |
3497 isModal: true, |
3526 width: 150, |
3498 autoOpen: false, |
3527 height: 23, |
3499 cancelButton: $("#YeastReady"), |
3528 dropDownWidth: 500, |
3500 modalOpacity: 0.40 |
3529 dropDownHeight: 500, |
3501 }); |
3530 renderer: function(index, label, value) { |
3502 $("#YeastReady").jqxButton({ template: "success", width: '90px', theme: theme }); |
3531 var datarecord = yeastlist.records[index]; |
3503 $("#YeastReady").click(function () { |
3532 return datarecord.laboratory + ' ' + datarecord.product_id + ' ' + datarecord.name; |
3504 var rowID = $("#yeastGrid").jqxGrid('getrowid', yeastRow); |
3533 } |
3505 console.log("YeastReady row:"+yeastRow+" ID:"+rowID); |
3534 }); |
3506 var row = { |
3535 $('#wy_select').on('select', function(event) { |
3507 y_name: yeastData.y_name, |
3536 if (event.args) { |
3508 y_laboratory: yeastData.y_laboratory, |
3537 var datarecord, index = event.args.index; |
3509 y_product_id: yeastData.y_product_id, |
3538 datarecord = yeastlist.records[index]; |
3510 y_amount: yeastData.y_amount, |
3539 $('#wy_name').val(datarecord.name); |
3511 y_cost: yeastData.y_cost, |
3540 $('#wy_laboratory').val(datarecord.laboratory); |
3512 y_type: yeastData.y_type, |
3541 $('#wy_product_id').val(datarecord.product_id); |
3513 y_form: yeastData.y_form, |
3542 yeastData.y_name = datarecord.name; |
3514 y_flocculation: yeastData.y_flocculation, |
3543 yeastData.y_cost = datarecord.cost; |
3515 y_min_temperature: yeastData.y_min_temperature, |
3544 yeastData.y_type = datarecord.type; |
3516 y_max_temperature: yeastData.y_max_temperature, |
3545 yeastData.y_form = datarecord.form; |
3517 y_attenuation: yeastData.y_attenuation, |
3546 yeastData.y_laboratory = datarecord.laboratory; |
3518 y_use: yeastData.y_use, |
3547 yeastData.y_product_id = datarecord.product_id; |
3519 y_cells: yeastData.y_cells, |
3548 yeastData.y_min_temperature = datarecord.min_temperature; |
3520 y_tolerance: yeastData.y_tolerance, |
3549 yeastData.y_max_temperature = datarecord.max_temperature; |
3521 y_inventory: yeastData.y_inventory, |
3550 yeastData.y_flocculation = datarecord.flocculation; |
3522 y_avail: yeastData.y_avail |
3551 yeastData.y_attenuation = datarecord.attenuation; |
3523 }; |
3552 yeastData.y_cells = datarecord.cells; |
3524 $("#yeastGrid").jqxGrid('updaterow', rowID, row); |
3553 yeastData.y_inventory = datarecord.inventory; |
3525 calcFermentables(); |
3554 if (yeastData.y_form == 0) { |
3526 }); |
3555 $('#wy_pmpt_amount').html('Pak(ken):'); |
3527 $("#wy_name").jqxInput({ theme: theme, width: 320, height: 23 }); |
3556 } else if (yeastData.y_form == 1) { |
3528 $("#wy_laboratory").jqxInput({ theme: theme, width: 320, height: 23 }); |
3557 $('#wy_pmpt_amount').html('Gewicht gram:'); |
3529 $("#wy_product_id").jqxInput({ theme: theme, width: 320, height: 23 }); |
3558 } else { |
3530 $("#wy_instock").jqxCheckBox({ theme: theme, height: 23 }); |
3559 $('#wy_pmpt_amount').html('Volume ml:'); |
3531 $("#wy_instock").on('change', function (event) { |
3560 } |
3532 yeastinstock = event.args.checked; |
3561 calcFermentables(); |
3533 yeastlist.dataBind(); |
3562 } |
3534 }); |
3563 }); |
3535 $("#wy_select").jqxDropDownList({ |
3564 $('#wy_amount').jqxNumberInput(Spin1dec); |
3536 placeHolder: "Kies gist:", |
3565 $('#wy_amount').on('change', function(event) { |
3537 theme: theme, |
3566 console.log('amount changed: ' + event.args.value); |
3538 source: yeastlist, |
3567 var amount; |
3539 displayMember: "name", |
3568 if (yeastData.y_form == 0) // Liquid |
3540 width: 150, |
3569 amount = parseFloat(event.args.value); |
3541 height: 23, |
3570 else |
3542 dropDownWidth: 500, |
3571 amount = parseFloat(event.args.value) / 1000; |
3543 dropDownHeight: 500, |
3572 yeastData.y_amount = amount; |
3544 renderer: function (index, label, value) { |
3573 calcFermentables(); |
3545 var datarecord = yeastlist.records[index]; |
3574 }); |
3546 return datarecord.laboratory+" "+datarecord.product_id+" "+datarecord.name; |
3575 $('#wy_use').jqxDropDownList({ |
3547 } |
3576 theme: theme, |
3548 }); |
3577 source: YeastUseAdapter, |
3549 $("#wy_select").on('select', function (event) { |
3578 valueMember: 'id', |
3550 if (event.args) { |
3579 displayMember: 'nl', |
3551 var index = event.args.index; |
3580 width: 180, |
3552 var datarecord = yeastlist.records[index]; |
3581 height: 23, |
3553 $("#wy_name").val(datarecord.name); |
3582 autoDropDownHeight: true, |
3554 $("#wy_laboratory").val(datarecord.laboratory); |
3583 dropDownVerticalAlignment: 'top' |
3555 $("#wy_product_id").val(datarecord.product_id); |
3584 }); |
3556 yeastData.y_name = datarecord.name; |
3585 $('#wy_use').on('select', function(event) { |
3557 yeastData.y_cost = datarecord.cost; |
3586 if (event.args) { |
3558 yeastData.y_type = datarecord.type; |
3587 var index = event.args.index; |
3559 yeastData.y_form = datarecord.form; |
3588 yeastData.y_use = index; |
3560 yeastData.y_laboratory = datarecord.laboratory; |
3589 calcFermentabes(); |
3561 yeastData.y_product_id = datarecord.product_id; |
3590 } |
3562 yeastData.y_min_temperature = datarecord.min_temperature; |
3591 }); |
3563 yeastData.y_max_temperature = datarecord.max_temperature; |
3592 |
3564 yeastData.y_flocculation = datarecord.flocculation; |
3593 // Tab 6, Maischen |
3565 yeastData.y_attenuation = datarecord.attenuation; |
3594 $('#mash_name').jqxInput({ theme: theme, width: 320, height: 23 }); |
3566 yeastData.y_cells = datarecord.cells; |
3595 $('#mash_select').jqxDropDownList({ |
3567 yeastData.y_inventory = datarecord.inventory; |
3596 placeHolder: 'Kies schema:', |
3568 if (yeastData.y_form == 0) { |
3597 theme: theme, |
3569 $("#wy_pmpt_amount").html("Pak(ken):"); |
3598 source: mashlist, |
3570 } else if (yeastData.y_form == 1) { |
3599 displayMember: 'name', |
3571 $("#wy_pmpt_amount").html("Gewicht gram:"); |
3600 width: 250, |
3572 } else { |
3601 height: 23, |
3573 $("#wy_pmpt_amount").html("Volume ml:"); |
3602 dropDownWidth: 500, |
3574 } |
3603 dropDownHeight: 500, |
3575 calcFermentables(); |
3604 dropDownHorizontalAlignment: 'right' |
3576 } |
3605 }); |
3577 }); |
3606 $('#mash_select').on('select', function(event) { |
3578 $("#wy_amount").jqxNumberInput( Spin1dec ); |
3607 if (event.args) { |
3579 $('#wy_amount').on('change', function (event) { |
3608 var data, datarecord, i, row, rows, rowIDs, index = event.args.index; |
3580 console.log("amount changed: "+event.args.value); |
3609 // First delete all current steps |
3581 if (yeastData.y_form == 0) // Liquid |
3610 rowIDs = new Array(); |
3582 var amount = parseFloat(event.args.value); |
3611 rows = $('#mashGrid').jqxGrid('getdisplayrows'); |
3583 else |
3612 for (i = 0; i < rows.length; i++) { |
3584 var amount = parseFloat(event.args.value) / 1000; |
3613 row = rows[i]; |
3585 yeastData.y_amount = amount; |
3614 rowIDs.push(row.uid); |
3586 calcFermentables(); |
3615 } |
3587 }); |
3616 $('#mashGrid').jqxGrid('deleterow', rowIDs); |
3588 $("#wy_use").jqxDropDownList({ |
3617 // Then add the new steps |
3589 theme: theme, |
3618 datarecord = mashlist.records[index]; |
3590 source: YeastUseAdapter, |
3619 $('#mash_name').val(datarecord.name); |
3591 valueMember: 'id', |
3620 for (i = 0; i < datarecord.steps.length; i++) { |
3592 displayMember: 'nl', |
3621 data = datarecord.steps[i]; |
3593 width: 180, |
3622 row = {}; |
3594 height: 23, |
3623 row['step_name'] = data.step_name; |
3595 autoDropDownHeight: true, |
3624 row['step_type'] = data.step_type; |
3596 dropDownVerticalAlignment: 'top' |
3625 // For now, but this must be smarter. |
3597 }); |
3626 if (mash_infuse == 0 && dataRecord.w1_amount > 0) |
3598 $("#wy_use").on('select', function (event) { |
3627 mash_infuse = dataRecord.w1_amount; |
3599 if (event.args) { |
3628 if (i == 0) |
3600 var index = event.args.index; |
3629 row['step_infuse_amount'] = mash_infuse; |
3601 yeastData.y_use = index; |
3630 else |
3602 calcFermentabes(); |
3631 row['step_infuse_amount'] = 0; |
3603 } |
3632 row['step_temp'] = data.step_temp; |
3604 }); |
3633 if (mashkg > 0) |
3605 |
3634 row['step_thickness'] = parseFloat(mash_infuse / mashkg); |
3606 // Tab 6, Maischen |
3635 else |
3607 $("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 }); |
3636 row['step_thickness'] = 0; |
3608 $("#mash_select").jqxDropDownList({ |
3637 row['end_temp'] = data.end_temp; |
3609 placeHolder: "Kies schema:", |
3638 row['step_time'] = data.step_time; |
3610 theme: theme, |
3639 row['ramp_time'] = data.ramp_time; |
3611 source: mashlist, |
3640 $('#mashGrid').jqxGrid('addrow', null, row); |
3612 displayMember: "name", |
3641 } |
3613 width: 250, |
3642 } |
3614 height: 23, |
3643 }); |
3615 dropDownWidth: 500, |
3644 $('#popupMash').jqxWindow({ |
3616 dropDownHeight: 500, |
3645 width: 800, |
3617 dropDownHorizontalAlignment: 'right' |
3646 height: 350, |
3618 }); |
3647 position: { x: 230, y: 100 }, |
3619 $("#mash_select").on('select', function (event) { |
3648 resizable: false, |
3620 if (event.args) { |
3649 theme: theme, |
3621 var index = event.args.index; |
3650 isModal: true, |
3622 // First delete all current steps |
3651 autoOpen: false, |
3623 var rowIDs = new Array(); |
3652 cancelButton: $('#MashReady'), |
3624 var rows = $("#mashGrid").jqxGrid('getdisplayrows'); |
3653 modalOpacity: 0.40 |
3625 for (var i = 0; i < rows.length; i++) { |
3654 }); |
3626 var row = rows[i]; |
3655 $('#MashReady').jqxButton({ template: 'success', width: '90px', theme: theme }); |
3627 rowIDs.push(row.uid); |
3656 $('#MashReady').click(function() { |
3628 } |
3657 calcMash(); |
3629 $("#mashGrid").jqxGrid('deleterow', rowIDs); |
3658 }); |
3630 // Then add the new steps |
3659 $('#wstep_name').jqxInput({ theme: theme, width: 320, height: 23 }); |
3631 var datarecord = mashlist.records[index]; |
3660 $('#wstep_name').on('change', function(event) { |
3632 $("#mash_name").val(datarecord.name); |
3661 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
3633 for (var i = 0; i < datarecord.steps.length; i++) { |
3662 rowdata.step_name = event.args.value; |
3634 var data = datarecord.steps[i]; |
3663 }); |
3635 var row = {}; |
3664 $('#wstep_type').jqxDropDownList({ |
3636 row["step_name"] = data.step_name; |
3665 theme: theme, |
3637 row["step_type"] = data.step_type; |
3666 source: MashStepTypeAdapter, |
3638 // For now, but this must be smarter. |
3667 valueMember: 'id', |
3639 if (mash_infuse == 0 && dataRecord.w1_amount > 0) |
3668 displayMember: 'nl', |
3640 mash_infuse = dataRecord.w1_amount; |
3669 width: 180, |
3641 if (i == 0) |
3670 height: 23, |
3642 row["step_infuse_amount"] = mash_infuse; |
3671 autoDropDownHeight: true |
3643 else |
3672 }); |
3644 row["step_infuse_amount"] = 0; |
3673 $('#wstep_type').on('select', function(event) { |
3645 row["step_temp"] = data.step_temp; |
3674 if (event.args) { |
3646 if (mashkg > 0) |
3675 var rowdata, rows, i, row, index = event.args.index; |
3647 row["step_thickness"] = parseFloat(mash_infuse / mashkg); |
3676 rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
3648 else |
3677 rowdata.step_type = index; |
3649 row["step_thickness"] = 0; |
3678 if (index == 0) { |
3650 row["end_temp"] = data.end_temp; |
3679 $('#wstep_infuse_amount').show(); |
3651 row["step_time"] = data.step_time; |
3680 $('#wstep_pmpt').show(); |
3652 row["ramp_time"] = data.ramp_time; |
3681 } else { |
3653 var commit = $("#mashGrid").jqxGrid('addrow', null, row); |
3682 rowdata.step_infuse_amount = 0; |
3654 } |
3683 $('#wstep_infuse_amount').hide(); |
3655 } |
3684 $('#wstep_pmpt').hide(); |
3656 }); |
3685 } |
3657 $("#popupMash").jqxWindow({ |
3686 mash_infuse = 0; |
3658 width: 800, |
3687 rows = $('#mashGrid').jqxGrid('getrows'); |
3659 height: 350, |
3688 for (i = 0; i < rows.length; i++) { |
3660 position: { x: 230, y: 100 }, |
3689 row = rows[i]; |
3661 resizable: false, |
3690 if (row.step_type == 0) // Infusion |
3662 theme: theme, |
3691 mash_infuse += parseFloat(row.step_infuse_amount); |
3663 isModal: true, |
3692 } |
3664 autoOpen: false, |
3693 } |
3665 cancelButton: $("#MashReady"), |
3694 }); |
3666 modalOpacity: 0.40 |
3695 $('#wstep_temp').jqxNumberInput(Spin1dec); |
3667 }); |
3696 $('#wstep_temp').on('change', function(event) { |
3668 $("#MashReady").jqxButton({ template: "success", width: '90px', theme: theme }); |
3697 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
3669 $("#MashReady").click(function () { |
3698 rowdata.step_temp = parseFloat(event.args.value); |
3670 calcMash(); |
3699 }); |
3671 }); |
3700 $('#wend_temp').jqxNumberInput(Spin1dec); |
3672 $("#wstep_name").jqxInput({ theme: theme, width: 320, height: 23 }); |
3701 $('#wend_temp').on('change', function(event) { |
3673 $("#wstep_name").on('change', function (event) { |
3702 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
3674 var rowdata = $("#mashGrid").jqxGrid('getrowdata', mashRow); |
3703 rowdata.end_temp = parseFloat(event.args.value); |
3675 rowdata.step_name = event.args.value; |
3704 }); |
3676 }); |
3705 $('#wstep_time').jqxNumberInput(PosInt); |
3677 $("#wstep_type").jqxDropDownList({ |
3706 $('#wstep_time').on('change', function(event) { |
3678 theme: theme, |
3707 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
3679 source: MashStepTypeAdapter, |
3708 rowdata.step_time = parseFloat(event.args.value); |
3680 valueMember: 'id', |
3709 }); |
3681 displayMember: 'nl', |
3710 $('#wramp_time').jqxNumberInput(PosInt); |
3682 width: 180, |
3711 $('#wramp_time').on('change', function(event) { |
3683 height: 23, |
3712 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
3684 autoDropDownHeight: true |
3713 rowdata.ramp_time = parseFloat(event.args.value); |
3685 }); |
3714 }); |
3686 $("#wstep_type").on('select', function (event) { |
3715 $('#wstep_infuse_amount').jqxNumberInput(Spin1dec); |
3687 if (event.args) { |
3716 $('#wstep_infuse_amount').on('change', function(event) { |
3688 var index = event.args.index; |
3717 var i, rows, row, rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
3689 var rowdata = $("#mashGrid").jqxGrid('getrowdata', mashRow); |
3718 rowdata.step_infuse_amount = parseFloat(event.args.value); |
3690 rowdata.step_type = index; |
3719 mash_infuse = 0; |
3691 if (index == 0) { |
3720 rows = $('#mashGrid').jqxGrid('getrows'); |
3692 $("#wstep_infuse_amount").show(); |
3721 for (i = 0; i < rows.length; i++) { |
3693 $("#wstep_pmpt").show(); |
3722 row = rows[i]; |
3694 } else { |
3723 if (row.step_type == 0) // Infusion |
3695 rowdata.step_infuse_amount = 0; |
3724 mash_infuse += parseFloat(row.step_infuse_amount); |
3696 $("#wstep_infuse_amount").hide(); |
3725 } |
3697 $("#wstep_pmpt").hide(); |
3726 if (dataRecord.w2_amount == 0) { |
3698 } |
3727 dataRecord.w1_amount = mash_infuse; |
3699 mash_infuse = 0; |
3728 $('#w1_amount').val(mash_infuse); |
3700 var rows = $('#mashGrid').jqxGrid('getrows'); |
3729 } else { |
3701 for (var i = 0; i < rows.length; i++) { |
3730 dataRecord.w1_amount = (dataRecord.w1_amount / (dataRecord.w1_amount + dataRecord.w2_amount)) * mash_infuse; |
3702 var row = rows[i]; |
3731 dataRecord.w2_amount = (dataRecord.w2_amount / (dataRecord.w1_amount + dataRecord.w2_amount)) * mash_infuse; |
3703 if (row.step_type == 0) // Infusion |
3732 $('#w1_amount').val(dataRecord.w1_amount); |
3704 mash_infuse += parseFloat(row.step_infuse_amount); |
3733 $('#w2_amount').val(dataRecord.w2_amount); |
3705 } |
3734 } |
3706 } |
3735 $('#wg_amount').val(mash_infuse); |
3707 }); |
3736 }); |
3708 $("#wstep_temp").jqxNumberInput( Spin1dec ); |
3737 |
3709 $('#wstep_temp').on('change', function (event) { |
3738 // Tab 7, Water |
3710 var rowdata = $("#mashGrid").jqxGrid('getrowdata', mashRow); |
3739 $('#tgt_bu').jqxNumberInput(Show2wat); |
3711 rowdata.step_temp = parseFloat(event.args.value); |
3740 $('#tgt_cl_so4').jqxNumberInput(Show1wat); |
3712 }); |
3741 $('#got_cl_so4').jqxNumberInput(Show1wat); |
3713 $("#wend_temp").jqxNumberInput( Spin1dec ); |
3742 |
3714 $('#wend_temp').on('change', function (event) { |
3743 // Water source 1 |
3715 var rowdata = $("#mashGrid").jqxGrid('getrowdata', mashRow); |
3744 $('#w1_name').jqxDropDownList({ |
3716 rowdata.end_temp = parseFloat(event.args.value); |
3745 placeHolder: 'Kies hoofd water:', |
3717 }); |
3746 theme: theme, |
3718 $("#wstep_time").jqxNumberInput( PosInt ); |
3747 source: waterlist, |
3719 $('#wstep_time').on('change', function (event) { |
3748 displayMember: 'name', |
3720 var rowdata = $("#mashGrid").jqxGrid('getrowdata', mashRow); |
3749 width: 250, |
3721 rowdata.step_time = parseFloat(event.args.value); |
3750 height: 27, |
3722 }); |
3751 dropDownWidth: 400, |
3723 $("#wramp_time").jqxNumberInput( PosInt ); |
3752 dropDownHeight: 400 |
3724 $('#wramp_time').on('change', function (event) { |
3753 }); |
3725 var rowdata = $("#mashGrid").jqxGrid('getrowdata', mashRow); |
3754 $('#w1_name').on('select', function(event) { |
3726 rowdata.ramp_time = parseFloat(event.args.value); |
3755 if (event.args) { |
3727 }); |
3756 var datarecord, index = event.args.index; |
3728 $("#wstep_infuse_amount").jqxNumberInput( Spin1dec ); |
3757 datarecord = waterlist.records[index]; |
3729 $('#wstep_infuse_amount').on('change', function (event) { |
3758 dataRecord.w1_name = datarecord.name; |
3730 var rowdata = $("#mashGrid").jqxGrid('getrowdata', mashRow); |
3759 $('#w1_calcium').val(datarecord.calcium); |
3731 rowdata.step_infuse_amount = parseFloat(event.args.value); |
3760 dataRecord.w1_calcium = datarecord.calcium; |
3732 mash_infuse = 0; |
3761 $('#w1_sulfate').val(datarecord.sulfate); |
3733 var rows = $('#mashGrid').jqxGrid('getrows'); |
3762 dataRecord.w1_sulfate = datarecord.sulfate; |
3734 for (var i = 0; i < rows.length; i++) { |
3763 $('#w1_chloride').val(datarecord.chloride); |
3735 var row = rows[i]; |
3764 dataRecord.w1_chloride = datarecord.chloride; |
3736 if (row.step_type == 0) // Infusion |
3765 $('#w1_sodium').val(datarecord.sodium); |
3737 mash_infuse += parseFloat(row.step_infuse_amount); |
3766 dataRecord.w1_sodium = datarecord.sodium; |
3738 } |
3767 $('#w1_magnesium').val(datarecord.magnesium); |
3739 if (dataRecord.w2_amount == 0) { |
3768 dataRecord.w1_magnesium = datarecord.magnesium; |
3740 dataRecord.w1_amount = mash_infuse; |
3769 $('#w1_total_alkalinity').val(datarecord.total_alkalinity); |
3741 $("#w1_amount").val(mash_infuse); |
3770 dataRecord.w1_total_alkalinity = datarecord.total_alkalinity; |
3742 } else { |
3771 $('#w1_ph').val(datarecord.ph); |
3743 dataRecord.w1_amount = (dataRecord.w1_amount / (dataRecord.w1_amount + dataRecord.w2_amount)) * mash_infuse; |
3772 dataRecord.w1_ph = datarecord.ph; |
3744 dataRecord.w2_amount = (dataRecord.w2_amount / (dataRecord.w1_amount + dataRecord.w2_amount)) * mash_infuse; |
3773 $('#w1_cost').val(datarecord.cost); |
3745 $("#w1_amount").val(dataRecord.w1_amount); |
3774 dataRecord.w1_cost = datarecord.cost; |
3746 $("#w2_amount").val(dataRecord.w2_amount); |
3775 calcWater(); |
3747 } |
3776 } |
3748 $('#wg_amount').val(mash_infuse); |
3777 }); |
3749 }); |
3778 $('#w1_amount').jqxNumberInput(Show1wat); |
3750 |
3779 $('#w1_calcium').jqxNumberInput(Show1wat); |
3751 // Tab 7, Water |
3780 $('#w1_magnesium').jqxNumberInput(Show1wat); |
3752 $("#tgt_bu").jqxNumberInput( Show2wat ); |
3781 $('#w1_sodium').jqxNumberInput(Show1wat); |
3753 $("#tgt_cl_so4").jqxNumberInput( Show1wat ); |
3782 $('#w1_total_alkalinity').jqxNumberInput(Show1wat); |
3754 $("#got_cl_so4").jqxNumberInput( Show1wat ); |
3783 $('#w1_chloride').jqxNumberInput(Show1wat); |
3755 |
3784 $('#w1_sulfate').jqxNumberInput(Show1wat); |
3756 // Water source 1 |
3785 $('#w1_ph').jqxNumberInput(Show1wat); |
3757 $("#w1_name").jqxDropDownList({ |
3786 // Water source 2 |
3758 placeHolder: "Kies hoofd water:", |
3787 $('#w2_name').jqxDropDownList({ |
3759 theme: theme, |
3788 placeHolder: 'Kies meng water:', |
3760 source: waterlist, |
3789 theme: theme, |
3761 displayMember: "name", |
3790 source: waterlist, |
3762 width: 250, |
3791 displayMember: 'name', |
3763 height: 27, |
3792 width: 250, |
3764 dropDownWidth: 400, |
3793 height: 27, |
3765 dropDownHeight: 400 |
3794 dropDownWidth: 400, |
3766 }); |
3795 dropDownHeight: 400 |
3767 $("#w1_name").on('select', function (event) { |
3796 }); |
3768 if (event.args) { |
3797 $('#w2_name').on('select', function(event) { |
3769 var index = event.args.index; |
3798 if (event.args) { |
3770 var datarecord = waterlist.records[index]; |
3799 var datarecord, index = event.args.index; |
3771 dataRecord.w1_name = datarecord.name; |
3800 datarecord = waterlist.records[index]; |
3772 $("#w1_calcium").val(datarecord.calcium); |
3801 dataRecord.w2_name = datarecord.name; |
3773 dataRecord.w1_calcium = datarecord.calcium; |
3802 $('#w2_calcium').val(datarecord.calcium); |
3774 $("#w1_sulfate").val(datarecord.sulfate); |
3803 dataRecord.w2_calcium = datarecord.calcium; |
3775 dataRecord.w1_sulfate = datarecord.sulfate; |
3804 $('#w2_sulfate').val(datarecord.sulfate); |
3776 $("#w1_chloride").val(datarecord.chloride); |
3805 dataRecord.w2_sulfate = datarecord.sulfate; |
3777 dataRecord.w1_chloride = datarecord.chloride; |
3806 $('#w2_chloride').val(datarecord.chloride); |
3778 $("#w1_sodium").val(datarecord.sodium); |
3807 dataRecord.w2_chloride = datarecord.chloride; |
3779 dataRecord.w1_sodium = datarecord.sodium; |
3808 $('#w2_sodium').val(datarecord.sodium); |
3780 $("#w1_magnesium").val(datarecord.magnesium); |
3809 dataRecord.w2_sodium = datarecord.sodium; |
3781 dataRecord.w1_magnesium = datarecord.magnesium; |
3810 $('#w2_magnesium').val(datarecord.magnesium); |
3782 $("#w1_total_alkalinity").val(datarecord.total_alkalinity); |
3811 dataRecord.w2_magnesium = datarecord.magnesium; |
3783 dataRecord.w1_total_alkalinity = datarecord.total_alkalinity; |
3812 $('#w2_total_alkalinity').val(datarecord.total_alkalinity); |
3784 $("#w1_ph").val(datarecord.ph); |
3813 dataRecord.w2_total_alkalinity = datarecord.total_alkalinity; |
3785 dataRecord.w1_ph = datarecord.ph; |
3814 $('#w2_ph').val(datarecord.ph); |
3786 $("#w1_cost").val(datarecord.cost); |
3815 dataRecord.w2_ph = datarecord.ph; |
3787 dataRecord.w1_cost = datarecord.cost; |
3816 $('#w2_cost').val(datarecord.cost); |
3788 calcWater(); |
3817 dataRecord.w2_cost = datarecord.cost; |
3789 } |
3818 $('#w2_amount').jqxNumberInput({ max: 100000, readOnly: false }); // Set high max to enable the spinbuttons. |
3790 }); |
3819 calcWater(); |
3791 $("#w1_amount").jqxNumberInput( Show1wat ); |
3820 } |
3792 $("#w1_calcium").jqxNumberInput( Show1wat ); |
3821 }); |
3793 $("#w1_magnesium").jqxNumberInput( Show1wat ); |
3822 $('#w2_amount').jqxTooltip({ content: 'De verdeling van het hoofd en meng water. Het totale maisch water volume blijft gelijk.'}); |
3794 $("#w1_sodium").jqxNumberInput( Show1wat ); |
3823 $('#w2_amount').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 94, height: 23, min: 0, decimalDigits: 1, spinButtons: true, readOnly: true }); |
3795 $("#w1_total_alkalinity").jqxNumberInput( Show1wat ); |
3824 $('#w2_calcium').jqxNumberInput(Show1wat); |
3796 $("#w1_chloride").jqxNumberInput( Show1wat ); |
3825 $('#w2_magnesium').jqxNumberInput(Show1wat); |
3797 $("#w1_sulfate").jqxNumberInput( Show1wat ); |
3826 $('#w2_sodium').jqxNumberInput(Show1wat); |
3798 $("#w1_ph").jqxNumberInput( Show1wat ); |
3827 $('#w2_total_alkalinity').jqxNumberInput(Show1wat); |
3799 // Water source 2 |
3828 $('#w2_chloride').jqxNumberInput(Show1wat); |
3800 $("#w2_name").jqxDropDownList({ |
3829 $('#w2_sulfate').jqxNumberInput(Show1wat); |
3801 placeHolder: "Kies meng water:", |
3830 $('#w2_ph').jqxNumberInput(Show1wat); |
3802 theme: theme, |
3831 // Water mixed |
3803 source: waterlist, |
3832 $('#wg_amount').jqxNumberInput(Show1wat); |
3804 displayMember: "name", |
3833 $('#wg_calcium').jqxNumberInput(Show1wat); |
3805 width: 250, |
3834 $('#wg_magnesium').jqxNumberInput(Show1wat); |
3806 height: 27, |
3835 $('#wg_sodium').jqxNumberInput(Show1wat); |
3807 dropDownWidth: 400, |
3836 $('#wg_total_alkalinity').jqxNumberInput(Show1wat); |
3808 dropDownHeight: 400 |
3837 $('#wg_chloride').jqxNumberInput(Show1wat); |
3809 }); |
3838 $('#wg_sulfate').jqxNumberInput(Show1wat); |
3810 $("#w2_name").on('select', function (event) { |
3839 $('#wg_ph').jqxNumberInput(Show1wat); |
3811 if (event.args) { |
3840 // Water treated |
3812 var index = event.args.index; |
3841 $('#wb_calcium').jqxTooltip({ content: 'De ideale hoeveelheid Calcium is tussen 40 en 150.'}); |
3813 var datarecord = waterlist.records[index]; |
3842 $('#wb_calcium').jqxNumberInput(Show1wat); |
3814 dataRecord.w2_name = datarecord.name; |
3843 $('#wb_magnesium').jqxTooltip({ content: 'De ideale hoeveelheid Magnesium is lager dan 30.'}); |
3815 $("#w2_calcium").val(datarecord.calcium); |
3844 $('#wb_magnesium').jqxNumberInput(Show1wat); |
3816 dataRecord.w2_calcium = datarecord.calcium; |
3845 $('#wb_sodium').jqxTooltip({ content: 'De ideale hoeveelheid Natrium is lager dan 150.'}); |
3817 $("#w2_sulfate").val(datarecord.sulfate); |
3846 $('#wb_sodium').jqxNumberInput(Show1wat); |
3818 dataRecord.w2_sulfate = datarecord.sulfate; |
3847 $('#wb_chloride').jqxTooltip({ content: 'De ideale hoeveelheid Chloride is tussen 50 en 100.'}); |
3819 $("#w2_chloride").val(datarecord.chloride); |
3848 $('#wb_chloride').jqxNumberInput(Show1wat); |
3820 dataRecord.w2_chloride = datarecord.chloride; |
3849 $('#wb_sulfate').jqxTooltip({ content: 'De ideale hoeveelheid Sulfaat is tussen 50 en 350.'}); |
3821 $("#w2_sodium").val(datarecord.sodium); |
3850 $('#wb_sulfate').jqxNumberInput(Show1wat); |
3822 dataRecord.w2_sodium = datarecord.sodium; |
3851 $('#wb_total_alkalinity').jqxNumberInput(Show1wat); |
3823 $("#w2_magnesium").val(datarecord.magnesium); |
3852 $('#wb_ph').jqxNumberInput(Show1wat); |
3824 dataRecord.w2_magnesium = datarecord.magnesium; |
3853 // Water target profile |
3825 $("#w2_total_alkalinity").val(datarecord.total_alkalinity); |
3854 $('#pr_name').jqxDropDownList({ |
3826 dataRecord.w2_total_alkalinity = datarecord.total_alkalinity; |
3855 placeHolder: 'Kies doel profiel:', |
3827 $("#w2_ph").val(datarecord.ph); |
3856 theme: theme, |
3828 dataRecord.w2_ph = datarecord.ph; |
3857 source: waterprofiles, |
3829 $("#w2_cost").val(datarecord.cost); |
3858 displayMember: 'name', |
3830 dataRecord.w2_cost = datarecord.cost; |
3859 width: 250, |
3831 $("#w2_amount").jqxNumberInput({ max: 100000, readOnly: false }); // Set high max to enable the spinbuttons. |
3860 height: 27, |
3832 calcWater(); |
3861 dropDownWidth: 400, |
3833 } |
3862 dropDownHeight: 300 |
3834 }); |
3863 }); |
3835 $("#w2_amount").jqxTooltip({ content: 'De verdeling van het hoofd en meng water. Het totale maisch water volume blijft gelijk.'}); |
3864 $('#pr_name').on('select', function(event) { |
3836 $("#w2_amount").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 94, height: 23, min: 0, max: 0, decimalDigits: 1, spinButtons: true, readOnly: true }); |
3865 if (event.args) { |
3837 $("#w2_calcium").jqxNumberInput( Show1wat ); |
3866 var datarecord, index = event.args.index; |
3838 $("#w2_magnesium").jqxNumberInput( Show1wat ); |
3867 datarecord = waterprofiles.records[index]; |
3839 $("#w2_sodium").jqxNumberInput( Show1wat ); |
3868 $('#pr_calcium').val(datarecord.calcium); |
3840 $("#w2_total_alkalinity").jqxNumberInput( Show1wat ); |
3869 $('#pr_sulfate').val(datarecord.sulfate); |
3841 $("#w2_chloride").jqxNumberInput( Show1wat ); |
3870 $('#pr_chloride').val(datarecord.chloride); |
3842 $("#w2_sulfate").jqxNumberInput( Show1wat ); |
3871 $('#pr_sodium').val(datarecord.sodium); |
3843 $("#w2_ph").jqxNumberInput( Show1wat ); |
3872 $('#pr_magnesium').val(datarecord.magnesium); |
3844 // Water mixed |
3873 $('#pr_total_alkalinity').val(datarecord.total_alkalinity); |
3845 $("#wg_amount").jqxNumberInput( Show1wat ); |
3874 } |
3846 $("#wg_calcium").jqxNumberInput( Show1wat ); |
3875 }); |
3847 $("#wg_magnesium").jqxNumberInput( Show1wat ); |
3876 $('#pr_calcium').jqxNumberInput(Show1wat); |
3848 $("#wg_sodium").jqxNumberInput( Show1wat ); |
3877 $('#pr_magnesium').jqxNumberInput(Show1wat); |
3849 $("#wg_total_alkalinity").jqxNumberInput( Show1wat ); |
3878 $('#pr_sodium').jqxNumberInput(Show1wat); |
3850 $("#wg_chloride").jqxNumberInput( Show1wat ); |
3879 $('#pr_total_alkalinity').jqxNumberInput(Show1wat); |
3851 $("#wg_sulfate").jqxNumberInput( Show1wat ); |
3880 $('#pr_chloride').jqxNumberInput(Show1wat); |
3852 $("#wg_ph").jqxNumberInput( Show1wat ); |
3881 $('#pr_sulfate').jqxNumberInput(Show1wat); |
3853 // Water treated |
3882 |
3854 $("#wb_calcium").jqxTooltip({ content: 'De ideale hoeveelheid Calcium is tussen 40 en 150.'}); |
3883 // Water agents |
3855 $("#wb_calcium").jqxNumberInput( Show1wat ); |
3884 $('#wa_cacl2').jqxTooltip({ content: 'Voor het maken van een ander waterprofiel. Voegt calcium en chloride toe. Voor het verbeteren van zoetere bieren.'}); |
3856 $("#wb_magnesium").jqxTooltip({ content: 'De ideale hoeveelheid Magnesium is lager dan 30.'}); |
3885 $('#wa_cacl2').jqxNumberInput(Spin1dec); |
3857 $("#wb_magnesium").jqxNumberInput( Show1wat ); |
3886 $('#wa_caso4').jqxTooltip({ content: 'Gips. Voor het maken van een ander waterprofiel. Voegt calcium en sulfaat toe. Voor het verbeteren van bittere bieren.'}); |
3858 $("#wb_sodium").jqxTooltip({ content: 'De ideale hoeveelheid Natrium is lager dan 150.'}); |
3887 $('#wa_caso4').jqxNumberInput(Spin1dec); |
3859 $("#wb_sodium").jqxNumberInput( Show1wat ); |
3888 $('#wa_mgso4').jqxTooltip({ content: 'Epsom zout. Voor het maken van een ander waterprofiel. Voegt magnesium en sulfaat toe. Gebruik spaarzaam!'}); |
3860 $("#wb_chloride").jqxTooltip({ content: 'De ideale hoeveelheid Chloride is tussen 50 en 100.'}); |
3889 $('#wa_mgso4').jqxNumberInput(Spin1dec); |
3861 $("#wb_chloride").jqxNumberInput( Show1wat ); |
3890 $('#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.'}); |
3862 $("#wb_sulfate").jqxTooltip({ content: 'De ideale hoeveelheid Sulfaat is tussen 50 en 350.'}); |
3891 $('#wa_nacl').jqxNumberInput(Spin1dec); |
3863 $("#wb_sulfate").jqxNumberInput( Show1wat ); |
3892 $('#mash_ph').jqxTooltip({ content: 'Maisch pH tussen 5.2 en 5.6. Gebruik 5.2 voor lichte en 5.5 voor donkere bieren.'}); |
3864 $("#wb_total_alkalinity").jqxNumberInput( Show1wat ); |
3893 $('#mash_ph').jqxNumberInput(SpinpH); |
3865 $("#wb_ph").jqxNumberInput( Show1wat ); |
3894 $('#calc_acid').jqxCheckBox({ theme: theme, width: 120, height: 23 }); |
3866 // Water target profile |
3895 $('#wa_base_name').jqxDropDownList({ |
3867 $("#pr_name").jqxDropDownList({ |
3896 theme: theme, |
3868 placeHolder: "Kies doel profiel:", |
3897 source: BaseTypeAdapter, |
3869 theme: theme, |
3898 valueMember: 'id', |
3870 source: waterprofiles, |
3899 displayMember: 'nl', |
3871 displayMember: "name", |
3900 width: 170, |
3872 width: 250, |
3901 height: 23, |
3873 height: 27, |
3902 autoDropDownHeight: true |
3874 dropDownWidth: 400, |
3903 }); |
3875 dropDownHeight: 300 |
3904 $('#wa_base').jqxNumberInput(Spin2dec); |
3876 }); |
3905 $('#wa_base').jqxNumberInput({ symbol: ' gr', symbolPosition: 'right' }); |
3877 $("#pr_name").on('select', function (event) { |
3906 $('#wa_acid_name').jqxDropDownList({ |
3878 if (event.args) { |
3907 theme: theme, |
3879 var index = event.args.index; |
3908 source: AcidTypeAdapter, |
3880 var datarecord = waterprofiles.records[index]; |
3909 valueMember: 'id', |
3881 $("#pr_calcium").val(datarecord.calcium); |
3910 displayMember: 'nl', |
3882 $("#pr_sulfate").val(datarecord.sulfate); |
3911 width: 170, |
3883 $("#pr_chloride").val(datarecord.chloride); |
3912 height: 23, |
3884 $("#pr_sodium").val(datarecord.sodium); |
3913 autoDropDownHeight: true |
3885 $("#pr_magnesium").val(datarecord.magnesium); |
3914 }); |
3886 $("#pr_total_alkalinity").val(datarecord.total_alkalinity); |
3915 $('#wa_acid').jqxNumberInput(Spin2dec); |
3887 } |
3916 $('#wa_acid').jqxNumberInput({ symbol: ' ml', symbolPosition: 'right' }); |
3888 }); |
3917 $('#wa_acid_perc').jqxNumberInput(Perc0); |
3889 $("#pr_calcium").jqxNumberInput( Show1wat ); |
3918 $('#wa_acid_perc').jqxNumberInput({ width: 70, symbol: '%', symbolPosition: 'right' }); |
3890 $("#pr_magnesium").jqxNumberInput( Show1wat ); |
3919 // Sparge water |
3891 $("#pr_sodium").jqxNumberInput( Show1wat ); |
3920 $('#sparge_temp').jqxNumberInput(Spin1dec); |
3892 $("#pr_total_alkalinity").jqxNumberInput( Show1wat ); |
3921 $('#sparge_volume').jqxNumberInput(Spin1dec); |
3893 $("#pr_chloride").jqxNumberInput( Show1wat ); |
3922 $('#sparge_ph').jqxNumberInput(SpinpH); |
3894 $("#pr_sulfate").jqxNumberInput( Show1wat ); |
3923 $('#sparge_source').jqxDropDownList({ |
3895 |
3924 theme: theme, |
3896 // Water agents |
3925 source: SpargeSourceAdapter, |
3897 $("#wa_cacl2").jqxTooltip({ content: 'Voor het maken van een ander waterprofiel. Voegt calcium en chloride toe. Voor het verbeteren van zoetere bieren.'}); |
3926 valueMember: 'id', |
3898 $("#wa_cacl2").jqxNumberInput( Spin1dec ); |
3927 displayMember: 'nl', |
3899 $("#wa_caso4").jqxTooltip({ content: 'Gips. Voor het maken van een ander waterprofiel. Voegt calcium en sulfaat toe. Voor het verbeteren van bittere bieren.'}); |
3928 width: 110, |
3900 $("#wa_caso4").jqxNumberInput( Spin1dec ); |
3929 height: 23, |
3901 $("#wa_mgso4").jqxTooltip({ content: 'Epsom zout. Voor het maken van een ander waterprofiel. Voegt magnesium en sulfaat toe. Gebruik spaarzaam!'}); |
3930 autoDropDownHeight: true |
3902 $("#wa_mgso4").jqxNumberInput( Spin1dec ); |
3931 }); |
3903 $("#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.'}); |
3932 $('#sparge_acid_amount').jqxNumberInput(Spin2dec); |
3904 $("#wa_nacl").jqxNumberInput( Spin1dec ); |
3933 $('#sparge_acid_amount').jqxNumberInput({ spinButtons: false, readOnly: true, symbol: ' ml', symbolPosition: 'right' }); |
3905 $("#mash_ph").jqxTooltip({ content: 'Maisch pH tussen 5.2 en 5.6. Gebruik 5.2 voor lichte en 5.5 voor donkere bieren.'}); |
3934 $('#sparge_acid_type').jqxDropDownList({ |
3906 $("#mash_ph").jqxNumberInput( SpinpH ); |
3935 theme: theme, |
3907 $("#calc_acid").jqxCheckBox({ theme: theme, width: 120, height: 23 }); |
3936 source: AcidTypeAdapter, |
3908 $("#wa_base_name").jqxDropDownList({ |
3937 valueMember: 'id', |
3909 theme: theme, |
3938 displayMember: 'nl', |
3910 source: BaseTypeAdapter, |
3939 width: 110, |
3911 valueMember: 'id', |
3940 height: 23, |
3912 displayMember: 'nl', |
3941 autoDropDownHeight: true |
3913 width: 170, |
3942 }); |
3914 height: 23, |
3943 $('#sparge_acid_perc').jqxNumberInput(Perc0); |
3915 autoDropDownHeight: true |
3944 $('#sparge_acid_perc').jqxNumberInput({ symbol: '%', symbolPosition: 'right' }); |
3916 }); |
3945 |
3917 $("#wa_base").jqxNumberInput( Spin2dec ); |
3946 // Tabs inside the popup window. |
3918 $("#wa_base").jqxNumberInput({ symbol: ' gr', symbolPosition: 'right' }); |
3947 $('#jqxTabs').jqxTabs({ |
3919 $("#wa_acid_name").jqxDropDownList({ |
3948 theme: theme, |
3920 theme: theme, |
3949 width: 1280, |
3921 source: AcidTypeAdapter, |
3950 height: 660, |
3922 valueMember: 'id', |
3951 autoHeight: false, |
3923 displayMember: 'nl', |
3952 position: 'top' |
3924 width: 170, |
3953 }); |
3925 height: 23, |
3954 |
3926 autoDropDownHeight: true |
3955 // Buttons below |
3927 }); |
3956 $('#Export').jqxButton({ template: 'info', width: '80px', theme: theme }); |
3928 $("#wa_acid").jqxNumberInput( Spin2dec ); |
3957 $('#Export').bind('click', function() { |
3929 $("#wa_acid").jqxNumberInput({ symbol: ' ml', symbolPosition: 'right' }); |
3958 saveRecord(); |
3930 $("#wa_acid_perc").jqxNumberInput( Perc0 ); |
3959 window.location.href = 'rec_export.php?record=' + my_record + '&return=' + my_return + '&name=' + dataRecord.name; |
3931 $("#wa_acid_perc").jqxNumberInput({ width: 70, symbol: '%', symbolPosition: 'right' }); |
3960 }); |
3932 // Sparge water |
3961 |
3933 $("#sparge_temp").jqxNumberInput( Spin1dec ); |
3962 $('#Delete').jqxButton({ template: 'danger', width: '80px', theme: theme }); |
3934 $("#sparge_volume").jqxNumberInput( Spin1dec ); |
3963 $('#Delete').bind('click', function() { |
3935 $("#sparge_ph").jqxNumberInput( SpinpH ); |
3964 // Open a popup to confirm this action. |
3936 $("#sparge_source").jqxDropDownList({ |
3965 $('#eventWindow').jqxWindow('open'); |
3937 theme: theme, |
3966 $('#delOk').click(function() { |
3938 source: SpargeSourceAdapter, |
3967 var data = 'delete=true&' + $.param({ record: my_record }); |
3939 valueMember: 'id', |
3968 $.ajax({ |
3940 displayMember: 'nl', |
3969 dataType: 'json', |
3941 width: 110, |
3970 url: url, |
3942 height: 23, |
3971 cache: false, |
3943 autoDropDownHeight: true |
3972 data: data, |
3944 }); |
3973 type: 'POST', |
3945 $("#sparge_acid_amount").jqxNumberInput( Spin2dec ); |
3974 success: function(data, status, xhr) { |
3946 $("#sparge_acid_amount").jqxNumberInput({ spinButtons: false, readOnly: true, symbol: ' ml', symbolPosition: 'right' }); |
3975 // delete command is executed. |
3947 $("#sparge_acid_type").jqxDropDownList({ |
3976 window.location.href = my_return; |
3948 theme: theme, |
3977 }, |
3949 source: AcidTypeAdapter, |
3978 error: function(jqXHR, textStatus, errorThrown) { |
3950 valueMember: 'id', |
3979 } |
3951 displayMember: 'nl', |
3980 }); |
3952 width: 110, |
3981 }); |
3953 height: 23, |
3982 }); |
3954 autoDropDownHeight: true |
3983 |
3955 }); |
3984 $('#Cancel').jqxButton({ template: 'primary', width: '80px', theme: theme }); |
3956 $("#sparge_acid_perc").jqxNumberInput( Perc0 ); |
3985 $('#Cancel').bind('click', function() { |
3957 $("#sparge_acid_perc").jqxNumberInput({ symbol: '%', symbolPosition: 'right' }); |
3986 window.location.href = my_return; |
3958 |
3987 }); |
3959 // Tabs inside the popup window. |
3988 |
3960 $('#jqxTabs').jqxTabs({ |
3989 $('#Save').jqxButton({ template: 'success', width: '80px', theme: theme }); |
3961 theme: theme, |
3990 $('#Save').bind('click', function() { |
3962 width: 1280, |
3991 saveRecord(); |
3963 height: 660, |
3992 window.location.href = my_return; |
3964 autoHeight: false, |
3993 }); |
3965 position: 'top' |
3994 createDelElements(); |
3966 }); |
|
3967 |
|
3968 // Buttons below |
|
3969 $("#Export").jqxButton({ template: "info", width: '80px', theme: theme }); |
|
3970 $("#Export").bind('click', function () { |
|
3971 saveRecord(); |
|
3972 var url="rec_export.php?record=" + my_record + "&return=" + my_return + "&name=" + dataRecord.name; |
|
3973 window.location.href = url; |
|
3974 }); |
|
3975 |
|
3976 $("#Delete").jqxButton({ template: "danger", width: '80px', theme: theme }); |
|
3977 $("#Delete").bind('click', function () { |
|
3978 // Open a popup to confirm this action. |
|
3979 $('#eventWindow').jqxWindow('open'); |
|
3980 $("#delOk").click(function () { |
|
3981 var data = "delete=true&" + $.param({ record: my_record }); |
|
3982 $.ajax({ |
|
3983 dataType: 'json', |
|
3984 url: url, |
|
3985 cache: false, |
|
3986 data: data, |
|
3987 type: "POST", |
|
3988 success: function (data, status, xhr) { |
|
3989 // delete command is executed. |
|
3990 window.location.href = my_return; |
|
3991 }, |
|
3992 error: function (jqXHR, textStatus, errorThrown) { |
|
3993 } |
|
3994 }); |
|
3995 }); |
|
3996 }); |
|
3997 |
|
3998 $("#Cancel").jqxButton({ template: "primary", width: '80px', theme: theme }); |
|
3999 $("#Cancel").bind('click', function () { |
|
4000 window.location.href = my_return; |
|
4001 }); |
|
4002 |
|
4003 $("#Save").jqxButton({ template: "success", width: '80px', theme: theme }); |
|
4004 $("#Save").bind('click', function () { |
|
4005 saveRecord(); |
|
4006 window.location.href = my_return; |
|
4007 }); |
|
4008 createDelElements(); |
|
4009 }); |
3995 }); |
4010 |
3996 |