Mon, 16 Sep 2019 17:26:38 +0200
Color templates for the prod_new and rec_new tab buttons.
111
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /***************************************************************************** |
164
0a5abea575a9
Added the last tab, fermentation to the product editer.
Michiel Broek <mbroek@mbse.eu>
parents:
163
diff
changeset
|
2 | * Copyright (C) 2018-2019 |
111
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * Michiel Broek <mbroek at mbse dot eu> |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * This file is part of BMS |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * This is free software; you can redistribute it and/or modify it |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * under the terms of the GNU General Public License as published by the |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * Free Software Foundation; either version 2, or (at your option) any |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * later version. |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * BrewCloud is distributed in the hope that it will be useful, but |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | * General Public License for more details. |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | * |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
19 | * along with ThermFerm; see the file COPYING. If not, write to the Free |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | *****************************************************************************/ |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
23 | |
478 | 24 | function createDelElements() { |
25 | ||
26 | $('#eventWindow').jqxWindow({ | |
27 | theme: theme, | |
28 | position: { x: 490, y: 210 }, | |
29 | width: 300, | |
30 | height: 175, | |
31 | resizable: false, | |
32 | isModal: true, | |
33 | modalOpacity: 0.4, | |
34 | okButton: $('#delOk'), | |
35 | cancelButton: $('#delCancel'), | |
36 | initContent: function() { | |
37 | $('#delOk').jqxButton({ template: 'danger', width: '65px', theme: theme }); | |
38 | $('#delCancel').jqxButton({ template: 'success', width: '65px', theme: theme }); | |
39 | $('#delCancel').focus(); | |
40 | } | |
41 | }); | |
42 | $('#eventWindow').jqxWindow('hide'); | |
112
7ef48396f705
Added some buttons. Only allow product delete if it has no serious data.
Michiel Broek <mbroek@mbse.eu>
parents:
111
diff
changeset
|
43 | } |
7ef48396f705
Added some buttons. Only allow product delete if it has no serious data.
Michiel Broek <mbroek@mbse.eu>
parents:
111
diff
changeset
|
44 | |
7ef48396f705
Added some buttons. Only allow product delete if it has no serious data.
Michiel Broek <mbroek@mbse.eu>
parents:
111
diff
changeset
|
45 | |
7ef48396f705
Added some buttons. Only allow product delete if it has no serious data.
Michiel Broek <mbroek@mbse.eu>
parents:
111
diff
changeset
|
46 | |
478 | 47 | $(document).ready(function() { |
48 | ||
49 | var i, | |
50 | to_100 = false, // Fermentables adjust to 100% | |
51 | preboil_sg = 0, | |
52 | aboil_sg = 0, | |
53 | est_mash_sg = 0, | |
54 | psugar = 0, // Percentage real sugars | |
55 | pcara = 0, // Percentage cara/crystal malts | |
56 | svg = 77, // Default attenuation | |
57 | mashkg = 0, // Malt in mash weight | |
58 | pitchrate = 0.75, // Yeast pitch rate default | |
59 | initcells = 0, // Initial yeast cell count | |
60 | ||
61 | ok_fermentables = 1, // Fermentables are in stock | |
62 | ok_hops = 1, // Hops are in stock | |
63 | ok_miscs = 1, // Miscs are in stock | |
64 | ok_yeasts = 1, // Yeasts are in stock | |
65 | ok_waters = 1, // Waters are in stock | |
66 | ||
67 | hop_flavour = 0, | |
68 | hop_aroma = 0, | |
69 | mash_infuse = 0, | |
70 | last_base = '', | |
71 | last_acid = '', | |
72 | ||
73 | MMCa = 40.048, | |
74 | MMMg = 24.305, | |
75 | MMNa = 22.98976928, | |
76 | MMCl = 35.453, | |
77 | MMSO4 = 96.0626, | |
78 | MMHCO3 = 61.01684, | |
79 | MMCaSO4 = 172.171, | |
80 | MMCaCl2 = 147.015, | |
81 | MMCaCO3 = 100.087, | |
82 | MMMgSO4 = 246.475, | |
83 | MMNaHCO3 = 84.007, | |
84 | MMNa2CO3 = 105.996, | |
85 | MMNaCl = 58.443, | |
86 | MMCaOH2 = 74.06268, | |
87 | ||
88 | fermentableRow = 0, | |
89 | fermentableData = {}, | |
90 | fermentableInit = 1, | |
91 | hopRow = 0, | |
92 | hopData = {}, | |
93 | miscRow = 0, | |
94 | miscData = {}, | |
95 | yeastRow = 0, | |
96 | yeastData = {}, | |
97 | mashRow = 0, | |
98 | mashData = {}, | |
99 | Ka1 = 0.0000004445, | |
100 | Ka2 = 0.0000000000468, | |
101 | dataRecord = {}, | |
102 | url = 'includes/db_product.php', | |
484
2083c274b283
In the product editor mash tab, display the total mash volume and the total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
479
diff
changeset
|
103 | MaltVolume = 0.87, // l/kg 0.688 volgens internetbronnen, gemeten 0.874 l/kg, na enige tijd maischen 0,715 l/kg (A3 Otten). |
478 | 104 | |
105 | // Prepare the data | |
106 | source = { | |
107 | datatype: 'json', | |
108 | cache: false, | |
109 | datafields: [ | |
110 | // From prod_main | |
111 | { name: 'record', type: 'number' }, | |
112 | { name: 'uuid', type: 'string' }, | |
113 | { name: 'name', type: 'string' }, | |
114 | { name: 'code', type: 'string' }, | |
115 | { name: 'birth', type: 'string' }, | |
116 | { name: 'stage', type: 'int' }, | |
117 | { name: 'notes', type: 'string' }, | |
118 | { name: 'log_brew', type: 'int' }, | |
119 | { name: 'log_fermentation', type: 'int' }, | |
120 | { name: 'inventory_reduced', type: 'int' }, | |
121 | { name: 'locked', type: 'int' }, | |
122 | { name: 'eq_name', type: 'string' }, | |
123 | { name: 'eq_boil_size', type: 'float' }, | |
124 | { name: 'eq_batch_size', type: 'float' }, | |
125 | { name: 'eq_tun_volume', type: 'float' }, | |
126 | { name: 'eq_tun_weight', type: 'float' }, | |
127 | { name: 'eq_tun_specific_heat', type: 'float' }, | |
128 | { name: 'eq_tun_material', type: 'int' }, | |
129 | { name: 'eq_tun_height', type: 'float' }, | |
130 | { name: 'eq_top_up_water', type: 'float' }, | |
131 | { name: 'eq_trub_chiller_loss', type: 'float' }, | |
132 | { name: 'eq_evap_rate', type: 'float' }, | |
133 | { name: 'eq_boil_time', type: 'float' }, | |
134 | { name: 'eq_calc_boil_volume', type: 'int' }, | |
135 | { name: 'eq_top_up_kettle', type: 'float' }, | |
136 | { name: 'eq_hop_utilization', type: 'float' }, | |
137 | { name: 'eq_notes', type: 'string' }, | |
138 | { name: 'eq_lauter_volume', type: 'float' }, | |
139 | { name: 'eq_lauter_height', type: 'float' }, | |
140 | { name: 'eq_lauter_deadspace', type: 'float' }, | |
141 | { name: 'eq_kettle_volume', type: 'float' }, | |
142 | { name: 'eq_kettle_height', type: 'float' }, | |
143 | { name: 'eq_mash_volume', type: 'float' }, | |
144 | { name: 'eq_mash_max', type: 'float' }, | |
145 | { name: 'eq_efficiency', type: 'float' }, | |
146 | { name: 'brew_date_start', type: 'string' }, | |
147 | { name: 'brew_mash_ph', type: 'float' }, | |
148 | { name: 'brew_mash_sg', type: 'float' }, | |
149 | { name: 'brew_mash_efficiency', type: 'float' }, | |
150 | { name: 'brew_sparge_est', type: 'float' }, | |
151 | { name: 'brew_sparge_ph', type: 'float' }, | |
152 | { name: 'brew_preboil_volume', type: 'float' }, | |
153 | { name: 'brew_preboil_sg', type: 'float' }, | |
154 | { name: 'brew_preboil_ph', type: 'float' }, | |
155 | { name: 'brew_preboil_efficiency', type: 'float' }, | |
156 | { name: 'brew_aboil_volume', type: 'float' }, | |
157 | { name: 'brew_aboil_sg', type: 'float' }, | |
158 | { name: 'brew_aboil_ph', type: 'float' }, | |
159 | { name: 'brew_aboil_efficiency', type: 'float' }, | |
160 | { name: 'brew_cooling_method', type: 'int' }, | |
161 | { name: 'brew_cooling_time', type: 'float' }, | |
162 | { name: 'brew_cooling_to', type: 'float' }, | |
163 | { name: 'brew_whirlpool9', type: 'float' }, | |
164 | { name: 'brew_whirlpool7', type: 'float' }, | |
165 | { name: 'brew_whirlpool6', type: 'float' }, | |
166 | { name: 'brew_whirlpool2', type: 'float' }, | |
167 | { name: 'brew_fermenter_volume', type: 'float' }, | |
168 | { name: 'brew_fermenter_extrawater', type: 'float' }, | |
169 | { name: 'brew_fermenter_tcloss', type: 'float' }, | |
170 | { name: 'brew_aeration_time', type: 'float' }, | |
171 | { name: 'brew_aeration_speed', type: 'float' }, | |
172 | { name: 'brew_aeration_type', type: 'int' }, | |
173 | { name: 'brew_fermenter_sg', type: 'float' }, | |
174 | { name: 'brew_fermenter_ibu', type: 'float' }, | |
175 | { name: 'brew_fermenter_color', type: 'float' }, | |
176 | { name: 'brew_date_end', type: 'string' }, | |
177 | { name: 'og', type: 'float' }, | |
178 | { name: 'fg', type: 'float' }, | |
179 | { name: 'primary_start_temp', type: 'float' }, | |
180 | { name: 'primary_max_temp', type: 'float' }, | |
181 | { name: 'primary_end_temp', type: 'float' }, | |
182 | { name: 'primary_end_sg', type: 'float' }, | |
183 | { name: 'primary_end_date', type: 'string' }, | |
184 | { name: 'secondary_temp', type: 'float' }, | |
185 | { name: 'secondary_end_sg', type: 'float' }, | |
186 | { name: 'secondary_end_date', type: 'string' }, | |
187 | { name: 'tertiary_temp', type: 'float' }, | |
188 | { name: 'package_date', type: 'string' }, | |
189 | { name: 'package_volume', type: 'float' }, | |
190 | { name: 'package_infuse_amount', type: 'float' }, | |
191 | { name: 'package_infuse_abv', type: 'float' }, | |
192 | { name: 'package_infuse_notes', type: 'string' }, | |
193 | { name: 'package_abv', type: 'float' }, | |
194 | { name: 'package_ph', type: 'float' }, | |
195 | { name: 'bottle_amount', type: 'float' }, | |
196 | { name: 'bottle_carbonation', type: 'float' }, | |
197 | { name: 'bottle_priming_water', type: 'float' }, | |
198 | { name: 'bottle_priming_amount', type: 'float' }, | |
199 | { name: 'bottle_carbonation_temp', type: 'float' }, | |
200 | { name: 'keg_amount', type: 'float' }, | |
201 | { name: 'keg_carbonation', type: 'float' }, | |
202 | { name: 'keg_priming_water', type: 'float' }, | |
203 | { name: 'keg_priming_amount', type: 'float' }, | |
204 | { name: 'keg_carbonation_temp', type: 'float' }, | |
205 | { name: 'keg_forced_carb', type: 'int' }, | |
206 | { name: 'keg_pressure', type: 'float' }, | |
207 | { name: 'taste_notes', type: 'string' }, | |
208 | { name: 'taste_rate', type: 'float' }, | |
209 | { name: 'taste_date', type: 'string' }, | |
210 | { name: 'taste_color', type: 'string' }, | |
211 | { name: 'taste_transparency', type: 'string' }, | |
212 | { name: 'taste_head', type: 'string' }, | |
213 | { name: 'taste_aroma', type: 'string' }, | |
214 | { name: 'taste_taste', type: 'string' }, | |
215 | { name: 'taste_mouthfeel', type: 'string' }, | |
216 | { name: 'taste_aftertaste', type: 'string' }, | |
217 | { name: 'st_name', type: 'string' }, | |
218 | { name: 'st_letter', type: 'string' }, | |
219 | { name: 'st_guide', type: 'string' }, | |
220 | { name: 'st_category', type: 'string' }, | |
221 | { name: 'st_category_number', type: 'float' }, | |
222 | { name: 'st_type', type: 'int' }, | |
223 | { name: 'st_og_min', type: 'float' }, | |
224 | { name: 'st_og_max', type: 'float' }, | |
225 | { name: 'st_fg_min', type: 'float' }, | |
226 | { name: 'st_fg_max', type: 'float' }, | |
227 | { name: 'st_ibu_min', type: 'float' }, | |
228 | { name: 'st_ibu_max', type: 'float' }, | |
229 | { name: 'st_color_min', type: 'float' }, | |
230 | { name: 'st_color_max', type: 'float' }, | |
231 | { name: 'st_carb_min', type: 'float' }, | |
232 | { name: 'st_carb_max', type: 'float' }, | |
233 | { name: 'st_abv_min', type: 'float' }, | |
234 | { name: 'st_abv_max', type: 'float' }, | |
235 | { name: 'type', type: 'int' }, | |
236 | { name: 'batch_size', type: 'float' }, | |
237 | { name: 'boil_size', type: 'float' }, | |
238 | { name: 'boil_time', type: 'float' }, | |
239 | { name: 'efficiency', type: 'float' }, | |
240 | { name: 'est_og', type: 'float' }, | |
241 | { name: 'est_fg', type: 'float' }, | |
242 | { name: 'est_abv', type: 'float' }, | |
243 | { name: 'est_color', type: 'float' }, | |
244 | { name: 'color_method', type: 'int' }, | |
245 | { name: 'est_ibu', type: 'float' }, | |
246 | { name: 'ibu_method', type: 'int' }, | |
247 | { name: 'est_carb', type: 'float' }, | |
248 | { name: 'sparge_temp', type: 'float' }, | |
249 | { name: 'sparge_ph', type: 'float' }, | |
250 | { name: 'sparge_volume', type: 'float' }, | |
251 | { name: 'sparge_source', type: 'int' }, | |
252 | { name: 'sparge_acid_type', type: 'int' }, | |
253 | { name: 'sparge_acid_perc', type: 'float' }, | |
254 | { name: 'sparge_acid_amount', type: 'float' }, | |
255 | { name: 'mash_ph', type: 'float' }, | |
256 | { name: 'mash_name', type: 'string' }, | |
257 | { name: 'calc_acid', type: 'int' }, | |
258 | { name: 'w1_name', type: 'string' }, | |
259 | { name: 'w1_amount', type: 'float' }, | |
260 | { name: 'w1_calcium', type: 'float' }, | |
261 | { name: 'w1_sulfate', type: 'float' }, | |
262 | { name: 'w1_chloride', type: 'float' }, | |
263 | { name: 'w1_sodium', type: 'float' }, | |
264 | { name: 'w1_magnesium', type: 'float' }, | |
265 | { name: 'w1_total_alkalinity', type: 'float' }, | |
266 | { name: 'w1_ph', type: 'float' }, | |
267 | { name: 'w1_cost', type: 'float' }, | |
268 | { name: 'w2_name', type: 'string' }, | |
269 | { name: 'w2_amount', type: 'float' }, | |
270 | { name: 'w2_calcium', type: 'float' }, | |
271 | { name: 'w2_sulfate', type: 'float' }, | |
272 | { name: 'w2_chloride', type: 'float' }, | |
273 | { name: 'w2_sodium', type: 'float' }, | |
274 | { name: 'w2_magnesium', type: 'float' }, | |
275 | { name: 'w2_total_alkalinity', type: 'float' }, | |
276 | { name: 'w2_ph', type: 'float' }, | |
277 | { name: 'w2_cost', type: 'float' }, | |
278 | { name: 'wg_amount', type: 'float' }, | |
279 | { name: 'wg_calcium', type: 'float' }, | |
280 | { name: 'wg_sulfate', type: 'float' }, | |
281 | { name: 'wg_chloride', type: 'float' }, | |
282 | { name: 'wg_sodium', type: 'float' }, | |
283 | { name: 'wg_magnesium', type: 'float' }, | |
284 | { name: 'wg_total_alkalinity', type: 'float' }, | |
285 | { name: 'wg_ph', type: 'float' }, | |
286 | { name: 'wb_calcium', type: 'float' }, | |
287 | { name: 'wb_sulfate', type: 'float' }, | |
288 | { name: 'wb_chloride', type: 'float' }, | |
289 | { name: 'wb_sodium', type: 'float' }, | |
290 | { name: 'wb_magnesium', type: 'float' }, | |
291 | { name: 'wb_total_alkalinity', type: 'float' }, | |
292 | { name: 'wb_ph', type: 'float' }, | |
293 | { name: 'wa_acid_name', type: 'int' }, | |
294 | { name: 'wa_acid_perc', type: 'int' }, | |
295 | { name: 'wa_base_name', type: 'int' }, | |
296 | { name: 'starter_enable', type: 'int' }, | |
297 | { name: 'starter_type', type: 'int' }, | |
298 | { name: 'starter_sg', type: 'float' }, | |
299 | { name: 'starter_viability', type: 'int' }, | |
300 | { name: 'prop1_type', type: 'int' }, | |
301 | { name: 'prop1_volume', type: 'float' }, | |
302 | { name: 'prop2_type', type: 'int' }, | |
303 | { name: 'prop2_volume', type: 'float' }, | |
304 | { name: 'prop3_type', type: 'int' }, | |
305 | { name: 'prop3_volume', type: 'float' }, | |
306 | { name: 'prop4_type', type: 'int' }, | |
307 | { name: 'prop4_volume', type: 'float' }, | |
308 | { name: 'fermentables', type: 'array' }, | |
309 | { name: 'hops', type: 'array' }, | |
310 | { name: 'miscs', type: 'array' }, | |
311 | { name: 'yeasts', type: 'array' }, | |
312 | { name: 'mashs', type: 'array' } | |
313 | ], | |
314 | id: 'record', | |
315 | url: url + '?record=' + my_record | |
316 | }, | |
317 | ||
318 | // Load data and select one record. | |
319 | dataAdapter = new $.jqx.dataAdapter(source, { | |
320 | loadComplete: function() { | |
321 | var records = dataAdapter.records; | |
322 | dataRecord = records[0]; | |
323 | // Hidden record uuid | |
324 | $('#name').val(dataRecord.name); | |
325 | $('#code').val(dataRecord.code); | |
326 | $('#birth').val(dataRecord.birth); | |
327 | $('#stage').val(StageData[dataRecord.stage].nl); | |
328 | $('#notes').val(dataRecord.notes); | |
329 | $('#locked').val(dataRecord.locked); | |
330 | $('#eq_name').val(dataRecord.eq_name); | |
331 | $('#eq_notes').val(dataRecord.eq_notes); | |
332 | $('#eq_boil_size').val(dataRecord.eq_boil_size); | |
333 | $('#eq_batch_size').val(dataRecord.eq_batch_size); | |
334 | $('#eq_tun_volume').val(dataRecord.eq_tun_volume); | |
335 | $('#eq_top_up_water').val(dataRecord.eq_top_up_water); | |
336 | $('#eq_trub_chiller_loss').val(dataRecord.eq_trub_chiller_loss); | |
337 | $('#eq_evap_rate').val(dataRecord.eq_evap_rate); | |
338 | $('#eq_boil_time').val(dataRecord.eq_boil_time); | |
339 | $('#eq_top_up_kettle').val(dataRecord.eq_top_up_kettle); | |
340 | $('#eq_hop_utilization').val(dataRecord.eq_hop_utilization); | |
341 | $('#eq_lauter_volume').val(dataRecord.eq_lauter_volume); | |
342 | $('#eq_lauter_deadspace').val(dataRecord.eq_lauter_deadspace); | |
343 | $('#eq_kettle_volume').val(dataRecord.eq_kettle_volume); | |
344 | $('#eq_mash_volume').val(dataRecord.eq_mash_volume); | |
345 | $('#eq_mash_max').val(dataRecord.eq_mash_max); | |
346 | $('#eq_efficiency').val(dataRecord.eq_efficiency); | |
347 | // Brewdate | |
348 | $('#brew_date_start').val(dataRecord.brew_date_start); | |
349 | $('#brew_mash_ph').val(dataRecord.brew_mash_ph); | |
350 | $('#brew_mash_sg').val(dataRecord.brew_mash_sg); | |
351 | $('#brew_mash_efficiency').val(dataRecord.brew_mash_efficiency); | |
352 | // Header Spoelen en filteren | |
353 | $('#brew_sparge_temperature').val(dataRecord.sparge_temp); | |
354 | $('#brew_sparge_volume').val(dataRecord.sparge_volume); | |
355 | $('#brew_sparge_est').val(dataRecord.brew_sparge_est); | |
356 | $('#brew_sparge_ph').val(dataRecord.brew_sparge_ph); | |
357 | // Header Beluchten | |
358 | $('#brew_aeration_type').val(dataRecord.brew_aeration_type); | |
359 | $('#brew_aeration_time').val(dataRecord.brew_aeration_time); | |
360 | $('#brew_aeration_speed').val(dataRecord.brew_aeration_speed); | |
361 | ||
362 | $('#brew_preboil_ph').val(dataRecord.brew_preboil_ph); | |
363 | $('#brew_preboil_sg').val(dataRecord.brew_preboil_sg); | |
364 | $('#brew_preboil_volume').val(dataRecord.brew_preboil_volume); | |
365 | $('#brew_preboil_efficiency').val(dataRecord.brew_preboil_efficiency); | |
366 | // Header Koelen en whirlpoolen | |
367 | $('#brew_whirlpool9').val(dataRecord.brew_whirlpool9); | |
368 | $('#brew_whirlpool7').val(dataRecord.brew_whirlpool7); | |
369 | $('#brew_whirlpool6').val(dataRecord.brew_whirlpool6); | |
370 | $('#brew_whirlpool2').val(dataRecord.brew_whirlpool2); | |
371 | // Header Naar gistvat | |
372 | $('#brew_fermenter_volume').val(dataRecord.brew_fermenter_volume); | |
373 | $('#brew_fermenter_sg').val(dataRecord.brew_fermenter_sg); | |
374 | $('#brew_fermenter_sg2').val(dataRecord.brew_fermenter_sg); | |
375 | $('#brew_fermenter_ibu').val(dataRecord.brew_fermenter_ibu); | |
376 | $('#brew_fermenter_color').val(dataRecord.brew_fermenter_color); | |
377 | $('#brew_fermenter_extrawater').val(dataRecord.brew_fermenter_extrawater); | |
378 | $('#brew_fermenter_tcloss').val(dataRecord.brew_fermenter_tcloss); | |
379 | ||
380 | $('#brew_aboil_ph').val(dataRecord.brew_aboil_ph); | |
381 | $('#brew_aboil_sg').val(dataRecord.brew_aboil_sg); | |
382 | $('#brew_aboil_volume').val(dataRecord.brew_aboil_volume); | |
383 | $('#brew_aboil_efficiency').val(dataRecord.brew_aboil_efficiency); | |
384 | // Header Koelen en whirlpoolen | |
385 | $('#brew_cooling_to').val(dataRecord.brew_cooling_to); | |
386 | $('#brew_cooling_method').val(dataRecord.brew_cooling_method); | |
387 | $('#brew_cooling_time').val(dataRecord.brew_cooling_time); | |
388 | // Niks | |
389 | $('#brew_date_end').val(dataRecord.brew_date_end); | |
390 | $('#og').val(dataRecord.og); | |
391 | $('#fg').val(dataRecord.fg); | |
392 | $('#primary_start_temp').val(dataRecord.primary_start_temp); | |
393 | $('#primary_max_temp').val(dataRecord.primary_max_temp); | |
394 | $('#primary_end_temp').val(dataRecord.primary_end_temp); | |
395 | $('#primary_end_sg').val(dataRecord.primary_end_sg); | |
396 | $('#primary_end_date').val(dataRecord.primary_end_date); | |
397 | $('#secondary_temp').val(dataRecord.secondary_temp); | |
398 | $('#secondary_end_sg').val(dataRecord.secondary_end_sg); | |
399 | $('#secondary_end_date').val(dataRecord.secondary_end_date); | |
400 | $('#tertiary_temp').val(dataRecord.tertiary_temp); | |
401 | $('#package_date').val(dataRecord.package_date); | |
402 | $('#package_volume').val(dataRecord.package_volume); | |
403 | $('#package_infuse_amount').val(dataRecord.package_infuse_amount); | |
404 | $('#package_infuse_abv').val(dataRecord.package_infuse_abv); | |
405 | $('#package_infuse_notes').val(dataRecord.package_infuse_notes); | |
406 | $('#package_abv').val(dataRecord.package_abv); | |
407 | $('#package_ph').val(dataRecord.package_ph); | |
408 | $('#bottle_amount').val(dataRecord.bottle_amount); | |
409 | $('#bottle_carbonation').val(dataRecord.bottle_carbonation); | |
410 | $('#bottle_priming_water').val(dataRecord.bottle_priming_water); | |
411 | $('#bottle_priming_amount').val(dataRecord.bottle_priming_amount); | |
412 | $('#bottle_carbonation_temp').val(dataRecord.bottle_carbonation_temp); | |
413 | $('#keg_amount').val(dataRecord.keg_amount); | |
414 | $('#keg_carbonation').val(dataRecord.keg_carbonation); | |
415 | $('#keg_priming_water').val(dataRecord.keg_priming_water); | |
416 | $('#keg_priming_amount').val(dataRecord.keg_priming_amount); | |
417 | $('#keg_carbonation_temp').val(dataRecord.keg_carbonation_temp); | |
418 | $('#keg_forced_carb').val(dataRecord.keg_forced_carb); | |
419 | $('#keg_pressure').val(dataRecord.keg_pressure); | |
420 | $('#taste_notes').val(dataRecord.taste_notes); | |
421 | $('#taste_rate').val(dataRecord.taste_rate); | |
422 | $('#taste_date').val(dataRecord.taste_date); | |
423 | $('#taste_color').val(dataRecord.taste_color); | |
424 | $('#taste_transparency').val(dataRecord.taste_transparency); | |
425 | $('#taste_head').val(dataRecord.taste_head); | |
426 | $('#taste_aroma').val(dataRecord.taste_aroma); | |
427 | $('#taste_taste').val(dataRecord.taste_taste); | |
428 | $('#taste_mouthfeel').val(dataRecord.taste_mouthfeel); | |
429 | $('#taste_aftertaste').val(dataRecord.taste_aftertaste); | |
430 | ||
431 | // Recipe | |
432 | $('#st_name').val(dataRecord.st_name); | |
433 | $('#st_letter').val(dataRecord.st_letter); | |
434 | $('#st_guide').val(dataRecord.st_guide); | |
435 | $('#st_category').val(dataRecord.st_category); | |
436 | $('#st_category_number').val(dataRecord.st_category_number); | |
437 | $('#st_type').val(StyleTypeData[dataRecord.st_type].nl); | |
438 | $('#st_og_min').val(dataRecord.st_og_min); | |
439 | $('#st_og_max').val(dataRecord.st_og_max); | |
440 | $('#st_fg_min').val(dataRecord.st_fg_min); | |
441 | $('#st_fg_max').val(dataRecord.st_fg_max); | |
442 | $('#st_abv_min').val(dataRecord.st_abv_min); | |
443 | $('#st_abv_max').val(dataRecord.st_abv_max); | |
444 | $('#st_color_min').val(dataRecord.st_color_min); | |
445 | $('#st_color_max').val(dataRecord.st_color_max); | |
446 | $('#st_ibu_min').val(dataRecord.st_ibu_min); | |
447 | $('#st_ibu_max').val(dataRecord.st_ibu_max); | |
448 | $('#st_carb_min').val(dataRecord.st_carb_min); | |
449 | $('#st_carb_min2').val(dataRecord.st_carb_min); | |
450 | $('#st_carb_max').val(dataRecord.st_carb_max); | |
451 | $('#st_carb_max2').val(dataRecord.st_carb_max); | |
452 | $('#type').val(dataRecord.type); | |
453 | $('#batch_size').val(dataRecord.batch_size); | |
454 | $('#est_a_vol').val(dataRecord.batch_size * 1.04); | |
455 | $('#boil_size').val(dataRecord.boil_size); | |
456 | $('#est_pre_vol').val(dataRecord.boil_size * 1.04); | |
457 | $('#boil_time').val(dataRecord.boil_time); | |
458 | $('#efficiency').val(dataRecord.efficiency); | |
459 | $('#est_og').val(dataRecord.est_og); | |
460 | $('#est_og2').val(dataRecord.est_og); | |
461 | $('#est_og3').val(0); | |
462 | $('#est_fg').val(dataRecord.est_fg); | |
463 | $('#est_fg2').val(dataRecord.est_fg); | |
464 | $('#est_fg3').val(dataRecord.est_fg); | |
465 | $('#est_color').val(dataRecord.est_color); | |
466 | $('#est_color2').val(dataRecord.est_color); | |
467 | $('#est_abv').val(dataRecord.est_abv); | |
468 | $('#color_method').val(dataRecord.color_method); | |
469 | $('#est_ibu').val(dataRecord.est_ibu); | |
470 | $('#est_ibu2').val(dataRecord.est_ibu); | |
471 | $('#ibu_method').val(dataRecord.ibu_method); | |
472 | $('#est_carb').val(dataRecord.est_carb); | |
473 | $('#mash_name').val(dataRecord.mash_name); | |
474 | $('#mash_ph').val(dataRecord.mash_ph); | |
475 | $('#sparge_temp').val(dataRecord.sparge_temp); | |
476 | $('#sparge_ph').val(dataRecord.sparge_ph); | |
477 | $('#sparge_volume').val(dataRecord.sparge_volume); | |
478 | $('#sparge_source').val(dataRecord.sparge_source); | |
479 | $('#sparge_acid_type').val(dataRecord.sparge_acid_type); | |
480 | $('#sparge_acid_perc').val(dataRecord.sparge_acid_perc); | |
481 | $('#sparge_acid_amount').val(dataRecord.sparge_acid_amount * 1000); | |
482 | $('#calc_acid').val(dataRecord.calc_acid); | |
483 | $('#w1_name').val(dataRecord.w1_name); | |
484 | $('#w1_amount').val(dataRecord.w1_amount); | |
485 | $('#w1_calcium').val(dataRecord.w1_calcium); | |
486 | $('#w1_sulfate').val(dataRecord.w1_sulfate); | |
487 | $('#w1_chloride').val(dataRecord.w1_chloride); | |
488 | $('#w1_sodium').val(dataRecord.w1_sodium); | |
489 | $('#w1_magnesium').val(dataRecord.w1_magnesium); | |
490 | $('#w1_total_alkalinity').val(dataRecord.w1_total_alkalinity); | |
491 | $('#w1_ph').val(dataRecord.w1_ph); | |
492 | $('#w1_cost').val(dataRecord.w1_cost); | |
493 | $('#w2_name').val(dataRecord.w2_name); | |
494 | $('#w2_amount').val(dataRecord.w2_amount); | |
495 | $('#w2_calcium').val(dataRecord.w2_calcium); | |
496 | $('#w2_sulfate').val(dataRecord.w2_sulfate); | |
497 | $('#w2_chloride').val(dataRecord.w2_chloride); | |
498 | $('#w2_sodium').val(dataRecord.w2_sodium); | |
499 | $('#w2_magnesium').val(dataRecord.w2_magnesium); | |
500 | $('#w2_total_alkalinity').val(dataRecord.w2_total_alkalinity); | |
501 | $('#w2_ph').val(dataRecord.w2_ph); | |
502 | $('#w2_cost').val(dataRecord.w2_cost); | |
503 | $('#wg_amount').val(dataRecord.wg_amount); | |
504 | $('#wg_calcium').val(dataRecord.wg_calcium); | |
505 | $('#wg_sulfate').val(dataRecord.wg_sulfate); | |
506 | $('#wg_chloride').val(dataRecord.wg_chloride); | |
507 | $('#wg_sodium').val(dataRecord.wg_sodium); | |
508 | $('#wg_magnesium').val(dataRecord.wg_magnesium); | |
509 | $('#wg_total_alkalinity').val(dataRecord.wg_total_alkalinity); | |
510 | $('#wg_ph').val(dataRecord.wg_ph); | |
511 | $('#wb_calcium').val(dataRecord.wb_calcium); | |
512 | $('#wb_sulfate').val(dataRecord.wb_sulfate); | |
513 | $('#wb_chloride').val(dataRecord.wb_chloride); | |
514 | $('#wb_sodium').val(dataRecord.wb_sodium); | |
515 | $('#wb_magnesium').val(dataRecord.wb_magnesium); | |
516 | $('#wb_total_alkalinity').val(dataRecord.wb_total_alkalinity); | |
517 | $('#wb_ph').val(dataRecord.wb_ph); | |
518 | $('#wa_acid_name').val(dataRecord.wa_acid_name); | |
519 | $('#wa_acid_perc').val(dataRecord.wa_acid_perc); | |
520 | $('#wa_base_name').val(dataRecord.wa_base_name); | |
521 | $('#starter_enable').val(dataRecord.starter_enable); | |
522 | $('#starter_type').val(dataRecord.starter_type); | |
523 | $('#starter_sg').val(dataRecord.starter_sg); | |
524 | $('#starter_viability').val(dataRecord.starter_viability); | |
525 | $('#prop1_type').val(dataRecord.prop1_type); | |
526 | $('#prop1_volume').val(dataRecord.prop1_volume); | |
527 | $('#prop2_type').val(dataRecord.prop2_type); | |
528 | $('#prop2_volume').val(dataRecord.prop2_volume); | |
529 | $('#prop3_type').val(dataRecord.prop3_type); | |
530 | $('#prop3_volume').val(dataRecord.prop3_volume); | |
531 | $('#prop4_type').val(dataRecord.prop4_type); | |
532 | $('#prop4_volume').val(dataRecord.prop4_volume); | |
533 | editFermentable(dataRecord); | |
534 | editHop(dataRecord); | |
535 | editMisc(dataRecord); | |
536 | editYeast(dataRecord); | |
537 | editMash(dataRecord); | |
538 | calcStage(); | |
539 | $('#jqxTabs').jqxTabs('select', 2); | |
540 | }, | |
541 | loadError: function(jqXHR, status, error) { | |
542 | }, | |
543 | beforeLoadComplete: function(records) { | |
544 | $('#jqxLoader').jqxLoader('open'); | |
545 | } | |
546 | }); | |
547 | ||
548 | // Inline fermentables editor | |
549 | var editFermentable = function(data) { | |
550 | var fermentableSource = { | |
551 | localdata: data.fermentables, | |
552 | datatype: 'local', | |
553 | cache: false, | |
554 | async: false, | |
555 | datafields: [ | |
556 | { name: 'f_name', type: 'string' }, | |
557 | { name: 'f_origin', type: 'string' }, | |
558 | { name: 'f_supplier', type: 'string' }, | |
559 | { name: 'f_amount', type: 'float' }, | |
560 | { name: 'f_cost', type: 'float' }, | |
561 | { name: 'f_type', type: 'int' }, | |
562 | { name: 'f_yield', type: 'float' }, | |
563 | { name: 'f_color', type: 'float' }, | |
564 | { name: 'f_coarse_fine_diff', type: 'float' }, | |
565 | { name: 'f_moisture', type: 'float' }, | |
566 | { name: 'f_diastatic_power', type: 'float' }, | |
567 | { name: 'f_protein', type: 'float' }, | |
568 | { name: 'f_max_in_batch', type: 'float' }, | |
569 | { name: 'f_graintype', type: 'int' }, | |
570 | { name: 'f_added', type: 'int' }, | |
571 | { name: 'f_dissolved_protein', type: 'float' }, | |
572 | { name: 'f_recommend_mash', type: 'int' }, | |
573 | { name: 'f_add_after_boil', type: 'int' }, | |
574 | { name: 'f_adjust_to_total_100', type: 'int' }, | |
575 | { name: 'f_percentage', type: 'float' }, | |
576 | { name: 'f_di_ph', type: 'float' }, | |
577 | { name: 'f_acid_to_ph_57', type: 'float' }, | |
578 | { name: 'f_inventory', type: 'float' }, | |
579 | { name: 'f_avail', type: 'int' } | |
580 | ], | |
581 | addrow: function(rowid, rowdata, position, commit) { | |
582 | //console.log("fermentable addrow "+rowid); | |
583 | commit(true); | |
584 | }, | |
585 | deleterow: function(rowid, commit) { | |
586 | //console.log("fermentable deleterow "+rowid); | |
587 | commit(true); | |
588 | }, | |
589 | updaterow: function(rowid, rowdata, commit) { | |
590 | //console.log("fermentable updaterow "+rowid); | |
591 | commit(true); | |
592 | } | |
593 | }, | |
594 | fermentableAdapter = new $.jqx.dataAdapter(fermentableSource); | |
595 | ||
596 | $('#fermentableGrid').jqxGrid({ | |
597 | width: 1240, | |
598 | height: 470, | |
599 | source: fermentableAdapter, | |
600 | theme: theme, | |
601 | selectionmode: 'singlerow', | |
602 | showtoolbar: true, | |
603 | rendertoolbar: function(toolbar) { | |
604 | var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); | |
605 | toolbar.append(container); | |
606 | container.append('<div style="float: left; margin-left: 165px;" id="faddrowbutton"></div>'); | |
607 | container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>'); | |
608 | container.append('<div style="float: left; margin-left: 10px;" id="finstockbutton"></div>'); | |
609 | container.append('<input style="float: left; margin-left: 400px;" id="fdeleterowbutton" type="button" value="Verwijder mout" />'); | |
610 | // add fermentable from dropdownlist. | |
611 | $('#faddrowbutton').jqxDropDownList({ | |
612 | placeHolder: 'Kies mout:', | |
613 | theme: theme, | |
614 | template: 'primary', | |
615 | source: fermentablelist, | |
616 | displayMember: 'name', | |
617 | disabled: (dataRecord.stage > 3), | |
618 | width: 150, | |
619 | height: 27, | |
620 | dropDownWidth: 500, | |
621 | dropDownHeight: 500, | |
622 | renderer: function(index, label, value) { | |
623 | var datarecord = fermentablelist.records[index]; | |
624 | return datarecord.supplier + ' / ' + datarecord.name + ' (' + datarecord.color + ' EBC)'; | |
625 | } | |
626 | }); | |
627 | $('#faddrowbutton').on('select', function(event) { | |
628 | if (event.args) { | |
629 | var index, datarecord, row = {}, rowscount = $('#fermentableGrid').jqxGrid('getdatainformation').rowscount; | |
630 | index = event.args.index; | |
631 | datarecord = fermentablelist.records[index]; | |
632 | row['f_name'] = datarecord.name; | |
633 | row['f_origin'] = datarecord.origin; | |
634 | row['f_supplier'] = datarecord.supplier; | |
635 | row['f_amount'] = 0; | |
636 | row['f_cost'] = datarecord.cost; | |
637 | row['f_type'] = datarecord.type; | |
638 | row['f_yield'] = datarecord.yield; | |
639 | row['f_color'] = datarecord.color; | |
640 | row['f_coarse_fine_diff'] = datarecord.coarse_fine_diff; | |
641 | row['f_moisture'] = datarecord.moisture; | |
642 | row['f_diastatic_power'] = datarecord.diastatic_power; | |
643 | row['f_protein'] = datarecord.protein; | |
644 | row['f_max_in_batch'] = datarecord.max_in_batch; | |
645 | row['f_graintype'] = datarecord.graintype; | |
646 | if (datarecord.add_after_boil) { | |
647 | row['f_added'] = 2; // Fermentation | |
648 | } else if ((datarecord.type == 1) || (datarecord.type == 4)) { // Sugar or Adjunct | |
649 | row['f_added'] = 1; // Boil | |
650 | } else { | |
651 | row['f_added'] = 0; // Mash | |
652 | } | |
653 | row['f_dissolved_protein'] = datarecord.dissolved_protein; | |
654 | row['f_recommend_mash'] = datarecord.recommend_mash; | |
655 | row['f_add_after_boil'] = datarecord.add_after_boil; | |
656 | if (rowscount == 0) { | |
657 | // The first fermentable | |
658 | row['f_adjust_to_total_100'] = 1; | |
659 | row['f_percentage'] = 100; | |
660 | } else { | |
661 | row['f_adjust_to_total_100'] = 0; | |
662 | row['f_percentage'] = 0; | |
663 | } | |
664 | row['f_di_ph'] = datarecord.di_ph; | |
665 | row['f_acid_to_ph_57'] = datarecord.acid_to_ph_57; | |
666 | row['f_inventory'] = datarecord.inventory; | |
667 | $('#fermentableGrid').jqxGrid('addrow', null, row); | |
668 | } | |
669 | }); | |
670 | ||
671 | $('#finstockbutton').jqxCheckBox({ theme: theme, height: 27, disabled: (dataRecord.stage > 3) }); | |
672 | $('#finstockbutton').on('change', function(event) { | |
673 | fermentableinstock = event.args.checked; | |
674 | fermentablelist.dataBind(); | |
675 | }); | |
676 | ||
677 | // delete selected fermentable. | |
678 | $('#fdeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 3) }); | |
679 | $('#fdeleterowbutton').on('click', function() { | |
680 | var rowscount, id, percent, amount, i, rowdata, | |
681 | selectedrowindex = $('#fermentableGrid').jqxGrid('getselectedrowindex'); | |
682 | rowscount = $('#fermentableGrid').jqxGrid('getdatainformation').rowscount; | |
683 | if (selectedrowindex >= 0 && selectedrowindex < rowscount) { | |
684 | id = $('#fermentableGrid').jqxGrid('getrowid', selectedrowindex); | |
685 | percent = $('#fermentableGrid').jqxGrid('getcellvalue', id, 'f_percentage'); | |
686 | amount = $('#fermentableGrid').jqxGrid('getcellvalue', id, 'f_amount'); | |
687 | $('#fermentableGrid').jqxGrid('deleterow', id); | |
688 | } | |
689 | rowscount = $('#fermentableGrid').jqxGrid('getdatainformation').rowscount; | |
690 | if (rowscount > 1) { | |
691 | if (to_100) { | |
692 | for (i = 0; i < rowscount; i++) { | |
693 | rowdata = $('#fermentableGrid').jqxGrid('getrowdata', i); | |
694 | if (rowdata.f_adjust_to_total_100) { | |
695 | rowdata.f_percentage += percent; | |
696 | rowdata.f_amount += amount; | |
697 | } | |
698 | } | |
699 | } else { | |
700 | calcPercentages(); | |
701 | } | |
702 | } else { | |
703 | $('#fermentableGrid').jqxGrid('setcellvalue', 0, 'f_percentage', 100); | |
704 | } | |
705 | calcFermentables(); | |
706 | calcIBUs(); | |
707 | }); | |
708 | }, | |
709 | ready: function() { | |
710 | calcFermentables(); | |
711 | $('#jqxTabs').jqxTabs('next'); | |
712 | }, | |
713 | columns: [ | |
714 | { text: 'Vergistbaar ingrediënt', datafield: 'f_name', | |
715 | cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { | |
716 | return '<span style="margin: 3px; margin-top: 6px; float: left;">' + rowdata.f_supplier + ' / ' + | |
717 | rowdata.f_name + ' (' + rowdata.f_color + ' EBC)</span>'; | |
718 | } | |
719 | }, | |
720 | { text: 'Type', width: 100, datafield: 'f_type', | |
721 | cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { | |
722 | return '<span style="margin: 3px; margin-top: 6px; float: left;">' + FermentableTypeData[value].nl + '</span>'; | |
723 | } | |
724 | }, | |
725 | { text: 'Moment', width: 110, datafield: 'f_added', | |
726 | cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { | |
727 | return '<span style="margin: 3px; margin-top: 6px; float: left;">' + AddedData[value].nl + '</span>'; | |
728 | } | |
729 | }, | |
730 | { text: 'Maxinbatch', datafield: 'f_max_in_batch', hidden: true }, | |
731 | { text: 'Opbrengst', datafield: 'f_yield', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, | |
732 | { text: 'Gewicht Kg', datafield: 'f_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, | |
733 | { text: 'Voorraad Kg', datafield: 'f_inventory', width: 120, align: 'right', | |
734 | cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties, rowdata) { | |
735 | var color = '#ffffff'; | |
736 | if (((dataRecord.inventory_reduced <= 2) && (rowdata.f_added <= 1)) || // Mash or boil | |
737 | ((dataRecord.inventory_reduced <= 3) && (rowdata.f_added == 2)) || // Primary | |
738 | ((dataRecord.inventory_reduced <= 5) && (rowdata.f_added == 3)) || // Secondary or Tertiary | |
739 | ((dataRecord.inventory_reduced <= 6) && (rowdata.f_added == 4)) || // Bottle | |
740 | ((dataRecord.inventory_reduced <= 6) && (rowdata.f_added == 5))) { // Kegs | |
741 | if (value < rowdata.f_amount) | |
742 | color = '#ff4040'; | |
743 | return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + fermentableAdapter.formatNumber(value, 'f3') + '</span>'; | |
744 | } else { | |
745 | return '<span></span>'; | |
746 | } | |
747 | } | |
748 | }, | |
749 | { text: 'Procent', datafield: 'f_percentage', width: 90, align: 'right', | |
750 | cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties, rowdata) { | |
751 | if (rowdata.f_added >= 4) | |
752 | return '<span></span>'; | |
753 | var color = '#ffffff'; | |
754 | if (value > rowdata.f_max_in_batch) | |
755 | color = '#ff4040'; | |
756 | return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + fermentableAdapter.formatNumber(value, 'p1') + '</span>'; | |
757 | } | |
758 | }, | |
759 | { text: '100%', datafield: 'f_adjust_to_total_100', width: 70, align: 'center', cellsalign: 'center', | |
760 | cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { | |
761 | if (value == 0) | |
762 | return '<span></span>'; | |
763 | return '<span><img style="float:left; margin-left:25px; margin-top:4px;" src="images/dialog-ok-apply.png"></span>'; | |
764 | } | |
765 | }, | |
766 | { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', | |
767 | cellsrenderer: function() { | |
768 | return 'Wijzig'; | |
769 | }, buttonclick: function(row) { | |
770 | fermentableRow = row; | |
771 | fermentableData = $('#fermentableGrid').jqxGrid('getrowdata', fermentableRow); | |
772 | if (fermentableData.f_added >= 4) { | |
773 | alert('Wijzig dit in de Verpakken tab'); | |
774 | } else if (dataRecord.stage > 3) { | |
775 | alert('Ingredieënt is al verwerkt.'); | |
776 | } else { | |
777 | $('#wf_name').val(fermentableData.f_name); | |
778 | $('#wf_amount').val(fermentableData.f_amount); | |
779 | $('#wf_percentage').val(fermentableData.f_percentage); | |
780 | $('#wf_max_in_batch').val(fermentableData.f_max_in_batch); | |
781 | $('#wf_adjust_to_total_100').val(fermentableData.f_adjust_to_total_100); | |
782 | $('#wf_added').val(fermentableData.f_added); | |
783 | // show the popup window. | |
784 | $('#popupFermentable').jqxWindow('open'); | |
785 | } | |
786 | } | |
787 | } | |
788 | ] | |
789 | }); | |
790 | }, | |
791 | ||
792 | // Inline hops editor | |
793 | editHop = function(data) { | |
794 | var hopSource = { | |
795 | localdata: data.hops, | |
796 | datatype: 'local', | |
797 | cache: false, | |
798 | async: false, | |
799 | datafields: [ | |
800 | { name: 'h_name', type: 'string' }, | |
801 | { name: 'h_origin', type: 'string' }, | |
802 | { name: 'h_amount', type: 'float' }, | |
803 | { name: 'h_cost', type: 'float' }, | |
804 | { name: 'h_type', type: 'int' }, | |
805 | { name: 'h_form', type: 'int' }, | |
806 | { name: 'h_useat', type: 'int' }, | |
807 | { name: 'h_time', type: 'float' }, | |
808 | { name: 'h_alpha', type: 'float' }, | |
809 | { name: 'h_beta', type: 'float' }, | |
810 | { name: 'h_hsi', type: 'float' }, | |
811 | { name: 'h_humulene', type: 'float' }, | |
812 | { name: 'h_caryophyllene', type: 'float' }, | |
813 | { name: 'h_cohumulone', type: 'float' }, | |
814 | { name: 'h_myrcene', type: 'float' }, | |
815 | { name: 'h_total_oil', type: 'float' }, | |
816 | { name: 'h_inventory', type: 'float' }, | |
817 | { name: 'h_avail', type: 'int' } | |
818 | ], | |
819 | addrow: function(rowid, rowdata, position, commit) { | |
820 | console.log('hop addrow ' + rowid); | |
821 | commit(true); | |
822 | }, | |
823 | deleterow: function(rowid, commit) { | |
824 | console.log('hop deleterow ' + rowid); | |
825 | commit(true); | |
826 | }, | |
827 | updaterow: function(rowid, rowdata, commit) { | |
828 | console.log('hop updaterow ' + rowid); | |
829 | commit(true); | |
830 | } | |
831 | }, | |
832 | hopAdapter = new $.jqx.dataAdapter(hopSource); | |
833 | ||
834 | $('#hopGrid').jqxGrid({ | |
835 | width: 1240, | |
836 | height: 560, | |
837 | source: hopAdapter, | |
838 | theme: theme, | |
839 | selectionmode: 'singlerow', | |
840 | showtoolbar: true, | |
841 | rendertoolbar: function(toolbar) { | |
842 | var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); | |
843 | toolbar.append(container); | |
844 | container.append('<div style="float: left; margin-left: 165px;" id="haddrowbutton"></div>'); | |
845 | container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>'); | |
846 | container.append('<div style="float: left; margin-left: 10px;" id="hinstockbutton"></div>'); | |
847 | container.append('<input style="float: left; margin-left: 400px;" id="hdeleterowbutton" type="button" value="Verwijder hop" />'); | |
848 | // add hop from dropdownlist. | |
849 | $('#haddrowbutton').jqxDropDownList({ | |
850 | placeHolder: 'Kies hop:', | |
851 | theme: theme, | |
852 | template: 'primary', | |
853 | source: hoplist, | |
854 | disabled: (dataRecord.stage > 3), | |
855 | displayMember: 'name', | |
856 | width: 150, | |
857 | height: 27, | |
858 | dropDownWidth: 500, | |
859 | dropDownHeight: 500, | |
860 | renderer: function(index, label, value) { | |
861 | var datarecord = hoplist.records[index]; | |
862 | return datarecord.origin + ' - ' + datarecord.name + ' / ' + HopFormData[datarecord.form].nl + ' (' + datarecord.alpha + '% α)'; | |
863 | } | |
864 | }); | |
865 | $('#haddrowbutton').on('select', function(event) { | |
866 | if (event.args) { | |
867 | var datarecord, row = {}, index = event.args.index; | |
868 | datarecord = hoplist.records[index]; | |
869 | row['h_name'] = datarecord.name; | |
870 | row['h_origin'] = datarecord.origin; | |
871 | row['h_amount'] = 0; | |
872 | row['h_cost'] = datarecord.cost; | |
873 | row['h_type'] = datarecord.type; | |
874 | row['h_form'] = datarecord.form; | |
875 | row['h_useat'] = 2; // Boil | |
876 | row['h_time'] = 0; | |
877 | row['h_alpha'] = datarecord.alpha; | |
878 | row['h_beta'] = datarecord.beta; | |
879 | row['h_hsi'] = datarecord.hsi; | |
880 | row['h_humulene'] = datarecord.humulene; | |
881 | row['h_caryophyllene'] = datarecord.caryophyllene; | |
882 | row['h_cohumulone'] = datarecord.cohumulone; | |
883 | row['h_myrcene'] = datarecord.myrcene; | |
884 | row['h_total_oil'] = datarecord.total_oil; | |
885 | row['h_inventory'] = datarecord.inventory; | |
886 | $('#hopGrid').jqxGrid('addrow', null, row); | |
887 | } | |
888 | $('#haddrowbutton').jqxDropDownList('clearSelection'); | |
889 | }); | |
890 | ||
891 | $('#hinstockbutton').jqxCheckBox({ theme: theme, height: 27, disabled: (dataRecord.stage > 3) }); | |
892 | $('#hinstockbutton').on('change', function(event) { | |
893 | hopinstock = event.args.checked; | |
894 | hoplist.dataBind(); | |
895 | }); | |
896 | ||
897 | // delete selected hop. | |
898 | $('#hdeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 3) }); | |
899 | $('#hdeleterowbutton').on('click', function() { | |
900 | var rowscount, id, selectedrowindex = $('#hopGrid').jqxGrid('getselectedrowindex'); | |
901 | rowscount = $('#hopGrid').jqxGrid('getdatainformation').rowscount; | |
902 | if (selectedrowindex >= 0 && selectedrowindex < rowscount) { | |
903 | id = $('#hopGrid').jqxGrid('getrowid', selectedrowindex); | |
904 | $('#hopGrid').jqxGrid('deleterow', id); | |
905 | } | |
906 | calcIBUs(); | |
907 | }); | |
908 | }, | |
909 | ready: function() { | |
910 | calcIBUs(); | |
911 | $('#jqxTabs').jqxTabs('next'); | |
912 | }, | |
913 | columns: [ | |
914 | { text: 'Hop', datafield: 'h_name', | |
915 | cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { | |
916 | return '<span style="margin: 3px; margin-top: 6px; float: left;">' + rowdata.h_origin + ' / ' + rowdata.h_name + '</span>'; | |
917 | }, | |
918 | }, | |
919 | { text: 'Type', width: 90, datafield: 'h_type', | |
920 | cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { | |
921 | return '<span style="margin: 4px; margin-top: 6px; float: left;">' + HopTypeData[value].nl + '</span>'; | |
922 | } | |
923 | }, | |
924 | { text: 'Vorm', width: 90, datafield: 'h_form', | |
925 | cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { | |
926 | return '<span style="margin: 4px; margin-top: 6px; float: left;">' + HopFormData[value].nl + '</span>'; | |
927 | } | |
928 | }, | |
929 | { text: 'Alpha', datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, | |
930 | { text: 'Gebruik', width: 110, datafield: 'h_useat', | |
931 | cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { | |
932 | return '<span style="margin: 4px; margin-top: 6px; float: left;">' + HopUseData[value].nl + '</span>'; | |
933 | } | |
934 | }, | |
935 | { text: 'Tijdsduur', datafield: 'h_time', width: 90, align: 'right', | |
936 | cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { | |
937 | var duration = ''; | |
938 | if ((rowdata.h_useat == 2) || (rowdata.h_useat == 4)) // Boil, Whirlpool | |
939 | duration = dataAdapter.formatNumber(value, 'f0') + ' min.'; | |
940 | else if (rowdata.h_useat == 5) // Dry hop | |
941 | duration = dataAdapter.formatNumber(value / 1440, 'f0') + ' dagen'; | |
942 | return '<span style="margin: 4px; margin-top: 6px; float: right;">' + duration + '</span>'; | |
943 | } | |
944 | }, | |
945 | { text: 'IBU', datafield: 'ibu', width: 80, align: 'right', | |
946 | cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { | |
947 | var ibu = toIBU(rowdata.h_useat, rowdata.h_form, preboil_sg, parseFloat($('#batch_size').jqxNumberInput('decimal')), | |
948 | parseFloat(rowdata.h_amount), parseFloat(rowdata.h_time), parseFloat(rowdata.h_alpha), $('#ibu_method').val()); | |
949 | return '<span style="margin: 4px; margin-top: 6px; float: right;">' + dataAdapter.formatNumber(ibu, 'f1') + '</span>'; | |
950 | } | |
951 | }, | |
952 | { text: 'Gewicht', datafield: 'h_amount', width: 110, align: 'right', | |
953 | cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { | |
954 | var amount = dataAdapter.formatNumber(value, 'f1') + ' kg'; | |
955 | if (value < 1) | |
956 | amount = dataAdapter.formatNumber(value * 1000, 'f1') + ' gr'; | |
957 | return '<span style="margin: 4px; margin-top: 6px; float: right;">' + amount + '</span>'; | |
958 | } | |
959 | }, | |
960 | { text: 'Voorraad', datafield: 'h_inventory', width: 110, align: 'right', | |
961 | cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { | |
962 | if (((dataRecord.inventory_reduced <= 2) && (rowdata.h_useat <= 4)) || // Mash, FW, Boil, Aroma, Whirlpool | |
963 | ((dataRecord.inventory_reduced <= 6) && (rowdata.h_useat == 5))) { // Dry hop | |
964 | var amount, color = '#ffffff'; | |
965 | if (value < rowdata.h_amount) | |
966 | color = '#ff4040'; | |
967 | amount = dataAdapter.formatNumber(value, 'f1') + ' kg'; | |
968 | if (value < 1) | |
969 | amount = dataAdapter.formatNumber(value * 1000, 'f1') + ' gr'; | |
970 | return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + amount + '</span>'; | |
971 | } else { | |
972 | return '<span></span>'; | |
973 | } | |
974 | } | |
975 | }, | |
976 | { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', | |
977 | cellsrenderer: function() { | |
978 | return 'Wijzig'; | |
979 | }, buttonclick: function(row) { | |
980 | if (dataRecord.stage > 3) { | |
981 | alert('Ingredieënt is al verwerkt.'); | |
982 | } else { | |
983 | console.log('edit button row ' + row); | |
984 | hopRow = row; | |
985 | hopData = $('#hopGrid').jqxGrid('getrowdata', hopRow); | |
986 | $('#wh_name').val(hopData.h_name); | |
987 | $('#wh_amount').val(hopData.h_amount * 1000); | |
988 | var ibu = toIBU(hopData.h_useat, hopData.h_form, preboil_sg, parseFloat($('#batch_size').jqxNumberInput('decimal')), | |
989 | parseFloat(hopData.h_amount), parseFloat(hopData.h_time), parseFloat(hopData.h_alpha), $('#ibu_method').val()); | |
990 | $('#wh_ibu').val(ibu); | |
991 | if (hopData.h_useat == 5) // Dry hop | |
992 | $('#wh_time').val(hopData.h_time / 1440); | |
993 | else | |
994 | $('#wh_time').val(hopData.h_time); | |
995 | $('#wh_useat').val(hopData.h_useat); | |
996 | // show the popup window. | |
997 | $('#popupHop').jqxWindow('open'); | |
998 | } | |
999 | } | |
1000 | } | |
1001 | ] | |
1002 | }); | |
1003 | }, | |
1004 | ||
1005 | // Inline miscs editor | |
1006 | editMisc = function(data) { | |
1007 | var miscSource = { | |
1008 | localdata: data.miscs, | |
1009 | datatype: 'local', | |
1010 | cache: false, | |
1011 | async: false, | |
1012 | datafields: [ | |
1013 | { name: 'm_name', type: 'string' }, | |
1014 | { name: 'm_amount', type: 'float' }, | |
1015 | { name: 'm_cost', type: 'float' }, | |
1016 | { name: 'm_type', type: 'int' }, | |
1017 | { name: 'm_use_use', type: 'int' }, | |
1018 | { name: 'm_time', type: 'float' }, | |
1019 | { name: 'm_amount_is_weight', type: 'int' }, | |
1020 | { name: 'm_inventory', type: 'float' }, | |
1021 | { name: 'm_avail', type: 'int' } | |
1022 | ], | |
1023 | addrow: function(rowid, rowdata, position, commit) { | |
1024 | console.log('misc addrow ' + rowid); | |
1025 | commit(true); | |
1026 | }, | |
1027 | deleterow: function(rowid, commit) { | |
1028 | console.log('misc deleterow ' + rowid); | |
1029 | commit(true); | |
1030 | }, | |
1031 | updaterow: function(rowid, rowdata, commit) { | |
1032 | console.log('misc updaterow ' + rowid); | |
1033 | commit(true); | |
1034 | } | |
1035 | }, | |
1036 | miscAdapter = new $.jqx.dataAdapter(miscSource, { | |
1037 | beforeLoadComplete: function(records) { | |
1038 | var row, i, data = new Array(); | |
1039 | for (i = 0; i < records.length; i++) { | |
1040 | row = records[i]; | |
1041 | data.push(row); | |
1042 | // Initial set water agent values. | |
1043 | switch (row.m_name) { | |
1044 | case 'CaCl2': | |
1045 | $('#wa_cacl2').val(row.m_amount * 1000); | |
1046 | break; | |
1047 | case 'CaSO4': | |
1048 | $('#wa_caso4').val(row.m_amount * 1000); | |
1049 | break; | |
1050 | case 'MgSO4': | |
1051 | $('#wa_mgso4').val(row.m_amount * 1000); | |
1052 | break; | |
1053 | case 'NaCl': | |
1054 | $('#wa_nacl').val(row.m_amount * 1000); | |
1055 | break; | |
1056 | case 'Melkzuur': | |
1057 | $('#wa_acid_name').val(0); | |
1058 | $('#wa_acid').val(row.m_amount * 1000); | |
1059 | $('#wa_acid_perc').val(80); | |
1060 | last_acid = 'Melkzuur'; | |
1061 | break; | |
1062 | case 'Zoutzuur': | |
1063 | $('#wa_acid_name').val(1); | |
1064 | $('#wa_acid').val(row.m_amount * 1000); | |
1065 | $('#wa_acid_perc').val(80); | |
1066 | last_acid = 'Zoutzuur'; | |
1067 | break; | |
1068 | case 'Fosforzuur': | |
1069 | $('#wa_acid_name').val(2); | |
1070 | $('#wa_acid').val(row.m_amount * 1000); | |
1071 | $('#wa_acid_perc').val(80); | |
1072 | last_acid = 'Fosforzuur'; | |
1073 | break; | |
1074 | case 'Zwavelzuur': | |
1075 | $('#wa_acid_name').val(3); | |
1076 | $('#wa_acid').val(row.m_amount * 1000); | |
1077 | $('#wa_acid_perc').val(80); | |
1078 | last_acid = 'Zwavelzuur'; | |
1079 | break; | |
1080 | case 'NaHCO3': | |
1081 | $('#wa_base_name').val(0); | |
1082 | $('#wa_base').val(row.m_amount * 1000); | |
1083 | last_base = 'NaHCO3'; | |
1084 | break; | |
1085 | case 'Na2CO3': | |
1086 | $('#wa_base_name').val(1); | |
1087 | $('#wa_base').val(row.m_amount * 1000); | |
1088 | last_base = 'Na2CO3'; | |
1089 | break; | |
1090 | case 'CaCO3': | |
1091 | $('#wa_base_name').val(2); | |
1092 | $('#wa_base').val(row.m_amount * 1000); | |
1093 | last_base = 'CaCO3'; | |
1094 | break; | |
1095 | case 'Ca(OH)2': | |
1096 | $('#wa_base_name').val(3); | |
1097 | $('#wa_base').val(row.m_amount * 1000); | |
1098 | last_base = 'Ca(OH)2'; | |
1099 | break; | |
1100 | } | |
1101 | } | |
1102 | return data; | |
1103 | }, | |
1104 | loadError: function(jqXHR, status, error) { | |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
149
diff
changeset
|
1105 | $('#err').text(status + ' ' + error); |
478 | 1106 | }, |
1107 | }); | |
1108 | $('#miscGrid').jqxGrid({ | |
1109 | width: 1240, | |
1110 | height: 575, | |
1111 | source: miscAdapter, | |
1112 | theme: theme, | |
1113 | selectionmode: 'singlerow', | |
1114 | showtoolbar: true, | |
1115 | rendertoolbar: function(toolbar) { | |
1116 | var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); | |
1117 | toolbar.append(container); | |
1118 | container.append('<div style="float: left; margin-left: 165px;" id="maddrowbutton"></div>'); | |
1119 | container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>'); | |
1120 | container.append('<div style="float: left; margin-left: 10px;" id="minstockbutton"></div>'); | |
1121 | container.append('<input style="float: left; margin-left: 400px;" id="mdeleterowbutton" type="button" value="Verwijder ingredient" />'); | |
1122 | // add misc from dropdownlist. | |
1123 | $('#maddrowbutton').jqxDropDownList({ | |
1124 | placeHolder: 'Kies ingrediënt:', | |
1125 | theme: theme, | |
1126 | template: 'primary', | |
1127 | source: misclist, | |
1128 | disabled: (dataRecord.stage > 3), | |
1129 | displayMember: 'name', | |
1130 | width: 150, | |
1131 | height: 27, | |
1132 | dropDownWidth: 500, | |
1133 | dropDownHeight: 500 | |
1134 | }); | |
1135 | $('#maddrowbutton').on('select', function(event) { | |
1136 | if (event.args) { | |
1137 | var datarecord, row = {}, index = event.args.index; | |
1138 | datarecord = misclist.records[index]; | |
1139 | row['m_name'] = datarecord.name; | |
1140 | row['m_amount'] = 0; | |
1141 | row['m_cost'] = datarecord.cost; | |
1142 | row['m_type'] = datarecord.type; | |
1143 | row['m_use_use'] = datarecord.use_use; | |
1144 | row['m_time'] = 0; | |
1145 | row['m_amount_is_weight'] = datarecord.amount_is_weight; | |
1146 | row['m_inventory'] = datarecord.inventory; | |
1147 | $('#miscGrid').jqxGrid('addrow', null, row); | |
1148 | } | |
1149 | }); | |
1150 | $('#minstockbutton').jqxCheckBox({ theme: theme, height: 27, disabled: (dataRecord.stage > 3) }); | |
1151 | $('#minstockbutton').on('change', function(event) { | |
1152 | miscinstock = event.args.checked; | |
1153 | misclist.dataBind(); | |
1154 | }); | |
1155 | // delete selected misc. | |
1156 | $('#mdeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 3) }); | |
1157 | $('#mdeleterowbutton').on('click', function() { | |
1158 | var rowscount, type, id, selectedrowindex = $('#miscGrid').jqxGrid('getselectedrowindex'); | |
1159 | rowscount = $('#miscGrid').jqxGrid('getdatainformation').rowscount; | |
1160 | type = $('#miscGrid').jqxGrid('getcellvalue', selectedrowindex, 'm_type'); | |
1161 | if (selectedrowindex >= 0 && selectedrowindex < rowscount && type != 4) { // Water agent | |
1162 | id = $('#miscGrid').jqxGrid('getrowid', selectedrowindex); | |
1163 | $('#miscGrid').jqxGrid('deleterow', id); | |
1164 | } | |
1165 | }); | |
1166 | }, | |
1167 | ready: function() { | |
1168 | calcMiscs(); | |
1169 | $('#jqxTabs').jqxTabs('next'); | |
1170 | }, | |
1171 | columns: [ | |
1172 | { text: 'Ingredient', datafield: 'm_name' }, | |
1173 | { text: 'Type', width: 140, datafield: 'm_type', | |
1174 | cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { | |
1175 | return '<span style="margin: 3px; margin-top: 6px; float: left;">' + MiscTypeData[value].nl + '</span>'; | |
1176 | } | |
1177 | }, | |
1178 | { text: 'Gebruik', width: 140, datafield: 'm_use_use', | |
1179 | cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { | |
1180 | return '<span style="margin: 3px; margin-top: 6px; float: left;">' + MiscUseData[value].nl + '</span>'; | |
1181 | } | |
1182 | }, | |
1183 | { text: 'Tijd', datafield: 'm_time', width: 90, align: 'right', | |
1184 | cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { | |
1185 | var duration = ''; | |
1186 | if (rowdata.m_use_use == 2) // Boil | |
1187 | duration = dataAdapter.formatNumber(value, 'f0') + ' min.'; | |
1188 | else if ((rowdata.m_use_use == 3) || (rowdata.m_use_use == 4)) // Primary or Secondary | |
1189 | duration = dataAdapter.formatNumber(value / 1440, 'f0') + ' dagen'; | |
1190 | return '<span style="margin: 4px; margin-top: 6px; float: right;">' + duration + '</span>'; | |
1191 | } | |
1192 | }, | |
1193 | { text: 'Hoeveel', datafield: 'm_amount', width: 110, align: 'right', | |
1194 | cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { | |
1195 | var vstr = rowdata.m_amount_is_weight ? 'gr' : 'ml'; | |
1196 | return '<span style="margin: 4px; margin-top: 6px; float: right;">' + dataAdapter.formatNumber(value * 1000, 'f2') + ' ' + vstr + '</span>'; | |
1197 | } | |
1198 | }, | |
1199 | { text: 'Voorraad', datafield: 'm_inventory', width: 110, align: 'right', | |
1200 | cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { | |
1201 | var vstr, color, amount; | |
1202 | if (((dataRecord.inventory_reduced <= 2) && (rowdata.m_use_use <= 2)) || // Starter, Mash, Boil | |
1203 | ((dataRecord.inventory_reduced <= 3) && (rowdata.m_use_use == 3)) || // Primary | |
1204 | ((dataRecord.inventory_reduced <= 5) && (rowdata.m_use_use == 4)) || // Secondary, Teriary | |
1205 | ((dataRecord.inventory_reduced <= 6) && (rowdata.m_use_use == 5))) { // Bottle | |
1206 | vstr = rowdata.m_amount_is_weight ? 'gr' : 'ml'; | |
1207 | color = '#ffffff'; | |
1208 | if (value < rowdata.m_amount) | |
1209 | color = '#ff4040'; | |
1210 | amount = dataAdapter.formatNumber(value * 1000, 'f2') + ' ' + vstr; | |
1211 | return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + amount + '</span>'; | |
1212 | } else { | |
1213 | return '<span></span>'; | |
1214 | } | |
1215 | } | |
1216 | }, | |
1217 | { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', | |
1218 | cellsrenderer: function() { | |
1219 | return 'Wijzig'; | |
1220 | }, buttonclick: function(row) { | |
1221 | miscRow = row; | |
1222 | miscData = $('#miscGrid').jqxGrid('getrowdata', miscRow); | |
1223 | if (dataRecord.stage > 3) { | |
1224 | alert('Ingredieënt is al verwerkt.'); | |
1225 | } else if (miscData.m_type == 4) { | |
1226 | alert('Brouwzouten wijzigen in de water tab.'); | |
1227 | } else { | |
1228 | console.log('edit button row ' + row); | |
1229 | if (miscData.m_amount_is_weight) | |
1230 | $('#wm_pmpt_amount').html('Gewicht gram:'); | |
1231 | else | |
1232 | $('#wm_pmpt_amount').html('Volume ml:'); | |
1233 | $('#wm_name').val(miscData.m_name); | |
1234 | $('#wm_amount').val(miscData.m_amount * 1000); | |
1235 | if ((miscData.m_use_use == 3) || (miscData.m_use_use == 4)) // Primary or Secondary | |
1236 | $('#wm_time').val(miscData.m_time / 1440); | |
1237 | else | |
1238 | $('#wm_time').val(miscData.m_time); | |
1239 | $('#wm_use_use').val(miscData.m_use_use); | |
1240 | // show the popup window. | |
1241 | $('#popupMisc').jqxWindow('open'); | |
1242 | } | |
1243 | } | |
1244 | } | |
1245 | ] | |
1246 | }); | |
1247 | }, | |
1248 | ||
1249 | // Inline yeasts editor | |
1250 | editYeast = function(data) { | |
1251 | var yeastSource = { | |
1252 | localdata: data.yeasts, | |
1253 | datatype: 'local', | |
1254 | cache: false, | |
1255 | async: false, | |
1256 | datafields: [ | |
1257 | { name: 'y_name', type: 'string' }, | |
1258 | { name: 'y_laboratory', type: 'string' }, | |
1259 | { name: 'y_product_id', type: 'string' }, | |
1260 | { name: 'y_amount', type: 'float' }, | |
1261 | { name: 'y_cost', type: 'float' }, | |
1262 | { name: 'y_type', type: 'int' }, | |
1263 | { name: 'y_form', type: 'int' }, | |
1264 | { name: 'y_flocculation', type: 'int' }, | |
1265 | { name: 'y_min_temperature', type: 'float' }, | |
1266 | { name: 'y_max_temperature', type: 'float' }, | |
1267 | { name: 'y_attenuation', type: 'float' }, | |
1268 | { name: 'y_use', type: 'int' }, | |
1269 | { name: 'y_cells', type: 'float' }, | |
1270 | { name: 'y_tolerance', type: 'float' }, | |
1271 | { name: 'y_inventory', type: 'float' }, | |
1272 | { name: 'y_avail', type: 'int' } | |
1273 | ], | |
1274 | addrow: function(rowid, rowdata, position, commit) { | |
1275 | console.log('yeast addrow ' + rowid); | |
1276 | commit(true); | |
1277 | }, | |
1278 | deleterow: function(rowid, commit) { | |
1279 | console.log('yeast deleterow ' + rowid); | |
1280 | commit(true); | |
1281 | }, | |
1282 | updaterow: function(rowid, rowdata, commit) { | |
1283 | console.log('yeast updaterow ' + rowid); | |
1284 | commit(true); | |
1285 | } | |
1286 | }, | |
1287 | yeastAdapter = new $.jqx.dataAdapter(yeastSource); | |
1288 | ||
1289 | $('#yeastGrid').jqxGrid({ | |
1290 | width: 1240, | |
1291 | height: 350, | |
1292 | source: yeastAdapter, | |
1293 | theme: theme, | |
1294 | selectionmode: 'singlerow', | |
1295 | showtoolbar: true, | |
1296 | rendertoolbar: function(toolbar) { | |
1297 | var container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>'); | |
1298 | toolbar.append(container); | |
1299 | container.append('<div style="float: left; margin-left: 165px;" id="yaddrowbutton"></div>'); | |
1300 | container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>'); | |
1301 | container.append('<div style="float: left; margin-left: 10px;" id="yinstockbutton"></div>'); | |
1302 | container.append('<input style="float: left; margin-left: 400px;" id="ydeleterowbutton" type="button" value="Verwijder gist" />'); | |
1303 | // add yeast from dropdownlist. | |
1304 | $('#yaddrowbutton').jqxDropDownList({ | |
1305 | placeHolder: 'Kies gist:', | |
1306 | theme: theme, | |
1307 | source: yeastlist, | |
1308 | disabled: (dataRecord.stage > 3), | |
1309 | template: 'primary', | |
1310 | displayMember: 'name', | |
1311 | width: 150, | |
1312 | height: 27, | |
1313 | dropDownWidth: 500, | |
1314 | dropDownHeight: 500, | |
1315 | renderer: function(index, label, value) { | |
1316 | var datarecord = yeastlist.records[index]; | |
1317 | return datarecord.laboratory + ' ' + datarecord.product_id + ' ' + datarecord.name; | |
1318 | } | |
1319 | }); | |
1320 | $('#yaddrowbutton').on('select', function(event) { | |
1321 | if (event.args) { | |
1322 | var datarecord, row = {}, index = event.args.index; | |
1323 | datarecord = yeastlist.records[index]; | |
1324 | row['y_name'] = datarecord.name; | |
1325 | row['y_laboratory'] = datarecord.laboratory; | |
1326 | row['y_product_id'] = datarecord.product_id; | |
1327 | row['y_type'] = datarecord.type; | |
1328 | row['y_form'] = datarecord.form; | |
1329 | row['y_amount'] = 0; | |
1330 | row['y_cost'] = datarecord.cost; | |
1331 | row['y_use'] = 0; | |
1332 | row['y_min_temperature'] = datarecord.min_temperature; | |
1333 | row['y_max_temperature'] = datarecord.max_temperature; | |
1334 | row['y_attenuation'] = datarecord.attenuation; | |
1335 | row['y_flocculation'] = datarecord.flocculation; | |
1336 | row['y_cells'] = datarecord.cells; | |
1337 | row['y_tolerance'] = datarecord.tolerance; | |
1338 | row['y_inventory'] = datarecord.inventory; | |
1339 | $('#yeastGrid').jqxGrid('addrow', null, row); | |
1340 | } | |
1341 | calcYeast(); | |
1342 | $('#yaddrowbutton').jqxDropDownList('clearSelection'); | |
1343 | }); | |
1344 | $('#yinstockbutton').jqxCheckBox({ theme: theme, height: 27, disabled: (dataRecord.stage > 3) }); | |
1345 | $('#yinstockbutton').on('change', function(event) { | |
1346 | yeastinstock = event.args.checked; | |
1347 | yeastlist.dataBind(); | |
1348 | }); | |
1349 | // delete selected yeast. | |
1350 | $('#ydeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 3) }); | |
1351 | $('#ydeleterowbutton').on('click', function() { | |
1352 | var id, rowscount, selectedrowindex = $('#yeastGrid').jqxGrid('getselectedrowindex'); | |
1353 | rowscount = $('#yeastGrid').jqxGrid('getdatainformation').rowscount; | |
1354 | if (selectedrowindex >= 0 && selectedrowindex < rowscount) { | |
1355 | id = $('#yeastGrid').jqxGrid('getrowid', selectedrowindex); | |
1356 | $('#yeastGrid').jqxGrid('deleterow', id); | |
1357 | calcYeast(); | |
1358 | } | |
1359 | }); | |
1360 | }, | |
1361 | ready: function() { | |
1362 | calcFermentables(); | |
1363 | showStarter(); | |
1364 | calcYeast(); | |
1365 | $('#jqxTabs').jqxTabs('next'); | |
1366 | }, | |
1367 | columns: [ | |
1368 | { text: 'Gist', datafield: 'y_name' }, | |
1369 | { text: 'Laboratorium', width: 150, datafield: 'y_laboratory' }, | |
1370 | { text: 'Code', width: 90, datafield: 'y_product_id' }, | |
1371 | { text: 'Soort', width: 100, datafield: 'y_form', | |
1372 | cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { | |
1373 | return '<span style="margin: 4px; margin-top: 6px; float: left;">' + YeastFormData[value].nl + '</span>'; | |
1374 | } | |
1375 | }, | |
1376 | { text: 'Min. °C', width: 70, align: 'right', cellsalign: 'right', datafield: 'y_min_temperature' }, | |
1377 | { text: 'Max. °C', width: 70, align: 'right', cellsalign: 'right', datafield: 'y_max_temperature' }, | |
1378 | { text: 'Tol. %', width: 60, align: 'right', cellsalign: 'right', datafield: 'y_tolerance', | |
1379 | cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { | |
1380 | var amount = '', color = '#ffffff'; | |
1381 | if (value > 0) { | |
1382 | amount = dataAdapter.formatNumber(value, 'f1'); | |
1383 | if (dataRecord.est_abv > value) | |
1384 | color = '#ff4040'; | |
1385 | } | |
1386 | return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + amount + '</span>'; | |
1387 | } | |
1388 | }, | |
1389 | { text: 'Attn. %', width: 70, align: 'right', cellsalign: 'right', datafield: 'y_attenuation', cellsformat: 'f1' }, | |
1390 | { text: 'Voor', width: 120, datafield: 'y_use', | |
1391 | cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { | |
1392 | return '<span style="margin: 4px; margin-top: 6px; float: left;">' + YeastUseData[value].nl + '</span>'; | |
1393 | } | |
1394 | }, | |
1395 | { text: 'Hoeveel', datafield: 'y_amount', width: 90, align: 'right', | |
1396 | cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { | |
1397 | var amount = dataAdapter.formatNumber(value * 1000, 'f0') + ' ml'; | |
1398 | if (rowdata.y_form == 0) // Liquid | |
1399 | amount = dataAdapter.formatNumber(value, 'f0') + ' pk'; | |
1400 | else if (rowdata.y_form == 1) // Dry | |
1401 | amount = dataAdapter.formatNumber(value * 1000, 'f1') + ' gr'; | |
1402 | return '<span style="margin: 4px; margin-top: 6px; float: right;">' + amount + '</span>'; | |
1403 | } | |
1404 | }, | |
1405 | { text: 'Voorraad', datafield: 'y_inventory', width: 90, align: 'right', | |
1406 | cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { | |
1407 | var color, amount; | |
1408 | if (((dataRecord.inventory_reduced <= 3) && (rowdata.y_use == 0)) || // Primary | |
1409 | ((dataRecord.inventory_reduced <= 4) && (rowdata.y_use == 1)) || // Secondary | |
1410 | ((dataRecord.inventory_reduced <= 5) && (rowdata.y_use == 2)) || // Tertiary | |
1411 | ((dataRecord.inventory_reduced <= 6) && (rowdata.y_use == 3))) { // Bottle | |
1412 | color = '#ffffff'; | |
1413 | if (value < rowdata.y_amount) | |
1414 | color = '#ff4040'; | |
1415 | amount = dataAdapter.formatNumber(value * 1000, 'f0') + ' ml'; | |
1416 | if (rowdata.y_form == 0) // Liquid | |
1417 | amount = dataAdapter.formatNumber(value, 'f0') + ' pk'; | |
1418 | else if (rowdata.y_form == 1) // Dry | |
1419 | amount = dataAdapter.formatNumber(value * 1000, 'f1') + ' gr'; | |
1420 | return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + amount + '</span>'; | |
1421 | } else { | |
1422 | return '<span></span>'; | |
1423 | } | |
1424 | } | |
1425 | }, | |
1426 | { text: '', datafield: 'Edit', columntype: 'button', width: 90, align: 'center', | |
1427 | cellsrenderer: function() { | |
1428 | return 'Wijzig'; | |
1429 | }, buttonclick: function(row) { | |
1430 | if (dataRecord.stage > 3) { | |
1431 | alert('Ingredieënt is al verwerkt.'); | |
1432 | } else { | |
1433 | yeastRow = row; | |
1434 | yeastData = $('#yeastGrid').jqxGrid('getrowdata', yeastRow); | |
1435 | if (yeastData.y_form == 0) { | |
1436 | $('#wy_pmpt_amount').html('Pak(ken):'); | |
1437 | $('#wy_amount').val(yeastData.y_amount); | |
1438 | $('#wy_amount').jqxNumberInput({ decimalDigits: 0 }); | |
1439 | } else if (yeastData.y_form == 1) { | |
1440 | $('#wy_pmpt_amount').html('Gewicht gram:'); | |
1441 | $('#wy_amount').val(yeastData.y_amount * 1000); | |
1442 | $('#wy_amount').jqxNumberInput({ decimalDigits: 1 }); | |
1443 | } else { | |
1444 | $('#wy_pmpt_amount').html('Volume ml:'); | |
1445 | $('#wy_amount').val(yeastData.y_amount * 1000); | |
1446 | $('#wy_amount').jqxNumberInput({ decimalDigits: 0 }); | |
1447 | } | |
1448 | $('#wy_name').val(yeastData.y_name); | |
1449 | $('#wy_laboratory').val(yeastData.y_laboratory); | |
1450 | $('#wy_product_id').val(yeastData.y_product_id); | |
1451 | $('#wy_use').val(yeastData.y_use); | |
1452 | // show the popup window. | |
1453 | $('#popupYeast').jqxWindow('open'); | |
1454 | } | |
1455 | } | |
1456 | } | |
1457 | ] | |
1458 | }); | |
1459 | }, | |
1460 | ||
1461 | // inline mash editor | |
1462 | editMash = function(data) { | |
1463 | var mashSource = { | |
1464 | localdata: data.mashs, | |
1465 | datatype: 'local', | |
1466 | cache: false, | |
1467 | async: false, | |
1468 | datafields: [ | |
1469 | { name: 'step_name', type: 'string' }, | |
1470 | { name: 'step_type', type: 'int' }, | |
1471 | { name: 'step_infuse_amount', type: 'float' }, | |
1472 | { name: 'step_temp', type: 'float' }, | |
1473 | { name: 'step_time', type: 'float' }, | |
1474 | { name: 'step_thickness', type: 'float' }, | |
1475 | { name: 'ramp_time', type: 'float' }, | |
1476 | { name: 'end_temp', type: 'float' } | |
1477 | ], | |
1478 | addrow: function(rowid, rowdata, position, commit) { | |
1479 | console.log('mash addrow ' + rowid); | |
1480 | commit(true); | |
1481 | }, | |
1482 | deleterow: function(rowid, commit) { | |
1483 | console.log('mash deleterow ' + rowid); | |
1484 | commit(true); | |
1485 | } | |
1486 | }, | |
1487 | mashAdapter = new $.jqx.dataAdapter(mashSource, { | |
1488 | beforeLoadComplete: function(records) { | |
1489 | mash_infuse = 0; | |
1490 | var i, row, data = new Array(); | |
1491 | for (i = 0; i < records.length; i++) { | |
1492 | row = records[i]; | |
1493 | if (row.step_type == 0) // Infusion | |
1494 | mash_infuse += parseFloat(row.step_infuse_amount); | |
1495 | row.step_thickness = 0; // Init this field. | |
1496 | data.push(row); | |
1497 | } | |
1498 | }, | |
1499 | }); | |
1500 | $('#mashGrid').jqxGrid({ | |
1501 | width: 1240, | |
1502 | height: 400, | |
1503 | source: mashAdapter, | |
1504 | theme: theme, | |
1505 | selectionmode: 'singlerow', | |
1506 | showtoolbar: true, | |
1507 | rendertoolbar: function(toolbar) { | |
1508 | var container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>'); | |
1509 | toolbar.append(container); | |
1510 | container.append('<input style="float: left; margin-left: 165px;" id="saddrowbutton" type="button" value="Nieuwe stap" />'); | |
1511 | container.append('<input style="float: left; margin-left: 565px;" id="sdeleterowbutton" type="button" value="Verwijder stap" />'); | |
1512 | $('#saddrowbutton').jqxButton({ template: 'primary', theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 3) }); | |
1513 | $('#saddrowbutton').on('click', function() { | |
1514 | var row = {}, rowscount = $('#mashGrid').jqxGrid('getdatainformation').rowscount; | |
1515 | row['step_name'] = 'Stap ' + (rowscount + 1); | |
1516 | if (rowscount > 0) { | |
1517 | row['step_type'] = 1; | |
1518 | } else { | |
1519 | row['step_type'] = 0; | |
1520 | row['step_infuse_amount'] = 15; | |
1521 | } | |
1522 | row['step_temp'] = 62.0; | |
1523 | row['step_time'] = 20.0; | |
1524 | row['step_thickness'] = 0; | |
1525 | row['ramp_time'] = 1.0; | |
1526 | row['end_temp'] = 62.0; | |
1527 | $('#mashGrid').jqxGrid('addrow', null, row); | |
1528 | }); | |
1529 | // delete selected step. | |
1530 | $('#sdeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 3) }); | |
1531 | $('#sdeleterowbutton').on('click', function() { | |
1532 | var rowscount, id, selectedrowindex = $('#mashGrid').jqxGrid('getselectedrowindex'); | |
1533 | rowscount = $('#mashGrid').jqxGrid('getdatainformation').rowscount; | |
1534 | if (selectedrowindex >= 0 && selectedrowindex < rowscount) { | |
1535 | id = $('#mashGrid').jqxGrid('getrowid', selectedrowindex); | |
1536 | $('#mashGrid').jqxGrid('deleterow', id); | |
1537 | } | |
1538 | }); | |
1539 | }, | |
1540 | ready: function() { | |
1541 | calcInit(); | |
1542 | calcMash(); | |
1543 | $('#jqxLoader').jqxLoader('close'); | |
1544 | $('#jqxTabs').jqxTabs('first'); | |
1545 | }, | |
1546 | columns: [ | |
1547 | { text: 'Stap naam', datafield: 'step_name' }, | |
1548 | { text: 'Stap type', datafield: 'step_type', width: 175, | |
1549 | cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { | |
1550 | return '<span style="margin: 4px; margin-top: 6px; float: left;">' + MashStepTypeData[value].nl + '</span>'; | |
1551 | } | |
1552 | }, | |
1553 | { text: 'Start °C', datafield: 'step_temp', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, | |
1554 | { text: 'Eind °C', datafield: 'end_temp', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, | |
1555 | { text: 'Rust min.', datafield: 'step_time', width: 90, align: 'right', cellsalign: 'right' }, | |
1556 | { text: 'Stap min.', datafield: 'ramp_time', width: 90, align: 'right', cellsalign: 'right' }, | |
1557 | { text: 'Infuse L.', datafield: 'step_infuse_amount', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, | |
1558 | { text: 'L/Kg.', datafield: 'step_thickness', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f2' }, | |
1559 | { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', | |
1560 | cellsrenderer: function() { | |
1561 | return 'Wijzig'; | |
1562 | }, buttonclick: function(row) { | |
1563 | if (dataRecord.stage > 3) { | |
1564 | alert('Het maichen is al gedaan.'); | |
1565 | } else { | |
1566 | mashRow = row; | |
1567 | mashData = $('#mashGrid').jqxGrid('getrowdata', mashRow); | |
1568 | $('#wstep_name').val(mashData.step_name); | |
1569 | $('#wstep_type').val(mashData.step_type); | |
1570 | $('#wstep_infuse_amount').val(mashData.step_infuse_amount); | |
1571 | $('#wstep_temp').val(mashData.step_temp); | |
1572 | $('#wend_temp').val(mashData.end_temp); | |
1573 | $('#wstep_time').val(mashData.step_time); | |
1574 | $('#wramp_time').val(mashData.ramp_time); | |
1575 | if (mashData.step_type == 0) { | |
1576 | $('#wstep_infuse_amount').show(); | |
1577 | $('#wstep_pmpt').show(); | |
1578 | } else { | |
1579 | $('#wstep_infuse_amount').hide(); | |
1580 | $('#wstep_pmpt').hide(); | |
1581 | } | |
1582 | // show the popup window. | |
1583 | $('#popupMash').jqxWindow('open'); | |
1584 | } | |
1585 | } | |
1586 | } | |
1587 | ] | |
1588 | }); | |
1589 | }; | |
1590 | ||
1591 | /* | |
1592 | * Remove the top menu so that we MUST use the buttons to leave the editor. | |
1593 | */ | |
1594 | $('#jqxMenu').jqxMenu('destroy'); | |
1595 | console.log('record:' + my_record + ' return:' + my_return + ' theme:' + theme); | |
1596 | $('#jqxLoader').jqxLoader({ | |
1597 | width: 250, | |
1598 | height: 150, | |
1599 | isModal: true, | |
1600 | text: 'Laden product ...', | |
1601 | theme: theme | |
1602 | }); | |
1603 | ||
1604 | /* | |
1605 | * Generic functions | |
1606 | */ | |
1607 | function calcSupplies() { | |
1608 | if (dataRecord.inventory_reduced > 6) { | |
1609 | $('#ok_pmpt').hide(); | |
1610 | return; | |
1611 | } | |
1612 | if (ok_fermentables && ok_hops && ok_miscs && ok_yeasts && ok_waters) | |
1613 | $('#ok_supplies').html("<img src='images/dialog-ok-apply.png'>"); | |
1614 | else | |
1615 | $('#ok_supplies').html("<img src='images/dialog-error.png'>"); | |
1616 | } | |
1617 | ||
1618 | function calcPercentages() { | |
1619 | ||
1620 | console.log('calcPercentages()'); | |
1621 | var tw = 0, rowdata, percentage, rowscount = $('#fermentableGrid').jqxGrid('getdatainformation').rowscount; | |
1622 | if (rowscount > 1) { | |
1623 | for (i = 0; i < rowscount; i++) { | |
1624 | rowdata = $('#fermentableGrid').jqxGrid('getrowdata', i); | |
1625 | if (rowdata.f_added < 4) | |
1626 | tw += Round(rowdata.f_amount, 3); | |
1627 | } | |
1628 | tw = Round(tw, 3); | |
1629 | ||
1630 | for (i = 0; i < rowscount; i++) { | |
1631 | rowdata = $('#fermentableGrid').jqxGrid('getrowdata', i); | |
1632 | if (rowdata.f_added < 4) { | |
1633 | percentage = Round(rowdata.f_amount / tw * 100, 1); | |
1634 | $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_percentage', percentage); | |
1635 | } else { | |
1636 | $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_percentage', 0); | |
1637 | } | |
1638 | } | |
1639 | } else { | |
1640 | $('#fermentableGrid').jqxGrid('setcellvalue', 0, 'f_percentage', 100); | |
1641 | } | |
1642 | } | |
1643 | ||
1644 | /* | |
1645 | * All calculations that depend on changes in the fermentables, | |
1646 | * volumes and equipments. | |
1647 | */ | |
1648 | function calcFermentables() { | |
1649 | ||
1650 | var sugarsf = 0, // fermentable sugars mash + boil | |
1651 | sugarsm = 0, // fermentable sugars in mash | |
1652 | vol = 0, // Volume sugars after boil | |
1653 | addedS = 0, // Added sugars after boil | |
1654 | addedmass = 0, // Added mass after boil | |
1655 | mvol = 0, // mash volume | |
1656 | colort = 0, // Colors srm * vol totals | |
1657 | colorh = 0, // Colors ebc * vol * kt | |
1658 | colorn = 0, // Colors ebc * pt * pct | |
1659 | my_100 = false, | |
1660 | mashtime = 0, // Total mash time | |
1661 | mashtemp = 0, // Average mash temperature | |
1662 | bv = 0.925, // Bierverlies rendement | |
1663 | sr = 0.95, // Mash en spoel rendement | |
1664 | lintner = 0, // Total recipe lintner | |
1665 | i, row, rows, org, timem, aboil_volume, spoelw, ogx, topw, s = 0, d, v, x, | |
1666 | sug, alc, pt, cw, color, scolor, fig; | |
1667 | ||
1668 | /* Init global variables */ | |
1669 | psugar = 0; | |
1670 | pcara = 0; | |
1671 | mashkg = 0; | |
1672 | ok_fermentables = 1; // All is in stock. | |
1673 | ok_yeasts = 1; | |
1674 | ||
1675 | if ((rows = $('#mashGrid').jqxGrid('getrows'))) { | |
1676 | for (i = 0; i < rows.length; i++) { | |
1677 | row = rows[i]; | |
1678 | if (row.step_type == 0) // Infusion | |
1679 | mvol += parseFloat(row.step_infuse_amount); | |
1680 | if (row.step_temp <= 75) { // Ignore mashout | |
1681 | timem = row.step_time + row.ramp_time; | |
1682 | mashtime += timem; | |
1683 | mashtemp += timem * row.step_temp; | |
1684 | } | |
1685 | } | |
1686 | if (mashtime > 5) | |
1687 | mashtime -= 5; //Correct last ramp > 75 | |
1688 | mashtemp = Round(mashtemp / mashtime, 2); | |
1689 | } | |
1690 | ||
1691 | if (!(rows = $('#fermentableGrid').jqxGrid('getrows'))) { | |
1692 | return; // grid not yet loaded. | |
1693 | } | |
1694 | ||
1695 | for (i = 0; i < rows.length; i++) { | |
1696 | row = rows[i]; | |
1697 | if (row.f_adjust_to_total_100) | |
1698 | my_100 = true; | |
1699 | if (row.f_type == 1 && row.f_added < 4) // Sugar | |
1700 | psugar += row.f_percentage; | |
1701 | if (row.f_graintype == 2 && row.f_added < 4) // Crystal | |
1702 | pcara += row.f_percentage; | |
1703 | d = row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); | |
1704 | if (row.f_added == 0) { // Mash | |
1705 | if (mvol > 0) { // Only if mash already known. | |
1706 | mvol += row.f_amount * row.f_moisture / 100; | |
1707 | s += d; | |
1708 | } | |
1709 | d = parseFloat(dataRecord.efficiency) / 100 * d; | |
1710 | sugarsm += d; | |
1711 | mashkg += parseFloat(row.f_amount); | |
1712 | } | |
1713 | if (row.f_added == 0 || row.f_added == 1) // Mash or Boil | |
1714 | sugarsf += d; | |
1715 | if (row.f_added == 2 || row.f_added == 3) { // Fermentation or lagering | |
1716 | x = (row.f_yield / 100) * (1 - row.f_moisture / 100); | |
1717 | addedS += row.f_amount * x; | |
1718 | addedmass += row.f_amount; | |
1719 | vol += (x * sugardensity + (1 - x) * 1) * row.f_amount; | |
1720 | } | |
1721 | if (row.f_added < 4) { | |
1722 | colort += row.f_amount * ebc_to_srm(row.f_color); | |
1723 | colorh += row.f_amount * row.f_color * get_kt(row.f_color); | |
1724 | colorn += (row.f_percentage / 100) * row.f_color; // For 8.6 Pt wort. | |
1725 | } | |
1726 | if (fermentableInit) { | |
1727 | if (row.f_added == 4) { | |
1728 | $('#bottle_priming_total').val(row.f_amount * 1000); // Prevent clearing | |
1729 | $('#bottle_priming_sugar').jqxDropDownList('selectItem', row.f_name); | |
1730 | } | |
1731 | if (row.f_added == 5) { | |
1732 | $('#keg_priming_total').val(row.f_amount * 1000); | |
1733 | $('#keg_priming_sugar').jqxDropDownList('selectItem', row.f_name); | |
1734 | } | |
1735 | } | |
1736 | // Check supplies. | |
1737 | if ((((dataRecord.inventory_reduced <= 2) && (row.f_added <= 1)) || // Mash or boil | |
1738 | ((dataRecord.inventory_reduced <= 3) && (row.f_added == 2)) || // Primary | |
1739 | ((dataRecord.inventory_reduced <= 5) && (row.f_added == 3)) || // Secondary or Tertiary | |
1740 | ((dataRecord.inventory_reduced <= 6) && (row.f_added == 4)) || // Bottle | |
1741 | ((dataRecord.inventory_reduced <= 6) && (row.f_added == 5))) && row.f_inventory < row.f_amount) { | |
1742 | ok_fermentables = 0; | |
1743 | } | |
1744 | if (row.f_added == 0 && (row.f_type == 0 || row.f_type == 4) && row.f_color < 50) { // Mash and Grain/Adjunct and Color < 50 | |
1745 | lintner += row.f_diastatic_power * row.f_amount; | |
1746 | } | |
1747 | } | |
1748 | fermentableInit = 0; | |
1749 | $('#ferm_lintner').val(Math.round(parseFloat(lintner / mashkg))); | |
1750 | $('#mash_kg').val(mashkg); | |
1751 | console.log('calcFermentables() supplies:' + ok_fermentables + ' moutsuiker:' + sugarsm + '/' + sugarsf); | |
1752 | to_100 = my_100; | |
1753 | if (to_100) { | |
1754 | $('#wf_amount').jqxNumberInput({ width: 90, readOnly: true, spinButtons: false }); | |
1755 | } else { | |
1756 | $('#wf_amount').jqxNumberInput({ width: 110, readOnly: false, spinButtons: true }); | |
1757 | } | |
1758 | ||
1759 | if (mvol > 0) { | |
1760 | v = s / sugardensity + mvol; | |
1761 | s = 1000 * s / (v * 10); //deg. Plato | |
1762 | est_mash_sg = Round(plato_to_sg(s), 5); | |
1763 | $('#est_mash_sg').val(est_mash_sg); | |
1764 | } | |
1765 | ||
1766 | // Estimate total recipe OG. | |
1767 | dataRecord.est_og = estimate_sg(sugarsf + addedS, parseFloat(dataRecord.batch_size)); | |
1768 | $('#est_og').val(dataRecord.est_og); | |
1769 | $('#est_og2').val(dataRecord.est_og); | |
1770 | org = dataRecord.est_og; | |
1771 | ||
1772 | // Estimate SG in kettle after boil | |
1773 | aboil_sg = estimate_sg(sugarsf, parseFloat(dataRecord.batch_size)); | |
1774 | $('#est_og3').val(aboil_sg); | |
1775 | ||
1776 | // Estimate SG in kettle before boil | |
1777 | preboil_sg = estimate_sg(sugarsm, parseFloat(dataRecord.boil_size)); | |
1778 | $('#est_pre_sg').val(preboil_sg); | |
1779 | ||
1780 | // Recalculate volumes. | |
1781 | aboil_volume = parseFloat(dataRecord.batch_size); | |
1782 | if (dataRecord.brew_aboil_volume > 0) | |
1783 | aboil_volume = dataRecord.brew_aboil_volume / 1.04; // volume @ 20 degrees | |
1784 | if (dataRecord.brew_fermenter_tcloss == 0) { | |
1785 | dataRecord.brew_fermenter_tcloss = dataRecord.eq_trub_chiller_loss; | |
1786 | $('#brew_fermenter_tcloss').val(dataRecord.brew_fermenter_tcloss); | |
1787 | } | |
1788 | dataRecord.brew_fermenter_volume = aboil_volume - dataRecord.brew_fermenter_tcloss + dataRecord.brew_fermenter_extrawater; | |
1789 | $('#brew_fermenter_volume').val(dataRecord.brew_fermenter_volume); | |
1790 | // Estimated needed sparge water corrected for the temperature. | |
1791 | spoelw = (dataRecord.boil_size - mash_infuse + (mashkg * my_grain_absorbtion) + dataRecord.eq_lauter_deadspace) * 1.03; | |
1792 | $('#brew_sparge_est').val(spoelw); | |
1793 | // Calculate SG in fermenter | |
1794 | ogx = dataRecord.brew_aboil_sg; | |
1795 | if (ogx < 1.002) | |
1796 | ogx = aboil_sg; | |
1797 | topw = dataRecord.brew_fermenter_extrawater; | |
1798 | ||
1799 | if (dataRecord.brew_fermenter_volume > 0) { | |
1800 | sug = sg_to_plato(ogx) * dataRecord.brew_fermenter_volume * ogx / 100; //kg of sugar in | |
1801 | sug += addedS; //kg | |
1802 | ||
1803 | if ((dataRecord.brew_fermenter_volume * ogx + addedmass) > 0) { | |
1804 | pt = 100 * sug / (dataRecord.brew_fermenter_volume * ogx + addedmass + topw); | |
1805 | dataRecord.brew_fermenter_sg = Round(plato_to_sg(pt), 4); | |
1806 | $('#brew_fermenter_sg').val(dataRecord.brew_fermenter_sg); | |
1807 | // color | |
1808 | if (dataRecord.color_method == 4) { | |
1809 | dataRecord.brew_fermenter_color = Math.round(((pt / 8.6) * colorn) + (dataRecord.boil_time / 60)); | |
1810 | } else if (dataRecord.color_method == 3) { | |
1811 | dataRecord.brew_fermenter_color = Math.round((4.46 * bv * sr) / (aboil_volume + topw) * colorh); | |
1812 | } else { | |
1813 | cw = colort / (aboil_volume + topw) * 8.34436; | |
1814 | dataRecord.brew_fermenter_color = kw_to_ebc(dataRecord.color_method, cw); | |
1815 | } | |
1816 | $('#brew_fermenter_color').val(dataRecord.brew_fermenter_color); | |
1817 | scolor = ebc_to_color(dataRecord.brew_fermenter_color); | |
1818 | $('#bcolorf').show(); | |
1819 | document.getElementById('bcolorf').style.background = scolor; | |
1820 | } | |
1821 | } else { | |
1822 | // Negative volume | |
1823 | dataRecord.brew_fermenter_sg = dataRecord.brew_fermenter_color = 0; | |
1824 | $('#brew_fermenter_sg').val(0); | |
1825 | $('#brew_fermenter_color').val(0); | |
1826 | $('#bcolorf').hide(); | |
1827 | } | |
1828 | ||
1829 | // Color of the wort | |
1830 | if (dataRecord.color_method == 4) { | |
1831 | color = Math.round(((sg_to_plato(dataRecord.est_og) / 8.6) * colorn) + (dataRecord.boil_time / 60)); | |
1832 | } else if (dataRecord.color_method == 3) { // Hans Halberstadt | |
1833 | color = Math.round((4.46 * bv * sr) / parseFloat(dataRecord.batch_size) * colorh); | |
1834 | } else { | |
1835 | cw = colort / parseFloat(dataRecord.batch_size) * 8.34436; | |
1836 | color = kw_to_ebc(dataRecord.color_method, cw); | |
1837 | } | |
1838 | dataRecord.est_color = color; | |
1839 | $('#est_color').val(color); | |
1840 | $('#est_color2').val(color); | |
1841 | scolor = ebc_to_color(color); | |
1842 | document.getElementById('bcolor').style.background = scolor; | |
1843 | document.getElementById('bcolor2').style.background = scolor; | |
1844 | ||
1845 | // Progress bars | |
1846 | pmalts = mashkg / dataRecord.eq_mash_max * 100; | |
1847 | $('#perc_malts').jqxProgressBar('val', pmalts); | |
1848 | $('#perc_sugars').jqxProgressBar('val', psugar); | |
1849 | $('#perc_cara').jqxProgressBar('val', pcara); | |
1850 | calcStage(); | |
1851 | ||
1852 | // Calculate estimated svg. | |
1853 | svg = 0; // default. | |
1854 | initcells = 0; | |
1855 | rows = $('#yeastGrid').jqxGrid('getrows'); | |
1856 | for (i = 0; i < rows.length; i++) { | |
1857 | row = rows[i]; | |
1858 | if (row.y_use == 0) { // Primary | |
1859 | if (parseFloat(row.y_attenuation) > svg) | |
1860 | svg = parseFloat(row.y_attenuation); // Take the highest if multiple yeasts. | |
1861 | if (row.y_form == 0) | |
1862 | initcells += (parseFloat(row.y_cells) / 1000000000) * parseFloat(row.y_amount) * (dataRecord.starter_viability / 100); | |
1863 | else | |
1864 | initcells += (parseFloat(row.y_cells) / 1000000) * parseFloat(row.y_amount); | |
1865 | } | |
1866 | // TODO: brett in secondary ?? | |
1867 | if ((((dataRecord.inventory_reduced <= 3) && (row.y_use == 0)) || // Primary | |
1868 | ((dataRecord.inventory_reduced <= 4) && (row.y_use == 1)) || // Secondary | |
1869 | ((dataRecord.inventory_reduced <= 5) && (row.y_use == 2)) || // Tertiary | |
1870 | ((dataRecord.inventory_reduced <= 6) && (row.y_use == 3))) && // Bottle | |
1871 | (row.y_inventory < row.y_amount)) { | |
1872 | ok_yeasts = 0; | |
1873 | } | |
1874 | } | |
1875 | calcSupplies(); | |
1876 | if (svg == 0) | |
1877 | svg = 77; | |
1878 | ||
1879 | if ((mashkg > 0) && (mash_infuse > 0) && (mashtime > 0) && (mashtemp > 0)) { | |
1880 | dataRecord.est_fg = estimate_fg(psugar, pcara, mash_infuse / mashkg, mashtime, mashtemp, svg, dataRecord.est_og); | |
1881 | } else { | |
1882 | dataRecord.est_fg = estimate_fg(psugar, pcara, 0, 0, 0, svg, dataRecord.est_og); | |
1883 | } | |
1884 | $('#est_fg').val(dataRecord.est_fg); | |
1885 | $('#est_fg2').val(dataRecord.est_fg); | |
1886 | $('#est_fg3').val(dataRecord.est_fg); | |
1887 | fig = dataRecord.est_fg; | |
1888 | ||
1889 | dataRecord.est_abv = abvol(dataRecord.est_og, dataRecord.est_fg); | |
1890 | $('#est_abv').val(dataRecord.est_abv); | |
1891 | $('#est_abv2').val(dataRecord.est_abv); | |
1892 | ||
1893 | // Calculate the final svg if available use the real value. | |
1894 | if ((dataRecord.stage >= 6) && (dataRecord.fg > 0.990) && (dataRecord.fg < dataRecord.brew_fermenter_sg)) { | |
1895 | svg = 100 * (dataRecord.brew_fermenter_sg - dataRecord.fg) / (dataRecord.brew_fermenter_sg - 1); | |
1896 | org = dataRecord.brew_fermenter_sg; | |
1897 | fig = dataRecord.fg; | |
1898 | } | |
1899 | ||
1900 | $('#yeast_cells').val(initcells); | |
1901 | $('#need_cells').val(getNeededYeastCells()); | |
1902 | ||
1903 | // Calculate the calories in kcal/l (from brouwhulp) | |
1904 | alc = 1881.22 * fig * (org - fig) / (1.775 - org); | |
1905 | sug = 3550 * fig * (0.1808 * org + 0.8192 * fig - 1.0004); | |
1906 | $('#kcal').val(Math.round((alc + sug) / (12 * 0.0295735296))); | |
1907 | }; | |
1908 | ||
1909 | function calcMash() { | |
1910 | ||
484
2083c274b283
In the product editor mash tab, display the total mash volume and the total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
479
diff
changeset
|
1911 | var h, m, infused = 0, mashtime = 0, mashvol = 0, i, row; |
2083c274b283
In the product editor mash tab, display the total mash volume and the total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
479
diff
changeset
|
1912 | |
2083c274b283
In the product editor mash tab, display the total mash volume and the total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
479
diff
changeset
|
1913 | if ((rows = $('#mashGrid').jqxGrid('getrows')) && (mashkg > 0)) { |
2083c274b283
In the product editor mash tab, display the total mash volume and the total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
479
diff
changeset
|
1914 | for (i = 0; i < rows.length; i++) { |
2083c274b283
In the product editor mash tab, display the total mash volume and the total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
479
diff
changeset
|
1915 | row = $('#mashGrid').jqxGrid('getrowdata', i); |
2083c274b283
In the product editor mash tab, display the total mash volume and the total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
479
diff
changeset
|
1916 | if (row.step_type == 0) // Infusion |
2083c274b283
In the product editor mash tab, display the total mash volume and the total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
479
diff
changeset
|
1917 | infused += row.step_infuse_amount; |
2083c274b283
In the product editor mash tab, display the total mash volume and the total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
479
diff
changeset
|
1918 | mashtime += row.step_time + row.ramp_time; |
2083c274b283
In the product editor mash tab, display the total mash volume and the total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
479
diff
changeset
|
1919 | $('#mashGrid').jqxGrid('setcellvalue', i, 'step_thickness', infused / mashkg); |
2083c274b283
In the product editor mash tab, display the total mash volume and the total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
479
diff
changeset
|
1920 | } |
478 | 1921 | } |
484
2083c274b283
In the product editor mash tab, display the total mash volume and the total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
479
diff
changeset
|
1922 | mashvol = mashkg * MaltVolume + infused; |
2083c274b283
In the product editor mash tab, display the total mash volume and the total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
479
diff
changeset
|
1923 | $('#est_mashvol').val(mashvol); |
2083c274b283
In the product editor mash tab, display the total mash volume and the total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
479
diff
changeset
|
1924 | h = Math.floor(mashtime / 60); |
2083c274b283
In the product editor mash tab, display the total mash volume and the total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
479
diff
changeset
|
1925 | m = Math.floor(mashtime - (h * 60)); |
2083c274b283
In the product editor mash tab, display the total mash volume and the total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
479
diff
changeset
|
1926 | if (h < 10) |
2083c274b283
In the product editor mash tab, display the total mash volume and the total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
479
diff
changeset
|
1927 | h = '0' + h; |
2083c274b283
In the product editor mash tab, display the total mash volume and the total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
479
diff
changeset
|
1928 | if (m < 10) |
2083c274b283
In the product editor mash tab, display the total mash volume and the total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
479
diff
changeset
|
1929 | m = '0' + m; |
2083c274b283
In the product editor mash tab, display the total mash volume and the total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
479
diff
changeset
|
1930 | $('#est_mashtime').val(h + ':' + m); |
478 | 1931 | } |
1932 | ||
1933 | /* | |
1934 | * Change OG of recipe but keep the water volumes. | |
1935 | */ | |
1936 | function calcFermentablesFromOG(OG) { | |
1937 | ||
1938 | console.log('calcFermentablesFromOG(' + OG + ')'); | |
1939 | var amount, row, d, i, sug, tot = 0, totmass = 0, rowscount, efficiency = parseFloat($('#efficiency').jqxNumberInput('decimal')); | |
1940 | sug = sg_to_plato(OG) * parseFloat($('#batch_size').jqxNumberInput('decimal')) * OG / 100; //total amount of sugars in kg | |
1941 | rowscount = $('#fermentableGrid').jqxGrid('getdatainformation').rowscount; | |
1942 | ||
1943 | for (i = 0; i < rowscount; i++) { | |
1944 | row = $('#fermentableGrid').jqxGrid('getrowdata', i); | |
1945 | if (row.f_added < 4) { | |
1946 | d = row.f_percentage / 100 * (row.f_yield / 100) * (1 - row.f_moisture / 100); | |
1947 | if (row.f_added == 0) // Mash | |
1948 | d = efficiency / 100 * d; | |
1949 | tot += d; | |
1950 | } | |
1951 | } | |
1952 | if (tot) | |
1953 | totmass = Round(sug / tot, 3); | |
1954 | ||
1955 | if (totmass) { | |
1956 | for (i = 0; i < rowscount; i++) { | |
1957 | row = $('#fermentableGrid').jqxGrid('getrowdata', i); | |
1958 | if (row.f_added < 4) { | |
1959 | amount = Math.round(row.f_percentage * 10 * totmass) / 1000; | |
1960 | $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_amount', amount); | |
1961 | } | |
1962 | } | |
1963 | } | |
1964 | }; | |
1965 | ||
1966 | function getNeededYeastCells() { | |
1967 | ||
1968 | var plato, volume, sg = dataRecord.brew_fermenter_sg; | |
1969 | if (sg <= 1.0001 && dataRecord.fg > 1.000) | |
1970 | sg = dataRecord.fg; | |
1971 | else if (sg <= 1.0001) | |
1972 | sg = dataRecord.est_og; | |
1973 | plato = sg_to_plato(sg); | |
1974 | ||
1975 | volume = dataRecord.brew_fermenter_volume; | |
1976 | if (volume <= 0) | |
1977 | volume = dataRecord.batch_size - dataRecord.eq_trub_chiller_loss; | |
1978 | ||
1979 | return pitchrate * volume * plato; | |
1980 | } | |
1981 | ||
1982 | function hopFlavourContribution(bt, vol, use, amount) { | |
1983 | var result; | |
1984 | ||
1985 | if (use == 1) { // First wort | |
1986 | result = 0.15; // assume 15% flavourcontribution for fwh | |
1987 | } else if (bt > 50) { | |
1988 | result = 0.10; // assume 10% flavourcontribution as a minimum | |
1989 | } else { | |
1990 | result = 15.25 / (6 * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((bt - 21) / 6, 2)); | |
1991 | if (result < 0.10) | |
1992 | result = 0.10; // assume 10% flavourcontribution as a minimum | |
1993 | } | |
1994 | return (result * amount * 1000) / vol; | |
1995 | } | |
1996 | ||
1997 | function hopAromaContribution(bt, vol, use, amount) { | |
1998 | var result = 0; | |
1999 | ||
2000 | if (use == 5) { // Dry hop | |
2001 | result = 1.33; | |
2002 | } else if (bt > 20) { | |
2003 | result = 0; | |
2004 | } else if (bt > 7.5) { | |
2005 | result = 10.03 / (4 * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((bt - 7.5) / 4, 2)); | |
2006 | } else if (use == 2) { // Boil | |
2007 | result = 1; | |
2008 | } else if (use == 3) { // Aroma | |
2009 | result = 1.2; | |
2010 | } else if (use == 4) { // Whirlpool | |
2011 | result = 1.2; | |
2012 | } | |
2013 | return (result * amount * 1000) / vol; | |
2014 | } | |
2015 | ||
2016 | function calcIBUs() { | |
2017 | var total_ibus = 0, ferm_ibus = 0, rows = {}, i, row; | |
2018 | hop_aroma = hop_flavour = 0; | |
2019 | if (!(rows = $('#hopGrid').jqxGrid('getrows'))) { | |
2020 | return; | |
2021 | } | |
2022 | ok_hops = 1; | |
2023 | for (i = 0; i < rows.length; i++) { | |
2024 | row = rows[i]; | |
2025 | total_ibus += toIBU(row.h_useat, row.h_form, preboil_sg, parseFloat(dataRecord.batch_size), | |
2026 | parseFloat(row.h_amount), parseFloat(row.h_time), parseFloat(row.h_alpha), dataRecord.ibu_method); | |
2027 | ferm_ibus += toIBU(row.h_useat, row.h_form, preboil_sg, | |
2028 | parseFloat(dataRecord.brew_fermenter_volume) + parseFloat(dataRecord.brew_fermenter_tcloss), | |
2029 | parseFloat(row.h_amount), parseFloat(row.h_time), parseFloat(row.h_alpha), dataRecord.ibu_method); | |
2030 | hop_flavour += hopFlavourContribution(parseFloat(row.h_time), parseFloat(dataRecord.batch_size), | |
2031 | row.h_useat, parseFloat(row.h_amount)); | |
2032 | hop_aroma += hopAromaContribution(parseFloat(row.h_time), parseFloat(dataRecord.batch_size), | |
469
3d532097860d
Code optimisation for compressed javascript in the product editor
Michiel Broek <mbroek@mbse.eu>
parents:
464
diff
changeset
|
2033 | row.h_useat, parseFloat(row.h_amount)); |
478 | 2034 | if ((((dataRecord.inventory_reduced <= 2) && (row.h_useat <= 4)) || // Mash, FW, Boil, Aroma, Whirlpool |
2035 | ((dataRecord.inventory_reduced <= 6) && (row.h_useat == 5))) && // Dry-hop | |
2036 | (row.h_inventory < row.h_amount)) | |
2037 | ok_hops = 0; | |
2038 | } | |
2039 | total_ibus = Math.round(total_ibus * 10) / 10; | |
2040 | ferm_ibus = Math.round(ferm_ibus * 10) / 10; | |
2041 | hop_flavour = Math.round(hop_flavour * 1000 / 5) / 10; | |
2042 | hop_aroma = Math.round(hop_aroma * 1000 / 6) / 10; | |
2043 | if (hop_flavour > 100) | |
2044 | hop_flavour = 100; | |
2045 | if (hop_aroma > 100) | |
2046 | hop_aroma = 100; | |
2047 | console.log('calcIBUs(): ' + total_ibus + ' flavour: ' + hop_flavour + ' aroma: ' + hop_aroma + | |
2048 | ' fermenter:' + ferm_ibus + ' supplies:' + ok_hops); | |
2049 | dataRecord.est_ibu = total_ibus; | |
2050 | $('#est_ibu').val(total_ibus); | |
2051 | $('#est_ibu2').val(total_ibus); | |
2052 | $('#hop_flavour').jqxProgressBar('val', hop_flavour); | |
2053 | $('#hop_aroma').jqxProgressBar('val', hop_aroma); | |
2054 | $('#brew_fermenter_ibu').val(ferm_ibus); | |
2055 | calcStage(); | |
2056 | calcSupplies(); | |
2057 | }; | |
2058 | ||
2059 | /* | |
2060 | * http://braukaiser.com/blog/blog/2012/11/03/estimating-yeast-growth/ | |
2061 | * | |
2062 | * stype: 0=stirred, 1=shaken, 2=simple | |
2063 | * totcells: initial cells | |
2064 | * egrams: gram extract | |
2065 | */ | |
2066 | function getGrowthRate(stype, totcells, egrams) { | |
2067 | ||
2068 | /* Cells per grams extract (B/g) */ | |
2069 | var cpe = totcells / egrams; | |
2070 | ||
2071 | if (cpe > 3.5) | |
2072 | return 0; // no growth | |
2073 | if (stype == 2) | |
2074 | return 0.4; // simple starter | |
2075 | if (stype == 1) | |
2076 | return 0.62; // shaken starter | |
2077 | if (cpe <= 1.4) // stirred starter | |
2078 | return 1.4; | |
2079 | return 2.33 - (.67 * cpe); | |
2080 | }; | |
2081 | ||
2082 | function calcStep(svol, stype, start) { | |
2083 | ||
2084 | var gperpoint = 2.72715, //number of grams of extract per point of starter gravity per liter | |
2085 | prate = start / svol * 1000, | |
2086 | irate = Round(prate, 1), | |
2087 | egrams = (dataRecord.starter_sg - 1) * svol * gperpoint, | |
2088 | grate = getGrowthRate(stype, start, egrams), | |
2089 | ncells = Round(egrams * grate, 1), | |
2090 | totcells = parseFloat(ncells) + start; | |
2091 | ||
495
fdbb6bfae569
Disabled some console.log items.
Michiel Broek <mbroek@mbse.eu>
parents:
490
diff
changeset
|
2092 | //console.log('svol:' + svol + ' start:' + start + ' irate:' + irate + ' egrams:' + egrams + ' grate:' + grate + ' ncells:' + ncells); |
478 | 2093 | return { |
2094 | svol: svol, | |
2095 | irate: irate, | |
2096 | prate: Round(prate, 1), | |
2097 | ncells: ncells, | |
2098 | totcells: totcells, | |
2099 | growf: Round(ncells / start, 2) | |
2100 | }; | |
2101 | } | |
2102 | ||
2103 | /* | |
2104 | * Calculate all starter steps. | |
2105 | * stype: final starter type: 0 = stirred, 1 = shaked, 2 = simple. | |
2106 | * start: initial cells in billions | |
2107 | * needed: needed cells in billions | |
2108 | * | |
2109 | * result: all values updated. | |
2110 | */ | |
2111 | function calcSteps(stype, start, needed) { | |
2112 | ||
2113 | var uvols = [20, 40, 60, 80, 100, 150, 200, 250, 375, 500, 625, 750, 875, 1000, 1250, 1500, 2000, 2500, 3000, 4000, 5000], | |
2114 | mvols = uvols.length, svol = 0, lasti = 0, result = {}, i; | |
2115 | ||
2116 | /* | |
2117 | * If no values are set, auto calculate the starter. | |
2118 | */ | |
2119 | if ((parseFloat($('#prop1_volume').jqxNumberInput('decimal')) + parseFloat($('#prop2_volume').jqxNumberInput('decimal')) + | |
2120 | parseFloat($('#prop3_volume').jqxNumberInput('decimal')) + parseFloat($('#prop4_volume').jqxNumberInput('decimal'))) == 0) { | |
2121 | // clear by default | |
2122 | for (i = 1; i < 5; i++) { | |
2123 | $('#prop' + i + '_type').hide(); | |
2124 | $('#r' + i + '_pmpt').show(); | |
2125 | $('#prop' + i + '_type').val(stype); | |
2126 | $('#prop' + i + '_volume').hide(); | |
2127 | $('#prop' + i + '_volume').val(0); | |
2128 | $('#prop' + i + '_irate').hide(); | |
2129 | $('#prop' + i + '_ncells').hide(); | |
2130 | $('#prop' + i + '_tcells').hide(); | |
2131 | $('#prop' + i + '_growf').hide(); | |
2132 | } | |
2133 | if (start > needed) { | |
2134 | return; // no starter needed | |
2135 | } | |
2136 | $('#prop1_type').show(); | |
2137 | $('#r1_pmpt').hide(); | |
2138 | $('#prop1_volume').show(); | |
2139 | $('#prop1_irate').show(); | |
2140 | $('#prop1_ncells').show(); | |
2141 | $('#prop1_tcells').show(); | |
2142 | $('#prop1_growf').show(); | |
2143 | for (i = lasti; i <= mvols; i++) { | |
2144 | lasti = i; | |
2145 | svol = uvols[lasti]; | |
2146 | result = calcStep(svol, stype, start); | |
2147 | if (result.irate < 25) { | |
2148 | // inocculation rate too low, backup one step and break out. | |
2149 | lasti = i - 1; | |
2150 | svol = uvols[lasti]; | |
2151 | result = calcStep(svol, stype, start); | |
2152 | break; | |
2153 | } | |
2154 | if (result.totcells > needed || i == mvols) { // hit the target or loops done | |
2155 | break; | |
2156 | } | |
2157 | } | |
2158 | $('#prop1_volume').val(result.svol / 1000); // to liters | |
2159 | $('#prop1_irate').val(result.prate); | |
2160 | $('#prop1_ncells').val(result.ncells); | |
2161 | $('#prop1_tcells').val(result.totcells); | |
2162 | $('#prop1_growf').val(result.growf); | |
2163 | if (result.totcells > needed) | |
2164 | return; // hit the target | |
2165 | ||
2166 | // second stage | |
2167 | $('#r2_pmpt').hide(); | |
2168 | $('#prop2_type').val(stype); | |
2169 | $('#prop2_type').show(); | |
2170 | $('#prop2_volume').show(); | |
2171 | $('#prop2_irate').show(); | |
2172 | $('#prop2_ncells').show(); | |
2173 | $('#prop2_tcells').show(); | |
2174 | $('#prop2_growf').show(); | |
2175 | for (i = lasti; i <= mvols; i++) { | |
2176 | lasti = i; | |
2177 | svol = uvols[lasti]; | |
2178 | result = calcStep(svol, stype, $('#prop1_tcells').val()); | |
2179 | if (result.irate < 25) { | |
2180 | lasti = i - 1; | |
2181 | svol = uvols[lasti]; | |
2182 | result = calcStep(svol, stype, $('#prop1_tcells').val()); | |
2183 | break; | |
2184 | } | |
2185 | if (result.totcells > needed || i == mvols) { // hit the target or loops done | |
2186 | break; | |
2187 | } | |
2188 | } | |
2189 | $('#prop2_volume').val(result.svol / 1000); // to liters | |
2190 | $('#prop2_irate').val(result.prate); | |
2191 | $('#prop2_ncells').val(result.ncells); | |
2192 | $('#prop2_tcells').val(result.totcells); | |
2193 | $('#prop2_growf').val(result.growf); | |
2194 | if (result.totcells > needed) | |
2195 | return; // hit the target | |
2196 | ||
2197 | // third stage | |
2198 | $('#r3_pmpt').hide(); | |
2199 | $('#prop3_type').val(stype); | |
2200 | $('#prop3_type').show(); | |
2201 | $('#prop3_volume').show(); | |
2202 | $('#prop3_irate').show(); | |
2203 | $('#prop3_ncells').show(); | |
2204 | $('#prop3_tcells').show(); | |
2205 | $('#prop3_growf').show(); | |
2206 | for (i = lasti; i <= mvols; i++) { | |
2207 | lasti = i; | |
2208 | svol = uvols[lasti]; | |
2209 | result = calcStep(svol, stype, $('#prop2_tcells').val()); | |
2210 | if (result.irate < 25) { | |
2211 | lasti = i - 1; | |
2212 | svol = uvols[lasti]; | |
2213 | result = calcStep(svol, stype, $('#prop2_tcells').val()); | |
2214 | break; | |
2215 | } | |
2216 | if (result.totcells > needed || i == mvols) { // hit the target or loops done | |
2217 | break; | |
2218 | } | |
2219 | } | |
2220 | $('#prop3_volume').val(result.svol / 1000); // to liters | |
2221 | $('#prop3_irate').val(result.prate); | |
2222 | $('#prop3_ncells').val(result.ncells); | |
2223 | $('#prop3_tcells').val(result.totcells); | |
2224 | $('#prop3_growf').val(result.growf); | |
2225 | if (result.totcells > needed) | |
2226 | return; // hit the target | |
2227 | ||
2228 | // fourth stage | |
2229 | $('#r4_pmpt').hide(); | |
2230 | $('#prop4_type').val(stype); | |
2231 | $('#prop4_type').show(); | |
2232 | $('#prop4_volume').show(); | |
2233 | $('#prop4_irate').show(); | |
2234 | $('#prop4_ncells').show(); | |
2235 | $('#prop4_tcells').show(); | |
2236 | $('#prop4_growf').show(); | |
2237 | for (i = lasti; i <= mvols; i++) { | |
2238 | lasti = i; | |
2239 | svol = uvols[lasti]; | |
2240 | result = calcStep(svol, stype, $('#prop3_tcells').val()); | |
2241 | if (result.totcells > needed || i == mvols) { // hit the target or loops done | |
2242 | $('#prop4_volume').val(result.svol / 1000); // to liters | |
2243 | $('#prop4_irate').val(result.prate); | |
2244 | $('#prop4_ncells').val(result.ncells); | |
2245 | $('#prop4_tcells').val(result.totcells); | |
2246 | $('#prop4_growf').val(result.growf); | |
2247 | return; | |
2248 | } | |
2249 | } | |
2250 | } else { | |
2251 | // recalculate | |
2252 | if (dataRecord.prop1_volume > 0) { | |
2253 | $('#r1_pmpt').hide(); | |
2254 | $('#prop1_type').show(); | |
2255 | $('#prop1_volume').show(); | |
2256 | $('#prop1_irate').show(); | |
2257 | $('#prop1_ncells').show(); | |
2258 | $('#prop1_tcells').show(); | |
2259 | $('#prop1_growf').show(); | |
2260 | result = calcStep($('#prop1_volume').val() * 1000, dataRecord.prop1_type, start); | |
2261 | $('#prop1_irate').val(result.prate); | |
2262 | $('#prop1_ncells').val(result.ncells); | |
2263 | $('#prop1_tcells').val(result.totcells); | |
2264 | $('#prop1_growf').val(result.growf); | |
2265 | } | |
2266 | if (dataRecord.prop2_volume > 0) { | |
2267 | $('#r2_pmpt').hide(); | |
2268 | $('#prop2_type').show(); | |
2269 | $('#prop2_volume').show(); | |
2270 | $('#prop2_irate').show(); | |
2271 | $('#prop2_ncells').show(); | |
2272 | $('#prop2_tcells').show(); | |
2273 | $('#prop2_growf').show(); | |
2274 | result = calcStep($('#prop2_volume').val() * 1000, dataRecord.prop2_type, $('#prop1_tcells').val()); | |
2275 | $('#prop2_irate').val(result.prate); | |
2276 | $('#prop2_ncells').val(result.ncells); | |
2277 | $('#prop2_tcells').val(result.totcells); | |
2278 | $('#prop2_growf').val(result.growf); | |
2279 | } | |
2280 | if (dataRecord.prop3_volume > 0) { | |
2281 | $('#r3_pmpt').hide(); | |
2282 | $('#prop3_type').show(); | |
2283 | $('#prop3_volume').show(); | |
2284 | $('#prop3_irate').show(); | |
2285 | $('#prop3_ncells').show(); | |
2286 | $('#prop3_tcells').show(); | |
2287 | $('#prop3_growf').show(); | |
2288 | result = calcStep($('#prop3_volume').val() * 1000, dataRecord.prop3_type, $('#prop2_tcells').val()); | |
2289 | $('#prop3_irate').val(result.prate); | |
2290 | $('#prop3_ncells').val(result.ncells); | |
2291 | $('#prop3_tcells').val(result.totcells); | |
2292 | $('#prop3_growf').val(result.growf); | |
2293 | } | |
2294 | if (dataRecord.prop4_volume > 0) { | |
2295 | $('#r4_pmpt').hide(); | |
2296 | $('#prop4_type').show(); | |
2297 | $('#prop4_volume').show(); | |
2298 | $('#prop4_irate').show(); | |
2299 | $('#prop4_ncells').show(); | |
2300 | $('#prop4_tcells').show(); | |
2301 | $('#prop4_growf').show(); | |
2302 | result = calcStep($('#prop4_volume').val() * 1000, dataRecord.prop4_type, $('#prop3_tcells').val()); | |
2303 | $('#prop4_irate').val(result.prate); | |
2304 | $('#prop4_ncells').val(result.ncells); | |
2305 | $('#prop4_tcells').val(result.totcells); | |
2306 | $('#prop4_growf').val(result.growf); | |
2307 | } | |
2308 | } | |
2309 | } | |
2310 | ||
2311 | function calcYeast() { | |
2312 | ||
2313 | // Calculate needed cells. | |
2314 | var plato, volume, rows, rowscount, row, i, needed, use_cells, sg = dataRecord.brew_fermenter_sg; | |
2315 | if (sg <= 1.0001 && dataRecord.fg > 1.000) | |
2316 | sg = dataRecord.fg; | |
2317 | else if (sg <= 1.0001) | |
2318 | sg = dataRecord.est_og; | |
2319 | plato = sg_to_plato(sg); | |
2320 | ||
2321 | volume = dataRecord.brew_fermenter_volume; | |
2322 | if (volume > 0) { | |
2323 | if (dataRecord.brew_fermenter_extrawater > 0) | |
2324 | volume += dataRecord.brew_fermenter_extrawater; | |
2325 | } else { | |
2326 | volume = dataRecord.batch_size - dataRecord.eq_trub_chiller_loss; | |
2327 | } | |
2328 | ||
2329 | // Also in calcFermentables() | |
2330 | $('#yeast_cells').val(initcells); | |
2331 | ||
2332 | if (!(rows = $('#yeastGrid').jqxGrid('getrows'))) { | |
2333 | return; // grid not yet loaded. | |
2334 | } | |
2335 | rowscount = $('#yeastGrid').jqxGrid('getdatainformation').rowscount; | |
2336 | if (rowscount == 0) | |
2337 | return; // no yeast in recipe | |
2338 | ||
2339 | for (i = 0; i < rowscount; i++) { | |
2340 | row = $('#yeastGrid').jqxGrid('getrowdata', i); | |
2341 | if (row.y_use == 0) { // primary | |
2342 | // pitchrate see https://www.brewersfriend.com/yeast-pitch-rate-and-starter-calculator/ | |
2343 | // and http://braukaiser.com/blog/blog/2012/11/03/estimating-yeast-growth/ | |
2344 | pitchrate = 0.75; | |
2345 | if (dataRecord.est_og > 1.060) | |
2346 | pitchrate = 1.0; | |
2347 | // if (dataRecord.est_og > 1.076) | |
2348 | // pitchrate = 1.25; // Wyeast labs. http://www.wyeastlab.com/hb_pitchrates.cfm | |
2349 | if (row.y_type == 0) // lager yeast | |
2350 | pitchrate *= 2; | |
2351 | ||
2352 | // if (row.y_form == 1) { // dry yeast | |
2353 | // } else { // possible starter needed | |
2354 | // } | |
2355 | } | |
2356 | } | |
495
fdbb6bfae569
Disabled some console.log items.
Michiel Broek <mbroek@mbse.eu>
parents:
490
diff
changeset
|
2357 | needed = Round(pitchrate * volume * plato, 1); |
478 | 2358 | console.log('calcYeast() pitchrate:' + pitchrate + ' start:' + initcells + ' needed:' + needed + ' volume:' + volume); |
2359 | $('#need_cells').val(needed); | |
2360 | use_cells = initcells; | |
2361 | ||
2362 | if (dataRecord.starter_enable) { | |
2363 | calcSteps(dataRecord.starter_type, initcells, needed); | |
2364 | ||
2365 | for (i = 1; i < 5; i++) { | |
2366 | $('#r' + i + '_irate').html(''); | |
2367 | $('#r' + i + '_growf').html(''); | |
2368 | $('#r' + i + '_tcells').html(''); | |
2369 | if (parseFloat($('#prop' + i + '_volume').val()) > 0) { | |
2370 | if ((parseFloat($('#prop' + i + '_irate').val()) < 25) || (parseFloat($('#prop' + i + '_irate').val()) > 100)) { | |
2371 | $('#r' + i + '_irate').html("<img src='images/dialog-error.png'>"); | |
2372 | } else { | |
2373 | $('#r' + i + '_irate').html("<img src='images/dialog-ok-apply.png'>"); | |
2374 | } | |
2375 | if (parseFloat($('#prop' + i + '_growf').val()) < 1) | |
2376 | $('#r' + i + '_growf').html("<img src='images/dialog-error.png'>"); | |
2377 | if (($('#prop' + i + '_type').val() > 0) && (parseFloat($('#prop' + i + '_growf').val()) > 3)) | |
2378 | $('#r' + i + '_growf').html("<img src='images/dialog-error.png'>"); | |
2379 | if (parseFloat($('#prop' + i + '_tcells').val()) > needed) | |
2380 | $('#r' + i + '_tcells').html("<img src='images/dialog-ok-apply.png'>"); | |
2381 | use_cells = parseFloat($('#prop' + i + '_tcells').val()); | |
2382 | } else { | |
2383 | $('#r' + i + '_irate').html(''); | |
2384 | } | |
2385 | } | |
2386 | } | |
2387 | $('#plato_cells').val(parseFloat(use_cells / (volume * plato))); | |
2388 | }; | |
2389 | ||
2390 | function adjustHops(factor) { | |
2391 | ||
2392 | console.log('adjustHops(' + factor + ')'); | |
2393 | var row, i, amount, rowscount = $('#hopGrid').jqxGrid('getdatainformation').rowscount; | |
2394 | if (rowscount == 0) | |
2395 | return; | |
2396 | for (i = 0; i < rowscount; i++) { | |
2397 | row = $('#hopGrid').jqxGrid('getrowdata', i); | |
2398 | amount = row.h_amount * factor; | |
2399 | $('#hopGrid').jqxGrid('setcellvalue', i, 'h_amount', amount); | |
2400 | } | |
2401 | }; | |
2402 | ||
2403 | function calcMiscs() { | |
2404 | ||
2405 | ok_miscs = 1; | |
2406 | var row, i, rowscount = $('#miscGrid').jqxGrid('getdatainformation').rowscount; | |
2407 | if (rowscount == 0) | |
2408 | return; | |
2409 | for (i = 0; i < rowscount; i++) { | |
2410 | row = $('#miscGrid').jqxGrid('getrowdata', i); | |
2411 | if ((((dataRecord.inventory_reduced <= 2) && (row.m_use_use <= 2)) || // Starter, Mash, Boil | |
2412 | ((dataRecord.inventory_reduced <= 3) && (row.m_use_use == 3)) || // Primary | |
2413 | ((dataRecord.inventory_reduced <= 5) && (row.m_use_use == 4)) || // Secondary, Teriary | |
2414 | ((dataRecord.inventory_reduced <= 6) && (row.m_use_use == 5))) && // Bottle | |
2415 | (row.m_inventory < row.m_amount)) { | |
2416 | ok_miscs = 0; | |
2417 | } | |
2418 | } | |
2419 | calcSupplies(); | |
2420 | }; | |
2421 | ||
2422 | function adjustMiscs(factor) { | |
2423 | ||
2424 | console.log('adjustMiscs(' + factor + ')'); | |
2425 | var row, i, amount, rowscount = $('#miscGrid').jqxGrid('getdatainformation').rowscount; | |
2426 | if (rowscount == 0) | |
2427 | return; | |
2428 | for (i = 0; i < rowscount; i++) { | |
2429 | row = $('#miscGrid').jqxGrid('getrowdata', i); | |
2430 | amount = row.m_amount * factor; | |
2431 | $('#miscGrid').jqxGrid('setcellvalue', i, 'm_amount', amount); | |
2432 | switch (row.m_name) { | |
2433 | case 'CaCl2': | |
2434 | $('#wa_cacl2').val(row.m_amount * 1000); | |
2435 | break; | |
2436 | case 'CaSO4': | |
2437 | $('#wa_caso4').val(row.m_amount * 1000); | |
2438 | break; | |
2439 | case 'MgSO4': | |
2440 | $('#wa_mgso4').val(row.m_amount * 1000); | |
2441 | break; | |
2442 | case 'NaCl': | |
2443 | $('#wa_nacl').val(row.m_amount * 1000); | |
2444 | break; | |
2445 | case 'Melkzuur': | |
2446 | case 'Zoutzuur': | |
2447 | case 'Fosforzuur': | |
2448 | case 'Zwavelzuur': | |
2449 | $('#wa_acid').val(row.m_amount * 1000); | |
2450 | break; | |
2451 | case 'NaHCO3': | |
2452 | case 'Na2CO3': | |
2453 | case 'CaCO3': | |
2454 | case 'Ca(OH)2': | |
2455 | $('#wa_base').val(row.m_amount * 1000); | |
2456 | break; | |
2457 | } | |
2458 | } | |
2459 | }; | |
2460 | ||
2461 | function adjustYeasts(factor) { | |
2462 | ||
2463 | console.log('adjustYeasts(' + factor + ')'); | |
2464 | var row, i, amount, rowscount = $('#yeastGrid').jqxGrid('getdatainformation').rowscount; | |
2465 | if (rowscount == 0) | |
2466 | return; | |
2467 | for (i = 0; i < rowscount; i++) { | |
2468 | row = $('#yeastGrid').jqxGrid('getrowdata', i); | |
2469 | if (row.y_form == 1) { // Only adjust dry yeast | |
2470 | amount = row.y_amount * factor; | |
2471 | $('#yeastGrid').jqxGrid('setcellvalue', i, 'y_amount', amount); | |
2472 | } | |
2473 | } | |
2474 | calcYeast(); | |
2475 | }; | |
2476 | ||
2477 | function adjustWaters(factor) { | |
2478 | ||
2479 | console.log('adjustWaters(' + factor + ')'); | |
2480 | var amount, row, i, rowscount = $('#mashGrid').jqxGrid('getdatainformation').rowscount; | |
2481 | if (rowscount == 0) | |
2482 | return; | |
2483 | mash_infuse = 0; | |
2484 | for (i = 0; i < rowscount; i++) { | |
2485 | row = $('#mashGrid').jqxGrid('getrowdata', i); | |
2486 | if (row.step_type == 0) { // Infusion | |
2487 | amount = Round(row.step_infuse_amount * factor, 1); | |
2488 | $('#mashGrid').jqxGrid('setcellvalue', i, 'step_infuse_amount', amount); | |
2489 | mash_infuse += amount; | |
2490 | } | |
2491 | } | |
2492 | if (dataRecord.w2_amount == 0) { | |
2493 | dataRecord.w1_amount = mash_infuse; | |
2494 | $('#w1_amount').val(mash_infuse); | |
2495 | } else { | |
2496 | dataRecord.w1_amount = (dataRecord.w1_amount / (dataRecord.w1_amount + dataRecord.w2_amount)) * mash_infuse; | |
2497 | dataRecord.w2_amount = (dataRecord.w2_amount / (dataRecord.w1_amount + dataRecord.w2_amount)) * mash_infuse; | |
2498 | $('#w1_amount').val(dataRecord.w1_amount); | |
2499 | $('#w2_amount').val(dataRecord.w2_amount); | |
2500 | } | |
2501 | $('#wg_amount').val(mash_infuse); | |
2502 | }; | |
2503 | ||
2504 | function calcMashEfficiency() { | |
2505 | var c, m; | |
2506 | if (parseFloat($('#brew_mash_sg').jqxNumberInput('decimal')) < 1.002) | |
2507 | return; | |
2508 | c = sg_to_plato(est_mash_sg); | |
2509 | m = sg_to_plato(parseFloat($('#brew_mash_sg').jqxNumberInput('decimal'))); | |
2510 | if (c > 0.5) | |
2511 | $('#brew_mash_efficiency').val(100 * m / c); | |
2512 | else | |
2513 | $('#brew_mash_efficiency').val(0); | |
2514 | }; | |
2515 | ||
2516 | function calcEfficiencyBeforeBoil() { | |
2517 | var m = 0, rows = {}, i, row, tot, result = 0; | |
2518 | if (!(rows = $('#fermentableGrid').jqxGrid('getrows'))) { | |
2519 | return; // grid not yet loaded. | |
2520 | } | |
2521 | for (i = 0; i < rows.length; i++) { | |
2522 | row = rows[i]; | |
2523 | if (row.f_added == 0) { // Mash | |
2524 | m += row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); | |
2525 | } | |
2526 | } | |
2527 | tot = sg_to_plato(dataRecord.brew_preboil_sg) * (dataRecord.brew_preboil_volume / 1.04) * dataRecord.brew_preboil_sg * 10 / 1000; | |
2528 | if (m > 0) | |
2529 | result = Round((tot / m * 100), 1); | |
2530 | if (result < 0) | |
2531 | result = 0; | |
2532 | $('#brew_preboil_efficiency').val(result); | |
2533 | } | |
2534 | ||
2535 | function calcEfficiencyAfterBoil() { | |
2536 | var m = 0, // Sugars added at mash | |
2537 | b = 0, // Sugars added at boil | |
2538 | rows = {}, i, row, tot, result = 0; | |
2539 | if (!(rows = $('#fermentableGrid').jqxGrid('getrows'))) { | |
2540 | return; // grid not yet loaded. | |
2541 | } | |
2542 | for (i = 0; i < rows.length; i++) { | |
2543 | row = rows[i]; | |
2544 | if (row.f_added == 0) { // Mash | |
2545 | m += row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); | |
2546 | } else if (row.f_added == 1) { // Boil | |
2547 | b += row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); | |
2548 | } | |
2549 | } | |
2550 | tot = sg_to_plato(dataRecord.brew_aboil_sg) * (dataRecord.brew_aboil_volume / 1.04) * dataRecord.brew_aboil_sg * 10 / 1000; | |
2551 | tot -= b; // total sugars in wort minus added sugars. | |
2552 | if (m > 0) | |
2553 | result = Round((tot / m * 100), 1); | |
2554 | if (result < 0) | |
2555 | result = 0; | |
2556 | dataRecord.brew_aboil_efficiency = result; | |
2557 | $('#brew_aboil_efficiency').val(result); | |
2558 | } | |
2559 | ||
2560 | function GetBUGU() { | |
2561 | var gu = (dataRecord.est_og - 1) * 1000; | |
2562 | if (gu > 0) | |
2563 | return dataRecord.est_ibu / gu; | |
2564 | else | |
2565 | return 0.5; | |
2566 | } | |
2567 | ||
2568 | function GetOptClSO4ratio() { | |
2569 | var BUGU = GetBUGU(); | |
2570 | return (-1.2 * BUGU + 1.4); | |
2571 | } | |
2572 | ||
2573 | function setWaterAgent(name, amount) { | |
2574 | var row, i, id, found = false, miscs, rows = $('#miscGrid').jqxGrid('getrows'); | |
2575 | if (amount == 0) { | |
2576 | for (i = 0; i < rows.length; i++) { | |
2577 | row = rows[i]; | |
2578 | if (row.m_name == name) { | |
2579 | id = $('#miscGrid').jqxGrid('getrowid', i); | |
2580 | $('#miscGrid').jqxGrid('deleterow', id); | |
2581 | } | |
2582 | } | |
2583 | } else { | |
2584 | for (i = 0; i < rows.length; i++) { | |
2585 | row = rows[i]; | |
2586 | if (row.m_name == name) { | |
2587 | found = true; | |
2588 | $('#miscGrid').jqxGrid('setcellvalue', i, 'm_amount', amount / 1000); | |
2589 | break; | |
2590 | } | |
2591 | } | |
2592 | if (! found) { | |
2593 | miscs = new $.jqx.dataAdapter(miscInvSource, { | |
2594 | loadComplete: function() { | |
2595 | var record, i, row = {}, records = miscs.records; | |
2596 | for (i = 0; i < records.length; i++) { | |
2597 | record = records[i]; | |
2598 | if (record.name == name) { | |
2599 | row['m_name'] = record.name; | |
2600 | row['m_amount'] = amount / 1000; | |
2601 | row['m_cost'] = record.cost; | |
2602 | row['m_type'] = record.type; | |
2603 | row['m_use_use'] = record.use_use; | |
2604 | row['m_time'] = 0; | |
2605 | row['m_amount_is_weight'] = record.amount_is_weight; | |
2606 | row['m_inventory'] = record.inventory; | |
2607 | row['m_avail'] = 1; | |
2608 | $('#miscGrid').jqxGrid('addrow', null, row); | |
2609 | } | |
2610 | } | |
2611 | } | |
2612 | }); | |
2613 | miscs.dataBind(); | |
2614 | return; | |
2615 | } | |
2616 | } | |
2617 | } | |
2618 | ||
2619 | function setRangeIndicator(ion, rangeCode) { | |
2620 | if ((rangeCode == 'laag') || (rangeCode == 'hoog')) | |
2621 | $('#wr_' + ion).html("<img src='images/dialog-error.png'><span style='vertical-align: top; font-size: 10px; font-style: italic;'>" + rangeCode + '</span>'); | |
2622 | else | |
2623 | $('#wr_' + ion).html("<img src='images/dialog-ok-apply.png'>"); | |
2624 | } | |
2625 | ||
2626 | function mix(v1, v2, c1, c2) { | |
2627 | if ((v1 + v2) > 0) { | |
2628 | return ((v1 * c1) + (v2 * c2)) / (v1 + v2); | |
2629 | } | |
2630 | return 0; | |
2631 | } | |
2632 | ||
2633 | // mg/l as CaCO3 | |
2634 | function ResidualAlkalinity(total_alkalinity, calcium, magnesium) { | |
2635 | return total_alkalinity - (calcium / 1.4 + magnesium / 1.7); | |
2636 | } | |
2637 | ||
2638 | function PartCO3(pH) { | |
2639 | var H = Math.pow(10, -pH); | |
2640 | return 100 * Ka1 * Ka2 / (H * H + H * Ka1 + Ka1 * Ka2); | |
2641 | } | |
2642 | ||
2643 | function PartHCO3(pH) { | |
2644 | var H = Math.pow(10, -pH); | |
2645 | return 100 * Ka1 * H / (H * H + H * Ka1 + Ka1 * Ka2); | |
2646 | } | |
2647 | ||
2648 | function Charge(pH) { | |
2649 | return (-2 * PartCO3(pH) - PartHCO3(pH)); | |
2650 | } | |
2651 | ||
2652 | //Z alkalinity is the amount of acid (in mEq/l) needed to bring water to the target pH (Z pH) | |
2653 | function ZAlkalinity(pHZ) { | |
2654 | var C43 = Charge(4.3), | |
2655 | Cw = Charge(parseFloat($('#wg_ph').jqxNumberInput('decimal'))), | |
2656 | Cz = Charge(pHZ), | |
2657 | DeltaCNaught = -C43 + Cw, | |
2658 | CT = parseFloat($('#wg_total_alkalinity').jqxNumberInput('decimal')) / 50 / DeltaCNaught, | |
2659 | DeltaCZ = -Cz + Cw; | |
2660 | return CT * DeltaCZ; | |
2661 | } | |
2662 | ||
2663 | //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) | |
2664 | function ZRA(pHZ) { | |
2665 | ||
2666 | var Magn, Z, Calc = parseFloat($('#wg_calcium').jqxNumberInput('decimal')) / (MMCa / 2); | |
2667 | Magn = parseFloat($('#wg_magnesium').jqxNumberInput('decimal')) / (MMMg / 2); | |
2668 | Z = ZAlkalinity(pHZ); | |
2669 | return Z - (Calc / 3.5 + Magn / 7); | |
2670 | } | |
2671 | ||
2672 | function ProtonDeficit(pHZ) { | |
2673 | ||
2674 | var rows, i, C1, ebc, x, Result = ZRA(pHZ) * parseFloat($('#wg_amount').jqxNumberInput('decimal')); | |
2675 | // proton deficit for the grist | |
2676 | rows = $('#fermentableGrid').jqxGrid('getrows'); | |
2677 | for (i = 0; i < rows.length; i++) { | |
2678 | row = rows[i]; | |
2679 | if (row.f_added == 0 && row.f_graintype != 6) { // Added == Mash && graintype != No Malt | |
2680 | // Check if acid is required | |
2681 | C1 = 0; | |
2682 | if ((row.f_di_ph != 5.7) && ((row.f_acid_to_ph_57 < - 0.1) || (row.f_acid_to_ph_57 > 0.1))) { | |
2683 | C1 = row.f_acid_to_ph_57 / (row.f_di_ph - 5.7); | |
2684 | } else { | |
2685 | // If the acid_to_ph_5.7 is unknown from the maltster, guess the required acid. | |
2686 | ebc = row.f_color; | |
2687 | switch (row.f_graintype) { | |
2688 | case 0: // Base, Special, Kilned | |
2689 | case 3: | |
2690 | case 5: C1 = 0.014 * ebc - 34.192; | |
2691 | break; | |
2692 | case 2: C1 = -0.0597 * ebc - 32.457; // Crystal | |
2693 | break; | |
2694 | case 1: C1 = 0.0107 * ebc - 54.768; // Roast | |
2695 | break; | |
2696 | case 4: C1 = -149; // Sour malt | |
2697 | break; | |
2698 | } | |
2699 | } | |
2700 | x = C1 * (pHZ - row.f_di_ph); // AcidRequired(ZpH) | |
2701 | Result += x * row.f_amount; | |
2702 | } | |
2703 | } | |
2704 | return Result; | |
2705 | } | |
2706 | ||
2707 | function MashpH() { | |
2708 | var n = 0, pH = 5.4, deltapH = 0.001, deltapd = 0.1, pd = ProtonDeficit(pH); | |
2709 | while (((pd < -deltapd) || (pd > deltapd)) && (n < 2000)) { | |
2710 | n++; | |
2711 | if (pd < -deltapd) | |
2712 | pH -= deltapH; | |
2713 | else if (pd > deltapd) | |
2714 | pH += deltapH; | |
2715 | pd = ProtonDeficit(pH); | |
2716 | } | |
495
fdbb6bfae569
Disabled some console.log items.
Michiel Broek <mbroek@mbse.eu>
parents:
490
diff
changeset
|
2717 | pH = Round(pH, 2); |
fdbb6bfae569
Disabled some console.log items.
Michiel Broek <mbroek@mbse.eu>
parents:
490
diff
changeset
|
2718 | //console.log('MashpH() n: ' + n + ' pH: ' + pH); |
478 | 2719 | return pH; |
2720 | } | |
2721 | ||
2722 | function GetAcidSpecs(AT) { | |
2723 | switch (AT) { | |
2724 | case 0: // Melkzuur | |
2725 | return { pK1: 3.86, pK2: 20, pK3: 20, MolWt: 90.08, AcidSG: 1214, AcidPrc: 0.88 }; | |
2726 | case 1: // Zoutzuur | |
2727 | return { pK1: -7, pK2: 20, pK3: 20, MolWt: 36.46, AcidSG: 1142, AcidPrc: 0.28 }; | |
2728 | case 2: // Fosforzuur | |
2729 | return { pK1: 2.12, pK2: 7.20, pK3: 12.44, MolWt: 98.00, AcidSG: 1170, AcidPrc: 0.25 }; | |
2730 | case 3: // Zwavelzuur | |
2731 | return { pK1: -1, pK2: 1.92, pK3: 20, MolWt: 98.07, AcidSG: 1700, AcidPrc: 0.93 }; | |
2732 | } | |
2733 | } | |
2734 | ||
2735 | function calcWater() { | |
2736 | ||
495
fdbb6bfae569
Disabled some console.log items.
Michiel Broek <mbroek@mbse.eu>
parents:
490
diff
changeset
|
2737 | //console.log('calcWater()'); |
478 | 2738 | var liters = 0, |
2739 | calcium = 0, | |
2740 | magnesium = 0, | |
2741 | sodium = 0, | |
2742 | total_alkalinity = 0, | |
2743 | bicarbonate = 0, | |
2744 | chloride = 0, | |
2745 | sulfate = 0, | |
2746 | ph = 0, | |
2747 | RA = 0, | |
2748 | frac = 0, | |
2749 | TpH = 0, | |
2750 | protonDeficit = 0, | |
2751 | AT, BT, result, pK1, pK2, pK3, MolWt, AcidSG, AcidPrc, | |
2752 | r1d, r2d, f1d, f2d, f3d, | |
2753 | deltapH, deltapd, pd, n, | |
2754 | piCLSO4_low, piCLSO4_high, Res, | |
2755 | wg_calcium, wg_sodium, wg_total_alkalinity, wg_chloride, wg_sulfate, wg_bicarbonate; | |
2756 | ||
2757 | if (dataRecord.w1_name == '') { | |
2758 | return; | |
2759 | } | |
2760 | ||
2761 | // If there is a dillute water source, mix the waters. | |
2762 | if (dataRecord.w2_name != '') { | |
2763 | liters = dataRecord.w1_amount + dataRecord.w2_amount; | |
2764 | calcium = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_calcium, dataRecord.w2_calcium); | |
2765 | magnesium = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_magnesium, dataRecord.w2_magnesium); | |
2766 | sodium = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_sodium, dataRecord.w2_sodium); | |
2767 | chloride = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_chloride, dataRecord.w2_chloride); | |
2768 | sulfate = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_sulfate, dataRecord.w2_sulfate); | |
2769 | total_alkalinity = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_total_alkalinity, dataRecord.w2_total_alkalinity); | |
2770 | ph = -Math.log10(((Math.pow(10, -dataRecord.w1_ph) * dataRecord.w1_amount) + (Math.pow(10, -dataRecord.w2_ph) * dataRecord.w2_amount)) / liters); | |
2771 | } else { | |
2772 | liters = dataRecord.w1_amount; | |
2773 | calcium = dataRecord.w1_calcium; | |
2774 | magnesium = dataRecord.w1_magnesium; | |
2775 | sodium = dataRecord.w1_sodium; | |
2776 | chloride = dataRecord.w1_chloride; | |
2777 | sulfate = dataRecord.w1_sulfate; | |
2778 | total_alkalinity = dataRecord.w1_total_alkalinity; | |
2779 | ph = dataRecord.w1_ph; | |
2780 | } | |
2781 | $('#wg_amount').val(liters); | |
2782 | wg_calcium = calcium; | |
2783 | $('#wg_calcium').val(Math.round(calcium * 10) / 10); | |
2784 | //var wg_magnesium = magnesium; | |
2785 | $('#wg_magnesium').val(Math.round(magnesium * 10) / 10); | |
2786 | wg_sodium = sodium; | |
2787 | $('#wg_sodium').val(Math.round(sodium * 10) / 10); | |
2788 | wg_total_alkalinity = total_alkalinity; | |
2789 | $('#wg_total_alkalinity').val(Math.round(total_alkalinity * 10) / 10); | |
2790 | wg_chloride = chloride; | |
2791 | $('#wg_chloride').val(Math.round(chloride * 10) / 10); | |
2792 | wg_sulfate = sulfate; | |
2793 | $('#wg_sulfate').val(Math.round(sulfate * 10) / 10); | |
2794 | // Note: brouwhulp has the malts included here in the result. | |
2795 | //var wg_ph = ph; | |
2796 | $('#wg_ph').val(Round(ph, 1)); | |
2797 | $('#wb_ph').val(Round(MashpH(), 1)); | |
2798 | $('#est_mash_ph').val(Round(MashpH(), 1)); | |
2799 | bicarbonate = total_alkalinity * 1.22; | |
2800 | wg_bicarbonate = bicarbonate; | |
2801 | ||
2802 | // Noot: de volgende berekeningen geven bijna gelijke resultaten in Brun'water. | |
2803 | // Calculate Ca | |
2804 | RA = parseFloat($('#wa_cacl2').jqxNumberInput('decimal')) * MMCa / MMCaCl2 + | |
2805 | parseFloat($('#wa_caso4').jqxNumberInput('decimal')) * MMCa / MMCaSO4; | |
2806 | calcium += 1000 * RA / liters; | |
2807 | ||
2808 | // Calculate Mg | |
2809 | RA = parseFloat($('#wa_mgso4').jqxNumberInput('decimal')) * MMMg / MMMgSO4; | |
2810 | magnesium += 1000 * RA / liters; | |
2811 | ||
2812 | // Calculate Na | |
2813 | RA = parseFloat($('#wa_nacl').jqxNumberInput('decimal')) * MMNa / MMNaCl + | |
2814 | parseFloat($('#wa_base').jqxNumberInput('decimal')) * MMNa / MMNaHCO3; | |
2815 | sodium += 1000 * RA / liters; | |
2816 | ||
2817 | // Calculate SO4 | |
2818 | RA = parseFloat($('#wa_caso4').jqxNumberInput('decimal')) * MMSO4 / MMCaSO4 + | |
2819 | parseFloat($('#wa_mgso4').jqxNumberInput('decimal')) * MMSO4 / MMMgSO4; | |
2820 | sulfate += 1000 * RA / liters; | |
2821 | ||
2822 | // Calculate Cl | |
2823 | RA = 2 * parseFloat($('#wa_cacl2').jqxNumberInput('decimal')) * MMCl / MMCaCl2 + | |
2824 | parseFloat($('#wa_nacl').jqxNumberInput('decimal')) * MMCl / MMNaCl; | |
2825 | chloride += 1000 * RA / liters; | |
2826 | // Einde noot. | |
2827 | ||
2828 | if ($('#wa_acid_name').val() < 0 || $('#wa_acid_name').val() > 3) { | |
2829 | $('#wa_acid_name').val(0); | |
2830 | dataRecord.wa_acid_name = 0; | |
2831 | } | |
2832 | if (last_acid == '') | |
2833 | last_acid = AcidTypeData[$('#wa_acid_name').val()].nl; | |
2834 | ||
2835 | if ($('#wa_base_name').val() < 0 || $('#wa_base_name').val() > 3) { | |
2836 | $('#wa_base_name').val(0); | |
2837 | dataRecord.wa_base_name = 0; | |
2838 | } | |
2839 | if (last_base == '') | |
2840 | last_base = BaseTypeData[$('#wa_base_name').val()].nl; | |
2841 | ||
2842 | AT = dataRecord.wa_acid_name; | |
2843 | BT = dataRecord.wa_base_name; | |
2844 | ||
2845 | result = GetAcidSpecs(AT); | |
2846 | pK1 = result.pK1; | |
2847 | pK2 = result.pK2; | |
2848 | pK3 = result.pK3; | |
2849 | MolWt = result.MolWt; | |
2850 | AcidSG = result.AcidSG; | |
2851 | AcidPrc = result.AcidPrc; | |
2852 | ||
2853 | if (dataRecord.calc_acid) { | |
2854 | TpH = parseFloat(dataRecord.mash_ph); | |
2855 | protonDeficit = ProtonDeficit(TpH); | |
495
fdbb6bfae569
Disabled some console.log items.
Michiel Broek <mbroek@mbse.eu>
parents:
490
diff
changeset
|
2856 | //console.log('calc_acid tgt: ' + TpH + ' protonDeficit: ' + protonDeficit); |
478 | 2857 | if (protonDeficit > 0) { // Add acid |
2858 | $('#wa_base').val(0); | |
2859 | setWaterAgent(last_base, 0); | |
2860 | frac = CalcFrac(TpH, pK1, pK2, pK3); | |
2861 | Acid = protonDeficit / frac; | |
2862 | Acid *= MolWt; // mg | |
2863 | Acidmg = Acid; | |
2864 | Acid = Acid / AcidSG; // ml | |
2865 | ||
2866 | if (parseFloat($('#wa_acid_perc').jqxNumberInput('decimal')) == 0) | |
2867 | $('#wa_acid_perc').val(AcidPrc); | |
495
fdbb6bfae569
Disabled some console.log items.
Michiel Broek <mbroek@mbse.eu>
parents:
490
diff
changeset
|
2868 | Acid = Round(Acid * AcidPrc / (parseFloat($('#wa_acid_perc').jqxNumberInput('decimal')) / 100), 2); // ml |
fdbb6bfae569
Disabled some console.log items.
Michiel Broek <mbroek@mbse.eu>
parents:
490
diff
changeset
|
2869 | //console.log('Final ml: ' + Acid); |
fdbb6bfae569
Disabled some console.log items.
Michiel Broek <mbroek@mbse.eu>
parents:
490
diff
changeset
|
2870 | $('#wa_acid').val(Acid); |
fdbb6bfae569
Disabled some console.log items.
Michiel Broek <mbroek@mbse.eu>
parents:
490
diff
changeset
|
2871 | setWaterAgent(AcidTypeData[AT].nl, Acid); |
478 | 2872 | |
2873 | bicarbonate = bicarbonate - protonDeficit * frac / liters; | |
2874 | total_alkalinity = bicarbonate * 50 / 61; | |
2875 | } else if (protonDeficit < 0) { //Add base | |
2876 | $('#wa_acid').val(0); | |
2877 | setWaterAgent(last_acid, 0); | |
2878 | r1d = Math.pow(10, (TpH - 6.38)); | |
2879 | r2d = Math.pow(10, (TpH - 10.38)); | |
2880 | f1d = 1 / (1 + r1d + r1d * r2d); | |
2881 | f2d = f1d * r1d; | |
2882 | f3d = f2d * r2d; | |
2883 | switch (BT) { | |
2884 | case 0: | |
2885 | RA = -protonDeficit / (f1d - f3d); // Sodiumbicarbonate, mmol totaal | |
2886 | RA = RA * MMNaHCO3 / 1000; //gram | |
2887 | $('#wa_base').val(Round(RA, 2)); | |
2888 | setWaterAgent('NaHCO3', Round(RA, 2)); | |
2889 | if (liters > 0) { | |
2890 | // Na | |
2891 | RA = parseFloat($('#wa_nacl').jqxNumberInput('decimal')) * MMNa / MMNaCl + | |
2892 | parseFloat($('#wa_base').jqxNumberInput('decimal')) * MMNa / MMNaHCO3; | |
2893 | RA = 1000 * RA / liters; | |
2894 | sodium = wg_sodium + RA; | |
2895 | // HCO3 | |
2896 | RA = parseFloat($('#wa_base').jqxNumberInput('decimal')) * MMHCO3 / MMNaHCO3; | |
2897 | RA = 1000 * RA / liters; | |
2898 | bicarbonate = wg_bicarbonate + RA; | |
2899 | total_alkalinity = bicarbonate * 50 / 61; | |
2900 | RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); | |
2901 | } | |
2902 | break; | |
2903 | case 1: | |
2904 | RA = -protonDeficit / (2 * f1d + f2d); // Sodiumcarbonate, mmol totaal | |
2905 | RA = RA * MMNa2CO3 / 1000; //gram | |
2906 | $('#wa_base').val(Round(RA, 2)); | |
2907 | setWaterAgent('Na2CO3', Round(RA, 2)); | |
2908 | if (liters > 0) { | |
2909 | RA = parseFloat($('#wa_nacl').jqxNumberInput('decimal')) * MMNa / MMNaCl + | |
2910 | parseFloat($('#wa_base').jqxNumberInput('decimal')) * 2 * MMNa / MMNa2CO3; | |
2911 | RA = 1000 * RA / liters; | |
2912 | sodium = wg_sodium + RA; | |
2913 | // HCO3 | |
2914 | RA = parseFloat($('#wa_base').jqxNumberInput('decimal')) * MMHCO3 / MMNa2CO3; | |
2915 | RA = 1000 * RA / liters; | |
2916 | bicarbonate = wg_bicarbonate + RA; | |
2917 | total_alkalinity = bicarbonate * 50 / 61; | |
2918 | RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); | |
2919 | } | |
2920 | break; | |
2921 | case 2: | |
2922 | RA = -protonDeficit * (f1d - f3d); // Calciumcarbonate, mmol totaal | |
2923 | RA = RA * MMCaCO3 / 1000; //gram | |
2924 | //but only 1/3 is effective, so add 3 times as much | |
2925 | RA = 3 * RA; | |
2926 | $('#wa_base').val(Round(RA, 2)); | |
2927 | setWaterAgent('CaCO3', Round(RA, 2)); | |
2928 | if (liters > 0) { | |
2929 | //Bicarbonate | |
2930 | RA = parseFloat($('#wa_base').jqxNumberInput('decimal')) / 3 * MMHCO3 / MMCaCO3; | |
2931 | RA = 1000 * RA / liters; | |
2932 | bicarbonate = wg_bicarbonate + RA; | |
2933 | total_alkalinity = bicarbonate * 50 / 61; | |
2934 | //Ca precipitates out as Ca10(PO4)6(OH)2 | |
2935 | RA = parseFloat($('#wa_cacl2').jqxNumberInput('decimal')) * MMCa / MMCaCl2 + | |
2936 | parseFloat($('#wa_caso4').jqxNumberInput('decimal')) * MMCa / MMCaSO4 + | |
2937 | parseFloat($('#wa_base').jqxNumberInput('decimal')) * MMCa / MMCaCO3; | |
2938 | RA = 1000 * RA / liters; | |
2939 | calcium = wg_calcium + RA; | |
2940 | RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); | |
2941 | } | |
2942 | break; | |
2943 | case 3: | |
2944 | RA = -protonDeficit / 19.3; // Calciumhydroxide | |
2945 | $('#wa_base').val(Round(RA, 2)); | |
2946 | setWaterAgent('Ca(OH)2', Round(RA, 2)); | |
2947 | if (liters > 0) { | |
2948 | // Bicarbonate | |
2949 | RA = -protonDeficit / liters; | |
2950 | total_alkalinity = wg_total_alkalinity + RA; | |
2951 | bicarbonate = total_alkalinity * 61 / 50; | |
2952 | // Calcium | |
2953 | RA = parseFloat($('#wa_cacl2').jqxNumberInput('decimal')) * MMCa / MMCaCl2 + | |
2954 | parseFloat($('#wa_caso4').jqxNumberInput('decimal')) * MMCa / MMCaSO4 + | |
2955 | parseFloat($('#wa_base').jqxNumberInput('decimal')) * MMCa / MMCaOH2; | |
2956 | RA = 1000 * RA / liters; | |
2957 | calcium = wg_calcium + RA; | |
2958 | RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); | |
2959 | } | |
2960 | break; | |
2961 | } | |
2962 | } | |
2963 | ph = TpH; | |
2964 | $('#wb_ph').val(Round(ph, 1)); | |
2965 | $('#est_mash_ph').val(Round(ph, 1)); | |
2966 | } else { // Manual | |
2967 | console.log('calc_acid no'); | |
2968 | // First add base salts | |
2969 | if (parseFloat($('#wa_base').jqxNumberInput('decimal')) > 0) { | |
2970 | if (liters > 0) { | |
2971 | switch (BT) { | |
2972 | case 0: // Sodiumbicarbonate, Na | |
2973 | RA = parseFloat($('#wa_nacl').jqxNumberInput('decimal')) * MMNa / MMNaCl + | |
2974 | parseFloat($('#wa_base').jqxNumberInput('decimal')) * MMNa / MMNaHCO3; | |
2975 | RA = 1000 * RA / liters; | |
2976 | sodium = wg_sodium + RA; | |
2977 | // HCO3 | |
2978 | RA = parseFloat($('#wa_base').jqxNumberInput('decimal')) * MMHCO3 / MMNaHCO3; | |
2979 | RA = 1000 * RA / liters; | |
2980 | bicarbonate = wg_bicarbonate + RA; | |
2981 | total_alkalinity = bicarbonate * 50 / 61; | |
2982 | RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); | |
2983 | break; | |
2984 | case 1: // Sodiumcarbonate | |
2985 | RA = parseFloat($('#wa_nacl').jqxNumberInput('decimal')) * MMNa / MMNaCl + | |
2986 | parseFloat($('#wa_base').jqxNumberInput('decimal')) * 2 * MMNa / MMNa2CO3; | |
2987 | RA = 1000 * RA / liters; | |
2988 | sodium = wg_sodium + RA; | |
2989 | // HCO3 | |
2990 | RA = parseFloat($('#wa_base').jqxNumberInput('decimal')) * MMHCO3 / MMNa2CO3; | |
2991 | RA = 1000 * RA / liters; | |
2992 | bicarbonate = wg_bicarbonate + RA; | |
2993 | total_alkalinity = bicarbonate * 50 / 61; | |
2994 | RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); | |
2995 | break; | |
2996 | case 2: // Calciumcarbonate: Bicarbonate | |
2997 | RA = parseFloat($('#wa_base').jqxNumberInput('decimal')) / 3 * MMHCO3 / MMCaCO3; | |
2998 | RA = 1000 * RA / liters; | |
2999 | bicarbonate = wg_bicarbonate + RA; | |
3000 | total_alkalinity = bicarbonate * 50 / 61; | |
3001 | RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); | |
3002 | // Ca | |
3003 | RA = parseFloat($('#wa_cacl2').jqxNumberInput('decimal')) * MMCa / MMCaCl2 + | |
3004 | parseFloat($('#wa_caso4').jqxNumberInput('decimal')) * MMCa / MMCaSO4 + | |
3005 | parseFloat($('#wa_base').jqxNumberInput('decimal')) * MMCa / MMCaCO3; | |
3006 | RA = 1000 * RA / liters; | |
3007 | calcium = wg_calcium + RA; | |
3008 | break; | |
3009 | } | |
3010 | } | |
3011 | } | |
3012 | ||
3013 | TpH = parseFloat(dataRecord.mash_ph); | |
3014 | pHa = MashpH(); // This one is in demi water, should be in adjusted water??? | |
3015 | // Then calculate the new pH with added acids | |
3016 | if (parseFloat($('#wa_acid').jqxNumberInput('decimal')) > 0) { | |
3017 | console.log('TpH: ' + TpH + ' water: ' + pHa); | |
3018 | Acid = parseFloat($('#wa_acid').jqxNumberInput('decimal')); | |
3019 | if (parseFloat($('#wa_acid_perc').jqxNumberInput('decimal')) == 0) | |
3020 | $('#wa_acid_perc').val(AcidPrc); | |
3021 | Acid = Acid / AcidPrc * (parseFloat($('#wa_acid_perc').jqxNumberInput('decimal')) / 100); // ml | |
3022 | Acid *= AcidSG; // ml | |
3023 | Acid /= MolWt; // mg | |
3024 | Acidmg = Acid; | |
3025 | ||
3026 | //find the pH where the protondeficit = protondeficit by the acid | |
3027 | frac = CalcFrac(pHa, pK1, pK2, pK3); | |
3028 | protonDeficit = Acid * frac; | |
3029 | ||
3030 | deltapH = 0.001; | |
3031 | deltapd = 0.1; | |
3032 | pd = ProtonDeficit(pHa); | |
3033 | n = 0; | |
3034 | while (((pd < (protonDeficit - deltapd)) || (pd > (protonDeficit + deltapd))) && (n < 2000)) { | |
3035 | n++; | |
3036 | if (pd < (protonDeficit - deltapd)) | |
3037 | pHa -= deltapH; | |
3038 | else if (pd > (protonDeficit + deltapd)) | |
3039 | pHa += deltapH; | |
3040 | frac = CalcFrac(pHa, pK1, pK2, pK3); | |
3041 | protonDeficit = Acid * frac; | |
3042 | pd = ProtonDeficit(pHa); | |
3043 | } | |
3044 | console.log('n: ' + n + ' pd: ' + pd + ' protonDeficit: ' + protonDeficit + ' frac: ' + frac + ' pHa: ' + pHa); | |
3045 | RA = wg_bicarbonate - protonDeficit * frac / liters; | |
3046 | bicarbonate = RA; | |
3047 | total_alkalinity = RA * 50 / 61; | |
3048 | ph = pHa; | |
3049 | $('#wb_ph').val(Round(ph, 1)); | |
3050 | $('#est_mash_ph').val(Round(ph, 1)); | |
3051 | } | |
3052 | } | |
3053 | ||
3054 | if ((AT == 3) && (liters > 0)) { // Sulfuctic / Zwavelzuur | |
3055 | RA = parseFloat($('#wa_caso4').jqxNumberInput('decimal')) * MMSO4 / MMCaSO4 + | |
3056 | parseFloat($('#wa_mgso4').jqxNumberInput('decimal')) * MMSO4 / MMMgSO4 + | |
3057 | Acidmg / 1000 * MMSO4 / (MMSO4 + 2); | |
3058 | RA = 1000 * RA / liters; | |
3059 | sulfate = wg_sulfate + RA; // Not add to sulfate?? | |
3060 | } else if ((AT == 1) && (liters > 0)) { // Hydrochloric, Zoutzuur | |
3061 | RA = parseFloat($('#wa_cacl2').jqxNumberInput('decimal')) * MMCl / MMCaCl2 + | |
3062 | parseFloat($('#wa_nacl').jqxNumberInput('decimal')) * MMCl / MMNaCl + | |
3063 | Acidmg / 1000 * MMCl / (MMCl + 1); | |
3064 | RA = 1000 * RA / liters; | |
3065 | chloride = wg_chloride + RA; | |
3066 | } | |
3067 | ||
3068 | // 2:1 Sulfate to Chroride IPA's, Pale Ales. | |
3069 | // 1:1 Sulfate to Chloride Balanced | |
3070 | // 1:2 Sulfate to Chloride Malty | |
3071 | // Note, values below are the other way, cl to so4! | |
3072 | // So: 0.5 is IPA's, Pale Ales. | |
3073 | // 1 Balanced | |
3074 | // 2 Malty. | |
3075 | $('#tgt_bu').val(Round(GetBUGU(), 2)); | |
3076 | // From brouwhulp. | |
3077 | if (GetBUGU() < 0.32) | |
3078 | $('#wr_bu').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Zeer moutig en zoet</span>"); | |
3079 | else if (GetBUGU() < 0.43) | |
3080 | $('#wr_bu').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Moutig, zoet</span>"); | |
3081 | else if (GetBUGU() < 0.52) | |
3082 | $('#wr_bu').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Evenwichtig</span>"); | |
3083 | else if (GetBUGU() < 0.63) | |
3084 | $('#wr_bu').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Licht hoppig, bitter</span>"); | |
3085 | else | |
3086 | $('#wr_bu').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Extra hoppig, zeer bitter</span>"); | |
3087 | $('#tgt_cl_so4').val(Round(GetOptClSO4ratio(), 1)); | |
3088 | if (sulfate > 0) | |
3089 | RA = chloride / sulfate; | |
3090 | else | |
3091 | RA = 10; | |
3092 | $('#got_cl_so4').val(Round(RA, 1)); | |
3093 | piCLSO4_low = 0.8 * GetOptClSO4ratio(); | |
3094 | piCLSO4_high = 1.2 * GetOptClSO4ratio(); | |
3095 | Res = 'normaal'; | |
3096 | if (RA < piCLSO4_low) | |
3097 | Res = 'laag'; | |
3098 | else if (RA > piCLSO4_high) | |
3099 | Res = 'hoog'; | |
3100 | setRangeIndicator('cl_so4', Res); | |
3101 | ||
3102 | $('#wb_calcium').val(Round(calcium, 1)); | |
3103 | $('#wb_magnesium').val(Round(magnesium, 1)); | |
3104 | $('#wb_sodium').val(Round(sodium, 1)); | |
3105 | $('#wb_sulfate').val(Round(sulfate, 1)); | |
3106 | $('#wb_chloride').val(Round(chloride, 1)); | |
3107 | $('#wb_total_alkalinity').val(Round(total_alkalinity, 1)); | |
3108 | ||
3109 | if (calcium < 40) { | |
3110 | setRangeIndicator('calcium', 'laag'); | |
3111 | } else if (calcium > 150) { | |
3112 | setRangeIndicator('calcium', 'hoog'); | |
3113 | } else { | |
3114 | setRangeIndicator('calcium', 'normaal'); | |
3115 | } | |
3116 | if (magnesium >= 0 && magnesium <= 30) { | |
3117 | setRangeIndicator('magnesium', 'normaal'); | |
3118 | } else { | |
3119 | setRangeIndicator('magnesium', 'hoog'); | |
3120 | } | |
3121 | if (sodium <= 150) { | |
3122 | setRangeIndicator('sodium', 'normaal'); | |
3123 | } else { | |
3124 | setRangeIndicator('sodium', 'hoog'); | |
3125 | } | |
3126 | // Both chloride and sulfate should be above 50 according to | |
3127 | // John Palmer. So the Cl/SO4 ratio calculation will work. | |
3128 | if (chloride <= 50) { | |
3129 | setRangeIndicator('chloride', 'laag'); | |
3130 | } else if (chloride <= 100) { | |
3131 | setRangeIndicator('chloride', 'normaal'); | |
3132 | } else { | |
3133 | setRangeIndicator('chloride', 'hoog'); | |
3134 | } | |
3135 | if (sulfate <= 50) { | |
3136 | setRangeIndicator('sulfate', 'laag'); | |
3137 | } else if (sulfate <= 350) { | |
3138 | setRangeIndicator('sulfate', 'normaal'); | |
3139 | } else { | |
3140 | setRangeIndicator('sulfate', 'hoog'); | |
3141 | } | |
3142 | if (ph < 5.2) { | |
3143 | setRangeIndicator('ph', 'laag'); | |
3144 | } else if (ph > 5.6) { | |
3145 | setRangeIndicator('ph', 'hoog'); | |
3146 | } else { | |
3147 | setRangeIndicator('ph', 'normaal'); | |
3148 | } | |
3149 | calcSparge(); | |
3150 | calcMiscs(); | |
3151 | calcSupplies(); | |
3152 | } | |
3153 | ||
3154 | function calcSparge() { | |
3155 | ||
3156 | var TargetpH, Source_pH, Source_alkalinity, r1, r2, d, f1, f3, r143, r243, d43, f143, f343, | |
3157 | alkalinity, Ct, r1g, r2g, dg, f1g, f3g, Acid, AT, result, pK1, pK2, pK3, MolWt, AcidSG, AcidPrc, fract; | |
3158 | ||
3159 | // Code from BrewBuddy/Brouwhulp, who got it from http://www.brewery.org/brewery/library/Acidi0,00fWaterAJD0497.html | |
3160 | TargetpH = dataRecord.sparge_ph; | |
3161 | Source_pH = dataRecord.w1_ph; | |
3162 | Source_alkalinity = dataRecord.w1_total_alkalinity; | |
3163 | // Select watersource or fallback to the first source. | |
3164 | if (dataRecord.sparge_source == 1) { // Source 2 | |
3165 | if (dataRecord.w2_ph > 0.0) { | |
3166 | Source_pH = dataRecord.w2_ph; | |
3167 | Source_alkalinity = dataRecord.w2_total_alkalinity; | |
3168 | } else { | |
3169 | dataRecord.sparge_source = 0; // Source 1 | |
3170 | $('#sparge_source').val(0); | |
3171 | } | |
3172 | } else if (dataRecord.sparge_source == 2) { // Mixed | |
3173 | if (dataRecord.w2_ph > 0.0) { | |
3174 | Source_pH = parseFloat($('#wg_ph').jqxNumberInput('decimal')); | |
3175 | Source_alkalinity = parseFloat($('#wg_total_alkalinity').jqxNumberInput('decimal')); | |
3176 | } else { | |
3177 | dataRecord.sparge_source = 0; | |
3178 | $('#sparge_source').val(0); | |
3179 | } | |
3180 | } | |
3181 | ||
3182 | // Step 1: Compute the mole fractions of carbonic (f1o), bicarbonate (f2o) and carbonate(f3o) at the water pH | |
3183 | r1 = Math.pow(10, Source_pH - 6.38); | |
3184 | r2 = Math.pow(10, Source_pH - 10.373); | |
3185 | d = 1 + r1 + r1 * r2; | |
3186 | f1 = 1 / d; | |
3187 | f3 = r1 * r2 / d; | |
3188 | ||
3189 | //Step 2. Compute the mole fractions at pH = 4.3 (the pH which defines alkalinity) | |
3190 | r143 = Math.pow(10, 4.3 - 6.38); | |
3191 | r243 = Math.pow(10, 4.3 - 10.373); | |
3192 | d43 = 1 + r143 + r143 * r243; | |
3193 | f143 = 1 / d43; | |
3194 | f343 = r143 * r243 / d43; | |
3195 | ||
3196 | //Step 3. Convert the water alkalinity to milliequivalents/L | |
3197 | alkalinity = Source_alkalinity / 50; | |
3198 | ||
3199 | //Step 4. Solve | |
3200 | Ct = (alkalinity - 1000 * (Math.pow(10, -4.3) - Math.pow(10, -Source_pH))) / ((f143 - f1) + (f3 - f343)); | |
3201 | ||
3202 | //Step 5. Compute mole fractions at desired pH | |
3203 | r1g = Math.pow(10, TargetpH - 6.38); | |
3204 | r2g = Math.pow(10, TargetpH - 10.373); | |
3205 | dg = 1 + r1g + r1g * r2g; | |
3206 | f1g = 1 / dg; | |
3207 | f3g = r1g * r2g / dg; | |
3208 | ||
3209 | //Step 6. Use these to compute the milliequivalents acid required per liter (mEq/L) | |
3210 | Acid = Ct * ((f1g - f1) + (f3 - f3g)) + Math.pow(10, -TargetpH) - Math.pow(10, -Source_pH); //mEq/l | |
3211 | Acid += 0.01; // Add acid that would be required for distilled water. | |
3212 | if (dataRecord.sparge_acid_type < 0 || dataRecord.sparge_acid_type > 3) { | |
3213 | dataRecord.sparge_acid_type = 0; | |
3214 | $('#sparge_acid_type').val(0); | |
3215 | } | |
3216 | ||
3217 | //Step 8. Get the acid data. | |
3218 | AT = dataRecord.sparge_acid_type; | |
3219 | result = GetAcidSpecs(AT); | |
3220 | pK1 = result.pK1; | |
3221 | pK2 = result.pK2; | |
3222 | pK3 = result.pK3; | |
3223 | MolWt = result.MolWt; | |
3224 | AcidSG = result.AcidSG; | |
3225 | AcidPrc = result.AcidPrc; | |
3226 | fract = CalcFrac(TargetpH, pK1, pK2, pK3); | |
3227 | ||
3228 | //Step 9. Now divide the mEq required by the "fraction". This is the required number of moles of acid. | |
3229 | Acid /= fract; | |
3230 | ||
3231 | //Step 10. Multiply by molecular weight of the acid | |
3232 | Acid *= MolWt; //mg | |
3233 | ||
3234 | Acid = Acid / AcidSG; //ml ; 88% lactic solution | |
3235 | f1 = dataRecord.sparge_acid_perc; | |
3236 | if (f1 <= 0.1) | |
3237 | f1 = AcidPrc; | |
3238 | Acid = Acid * AcidPrc / (f1 / 100); | |
3239 | ||
3240 | Acid *= dataRecord.sparge_volume; //ml lactic acid total | |
3241 | Acid = Round(Acid, 2); | |
3242 | dataRecord.sparge_acid_amount = Acid / 1000; | |
3243 | $('#sparge_acid_amount').val(Acid); | |
3244 | } | |
3245 | ||
3246 | function calcFermentation() { | |
3247 | var primary_svg, secondary_svg, final_svg, ABV; | |
3248 | if (dataRecord.brew_fermenter_sg < 1.020) | |
3249 | return; | |
3250 | if ((dataRecord.primary_end_sg > 0.990) && (dataRecord.primary_end_sg < dataRecord.brew_fermenter_sg)) { | |
3251 | primary_svg = Round(100 * (dataRecord.brew_fermenter_sg - dataRecord.primary_end_sg) / (dataRecord.brew_fermenter_sg - 1), 1); | |
3252 | $('#primary_svg').val(primary_svg); | |
3253 | if ((dataRecord.secondary_end_sg > 0.990) && (dataRecord.secondary_end_sg < dataRecord.brew_fermenter_sg)) { | |
3254 | secondary_svg = Round(100 * (dataRecord.brew_fermenter_sg - dataRecord.secondary_end_sg) / (dataRecord.brew_fermenter_sg - 1), 1); | |
3255 | $('#secondary_svg').val(secondary_svg); | |
3256 | if ((dataRecord.fg > 0.990) && (dataRecord.fg < dataRecord.brew_fermenter_sg)) { | |
3257 | final_svg = Round(100 * (dataRecord.brew_fermenter_sg - dataRecord.fg) / (dataRecord.brew_fermenter_sg - 1), 1); | |
3258 | $('#final_svg').val(final_svg); | |
3259 | ABV = Round(abvol(dataRecord.brew_fermenter_sg, dataRecord.fg), 2); | |
3260 | $('#final_abv').val(ABV); | |
3261 | } | |
3262 | } | |
3263 | } | |
3264 | } | |
3265 | ||
3266 | function ResCO2(CO2, T) { | |
3267 | var F = T * 1.8 + 32; | |
3268 | return 3.0378 - 0.050062 * F + 0.00026555 * F * F; | |
3269 | } | |
3270 | ||
3271 | function CarbCO2toS(CO2, T, SFactor) { | |
3272 | var sugar = SFactor * (CO2 - ResCO2(CO2, T)) / 0.286; | |
3273 | if (sugar < 0) | |
3274 | sugar = 0; | |
3275 | return Round(sugar, 3); | |
3276 | } | |
3277 | ||
3278 | function GetPressure(CO2, T1, T2) { | |
3279 | var P, V = CO2 - ResCO2(CO2, T1); | |
3280 | if (V < 0) | |
3281 | return 0; | |
3282 | P = -1.09145427669121 + 0.00800006989646477 * T2 + 0.000260276315484684 * T2 * T2 + 0.0215142075945119 * T2 * V + | |
3283 | 0.674996600795854 * V + -0.00471757220150754 * V * V; | |
3284 | //console.log("CO2: "+CO2+" "+V+" Temp: "+T1+" "+T2+" Pressure: "+P); | |
3285 | if (P < 0) | |
3286 | P = 0; | |
3287 | P = P * 1.01325; // atm to bar | |
3288 | return Round(P, 1); | |
3289 | } | |
3290 | ||
3291 | function CarbCO2ToPressure(CO2, T) { | |
3292 | return (CO2 - (-0.000005594056 * Math.pow(T, 4) + 0.000144357886 * Math.pow(T, 3) + | |
3293 | 0.000362999168 * T * T - 0.064872987645 * T + 1.641145175049)) / | |
3294 | (0.00000498031 * Math.pow(T, 4) - 0.00024358267 * Math.pow(T, 3) + 0.00385867329 * T * T - 0.05671206825 * T + 1.53801423376); | |
3295 | } | |
3296 | ||
3297 | function calcCarbonation() { | |
3298 | ||
3299 | var TSec, ABV, bvol, balc, babv, mvol, malc, tvol, talc, i, row, SFactor, pvol, pabv, Pressure, kabv; | |
3300 | ||
3301 | TSec = dataRecord.secondary_temp; | |
3302 | if (TSec < 1) | |
3303 | TSec = dataRecord.primary_end_temp; | |
3304 | if (TSec < 1) | |
3305 | TSec = 18; | |
3306 | ||
3307 | if (dataRecord.fg == 0.000) | |
3308 | ABV = abvol(dataRecord.brew_fermenter_sg, parseFloat($('#est_fg').jqxNumberInput('decimal'))); | |
3309 | else | |
3310 | ABV = abvol(dataRecord.brew_fermenter_sg, dataRecord.fg); | |
3311 | ||
3312 | /* Calculate new volume and alcohol. */ | |
3313 | bvol = dataRecord.package_volume - (ABV * dataRecord.package_volume) / 100; | |
3314 | balc = dataRecord.package_volume - bvol; | |
3315 | mvol = dataRecord.package_infuse_amount - (dataRecord.package_infuse_abv * dataRecord.package_infuse_amount) / 100; | |
3316 | malc = dataRecord.package_infuse_amount - mvol; | |
3317 | talc = balc + malc; | |
3318 | tvol = bvol + mvol; | |
3319 | ABV = Round(talc / (tvol + talc) * 100, 2); | |
3320 | dataRecord.package_abv = ABV; | |
3321 | $('#package_abv').val(ABV); | |
3322 | ||
3323 | //console.log("calcCarbonation() TSec:"+TSec+" ABV:"+ABV); | |
3324 | if (!(rows = $('#fermentableGrid').jqxGrid('getrows'))) { | |
3325 | return; | |
3326 | } | |
3327 | ||
3328 | // Bottles | |
3329 | dataRecord.bottle_priming_amount = 0; | |
3330 | dataRecord.bottle_priming_total = 0; | |
3331 | for (i = 0; i < rows.length; i++) { | |
3332 | row = rows[i]; | |
3333 | if (row.f_added == 4) { | |
3334 | SFactor = 1 / ((row.f_yield / 100) * (1 - row.f_moisture / 100)); | |
3335 | dataRecord.bottle_priming_amount = CarbCO2toS(dataRecord.bottle_carbonation, TSec, SFactor); | |
3336 | dataRecord.bottle_priming_total = Round(dataRecord.bottle_amount * dataRecord.bottle_priming_amount, 2); | |
3337 | $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_amount', dataRecord.bottle_priming_total / 1000); | |
3338 | } | |
3339 | } | |
3340 | $('#bottle_priming_amount').val(Round(dataRecord.bottle_priming_amount, 1)); | |
3341 | $('#bottle_priming_total').val(dataRecord.bottle_priming_total); | |
3342 | pabv = ABV + dataRecord.bottle_priming_amount * 0.47 / 7.907; | |
3343 | pvol = dataRecord.bottle_amount - (pabv * dataRecord.bottle_amount) / 100; | |
3344 | talc = dataRecord.bottle_amount - pvol; | |
3345 | tvol = pvol + dataRecord.bottle_priming_water; | |
3346 | babv = Round(talc / (tvol + talc) * 100, 2); | |
3347 | //console.log("bottle pabv:"+pabv+" pvol:"+pvol+" wvol:"+dataRecord.bottle_priming_water+" tvol:"+tvol+" talc:"+talc+" abv:"+babv); | |
3348 | $('#bottle_abv').val(babv); | |
3349 | $('#bottle_pressure').val(GetPressure(dataRecord.bottle_carbonation, TSec, dataRecord.bottle_carbonation_temp)); | |
3350 | ||
3351 | // Kegs | |
3352 | Pressure = CarbCO2ToPressure(dataRecord.keg_carbonation, dataRecord.keg_carbonation_temp); | |
3353 | if (Pressure < 0) | |
3354 | Pressure = 0; | |
3355 | dataRecord.keg_pressure = Pressure; | |
3356 | $('#keg_pressure').val(Round(Pressure, 1)); | |
3357 | ||
3358 | dataRecord.keg_priming_amount = 0; | |
3359 | dataRecord.keg_priming_total = 0; | |
3360 | if (!dataRecord.keg_forced_carb) { | |
469
3d532097860d
Code optimisation for compressed javascript in the product editor
Michiel Broek <mbroek@mbse.eu>
parents:
464
diff
changeset
|
3361 | for (i = 0; i < rows.length; i++) { |
3d532097860d
Code optimisation for compressed javascript in the product editor
Michiel Broek <mbroek@mbse.eu>
parents:
464
diff
changeset
|
3362 | row = rows[i]; |
478 | 3363 | if (row.f_added == 5) { |
3364 | SFactor = 1 / ((row.f_yield / 100) * (1 - row.f_moisture / 100)); | |
3365 | dataRecord.keg_priming_amount = CarbCO2toS(dataRecord.keg_carbonation, TSec, SFactor); | |
3366 | dataRecord.keg_priming_total = Round(dataRecord.keg_amount * dataRecord.keg_priming_amount, 2); | |
3367 | $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_amount', dataRecord.keg_priming_total / 1000); | |
469
3d532097860d
Code optimisation for compressed javascript in the product editor
Michiel Broek <mbroek@mbse.eu>
parents:
464
diff
changeset
|
3368 | } |
3d532097860d
Code optimisation for compressed javascript in the product editor
Michiel Broek <mbroek@mbse.eu>
parents:
464
diff
changeset
|
3369 | } |
478 | 3370 | $('#keg_priming_amount').val(Round(dataRecord.keg_priming_amount, 1)); |
3371 | $('#keg_priming_total').val(dataRecord.keg_priming_total); | |
3372 | pabv = ABV + dataRecord.keg_priming_amount * 0.47 / 7.907; | |
3373 | pvol = dataRecord.keg_amount - (pabv * dataRecord.keg_amount) / 100; | |
3374 | talc = dataRecord.keg_amount - pvol; | |
3375 | tvol = pvol + dataRecord.keg_priming_water; | |
3376 | kabv = Round(talc / (tvol + talc) * 100, 2); | |
469
3d532097860d
Code optimisation for compressed javascript in the product editor
Michiel Broek <mbroek@mbse.eu>
parents:
464
diff
changeset
|
3377 | //console.log("kegs pabv:"+pabv+" pvol:"+pvol+" wvol:"+dataRecord.keg_priming_water+" tvol:"+tvol+" talc:"+talc+" abv:"+kabv); |
478 | 3378 | $('#keg_abv').val(kabv); |
3379 | } else { | |
3380 | $('#keg_priming_amount').val(0); | |
3381 | $('#keg_priming_total').val(0); | |
3382 | $('#keg_abv').val(ABV); | |
3383 | } | |
3384 | } | |
3385 | ||
3386 | function calcStage() { | |
3387 | ||
3388 | var newstage = dataRecord.stage, d, date1, date2, date1_unixtime, date2_unixtime, timeDifference, timeDifferenceInDays; | |
3389 | ||
3390 | if (newstage == 0 && dataRecord.est_og > 1.005 && dataRecord.est_color > 3 && dataRecord.est_ibu > 3) | |
3391 | newstage = 1; | |
3392 | if (newstage == 1 && parseFloat($('#brew_date_start').val()) > 2000) | |
3393 | newstage = 2; // Brewday | |
3394 | if (newstage == 2 && ($('#brew_date_start').val() == '')) | |
3395 | newstage = 1; // No brewday | |
3396 | if (newstage == 2 && parseFloat($('#brew_date_end').val()) > 2000) | |
3397 | newstage = 3; // Primary | |
3398 | if (newstage == 3 && parseFloat($('#primary_end_date').val()) > 2000) | |
3399 | newstage = 4; // Secondary | |
3400 | if (newstage == 4 && parseFloat($('#secondary_end_date').val()) > 2000) | |
3401 | newstage = 5; // Tertiary | |
3402 | if (newstage == 5 && parseFloat($('#package_date').val()) > 2000) | |
3403 | newstage = 6; // Package | |
3404 | if (newstage >= 6 && newstage < 9) { | |
3405 | d = new Date(); | |
3406 | date2 = $('#package_date').val(); | |
3407 | date2 = date2.split('-'); | |
3408 | // Now we convert the array to a Date object | |
3409 | date1 = new Date(d.getFullYear(), d.getMonth(), d.getDate()); | |
3410 | date2 = new Date(date2[0], date2[1] - 1, date2[2]); | |
3411 | // We use the getTime() method and get the unixtime | |
3412 | date1_unixtime = parseInt(date1.getTime() / 1000); | |
3413 | date2_unixtime = parseInt(date2.getTime() / 1000); | |
3414 | // This is the calculated difference in seconds | |
3415 | timeDifference = date1_unixtime - date2_unixtime; | |
3416 | timeDifferenceInDays = timeDifference / 60 / 60 / 24; | |
3417 | if (timeDifferenceInDays > 0) { // At least one day | |
3418 | if (timeDifferenceInDays >= 42) // 6 weeks | |
3419 | newstage = 9; // Ready to taste | |
3420 | else if (timeDifferenceInDays >= 14) // 14 days | |
3421 | newstage = 8; // Mature | |
3422 | else | |
3423 | newstage = 7; // Carbonation | |
3424 | } | |
3425 | } | |
3426 | if (newstage == 9 && parseFloat($('#taste_date').val()) > 2000) | |
3427 | newstage = 10; // Ready | |
3428 | ||
3429 | if (newstage != dataRecord.stage) { | |
3430 | console.log('calcStage() old: ' + dataRecord.stage + ' new: ' + newstage); | |
3431 | dataRecord.stage = newstage; | |
3432 | } | |
3433 | ||
3434 | /* | |
3435 | * Set stage and enable or disable parts of the screens. | |
3436 | */ | |
3437 | $('#stage').val(StageData[dataRecord.stage].nl); | |
3438 | if (dataRecord.stage >= 10) { | |
3439 | $('#locked').jqxCheckBox({ disabled: false }); | |
3440 | } | |
3441 | ||
3442 | /* | |
3443 | * When the brew is in progress or done, block equipment select and delete. | |
3444 | */ | |
3445 | if (dataRecord.stage > 1) { | |
3446 | $('#equipmentSelect').jqxDropDownList({ disabled: true }); | |
3447 | $('#Delete').jqxButton({ disabled: true }); | |
3448 | } | |
3449 | ||
3450 | if (dataRecord.stage < 1) // Planning, no ingredients | |
3451 | $('#jqxTabs').jqxTabs('disableAt', 8); // Brewday tab | |
3452 | else | |
3453 | $('#jqxTabs').jqxTabs('enableAt', 8); | |
3454 | ||
3455 | if (dataRecord.stage < 3) { // Primary | |
3456 | $('#jqxTabs').jqxTabs('disableAt', 9); // Fermentation tab | |
3457 | } else { | |
3458 | $('#jqxTabs').jqxTabs('enableAt', 9); | |
3459 | $('#name').jqxInput({ disabled: true }); | |
3460 | $('#code').jqxInput({ disabled: true }); | |
3461 | $('#batch_size').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3462 | $('#boil_size').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3463 | $('#boil_time').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3464 | $('#efficiency').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3465 | $('#est_og').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3466 | $('#type').jqxDropDownList({ disabled: true }); | |
3467 | $('#styleSelect').jqxDropDownList({ disabled: true }); | |
3468 | $('#color_method').jqxDropDownList({ disabled: true }); | |
3469 | $('#ibu_method').jqxDropDownList({ disabled: true }); | |
3470 | $('#mash_select').jqxDropDownList({ disabled: true }); | |
3471 | $('#w1_name').jqxDropDownList({ disabled: true }); | |
3472 | $('#w2_name').jqxDropDownList({ disabled: true }); | |
3473 | $('#w2_amount').jqxNumberInput({ readOnly: true }); | |
3474 | $('#pr_name').jqxDropDownList({ disabled: true }); | |
3475 | $('#wa_cacl2').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3476 | $('#wa_caso4').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3477 | $('#wa_mgso4').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3478 | $('#wa_nacl').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3479 | $('#mash_ph').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3480 | $('#calc_acid').jqxCheckBox({ disabled: true }); | |
3481 | $('#wa_base_name').jqxDropDownList({ disabled: true }); | |
3482 | $('#wa_base').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3483 | $('#wa_acid_name').jqxDropDownList({ disabled: true }); | |
3484 | $('#wa_acid').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3485 | $('#wa_acid_perc').jqxNumberInput({ spinButtons: false, readOnly: true, width: 70 }); | |
3486 | $('#sparge_temp').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3487 | $('#sparge_volume').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3488 | $('#sparge_ph').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3489 | $('#sparge_source').jqxDropDownList({ disabled: true }); | |
3490 | $('#sparge_acid_type').jqxDropDownList({ disabled: true }); | |
3491 | $('#sparge_acid_perc').jqxNumberInput({ spinButtons: false, readOnly: true, width: false }); | |
3492 | $('#starter_enable').jqxCheckBox({ disabled: true }); | |
3493 | $('#starter_type').jqxDropDownList({ disabled: true }); | |
3494 | $('#starter_try').jqxButton({ disabled: true }); | |
3495 | $('#starter_sg').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3496 | $('#starter_viability').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3497 | } | |
3498 | if (dataRecord.stage > 3) { // Primary fermentation done | |
3499 | $('#brew_date_start').jqxDateTimeInput({ disabled: true }); | |
3500 | $('#brew_date_end').jqxDateTimeInput({ disabled: true }); | |
3501 | $('#brew_mash_ph').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3502 | $('#brew_preboil_ph').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3503 | $('#brew_aboil_ph').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3504 | $('#brew_mash_sg').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3505 | $('#brew_preboil_sg').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3506 | $('#brew_aboil_sg').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3507 | $('#brew_preboil_volume').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3508 | $('#brew_aboil_volume').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3509 | $('#brew_whirlpool9').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3510 | $('#brew_cooling_to').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3511 | $('#brew_whirlpool7').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3512 | $('#brew_cooling_method').jqxDropDownList({ disabled: true }); | |
3513 | $('#brew_whirlpool6').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3514 | $('#brew_cooling_time').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3515 | $('#brew_sparge_ph').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3516 | $('#brew_whirlpool2').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3517 | $('#brew_aeration_type').jqxDropDownList({ disabled: true }); | |
3518 | $('#brew_fermenter_tcloss').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3519 | $('#brew_aeration_time').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3520 | $('#brew_fermenter_extrawater').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3521 | $('#brew_aeration_speed').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3522 | } | |
3523 | if (dataRecord.stage == 5) // Lagering, allow packaging | |
3524 | $('#package_date').jqxDateTimeInput({ disabled: false }); | |
3525 | else | |
3526 | $('#package_date').jqxDateTimeInput({ disabled: true }); | |
3527 | if (dataRecord.stage >= 5) { // At least secondary | |
3528 | $('#primary_start_temp').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3529 | $('#primary_max_temp').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3530 | $('#primary_end_temp').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3531 | $('#primary_end_sg').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3532 | $('#primary_end_brix').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3533 | $('#primary_end_date').jqxDateTimeInput({ disabled: true }); | |
3534 | } | |
3535 | if (dataRecord.stage >= 6) { // Packaged | |
3536 | $('#secondary_temp').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3537 | $('#secondary_end_sg').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3538 | $('#secondary_end_date').jqxDateTimeInput({ disabled: true }); | |
3539 | $('#tertiary_temp').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3540 | $('#fg').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3541 | $('#final_brix').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3542 | $('#package_date').jqxDateTimeInput({ disabled: true }); | |
3543 | $('#package_volume').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3544 | $('#package_infuse_amount').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3545 | $('#package_infuse_abv').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3546 | $('#package_infuse_notes').jqxInput({ disabled: true }); | |
3547 | $('#package_ph').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3548 | $('#bottle_amount').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3549 | $('#bottle_priming_water').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3550 | $('#keg_priming_water').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3551 | $('#keg_amount').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3552 | $('#bottle_carbonation').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3553 | $('#keg_carbonation').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3554 | $('#bottle_priming_sugar').jqxDropDownList({ disabled: true }); | |
3555 | $('#keg_priming_sugar').jqxDropDownList({ disabled: true }); | |
3556 | $('#keg_forced_carb').jqxCheckBox({ disabled: true }); | |
3557 | $('#bottle_carbonation_temp').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3558 | $('#keg_carbonation_temp').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3559 | } | |
3560 | if (dataRecord.stage < 8) { // Taste when at least Mature. | |
3561 | $('#jqxTabs').jqxTabs('disableAt', 11); // Tasting tab | |
3562 | } else { | |
3563 | $('#jqxTabs').jqxTabs('enableAt', 11); | |
3564 | } | |
3565 | ||
3566 | if (dataRecord.stage == 11) { // Locked | |
3567 | $('#taste_date').jqxDateTimeInput({ disabled: true }); | |
3568 | $('#taste_rate').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3569 | $('#taste_color').jqxInput({ disabled: true }); | |
3570 | $('#taste_transparency').jqxInput({ disabled: true }); | |
3571 | $('#taste_head').jqxInput({ disabled: true }); | |
3572 | $('#taste_aroma').jqxInput({ disabled: true }); | |
3573 | $('#taste_taste').jqxInput({ disabled: true }); | |
3574 | $('#taste_aftertaste').jqxInput({ disabled: true }); | |
3575 | $('#taste_mouthfeel').jqxInput({ disabled: true }); | |
3576 | $('#taste_notes').jqxInput({ disabled: true }); | |
3577 | $('#notes').jqxInput({ disabled: true }); | |
3578 | } else { | |
3579 | $('#notes').jqxInput({ disabled: false }); | |
3580 | } | |
3581 | } | |
3582 | ||
3583 | function showStarter() { | |
3584 | ||
3585 | if (dataRecord.starter_enable) { | |
3586 | $('#propagator').show(); | |
3587 | $('#starter_type').jqxDropDownList({ disabled: false }); | |
3588 | $('#starter_try').jqxButton({ disabled: false }); | |
3589 | $('#starter_sg').jqxNumberInput({ spinButtons: true, readOnly: false, width: 110 }); | |
3590 | $('#starter_viability').jqxNumberInput({ spinButtons: true, readOnly: false, width: 110 }); | |
3591 | } else { | |
3592 | $('#propagator').hide(); | |
3593 | $('#starter_type').jqxDropDownList({ disabled: true }); | |
3594 | $('#starter_try').jqxButton({ disabled: true }); | |
3595 | $('#starter_sg').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3596 | $('#starter_viability').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
3597 | } | |
3598 | } | |
3599 | ||
3600 | function calcInit() { | |
3601 | console.log('calcInit()'); | |
3602 | ||
3603 | calcMashEfficiency(); | |
3604 | calcEfficiencyBeforeBoil(); | |
3605 | calcEfficiencyAfterBoil(); | |
3606 | ||
3607 | $('#starter_enable').on('checked', function(event) { | |
3608 | dataRecord.starter_enable = 1; | |
3609 | showStarter(); | |
3610 | calcYeast(); | |
3611 | }); | |
3612 | $('#starter_enable').on('unchecked', function(event) { | |
3613 | dataRecord.starter_enable = 0; | |
3614 | showStarter(); | |
3615 | calcYeast(); | |
3616 | }); | |
3617 | $('#starter_try').click(function() { | |
3618 | $('#prop1_volume').val(0); | |
3619 | $('#prop2_volume').val(0); | |
3620 | $('#prop3_volume').val(0); | |
3621 | $('#prop4_volume').val(0); | |
3622 | calcYeast(); | |
3623 | }); | |
3624 | $('#starter_type').on('change', function(event) { | |
3625 | if (event.args) { | |
3626 | dataRecord.starter_type = event.args.index; | |
3627 | calcYeast(); | |
3628 | } | |
3629 | }); | |
3630 | $('#starter_sg').on('change', function(event) { | |
3631 | if (event.args) { | |
3632 | dataRecord.starter_sg = event.args.value; | |
3633 | calcYeast(); | |
3634 | } | |
3635 | }); | |
3636 | $('#starter_viability').on('change', function(event) { | |
3637 | if (event.args) { | |
3638 | dataRecord.starter_viability = event.args.value; | |
3639 | calcFermentables(); | |
3640 | calcYeast(); | |
3641 | } | |
3642 | }); | |
3643 | $('#prop1_type').on('change', function(event) { | |
3644 | if (event.args) { | |
3645 | dataRecord.prop1_type = event.args.index; | |
3646 | calcYeast(); | |
3647 | } | |
3648 | }); | |
3649 | $('#prop1_volume').on('change', function(event) { | |
3650 | if (event.args) { | |
3651 | dataRecord.prop1_volume = event.args.value; | |
3652 | calcYeast(); | |
3653 | } | |
3654 | }); | |
3655 | $('#prop2_type').on('change', function(event) { | |
3656 | if (event.args) { | |
3657 | dataRecord.prop2_type = event.args.index; | |
3658 | calcYeast(); | |
3659 | } | |
3660 | }); | |
3661 | $('#prop2_volume').on('change', function(event) { | |
3662 | if (event.args) { | |
3663 | dataRecord.prop2_volume = event.args.value; | |
3664 | calcYeast(); | |
3665 | } | |
3666 | }); | |
3667 | $('#prop3_type').on('change', function(event) { | |
3668 | if (event.args) { | |
3669 | dataRecord.prop3_type = event.args.index; | |
3670 | calcYeast(); | |
3671 | } | |
3672 | }); | |
3673 | $('#prop3_volume').on('change', function(event) { | |
3674 | if (event.args) { | |
3675 | dataRecord.prop3_volume = event.args.value; | |
3676 | calcYeast(); | |
3677 | } | |
3678 | }); | |
3679 | $('#prop4_type').on('change', function(event) { | |
3680 | if (event.args) { | |
3681 | dataRecord.prop4_type = event.args.index; | |
3682 | calcYeast(); | |
3683 | } | |
3684 | }); | |
3685 | $('#prop4_volume').on('change', function(event) { | |
3686 | if (event.args) { | |
3687 | dataRecord.prop4_volume = event.args.value; | |
3688 | calcYeast(); | |
3689 | } | |
3690 | }); | |
3691 | ||
3692 | $('#calc_acid').on('checked', function(event) { | |
3693 | dataRecord.calc_acid = 1; | |
3694 | calcWater(); | |
3695 | }); | |
3696 | $('#calc_acid').on('unchecked', function(event) { | |
3697 | dataRecord.calc_acid = 0; | |
3698 | calcWater(); | |
3699 | }); | |
3700 | $('#w1_name').jqxDropDownList('selectItem', dataRecord.w1_name); | |
3701 | $('#w2_name').jqxDropDownList('selectItem', dataRecord.w2_name); | |
3702 | // Fix tap water if zero using mash infuse amount. | |
3703 | if (parseFloat($('#w1_amount').jqxNumberInput('decimal')) == 0 && mash_infuse > 0) { | |
3704 | $('#w1_amount').val(mash_infuse); | |
3705 | dataRecord.w1_amount = mash_infuse; | |
3706 | $('#wg_amount').val(mash_infuse); | |
3707 | $('#w2_amount').val(0); | |
3708 | dataRecord.w2_amount = 0; | |
3709 | } | |
3710 | calcWater(); | |
3711 | $('#w2_amount').on('change', function(event) { | |
3712 | var newval = parseFloat(event.args.value); | |
3713 | ||
3714 | if (newval > mash_infuse) { | |
3715 | $('#w2_amount').val(dataRecord.w2_amount); | |
3716 | return; | |
3717 | } | |
3718 | dataRecord.w1_amount = parseFloat($('#wg_amount').jqxNumberInput('decimal')) - newval; | |
3719 | $('#w1_amount').val(dataRecord.w1_amount); | |
3720 | dataRecord.w2_amount = newval; | |
3721 | console.log('new: ' + event.args.value + ' w1: ' + dataRecord.w1_amount + ' w2: ' + dataRecord.w2_amount); | |
3722 | calcWater(); | |
3723 | }); | |
3724 | $('#wa_cacl2').on('change', function(event) { | |
3725 | if (event.args) { | |
3726 | setWaterAgent('CaCl2', 0); // This can prevent double entries. | |
3727 | setWaterAgent('CaCl2', event.args.value); | |
3728 | calcWater(); | |
3729 | } | |
3730 | }); | |
3731 | $('#wa_caso4').on('change', function(event) { | |
3732 | if (event.args) { | |
3733 | setWaterAgent('CaSO4', 0); | |
3734 | setWaterAgent('CaSO4', event.args.value); | |
3735 | calcWater(); | |
3736 | } | |
3737 | }); | |
3738 | $('#wa_mgso4').on('change', function(event) { | |
3739 | if (event.args) { | |
3740 | setWaterAgent('MgSO4', 0); | |
3741 | setWaterAgent('MgSO4', event.args.value); | |
3742 | calcWater(); | |
3743 | } | |
3744 | }); | |
3745 | $('#wa_nacl').on('change', function(event) { | |
3746 | if (event.args) { | |
3747 | setWaterAgent('NaCl', 0); | |
3748 | setWaterAgent('NaCl', event.args.value); | |
3749 | calcWater(); | |
3750 | } | |
3751 | }); | |
3752 | $('#wa_base_name').on('change', function(event) { | |
3753 | if (event.args) { | |
3754 | var index = event.args.index; | |
3755 | console.log('wa_base_name ' + index); | |
3756 | setWaterAgent(last_base, 0); | |
3757 | last_base = BaseTypeData[index].nl; | |
3758 | setWaterAgent(last_base, parseFloat($('#wa_base').jqxNumberInput('decimal'))); | |
3759 | dataRecord.wa_base_name = index; | |
3760 | calcWater(); | |
3761 | } | |
3762 | }); | |
3763 | $('#wa_base').on('change', function(event) { | |
3764 | var name = BaseTypeData[$('#wa_base_name').val()].nl; | |
3765 | setWaterAgent(name, parseFloat(event.args.value)); | |
3766 | calcWater(); | |
3767 | }); | |
3768 | $('#wa_acid_name').on('change', function(event) { | |
3769 | if (event.args) { | |
3770 | var index = event.args.index; | |
3771 | console.log('wa_acid_name ' + index); | |
3772 | setWaterAgent(last_acid, 0); | |
3773 | last_acid = AcidTypeData[index].nl; | |
3774 | setWaterAgent(last_acid, parseFloat($('#wa_acid').jqxNumberInput('decimal'))); | |
3775 | dataRecord.wa_acid_name = index; | |
3776 | calcWater(); | |
3777 | } | |
3778 | }); | |
3779 | $('#wa_acid').on('change', function(event) { | |
3780 | var name = AcidTypeData[$('#wa_acid_name').val()].nl; | |
3781 | setWaterAgent(name, parseFloat(event.args.value)); | |
3782 | calcWater(); | |
3783 | }); | |
3784 | $('#wa_acid_perc').on('change', function(event) { calcWater(); }); | |
3785 | ||
3786 | $('#color_method').on('change', function(event) { | |
3787 | dataRecord.color_method = event.args.index; | |
3788 | calcFermentables(); | |
3789 | }); | |
3790 | $('#ibu_method').on('change', function(event) { | |
3791 | dataRecord.ibu_method = event.args.index; | |
3792 | calcFermentables(); | |
3793 | calcIBUs(); | |
3794 | }); | |
3795 | ||
3796 | $('#batch_size').on('change', function(event) { | |
3797 | console.log('batch_size change:' + event.args.value + ' old:' + dataRecord.batch_size); | |
3798 | $('#est_a_vol').val(event.args.value * 1.04); | |
3799 | var factor, new_boil = parseFloat(event.args.value) + dataRecord.boil_size - dataRecord.batch_size; | |
3800 | factor = parseFloat(event.args.value) / dataRecord.batch_size; | |
3801 | dataRecord.boil_size = new_boil; | |
3802 | $('#boil_size').val(Round(new_boil, 2)); | |
3803 | $('#est_pre_vol').val(Round(new_boil * 1.04, 2)); | |
3804 | dataRecord.sparge_volume *= factor; | |
3805 | $('#sparge_volume').val(dataRecord.sparge_volume); | |
3806 | $('#brew_sparge_volume').val(dataRecord.sparge_volume); | |
3807 | dataRecord.batch_size = parseFloat(event.args.value); | |
3808 | calcFermentablesFromOG(parseFloat($('#est_og').jqxNumberInput('decimal'))); // Keep the OG | |
3809 | adjustWaters(factor); | |
3810 | calcFermentables(); | |
3811 | adjustHops(factor); | |
3812 | adjustMiscs(factor); | |
3813 | adjustYeasts(factor); | |
3814 | calcIBUs(); | |
3815 | calcWater(); | |
3816 | calcSparge(); | |
3817 | calcMash(); | |
3818 | }); | |
3819 | $('#boil_time').on('change', function(event) { | |
3820 | console.log('boil_time change:' + parseFloat(event.args.value) + ' old:' + dataRecord.boil_time); | |
3821 | var new_boil, new_evap, old_evap = parseFloat(dataRecord.boil_size) - parseFloat(dataRecord.batch_size); | |
3822 | new_evap = old_evap * (parseFloat(event.args.value) / dataRecord.boil_time); | |
3823 | new_boil = parseFloat(dataRecord.batch_size) + new_evap; | |
3824 | dataRecord.boil_time = parseFloat(event.args.value); | |
3825 | dataRecord.boil_size = new_boil; | |
3826 | $('#est_pre_vol').val(Round(new_boil * 1.04, 2)); | |
3827 | $('#boil_size').val(Round(new_boil, 2)); | |
3828 | calcFermentables(); | |
3829 | calcIBUs(); | |
3830 | calcYeast(); | |
3831 | }); | |
3832 | $('#efficiency').on('change', function(event) { | |
3833 | var estog = parseFloat($('#est_og').jqxNumberInput('decimal')); | |
3834 | dataRecord.efficiency = parseFloat(event.args.value); | |
3835 | console.log('efficiency change:' + dataRecord.efficiency + ' est_og:' + estog); | |
3836 | calcFermentablesFromOG(estog); // Keep the OG | |
3837 | calcFermentables(); | |
3838 | calcIBUs(); | |
3839 | calcYeast(); | |
3840 | }); | |
3841 | $('#est_og').on('change', function(event) { | |
3842 | dataRecord.est_og = parseFloat(event.args.value); | |
3843 | console.log('est_og change:' + dataRecord.est_og); | |
3844 | $('#est_og2').val(dataRecord.est_og); | |
3845 | calcFermentablesFromOG(dataRecord.est_og); // Adjust fermentables amounts | |
3846 | calcFermentables(); // Update the recipe details | |
3847 | calcIBUs(); // and the IBU's. | |
3848 | calcMash(); | |
3849 | calcYeast(); | |
3850 | }); | |
3851 | $('#mash_ph').on('change', function(event) { | |
3852 | dataRecord.mash_ph = parseFloat(event.args.value); | |
3853 | calcWater(); | |
3854 | }); | |
3855 | ||
3856 | $('#sparge_ph').on('change', function(event) { | |
3857 | dataRecord.sparge_ph = parseFloat(event.args.value); | |
3858 | calcSparge(); | |
3859 | }); | |
3860 | $('#sparge_volume').on('change', function(event) { | |
3861 | dataRecord.sparge_volume = parseFloat(event.args.value); | |
3862 | $('#brew_sparge_volume').val(dataRecord.sparge_volume); | |
3863 | calcSparge(); | |
3864 | }); | |
3865 | $('#sparge_temp').on('change', function(event) { | |
3866 | dataRecord.sparge_temp = parseFloat(event.args.value); | |
3867 | $('#brew_sparge_temperature').val(dataRecord.sparge_temp); | |
3868 | }); | |
3869 | $('#sparge_source').on('change', function(event) { | |
3870 | if (event.args) { | |
3871 | dataRecord.sparge_source = event.args.index; | |
3872 | calcSparge(); | |
3873 | } | |
3874 | }); | |
3875 | $('#sparge_acid_type').on('change', function(event) { | |
3876 | if (event.args) { | |
3877 | dataRecord.sparge_acid_type = event.args.index; | |
3878 | console.log('new sparge_acid_type: ' + dataRecord.sparge_acid_type); | |
3879 | calcSparge(); | |
3880 | } | |
3881 | }); | |
3882 | $('#sparge_acid_perc').on('change', function(event) { | |
3883 | dataRecord.sparge_acid_perc = parseFloat(event.args.value); | |
3884 | calcSparge(); | |
3885 | }); | |
3886 | ||
3887 | calcFermentation(); | |
3888 | calcCarbonation(); | |
3889 | $('#package_volume').on('change', function(event) { | |
3890 | var diff, tnew, told = dataRecord.package_volume + dataRecord.package_infuse_amount; | |
3891 | dataRecord.package_volume = parseFloat(event.args.value); | |
3892 | if (dataRecord.package_volume > dataRecord.brew_fermenter_volume) { | |
3893 | dataRecord.package_volume = dataRecord.brew_fermenter_volume; | |
3894 | $('#package_volume').val(dataRecord.package_volume); | |
3895 | } | |
3896 | tnew = dataRecord.package_volume + dataRecord.package_infuse_amount; | |
3897 | diff = tnew - told; | |
3898 | if (told > 0) { | |
3899 | dataRecord.bottle_amount += (dataRecord.bottle_amount / told) * diff; | |
3900 | dataRecord.keg_amount += (dataRecord.keg_amount / told) * diff; | |
3901 | } else { | |
3902 | dataRecord.bottle_amount = tnew; | |
3903 | dataRecord.keg_amount = 0; | |
3904 | } | |
3905 | console.log('diff:' + diff + ' old:' + told + ' bottle:' + dataRecord.bottle_amount + ' keg:' + dataRecord.keg_amount); | |
3906 | $('#bottle_amount').val(parseFloat(dataRecord.bottle_amount * 1000) / 1000); | |
3907 | $('#keg_amount').val(parseFloat(dataRecord.keg_amount * 1000) / 1000); | |
3908 | calcCarbonation(); | |
3909 | }); | |
3910 | $('#package_infuse_amount').on('change', function(event) { | |
3911 | var diff, tnew, told = dataRecord.package_volume + dataRecord.package_infuse_amount; | |
3912 | dataRecord.package_infuse_amount = parseFloat(event.args.value); | |
3913 | tnew = dataRecord.package_volume + dataRecord.package_infuse_amount; | |
3914 | diff = tnew - told; | |
3915 | if (told > 0) { | |
3916 | dataRecord.bottle_amount += (dataRecord.bottle_amount / told) * diff; | |
3917 | dataRecord.keg_amount += (dataRecord.keg_amount / told) * diff; | |
3918 | } else { | |
3919 | dataRecord.bottle_amount = tnew; | |
3920 | dataRecord.keg_amount = 0; | |
3921 | } | |
3922 | console.log('diff:' + diff + ' old:' + told + ' bottle:' + dataRecord.bottle_amount + ' keg:' + dataRecord.keg_amount); | |
3923 | $('#bottle_amount').val(parseFloat(dataRecord.bottle_amount * 1000) / 1000); | |
3924 | $('#keg_amount').val(parseFloat(dataRecord.keg_amount * 1000) / 1000); | |
3925 | calcCarbonation(); | |
3926 | }); | |
3927 | $('#package_infuse_abv').on('change', function(event) { | |
3928 | dataRecord.package_infuse_abv = parseFloat(event.args.value); | |
3929 | calcCarbonation(); | |
3930 | }); | |
3931 | $('#bottle_amount').on('change', function(event) { | |
3932 | var vtot, diff, vnew = parseFloat(event.args.value); | |
3933 | vtot = dataRecord.package_volume + dataRecord.package_infuse_amount; | |
3934 | if (vnew > vtot) | |
3935 | vnew = vtot; | |
3936 | diff = dataRecord.bottle_amount - vnew; | |
3937 | dataRecord.bottle_amount = Math.round((dataRecord.bottle_amount - diff) * 1000) / 1000; | |
3938 | dataRecord.keg_amount = Math.round((dataRecord.keg_amount + diff) * 1000) / 1000; | |
3939 | $('#bottle_amount').val(parseFloat(dataRecord.bottle_amount)); | |
3940 | $('#keg_amount').val(parseFloat(dataRecord.keg_amount)); | |
3941 | calcCarbonation(); | |
3942 | }); | |
3943 | $('#bottle_priming_water').on('change', function(event) { | |
3944 | dataRecord.bottle_priming_water = parseFloat(event.args.value); | |
3945 | calcCarbonation(); | |
3946 | }); | |
3947 | $('#keg_amount').on('change', function(event) { | |
3948 | var diff, vtot, vnew = parseFloat(event.args.value); | |
3949 | vtot = dataRecord.package_volume + dataRecord.package_infuse_amount; | |
3950 | if (vnew > vtot) | |
3951 | vnew = vtot; | |
3952 | diff = dataRecord.keg_amount - vnew; | |
3953 | dataRecord.bottle_amount = Math.round((dataRecord.bottle_amount + diff) * 1000) / 1000; | |
3954 | dataRecord.keg_amount = Math.round((dataRecord.keg_amount - diff) * 1000) / 1000; | |
3955 | $('#bottle_amount').val(parseFloat(dataRecord.bottle_amount)); | |
3956 | $('#keg_amount').val(parseFloat(dataRecord.keg_amount)); | |
3957 | calcCarbonation(); | |
3958 | }); | |
3959 | $('#keg_priming_water').on('change', function(event) { | |
3960 | dataRecord.keg_priming_water = parseFloat(event.args.value); | |
3961 | calcCarbonation(); | |
3962 | }); | |
3963 | $('#bottle_carbonation').on('change', function(event) { | |
3964 | dataRecord.bottle_carbonation = parseFloat(event.args.value); | |
3965 | calcCarbonation(); | |
3966 | }); | |
3967 | $('#bottle_carbonation_temp').on('change', function(event) { | |
3968 | dataRecord.bottle_carbonation_temp = parseFloat(event.args.value); | |
3969 | calcCarbonation(); | |
3970 | }); | |
3971 | $('#keg_carbonation').on('change', function(event) { | |
3972 | dataRecord.keg_carbonation = parseFloat(event.args.value); | |
3973 | calcCarbonation(); | |
3974 | }); | |
3975 | $('#keg_forced_carb').on('checked', function(event) { | |
3976 | dataRecord.keg_forced_carb = 1; | |
3977 | calcCarbonation(); | |
3978 | }); | |
3979 | $('#keg_forced_carb').on('unchecked', function(event) { | |
3980 | dataRecord.keg_forced_carb = 0; | |
3981 | calcCarbonation(); | |
3982 | }); | |
3983 | $('#keg_carbonation_temp').on('change', function(event) { | |
3984 | dataRecord.keg_carbonation_temp = parseFloat(event.args.value); | |
3985 | calcCarbonation(); | |
3986 | }); | |
3987 | ||
3988 | $('#brew_fermenter_extrawater').on('change', function(event) { | |
3989 | dataRecord.brew_fermenter_extrawater = parseFloat(event.args.value); | |
3990 | calcFermentables(); | |
3991 | calcIBUs(); | |
3992 | calcYeast(); | |
3993 | }); | |
3994 | $('#brew_fermenter_tcloss').on('change', function(event) { | |
3995 | dataRecord.brew_fermenter_tcloss = parseFloat(event.args.value); | |
3996 | calcFermentables(); | |
3997 | calcIBUs(); | |
3998 | calcYeast(); | |
3999 | }); | |
4000 | $('#primary_end_sg').on('change', function(event) { | |
4001 | dataRecord.primary_end_sg = parseFloat(event.args.value); | |
4002 | calcFermentation(); | |
4003 | }); | |
4004 | $('#primary_end_brix').on('change', function(event) { | |
4005 | var OBrix, FBrix, FG; | |
4006 | if (dataRecord.brew_fermenter_sg >= 1.020) { | |
4007 | OBrix = sg_to_brix(dataRecord.brew_fermenter_sg); | |
4008 | FBrix = parseFloat(event.args.value); | |
4009 | FG = Round(1.0031 - 0.002318474 * OBrix - 0.000007775 * (OBrix * OBrix) - 0.000000034 * Math.pow(OBrix, 3) + | |
4010 | 0.00574 * (FBrix) + 0.00003344 * (FBrix * FBrix) + 0.000000086 * Math.pow(FBrix, 3), 4); | |
4011 | //console.log("OBrix:"+OBrix+" FBrix:"+FBrix+" FG:"+FG); | |
4012 | if (FBrix > 0.05) { | |
4013 | $('#primary_end_sg').val(FG); | |
4014 | dataRecord.primary_end_sg = FG; | |
4015 | } | |
4016 | calcFermentation(); | |
4017 | } | |
4018 | }); | |
4019 | $('#secondary_end_sg').on('change', function(event) { | |
4020 | dataRecord.secondary_end_sg = parseFloat(event.args.value); | |
4021 | calcFermentation(); | |
4022 | }); | |
4023 | $('#secondary_end_brix').on('change', function(event) { | |
4024 | var OBrix, FBrix, FG; | |
4025 | if (dataRecord.brew_fermenter_sg >= 1.020) { | |
4026 | OBrix = sg_to_brix(dataRecord.brew_fermenter_sg); | |
4027 | FBrix = parseFloat(event.args.value); | |
4028 | FG = Round(1.0031 - 0.002318474 * OBrix - 0.000007775 * (OBrix * OBrix) - 0.000000034 * Math.pow(OBrix, 3) + | |
4029 | 0.00574 * (FBrix) + 0.00003344 * (FBrix * FBrix) + 0.000000086 * Math.pow(FBrix, 3), 4); | |
4030 | //console.log("OBrix:"+OBrix+" FBrix:"+FBrix+" FG:"+FG); | |
4031 | if (FBrix > 0.05) { | |
4032 | $('#secondary_end_sg').val(FG); | |
4033 | dataRecord.secondary_end_sg = FG; | |
4034 | } | |
4035 | calcFermentation(); | |
4036 | } | |
4037 | }); | |
4038 | $('#final_brix').on('change', function(event) { | |
4039 | var OBrix, FBrix, FG; | |
4040 | if (dataRecord.brew_fermenter_sg >= 1.020) { | |
4041 | OBrix = sg_to_brix(dataRecord.brew_fermenter_sg); | |
4042 | FBrix = parseFloat(event.args.value); | |
4043 | FG = Round(1.0031 - 0.002318474 * OBrix - 0.000007775 * (OBrix * OBrix) - 0.000000034 * Math.pow(OBrix, 3) + | |
4044 | 0.00574 * (FBrix) + 0.00003344 * (FBrix * FBrix) + 0.000000086 * Math.pow(FBrix, 3), 4); | |
4045 | //console.log("OBrix:"+OBrix+" FBrix:"+FBrix+" FG:"+FG); | |
4046 | if (FBrix > 0.05) { | |
4047 | $('#fg').val(FG); | |
4048 | dataRecord.fg = FG; | |
4049 | } | |
4050 | calcFermentation(); | |
4051 | } | |
4052 | }); | |
4053 | $('#fg').on('change', function(event) { | |
4054 | dataRecord.fg = parseFloat(event.args.value); | |
4055 | calcFermentation(); | |
4056 | }); | |
4057 | $('#BLog').jqxButton({ disabled: (dataRecord.log_brew) ? false : true}); | |
4058 | $('#FLog').jqxButton({ disabled: (dataRecord.log_fermentation) ? false : true}); | |
4059 | } | |
4060 | ||
4061 | $('#styleSelect').jqxDropDownList({ | |
4062 | placeHolder: 'Kies bierstijl:', | |
4063 | theme: theme, | |
4064 | source: styleslist, | |
4065 | displayMember: 'name', | |
4066 | width: 180, | |
4067 | height: 23, | |
4068 | dropDownVerticalAlignment: 'top', | |
4069 | dropDownWidth: 500, | |
4070 | dropDownHeight: 380, | |
4071 | renderer: function(index, label, value) { | |
4072 | var datarecord = styleslist.records[index]; | |
4073 | return datarecord.style_guide + ' ' + datarecord.style_letter + ' ' + datarecord.name; | |
4074 | } | |
4075 | }); | |
4076 | $('#styleSelect').on('select', function(event) { | |
4077 | if (event.args) { | |
4078 | var datarecord, index = event.args.index; | |
4079 | datarecord = styleslist.records[index]; | |
4080 | $('#st_name').val(datarecord.name); | |
4081 | $('#st_category').val(datarecord.category); | |
4082 | $('#st_category_number').val(datarecord.category_number); | |
4083 | $('#st_letter').val(datarecord.style_letter); | |
4084 | $('#st_guide').val(datarecord.style_guide); | |
4085 | $('#st_type').val(StyleTypeData[datarecord.type].nl); | |
4086 | $('#st_og_min').val(datarecord.og_min); | |
4087 | $('#st_og_max').val(datarecord.og_max); | |
4088 | $('#st_fg_min').val(datarecord.fg_min); | |
4089 | $('#st_fg_max').val(datarecord.fg_max); | |
4090 | $('#st_ibu_min').val(datarecord.ibu_min); | |
4091 | $('#st_ibu_max').val(datarecord.ibu_max); | |
4092 | $('#st_color_min').val(datarecord.color_min); | |
4093 | $('#st_color_max').val(datarecord.color_max); | |
4094 | $('#st_carb_min').val(datarecord.carb_min); | |
4095 | $('#st_carb_min2').val(datarecord.carb_min); | |
4096 | $('#st_carb_max').val(datarecord.carb_max); | |
4097 | $('#st_carb_max2').val(datarecord.carb_max); | |
4098 | $('#st_abv_min').val(datarecord.abv_min); | |
4099 | $('#st_abv_max').val(datarecord.abv_max); | |
4100 | } | |
4101 | }); | |
4102 | ||
4103 | // Equipemnt dropdown list | |
4104 | $('#equipmentSelect').jqxDropDownList({ | |
4105 | placeHolder: 'Kies apparatuur:', | |
4106 | theme: theme, | |
4107 | source: equipmentlist, | |
4108 | displayMember: 'name', | |
4109 | width: 170, | |
4110 | height: 23, | |
4111 | dropDownWidth: 300, | |
4112 | renderer: function(index, label, value) { | |
4113 | var datarecord = equipmentlist.records[index]; | |
4114 | return datarecord.batch_size + ' liter ' + datarecord.name; | |
4115 | } | |
4116 | }); | |
4117 | $('#equipmentSelect').on('select', function(event) { | |
4118 | if (event.args) { | |
4119 | var datarecord, factor, index = event.args.index; | |
4120 | datarecord = equipmentlist.records[index]; | |
4121 | factor = datarecord.batch_size / dataRecord.batch_size; | |
4122 | $('#eq_name').val(datarecord.name); | |
4123 | $('#eq_boil_size').val(datarecord.boil_size); | |
4124 | dataRecord.boil_size = datarecord.boil_size; | |
4125 | $('#boil_size').val(datarecord.boil_size); | |
4126 | $('#eq_batch_size').val(datarecord.batch_size); | |
4127 | dataRecord.batch_size = datarecord.batch_size; | |
4128 | $('#batch_size').val(datarecord.batch_size); | |
4129 | $('#est_a_vol').val(datarecord.batch_size * 1.04); | |
4130 | $('#eq_tun_volume').val(datarecord.tun_volume); | |
4131 | dataRecord.eq_tun_weight = datarecord.tun_weight; | |
4132 | dataRecord.eq_tun_specific_heat = datarecord.tun_specific_heat; | |
4133 | dataRecord.eq_tun_material = datarecord.tun_material; | |
4134 | dataRecord.eq_tun_height = datarecord.tun_height / 100.0; | |
4135 | $('#eq_top_up_water').val(datarecord.top_up_water); | |
4136 | dataRecord.eq_trub_chiller_loss = datarecord.trub_chiller_loss; | |
4137 | $('#eq_trub_chiller_loss').val(datarecord.trub_chiller_loss); | |
4138 | $('#eq_evap_rate').val(datarecord.evap_rate); | |
4139 | $('#eq_boil_time').val(datarecord.boil_time); | |
4140 | dataRecord.eq_calc_boil_volume = datarecord.calc_boil_volume; | |
4141 | $('#eq_top_up_kettle').val(datarecord.top_up_kettle); | |
4142 | $('#eq_hop_utilization').val(datarecord.hop_utilization); | |
4143 | $('#eq_notes').val(datarecord.notes); | |
4144 | $('#eq_lauter_volume').val(datarecord.lauter_volume); | |
4145 | dataRecord.eq_lauter_height = datarecord.lauter_height / 100.0; | |
4146 | $('#eq_lauter_deadspace').val(datarecord.lauter_deadspace); | |
4147 | $('#eq_kettle_volume').val(datarecord.kettle_volume); | |
4148 | dataRecord.eq_kettle_height = datarecord.kettle_height / 100.0; | |
4149 | $('#eq_mash_volume').val(datarecord.mash_volume); | |
4150 | $('#eq_mash_max').val(datarecord.mash_max); | |
4151 | dataRecord.eq_mash_max = datarecord.mash_max; | |
4152 | $('#mash_max').val(datarecord.mash_max); | |
4153 | $('#eq_efficiency').val(datarecord.efficiency); | |
4154 | dataRecord.efficiency = datarecord.efficiency; | |
4155 | $('#efficiency').val(datarecord.efficiency); | |
4156 | ||
4157 | dataRecord.sparge_volume = Math.round(datarecord.boil_size * 5) / 10; | |
4158 | $('#sparge_volume').val(dataRecord.sparge_volume); | |
4159 | $('#brew_sparge_volume').val(dataRecord.sparge_volume); | |
4160 | $('#est_pre_vol').val(datarecord.boil_size * 1.04); | |
4161 | calcFermentablesFromOG(parseFloat($('#est_og').jqxNumberInput('decimal'))); // Keep the OG | |
4162 | adjustWaters(factor); | |
4163 | calcFermentables(); | |
4164 | adjustHops(factor); | |
4165 | adjustMiscs(factor); | |
4166 | adjustYeasts(factor); | |
4167 | calcIBUs(); | |
4168 | calcWater(); | |
4169 | calcSparge(); | |
4170 | } | |
4171 | }); | |
4172 | ||
489
18e5cfe5d126
Load new url in database write callback
Michiel Broek <mbroek@mbse.eu>
parents:
484
diff
changeset
|
4173 | function saveRecord(goback) { |
478 | 4174 | var row = { |
4175 | record: my_record, | |
4176 | uuid: dataRecord.uuid, | |
4177 | name: $('#name').val(), | |
4178 | code: $('#code').val(), | |
4179 | birth: $('#birth').val(), | |
4180 | stage: dataRecord.stage, | |
4181 | notes: $('#notes').val(), | |
4182 | log_brew: dataRecord.log_brew, | |
4183 | log_fermentation: dataRecord.log_fermentation, | |
4184 | inventory_reduced: dataRecord.inventory_reduced, | |
4185 | locked: dataRecord.locked, | |
4186 | eq_name: $('#eq_name').val(), | |
4187 | eq_boil_size: parseFloat($('#eq_boil_size').jqxNumberInput('decimal')), | |
4188 | eq_batch_size: parseFloat($('#eq_batch_size').jqxNumberInput('decimal')), | |
4189 | eq_tun_volume: parseFloat($('#eq_tun_volume').jqxNumberInput('decimal')), | |
4190 | eq_tun_weight: dataRecord.eq_tun_weight, | |
4191 | eq_tun_specific_heat: dataRecord.eq_tun_specific_heat, | |
4192 | eq_tun_material: dataRecord.eq_tun_material, | |
4193 | eq_tun_height: dataRecord.eq_tun_height, | |
4194 | eq_top_up_water: parseFloat($('#eq_top_up_water').jqxNumberInput('decimal')), | |
4195 | eq_trub_chiller_loss: parseFloat($('#eq_trub_chiller_loss').jqxNumberInput('decimal')), | |
4196 | eq_evap_rate: parseFloat($('#eq_evap_rate').jqxNumberInput('decimal')), | |
4197 | eq_boil_time: parseFloat($('#eq_boil_time').jqxNumberInput('decimal')), | |
4198 | eq_calc_boil_volume: dataRecord.eq_calc_boil_volume, | |
4199 | eq_top_up_kettle: parseFloat($('#eq_top_up_kettle').jqxNumberInput('decimal')), | |
4200 | eq_hop_utilization: parseFloat($('#eq_hop_utilization').jqxNumberInput('decimal')), | |
4201 | eq_notes: $('#eq_notes').val(), | |
4202 | eq_lauter_volume: parseFloat($('#eq_lauter_volume').jqxNumberInput('decimal')), | |
4203 | eq_lauter_height: dataRecord.eq_lauter_height, | |
4204 | eq_lauter_deadspace: parseFloat($('#eq_lauter_deadspace').jqxNumberInput('decimal')), | |
4205 | eq_kettle_volume: parseFloat($('#eq_kettle_volume').jqxNumberInput('decimal')), | |
4206 | eq_kettle_height: dataRecord.eq_kettle_height, | |
4207 | eq_mash_volume: parseFloat($('#eq_mash_volume').jqxNumberInput('decimal')), | |
4208 | eq_mash_max: parseFloat($('#eq_mash_max').jqxNumberInput('decimal')), | |
4209 | eq_efficiency: parseFloat($('#eq_efficiency').jqxNumberInput('decimal')), | |
4210 | brew_date_start: $('#brew_date_start').val(), | |
4211 | brew_mash_ph: parseFloat($('#brew_mash_ph').jqxNumberInput('decimal')), | |
4212 | brew_mash_sg: parseFloat($('#brew_mash_sg').jqxNumberInput('decimal')), | |
4213 | brew_mash_efficiency: parseFloat($('#brew_mash_efficiency').jqxNumberInput('decimal')), | |
4214 | brew_sparge_est: parseFloat($('#brew_sparge_est').jqxNumberInput('decimal')), | |
4215 | brew_sparge_ph: parseFloat($('#brew_sparge_ph').jqxNumberInput('decimal')), | |
4216 | brew_preboil_volume: parseFloat($('#brew_preboil_volume').jqxNumberInput('decimal')), | |
4217 | brew_preboil_sg: parseFloat($('#brew_preboil_sg').jqxNumberInput('decimal')), | |
4218 | brew_preboil_ph: parseFloat($('#brew_preboil_ph').jqxNumberInput('decimal')), | |
4219 | brew_preboil_efficiency: parseFloat($('#brew_preboil_efficiency').jqxNumberInput('decimal')), | |
4220 | brew_aboil_volume: parseFloat($('#brew_aboil_volume').jqxNumberInput('decimal')), | |
4221 | brew_aboil_sg: parseFloat($('#brew_aboil_sg').jqxNumberInput('decimal')), | |
4222 | brew_aboil_ph: parseFloat($('#brew_aboil_ph').jqxNumberInput('decimal')), | |
4223 | brew_aboil_efficiency: parseFloat($('#brew_aboil_efficiency').jqxNumberInput('decimal')), | |
4224 | brew_cooling_method: $('#brew_cooling_method').val(), | |
4225 | brew_cooling_time: parseFloat($('#brew_cooling_time').jqxNumberInput('decimal')), | |
4226 | brew_cooling_to: parseFloat($('#brew_cooling_to').jqxNumberInput('decimal')), | |
4227 | brew_whirlpool9: parseFloat($('#brew_whirlpool9').jqxNumberInput('decimal')), | |
4228 | brew_whirlpool7: parseFloat($('#brew_whirlpool7').jqxNumberInput('decimal')), | |
4229 | brew_whirlpool6: parseFloat($('#brew_whirlpool6').jqxNumberInput('decimal')), | |
4230 | brew_whirlpool2: parseFloat($('#brew_whirlpool2').jqxNumberInput('decimal')), | |
4231 | brew_fermenter_volume: parseFloat($('#brew_fermenter_volume').jqxNumberInput('decimal')), | |
4232 | brew_fermenter_extrawater: parseFloat($('#brew_fermenter_extrawater').jqxNumberInput('decimal')), | |
4233 | brew_fermenter_tcloss: parseFloat($('#brew_fermenter_tcloss').jqxNumberInput('decimal')), | |
4234 | brew_aeration_time: parseFloat($('#brew_aeration_time').jqxNumberInput('decimal')), | |
4235 | brew_aeration_speed: parseFloat($('#brew_aeration_speed').jqxNumberInput('decimal')), | |
4236 | brew_aeration_type: $('#brew_aeration_type').val(), | |
4237 | brew_fermenter_sg: parseFloat($('#brew_fermenter_sg').jqxNumberInput('decimal')), | |
4238 | brew_fermenter_ibu: parseFloat($('#brew_fermenter_ibu').jqxNumberInput('decimal')), | |
4239 | brew_fermenter_color: parseFloat($('#brew_fermenter_color').jqxNumberInput('decimal')), | |
4240 | brew_date_end: $('#brew_date_end').val(), | |
4241 | og: dataRecord.og, | |
4242 | fg: parseFloat($('#fg').jqxNumberInput('decimal')), | |
4243 | primary_start_temp: parseFloat($('#primary_start_temp').jqxNumberInput('decimal')), | |
4244 | primary_max_temp: parseFloat($('#primary_max_temp').jqxNumberInput('decimal')), | |
4245 | primary_end_temp: parseFloat($('#primary_end_temp').jqxNumberInput('decimal')), | |
4246 | primary_end_sg: parseFloat($('#primary_end_sg').jqxNumberInput('decimal')), | |
4247 | primary_end_date: $('#primary_end_date').val(), | |
4248 | secondary_temp: parseFloat($('#secondary_temp').jqxNumberInput('decimal')), | |
4249 | secondary_end_sg: parseFloat($('#secondary_end_sg').jqxNumberInput('decimal')), | |
4250 | secondary_end_date: $('#secondary_end_date').val(), | |
4251 | tertiary_temp: parseFloat($('#tertiary_temp').jqxNumberInput('decimal')), | |
4252 | package_date: $('#package_date').val(), | |
4253 | package_volume: parseFloat($('#package_volume').jqxNumberInput('decimal')), | |
4254 | package_infuse_amount: parseFloat($('#package_infuse_amount').jqxNumberInput('decimal')), | |
4255 | package_infuse_abv: parseFloat($('#package_infuse_abv').jqxNumberInput('decimal')), | |
4256 | package_infuse_notes: $('#package_infuse_notes').val(), | |
4257 | package_abv: parseFloat($('#package_abv').jqxNumberInput('decimal')), | |
4258 | package_ph: parseFloat($('#package_ph').jqxNumberInput('decimal')), | |
4259 | bottle_amount: parseFloat($('#bottle_amount').jqxNumberInput('decimal')), | |
4260 | bottle_carbonation: parseFloat($('#bottle_carbonation').jqxNumberInput('decimal')), | |
4261 | bottle_priming_water: parseFloat($('#bottle_priming_water').jqxNumberInput('decimal')), | |
4262 | bottle_priming_amount: parseFloat($('#bottle_priming_amount').jqxNumberInput('decimal')), | |
4263 | bottle_carbonation_temp: parseFloat($('#bottle_carbonation_temp').jqxNumberInput('decimal')), | |
4264 | keg_amount: parseFloat($('#keg_amount').jqxNumberInput('decimal')), | |
4265 | keg_carbonation: parseFloat($('#keg_carbonation').jqxNumberInput('decimal')), | |
4266 | keg_priming_water: parseFloat($('#keg_priming_water').jqxNumberInput('decimal')), | |
4267 | keg_priming_amount: parseFloat($('#keg_priming_amount').jqxNumberInput('decimal')), | |
4268 | keg_carbonation_temp: parseFloat($('#keg_carbonation_temp').jqxNumberInput('decimal')), | |
4269 | keg_forced_carb: dataRecord.keg_forced_carb, | |
4270 | keg_pressure: parseFloat($('#keg_pressure').jqxNumberInput('decimal')), | |
4271 | taste_notes: $('#taste_notes').val(), | |
4272 | taste_rate: parseFloat($('#taste_rate').jqxNumberInput('decimal')), | |
4273 | taste_date: $('#taste_date').val(), | |
4274 | taste_color: $('#taste_color').val(), | |
4275 | taste_transparency: $('#taste_transparency').val(), | |
4276 | taste_head: $('#taste_head').val(), | |
4277 | taste_aroma: $('#taste_aroma').val(), | |
4278 | taste_taste: $('#taste_taste').val(), | |
4279 | taste_mouthfeel: $('#taste_mouthfeel').val(), | |
4280 | taste_aftertaste: $('#taste_aftertaste').val(), | |
4281 | st_name: $('#st_name').val(), | |
4282 | st_letter: $('#st_letter').val(), | |
4283 | st_guide: $('#st_guide').val(), | |
4284 | st_type: dataRecord.st_type, | |
4285 | st_category: $('#st_category').val(), | |
4286 | st_category_number: parseFloat($('#st_category_number').jqxNumberInput('decimal')), | |
4287 | st_og_min: parseFloat($('#st_og_min').jqxNumberInput('decimal')), | |
4288 | st_og_max: parseFloat($('#st_og_max').jqxNumberInput('decimal')), | |
4289 | st_fg_min: parseFloat($('#st_fg_min').jqxNumberInput('decimal')), | |
4290 | st_fg_max: parseFloat($('#st_fg_max').jqxNumberInput('decimal')), | |
4291 | st_ibu_min: parseFloat($('#st_ibu_min').jqxNumberInput('decimal')), | |
4292 | st_ibu_max: parseFloat($('#st_ibu_max').jqxNumberInput('decimal')), | |
4293 | st_color_min: parseFloat($('#st_color_min').jqxNumberInput('decimal')), | |
4294 | st_color_max: parseFloat($('#st_color_max').jqxNumberInput('decimal')), | |
4295 | st_carb_min: parseFloat($('#st_carb_min').jqxNumberInput('decimal')), | |
4296 | st_carb_max: parseFloat($('#st_carb_max').jqxNumberInput('decimal')), | |
4297 | st_abv_min: parseFloat($('#st_abv_min').jqxNumberInput('decimal')), | |
4298 | st_abv_max: parseFloat($('#st_abv_max').jqxNumberInput('decimal')), | |
4299 | type: $('#type').val(), | |
4300 | batch_size: parseFloat($('#batch_size').jqxNumberInput('decimal')), | |
4301 | boil_size: parseFloat($('#boil_size').jqxNumberInput('decimal')), | |
4302 | boil_time: parseFloat($('#boil_time').jqxNumberInput('decimal')), | |
4303 | efficiency: parseFloat($('#efficiency').jqxNumberInput('decimal')), | |
4304 | est_og: parseFloat($('#est_og').jqxNumberInput('decimal')), | |
4305 | est_fg: parseFloat($('#est_fg').jqxNumberInput('decimal')), | |
4306 | est_abv: parseFloat($('#est_abv').jqxNumberInput('decimal')), | |
4307 | est_color: parseFloat($('#est_color').jqxNumberInput('decimal')), | |
4308 | color_method: $('#color_method').val(), | |
4309 | est_ibu: parseFloat($('#est_ibu').jqxNumberInput('decimal')), | |
4310 | ibu_method: $('#ibu_method').val(), | |
4311 | est_carb: parseFloat($('#est_carb').jqxNumberInput('decimal')), | |
4312 | mash_name: $('#mash_name').val(), | |
4313 | mash_ph: parseFloat($('#mash_ph').jqxNumberInput('decimal')), | |
4314 | sparge_temp: parseFloat($('#sparge_temp').jqxNumberInput('decimal')), | |
4315 | sparge_ph: parseFloat($('#sparge_ph').jqxNumberInput('decimal')), | |
4316 | sparge_volume: parseFloat($('#sparge_volume').jqxNumberInput('decimal')), | |
4317 | sparge_source: $('#sparge_source').val(), | |
4318 | sparge_acid_type: $('#sparge_acid_type').val(), | |
4319 | sparge_acid_perc: parseFloat($('#sparge_acid_perc').jqxNumberInput('decimal')), | |
4320 | sparge_acid_amount: dataRecord.sparge_acid_amount, | |
4321 | calc_acid: dataRecord.calc_acid, | |
4322 | w1_name: $('#w1_name').val(), | |
4323 | w1_amount: parseFloat($('#w1_amount').jqxNumberInput('decimal')), | |
4324 | w1_calcium: parseFloat($('#w1_calcium').jqxNumberInput('decimal')), | |
4325 | w1_sulfate: parseFloat($('#w1_sulfate').jqxNumberInput('decimal')), | |
4326 | w1_chloride: parseFloat($('#w1_chloride').jqxNumberInput('decimal')), | |
4327 | w1_sodium: parseFloat($('#w1_sodium').jqxNumberInput('decimal')), | |
4328 | w1_magnesium: parseFloat($('#w1_magnesium').jqxNumberInput('decimal')), | |
4329 | w1_total_alkalinity: parseFloat($('#w1_total_alkalinity').jqxNumberInput('decimal')), | |
4330 | w1_ph: parseFloat($('#w1_ph').jqxNumberInput('decimal')), | |
4331 | w1_cost: dataRecord.w1_cost, | |
4332 | w2_name: $('#w2_name').val(), | |
4333 | w2_amount: parseFloat($('#w2_amount').jqxNumberInput('decimal')), | |
4334 | w2_calcium: parseFloat($('#w2_calcium').jqxNumberInput('decimal')), | |
4335 | w2_sulfate: parseFloat($('#w2_sulfate').jqxNumberInput('decimal')), | |
4336 | w2_chloride: parseFloat($('#w2_chloride').jqxNumberInput('decimal')), | |
4337 | w2_sodium: parseFloat($('#w2_sodium').jqxNumberInput('decimal')), | |
4338 | w2_magnesium: parseFloat($('#w2_magnesium').jqxNumberInput('decimal')), | |
4339 | w2_total_alkalinity: parseFloat($('#w2_total_alkalinity').jqxNumberInput('decimal')), | |
4340 | w2_ph: parseFloat($('#w2_ph').jqxNumberInput('decimal')), | |
4341 | w2_cost: dataRecord.w2_cost, | |
4342 | wg_amount: parseFloat($('#wg_amount').jqxNumberInput('decimal')), | |
4343 | wg_calcium: parseFloat($('#wg_calcium').jqxNumberInput('decimal')), | |
4344 | wg_sulfate: parseFloat($('#wg_sulfate').jqxNumberInput('decimal')), | |
4345 | wg_chloride: parseFloat($('#wg_chloride').jqxNumberInput('decimal')), | |
4346 | wg_sodium: parseFloat($('#wg_sodium').jqxNumberInput('decimal')), | |
4347 | wg_magnesium: parseFloat($('#wg_magnesium').jqxNumberInput('decimal')), | |
4348 | wg_total_alkalinity: parseFloat($('#wg_total_alkalinity').jqxNumberInput('decimal')), | |
4349 | wg_ph: parseFloat($('#wg_ph').jqxNumberInput('decimal')), | |
4350 | wb_calcium: parseFloat($('#wb_calcium').jqxNumberInput('decimal')), | |
4351 | wb_sulfate: parseFloat($('#wb_sulfate').jqxNumberInput('decimal')), | |
4352 | wb_chloride: parseFloat($('#wb_chloride').jqxNumberInput('decimal')), | |
4353 | wb_sodium: parseFloat($('#wb_sodium').jqxNumberInput('decimal')), | |
4354 | wb_magnesium: parseFloat($('#wb_magnesium').jqxNumberInput('decimal')), | |
4355 | wb_total_alkalinity: parseFloat($('#wb_total_alkalinity').jqxNumberInput('decimal')), | |
4356 | wb_ph: parseFloat($('#wb_ph').jqxNumberInput('decimal')), | |
4357 | wa_acid_name: $('#wa_acid_name').val(), | |
4358 | wa_acid_perc: parseFloat($('#wa_acid_perc').jqxNumberInput('decimal')), | |
4359 | wa_base_name: $('#wa_base_name').val(), | |
4360 | starter_enable: dataRecord.starter_enable, | |
4361 | starter_type: $('#starter_type').val(), | |
4362 | starter_sg: parseFloat($('#starter_sg').jqxNumberInput('decimal')), | |
4363 | starter_viability: parseFloat($('#starter_viability').jqxNumberInput('decimal')), | |
4364 | prop1_type: $('#prop1_type').val(), | |
4365 | prop1_volume: parseFloat($('#prop1_volume').jqxNumberInput('decimal')), | |
4366 | prop2_type: $('#prop2_type').val(), | |
4367 | prop2_volume: parseFloat($('#prop2_volume').jqxNumberInput('decimal')), | |
4368 | prop3_type: $('#prop3_type').val(), | |
4369 | prop3_volume: parseFloat($('#prop3_volume').jqxNumberInput('decimal')), | |
4370 | prop4_type: $('#prop4_type').val(), | |
4371 | prop4_volume: parseFloat($('#prop4_volume').jqxNumberInput('decimal')), | |
4372 | fermentables: $('#fermentableGrid').jqxGrid('getrows'), | |
4373 | hops: $('#hopGrid').jqxGrid('getrows'), | |
4374 | miscs: $('#miscGrid').jqxGrid('getrows'), | |
4375 | yeasts: $('#yeastGrid').jqxGrid('getrows'), | |
4376 | mashs: $('#mashGrid').jqxGrid('getrows') | |
4377 | }, | |
4378 | data = 'update=true&' + $.param(row); | |
4379 | $.ajax({ | |
4380 | dataType: 'json', | |
4381 | url: url, | |
4382 | cache: false, | |
4383 | data: data, | |
4384 | async: false, | |
4385 | type: 'POST', | |
4386 | success: function(data, status, xhr) { | |
489
18e5cfe5d126
Load new url in database write callback
Michiel Broek <mbroek@mbse.eu>
parents:
484
diff
changeset
|
4387 | console.log('saveRecord(' + goback + ') success'); |
18e5cfe5d126
Load new url in database write callback
Michiel Broek <mbroek@mbse.eu>
parents:
484
diff
changeset
|
4388 | if (goback) |
18e5cfe5d126
Load new url in database write callback
Michiel Broek <mbroek@mbse.eu>
parents:
484
diff
changeset
|
4389 | window.location.href = my_return; |
18e5cfe5d126
Load new url in database write callback
Michiel Broek <mbroek@mbse.eu>
parents:
484
diff
changeset
|
4390 | else |
18e5cfe5d126
Load new url in database write callback
Michiel Broek <mbroek@mbse.eu>
parents:
484
diff
changeset
|
4391 | window.location.href = |
18e5cfe5d126
Load new url in database write callback
Michiel Broek <mbroek@mbse.eu>
parents:
484
diff
changeset
|
4392 | 'prod_export.php?record=' + my_record + '&return=' + my_return + '&select=' + my_select + '&code=' + dataRecord.code + '&name=' + dataRecord.name; |
478 | 4393 | }, |
4394 | error: function(jqXHR, textStatus, errorThrown) { | |
489
18e5cfe5d126
Load new url in database write callback
Michiel Broek <mbroek@mbse.eu>
parents:
484
diff
changeset
|
4395 | console.log('saveRecord() ' + textStatus); |
478 | 4396 | } |
4397 | }); | |
4398 | }; | |
4399 | ||
4400 | dataAdapter.dataBind(); | |
4401 | ||
4402 | // initialize the input fields. | |
4403 | // Tab 1, Algemeen | |
4404 | $('#name').jqxTooltip({ content: 'De naam voor dit product.' }); | |
4405 | $('#name').jqxInput({ theme: theme, width: 640, height: 23 }); | |
4406 | $('#code').jqxTooltip({ content: 'Product code nummer.' }); | |
4407 | $('#code').jqxInput({ theme: theme, width: 100, height: 23 }); | |
4408 | $('#birth').jqxTooltip({ content: 'De ontwerp datum van dit product.' }); | |
4409 | $('#birth').jqxInput({ theme: theme, width: 120, height: 23 }); | |
4410 | $('#stage').jqxTooltip({ content: 'De productie fase van dit product.' }); | |
4411 | $('#stage').jqxInput({ theme: theme, width: 100, height: 23 }); | |
4412 | $('#locked').jqxCheckBox({ theme: theme, width: 120, height: 23, disabled: true }); | |
4413 | $('#locked').on('checked', function(event) { | |
4414 | if (dataRecord.stage >= 10) { | |
4415 | dataRecord.locked = 1; | |
4416 | dataRecord.stage = 11; | |
4417 | calcStage(); | |
4418 | } | |
4419 | }); | |
4420 | $('#locked').on('unchecked', function(event) { | |
4421 | if (dataRecord.stage >= 10) { | |
4422 | dataRecord.locked = 0; | |
4423 | dataRecord.stage = 10; | |
4424 | calcStage(); | |
4425 | } | |
4426 | }); | |
4427 | $('#notes').jqxTooltip({ content: 'De uitgebreide opmerkingen over dit product.' }); | |
4428 | $('#notes').jqxInput({ theme: theme, width: 960, height: 100 }); | |
4429 | $('#type').jqxTooltip({ content: 'Het brouw type van dit recept.' }); | |
4430 | $('#type').jqxDropDownList({ | |
4431 | theme: theme, | |
4432 | source: RecipeTypeAdapter, | |
4433 | valueMember: 'id', | |
4434 | displayMember: 'nl', | |
4435 | width: 180, | |
4436 | height: 23, | |
4437 | autoDropDownHeight: true | |
4438 | }); | |
4439 | $('#efficiency').jqxTooltip({ content: 'Het rendement van maischen en koken.' }); | |
4440 | $('#efficiency').jqxNumberInput(Perc1dec); | |
4441 | $('#batch_size').jqxTooltip({ content: 'Het volume van het gekoelde wort na het koken.' }); | |
4442 | $('#batch_size').jqxNumberInput(Spin1dec); | |
4443 | $('#batch_size').jqxNumberInput({ min: 4 }); | |
4444 | $('#boil_time').jqxTooltip({ content: 'De kooktijd in minuten.' }); | |
4445 | $('#boil_time').jqxNumberInput(PosInt); | |
4446 | $('#boil_time').jqxNumberInput({ min: 4, max: 360 }); | |
4447 | $('#boil_size').jqxTooltip({ content: 'Het volume van het wort voor het koken.' }); | |
4448 | $('#boil_size').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 2, readOnly: true }); | |
4449 | ||
4450 | $('#st_guide').jqxTooltip({ content: 'De bierstijl gids voor dit recept.'}); | |
4451 | $('#st_guide').jqxInput({ theme: theme, width: 250, height: 23 }); | |
4452 | $('#st_name').jqxTooltip({ content: 'De bierstijl naam voor dit recept.'}); | |
4453 | $('#st_name').jqxInput({ theme: theme, width: 250, height: 23 }); | |
4454 | $('#st_letter').jqxTooltip({ content: 'De bierstijl letter voor dit recept.'}); | |
4455 | $('#st_letter').jqxInput({ theme: theme, width: 90, height: 23 }); | |
4456 | $('#st_type').jqxTooltip({ content: 'Het bierstijl type.'}); | |
4457 | $('#st_type').jqxInput({ theme: theme, width: 250, height: 23 }); | |
4458 | $('#st_category').jqxTooltip({ content: 'De Amerikaanse bierstijl categorie.'}); | |
4459 | $('#st_category').jqxInput({ theme: theme, width: 250, height: 23 }); | |
4460 | $('#st_category_number').jqxTooltip({ content: 'De Amerikaanse bierstijl categorie sub nummer.'}); | |
4461 | $('#st_category_number').jqxNumberInput(Smal0dec); | |
4462 | ||
4463 | $('#est_og').jqxTooltip({ content: 'Het begin SG wat je wilt bereiken. De moutstort wordt automatisch herberekend.' }); | |
4464 | $('#est_og').jqxNumberInput(SGopts); | |
4465 | $('#st_og_min').jqxTooltip({ content: 'Het minimum begin SG voor deze bierstijl.'}); | |
4466 | $('#st_og_min').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); | |
4467 | $('#st_og_max').jqxTooltip({ content: 'Het maximum begin SG voor deze bierstijl.'}); | |
4468 | $('#st_og_max').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); | |
4469 | ||
4470 | $('#est_fg').jqxTooltip({ content: 'Het verwachte eind SG. Dit wordt automatisch berekend.' }); | |
4471 | $('#est_fg').jqxNumberInput(Show3dec); | |
4472 | $('#st_fg_min').jqxTooltip({ content: 'Het minimum eind SG voor deze bierstijl.'}); | |
4473 | $('#st_fg_min').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); | |
4474 | $('#st_fg_max').jqxTooltip({ content: 'Het maximum eind SG voor deze bierstijl.'}); | |
4475 | $('#st_fg_max').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); | |
4476 | ||
4477 | $('#est_abv').jqxTooltip({ content: 'Alcohol volume %. Dit wordt automatisch berekend.' }); | |
4478 | $('#est_abv').jqxNumberInput(Smal1dec); | |
4479 | $('#st_abv_min').jqxTooltip({ content: 'Het minimum alcohol volume % voor deze bierstijl.'}); | |
4480 | $('#st_abv_min').jqxNumberInput(Smal1dec); | |
4481 | $('#st_abv_max').jqxTooltip({ content: 'Het maximum alcohol volume % voor deze bierstijl.'}); | |
4482 | $('#st_abv_max').jqxNumberInput(Smal1dec); | |
4483 | ||
4484 | $('#est_color').jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' }); | |
4485 | $('#est_color').jqxNumberInput(Show0dec); | |
4486 | $('#st_color_min').jqxTooltip({ content: 'De minimum kleur voor deze bierstijl.'}); | |
4487 | $('#st_color_min').jqxNumberInput(Smal0dec); | |
4488 | $('#st_color_max').jqxTooltip({ content: 'De maximum kleur voor deze bierstijl.'}); | |
4489 | $('#st_color_max').jqxNumberInput(Smal0dec); | |
4490 | $('#color_method').jqxDropDownList({ | |
4491 | theme: theme, | |
4492 | source: ColorMethodAdapter, | |
4493 | valueMember: 'id', | |
4494 | displayMember: 'nl', | |
4495 | width: 180, | |
4496 | height: 23, | |
4497 | autoDropDownHeight: true | |
4498 | }); | |
4499 | $('#est_ibu').jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' }); | |
4500 | $('#est_ibu').jqxNumberInput(Show0dec); | |
4501 | $('#st_ibu_min').jqxTooltip({ content: 'De minimum bitterheid voor deze bierstijl.'}); | |
4502 | $('#st_ibu_min').jqxNumberInput(Smal0dec); | |
4503 | $('#st_ibu_max').jqxTooltip({ content: 'De maximum bitterheid voor deze bierstijl.'}); | |
4504 | $('#st_ibu_max').jqxNumberInput(Smal0dec); | |
4505 | $('#ibu_method').jqxDropDownList({ | |
4506 | theme: theme, | |
4507 | source: IBUmethodAdapter, | |
4508 | valueMember: 'id', | |
4509 | displayMember: 'nl', | |
4510 | width: 180, | |
4511 | height: 23, | |
4512 | autoDropDownHeight: true, | |
4513 | dropDownVerticalAlignment: 'top' | |
4514 | }); | |
4515 | $('#kcal').jqxTooltip({ content: 'Energie-inhoud in kcal/liter.' }); | |
4516 | $('#kcal').jqxNumberInput(Smal0dec); | |
4517 | $('#est_carb').jqxTooltip({ content: 'Koolzuur volume. Dit wordt automatisch berekend.' }); | |
4518 | $('#est_carb').jqxNumberInput(Smal1dec); | |
4519 | $('#st_carb_min').jqxTooltip({ content: 'Het minimum koolzuur volume voor deze bierstijl.'}); | |
4520 | $('#st_carb_min').jqxNumberInput(Smal1dec); | |
4521 | $('#st_carb_max').jqxTooltip({ content: 'Het maximum koolzuur volume voor deze bierstijl.'}); | |
4522 | $('#st_carb_max').jqxNumberInput(Smal1dec); | |
4523 | ||
4524 | // Tab 2, Equipment | |
4525 | $('#eq_name').jqxTooltip({ content: 'De naam van deze brouw apparatuur.' }); | |
4526 | $('#eq_name').jqxInput({ theme: theme, width: 250, height: 23 }); | |
4527 | $('#eq_boil_size').jqxTooltip({ content: 'Normaal kook volume in liters' }); | |
4528 | $('#eq_boil_size').jqxNumberInput(Show1dec); | |
4529 | $('#eq_batch_size').jqxTooltip({ content: 'Berekende batch grootte in liters aan het eind van de kook.' }); | |
4530 | $('#eq_batch_size').jqxNumberInput(Show1dec); | |
4531 | $('#eq_tun_volume').jqxTooltip({ content: 'Maisch ketel volume.' }); | |
4532 | $('#eq_tun_volume').jqxNumberInput(Show1dec); | |
4533 | $('#eq_top_up_water').jqxTooltip({ content: 'Extra water in het gistvat.' }); | |
4534 | $('#eq_top_up_water').jqxNumberInput(Show1dec); | |
4535 | $('#eq_trub_chiller_loss').jqxTooltip({ content: 'Standaard verlies bij het overbrengen naar het gistvat.' }); | |
4536 | $('#eq_trub_chiller_loss').jqxNumberInput(Show1dec); | |
4537 | $('#eq_evap_rate').jqxTooltip({ content: 'Verdamping in liters per uur.' }); | |
4538 | $('#eq_evap_rate').jqxNumberInput(Show2dec); | |
4539 | $('#eq_boil_time').jqxTooltip({ content: 'Normale kooktijd in minuten.' }); | |
4540 | $('#eq_boil_time').jqxNumberInput(Show0dec); | |
4541 | $('#eq_top_up_kettle').jqxTooltip({ content: 'Extra water toevoegen tijdens de kook.' }); | |
4542 | $('#eq_top_up_kettle').jqxNumberInput(Show1dec); | |
4543 | $('#eq_hop_utilization').jqxTooltip({ content: '100% voor kleine installaties, hoger voor grote brouwerijen.' }); | |
4544 | $('#eq_hop_utilization').jqxNumberInput(Show0dec); | |
4545 | $('#eq_notes').jqxTooltip({ content: 'Opmerkingen over deze apparatuur.' }); | |
4546 | $('#eq_notes').jqxInput({ theme: theme, width: 960, height: 200 }); | |
4547 | $('#eq_lauter_volume').jqxTooltip({ content: 'Filterkuip volume.' }); | |
4548 | $('#eq_lauter_volume').jqxNumberInput(Show1dec); | |
4549 | $('#eq_lauter_deadspace').jqxTooltip({ content: 'Filterkuip verlies in liters.' }); | |
4550 | $('#eq_lauter_deadspace').jqxNumberInput(Show1dec); | |
4551 | $('#eq_kettle_volume').jqxTooltip({ content: 'Kook ketel volume in liters.' }); | |
4552 | $('#eq_kettle_volume').jqxNumberInput(Show1dec); | |
4553 | $('#eq_mash_volume').jqxTooltip({ content: 'Maisch water voor de eerste stap.' }); | |
4554 | $('#eq_mash_volume').jqxNumberInput(Show1dec); | |
4555 | $('#eq_mash_max').jqxTooltip({ content: 'De maximale moutstort in Kg.' }); | |
4556 | $('#eq_mash_max').jqxNumberInput(Show1dec); | |
4557 | $('#eq_efficiency').jqxTooltip({ content: 'Gemiddeld brouwzaal rendement.' }); | |
4558 | $('#eq_efficiency').jqxNumberInput(Show1dec); | |
4559 | ||
4560 | // Tab 3, Fermentables | |
4561 | $('#est_color2').jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' }); | |
4562 | $('#est_color2').jqxNumberInput(Show0dec); | |
4563 | $('#est_og2').jqxTooltip({ content: 'Het geschatte begin SG van dit product.' }); | |
4564 | $('#est_og2').jqxNumberInput(Show3dec); | |
4565 | $('#mash_kg').jqxTooltip({ content: 'Het gewicht van alle mouten in de maisch.' }); | |
4566 | $('#mash_kg').jqxNumberInput(Show3dec); | |
4567 | $('#perc_malts').jqxProgressBar({ | |
4568 | width: 300, | |
4569 | height: 23, | |
4570 | theme: theme, | |
4571 | showText: true, | |
4572 | max: 120, | |
4573 | animationDuration: 0, | |
4574 | colorRanges: [ | |
4575 | { stop: 90, color: '#008C00' }, | |
4576 | { stop: 100, color: '#EB7331' }, | |
4577 | { stop: 120, color: '#FF0000' } | |
4578 | ], | |
4579 | renderText: function(text) { | |
4580 | return (Math.round(parseInt(text) * 1.2)) + '%'; | |
4581 | } | |
4582 | }); | |
4583 | $('#perc_sugars').jqxProgressBar({ | |
4584 | width: 300, | |
4585 | height: 23, | |
4586 | theme: theme, | |
4587 | showText: true, | |
4588 | max: 50, | |
4589 | animationDuration: 0, | |
4590 | colorRanges: [ | |
4591 | { stop: 20, color: '#008C00' }, | |
4592 | { stop: 50, color: '#FF0000' } | |
4593 | ], | |
4594 | renderText: function(text) { | |
4595 | return (Math.round(parseInt(text) * 5) / 10) + '%'; | |
4596 | } | |
4597 | }); | |
4598 | $('#perc_cara').jqxProgressBar({ | |
4599 | width: 300, | |
4600 | height: 23, | |
4601 | theme: theme, | |
4602 | showText: true, | |
4603 | max: 50, | |
4604 | animationDuration: 0, | |
4605 | colorRanges: [ | |
4606 | { stop: 25, color: '#008C00' }, | |
4607 | { stop: 50, color: '#FF0000' } | |
4608 | ], | |
4609 | renderText: function(text) { | |
4610 | return (Math.round(parseInt(text) * 5) / 10) + '%'; | |
4611 | } | |
4612 | }); | |
4613 | $('#ferm_lintner').jqxProgressBar({ | |
4614 | width: 300, | |
4615 | height: 23, | |
4616 | theme: theme, | |
4617 | showText: true, | |
4618 | max: 200, | |
4619 | animationDuration: 0, | |
4620 | colorRanges: [ | |
4621 | { stop: 30, color: '#FF0000' }, | |
4622 | { stop: 40, color: '#EB7331' }, | |
4623 | { stop: 200, color: '#008C00' } | |
4624 | ], | |
4625 | renderText: function(text) { | |
4626 | return (parseInt(text) * 2) + ' lintner'; | |
4627 | } | |
4628 | }); | |
4629 | $('#popupFermentable').jqxWindow({ | |
4630 | width: 800, | |
4631 | height: 300, | |
4632 | position: { x: 230, y: 100 }, | |
4633 | resizable: false, | |
4634 | theme: theme, | |
4635 | isModal: true, | |
4636 | autoOpen: false, | |
4637 | cancelButton: $('#FermentableReady'), | |
4638 | modalOpacity: 0.40 | |
4639 | }); | |
4640 | $('#FermentableReady').jqxButton({ template: 'success', width: '90px', theme: theme }); | |
4641 | $('#FermentableReady').click(function() { | |
4642 | var row, rowID = $('#fermentableGrid').jqxGrid('getrowid', fermentableRow); | |
4643 | console.log('FermentableReady row:' + fermentableRow + ' ID:' + rowID); | |
4644 | row = { | |
4645 | f_name: fermentableData.f_name, | |
4646 | f_origin: fermentableData.f_origin, | |
4647 | f_supplier: fermentableData.f_supplier, | |
4648 | f_amount: fermentableData.f_amount, | |
4649 | f_cost: fermentableData.f_cost, | |
4650 | f_type: fermentableData.f_type, | |
4651 | f_yield: fermentableData.f_yield, | |
4652 | f_color: fermentableData.f_color, | |
4653 | f_coarse_fine_diff: fermentableData.f_coarse_fine_diff, | |
4654 | f_moisture: fermentableData.f_moisture, | |
4655 | f_diastatic_power: fermentableData.f_diastatic_power, | |
4656 | f_protein: fermentableData.f_protein, | |
4657 | f_max_in_batch: fermentableData.f_max_in_batch, | |
4658 | f_graintype: fermentableData.f_graintype, | |
4659 | f_added: fermentableData.f_added, | |
4660 | f_dissolved_protein: fermentableData.f_dissolved_protein, | |
4661 | f_recommend_mash: fermentableData.f_recommend_mash, | |
4662 | f_add_after_boil: fermentableData.f_add_after_boil, | |
4663 | f_adjust_to_total_100: fermentableData.f_adjust_to_total_100, | |
4664 | f_percentage: fermentableData.f_percentage, | |
4665 | f_di_ph: fermentableData.f_di_ph, | |
4666 | f_acid_to_ph_57: fermentableData.f_acid_to_ph_57, | |
4667 | f_inventory: fermentableData.f_inventory, | |
4668 | f_avail: fermentableData.f_avail | |
4669 | }; | |
4670 | $('#fermentableGrid').jqxGrid('updaterow', rowID, row); | |
4671 | calcPercentages(); | |
4672 | calcFermentables(); | |
4673 | calcIBUs(); | |
4674 | calcMash(); | |
4675 | // Waters: yes there is impact. | |
4676 | }); | |
4677 | $('#wf_name').jqxInput({ theme: theme, width: 320, height: 23 }); | |
4678 | $('#wf_instock').jqxCheckBox({ theme: theme, height: 23 }); | |
4679 | $('#wf_instock').on('change', function(event) { | |
4680 | fermentableinstock = event.args.checked; | |
4681 | fermentablelist.dataBind(); | |
4682 | }); | |
4683 | $('#wf_select').jqxDropDownList({ | |
4684 | placeHolder: 'Kies mout:', | |
4685 | theme: theme, | |
4686 | source: fermentablelist, | |
4687 | displayMember: 'name', | |
4688 | width: 150, | |
4689 | height: 23, | |
4690 | dropDownWidth: 500, | |
4691 | dropDownHeight: 500, | |
4692 | renderer: function(index, label, value) { | |
4693 | var datarecord = fermentablelist.records[index]; | |
4694 | return datarecord.supplier + ' / ' + datarecord.name + ' (' + datarecord.color + ' EBC)'; | |
4695 | } | |
4696 | }); | |
4697 | $('#wf_select').on('select', function(event) { | |
4698 | if (event.args) { | |
4699 | var datarecord, index = event.args.index; | |
4700 | datarecord = fermentablelist.records[index]; | |
4701 | $('#wf_name').val(datarecord.name); | |
4702 | fermentableData.f_name = datarecord.name; | |
4703 | fermentableData.f_origin = datarecord.origin; | |
4704 | fermentableData.f_supplier = datarecord.supplier; | |
4705 | fermentableData.f_type = datarecord.type; | |
4706 | fermentableData.f_cost = datarecord.cost; | |
4707 | fermentableData.f_yield = datarecord.yield; | |
4708 | fermentableData.f_color = datarecord.color; | |
4709 | fermentableData.f_coarse_fine_diff = datarecord.coarse_fine_diff; | |
4710 | fermentableData.f_moisture = datarecord.moisture; | |
4711 | fermentableData.f_diastatic_power = datarecord.diastatic_power; | |
4712 | fermentableData.f_protein = datarecord.protein; | |
4713 | fermentableData.f_max_in_batch = datarecord.max_in_batch; | |
4714 | fermentableData.f_graintype = datarecord.graintype; | |
4715 | fermentableData.f_dissolved_protein = datarecord.dissolved_protein; | |
4716 | fermentableData.f_recommend_mash = datarecord.recommend_mash; | |
4717 | fermentableData.f_add_after_boil = datarecord.add_after_boil; | |
4718 | fermentableData.f_di_ph = datarecord.di_ph; | |
4719 | fermentableData.f_acid_to_ph_57 = datarecord.acid_to_ph_57; | |
4720 | fermentableData.f_inventory = datarecord.inventory; | |
4721 | } | |
4722 | }); | |
4723 | $('#wf_amount').jqxNumberInput(Spin3dec); | |
4724 | $('#wf_amount').on('change', function(event) { | |
4725 | console.log('amount changed: ' + event.args.value); | |
4726 | $('#fermentableGrid').jqxGrid('setcellvalue', fermentableRow, 'f_amount', event.args.value); | |
4727 | fermentableData.f_amount = event.args.value; | |
4728 | if (! to_100) { | |
4729 | calcPercentages(); | |
4730 | calcFermentables(); | |
4731 | calcIBUs(); | |
4732 | calcMash(); | |
4733 | } | |
4734 | }); | |
4735 | $('#wf_percentage').jqxNumberInput(Perc1dec); | |
4736 | $('#wf_percentage').on('change', function(event) { | |
4737 | var newvalue, rowscount, rowdata, diff, tw, damount, namount, nw, newperc, | |
4738 | oldvalue = Math.round(fermentableData.f_percentage * 10) / 10.0; | |
4739 | newvalue = event.args.value; | |
4740 | console.log('percentage changed: ' + newvalue + ' old: ' + oldvalue); | |
4741 | fermentableData.f_percent = newvalue; | |
4742 | rowscount = $('#fermentableGrid').jqxGrid('getdatainformation').rowscount; | |
4743 | if ((oldvalue != newvalue) && (rowscount > 1)) { | |
4744 | rowdata = $('#fermentableGrid').jqxGrid('getrowdata', fermentableRow); | |
4745 | if (rowdata.f_adjust_to_total_100) { | |
4746 | $('#wf_percentage').val(oldvalue); | |
4747 | } else { | |
4748 | diff = newvalue - oldvalue; | |
4749 | tw = 0; // total weight | |
4750 | for (i = 0; i < rowscount; i++) { | |
4751 | rowdata = $('#fermentableGrid').jqxGrid('getrowdata', i); | |
4752 | if (rowdata.f_added < 4) | |
4753 | tw += Math.round(rowdata.f_amount * 1000) / 1000; | |
4754 | } | |
4755 | tw = Math.round(tw * 1000) / 1000; | |
4756 | if (to_100) { | |
4757 | // Adjust this row and the 100% row. | |
4758 | damount = Math.round(tw * diff * 10) / 1000; | |
4759 | rowdata = $('#fermentableGrid').jqxGrid('getrowdata', fermentableRow); | |
4760 | namount = Round(rowdata.f_amount + damount, 3); | |
4761 | $('#fermentableGrid').jqxGrid('setcellvalue', fermentableRow, 'f_amount', namount); | |
4762 | $('#wf_amount').val(namount); | |
4763 | $('#fermentableGrid').jqxGrid('setcellvalue', fermentableRow, 'f_percentage', rowdata.f_percentage + diff); | |
4764 | for (i = 0; i < rowscount; i++) { | |
4765 | rowdata = $('#fermentableGrid').jqxGrid('getrowdata', i); | |
4766 | if (rowdata.f_adjust_to_total_100) { | |
4767 | namount = rowdata.f_amount - damount; | |
4768 | $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_percentage', rowdata.f_percentage - diff); | |
4769 | $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_amount', namount); | |
4770 | } | |
4771 | } | |
4772 | calcFermentables(); | |
4773 | calcIBUs(); | |
4774 | calcMash(); | |
4775 | } else { | |
4776 | // Adjust all the rows. | |
4777 | nw = tw * diff / 100; | |
4778 | for (i = 0; i < rowscount; i++) { | |
4779 | rowdata = $('#fermentableGrid').jqxGrid('getrowdata', i); | |
4780 | if (rowdata.f_added < 4) { | |
4781 | if (i == fermentableRow) { | |
4782 | namount = Math.round((rowdata.f_amount + nw) * 1000) / 1000; | |
4783 | $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_amount', namount); | |
4784 | // $('#wf_amount').val(namount); // Will crash the script. | |
4785 | $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_percentage', newvalue); | |
4786 | } else { | |
4787 | namount = Math.round((rowdata.f_amount - (nw / (rowscount - 1))) * 1000) / 1000; | |
4788 | newperc = Math.round((namount / tw) * 1000) / 10.0; | |
4789 | $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_amount', namount); | |
4790 | $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_percentage', newperc); | |
4791 | } | |
4792 | } else { | |
4793 | $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_percentage', 0); | |
4794 | } | |
4795 | } | |
4796 | calcFermentables(); | |
4797 | calcIBUs(); | |
4798 | calcMash(); | |
4799 | } | |
4800 | } | |
4801 | } | |
4802 | }); | |
4803 | $('#wf_max_in_batch').jqxNumberInput(Show1dec); | |
4804 | $('#wf_adjust_to_total_100').jqxCheckBox({ theme: theme, width: 120, height: 23 }); | |
4805 | $('#wf_adjust_to_total_100').on('checked', function(event) { | |
4806 | if (fermentableData.f_adjust_to_total_100 == 0) { | |
4807 | if (to_100) { | |
4808 | // Reset other flag first. | |
4809 | var i, rowscount = $('#fermentableGrid').jqxGrid('getdatainformation').rowscount; | |
4810 | for (i = 0; i < rowscount; i++) { | |
4811 | if (i != fermentableRow) { | |
4812 | $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_adjust_to_total_100', 0); | |
4813 | } | |
4814 | } | |
4815 | } | |
4816 | $('#fermentableGrid').jqxGrid('setcellvalue', fermentableRow, 'f_adjust_to_total_100', 1); | |
4817 | calcFermentables(); | |
4818 | } | |
4819 | }); | |
4820 | $('#wf_adjust_to_total_100').on('unchecked', function(event) { | |
4821 | if (fermentableData.f_adjust_to_total_100 != 0) { | |
4822 | $('#fermentableGrid').jqxGrid('setcellvalue', fermentableRow, 'f_adjust_to_total_100', 0); | |
4823 | calcFermentables(); | |
4824 | } | |
4825 | }); | |
4826 | $('#wf_added').jqxDropDownList({ | |
4827 | theme: theme, | |
4828 | source: AddedAdapter, | |
4829 | valueMember: 'id', | |
4830 | displayMember: 'nl', | |
4831 | width: 180, | |
4832 | height: 23, | |
4833 | autoDropDownHeight: true, | |
4834 | dropDownVerticalAlignment: 'top' | |
4835 | }); | |
4836 | $('#wf_added').on('select', function(event) { | |
4837 | if (event.args) { | |
4838 | var index = event.args.index; | |
4839 | $('#fermentableGrid').jqxGrid('setcellvalue', fermentableRow, 'f_added', index); | |
4840 | calcFermentables(); | |
4841 | calcIBUs(); | |
4842 | calcMash(); | |
4843 | } | |
4844 | }); | |
4845 | ||
4846 | // Tab 4, Hops | |
4847 | $('#est_ibu2').jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' }); | |
4848 | $('#est_ibu2').jqxNumberInput(Smal0dec); | |
4849 | $('#hop_flavour').jqxProgressBar({ | |
4850 | width: 300, | |
4851 | height: 23, | |
4852 | theme: theme, | |
4853 | showText: true, | |
4854 | animationDuration: 0, | |
4855 | colorRanges: [ | |
4856 | { stop: 20, color: '#004D00' }, | |
4857 | { stop: 40, color: '#008C00' }, | |
4858 | { stop: 60, color: '#00BF00' }, | |
4859 | { stop: 80, color: '#00FF00' }, | |
4860 | { stop: 100, color: '#80FF80' } | |
4861 | ], | |
4862 | renderText: function(text) { | |
4863 | var val = parseInt(text); | |
4864 | if (val < 20) | |
4865 | return 'Weinig'; | |
4866 | else if (val < 40) | |
4867 | return 'Matig'; | |
4868 | else if (val < 60) | |
4869 | return 'Redelijk'; | |
4870 | else if (val < 80) | |
4871 | return 'Veel'; | |
4872 | else | |
4873 | return 'Zeer veel'; | |
4874 | } | |
4875 | }); | |
4876 | $('#hop_aroma').jqxProgressBar({ | |
4877 | width: 300, height: 23, theme: theme, showText: true, | |
4878 | animationDuration: 0, | |
4879 | colorRanges: [ | |
4880 | { stop: 20, color: '#004D00' }, | |
4881 | { stop: 40, color: '#008C00' }, | |
4882 | { stop: 60, color: '#00BF00' }, | |
4883 | { stop: 80, color: '#00FF00' }, | |
4884 | { stop: 100, color: '#80FF80' } | |
4885 | ], | |
4886 | renderText: function(text) { | |
4887 | var val = parseInt(text); | |
4888 | if (val < 20) | |
4889 | return 'Weinig'; | |
4890 | else if (val < 40) | |
4891 | return 'Matig'; | |
4892 | else if (val < 60) | |
4893 | return 'Redelijk'; | |
4894 | else if (val < 80) | |
4895 | return 'Veel'; | |
4896 | else | |
4897 | return 'Zeer veel'; | |
4898 | } | |
4899 | }); | |
4900 | $('#popupHop').jqxWindow({ | |
4901 | width: 800, | |
4902 | height: 300, | |
4903 | position: { x: 230, y: 100 }, | |
4904 | resizable: false, | |
4905 | theme: theme, | |
4906 | isModal: true, | |
4907 | autoOpen: false, | |
4908 | cancelButton: $('#HopReady'), | |
4909 | modalOpacity: 0.40 | |
4910 | }); | |
4911 | $('#HopReady').jqxButton({ template: 'success', width: '90px', theme: theme }); | |
4912 | $('#HopReady').click(function() { | |
4913 | var row, rowID = $('#hopGrid').jqxGrid('getrowid', hopRow); | |
4914 | row = { | |
4915 | h_name: $('#wh_name').val(), | |
4916 | h_origin: hopData.h_origin, | |
4917 | h_amount: parseFloat($('#wh_amount').jqxNumberInput('decimal')) / 1000, | |
4918 | h_cost: hopData.h_cost, | |
4919 | h_type: hopData.h_type, | |
4920 | h_form: hopData.h_form, | |
4921 | h_useat: $('#wh_useat').val(), | |
4922 | h_time: hopData.h_time, | |
4923 | h_alpha: hopData.h_alpha, | |
4924 | h_beta: hopData.h_beta, | |
4925 | h_hsi: hopData.h_hsi, | |
4926 | h_humulene: hopData.h_humulene, | |
4927 | h_caryophyllene: hopData.h_caryophyllene, | |
4928 | h_cohumulone: hopData.h_cohumulone, | |
4929 | h_myrcene: hopData.h_myrcene, | |
4930 | h_total_oil: hopData.h_total_oil, | |
4931 | h_inventory: hopData.h_inventory, | |
4932 | h_avail: hopData.h_avail | |
4933 | }; | |
4934 | $('#hopGrid').jqxGrid('updaterow', rowID, row); | |
4935 | calcIBUs(); | |
4936 | }); | |
4937 | $('#wh_name').jqxInput({ theme: theme, width: 320, height: 23 }); | |
4938 | $('#wh_instock').jqxCheckBox({ theme: theme, height: 23 }); | |
4939 | $('#wh_instock').on('change', function(event) { | |
4940 | hopinstock = event.args.checked; | |
4941 | hoplist.dataBind(); | |
4942 | }); | |
4943 | $('#wh_select').jqxDropDownList({ | |
4944 | placeHolder: 'Kies hop:', | |
4945 | theme: theme, | |
4946 | source: hoplist, | |
4947 | displayMember: 'name', | |
4948 | width: 150, | |
4949 | height: 23, | |
4950 | dropDownWidth: 500, | |
4951 | dropDownHeight: 500, | |
4952 | renderer: function(index, label, value) { | |
4953 | var datarecord = hoplist.records[index]; | |
4954 | return datarecord.origin + ' - ' + datarecord.name + ' / ' + HopFormData[datarecord.form].nl + ' (' + datarecord.alpha + ' % α)'; | |
4955 | } | |
4956 | }); | |
4957 | $('#wh_select').on('select', function(event) { | |
4958 | if (event.args) { | |
4959 | var datarecord, index = event.args.index; | |
4960 | datarecord = hoplist.records[index]; | |
4961 | $('#wh_name').val(datarecord.name); | |
4962 | hopData.h_name = datarecord.name; | |
4963 | hopData.h_origin = datarecord.origin; | |
4964 | hopData.h_cost = datarecord.cost; | |
4965 | hopData.h_type = datarecord.type; | |
4966 | hopData.h_form = datarecord.form; | |
4967 | hopData.h_alpha = datarecord.alpha; | |
4968 | hopData.h_beta = datarecord.beta; | |
4969 | hopData.h_hsi = datarecord.hsi; | |
4970 | hopData.h_humulene = datarecord.humulene; | |
4971 | hopData.h_caryophyllene = datarecord.caryophyllene; | |
4972 | hopData.h_cohumulone = datarecord.cohumulone; | |
4973 | hopData.h_myrcene = datarecord.myrcene; | |
4974 | hopData.h_total_oil = datarecord.total_oil; | |
4975 | hopData.h_inventory = datarecord.inventory; | |
4976 | } | |
4977 | }); | |
4978 | $('#wh_amount').jqxNumberInput(Spin1dec); | |
4979 | $('#wh_amount').on('change', function(event) { | |
4980 | console.log('amount changed: ' + event.args.value + ' time:' + hopData.h_time + ' alpha:' + hopData.h_alpha); | |
4981 | var ibu, amount = parseFloat(event.args.value) / 1000; | |
4982 | ibu = toIBU(hopData.h_useat, hopData.h_form, preboil_sg, parseFloat($('#batch_size').jqxNumberInput('decimal')), | |
4983 | amount, parseFloat(hopData.h_time), parseFloat(hopData.h_alpha), $('#ibu_method').val() | |
4984 | ); | |
4985 | hopData.h_amount = amount; | |
4986 | $('#wh_ibu').val(ibu); | |
4987 | }); | |
4988 | $('#wh_ibu').jqxNumberInput(Show1dec); | |
4989 | $('#wh_time').jqxNumberInput(PosInt); | |
4990 | $('#wh_time').on('change', function(event) { | |
4991 | var ibu, newtime = parseFloat(event.args.value); | |
4992 | // Check limits and correct | |
4993 | if (hopData.h_useat == 2) { // Boil | |
4994 | if (newtime > parseFloat($('#boil_time').jqxNumberInput('decimal'))) { | |
4995 | newtime = parseFloat($('#boil_time').jqxNumberInput('decimal')); | |
4996 | $('#wh_time').val(newtime); | |
4997 | } | |
4998 | hopData.h_time = newtime; | |
4999 | } else if (hopData.h_useat == 4) { // Whirlpool | |
5000 | if (newtime > 120) { | |
5001 | newtime = 120; | |
5002 | $('#wh_time').val(newtime); | |
5003 | } | |
5004 | hopData.h_time = newtime; | |
5005 | } else if (hopData.h_useat == 5) { // Dry hop | |
5006 | if (newtime > 21) { | |
5007 | newtime = 21; | |
5008 | $('#wh_time').val(newtime); | |
5009 | } | |
5010 | hopData.h_time = newtime * 1440; | |
5011 | } | |
5012 | ibu = toIBU(hopData.h_useat, hopData.h_form, preboil_sg, parseFloat($('#batch_size').jqxNumberInput('decimal')), | |
5013 | parseFloat(hopData.h_amount), parseFloat(hopData.h_time), parseFloat(hopData.h_alpha), $('#ibu_method').val()); | |
5014 | // console.log("time changed: "+newtime+" final:"+hopData.h_time+" ibu:"+ibu); | |
5015 | $('#wh_ibu').val(ibu); | |
5016 | }); | |
5017 | $('#wh_useat').jqxDropDownList({ | |
5018 | theme: theme, | |
5019 | source: HopUseAdapter, | |
5020 | valueMember: 'id', | |
5021 | displayMember: 'nl', | |
5022 | width: 180, | |
5023 | height: 23, | |
5024 | autoDropDownHeight: true, | |
5025 | dropDownVerticalAlignment: 'top' | |
5026 | }); | |
5027 | $('#wh_useat').on('select', function(event) { | |
5028 | if (event.args) { | |
5029 | var index = event.args.index; | |
5030 | hopData.h_useat = index; | |
5031 | if ((index == 0) || (index == 1)) { // Mashhop or First wort hop | |
5032 | hopData.h_time = parseFloat(dataRecord.boil_time); | |
5033 | $('#wh_time').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
5034 | $('#wh_time').val(hopData.h_time); | |
5035 | } else if (index == 3) { // Aroma | |
5036 | hopData.h_time = 0; | |
5037 | $('#wh_time').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
5038 | $('#wh_time').val(0); | |
5039 | } else { // Boil, Whirlpool or Dry hop | |
5040 | $('#wh_time').jqxNumberInput({ spinButtons: true, readOnly: false, width: 110 }); | |
5041 | } | |
5042 | if (index == 5) // Dry hop | |
5043 | $('#wh_pmpt_time').html('Tijd in dagen'); | |
5044 | else | |
5045 | $('#wh_pmpt_time').html('Tijd in minuten'); | |
5046 | } | |
5047 | }); | |
5048 | ||
5049 | // Tab 5, Miscs | |
5050 | $('#popupMisc').jqxWindow({ | |
5051 | width: 800, | |
5052 | height: 275, | |
5053 | position: { x: 230, y: 100 }, | |
5054 | resizable: false, | |
5055 | theme: theme, | |
5056 | isModal: true, | |
5057 | autoOpen: false, | |
5058 | cancelButton: $('#MiscReady'), | |
5059 | modalOpacity: 0.40 | |
5060 | }); | |
5061 | $('#MiscReady').jqxButton({ template: 'success', width: '90px', theme: theme }); | |
5062 | $('#MiscReady').click(function() { | |
5063 | var row, rowID = $('#miscGrid').jqxGrid('getrowid', miscRow); | |
5064 | console.log('MiscReady row:' + miscRow + ' ID:' + rowID); | |
5065 | row = { | |
5066 | m_name: miscData.m_name, | |
5067 | m_amount: miscData.m_amount, | |
5068 | m_cost: miscData.m_cost, | |
5069 | m_type: miscData.m_type, | |
5070 | m_use_use: miscData.m_use_use, | |
5071 | m_time: miscData.m_time, | |
5072 | m_amount_is_weight: miscData.m_amount_is_weight, | |
5073 | m_inventory: miscData.m_inventory, | |
5074 | m_avail: miscData.m_avail | |
5075 | }; | |
5076 | $('#miscGrid').jqxGrid('updaterow', rowID, row); | |
5077 | calcMiscs(); | |
5078 | }); | |
5079 | $('#wm_name').jqxInput({ theme: theme, width: 320, height: 23 }); | |
5080 | $('#wm_instock').jqxCheckBox({ theme: theme, height: 23 }); | |
5081 | $('#wm_instock').on('change', function(event) { | |
5082 | miscinstock = event.args.checked; | |
5083 | misclist.dataBind(); | |
5084 | }); | |
5085 | $('#wm_select').jqxDropDownList({ | |
5086 | placeHolder: 'Kies ingrediënt:', | |
5087 | theme: theme, | |
5088 | source: misclist, | |
5089 | displayMember: 'name', | |
5090 | width: 150, | |
5091 | height: 23, | |
5092 | dropDownWidth: 500, | |
5093 | dropDownHeight: 500 | |
5094 | }); | |
5095 | $('#wm_select').on('select', function(event) { | |
5096 | if (event.args) { | |
5097 | var datarecord, index = event.args.index; | |
5098 | datarecord = misclist.records[index]; | |
5099 | $('#wm_name').val(datarecord.name); | |
5100 | miscData.m_name = datarecord.name; | |
5101 | miscData.m_cost = datarecord.cost; | |
5102 | miscData.m_type = datarecord.type; | |
5103 | miscData.m_use_use = datarecord.use_use; | |
5104 | miscData.m_amount_is_weight = datarecord.amount_is_weight; | |
5105 | miscData.m_inventory = datarecord.inventory; | |
5106 | } | |
5107 | }); | |
5108 | $('#wm_amount').jqxNumberInput(Spin2dec); | |
5109 | $('#wm_amount').on('change', function(event) { | |
5110 | console.log('amount changed: ' + event.args.value); | |
5111 | miscData.m_amount = parseFloat(event.args.value) / 1000; | |
5112 | }); | |
5113 | $('#wm_time').jqxNumberInput(PosInt); | |
5114 | $('#wm_time').on('change', function(event) { | |
5115 | var newtime = parseFloat(event.args.value); | |
5116 | ||
5117 | if (miscData.m_use_use == 2) { // Boil | |
5118 | if (newtime > parseFloat($('#boil_time').jqxNumberInput('decimal'))) { | |
5119 | newtime = parseFloat($('#boil_time').jqxNumberInput('decimal')); | |
5120 | $('#wm_time').val(newtime); | |
5121 | } | |
5122 | miscData.m_time = newtime; | |
5123 | } else if ((miscData.m_use_use == 3) || (miscData.m_use_use == 4)) { // Primary or Secondary | |
5124 | if (newtime > 21) { | |
5125 | newtime = 21; | |
5126 | $('#wm_time').val(newtime); | |
5127 | } | |
5128 | miscData.m_time = newtime * 1440; | |
5129 | } | |
5130 | }); | |
5131 | $('#wm_use_use').jqxDropDownList({ | |
5132 | theme: theme, | |
5133 | source: MiscUseAdapter, | |
5134 | valueMember: 'id', | |
5135 | displayMember: 'nl', | |
5136 | width: 180, | |
5137 | height: 23, | |
5138 | autoDropDownHeight: true, | |
5139 | dropDownVerticalAlignment: 'top' | |
5140 | }); | |
5141 | $('#wm_use_use').on('select', function(event) { | |
5142 | if (event.args) { | |
5143 | var index = event.args.index; | |
5144 | miscData.m_use_use = index; | |
5145 | if ((index == 2) || (index == 3) || (index == 4)) { // Boil, Primary or Secondary | |
5146 | $('#wm_time').jqxNumberInput({ spinButtons: true, readOnly: false, width: 110 }); | |
5147 | } else { | |
5148 | $('#wm_time').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); | |
5149 | $('#wm_time').val(0); | |
5150 | miscData.m_time = 0; | |
5151 | } | |
5152 | } | |
5153 | }); | |
5154 | ||
5155 | // Tab 6, Yeasts | |
5156 | $('#est_fg2').jqxTooltip({ content: 'Het verwachte eind SG. Dit wordt automatisch berekend.' }); | |
5157 | $('#est_fg2').jqxNumberInput(Show3dec); | |
5158 | $('#est_abv2').jqxTooltip({ content: 'Alcohol volume %. Dit wordt automatisch berekend.' }); | |
5159 | $('#est_abv2').jqxNumberInput(Smal1dec); | |
5160 | $('#yeast_cells').jqxNumberInput(Show1dec); | |
5161 | $('#need_cells').jqxNumberInput(Show1dec); | |
5162 | $('#plato_cells').jqxNumberInput(Show2dec); | |
5163 | $('#popupYeast').jqxWindow({ | |
5164 | width: 800, | |
5165 | height: 300, | |
5166 | position: { x: 230, y: 100 }, | |
5167 | resizable: false, | |
5168 | theme: theme, | |
5169 | isModal: true, | |
5170 | autoOpen: false, | |
5171 | cancelButton: $('#YeastReady'), | |
5172 | modalOpacity: 0.40 | |
5173 | }); | |
5174 | $('#YeastReady').jqxButton({ template: 'success', width: '90px', theme: theme }); | |
5175 | $('#YeastReady').click(function() { | |
5176 | var row, rowID = $('#yeastGrid').jqxGrid('getrowid', yeastRow); | |
5177 | console.log('YeastReady row:' + yeastRow + ' ID:' + rowID); | |
5178 | row = { | |
5179 | y_name: yeastData.y_name, | |
5180 | y_laboratory: yeastData.y_laboratory, | |
5181 | y_product_id: yeastData.y_product_id, | |
5182 | y_amount: yeastData.y_amount, | |
5183 | y_cost: yeastData.y_cost, | |
5184 | y_type: yeastData.y_type, | |
5185 | y_form: yeastData.y_form, | |
5186 | y_flocculation: yeastData.y_flocculation, | |
5187 | y_min_temperature: yeastData.y_min_temperature, | |
5188 | y_max_temperature: yeastData.y_max_temperature, | |
5189 | y_attenuation: yeastData.y_attenuation, | |
5190 | y_use: yeastData.y_use, | |
5191 | y_cells: yeastData.y_cells, | |
5192 | y_tolerance: yeastData.y_tolerance, | |
5193 | y_inventory: yeastData.y_inventory, | |
5194 | y_avail: yeastData.y_avail | |
5195 | }; | |
5196 | $('#yeastGrid').jqxGrid('updaterow', rowID, row); | |
5197 | calcFermentables(); | |
5198 | calcYeast(); | |
5199 | }); | |
5200 | $('#wy_name').jqxInput({ theme: theme, width: 320, height: 23 }); | |
5201 | $('#wy_laboratory').jqxInput({ theme: theme, width: 320, height: 23 }); | |
5202 | $('#wy_product_id').jqxInput({ theme: theme, width: 320, height: 23 }); | |
5203 | $('#wy_instock').jqxCheckBox({ theme: theme, height: 23 }); | |
5204 | $('#wy_instock').on('change', function(event) { | |
5205 | yeastinstock = event.args.checked; | |
5206 | yeastlist.dataBind(); | |
5207 | }); | |
5208 | $('#wy_select').jqxDropDownList({ | |
5209 | placeHolder: 'Kies gist:', | |
5210 | theme: theme, | |
5211 | source: yeastlist, | |
5212 | displayMember: 'name', | |
5213 | width: 150, | |
5214 | height: 23, | |
5215 | dropDownWidth: 500, | |
5216 | dropDownHeight: 500, | |
5217 | renderer: function(index, label, value) { | |
5218 | var datarecord = yeastlist.records[index]; | |
5219 | return datarecord.laboratory + ' ' + datarecord.product_id + ' ' + datarecord.name; | |
5220 | } | |
5221 | }); | |
5222 | $('#wy_select').on('select', function(event) { | |
5223 | if (event.args) { | |
5224 | var datarecord, index = event.args.index; | |
5225 | datarecord = yeastlist.records[index]; | |
5226 | $('#wy_name').val(datarecord.name); | |
5227 | $('#wy_laboratory').val(datarecord.laboratory); | |
5228 | $('#wy_product_id').val(datarecord.product_id); | |
5229 | yeastData.y_name = datarecord.name; | |
5230 | yeastData.y_cost = datarecord.cost; | |
5231 | yeastData.y_type = datarecord.type; | |
5232 | yeastData.y_form = datarecord.form; | |
5233 | yeastData.y_laboratory = datarecord.laboratory; | |
5234 | yeastData.y_product_id = datarecord.product_id; | |
5235 | yeastData.y_min_temperature = datarecord.min_temperature; | |
5236 | yeastData.y_max_temperature = datarecord.max_temperature; | |
5237 | yeastData.y_flocculation = datarecord.flocculation; | |
5238 | yeastData.y_attenuation = datarecord.attenuation; | |
5239 | yeastData.y_cells = datarecord.cells; | |
5240 | yeastData.y_inventory = datarecord.inventory; | |
5241 | if (yeastData.y_form == 0) { | |
5242 | $('#wy_pmpt_amount').html('Pak(ken):'); | |
5243 | } else if (yeastData.y_form == 1) { | |
5244 | $('#wy_pmpt_amount').html('Gewicht gram:'); | |
5245 | } else { | |
5246 | $('#wy_pmpt_amount').html('Volume ml:'); | |
5247 | } | |
5248 | calcFermentables(); | |
5249 | calcYeast(); | |
5250 | } | |
5251 | }); | |
5252 | $('#wy_amount').jqxNumberInput(Spin1dec); | |
5253 | $('#wy_amount').on('change', function(event) { | |
5254 | var amount = parseFloat(event.args.value); | |
5255 | if (yeastData.y_form != 0) // not Liquid | |
5256 | amount = parseFloat(event.args.value) / 1000; | |
5257 | yeastData.y_amount = amount; | |
5258 | calcFermentables(); | |
5259 | calcYeast(); | |
5260 | }); | |
5261 | $('#wy_use').jqxDropDownList({ | |
5262 | theme: theme, | |
5263 | source: YeastUseAdapter, | |
5264 | valueMember: 'id', | |
5265 | displayMember: 'nl', | |
5266 | width: 180, | |
5267 | height: 23, | |
5268 | autoDropDownHeight: true, | |
5269 | dropDownVerticalAlignment: 'top' | |
5270 | }); | |
5271 | $('#wy_use').on('select', function(event) { | |
5272 | if (event.args) { | |
5273 | var index = event.args.index; | |
5274 | yeastData.y_use = index; | |
5275 | calcFermentables(); | |
5276 | calcYeast(); | |
5277 | } | |
5278 | }); | |
5279 | for (i = 1; i < 5; i++) { | |
5280 | $('#prop' + i + '_type').jqxDropDownList({ | |
5281 | theme: theme, | |
5282 | source: StarterTypeAdapter, | |
5283 | valueMember: 'id', | |
5284 | displayMember: 'nl', | |
5285 | width: 120, | |
5286 | height: 23, | |
5287 | autoDropDownHeight: true | |
5288 | }); | |
5289 | $('#prop' + i + '_type').hide(); | |
5290 | $('#prop' + i + '_volume').jqxNumberInput(Spin3dec); | |
5291 | $('#prop' + i + '_volume').hide(); | |
5292 | $('#prop' + i + '_irate').jqxNumberInput(Show1dec); | |
5293 | $('#prop' + i + '_irate').hide(); | |
5294 | $('#prop' + i + '_ncells').jqxNumberInput(Show1dec); | |
5295 | $('#prop' + i + '_ncells').hide(); | |
5296 | $('#prop' + i + '_tcells').jqxNumberInput(Show1dec); | |
5297 | $('#prop' + i + '_tcells').hide(); | |
5298 | $('#prop' + i + '_growf').jqxNumberInput(Show2dec); | |
5299 | $('#prop' + i + '_growf').hide(); | |
5300 | } | |
5301 | $('#starter_enable').jqxCheckBox({ theme: theme, height: 23 }); | |
5302 | $('#starter_type').jqxDropDownList({ | |
5303 | theme: theme, | |
5304 | source: StarterTypeAdapter, | |
5305 | valueMember: 'id', | |
5306 | displayMember: 'nl', | |
5307 | width: 120, | |
5308 | height: 23, | |
5309 | autoDropDownHeight: true | |
5310 | }); | |
5311 | $('#starter_sg').jqxNumberInput(SGopts); | |
5312 | $('#starter_viability').jqxNumberInput(Perc0); | |
5313 | $('#starter_try').jqxButton({ template: 'primary', width: '100px', height: 23, theme: theme }); | |
5314 | ||
5315 | // Tab 7, Mashing | |
5316 | $('#mash_name').jqxTooltip({ content: 'De omschrijving van dit maisch profiel.' }); | |
5317 | $('#mash_name').jqxInput({ theme: theme, width: 320, height: 23 }); | |
5318 | $('#mash_select').jqxDropDownList({ | |
5319 | placeHolder: 'Kies schema:', | |
5320 | theme: theme, | |
5321 | source: mashlist, | |
5322 | displayMember: 'name', | |
5323 | width: 250, | |
5324 | height: 23, | |
5325 | dropDownWidth: 500, | |
5326 | dropDownHeight: 500, | |
5327 | dropDownHorizontalAlignment: 'right' | |
5328 | }); | |
5329 | $('#mash_select').on('select', function(event) { | |
5330 | if (event.args) { | |
5331 | var data, datarecord, rowIDs, rows, i, row, index = event.args.index; | |
5332 | // First delete all current steps | |
5333 | rowIDs = new Array(); | |
5334 | rows = $('#mashGrid').jqxGrid('getdisplayrows'); | |
5335 | for (i = 0; i < rows.length; i++) { | |
5336 | row = rows[i]; | |
5337 | rowIDs.push(row.uid); | |
5338 | } | |
5339 | $('#mashGrid').jqxGrid('deleterow', rowIDs); | |
5340 | // Then add the new steps | |
5341 | datarecord = mashlist.records[index]; | |
5342 | $('#mash_name').val(datarecord.name); | |
5343 | for (i = 0; i < datarecord.steps.length; i++) { | |
5344 | data = datarecord.steps[i]; | |
5345 | row = {}; | |
5346 | row['step_name'] = data.step_name; | |
5347 | row['step_type'] = data.step_type; | |
5348 | // For now, but this must be smarter. | |
5349 | if (mash_infuse == 0 && dataRecord.w1_amount > 0) | |
5350 | mash_infuse = dataRecord.w1_amount; | |
5351 | if (i == 0) | |
5352 | row['step_infuse_amount'] = mash_infuse; | |
5353 | else | |
5354 | row['step_infuse_amount'] = 0; | |
5355 | if (mashkg > 0) | |
5356 | row['step_thickness'] = parseFloat(mash_infuse / mashkg); | |
5357 | else | |
5358 | row['step_thickness'] = 0; | |
5359 | row['step_temp'] = data.step_temp; | |
5360 | row['end_temp'] = data.end_temp; | |
5361 | row['step_time'] = data.step_time; | |
5362 | row['ramp_time'] = data.ramp_time; | |
5363 | $('#mashGrid').jqxGrid('addrow', null, row); | |
5364 | } | |
490
6c9ad1317f0a
Recalculate mash after changing mash parameters.
Michiel Broek <mbroek@mbse.eu>
parents:
489
diff
changeset
|
5365 | calcMash(); |
478 | 5366 | } |
5367 | }); | |
484
2083c274b283
In the product editor mash tab, display the total mash volume and the total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
479
diff
changeset
|
5368 | $('#est_mashvol').jqxTooltip({ content: 'Het totale volume van het maishwater en de mout in de maish pan.' }); |
2083c274b283
In the product editor mash tab, display the total mash volume and the total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
479
diff
changeset
|
5369 | $('#est_mashvol').jqxNumberInput(Show1dec); |
2083c274b283
In the product editor mash tab, display the total mash volume and the total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
479
diff
changeset
|
5370 | $('#est_mashtime').jqxTooltip({ content: 'De totale tijdsduur van het maischen.' }); |
2083c274b283
In the product editor mash tab, display the total mash volume and the total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
479
diff
changeset
|
5371 | $('#est_mashtime').jqxInput({ theme: theme, width: 70, height: 23 }); |
478 | 5372 | $('#popupMash').jqxWindow({ |
5373 | width: 800, | |
5374 | height: 350, | |
5375 | position: { x: 230, y: 100 }, | |
5376 | resizable: false, | |
5377 | theme: theme, | |
5378 | isModal: true, | |
5379 | autoOpen: false, | |
5380 | cancelButton: $('#MashReady'), | |
5381 | modalOpacity: 0.40 | |
5382 | }); | |
5383 | $('#MashReady').jqxButton({ template: 'success', width: '90px', theme: theme }); | |
5384 | $('#MashReady').click(function() { | |
5385 | calcMash(); | |
5386 | }); | |
5387 | $('#wstep_name').jqxInput({ theme: theme, width: 320, height: 23 }); | |
5388 | $('#wstep_name').on('change', function(event) { | |
5389 | var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); | |
5390 | rowdata.step_name = event.args.value; | |
5391 | }); | |
5392 | $('#wstep_type').jqxDropDownList({ | |
5393 | theme: theme, | |
5394 | source: MashStepTypeAdapter, | |
5395 | valueMember: 'id', | |
5396 | displayMember: 'nl', | |
5397 | width: 180, | |
5398 | height: 23, | |
5399 | autoDropDownHeight: true | |
5400 | }); | |
5401 | $('#wstep_type').on('select', function(event) { | |
5402 | if (event.args) { | |
5403 | var rowdata, i, rows, row, index = event.args.index; | |
5404 | rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); | |
5405 | rowdata.step_type = index; | |
5406 | if (index == 0) { | |
5407 | $('#wstep_infuse_amount').show(); | |
5408 | $('#wstep_pmpt').show(); | |
5409 | } else { | |
5410 | rowdata.step_infuse_amount = 0; | |
5411 | $('#wstep_infuse_amount').hide(); | |
5412 | $('#wstep_pmpt').hide(); | |
5413 | } | |
5414 | mash_infuse = 0; | |
5415 | rows = $('#mashGrid').jqxGrid('getrows'); | |
5416 | for (i = 0; i < rows.length; i++) { | |
5417 | row = rows[i]; | |
5418 | if (row.step_type == 0) // Infusion | |
5419 | mash_infuse += parseFloat(row.step_infuse_amount); | |
5420 | } | |
5421 | } | |
5422 | }); | |
5423 | $('#wstep_temp').jqxNumberInput(Spin1dec); | |
5424 | $('#wstep_temp').on('change', function(event) { | |
5425 | var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); | |
5426 | rowdata.step_temp = parseFloat(event.args.value); | |
5427 | }); | |
5428 | $('#wend_temp').jqxNumberInput(Spin1dec); | |
5429 | $('#wend_temp').on('change', function(event) { | |
5430 | var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); | |
5431 | rowdata.end_temp = parseFloat(event.args.value); | |
5432 | }); | |
5433 | $('#wstep_time').jqxNumberInput(PosInt); | |
5434 | $('#wstep_time').on('change', function(event) { | |
5435 | var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); | |
5436 | rowdata.step_time = parseFloat(event.args.value); | |
490
6c9ad1317f0a
Recalculate mash after changing mash parameters.
Michiel Broek <mbroek@mbse.eu>
parents:
489
diff
changeset
|
5437 | calcMash(); |
478 | 5438 | }); |
5439 | $('#wramp_time').jqxNumberInput(PosInt); | |
5440 | $('#wramp_time').on('change', function(event) { | |
5441 | var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); | |
5442 | rowdata.ramp_time = parseFloat(event.args.value); | |
490
6c9ad1317f0a
Recalculate mash after changing mash parameters.
Michiel Broek <mbroek@mbse.eu>
parents:
489
diff
changeset
|
5443 | calcMash(); |
478 | 5444 | }); |
5445 | $('#wstep_infuse_amount').jqxNumberInput(Spin1dec); | |
5446 | $('#wstep_infuse_amount').on('change', function(event) { | |
5447 | var row, i, rows, rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); | |
5448 | rowdata.step_infuse_amount = parseFloat(event.args.value); | |
5449 | mash_infuse = 0; | |
5450 | rows = $('#mashGrid').jqxGrid('getrows'); | |
5451 | for (i = 0; i < rows.length; i++) { | |
5452 | row = rows[i]; | |
5453 | if (row.step_type == 0) // Infusion | |
5454 | mash_infuse += parseFloat(row.step_infuse_amount); | |
5455 | } | |
5456 | if (dataRecord.w2_amount == 0) { | |
5457 | dataRecord.w1_amount = mash_infuse; | |
5458 | $('#w1_amount').val(mash_infuse); | |
5459 | } else { | |
5460 | dataRecord.w1_amount = (dataRecord.w1_amount / (dataRecord.w1_amount + dataRecord.w2_amount)) * mash_infuse; | |
5461 | dataRecord.w2_amount = (dataRecord.w2_amount / (dataRecord.w1_amount + dataRecord.w2_amount)) * mash_infuse; | |
5462 | $('#w1_amount').val(dataRecord.w1_amount); | |
5463 | $('#w2_amount').val(dataRecord.w2_amount); | |
5464 | } | |
5465 | $('#wg_amount').val(mash_infuse); | |
479
67dbbf301ae7
Recalculate water and sparge water after changing the mash infuse volume
Michiel Broek <mbroek@mbse.eu>
parents:
478
diff
changeset
|
5466 | calcFermentables(); |
67dbbf301ae7
Recalculate water and sparge water after changing the mash infuse volume
Michiel Broek <mbroek@mbse.eu>
parents:
478
diff
changeset
|
5467 | calcWater(); |
67dbbf301ae7
Recalculate water and sparge water after changing the mash infuse volume
Michiel Broek <mbroek@mbse.eu>
parents:
478
diff
changeset
|
5468 | calcSparge(); |
490
6c9ad1317f0a
Recalculate mash after changing mash parameters.
Michiel Broek <mbroek@mbse.eu>
parents:
489
diff
changeset
|
5469 | calcMash(); |
478 | 5470 | }); |
5471 | ||
5472 | // Tab 8, Water | |
5473 | $('#tgt_bu').jqxNumberInput(Show2wat); | |
5474 | $('#tgt_cl_so4').jqxNumberInput(Show1wat); | |
5475 | $('#got_cl_so4').jqxNumberInput(Show1wat); | |
5476 | ||
5477 | // Water source 1 | |
5478 | $('#w1_name').jqxDropDownList({ | |
5479 | placeHolder: 'Kies hoofd water:', | |
5480 | theme: theme, | |
5481 | source: waterlist, | |
5482 | displayMember: 'name', | |
5483 | width: 250, | |
5484 | height: 27, | |
5485 | dropDownWidth: 400, | |
5486 | dropDownHeight: 400 | |
5487 | }); | |
5488 | $('#w1_name').on('select', function(event) { | |
5489 | if (event.args) { | |
5490 | var datarecord, index = event.args.index; | |
5491 | datarecord = waterlist.records[index]; | |
5492 | dataRecord.w1_name = datarecord.name; | |
5493 | $('#w1_calcium').val(datarecord.calcium); | |
5494 | dataRecord.w1_calcium = datarecord.calcium; | |
5495 | $('#w1_sulfate').val(datarecord.sulfate); | |
5496 | dataRecord.w1_sulfate = datarecord.sulfate; | |
5497 | $('#w1_chloride').val(datarecord.chloride); | |
5498 | dataRecord.w1_chloride = datarecord.chloride; | |
5499 | $('#w1_sodium').val(datarecord.sodium); | |
5500 | dataRecord.w1_sodium = datarecord.sodium; | |
5501 | $('#w1_magnesium').val(datarecord.magnesium); | |
5502 | dataRecord.w1_magnesium = datarecord.magnesium; | |
5503 | $('#w1_total_alkalinity').val(datarecord.total_alkalinity); | |
5504 | dataRecord.w1_total_alkalinity = datarecord.total_alkalinity; | |
5505 | $('#w1_ph').val(datarecord.ph); | |
5506 | dataRecord.w1_ph = datarecord.ph; | |
5507 | $('#w1_cost').val(datarecord.cost); | |
5508 | dataRecord.w1_cost = datarecord.cost; | |
5509 | calcWater(); | |
5510 | } | |
5511 | }); | |
5512 | $('#w1_amount').jqxNumberInput(Show1wat); | |
5513 | $('#w1_calcium').jqxNumberInput(Show1wat); | |
5514 | $('#w1_magnesium').jqxNumberInput(Show1wat); | |
5515 | $('#w1_sodium').jqxNumberInput(Show1wat); | |
5516 | $('#w1_total_alkalinity').jqxNumberInput(Show1wat); | |
5517 | $('#w1_chloride').jqxNumberInput(Show1wat); | |
5518 | $('#w1_sulfate').jqxNumberInput(Show1wat); | |
5519 | $('#w1_ph').jqxNumberInput(Show1wat); | |
5520 | // Water source 2 | |
5521 | $('#w2_name').jqxDropDownList({ | |
5522 | placeHolder: 'Kies meng water:', | |
5523 | theme: theme, | |
5524 | source: waterlist, | |
5525 | displayMember: 'name', | |
5526 | width: 250, | |
5527 | height: 27, | |
5528 | dropDownWidth: 400, | |
5529 | dropDownHeight: 400 | |
5530 | }); | |
5531 | $('#w2_name').on('select', function(event) { | |
5532 | if (event.args) { | |
5533 | var datarecord, index = event.args.index; | |
5534 | datarecord = waterlist.records[index]; | |
5535 | dataRecord.w2_name = datarecord.name; | |
5536 | $('#w2_calcium').val(datarecord.calcium); | |
5537 | dataRecord.w2_calcium = datarecord.calcium; | |
5538 | $('#w2_sulfate').val(datarecord.sulfate); | |
5539 | dataRecord.w2_sulfate = datarecord.sulfate; | |
5540 | $('#w2_chloride').val(datarecord.chloride); | |
5541 | dataRecord.w2_chloride = datarecord.chloride; | |
5542 | $('#w2_sodium').val(datarecord.sodium); | |
5543 | dataRecord.w2_sodium = datarecord.sodium; | |
5544 | $('#w2_magnesium').val(datarecord.magnesium); | |
5545 | dataRecord.w2_magnesium = datarecord.magnesium; | |
5546 | $('#w2_total_alkalinity').val(datarecord.total_alkalinity); | |
5547 | dataRecord.w2_total_alkalinity = datarecord.total_alkalinity; | |
5548 | $('#w2_ph').val(datarecord.ph); | |
5549 | dataRecord.w2_ph = datarecord.ph; | |
5550 | $('#w2_cost').val(datarecord.cost); | |
5551 | dataRecord.w2_cost = datarecord.cost; | |
5552 | $('#w2_amount').jqxNumberInput({ max: 100000, readOnly: false }); // Set high max to enable the spinbuttons. | |
5553 | calcWater(); | |
5554 | } | |
5555 | }); | |
5556 | $('#w2_amount').jqxTooltip({ content: 'De verdeling van het hoofd en meng water. Het totale maisch water volume blijft gelijk.'}); | |
5557 | $('#w2_amount').jqxNumberInput({ | |
5558 | inputMode: 'simple', spinMode: 'simple', theme: theme, width: 94, height: 23, min: 0, max: 0, decimalDigits: 1, | |
5559 | spinButtons: true, spinButtonsStep: 0.5, readOnly: true | |
5560 | }); | |
5561 | $('#w2_calcium').jqxNumberInput(Show1wat); | |
5562 | $('#w2_magnesium').jqxNumberInput(Show1wat); | |
5563 | $('#w2_sodium').jqxNumberInput(Show1wat); | |
5564 | $('#w2_total_alkalinity').jqxNumberInput(Show1wat); | |
5565 | $('#w2_chloride').jqxNumberInput(Show1wat); | |
5566 | $('#w2_sulfate').jqxNumberInput(Show1wat); | |
5567 | $('#w2_ph').jqxNumberInput(Show1wat); | |
5568 | // Water mixed | |
5569 | $('#wg_amount').jqxNumberInput(Show1wat); | |
5570 | $('#wg_calcium').jqxNumberInput(Show1wat); | |
5571 | $('#wg_magnesium').jqxNumberInput(Show1wat); | |
5572 | $('#wg_sodium').jqxNumberInput(Show1wat); | |
5573 | $('#wg_total_alkalinity').jqxNumberInput(Show1wat); | |
5574 | $('#wg_chloride').jqxNumberInput(Show1wat); | |
5575 | $('#wg_sulfate').jqxNumberInput(Show1wat); | |
5576 | $('#wg_ph').jqxNumberInput(Show1wat); | |
5577 | // Water treated | |
5578 | $('#wb_calcium').jqxTooltip({ content: 'De ideale hoeveelheid Calcium is tussen 40 en 150.'}); | |
5579 | $('#wb_calcium').jqxNumberInput(Show1wat); | |
5580 | $('#wb_magnesium').jqxTooltip({ content: 'De ideale hoeveelheid Magnesium is lager dan 30.'}); | |
5581 | $('#wb_magnesium').jqxNumberInput(Show1wat); | |
5582 | $('#wb_sodium').jqxTooltip({ content: 'De ideale hoeveelheid Natrium is lager dan 150.'}); | |
5583 | $('#wb_sodium').jqxNumberInput(Show1wat); | |
5584 | $('#wb_total_alkalinity').jqxNumberInput(Show1wat); | |
5585 | $('#wb_chloride').jqxTooltip({ content: 'De ideale hoeveelheid Chloride is tussen 50 en 100.'}); | |
5586 | $('#wb_chloride').jqxNumberInput(Show1wat); | |
5587 | $('#wb_sulfate').jqxTooltip({ content: 'De ideale hoeveelheid Sulfaat is tussen 50 en 350.'}); | |
5588 | $('#wb_sulfate').jqxNumberInput(Show1wat); | |
5589 | $('#wb_ph').jqxNumberInput(Show1wat); | |
5590 | // Water target profile | |
5591 | $('#pr_name').jqxDropDownList({ | |
5592 | placeHolder: 'Kies doel profiel:', | |
5593 | theme: theme, | |
5594 | source: waterprofiles, | |
5595 | displayMember: 'name', | |
5596 | width: 250, | |
5597 | height: 27, | |
5598 | dropDownWidth: 400, | |
5599 | dropDownHeight: 300 | |
5600 | }); | |
5601 | $('#pr_name').on('select', function(event) { | |
5602 | if (event.args) { | |
5603 | var datarecord, index = event.args.index; | |
5604 | datarecord = waterprofiles.records[index]; | |
5605 | $('#pr_calcium').val(datarecord.calcium); | |
5606 | $('#pr_sulfate').val(datarecord.sulfate); | |
5607 | $('#pr_chloride').val(datarecord.chloride); | |
5608 | $('#pr_sodium').val(datarecord.sodium); | |
5609 | $('#pr_magnesium').val(datarecord.magnesium); | |
5610 | $('#pr_total_alkalinity').val(datarecord.total_alkalinity); | |
5611 | } | |
5612 | }); | |
5613 | $('#pr_calcium').jqxNumberInput(Show1wat); | |
5614 | $('#pr_magnesium').jqxNumberInput(Show1wat); | |
5615 | $('#pr_sodium').jqxNumberInput(Show1wat); | |
5616 | $('#pr_total_alkalinity').jqxNumberInput(Show1wat); | |
5617 | $('#pr_chloride').jqxNumberInput(Show1wat); | |
5618 | $('#pr_sulfate').jqxNumberInput(Show1wat); | |
5619 | ||
5620 | // Water agents | |
5621 | $('#wa_cacl2').jqxTooltip({ content: 'Voor het maken van een ander waterprofiel. Voegt calcium en chloride toe. Voor het verbeteren van zoetere bieren.' }); | |
5622 | $('#wa_cacl2').jqxNumberInput(Spin1dec); | |
5623 | $('#wa_caso4').jqxTooltip({ | |
5624 | content: 'Gips. Voor het maken van een ander waterprofiel. Voegt calcium en sulfaat toe. Voor het verbeteren van bittere bieren.' | |
5625 | }); | |
5626 | $('#wa_caso4').jqxNumberInput(Spin1dec); | |
5627 | $('#wa_mgso4').jqxTooltip({ content: 'Epsom zout. Voor het maken van een ander waterprofiel. Voegt magnesium en sulfaat toe. Gebruik spaarzaam!' }); | |
5628 | $('#wa_mgso4').jqxNumberInput(Spin1dec); | |
5629 | $('#wa_nacl').jqxTooltip({ | |
5630 | content: 'Keukenzout. Voor het maken van een ander waterprofiel. Voegt natrium en chloride toe. ' + | |
5631 | 'Voor het accentueren van zoetheid. Bij hoge dosering wordt het bier ziltig.' | |
5632 | }); | |
5633 | $('#wa_nacl').jqxNumberInput(Spin1dec); | |
5634 | $('#mash_ph').jqxTooltip({ content: 'Maisch pH tussen 5.2 en 5.6. Gebruik 5.2 voor lichte en 5.5 voor donkere bieren.'}); | |
5635 | $('#mash_ph').jqxNumberInput(SpinpH); | |
5636 | $('#calc_acid').jqxCheckBox({ theme: theme, width: 120, height: 23 }); | |
5637 | $('#wa_base_name').jqxDropDownList({ | |
5638 | theme: theme, | |
5639 | source: BaseTypeAdapter, | |
5640 | valueMember: 'id', | |
5641 | displayMember: 'nl', | |
5642 | width: 170, | |
5643 | height: 23, | |
5644 | autoDropDownHeight: true | |
5645 | }); | |
5646 | $('#wa_base').jqxNumberInput(Spin2dec); | |
5647 | $('#wa_base').jqxNumberInput({ symbol: ' gr', symbolPosition: 'right' }); | |
5648 | $('#wa_acid_name').jqxDropDownList({ | |
5649 | theme: theme, | |
5650 | source: AcidTypeAdapter, | |
5651 | valueMember: 'id', | |
5652 | displayMember: 'nl', | |
5653 | width: 170, | |
5654 | height: 23, | |
5655 | autoDropDownHeight: true | |
5656 | }); | |
5657 | $('#wa_acid').jqxNumberInput(Spin2dec); | |
5658 | $('#wa_acid').jqxNumberInput({ symbol: ' ml', symbolPosition: 'right' }); | |
5659 | $('#wa_acid_perc').jqxNumberInput(Perc0); | |
5660 | $('#wa_acid_perc').jqxNumberInput({ width: 70, symbol: '%', symbolPosition: 'right' }); | |
5661 | // Sparge water | |
5662 | $('#sparge_temp').jqxNumberInput(Spin1dec); | |
5663 | $('#sparge_volume').jqxNumberInput(Spin1dec); | |
5664 | $('#sparge_ph').jqxNumberInput(SpinpH); | |
5665 | $('#sparge_source').jqxDropDownList({ | |
5666 | theme: theme, | |
5667 | source: SpargeSourceAdapter, | |
5668 | valueMember: 'id', | |
5669 | displayMember: 'nl', | |
5670 | width: 110, | |
5671 | height: 23, | |
5672 | autoDropDownHeight: true | |
5673 | }); | |
5674 | $('#sparge_acid_amount').jqxNumberInput(Spin2dec); | |
5675 | $('#sparge_acid_amount').jqxNumberInput({ spinButtons: false, readOnly: true, symbol: ' ml', symbolPosition: 'right' }); | |
5676 | $('#sparge_acid_type').jqxDropDownList({ | |
5677 | theme: theme, | |
5678 | source: AcidTypeAdapter, | |
5679 | valueMember: 'id', | |
5680 | displayMember: 'nl', | |
5681 | width: 110, | |
5682 | height: 23, | |
5683 | autoDropDownHeight: true | |
5684 | }); | |
5685 | $('#sparge_acid_perc').jqxNumberInput(Perc0); | |
5686 | $('#sparge_acid_perc').jqxNumberInput({ symbol: '%', symbolPosition: 'right' }); | |
5687 | ||
5688 | // Tab 9, Brewday | |
5689 | $('#brew_date_start').jqxTooltip({ content: 'Brouw datum en tijd. Voor planning laat de tijd op 00:00:00 staan.' }); | |
5690 | $('#brew_date_start').jqxDateTimeInput(DateTimeopts); | |
5691 | $('#brew_date_start').on('close', function(event) { calcStage(); }); | |
5692 | $('#brew_date_end').jqxTooltip({ content: 'End datum en tijd van de brouw. Leeg laten als er nog niet gebrouwen is.' }); | |
5693 | $('#brew_date_end').jqxDateTimeInput(DateTimeopts); | |
5694 | $('#brew_date_end').on('close', function(event) { calcStage(); }); | |
5695 | $('#brew_mash_ph').jqxTooltip({ content: 'De gemeten pH tijdens het maischen eventueel na correctie.' }); | |
5696 | $('#brew_mash_ph').jqxNumberInput(SpinpH); | |
5697 | $('#est_mash_ph').jqxTooltip({ content: 'De gewenste pH tijdens het maischen.' }); | |
5698 | $('#est_mash_ph').jqxNumberInput(Show1wat); | |
5699 | $('#brew_preboil_ph').jqxTooltip({ content: 'De gemeten pH in de kookketel na het spoelen en voor de kook.' }); | |
5700 | $('#brew_preboil_ph').jqxNumberInput(SpinpH); | |
5701 | // est_preboil_ph | |
5702 | $('#brew_aboil_ph').jqxTooltip({ content: 'De gemeten pH na het koken.' }); | |
5703 | $('#brew_aboil_ph').jqxNumberInput(SpinpH); | |
5704 | // est_aboil_ph | |
5705 | $('#brew_mash_sg').jqxTooltip({ content: 'Het bereikte SG na het maischen.' }); | |
5706 | $('#brew_mash_sg').jqxNumberInput(SGopts); | |
5707 | $('#brew_mash_sg').on('valueChanged', function() { calcMashEfficiency(); }); | |
5708 | $('#est_mash_sg').jqxTooltip({ content: 'Het berekende verwachte SG na het maischen.' }); | |
5709 | $('#est_mash_sg').jqxNumberInput(Show3wat); | |
5710 | $('#brew_preboil_sg').jqxTooltip({ content: 'Het gemeten SG in de kookketel na het spoelen en voor het koken.' }); | |
5711 | $('#brew_preboil_sg').jqxNumberInput(SGopts); | |
5712 | $('#brew_preboil_sg').on('valueChanged', function(event) { | |
5713 | dataRecord.brew_preboil_sg = event.args.value; | |
5714 | calcEfficiencyBeforeBoil(); | |
5715 | }); | |
5716 | $('#est_pre_sg').jqxTooltip({ content: 'Het berekende SG in de kookketel na het spoelen en voor het koken.' }); | |
5717 | $('#est_pre_sg').jqxNumberInput(Show3wat); | |
5718 | $('#brew_aboil_sg').jqxTooltip({ content: 'Het gemeten SG in de kookketel na het koken.' }); | |
5719 | $('#brew_aboil_sg').jqxNumberInput(SGopts); | |
5720 | $('#brew_aboil_sg').on('valueChanged', function(event) { | |
5721 | dataRecord.brew_aboil_sg = event.args.value; | |
5722 | calcEfficiencyAfterBoil(); | |
5723 | calcFermentables(); | |
5724 | calcIBUs(); | |
5725 | }); | |
5726 | $('#est_og3').jqxTooltip({ content: 'Het gewenste SG in de kookketel na het koken.' }); | |
5727 | $('#est_og3').jqxNumberInput(Show3wat); | |
5728 | $('#brew_mash_efficiency').jqxTooltip({ content: 'Het behaalde maisch rendement.' }); | |
5729 | $('#brew_mash_efficiency').jqxNumberInput(Show1dec); | |
5730 | $('#brew_preboil_volume').jqxTooltip({ content: 'Het gemeten volume van het wort voor het koken.' }); | |
5731 | $('#brew_preboil_volume').jqxNumberInput(Spin1dec); | |
5732 | $('#brew_preboil_volume').on('valueChanged', function(event) { | |
5733 | dataRecord.brew_preboil_volume = event.args.value; | |
5734 | calcEfficiencyBeforeBoil(); | |
5735 | }); | |
5736 | $('#est_pre_vol').jqxTooltip({ content: 'Het berekende volume van het wort voor het koken.' }); | |
5737 | $('#est_pre_vol').jqxNumberInput(Show1wat); | |
5738 | $('#brew_aboil_volume').jqxTooltip({ content: 'Het gemeten volume van het wort na het koken.' }); | |
5739 | $('#brew_aboil_volume').jqxNumberInput(Spin1dec); | |
5740 | $('#brew_aboil_volume').on('valueChanged', function(event) { | |
5741 | dataRecord.brew_aboil_volume = event.args.value; | |
5742 | calcEfficiencyAfterBoil(); | |
5743 | calcFermentables(); | |
5744 | calcIBUs(); | |
5745 | }); | |
5746 | $('#est_a_vol').jqxTooltip({ content: 'Het gewenste volume na het koken.' }); | |
5747 | $('#est_a_vol').jqxNumberInput(Show1wat); | |
5748 | $('#brew_preboil_efficiency').jqxTooltip({ content: 'Het berekende rendement voor het koken.' }); | |
5749 | $('#brew_preboil_efficiency').jqxNumberInput(Show1dec); | |
5750 | $('#brew_aboil_efficiency').jqxTooltip({ content: 'Het bereikte rendement na het koken.' }); | |
5751 | $('#brew_aboil_efficiency').jqxNumberInput(Show1dec); | |
5752 | $('#brew_sparge_temperature').jqxTooltip({ content: 'De spoelwater temperatuur, in te stellen in de Water tab.' }); | |
5753 | $('#brew_sparge_temperature').jqxNumberInput(Show1dec); | |
5754 | $('#brew_sparge_volume').jqxTooltip({ content: 'Het spoelwater voorraad volume, in te stellen in de Water tab.' }); | |
5755 | $('#brew_sparge_volume').jqxNumberInput(Show1dec); | |
5756 | $('#brew_sparge_est').jqxNumberInput(Show1dec); | |
5757 | $('#brew_whirlpool9').jqxNumberInput(PosInt); | |
5758 | $('#brew_whirlpool9').jqxNumberInput({ max: 120 }); | |
5759 | $('#brew_cooling_to').jqxNumberInput(Spin1dec); | |
5760 | $('#brew_sparge_ph').jqxNumberInput(SpinpH); | |
5761 | $('#brew_whirlpool7').jqxNumberInput(PosInt); | |
5762 | $('#brew_whirlpool7').jqxNumberInput({ max: 120 }); | |
5763 | $('#brew_cooling_method').jqxDropDownList({ | |
5764 | theme: theme, | |
5765 | source: CoolingTypeAdapter, | |
5766 | valueMember: 'id', | |
5767 | displayMember: 'nl', | |
5768 | width: 180, | |
5769 | height: 23, | |
5770 | autoDropDownHeight: true | |
5771 | }); | |
5772 | $('#brew_whirlpool6').jqxNumberInput(PosInt); | |
5773 | $('#brew_whirlpool6').jqxNumberInput({ max: 120 }); | |
5774 | $('#brew_cooling_time').jqxNumberInput(PosInt); | |
5775 | $('#brew_cooling_time').jqxNumberInput({ max: 1440 }); | |
5776 | $('#brew_whirlpool2').jqxNumberInput(PosInt); | |
5777 | $('#brew_whirlpool2').jqxNumberInput({ max: 120 }); | |
5778 | $('#brew_aeration_type').jqxDropDownList({ | |
5779 | theme: theme, | |
5780 | source: AerationTypeAdapter, | |
5781 | valueMember: 'id', | |
5782 | displayMember: 'nl', | |
5783 | width: 180, | |
5784 | height: 23, | |
5785 | autoDropDownHeight: true | |
5786 | }); | |
5787 | $('#brew_aeration_time').jqxNumberInput(PosInt); | |
5788 | $('#brew_aeration_time').jqxNumberInput({ max: 1440 }); | |
5789 | $('#brew_aeration_speed').jqxNumberInput(PosInt); | |
5790 | $('#brew_aeration_speed').jqxNumberInput({ max: 1440 }); | |
5791 | $('#brew_fermenter_volume').jqxNumberInput(Show1dec); | |
5792 | $('#brew_fermenter_extrawater').jqxNumberInput(Spin1dec); | |
5793 | $('#brew_fermenter_sg').jqxNumberInput(Show3dec); | |
5794 | $('#brew_fermenter_tcloss').jqxNumberInput(Spin1dec); | |
5795 | $('#brew_fermenter_ibu').jqxNumberInput(Show0dec); | |
5796 | $('#brew_fermenter_color').jqxNumberInput(Show0dec); | |
5797 | $('#BLog').jqxButton({ template: 'info', width: '150px', theme: theme }); | |
5798 | $('#BLog').click(function() { | |
5799 | // Open log in a new tab. | |
5800 | window.open('log_brew.php?code=' + dataRecord.code + '&name=' + dataRecord.name); | |
5801 | }); | |
5802 | ||
5803 | // Tab 10, Fermentation | |
5804 | // Note, fermentation temps changes must do calcCarbonation() | |
5805 | $('#brew_fermenter_sg2').jqxTooltip({ content: 'Het behaalde SG in het gistvat, overgenomen van de brouwdag.' }); | |
5806 | $('#brew_fermenter_sg2').jqxNumberInput(Show3dec); | |
5807 | $('#primary_start_temp').jqxTooltip({ content: 'De begintemperatuur van de hoofdvergisting.' }); | |
5808 | $('#primary_start_temp').jqxNumberInput(YeastT); | |
5809 | $('#primary_max_temp').jqxTooltip({ content: 'De hoogst bereikte piek temperatuur tijdens de hoofgvergisting.' }); | |
5810 | $('#primary_max_temp').jqxNumberInput(YeastT); | |
5811 | $('#primary_end_temp').jqxTooltip({ content: 'De eind temperatuur van de hoofdvergisting.' }); | |
5812 | $('#primary_end_temp').jqxNumberInput(YeastT); | |
5813 | $('#primary_end_sg').jqxTooltip({ content: 'Het gemeten SG aan het eind van de hoofdvergisting.' }); | |
5814 | $('#primary_end_sg').jqxNumberInput(SGopts); | |
5815 | $('#primary_end_brix').jqxTooltip({ content: 'Hulpfinctie: de afgelezen °Brix RI waarde met een refractometer.' }); | |
5816 | $('#primary_end_brix').jqxNumberInput(Spin1dec); | |
5817 | $('#primary_svg').jqxTooltip({ content: 'De schijnbare vergisting graad behaald na de hoofdgisting.' }); | |
5818 | $('#primary_svg').jqxNumberInput(Show1dec); | |
5819 | $('#primary_end_date').jqxTooltip({ content: 'De eind datum van de hoofdvergisting en eventueel overhevelen.' }); | |
5820 | $('#primary_end_date').jqxDateTimeInput(Dateopts); | |
5821 | $('#primary_end_date').on('close', function(event) { calcStage(); }); | |
5822 | $('#secondary_temp').jqxNumberInput(YeastT); | |
5823 | $('#secondary_end_sg').jqxTooltip({ content: 'Het gemeten SG aan het eind van de navergisting.' }); | |
5824 | $('#secondary_end_sg').jqxNumberInput(SGopts); | |
5825 | $('#secondary_end_brix').jqxTooltip({ content: 'Hulpfinctie: de afgelezen °Brix RI waarde met een refractometer.' }); | |
5826 | $('#secondary_end_brix').jqxNumberInput(Spin1dec); | |
5827 | $('#secondary_svg').jqxTooltip({ content: 'De schijnbare vergisting graad behaald na de nagisting.' }); | |
5828 | $('#secondary_svg').jqxNumberInput(Show1dec); | |
5829 | $('#secondary_end_date').jqxTooltip({ content: 'De eind datum van de navergisting en het begin van het lageren.' }); | |
5830 | $('#secondary_end_date').jqxDateTimeInput(Dateopts); | |
5831 | $('#secondary_end_date').on('close', function(event) { calcStage(); }); | |
5832 | $('#tertiary_temp').jqxNumberInput(YeastT); | |
5833 | $('#fg').jqxNumberInput(Spin3dec); | |
5834 | $('#est_fg3').jqxTooltip({ content: 'Het verwachte eind SG. Dit wordt automatisch berekend.' }); | |
5835 | $('#est_fg3').jqxNumberInput(Show3dec); | |
5836 | $('#final_brix').jqxTooltip({ content: 'Hulpfinctie: de afgelezen °Brix RI waarde met een refractometer.' }); | |
5837 | $('#final_brix').jqxNumberInput(Spin1dec); | |
5838 | $('#final_abv').jqxNumberInput(Show2dec); | |
5839 | $('#final_svg').jqxNumberInput(Show1dec); | |
5840 | $('#FLog').jqxButton({ template: 'info', width: '150px', theme: theme }); | |
5841 | $('#FLog').click(function() { | |
5842 | // Open log in a new tab. | |
5843 | window.open('log_fermentation.php?code=' + dataRecord.code + '&name=' + dataRecord.name); | |
5844 | }); | |
5845 | ||
5846 | // Tab 11, Packaging | |
5847 | // TODO: high gravity packaging, extra water and recalc abv, color and ibu. | |
5848 | $('#package_date').jqxTooltip({ content: 'De verpakkings datum van dit bier.' }); | |
5849 | $('#package_date').jqxDateTimeInput(Dateopts); | |
5850 | $('#package_date').on('close', function(event) { calcStage(); }); | |
5851 | $('#package_volume').jqxTooltip({ content: 'Het beschikbare volume om te bottelen of op fust te zetten.' }); | |
5852 | $('#package_volume').jqxNumberInput(Spin1dec); | |
5853 | $('#package_infuse_amount').jqxTooltip({ content: 'De hoeveelheid water of drank extra toe te voegen.' }); | |
5854 | $('#package_infuse_amount').jqxNumberInput(Spin3dec); | |
5855 | $('#package_infuse_abv').jqxTooltip({ content: 'De hoeveelheid alcohol in de drank, of 0.0 als het water is.' }); | |
5856 | $('#package_infuse_abv').jqxNumberInput(Spin1dec); | |
5857 | $('#package_infuse_notes').jqxTooltip({ content: 'Omschrijving van de extra toevoeging.' }); | |
5858 | $('#package_infuse_notes').jqxInput({ theme: theme, width: 640, height: 23 }); | |
5859 | $('#package_abv').jqxTooltip({ content: 'De uiteindelijke hoeveelheid alcohol volume %.' }); | |
5860 | $('#package_abv').jqxNumberInput(Show2dec); | |
5861 | $('#package_ph').jqxTooltip({ content: 'De gemeten pH vlak voor het verpakken.' }); | |
5862 | $('#package_ph').jqxNumberInput(SpinpH); | |
5863 | $('#st_carb_min2').jqxTooltip({ content: 'Het minimum aanbevolen koolzuur volume voor deze bierstijl.'}); | |
5864 | $('#st_carb_min2').jqxNumberInput(Smal1dec); | |
5865 | $('#st_carb_max2').jqxTooltip({ content: 'Het maximum aamnevolen koolzuur volume voor deze bierstijl.'}); | |
5866 | $('#st_carb_max2').jqxNumberInput(Smal1dec); | |
5867 | $('#bottle_amount').jqxTooltip({ content: 'De totale hoeveelheid te bottelen bier.' }); | |
5868 | $('#bottle_amount').jqxNumberInput(Spin1dec); | |
5869 | $('#keg_amount').jqxTooltip({ content: 'De totale hoeveelheid op fust te zetten bier.' }); | |
5870 | $('#keg_amount').jqxNumberInput(Spin1dec); | |
5871 | $('#bottle_carbonation').jqxTooltip({ content: 'Het gewenste CO2 volume in de flessen.' }); | |
5872 | $('#bottle_carbonation').jqxNumberInput(Spin2dec); | |
5873 | $('#bottle_carbonation').jqxNumberInput({ max: 5 }); | |
5874 | $('#keg_carbonation').jqxTooltip({ content: 'Het gewenste CO2 volume door de suiker in de fusten.' }); | |
5875 | $('#keg_carbonation').jqxNumberInput(Spin2dec); | |
5876 | $('#keg_carbonation').jqxNumberInput({ max: 5 }); | |
5877 | $('#bottle_priming_sugar').jqxDropDownList({ | |
5878 | placeHolder: 'Kies suiker:', | |
5879 | theme: theme, | |
5880 | source: fermentablesugars, | |
5881 | displayMember: 'name', | |
5882 | width: 200, | |
5883 | height: 23, | |
5884 | dropDownWidth: 300, | |
5885 | dropDownHeight: 400 | |
5886 | }); | |
5887 | $('#bottle_priming_sugar').on('select', function(event) { | |
5888 | if (event.args) { | |
5889 | var rowID, index, editrow = -1, datarecord, rows, i, row = {}; | |
5890 | index = event.args.index; | |
5891 | datarecord = fermentablesugars.records[index]; | |
5892 | rows = $('#fermentableGrid').jqxGrid('getrows'); | |
5893 | for (i = 0; i < rows.length; i++) { | |
5894 | if (rows[i].f_added == 4) { | |
5895 | editrow = i; | |
5896 | } | |
5897 | } | |
5898 | row['f_name'] = datarecord.name; | |
5899 | row['f_origin'] = datarecord.origin; | |
5900 | row['f_supplier'] = datarecord.supplier; | |
5901 | row['f_amount'] = parseFloat($('#bottle_priming_total').jqxNumberInput('decimal')) / 1000; | |
5902 | row['f_cost'] = datarecord.cost; | |
5903 | row['f_type'] = datarecord.type; | |
5904 | row['f_yield'] = datarecord.yield; | |
5905 | row['f_color'] = datarecord.color; | |
5906 | row['f_coarse_fine_diff'] = datarecord.coarse_fine_diff; | |
5907 | row['f_moisture'] = datarecord.moisture; | |
5908 | row['f_diastatic_power'] = datarecord.diastatic_power; | |
5909 | row['f_protein'] = datarecord.protein; | |
5910 | row['f_max_in_batch'] = datarecord.max_in_batch; | |
5911 | row['f_graintype'] = datarecord.graintype; | |
5912 | row['f_added'] = 4; | |
5913 | row['f_dissolved_protein'] = datarecord.dissolved_protein; | |
5914 | row['f_recommend_mash'] = datarecord.recommend_mash; | |
5915 | row['f_add_after_boil'] = 1; | |
5916 | row['f_adjust_to_total_100'] = 0; | |
5917 | row['f_percentage'] = 0; | |
5918 | row['f_di_ph'] = datarecord.di_ph; | |
5919 | row['f_acid_to_ph_57'] = datarecord.acid_to_ph_57; | |
5920 | row['f_inventory'] = datarecord.inventory; | |
5921 | if (editrow >= 0) { | |
5922 | rowID = $('#fermentableGrid').jqxGrid('getrowid', editrow); | |
5923 | $('#fermentableGrid').jqxGrid('updaterow', rowID, row); | |
5924 | } else { | |
5925 | $('#fermentableGrid').jqxGrid('addrow', null, row); | |
5926 | } | |
5927 | calcCarbonation(); | |
5928 | } | |
5929 | }); | |
5930 | $('#keg_priming_sugar').jqxDropDownList({ | |
5931 | placeHolder: 'Kies suiker:', | |
5932 | theme: theme, | |
5933 | source: fermentablesugars, | |
5934 | displayMember: 'name', | |
5935 | width: 200, | |
5936 | height: 23, | |
5937 | dropDownWidth: 300, | |
5938 | dropDownHeight: 400 | |
5939 | }); | |
5940 | $('#keg_priming_sugar').on('select', function(event) { | |
5941 | if (event.args) { | |
5942 | var rowID, index, editrow = -1, datarecord, rows, i, row = {}; | |
5943 | index = event.args.index; | |
5944 | datarecord = fermentablesugars.records[index]; | |
5945 | rows = $('#fermentableGrid').jqxGrid('getrows'); | |
5946 | for (i = 0; i < rows.length; i++) { | |
5947 | if (rows[i].f_added == 5) { | |
5948 | editrow = i; | |
5949 | } | |
5950 | } | |
5951 | row['f_name'] = datarecord.name; | |
5952 | row['f_origin'] = datarecord.origin; | |
5953 | row['f_supplier'] = datarecord.supplier; | |
5954 | row['f_amount'] = parseFloat($('#keg_priming_total').jqxNumberInput('decimal')) / 1000; | |
5955 | row['f_cost'] = datarecord.cost; | |
5956 | row['f_type'] = datarecord.type; | |
5957 | row['f_yield'] = datarecord.yield; | |
5958 | row['f_color'] = datarecord.color; | |
5959 | row['f_coarse_fine_diff'] = datarecord.coarse_fine_diff; | |
5960 | row['f_moisture'] = datarecord.moisture; | |
5961 | row['f_diastatic_power'] = datarecord.diastatic_power; | |
5962 | row['f_protein'] = datarecord.protein; | |
5963 | row['f_max_in_batch'] = datarecord.max_in_batch; | |
5964 | row['f_graintype'] = datarecord.graintype; | |
5965 | row['f_added'] = 5; | |
5966 | row['f_dissolved_protein'] = datarecord.dissolved_protein; | |
5967 | row['f_recommend_mash'] = datarecord.recommend_mash; | |
5968 | row['f_add_after_boil'] = 1; | |
5969 | row['f_adjust_to_total_100'] = 0; | |
5970 | row['f_percentage'] = 0; | |
5971 | row['f_di_ph'] = datarecord.di_ph; | |
5972 | row['f_acid_to_ph_57'] = datarecord.acid_to_ph_57; | |
5973 | row['f_inventory'] = datarecord.inventory; | |
5974 | if (editrow >= 0) { | |
5975 | rowID = $('#fermentableGrid').jqxGrid('getrowid', editrow); | |
5976 | $('#fermentableGrid').jqxGrid('updaterow', rowID, row); | |
5977 | } else { | |
5978 | $('#fermentableGrid').jqxGrid('addrow', null, row); | |
5979 | } | |
5980 | calcCarbonation(); | |
5981 | } | |
5982 | }); | |
5983 | $('#bottle_priming_amount').jqxNumberInput(Show1dec); | |
5984 | $('#bottle_priming_water').jqxTooltip({ content: 'De hoeveelheid water om de suiker op te lossen.' }); | |
5985 | $('#bottle_priming_water').jqxNumberInput(Spin3dec); | |
5986 | $('#keg_priming_amount').jqxNumberInput(Show1dec); | |
5987 | $('#keg_priming_water').jqxTooltip({ content: 'De hoeveelheid water om de suiker op te lossen.' }); | |
5988 | $('#keg_priming_water').jqxNumberInput(Spin3dec); | |
5989 | $('#bottle_priming_total').jqxNumberInput(Show1dec); | |
5990 | $('#bottle_pressure').jqxTooltip({ content: 'De maximaal te verwachten druk tijdens het hergisten.' }); | |
5991 | $('#bottle_pressure').jqxNumberInput(Show1dec); | |
5992 | $('#keg_priming_total').jqxNumberInput(Show1dec); | |
5993 | $('#keg_forced_carb').jqxCheckBox({ theme: theme, width: 120, height: 23 }); | |
5994 | $('#keg_pressure').jqxNumberInput(Show1dec); | |
5995 | $('#bottle_abv').jqxNumberInput(Show2dec); | |
5996 | $('#keg_abv').jqxNumberInput(Show2dec); | |
5997 | $('#bottle_carbonation_temp').jqxNumberInput(YeastT); | |
5998 | $('#keg_carbonation_temp').jqxNumberInput(YeastT); | |
5999 | ||
6000 | // Tab 12, Tasting | |
6001 | $('#taste_date').jqxTooltip({ content: 'De proef datum van dit bier.' }); | |
6002 | $('#taste_date').jqxDateTimeInput(Dateopts); | |
6003 | $('#taste_date').on('close', function(event) { calcStage(); }); | |
6004 | $('#taste_rate').jqxTooltip({ content: 'Het cijfer voor dit bier van 1 tot 10.' }); | |
6005 | $('#taste_rate').jqxNumberInput(Spin1dec); | |
6006 | $('#taste_rate').jqxNumberInput({ max: 10 }); | |
6007 | $('#taste_color').jqxTooltip({ content: 'De kleur van het bier.' }); | |
6008 | $('#taste_color').jqxInput({ theme: theme, width: 320, height: 23 }); | |
6009 | $('#taste_transparency').jqxTooltip({ content: 'De helderheid van het bier.' }); | |
6010 | $('#taste_transparency').jqxInput({ theme: theme, width: 320, height: 23 }); | |
6011 | $('#taste_head').jqxTooltip({ content: 'Het schuim op het bier.' }); | |
6012 | $('#taste_head').jqxInput({ theme: theme, width: 320, height: 23 }); | |
6013 | $('#taste_aroma').jqxTooltip({ content: 'Het aroma van het bier.' }); | |
6014 | $('#taste_aroma').jqxInput({ theme: theme, width: 960, height: 23 }); | |
6015 | $('#taste_taste').jqxTooltip({ content: 'De smaak van het bier.' }); | |
6016 | $('#taste_taste').jqxInput({ theme: theme, width: 960, height: 23 }); | |
6017 | $('#taste_aftertaste').jqxTooltip({ content: 'De nasmaak van het bier.' }); | |
6018 | $('#taste_aftertaste').jqxInput({ theme: theme, width: 960, height: 23 }); | |
6019 | $('#taste_mouthfeel').jqxTooltip({ content: 'Het mondgevoelvan het bier.' }); | |
6020 | $('#taste_mouthfeel').jqxInput({ theme: theme, width: 960, height: 23 }); | |
6021 | $('#taste_notes').jqxTooltip({ content: 'Het oordeel en opmerkingen over dit bier.' }); | |
6022 | $('#taste_notes').jqxInput({ theme: theme, width: 960, height: 100 }); | |
6023 | ||
6024 | $('#jqxTabs').jqxTabs({ | |
6025 | theme: theme, | |
6026 | width: 1280, | |
6027 | height: 660, | |
6028 | autoHeight: false, | |
6029 | position: 'top' | |
6030 | }); | |
6031 | ||
6032 | // Buttons below | |
6033 | $('#Export').jqxButton({ template: 'info', width: '80px', theme: theme }); | |
6034 | $('#Export').bind('click', function() { | |
489
18e5cfe5d126
Load new url in database write callback
Michiel Broek <mbroek@mbse.eu>
parents:
484
diff
changeset
|
6035 | saveRecord(0); |
478 | 6036 | }); |
6037 | ||
6038 | $('#Delete').jqxButton({ template: 'danger', width: '80px', theme: theme }); | |
6039 | $('#Delete').bind('click', function() { | |
6040 | // Open a popup to confirm this action. | |
6041 | $('#eventWindow').jqxWindow('open'); | |
6042 | $('#delOk').click(function() { | |
6043 | var data = 'delete=true&' + $.param({ uuid: dataRecord.uuid }); | |
6044 | $.ajax({ | |
6045 | dataType: 'json', | |
6046 | url: url, | |
6047 | cache: false, | |
6048 | data: data, | |
6049 | type: 'POST', | |
6050 | success: function(data, status, xhr) { | |
6051 | // delete command is executed. | |
6052 | window.location.href = my_return; | |
6053 | }, | |
6054 | error: function(jqXHR, textStatus, errorThrown) { | |
6055 | } | |
6056 | }); | |
6057 | }); | |
6058 | }); | |
6059 | ||
6060 | $('#Cancel').jqxButton({ template: 'primary', width: '80px', theme: theme }); | |
6061 | $('#Cancel').bind('click', function() { | |
6062 | window.location.href = my_return; | |
6063 | }); | |
6064 | ||
6065 | $('#Save').jqxButton({ template: 'success', width: '80px', theme: theme }); | |
6066 | $('#Save').bind('click', function() { | |
489
18e5cfe5d126
Load new url in database write callback
Michiel Broek <mbroek@mbse.eu>
parents:
484
diff
changeset
|
6067 | saveRecord(1); |
478 | 6068 | }); |
6069 | createDelElements(); | |
111
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6070 | }); |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6071 |