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