www/js/prod_new.js

changeset 816
d76f623d487c
parent 815
5714ea86187d
child 817
6ee186182c70
equal deleted inserted replaced
815:5714ea86187d 816:d76f623d487c
1 /*****************************************************************************
2 * Copyright (C) 2018-2020
3 *
4 * Michiel Broek <mbroek at mbse dot eu>
5 *
6 * This file is part of BMS
7 *
8 * This is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2, or (at your option) any
11 * later version.
12 *
13 * BrewCloud is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with ThermFerm; see the file COPYING. If not, write to the Free
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 *****************************************************************************/
22
23
24 $(document).ready(function() {
25
26 // Tab 1, base
27 $('#name').jqxTooltip({ content: 'De naam voor dit brouw project.' });
28 $('#name').jqxInput({ theme: theme, width: 640, height: 23 });
29 $('#code').jqxTooltip({ content: 'Het unieke code nummer van dit brouw project.' });
30 $('#code').jqxInput({ theme: theme, width: 100, height: 23 });
31 $('#notes').jqxTooltip({ content: 'De uitgebreide opmerkingen over dit project.' });
32 $('#notes').jqxInput({ theme: theme, width: 960, height: 200 });
33 $('#type').jqxDropDownList({
34 theme: theme,
35 source: RecipeTypeAdapter,
36 valueMember: 'id',
37 displayMember: 'nl',
38 width: 180,
39 height: 23,
40 autoDropDownHeight: true
41 });
42 $('#type').jqxDropDownList('selectItem', 2);
43 $('#type').on('select', function(event) {
44 if (event.args) {
45 recipe_type = event.args.index;
46 }
47 });
48
49 // Tab 2, style
50 $('#st_name').jqxTooltip({ content: 'De bierstijl naam voor dit recept.'});
51 $('#st_name').jqxInput({ theme: theme, width: 250, height: 23 });
52 $('#st_category').jqxTooltip({ content: 'De Amerikaanse bierstijl categorie.'});
53 $('#st_category').jqxInput({ theme: theme, width: 250, height: 23 });
54 $('#st_category_number').jqxTooltip({ content: 'De Amerikaanse bierstijl categorie sub nummer.'});
55 $('#st_category_number').jqxInput({ theme: theme, width: 70, height: 23 });
56 $('#st_letter').jqxTooltip({ content: 'De bierstijl letter voor dit recept.'});
57 $('#st_letter').jqxInput({ theme: theme, width: 250, height: 23 });
58 $('#st_guide').jqxTooltip({ content: 'De bierstijl gids voor dit recept.'});
59 $('#st_guide').jqxInput({ theme: theme, width: 250, height: 23 });
60 $('#st_notes').jqxInput({ theme: theme, width: 800, height: 100 });
61 $('#st_type').jqxTooltip({ content: 'Het bierstijl type.'});
62 $('#st_type').jqxInput({ theme: theme, width: 250, height: 23 });
63 $('#st_og_min').jqxTooltip({ content: 'Het minimum begin SG voor deze bierstijl.'});
64 $('#st_og_min').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 3, readOnly: true });
65 $('#st_og_max').jqxTooltip({ content: 'Het maximum begin SG voor deze bierstijl.'});
66 $('#st_og_max').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 3, readOnly: true });
67 $('#st_fg_min').jqxTooltip({ content: 'Het minimum eind SG voor deze bierstijl.'});
68 $('#st_fg_min').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 3, readOnly: true });
69 $('#st_fg_max').jqxTooltip({ content: 'Het maximum eind SG voor deze bierstijl.'});
70 $('#st_fg_max').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 3, readOnly: true });
71 $('#st_ibu_min').jqxTooltip({ content: 'De minimum bitterheid voor deze bierstijl.'});
72 $('#st_ibu_min').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 0, readOnly: true });
73 $('#st_ibu_max').jqxTooltip({ content: 'De maximum bitterheid voor deze bierstijl.'});
74 $('#st_ibu_max').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 0, readOnly: true });
75 $('#st_color_min').jqxTooltip({ content: 'De minimum kleur voor deze bierstijl.'});
76 $('#st_color_min').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 0, readOnly: true });
77 $('#st_color_max').jqxTooltip({ content: 'De maximum kleur voor deze bierstijl.'});
78 $('#st_color_max').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 0, readOnly: true });
79 $('#st_carb_min').jqxTooltip({ content: 'Het minimum koolzuur volume voor deze bierstijl.'});
80 $('#st_carb_min').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 1, readOnly: true });
81 $('#st_carb_max').jqxTooltip({ content: 'Het maximum koolzuur volume voor deze bierstijl.'});
82 $('#st_carb_max').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 1, readOnly: true });
83 $('#st_abv_min').jqxTooltip({ content: 'Het minimum alcohol volume % voor deze bierstijl.'});
84 $('#st_abv_min').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 1, readOnly: true });
85 $('#st_abv_max').jqxTooltip({ content: 'Het maximum alcohol volume % voor deze bierstijl.'});
86 $('#st_abv_max').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 1, readOnly: true });
87 $('#st_profile').jqxInput({ theme: theme, width: 800, height: 48 });
88 $('#st_ingredients').jqxInput({ theme: theme, width: 800, height: 23 });
89 $('#st_examples').jqxInput({ theme: theme, width: 800, height: 48 });
90 $('#styleSelect').jqxDropDownList({
91 placeHolder: 'Kies bierstijl:',
92 theme: theme,
93 source: styleslist,
94 displayMember: 'name',
95 width: 250,
96 height: 27,
97 dropDownWidth: 500,
98 dropDownHeight: 500,
99 renderer: function(index, label, value) {
100 var datarecord = styleslist.records[index];
101 return datarecord.style_guide + ' ' + datarecord.style_letter + ' ' + datarecord.name;
102 }
103 });
104 $('#styleSelect').on('select', function(event) {
105 if (event.args) {
106 var index = event.args.index,
107 datarecord = styleslist.records[index];
108 $('#st_name').val(datarecord.name);
109 $('#st_category').val(datarecord.category);
110 $('#st_category_number').val(datarecord.category_number);
111 $('#st_letter').val(datarecord.style_letter);
112 $('#st_guide').val(datarecord.style_guide);
113 style_type = datarecord.type;
114 $('#st_type').val(StyleTypeData[datarecord.type].nl);
115 $('#st_og_min').val(datarecord.og_min);
116 $('#st_og_max').val(datarecord.og_max);
117 $('#st_fg_min').val(datarecord.fg_min);
118 $('#st_fg_max').val(datarecord.fg_max);
119 $('#st_ibu_min').val(datarecord.ibu_min);
120 $('#st_ibu_max').val(datarecord.ibu_max);
121 $('#st_color_min').val(datarecord.color_min);
122 $('#st_color_max').val(datarecord.color_max);
123 $('#st_carb_min').val(datarecord.carb_min);
124 $('#st_carb_max').val(datarecord.carb_max);
125 $('#st_abv_min').val(datarecord.abv_min);
126 $('#st_abv_max').val(datarecord.abv_max);
127 $('#st_notes').val(datarecord.notes);
128 $('#st_profile').val(datarecord.profile);
129 $('#st_ingredients').val(datarecord.ingredients);
130 $('#st_examples').val(datarecord.examples);
131 }
132 });
133
134 // Tab 3, equipment
135 $('#eq_name').jqxTooltip({ content: 'De naam van deze brouw apparatuur.' });
136 $('#eq_name').jqxInput({ theme: theme, width: 250, height: 23 });
137 $('#eq_calc_boil_volume').jqxCheckBox({ theme: theme, width: 120, height: 23, disabled: true });
138 $('#eq_boil_size').jqxTooltip({ content: 'Normaal kook volume in liters' });
139 $('#eq_boil_size').jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 1 });
140 $('#eq_batch_size').jqxTooltip({ content: 'Berekende batch grootte in liters aan het eind van de kook.' });
141 $('#eq_batch_size').jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 1 });
142 $('#eq_tun_volume').jqxTooltip({ content: 'Maisch ketel volume.' });
143 $('#eq_tun_volume').jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 1 });
144 $('#eq_tun_weight').jqxTooltip({ content: 'Maisch ketel gewicht.' });
145 $('#eq_tun_weight').jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 1 });
146 $('#eq_tun_height').jqxTooltip({ content: 'Maisch ketel hoogte.' });
147 $('#eq_tun_height').jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 1 });
148 $('#eq_tun_material').jqxTooltip({ content: 'Maisch ketel materiaal.' });
149 $('#eq_tun_material').jqxInput({ theme: theme, width: 180, height: 23 });
150 $('#eq_tun_specific_heat').jqxTooltip({ content: 'Maisch ketel warmte geleiding.' });
151 $('#eq_tun_specific_heat').jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 3 });
152 $('#eq_top_up_water').jqxTooltip({ content: 'Extra water in het gistvat.' });
153 $('#eq_top_up_water').jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 1 });
154 $('#eq_trub_chiller_loss').jqxTooltip({ content: 'Standaard verlies bij het overbrengen naar het gistvat.' });
155 $('#eq_trub_chiller_loss').jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 1 });
156 $('#eq_evap_rate').jqxTooltip({ content: 'Verdamping in liters per uur.' });
157 $('#eq_evap_rate').jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 2 });
158 $('#eq_boil_time').jqxTooltip({ content: 'Normale kooktijd in minuten.' });
159 $('#eq_boil_time').jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 0 });
160 $('#eq_top_up_kettle').jqxTooltip({ content: 'Extra water toevoegen tijdens de kook.' });
161 $('#eq_top_up_kettle').jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 1 });
162 $('#eq_hop_utilization').jqxTooltip({ content: '100% voor kleine installaties, hoger voor grote brouwerijen.' });
163 $('#eq_hop_utilization').jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 0 });
164 $('#eq_notes').jqxTooltip({ content: 'Opmerkingen over deze apparatuur.' });
165 $('#eq_notes').jqxInput({ theme: theme, width: 960, height: 100 });
166 $('#eq_lauter_volume').jqxTooltip({ content: 'Filterkuip volume.' });
167 $('#eq_lauter_volume').jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 1 });
168 $('#eq_lauter_height').jqxTooltip({ content: 'Filterkuip hoogte.' });
169 $('#eq_lauter_height').jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 1 });
170 $('#eq_lauter_deadspace').jqxTooltip({ content: 'Filterkuip verlies in liters.' });
171 $('#eq_lauter_deadspace').jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 1 });
172 $('#eq_kettle_volume').jqxTooltip({ content: 'Kook ketel volume in liters.' });
173 $('#eq_kettle_volume').jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 1 });
174 $('#eq_kettle_height').jqxTooltip({ content: 'Kook ketel hoogte in cm.' });
175 $('#eq_kettle_height').jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 1 });
176 $('#eq_mash_volume').jqxTooltip({ content: 'Maisch water voor de eerste stap.' });
177 $('#eq_mash_volume').jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 1 });
178 $('#eq_mash_max').jqxTooltip({ content: 'De maximale moutstort in Kg.' });
179 $('#eq_mash_max').jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 1 });
180 $('#eq_efficiency').jqxTooltip({ content: 'Gemiddeld brouwzaal rendement.' });
181 $('#eq_efficiency').jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 1 });
182 $('#equipmentSelect').jqxDropDownList({
183 placeHolder: 'Kies apparatuur:',
184 theme: theme,
185 source: equipmentlist,
186 displayMember: 'name',
187 width: 250,
188 height: 27,
189 dropDownWidth: 300,
190 renderer: function(index, label, value) {
191 var datarecord = equipmentlist.records[index];
192 return datarecord.batch_size + ' liter ' + datarecord.name;
193 }
194 });
195 $('#equipmentSelect').on('select', function(event) {
196 if (event.args) {
197 var index = event.args.index,
198 datarecord = equipmentlist.records[index];
199 $('#eq_name').val(datarecord.name);
200 $('#eq_boil_size').val(datarecord.boil_size);
201 $('#eq_batch_size').val(datarecord.batch_size);
202 $('#eq_tun_volume').val(datarecord.tun_volume);
203 $('#eq_tun_weight').val(datarecord.tun_weight);
204 $('#eq_tun_specific_heat').val(datarecord.tun_specific_heat);
205 tun_material = datarecord.tun_material;
206 $('#eq_tun_material').val(MaterialData[datarecord.tun_material].nl);
207 $('#eq_tun_height').val(datarecord.tun_height);
208 $('#eq_top_up_water').val(datarecord.top_up_water);
209 $('#eq_trub_chiller_loss').val(datarecord.trub_chiller_loss);
210 $('#eq_evap_rate').val(datarecord.evap_rate);
211 $('#eq_boil_time').val(datarecord.boil_time);
212 $('#eq_calc_boil_volume').val(datarecord.calc_boil_volume);
213 $('#eq_top_up_kettle').val(datarecord.top_up_kettle);
214 $('#eq_hop_utilization').val(datarecord.hop_utilization);
215 $('#eq_notes').val(datarecord.notes);
216 $('#eq_lauter_volume').val(datarecord.lauter_volume);
217 $('#eq_lauter_height').val(datarecord.lauter_height);
218 $('#eq_lauter_deadspace').val(datarecord.lauter_deadspace);
219 $('#eq_kettle_volume').val(datarecord.kettle_volume);
220 $('#eq_kettle_height').val(datarecord.kettle_height);
221 $('#eq_mash_volume').val(datarecord.mash_volume);
222 $('#eq_mash_max').val(datarecord.mash_max);
223 $('#eq_efficiency').val(datarecord.efficiency);
224 }
225 });
226
227 var recipe_type = 2,
228 style_type = 0,
229 tun_material = 0,
230 wizard = (function() { // Creating wizard module
231
232 //Adding event listeners
233 var _addHandlers = function() {
234 $('#name').on('change', function(event) { wizard.validate(true); });
235 $('#code').on('change', function(event) { wizard.validate(true); });
236 $('#type').on('change', function(event) { wizard.validate(true); });
237 $('#styleSelect').on('change', function(event) { wizard.validate(true); });
238 $('#equipmentSelect').on('change', function(event) { wizard.validate(true); });
239 $('#nextButtonCompleted').click(function() {
240 var d = new Date(),
241 m = d.getMonth() + 1,
242 b = d.getFullYear() + '-',
243 newrow, data;
244 if (m < 10)
245 b = b + '0';
246 b = b + m + '-';
247 if (d.getDate() < 10)
248 b = b + '0';
249 b = b + d.getDate();
250 newrow = {
251 record: -1,
252 name: $('#name').val(),
253 code: $('#code').val(),
254 birth: b,
255 stage: 0,
256 notes: $('#notes').val(),
257 log_brew: 0,
258 log_fermentation: 0,
259 log_ispindel: 0,
260 log_co2pressure: 0,
261 inventory_reduced: 0,
262 locked: 0,
263 eq_name: $('#eq_name').val(),
264 eq_boil_size: parseFloat($('#eq_boil_size').jqxNumberInput('decimal')),
265 eq_batch_size: parseFloat($('#eq_batch_size').jqxNumberInput('decimal')),
266 eq_tun_volume: parseFloat($('#eq_tun_volume').jqxNumberInput('decimal')),
267 eq_tun_weight: parseFloat($('#eq_tun_weight').jqxNumberInput('decimal')),
268 eq_tun_specific_heat: parseFloat($('#eq_tun_specific_heat').jqxNumberInput('decimal')),
269 eq_tun_material: tun_material,
270 eq_tun_height: parseFloat($('#eq_tun_height').jqxNumberInput('decimal')) / 100,
271 eq_top_up_water: parseFloat($('#eq_top_up_water').jqxNumberInput('decimal')),
272 eq_trub_chiller_loss: parseFloat($('#eq_trub_chiller_loss').jqxNumberInput('decimal')),
273 eq_evap_rate: parseFloat($('#eq_evap_rate').jqxNumberInput('decimal')),
274 eq_boil_time: parseFloat($('#eq_boil_time').jqxNumberInput('decimal')),
275 eq_calc_boil_volume: $('#eq_calc_boil_volume').val() ?1:0,
276 eq_top_up_kettle: parseFloat($('#eq_top_up_kettle').jqxNumberInput('decimal')),
277 eq_hop_utilization: parseFloat($('#eq_hop_utilization').jqxNumberInput('decimal')),
278 eq_notes: $('#eq_notes').val(),
279 eq_lauter_volume: parseFloat($('#eq_lauter_volume').jqxNumberInput('decimal')),
280 eq_lauter_height: parseFloat($('#eq_lauter_height').jqxNumberInput('decimal')) / 100,
281 eq_lauter_deadspace: parseFloat($('#eq_lauter_deadspace').jqxNumberInput('decimal')),
282 eq_kettle_volume: parseFloat($('#eq_kettle_volume').jqxNumberInput('decimal')),
283 eq_kettle_height: parseFloat($('#eq_kettle_height').jqxNumberInput('decimal')) / 100,
284 eq_mash_volume: parseFloat($('#eq_mash_volume').jqxNumberInput('decimal')),
285 eq_mash_max: parseFloat($('#eq_mash_max').jqxNumberInput('decimal')),
286 eq_efficiency: parseFloat($('#eq_efficiency').jqxNumberInput('decimal')),
287 brew_date_start: '',
288 brew_mash_ph: 0.0,
289 brew_mash_sg: 1.000,
290 brew_mash_efficiency: 0,
291 brew_sparge_ph: 0.0,
292 brew_sparge_temperature: 85,
293 brew_sparge_est: 0,
294 brew_preboil_volume: 0,
295 brew_preboil_sg: 0,
296 brew_preboil_ph: 0.0,
297 brew_preboil_efficiency: 0,
298 brew_aboil_volume: 0,
299 brew_aboil_sg: 0,
300 brew_aboil_ph: 0.0,
301 brew_aboil_efficiency: 0,
302 brew_cooling_method: 0,
303 brew_cooling_time: 0,
304 brew_cooling_to: 20,
305 brew_whirlpool9: 0,
306 brew_whirlpool7: 0,
307 brew_whirlpool6: 0,
308 brew_whirlpool2: 0,
309 brew_fermenter_volume: parseFloat($('#eq_batch_size').jqxNumberInput('decimal')) -
310 parseFloat($('#eq_trub_chiller_loss').jqxNumberInput('decimal')) +
311 parseFloat($('#eq_top_up_water').jqxNumberInput('decimal')),
312 brew_fermenter_extrawater: parseFloat($('#eq_top_up_water').jqxNumberInput('decimal')),
313 brew_fermenter_tcloss: parseFloat($('#eq_trub_chiller_loss').jqxNumberInput('decimal')),
314 brew_aeration_time: 0,
315 brew_aeration_speed: 0,
316 brew_aeration_type: 0,
317 brew_fermenter_sg: 0,
318 brew_fermenter_ibu: 0,
319 brew_fermenter_color: 0,
320 brew_date_end: '',
321 og: 0,
322 fg: 0,
323 primary_start_temp: 0,
324 primary_max_temp: 0,
325 primary_end_temp: 0,
326 primary_end_sg: 0,
327 primary_end_date: '',
328 secondary_temp: 0,
329 secondary_end_date: '',
330 secondary_end_sg: 0,
331 tertiary_temp: 0,
332 package_date: '',
333 package_volume: 0,
334 package_infuse_amount: 0,
335 package_infuse_abv: 0,
336 package_infuse_notes: '',
337 package_abv: 0,
338 package_ph: 0,
339 bottle_amount: 0,
340 bottle_carbonation: 0,
341 bottle_priming_water: 0,
342 bottle_priming_amount: 0,
343 bottle_carbonation_temp: 23,
344 keg_amount: 0,
345 keg_carbonation: 0,
346 keg_priming_water: 0,
347 keg_priming_amount: 0,
348 keg_carbonation_temp: 23,
349 keg_forced_carb: 1,
350 keg_pressure: 0,
351 taste_notes: '',
352 taste_rate: 0,
353 taste_date: '',
354 taste_color: '',
355 taste_transparency: '',
356 taste_head: '',
357 taste_aroma: '',
358 taste_taste: '',
359 taste_mouthfeel: '',
360 taste_aftertaste: '',
361 st_name: $('#st_name').val(),
362 st_letter: $('#st_letter').val(),
363 st_guide: $('#st_guide').val(),
364 st_type: style_type,
365 st_category: $('#st_category').val(),
366 st_category_number: $('#st_category_number').val(),
367 st_og_min: parseFloat($('#st_og_min').jqxNumberInput('decimal')),
368 st_og_max: parseFloat($('#st_og_max').jqxNumberInput('decimal')),
369 st_fg_min: parseFloat($('#st_fg_min').jqxNumberInput('decimal')),
370 st_fg_max: parseFloat($('#st_fg_max').jqxNumberInput('decimal')),
371 st_ibu_min: parseFloat($('#st_ibu_min').jqxNumberInput('decimal')),
372 st_ibu_max: parseFloat($('#st_ibu_max').jqxNumberInput('decimal')),
373 st_color_min: parseFloat($('#st_color_min').jqxNumberInput('decimal')),
374 st_color_max: parseFloat($('#st_color_max').jqxNumberInput('decimal')),
375 st_carb_min: parseFloat($('#st_carb_min').jqxNumberInput('decimal')),
376 st_carb_max: parseFloat($('#st_carb_max').jqxNumberInput('decimal')),
377 st_abv_min: parseFloat($('#st_abv_min').jqxNumberInput('decimal')),
378 st_abv_max: parseFloat($('#st_abv_max').jqxNumberInput('decimal')),
379 type: recipe_type,
380 batch_size: parseFloat($('#eq_batch_size').jqxNumberInput('decimal')),
381 boil_size: parseFloat($('#eq_boil_size').jqxNumberInput('decimal')),
382 boil_time: parseFloat($('#eq_boil_time').jqxNumberInput('decimal')),
383 efficiency: parseFloat($('#eq_efficiency').jqxNumberInput('decimal')),
384 est_og: 0.000,
385 est_og3: 0.000,
386 est_fg: 0.000,
387 est_color: 0,
388 est_abv: 0.0,
389 est_carb: 0.0,
390 color_method: 0,
391 est_ibu: 0,
392 ibu_method: 0,
393 mash_name: '',
394 mash_ph: 5.4,
395 sparge_temp: 85.0,
396 sparge_volume: parseFloat($('#eq_boil_size').jqxNumberInput('decimal')) / 2,
397 sparge_ph: 5.8,
398 sparge_source: 0,
399 sparge_acid_type: 0,
400 sparge_acid_perc: 80,
401 sparge_acid_amount: 0,
402 calc_acid: 1,
403 w1_name: 'Tap water',
404 w1_amount: parseFloat($('#eq_mash_volume').jqxNumberInput('decimal')),
405 w1_calcium: 0,
406 w1_sulfate: 0,
407 w1_chloride: 0,
408 w1_sodium: 0,
409 w1_magnesium: 0,
410 w1_total_alkalinity: 0,
411 w1_ph: 7.0,
412 w1_cost: 0.0,
413 wa_acid_name: 0, // Lactic acid
414 wa_acid_perc: 80,
415 wa_base_name: 0,
416 wg_amount: parseFloat($('#eq_mash_volume').jqxNumberInput('decimal')),
417 wg_calcium: 0,
418 wg_sulfate: 0,
419 wg_chloride: 0,
420 wg_sodium: 0,
421 wg_magnesium: 0,
422 wg_total_alkalinity: 0,
423 wg_ph: 7.0,
424 wb_calcium: 0,
425 wb_sulfate: 0,
426 wb_sodium: 0,
427 wb_chloride: 0,
428 wb_magnesium: 0,
429 wb_total_alkalinity: 0,
430 wb_ph: 0,
431 starter_enable: 0,
432 divide_type: 0,
433 divide_size: 0,
434 divide_factor: 1,
435 divide_parts: 0,
436 divide_part: 0
437 };
438 data = 'insert=true&return=' + my_return + '&' + $.param(newrow);
439 $.ajax({
440 dataType: 'json',
441 url: 'includes/db_product.php',
442 cache: false,
443 data: data,
444 type: 'POST',
445 success: function(data, status, xhr) {
446 window.location.href = my_return;
447 },
448 error: function(jqXHR, textStatus, errorThrown) {
449 }
450 });
451 });
452 $('.nextButton').click(function() {
453 wizard.validate(true);
454 $('#jqxTabs').jqxTabs('next');
455 });
456 $('.backButton').click(function() {
457 wizard.validate(true);
458 $('#jqxTabs').jqxTabs('previous');
459 });
460 };
461
462 return {
463 //Initializing the wizzard - creating all elements, adding event handlers and starting the validation
464 init: function() {
465 $('#jqxTabs').jqxTabs({
466 theme: theme,
467 height: 630,
468 width: 1280,
469 autoHeight: false,
470 position: 'top',
471 keyboardNavigation: false
472 });
473 $('#nextButtonBase').jqxButton({ theme: theme, width: 150 });
474 $('#nextButtonStyle').jqxButton({ theme: theme, width: 150});
475 $('#backButtonStyle').jqxButton({ theme: theme, template: 'success', width: 150});
476 $('#nextButtonEq').jqxButton({ theme: theme, width: 150});
477 $('#backButtonEq').jqxButton({ theme: theme, template: 'success', width: 150});
478 $('#nextButtonCompleted').jqxButton({ theme: theme, template: 'success', width: 150});
479 $('#backButtonCompleted').jqxButton({ theme: theme, template: 'success', width: 150});
480 _addHandlers();
481 this.validate();
482 this.showHint('Validation hints.');
483 },
484
485 //Validating all wizard tabs
486 validate: function(notify) {
487 if (!this.firstTab(notify)) {
488 $('#jqxTabs').jqxTabs('disableAt', 1);
489 $('#jqxTabs').jqxTabs('disableAt', 2);
490 $('#jqxTabs').jqxTabs('disableAt', 3);
491 return;
492 } else {
493 $('#jqxTabs').jqxTabs('enableAt', 1);
494 }
495 if (!this.secondTab(notify)) {
496 $('#jqxTabs').jqxTabs('disableAt', 2);
497 $('#jqxTabs').jqxTabs('disableAt', 3);
498 return;
499 } else {
500 $('#jqxTabs').jqxTabs('enableAt', 2);
501 }
502 if (!this.thirdTab(notify)) {
503 $('#jqxTabs').jqxTabs('disableAt', 3);
504 return;
505 } else {
506 $('#jqxTabs').jqxTabs('enableAt', 3);
507 }
508 },
509
510 //Displaying message to the user
511 showHint: function(message, selector) {
512 if (typeof selector === 'undefined') {
513 selector = '.hint';
514 }
515 if (message === '') {
516 message = 'Ok, je mag doorgaan.';
517 }
518 $(selector).html('<strong>' + message + '</strong>');
519 },
520
521 //Validating the first tab
522 firstTab: function(notify) {
523 var name = $('#name').val(), code = $('#code').val(), message = '';
524 if (name.length < 3) {
525 message += 'Je moet een brouw project naam invullen. <br />';
526 }
527 if (code.length < 3) {
528 message += 'Je moet een brouw project code invullen. <br />';
529 }
530 // Check if code already exists.
531 if (message !== '') {
532 if (notify) {
533 this.showHint(message, '#hintBase');
534 }
535 return false;
536 }
537 this.showHint('Ok, je mag doorgaan.', '#hintBase');
538 $('#nextButtonBase').jqxButton({ template: 'success' });
539 return true;
540 },
541
542 //Validating the second tab
543 secondTab: function(notify) {
544 var stylesel = $('#styleSelect').val(), message = '';
545 if (stylesel.length < 3) {
546 message += 'Je moet een bierstijl kiezen. <br />';
547 }
548 if (message !== '') {
549 if (notify) {
550 this.showHint(message, '#hintStyle');
551 }
552 return false;
553 }
554 this.showHint('Ok, je mag doorgaan.', '#hintStyle');
555 $('#nextButtonStyle').jqxButton({ template: 'success' });
556 return true;
557 },
558
559 //Validating the third tab
560 thirdTab: function(notify) {
561 var equipsel = $('#equipmentSelect').val(), message = '';
562 if (equipsel.length < 3) {
563 message += 'Je moet een brouw installatie kiezen. <br />';
564 }
565 if (message !== '') {
566 if (notify) {
567 this.showHint(message, '#hintEq');
568 }
569 return false;
570 }
571 this.showHint('Ok, je mag doorgaan.', '#hintEq');
572 $('#nextButtonEq').jqxButton({ template: 'success' });
573 return true;
574 }
575 };
576 } ());
577
578 //Initializing the wizard
579 wizard.init();
580 });
581

mercurial