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