www/js/prod_edit.js

changeset 151
2c9cfe2f0860
parent 149
ff45488d480e
child 152
2e4249add363
equal deleted inserted replaced
150:159d7a89fcef 151:2c9cfe2f0860
51 var est_mash_sg = 0; 51 var est_mash_sg = 0;
52 var sugarsm = 0; // Sugars after mash 52 var sugarsm = 0; // Sugars after mash
53 var sugarsf = 0; // Sugars after boil 53 var sugarsf = 0; // Sugars after boil
54 var psugar = 0; // Percentage real sugars 54 var psugar = 0; // Percentage real sugars
55 var pcara = 0; // Percentage cara/crystal malts 55 var pcara = 0; // Percentage cara/crystal malts
56 var svg = 77; // Default attenuation
57 var mashkg = 0; // Malt in mash weight
58 var hop_flavour = 0;
59 var hop_aroma = 0;
60 var mash_infuse = 0;
61 var last_base = '';
62 var last_acid = '';
63
64 var MMCa = 40.048;
65 var MMMg = 24.305;
66 var MMNa = 22.98976928;
67 var MMCl = 35.453;
68 var MMSO4 = 96.0626;
69 var MMCO3 = 60.01684;
70 var MMHCO3 = 61.01684;
71 var MMCaSO4 = 172.171;
72 var MMCaCl2 = 147.015;
73 var MMCaCO3 = 100.087;
74 var MMMgSO4 = 246.475;
75 var MMNaHCO3 = 84.007;
76 var MMNa2CO3 = 105.996;
77 var MMNaCl = 58.443;
78 var MMCaOH2 = 74.06268;
79
56 var old_efficiency; 80 var old_efficiency;
57 var old_batch_size; 81 var old_batch_size;
58 var old_boil_time; 82 var old_boil_time;
59 83
60 console.log("record:" + my_record + " return:" + my_return + " theme:" + theme); 84 console.log("record:" + my_record + " return:" + my_return + " theme:" + theme);
85 $("#jqxLoader").jqxLoader({
86 width: 250,
87 height: 150,
88 isModal: true,
89 text: "Laden product ...",
90 theme: theme
91 });
61 92
62 function calcFermentables() { 93 function calcFermentables() {
63 console.log("calcFermentables()"); 94 console.log("calcFermentables()");
64 sugarsf = 0; 95 sugarsf = 0;
65 sugarsm = 0; 96 sugarsm = 0;
66 psugar = 0; 97 psugar = 0;
67 pcara = 0; 98 pcara = 0;
99 mashkg = 0;
68 var colorw = 0; // Colors working 100 var colorw = 0; // Colors working
69 101 var my_100 = false;
70 for (var i = 0; i < dataRecord.fermentables.length; i++) { 102
71 var row = dataRecord.fermentables[i]; 103 var rows = $('#fermentableGrid').jqxGrid('getrows');
104 for (var i = 0; i < rows.length; i++) {
105 var row = rows[i];
106 if (row.f_adjust_to_total_100)
107 my_100 = true;
72 if (row.f_type == "Sugar") 108 if (row.f_type == "Sugar")
73 psugar += row.f_percentage; 109 psugar += row.f_percentage;
74 if (row.f_type == "Crystal") 110 if (row.f_graintype == "Crystal")
75 pcara += row.f_percentage; 111 pcara += row.f_percentage;
76 var d = row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); 112 var d = row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100);
77 if (row.f_added == "Mash") { 113 if (row.f_added == "Mash") {
78 d = parseFloat(dataRecord.efficiency) / 100 * d; 114 d = parseFloat(dataRecord.efficiency) / 100 * d;
79 sugarsm += d; 115 sugarsm += d;
116 mashkg += row.f_amount;
80 } 117 }
81 sugarsf += d; 118 sugarsf += d;
82 colorw += row.f_amount * ebc_to_srm(row.f_color) / parseFloat(dataRecord.batch_size) * 8.34436; 119 colorw += row.f_amount * ebc_to_srm(row.f_color) / parseFloat(dataRecord.batch_size) * 8.34436;
83 } 120 }
84 console.log("sugarsm: " + sugarsm + " sugarsf: " + sugarsf + " batch: " + dataRecord.batch_size); 121 to_100 = my_100;
85 console.log("est_og: " + estimate_sg(sugarsf, parseFloat(dataRecord.batch_size))); 122 var est_og = estimate_sg(sugarsf, parseFloat(dataRecord.batch_size));
123 $('#est_og').val(est_og);
124 $('#est_og2').val(est_og);
86 preboil_sg = estimate_sg(sugarsm, parseFloat(dataRecord.boil_size)); 125 preboil_sg = estimate_sg(sugarsm, parseFloat(dataRecord.boil_size));
87 console.log("preboil_sg: " + preboil_sg); 126 var color = kw_to_ebc(dataRecord.color_method, colorw);
88 console.log("est_color: " + kw_to_ebc(dataRecord.color_method, colorw)); 127 $('#est_color').val(color);
89 $("#est_og").val(estimate_sg(sugarsf, parseFloat(dataRecord.batch_size))); 128 $('#est_color2').val(color);
90 $('#est_color').val(kw_to_ebc(dataRecord.color_method, colorw)); 129 var scolor = ebc_to_color(color);
130 document.getElementById("bcolor").style.background= scolor;
131 document.getElementById("bcolor2").style.background= scolor;
132 pmalts = mashkg / dataRecord.eq_mash_max * 100;
133 $("#perc_malts").jqxProgressBar('val', pmalts);
134 $("#perc_sugars").jqxProgressBar('val', psugar);
135 $("#perc_cara").jqxProgressBar('val', pcara);
91 }; 136 };
92 137
93 function calcFermentablesFromOG(OG) { 138 function calcFermentablesFromOG(OG) {
94 139
95 console.log("calcFermentablesFromOG("+OG+")"); 140 console.log("calcFermentablesFromOG("+OG+")");
98 var mass1, mass2, efficiency; 143 var mass1, mass2, efficiency;
99 144
100 for (j = 1; j < 15; j++) { // Maybe needed if there is equipment, not here. 145 for (j = 1; j < 15; j++) { // Maybe needed if there is equipment, not here.
101 vol = 0; 146 vol = 0;
102 sug2 = 0; 147 sug2 = 0;
103 efficiency = parseFloat($("#efficiency").jqxNumberInput('decimal')); 148 efficiency = parseFloat(dataRecord.efficiency);
104 var rows = $('#fermentableGrid').jqxGrid('getrows'); 149 var rows = $('#fermentableGrid').jqxGrid('getrows');
105 for (i = 0; i < rows.length; i++) { 150 for (i = 0; i < rows.length; i++) {
106 row = rows[i]; 151 row = rows[i];
107 if ((row.f_added == "Fermentation") || (row.f_added == "Lagering") || (row.f_added == "Bottle")) { 152 if ((row.f_added == "Fermentation") || (row.f_added == "Lagering") || (row.f_added == "Bottle")) {
108 var x = (row.f_yield / 100) * (1 - row.f_moisture / 100); 153 var x = (row.f_yield / 100) * (1 - row.f_moisture / 100);
148 } 193 }
149 }; 194 };
150 //CalcWaterBalance; 195 //CalcWaterBalance;
151 }; 196 };
152 197
198 function hopFlavourContribution(bt, vol, use, amount) {
199 var result;
200
201 if ((use == "First Wort") || (use == "First wort")) {
202 result = 0.15; // assume 15% flavourcontribution for fwh
203 } else if (bt > 50) {
204 result = 0.10; // assume 10% flavourcontribution as a minimum
205 } else {
206 result = 15.25 / (6 * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((bt - 21) /6, 2));
207 if (result < 0.10)
208 result = 0.10; // assume 10% flavourcontribution as a minimum
209 }
210 result = (result * amount * 1000) / vol;
211 // console.log("hopFlavourContribution("+bt+","+vol+","+use+","+amount+"): "+result);
212 return result;
213 }
214
215 function hopAromaContribution(bt, vol, use, amount) {
216 var result = 0;
217
218 if (bt > 20) {
219 result = 0;
220 } else if (bt > 7.5) {
221 result = 10.03 / (4 * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((bt - 7.5) /4, 2));
222 } else if (use == "Boil") {
223 result = 1;
224 } else if (use == "Aroma") {
225 result = 1.2;
226 } else if (use == "Whirlpool") {
227 result = 1.2;
228 } else if ((use == "Dry Hop") || (use == "Dry hop")) {
229 result = 1.33;
230 }
231 result = (result * amount * 1000) / vol;
232 // console.log("hopAromaContribution("+bt+","+vol+","+use+","+amount+"): "+result);
233 return result;
234 }
235
153 function calcIBUs() { 236 function calcIBUs() {
154 var total_ibus = 0; 237 var total_ibus = 0;
155 for (var i = 0; i < dataRecord.hops.length; i++) { 238 hop_aroma = hop_flavour = 0;
156 var row = dataRecord.hops[i]; 239 var rows = $('#hopGrid').jqxGrid('getrows');
240 for (var i = 0; i < rows.length; i++) {
241 var row = rows[i];
157 total_ibus += toIBU(row.h_useat, row.h_form, preboil_sg, parseFloat(dataRecord.batch_size), 242 total_ibus += toIBU(row.h_useat, row.h_form, preboil_sg, parseFloat(dataRecord.batch_size),
158 parseFloat(row.h_amount), parseFloat(row.h_time), parseFloat(row.h_alpha), dataRecord.ibu_method); 243 parseFloat(row.h_amount), parseFloat(row.h_time), parseFloat(row.h_alpha), dataRecord.ibu_method);
244 hop_flavour += hopFlavourContribution(parseFloat(row.h_time), parseFloat(dataRecord.batch_size),
245 row.h_useat, parseFloat(row.h_amount));
246 hop_aroma += hopAromaContribution(parseFloat(row.h_time), parseFloat(dataRecord.batch_size),
247 row.h_useat, parseFloat(row.h_amount));
159 } 248 }
160 console.log("calcIBUs(): " + total_ibus); 249 total_ibus = Math.round(total_ibus);
250 console.log("calcIBUs(): " + total_ibus + " flavour: " + hop_flavour + " aroma: " + hop_aroma);
251 dataRecord.est_ibu = total_ibus;
161 $('#est_ibu').val(total_ibus); 252 $('#est_ibu').val(total_ibus);
253 $('#est_ibu2').val(total_ibus);
254 $("#hop_flavour").jqxProgressBar('val', hop_flavour * 10);
255 $("#hop_aroma").jqxProgressBar('val', hop_aroma * 10);
162 }; 256 };
163 257
164 function calcSGendMash() { 258 function calcSGendMash() {
165 est_mash_sg = 0; 259 est_mash_sg = 0;
166 var mvol = 0; // Mash volume 260 var mvol = 0; // Mash volume
167 var s = 0; 261 var s = 0;
168 var gs = 0; // Grain absorbtion 262 var gs = 0; // Grain absorbtion
169 for (var i = 0; i < dataRecord.mashs.length; i++) { 263 var rows = $('#mashGrid').jqxGrid('getrows');
170 var row = dataRecord.mashs[i]; 264 for (var i = 0; i < rows.length; i++) {
265 var row = rows[i];
171 // console.log("step " + i + " " + row.step_name + " " + row.step_type); 266 // console.log("step " + i + " " + row.step_name + " " + row.step_type);
172 if (row.step_type == 'Infusion') 267 if (row.step_type == 'Infusion')
173 mvol += parseFloat(row.step_infuse_amount); 268 mvol += parseFloat(row.step_infuse_amount);
174 } 269 }
175 if (mvol > 0) { 270 if (mvol > 0) {
176 // console.log("mash volume: " + mvol); 271 // console.log("mash volume: " + mvol);
177 for (var i = 0; i < dataRecord.fermentables.length; i++) { 272 var rows = $('#fermentableGrid').jqxGrid('getrows');
178 var row = dataRecord.fermentables[i]; 273 for (var i = 0; i < rows.length; i++) {
179 274 var row = rows[i];
180 if (row.f_added == "Mash") { 275 if (row.f_added == "Mash") {
181 var d = row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); 276 var d = row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100);
182 mvol += row.f_amount * row.f_moisture / 100; 277 mvol += row.f_amount * row.f_moisture / 100;
183 gs += my_grain_absorbtion * row.f_amount; 278 gs += my_grain_absorbtion * row.f_amount;
184 s += d; 279 s += d;
200 // console.log("c "+ c + " m " + m + " in " + parseFloat($("#brew_mash_sg").jqxNumberInput('decimal'))); 295 // console.log("c "+ c + " m " + m + " in " + parseFloat($("#brew_mash_sg").jqxNumberInput('decimal')));
201 if (c > 0.5) 296 if (c > 0.5)
202 $("#brew_mash_efficiency").val(100 * m / c); 297 $("#brew_mash_efficiency").val(100 * m / c);
203 else 298 else
204 $("#brew_mash_efficiency").val(0); 299 $("#brew_mash_efficiency").val(0);
300 };
301
302 function calcInit () {
303 console.log("calc.init()");
304
305 calcSGendMash();
306 calcMashEfficiency();
307
205 }; 308 };
206 309
207 // Equipemnt dropdown list 310 // Equipemnt dropdown list
208 var equipmentUrl = "includes/db_inventory_equipments.php"; 311 var equipmentUrl = "includes/db_inventory_equipments.php";
209 var equipmentSource = { 312 var equipmentSource = {
282 }); 385 });
283 386
284 var dataRecord = {}; 387 var dataRecord = {};
285 var url = "includes/db_product.php"; 388 var url = "includes/db_product.php";
286 // tooltips 389 // tooltips
287 $("#pname").jqxTooltip({ content: 'De naam voor dit product.' }); 390 $("#name").jqxTooltip({ content: 'De naam voor dit product.' });
288 $("#code").jqxTooltip({ content: 'Product code nummer.' }); 391 $("#code").jqxTooltip({ content: 'Product code nummer.' });
289 $("#birth").jqxTooltip({ content: 'De ontwerp datum van dit product.' }); 392 $("#birth").jqxTooltip({ content: 'De ontwerp datum van dit product.' });
290 $("#stage").jqxTooltip({ content: 'De productie fase van dit product.' }); 393 $("#stage").jqxTooltip({ content: 'De productie fase van dit product.' });
291 $("#pnotes").jqxTooltip({ content: 'De uitgebreide opmerkingen over dit product.' }); 394 $("#notes").jqxTooltip({ content: 'De uitgebreide opmerkingen over dit product.' });
292 $("#eq_name").jqxTooltip({ content: 'De naam van deze brouw apparatuur.' }); 395 $("#eq_name").jqxTooltip({ content: 'De naam van deze brouw apparatuur.' });
293 $("#eq_notes").jqxTooltip({ content: 'Opmerkingen over deze apparatuur.' }); 396 $("#eq_notes").jqxTooltip({ content: 'Opmerkingen over deze apparatuur.' });
294 $("#eq_tun_volume").jqxTooltip({ content: 'Maisch ketel volume.' }); 397 $("#eq_tun_volume").jqxTooltip({ content: 'Maisch ketel volume.' });
295 $("#eq_mash_volume").jqxTooltip({ content: 'Maisch water voor de eerste stap.' }); 398 $("#eq_mash_volume").jqxTooltip({ content: 'Maisch water voor de eerste stap.' });
296 $("#eq_mash_max").jqxTooltip({ content: 'De maximale moutstort in Kg.' }); 399 $("#eq_mash_max").jqxTooltip({ content: 'De maximale moutstort in Kg.' });
303 $("#eq_boil_time").jqxTooltip({ content: 'Normale kooktijd in minuten..' }); 406 $("#eq_boil_time").jqxTooltip({ content: 'Normale kooktijd in minuten..' });
304 $("#eq_top_up_kettle").jqxTooltip({ content: 'Extra water toevoegen tijdens de kook.' }); 407 $("#eq_top_up_kettle").jqxTooltip({ content: 'Extra water toevoegen tijdens de kook.' });
305 $("#eq_hop_utilization").jqxTooltip({ content: '100% voor kleine installaties, hoger voor grote brouwerijen.' }); 408 $("#eq_hop_utilization").jqxTooltip({ content: '100% voor kleine installaties, hoger voor grote brouwerijen.' });
306 $("#eq_batch_size").jqxTooltip({ content: 'Berekende batch grootte in liters aan het eind van de kook.' }); 409 $("#eq_batch_size").jqxTooltip({ content: 'Berekende batch grootte in liters aan het eind van de kook.' });
307 $("#eq_trub_chiller_loss").jqxTooltip({ content: 'Standaard verlies bij het overbrengen naar het gistvat.' }); 410 $("#eq_trub_chiller_loss").jqxTooltip({ content: 'Standaard verlies bij het overbrengen naar het gistvat.' });
411 $("#type").jqxTooltip({ content: 'Het brouw type van dit recept.' });
412 $("#batch_size").jqxTooltip({ content: 'Het volume van het gekoelde wort na het koken.' });
413 $("#boil_time").jqxTooltip({ content: 'De kooktijd in minuten.' });
414 $("#boil_size").jqxTooltip({ content: 'Het volume van het wort voor het koken.' });
415 $("#efficiency").jqxTooltip({ content: 'Het rendement van maischen en koken.' });
416 $("#est_og").jqxTooltip({ content: 'Het begin SG wat je wilt bereiken. De moutstort wordt automatisch herberekend.' });
417 $("#est_og2").jqxTooltip({ content: 'Het begin SG wat je wilt bereiken. De moutstort wordt automatisch herberekend.' });
418 $("#est_fg").jqxTooltip({ content: 'Het eind SG. Dit wordt automatisch berekend.' });
419 $("#est_color").jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' });
420 $("#est_color2").jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' });
421 $("#est_ibu").jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' });
422 $("#est_ibu2").jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' });
423 $("#est_abv").jqxTooltip({ content: 'Alcohol volume %. Dit wordt automatisch berekend.' });
424 $("#est_carb").jqxTooltip({ content: 'Koolzuur volume. Dit wordt automatisch berekend.' });
425 // $("#st_name").jqxTooltip({ content: 'De bierstijl naam voor dit recept.'});
426 // $("#st_letter").jqxTooltip({ content: 'De bierstijl letter voor dit recept.'});
427 // $("#st_guide").jqxTooltip({ content: 'De bierstijl gids voor dit recept.'});
428 // $("#st_category").jqxTooltip({ content: 'De Amerikaanse bierstijl categorie.'});
429 // $("#st_category_number").jqxTooltip({ content: 'De Amerikaanse bierstijl categorie sub nummer.'});
430 // $("#st_type").jqxTooltip({ content: 'Het bierstijl type.'});
431 $("#st_og_min").jqxTooltip({ content: 'Het minimum begin SG voor deze bierstijl.'});
432 $("#st_og_max").jqxTooltip({ content: 'Het maximum begin SG voor deze bierstijl.'});
433 $("#st_fg_min").jqxTooltip({ content: 'Het minimum eind SG voor deze bierstijl.'});
434 $("#st_fg_max").jqxTooltip({ content: 'Het maximum eind SG voor deze bierstijl.'});
435 $("#st_color_min").jqxTooltip({ content: 'De minimum kleur voor deze bierstijl.'});
436 $("#st_color_max").jqxTooltip({ content: 'De maximum kleur voor deze bierstijl.'});
437 $("#st_ibu_min").jqxTooltip({ content: 'De minimum bitterheid voor deze bierstijl.'});
438 $("#st_ibu_max").jqxTooltip({ content: 'De maximum bitterheid voor deze bierstijl.'});
439 $("#st_abv_min").jqxTooltip({ content: 'Het minimum alcohol volume % voor deze bierstijl.'});
440 $("#st_abv_max").jqxTooltip({ content: 'Het maximum alcohol volume % voor deze bierstijl.'});
441 $("#st_carb_min").jqxTooltip({ content: 'Het minimum koolzuur volume voor deze bierstijl.'});
442 $("#st_carb_max").jqxTooltip({ content: 'Het maximum koolzuur volume voor deze bierstijl.'});
443 $("#wa_cacl2").jqxTooltip({ content: 'Voor het maken van een ander waterprofiel. Voegt calcium en chloride toe. Voor het verbeteren van zoetere bieren.'});
444 $("#wa_caso4").jqxTooltip({ content: 'Gips. Voor het maken van een ander waterprofiel. Voegt calcium en sulfaat toe. Voor het verbeteren van bittere bieren.'});
445 $("#wa_mgso4").jqxTooltip({ content: 'Epsom zout. Voor het maken van een ander waterprofiel. Voegt magnesium en sulfaat toe. Gebruik spaarzaam!'});
446 $("#wa_nacl").jqxTooltip({ content: 'Keukenzout. Voor het maken van een ander waterprofiel. Voegt natrium en chloride toe. Voor het accentueren van zoetheid. Bij hoge dosering wordt het bier ziltig.'});
447 $("#w2_amount").jqxTooltip({ content: 'De verdeling van het hoofd en meng water. Het totale maisch water volume blijft gelijk.'});
448 $("#wb_calcium").jqxTooltip({ content: 'De ideale hoeveelheid Calcium is tussen 40 en 150.'});
449 $("#wb_magnesium").jqxTooltip({ content: 'De ideale hoeveelheid Magnesium is lager dan 30.'});
450 $("#wb_sodium").jqxTooltip({ content: 'De ideale hoeveelheid Natrium is lager dan 150.'});
451 $("#wb_chloride").jqxTooltip({ content: 'De ideale hoeveelheid Chloride is lager dan 100.'});
452 $("#wb_sulfate").jqxTooltip({ content: 'De ideale hoeveelheid Sulfaat is lager dan 350.'});
308 453
309 // Prepare the data 454 // Prepare the data
310 var source = { 455 var source = {
311 datatype: "json", 456 datatype: "json",
312 cache: false, 457 cache: false,
313 datafields: [ 458 datafields: [
314 // From prod_main 459 // From prod_main
315 { name: 'record', type: 'number' }, 460 { name: 'record', type: 'number' },
316 { name: 'puuid', type: 'string' }, 461 { name: 'uuid', type: 'string' },
317 { name: 'pname', type: 'string' }, 462 { name: 'name', type: 'string' },
318 { name: 'code', type: 'string' }, 463 { name: 'code', type: 'string' },
319 { name: 'birth', type: 'string' }, 464 { name: 'birth', type: 'string' },
320 { name: 'stage', type: 'string' }, 465 { name: 'stage', type: 'string' },
321 { name: 'pnotes', type: 'string' }, 466 { name: 'notes', type: 'string' },
322 { name: 'log_brew', type: 'bool' }, 467 { name: 'log_brew', type: 'bool' },
323 { name: 'log_fermentation', type: 'bool' }, 468 { name: 'log_fermentation', type: 'bool' },
324 { name: 'inventory_reduced', type: 'bool' }, 469 { name: 'inventory_reduced', type: 'bool' },
325 { name: 'plocked', type: 'bool' }, 470 { name: 'locked', type: 'bool' },
326 { name: 'eq_name', type: 'string' }, 471 { name: 'eq_name', type: 'string' },
327 { name: 'eq_boil_size', type: 'float' }, 472 { name: 'eq_boil_size', type: 'float' },
328 { name: 'eq_batch_size', type: 'float' }, 473 { name: 'eq_batch_size', type: 'float' },
329 { name: 'eq_tun_volume', type: 'float' }, 474 { name: 'eq_tun_volume', type: 'float' },
330 { name: 'eq_tun_weight', type: 'float' }, 475 { name: 'eq_tun_weight', type: 'float' },
406 { name: 'taste_head', type: 'string' }, 551 { name: 'taste_head', type: 'string' },
407 { name: 'taste_aroma', type: 'string' }, 552 { name: 'taste_aroma', type: 'string' },
408 { name: 'taste_taste', type: 'string' }, 553 { name: 'taste_taste', type: 'string' },
409 { name: 'taste_mouthfeel', type: 'string' }, 554 { name: 'taste_mouthfeel', type: 'string' },
410 { name: 'taste_aftertaste', type: 'string' }, 555 { name: 'taste_aftertaste', type: 'string' },
411 // From prod_recipes
412 { name: 'uuid', type: 'string' },
413 { name: 'locked', type: 'bool' },
414 { name: 'st_name', type: 'string' }, 556 { name: 'st_name', type: 'string' },
415 { name: 'st_letter', type: 'string' }, 557 { name: 'st_letter', type: 'string' },
416 { name: 'st_guide', type: 'string' }, 558 { name: 'st_guide', type: 'string' },
417 { name: 'st_category', type: 'string' }, 559 { name: 'st_category', type: 'string' },
418 { name: 'st_category_number', type: 'float' }, 560 { name: 'st_category_number', type: 'float' },
427 { name: 'st_color_max', type: 'float' }, 569 { name: 'st_color_max', type: 'float' },
428 { name: 'st_carb_min', type: 'float' }, 570 { name: 'st_carb_min', type: 'float' },
429 { name: 'st_carb_max', type: 'float' }, 571 { name: 'st_carb_max', type: 'float' },
430 { name: 'st_abv_min', type: 'float' }, 572 { name: 'st_abv_min', type: 'float' },
431 { name: 'st_abv_max', type: 'float' }, 573 { name: 'st_abv_max', type: 'float' },
432 { name: 'name', type: 'string' },
433 { name: 'notes', type: 'string' },
434 { name: 'type', type: 'string' }, 574 { name: 'type', type: 'string' },
435 { name: 'batch_size', type: 'float' }, 575 { name: 'batch_size', type: 'float' },
436 { name: 'boil_size', type: 'float' }, 576 { name: 'boil_size', type: 'float' },
437 { name: 'boil_time', type: 'float' }, 577 { name: 'boil_time', type: 'float' },
438 { name: 'efficiency', type: 'float' }, 578 { name: 'efficiency', type: 'float' },
442 { name: 'est_color', type: 'float' }, 582 { name: 'est_color', type: 'float' },
443 { name: 'color_method', type: 'string' }, 583 { name: 'color_method', type: 'string' },
444 { name: 'est_ibu', type: 'float' }, 584 { name: 'est_ibu', type: 'float' },
445 { name: 'ibu_method', type: 'string' }, 585 { name: 'ibu_method', type: 'string' },
446 { name: 'est_carb', type: 'float' }, 586 { name: 'est_carb', type: 'float' },
447 { name: 'mash_sparge_temp', type: 'float' }, 587 { name: 'sparge_temp', type: 'float' },
588 { name: 'sparge_ph', type: 'float' },
589 { name: 'sparge_volume', type: 'float' },
590 { name: 'sparge_acid_type', type: 'string' },
591 { name: 'sparge_acid_perc', type: 'float' },
592 { name: 'sparge_acid_amount', type: 'float' },
448 { name: 'mash_ph', type: 'float' }, 593 { name: 'mash_ph', type: 'float' },
449 { name: 'mash_name', type: 'string' }, 594 { name: 'mash_name', type: 'string' },
595 { name: 'calc_acid', type: 'bool' },
596 { name: 'w1_name', type: 'string' },
597 { name: 'w1_amount', type: 'float' },
598 { name: 'w1_calcium', type: 'float' },
599 { name: 'w1_sulfate', type: 'float' },
600 { name: 'w1_chloride', type: 'float' },
601 { name: 'w1_sodium', type: 'float' },
602 { name: 'w1_magnesium', type: 'float' },
603 { name: 'w1_total_alkalinity', type: 'float' },
604 { name: 'w1_ph', type: 'float' },
605 { name: 'w1_cost', type: 'float' },
606 { name: 'w2_name', type: 'string' },
607 { name: 'w2_amount', type: 'float' },
608 { name: 'w2_calcium', type: 'float' },
609 { name: 'w2_sulfate', type: 'float' },
610 { name: 'w2_chloride', type: 'float' },
611 { name: 'w2_sodium', type: 'float' },
612 { name: 'w2_magnesium', type: 'float' },
613 { name: 'w2_total_alkalinity', type: 'float' },
614 { name: 'w2_ph', type: 'float' },
615 { name: 'w2_cost', type: 'float' },
450 { name: 'fermentables', type: 'array' }, 616 { name: 'fermentables', type: 'array' },
451 { name: 'hops', type: 'string' }, 617 { name: 'hops', type: 'string' },
452 { name: 'miscs', type: 'string' }, 618 { name: 'miscs', type: 'string' },
453 { name: 'yeasts', type: 'string' }, 619 { name: 'yeasts', type: 'string' },
454 { name: 'waters', type: 'array' },
455 { name: 'mashs', type: 'string' } 620 { name: 'mashs', type: 'string' }
456 ], 621 ],
457 id: 'record', 622 id: 'record',
458 url: url + '?record=' + my_record 623 url: url + '?record=' + my_record
459 }; 624 };
461 var dataAdapter = new $.jqx.dataAdapter(source, { 626 var dataAdapter = new $.jqx.dataAdapter(source, {
462 loadComplete: function () { 627 loadComplete: function () {
463 var records = dataAdapter.records; 628 var records = dataAdapter.records;
464 dataRecord = records[0]; 629 dataRecord = records[0];
465 // Hidden record uuid 630 // Hidden record uuid
466 $("#pname").val(dataRecord.pname); 631 $("#name").val(dataRecord.name);
467 $("#code").val(dataRecord.code); 632 $("#code").val(dataRecord.code);
468 $("#birth").val(dataRecord.birth); 633 $("#birth").val(dataRecord.birth);
469 $("#stage").val(dataRecord.stage); 634 $("#stage").val(dataRecord.stage);
470 $("#pnotes").val(dataRecord.pnotes); 635 $("#notes").val(dataRecord.notes);
471 $("#log_brew").val(dataRecord.log_brew); 636 $("#log_brew").val(dataRecord.log_brew);
472 $("#log_fermentation").val(dataRecord.log_fermentation); 637 $("#log_fermentation").val(dataRecord.log_fermentation);
473 $("#inventory_reduced").val(dataRecord.inventory_reduced); 638 $("#inventory_reduced").val(dataRecord.inventory_reduced);
474 $("#plocked").val(dataRecord.plocked); 639 $("#locked").val(dataRecord.locked);
475 $("#eq_name").val(dataRecord.eq_name); 640 $("#eq_name").val(dataRecord.eq_name);
476 $("#eq_notes").val(dataRecord.eq_notes); 641 $("#eq_notes").val(dataRecord.eq_notes);
477 $("#eq_boil_size").val(dataRecord.eq_boil_size); 642 $("#eq_boil_size").val(dataRecord.eq_boil_size);
478 $("#eq_batch_size").val(dataRecord.eq_batch_size); 643 $("#eq_batch_size").val(dataRecord.eq_batch_size);
479 $("#eq_tun_volume").val(dataRecord.eq_tun_volume); 644 $("#eq_tun_volume").val(dataRecord.eq_tun_volume);
531 $("#brew_fermenter_extrasugar").val(dataRecord.brew_fermenter_extrasugar); 696 $("#brew_fermenter_extrasugar").val(dataRecord.brew_fermenter_extrasugar);
532 $("#brew_fermenter_color").val(dataRecord.brew_fermenter_color); 697 $("#brew_fermenter_color").val(dataRecord.brew_fermenter_color);
533 $("#brew_date_end").val(dataRecord.brew_date_end); 698 $("#brew_date_end").val(dataRecord.brew_date_end);
534 699
535 // Recipe 700 // Recipe
536 // locked 701 $("#st_name").val(dataRecord.st_name);
537 // st_ style settings. 702 $("#st_letter").val(dataRecord.st_letter);
538 // name 703 $("#st_guide").val(dataRecord.st_guide);
539 // notes 704 $("#st_category").val(dataRecord.st_category);
540 // type 705 $("#st_category_number").val(dataRecord.st_category_number);
706 $("#st_type").val(dataRecord.st_type);
707 $("#st_og_min").val(dataRecord.st_og_min);
708 $("#st_og_max").val(dataRecord.st_og_max);
709 $("#st_fg_min").val(dataRecord.st_fg_min);
710 $("#st_fg_max").val(dataRecord.st_fg_max);
711 $("#st_abv_min").val(dataRecord.st_abv_min);
712 $("#st_abv_max").val(dataRecord.st_abv_max);
713 $("#st_color_min").val(dataRecord.st_color_min);
714 $("#st_color_max").val(dataRecord.st_color_max);
715 $("#st_ibu_min").val(dataRecord.st_ibu_min);
716 $("#st_ibu_max").val(dataRecord.st_ibu_max);
717 $("#st_carb_min").val(dataRecord.st_carb_min);
718 $("#st_carb_max").val(dataRecord.st_carb_max);
719 $("#type").val(dataRecord.type);
720 $("#batch_size").val(dataRecord.batch_size);
541 old_batch_size = dataRecord.batch_size; 721 old_batch_size = dataRecord.batch_size;
542 // boil_size 722 $("#boil_size").val(dataRecord.boil_size);
723 $("#boil_time").val(dataRecord.boil_time);
543 old_boil_time = dataRecord.boil_time; 724 old_boil_time = dataRecord.boil_time;
725 $("#efficiency").val(dataRecord.efficiency);
544 old_efficiency = dataRecord.efficiency; 726 old_efficiency = dataRecord.efficiency;
545 // est_og 727 $("#est_og").val(dataRecord.est_og);
546 // est_fg 728 $("#est_og2").val(dataRecord.est_og);
547 // est_abv 729 $("#est_fg").val(dataRecord.est_fg);
548 // est_color 730 $("#est_color").val(dataRecord.est_color);
549 // color_method 731 $("#est_color2").val(dataRecord.est_color);
550 // est_ibu 732 $("#est_abv").val(dataRecord.est_abv);
551 // ibu_method 733 $("#color_method").val(dataRecord.color_method);
552 // mash_sparge_temp 734 $("#est_ibu").val(dataRecord.est_ibu);
553 // mash_ph 735 $("#est_ibu2").val(dataRecord.est_ibu);
554 // mash_name 736 $("#ibu_method").val(dataRecord.ibu_method);
555 // fermentables 737 $("#est_carb").val(dataRecord.est_carb);
556 // hops 738 $("#mash_name").val(dataRecord.mash_name);
557 // miscs 739 $("#mash_ph").val(dataRecord.mash_ph);
558 // yeasts 740 $("#tgt_mash_ph").val(dataRecord.mash_ph);
559 // waters 741 $("#sparge_temp").val(dataRecord.sparge_temp);
560 // mashs 742 $("#sparge_ph").val(dataRecord.sparge_ph);
743 $("#sparge_volume").val(dataRecord.sparge_volume);
744 $("#sparge_acid_type").val(dataRecord.sparge_acid_type);
745 $("#sparge_acid_perc").val(dataRecord.sparge_acid_perc);
746 $("#sparge_acid_amount").val(dataRecord.sparge_acid_amount);
747 $("#calc_acid").val(dataRecord.calc_acid);
748 $("#w1_name").val(dataRecord.w1_name);
749 $("#w1_amount").val(dataRecord.w1_amount);
750 $("#w1_calcium").val(dataRecord.w1_calcium);
751 $("#w1_sulfate").val(dataRecord.w1_sulfate);
752 $("#w1_chloride").val(dataRecord.w1_chloride);
753 $("#w1_sodium").val(dataRecord.w1_sodium);
754 $("#w1_magnesium").val(dataRecord.w1_magnesium);
755 $("#w1_total_alkalinity").val(dataRecord.w1_total_alkalinity);
756 $("#w1_ph").val(dataRecord.w1_ph);
757 $("#w1_cost").val(dataRecord.w1_cost);
758 $("#w2_name").val(dataRecord.w2_name);
759 $("#w2_amount").val(dataRecord.w2_amount);
760 $("#w2_calcium").val(dataRecord.w2_calcium);
761 $("#w2_sulfate").val(dataRecord.w2_sulfate);
762 $("#w2_chloride").val(dataRecord.w2_chloride);
763 $("#w2_sodium").val(dataRecord.w2_sodium);
764 $("#w2_magnesium").val(dataRecord.w2_magnesium);
765 $("#w2_total_alkalinity").val(dataRecord.w2_total_alkalinity);
766 $("#w2_ph").val(dataRecord.w2_ph);
767 $("#w2_cost").val(dataRecord.w2_cost);
768 editFermentable(dataRecord);
769 editHop(dataRecord);
770 editMisc(dataRecord);
771 editYeast(dataRecord);
772 editMash(dataRecord);
561 773
562 switch (dataRecord.stage) { 774 switch (dataRecord.stage) {
563 case 'Plan': brewstage = 0; break; 775 case 'Plan': brewstage = 0; break;
564 case 'Wait': brewstage = 1; break; 776 case 'Wait': brewstage = 1; break;
565 case 'Brew': brewstage = 2; break; 777 case 'Brew': brewstage = 2; break;
583 if (brewstage > 0) { 795 if (brewstage > 0) {
584 $("#Delete").jqxButton({ disabled: true }); 796 $("#Delete").jqxButton({ disabled: true });
585 $("#birth").jqxDateTimeInput({ disabled: true }); 797 $("#birth").jqxDateTimeInput({ disabled: true });
586 } 798 }
587 if (brewstage < 3) { 799 if (brewstage < 3) {
588 $("#brew_log").jqxButton({ disabled: true }); 800 // $("#brew_log").jqxButton({ disabled: true });
589 $("#ferment_log").jqxButton({ disabled: true }); 801 // $("#ferment_log").jqxButton({ disabled: true });
590 } else { 802 } else {
591 if (! dataRecord.log_brew) 803 // if (! dataRecord.log_brew)
592 $("#brew_log").jqxButton({ disabled: true }); 804 // $("#brew_log").jqxButton({ disabled: true });
593 if (! dataRecord.log_fermentation) 805 // if (! dataRecord.log_fermentation)
594 $("#ferment_log").jqxButton({ disabled: true }); 806 // $("#ferment_log").jqxButton({ disabled: true });
595 } 807 }
596 if (brewstage < 6) 808 if (brewstage < 6)
597 $("#inventory_reduced").jqxCheckBox({ disabled : true }); 809 $("#inventory_reduced").jqxCheckBox({ disabled : true });
598 else if ($('#inventory_reduced').jqxCheckBox('checked')) 810 else if ($('#inventory_reduced').jqxCheckBox('checked'))
599 $("#inventory_reduced").jqxCheckBox({ disabled : true }); 811 $("#inventory_reduced").jqxCheckBox({ disabled : true });
600 812
601 calcFermentables(); 813 $('#jqxTabs').jqxTabs('select', 2);
602 calcIBUs();
603 calcSGendMash();
604 calcMashEfficiency();
605 }, 814 },
606 loadError: function (jqXHR, status, error) { 815 loadError: function (jqXHR, status, error) {
607 } 816 },
817 beforeLoadComplete: function (records) {
818 $('#jqxLoader').jqxLoader('open');
819 }
608 }); 820 });
609 dataAdapter.dataBind(); 821 dataAdapter.dataBind();
610 822
823 // Inline fermentables editor
824 var editFermentable = function (data) {
825 var fermentableSource = {
826 localdata: data.fermentables,
827 datatype: "local",
828 datafields: [
829 { name: 'f_name', type: 'string' },
830 { name: 'f_origin', type: 'string' },
831 { name: 'f_supplier', type: 'string' },
832 { name: 'f_amount', type: 'float' },
833 { name: 'f_cost', type: 'float' },
834 { name: 'f_type', type: 'string' },
835 { name: 'f_yield', type: 'float' },
836 { name: 'f_color', type: 'float' },
837 { name: 'f_coarse_fine_diff', type: 'float' },
838 { name: 'f_moisture', type: 'float' },
839 { name: 'f_diastatic_power', type: 'float' },
840 { name: 'f_protein', type: 'float' },
841 { name: 'f_max_in_batch', type: 'float' },
842 { name: 'f_graintype', type: 'string' },
843 { name: 'f_added', type: 'string' },
844 { name: 'f_dissolved_protein', type: 'float' },
845 { name: 'f_recommend_mash', type: 'bool' },
846 { name: 'f_add_after_boil', type: 'bool' },
847 { name: 'f_adjust_to_total_100', type: 'bool' },
848 { name: 'f_percentage', type: 'float' },
849 { name: 'f_di_ph', type: 'float' }
850 ],
851 addrow: function (rowid, rowdata, position, commit) {
852 commit(true);
853 },
854 deleterow: function (rowid, commit) {
855 commit(true);
856 }
857 };
858 var fermentableAdapter = new $.jqx.dataAdapter(fermentableSource);
859 $("#fermentableGrid").jqxGrid({
860 width: 1150,
861 height: 400,
862 source: fermentableAdapter,
863 theme: theme,
864 selectionmode: 'singlerow',
865 editmode: 'selectedcell',
866 editable: true,
867 localization: getLocalization(),
868 showtoolbar: true,
869 rendertoolbar: function (toolbar) {
870 var me = this;
871 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
872 toolbar.append(container);
873 container.append('<div style="float: left; margin-left: 165px;" id="faddrowbutton"></div>');
874 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>');
875 container.append('<div style="float: left; margin-left: 10px;" id="finstockbutton"></div>');
876 container.append('<input style="float: left; margin-left: 400px;" id="fdeleterowbutton" type="button" value="Verwijder mout" />');
877 // add fermentable from dropdownlist.
878 $("#faddrowbutton").jqxDropDownList({
879 placeHolder: "Kies mout:",
880 theme: theme,
881 source: fermentablelist,
882 displayMember: "name",
883 width: 150,
884 height: 27,
885 dropDownWidth: 500,
886 dropDownHeight: 500,
887 renderer: function (index, label, value) {
888 var datarecord = fermentablelist.records[index];
889 return datarecord.supplier+ " / " + datarecord.name + " (" + datarecord.color + " EBC)";
890 }
891 });
892 $("#faddrowbutton").on('select', function (event) {
893 if (event.args) {
894 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
895 var index = event.args.index;
896 var datarecord = fermentablelist.records[index];
897 var row = {};
898 row["f_name"] = datarecord.name;
899 row["f_origin"] = datarecord.origin;
900 row["f_supplier"] = datarecord.supplier;
901 row["f_amount"] = 0;
902 row["f_cost"] = datarecord.cost;
903 row["f_type"] = datarecord.type;
904 row["f_yield"] = datarecord.yield;
905 row["f_color"] = datarecord.color;
906 row["f_coarse_fine_diff"] = datarecord.coarse_fine_diff;
907 row["f_moisture"] = datarecord.moisture;
908 row["f_diastatic_power"] = datarecord.diastatic_power;
909 row["f_protein"] = datarecord.protein;
910 row["f_max_in_batch"] = datarecord.max_in_batch;
911 row["f_graintype"] = datarecord.graintype;
912 if (datarecord.add_after_boil) {
913 row["f_added"] = "Primary";
914 } else if ((datarecord.type == "Sugar") || (datarecord.type == "Adjunct")) {
915 row["f_added"] = "Boil";
916 } else {
917 row["f_added"] = "Mash";
918 }
919 row["f_dissolved_protein"] = 0;
920 row["f_recommend_mash"] = datarecord.recommend_mash;
921 row["f_add_after_boil"] = datarecord.add_after_boil;
922 if (rowscount == 0) {
923 // The first fermentable
924 row["f_adjust_to_total_100"] = 1;
925 row["f_percentage"] = 100;
926 } else {
927 row["f_adjust_to_total_100"] = 0;
928 row["f_percentage"] = 0;
929 }
930 row["f_di_ph"] = datarecord.di_ph;
931 var commit = $("#fermentableGrid").jqxGrid('addrow', null, row);
932 }
933 });
934
935 $("#finstockbutton").jqxCheckBox({ theme: theme, height: 27 });
936 $("#finstockbutton").on('change', function (event) {
937 fermentableinstock = event.args.checked;
938 fermentablelist.dataBind();
939 });
940
941 // delete selected fermentable.
942 $("#fdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 });
943 $("#fdeleterowbutton").on('click', function () {
944 var selectedrowindex = $("#fermentableGrid").jqxGrid('getselectedrowindex');
945 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
946 if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
947 var id = $("#fermentableGrid").jqxGrid('getrowid', selectedrowindex);
948 var percent = $('#fermentableGrid').jqxGrid('getcellvalue', id, "f_percentage");
949 var amount = $('#fermentableGrid').jqxGrid('getcellvalue', id, "f_amount");
950 var commit = $("#fermentableGrid").jqxGrid('deleterow', id);
951 }
952 rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
953 if (rowscount > 1) {
954 if (to_100) {
955 for (var i = 0; i < rowscount; i++) {
956 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
957 if (rowdata.f_adjust_to_total_100) {
958 rowdata.f_percentage += percent;
959 rowdata.f_amount += amount;
960 }
961 }
962 } else {
963 var tw = 0;
964 for (i = 0; i < rowscount; i++) {
965 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
966 tw += rowdata.f_amount;
967 };
968 for (i = 0; i < rowscount; i++) {
969 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
970 var percentage = Math.round(rowdata.f_amount / tw * 1000) / 10.0;
971 $("#fermentableGrid").jqxGrid('setcellvalue', i, "f_percentage", percentage);
972 };
973 }
974 } else {
975 $("#fermentableGrid").jqxGrid('setcellvalue', 0, "f_percentage", 100);
976 }
977 calcFermentables();
978 calcSVG();
979 calcABV();
980 calcIBUs();
981 });
982 },
983 ready: function() {
984 calcFermentables();
985 $('#jqxTabs').jqxTabs('next');
986 },
987 columns: [
988 { text: 'Vergistbaar ingredi&euml;nt', editable: false, datafield: 'f_name',
989 cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties) {
990 var rowData = $("#fermentableGrid").jqxGrid('getrowdata', row);
991 return "<span style='margin: 3px; margin-top: 6px; float: "+
992 columnproperties.cellsalign+"'>" +rowData.f_supplier+" / "+rowData.f_name+" ("+rowData.f_color+" EBC)</span>";
993 }
994 },
995 { text: 'Type', editable: false, align: 'center', cellsalign: 'center', width: 100, datafield: 'f_type' },
996 { text: 'Moment', width: 110, align: 'center', cellsalign: 'center', datafield: 'f_added', columntype: 'dropdownlist',
997 createeditor: function (row, column, editor) {
998 var srcAdded = [ "Mash", "Boil", "Fermentation", "Lagering", "Bottle" ];
999 editor.jqxDropDownList({ autoDropDownHeight: true, source: srcAdded });
1000 }
1001 },
1002 { text: 'Opbrengst', editable: false, datafield: 'f_yield', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'p1' },
1003 { text: 'Gewicht Kg', datafield: 'f_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f3',
1004 columntype: 'numberinput',
1005 validation: function (cell, value) {
1006 // Maximum weight is the batch_size, just a simple check.
1007 var maxmout = parseFloat($("#batch_size").jqxNumberInput('decimal'));
1008 if (value < 0 || value > maxmout) {
1009 return { result: false, message: "Gewicht moet 0-"+maxmout+" zijn" };
1010 }
1011 return true;
1012 },
1013 initeditor: function (row, cellvalue, editor) {
1014 editor.jqxNumberInput({ inputMode: 'simple', min: 0, decimalDigits: 3, spinButtons: false });
1015 },
1016 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
1017 if (to_100) {
1018 return oldvalue; // When using percentages, don't allow edited results.
1019 }
1020 }
1021 },
1022 { text: 'Percentage', datafield: 'f_percentage', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'p1',
1023 columntype: 'numberinput',
1024 validation: function (cell, value) {
1025 if (value < 0 || value > 100) {
1026 return { result: false, message: "Percentage moet 0-100 zijn" };
1027 }
1028 return true;
1029 },
1030 initeditor: function (row, cellvalue, editor) {
1031 editor.jqxNumberInput({ decimalDigits: 1, min: 0, max: 100, spinButtons: false });
1032 },
1033 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
1034 oldvalue = Math.round(oldvalue * 10) / 10.0;
1035 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
1036 if ((oldvalue != newvalue) && (rowscount > 1)) {
1037 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', row);
1038 if (rowdata.f_adjust_to_total_100) {
1039 return oldvalue;
1040 }
1041 var diff = newvalue - oldvalue;
1042 var tw = 0; // total weight
1043 for (i = 0; i < rowscount; i++) {
1044 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
1045 tw += rowdata.f_amount;
1046 }
1047 if (to_100) {
1048 // Adjust this row and the 100% row.
1049 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', row);
1050 rowdata.f_amount += tw * diff / 100;
1051 for (i = 0; i < rowscount; i++) {
1052 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
1053 if (rowdata.f_adjust_to_total_100) {
1054 rowdata.f_percentage -= diff;
1055 rowdata.f_amount -= tw * diff / 100;
1056 }
1057 }
1058 } else {
1059 // Adjust all the rows.
1060 var nw = tw * diff / 100;
1061 for (i = 0; i < rowscount; i++) {
1062 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
1063 if (i == row) {
1064 rowdata.f_amount += nw;
1065 } else {
1066 rowdata.f_amount -= nw / (rowscount - 1);
1067 rowdata.f_percentage = Math.round((rowdata.f_amount / tw) * 1000) / 10.0;
1068 }
1069 }
1070 }
1071 }
1072 }
1073 },
1074 { text: '100%', align: 'center', datafield: 'f_adjust_to_total_100', columntype: 'checkbox', width: 80,
1075 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
1076 if (to_100) {
1077 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
1078 for (i = 0; i < rowscount; i++) {
1079 if (i != row) {
1080 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
1081 rowdata.f_adjust_to_total_100 = false;
1082 }
1083 }
1084 }
1085 }
1086 }
1087 ]
1088 });
1089 $("#fermentableGrid").on('cellendedit', function (event) {
1090 var args = event.args;
1091 console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value);
1092 // Make sure the grid itself is updated.
1093 $("#fermentableGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value);
1094 if ((args.datafield == 'f_amount') && (! to_100)) {
1095 // If one of the amounts is changed, recalculate the percentages.
1096 console.log("adjust percentages");
1097 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
1098 if (rowscount > 1) {
1099 var tw = 0;
1100 for (i = 0; i < rowscount; i++) {
1101 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
1102 tw += rowdata.f_amount;
1103 };
1104 for (i = 0; i < rowscount; i++) {
1105 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
1106 var percentage = Math.round(rowdata.f_amount / tw * 1000) / 10.0;
1107 $("#fermentableGrid").jqxGrid('setcellvalue', i, "f_percentage", percentage);
1108 };
1109 } else {
1110 $("#fermentableGrid").jqxGrid('setcellvalue', 0, "f_percentage", 100);
1111 }
1112 };
1113 $('#fermentableGrid').jqxGrid('sortby', 'f_amount', 'desc'); // TODO: not reliable
1114 calcFermentables();
1115 calcSVG();
1116 calcABV();
1117 calcIBUs(); // Depends on gravity, so recalculate.
1118 });
1119 };
1120
1121 // Inline hops editor
1122 var editHop = function (data) {
1123 var hopSource = {
1124 localdata: data.hops,
1125 datatype: "local",
1126 cache: false,
1127 datafields: [
1128 { name: 'h_name', type: 'string' },
1129 { name: 'h_origin', type: 'string' },
1130 { name: 'h_amount', type: 'float' },
1131 { name: 'h_cost', type: 'float' },
1132 { name: 'h_type', type: 'string' },
1133 { name: 'h_form', type: 'string' },
1134 { name: 'h_useat', type: 'string' },
1135 { name: 'h_time', type: 'float' },
1136 { name: 'h_alpha', type: 'float' },
1137 { name: 'h_beta', type: 'float' },
1138 { name: 'h_hsi', type: 'float' },
1139 { name: 'h_humulene', type: 'float' },
1140 { name: 'h_carophyllene', type: 'float' },
1141 { name: 'h_cohumulone', type: 'float' },
1142 { name: 'h_myrcene', type: 'float' },
1143 { name: 'h_total_oil', type: 'float' },
1144 { name: 'h_weight', type: 'float' }
1145 ],
1146 addrow: function (rowid, rowdata, position, commit) {
1147 commit(true);
1148 },
1149 deleterow: function (rowid, commit) {
1150 commit(true);
1151 }
1152 };
1153 var hopAdapter = new $.jqx.dataAdapter(hopSource, {
1154 beforeLoadComplete: function (records) {
1155 var data = new Array();
1156 for (var i = 0; i < records.length; i++) {
1157 var row = records[i];
1158 row.h_weight = row.h_amount * 1000;
1159 data.push(row);
1160 }
1161 return data;
1162 },
1163 loadError: function(jqXHR, status, error) {
1164 $('#err').text(status + ' ' + error);
1165 },
1166 });
1167 $("#hopGrid").jqxGrid({
1168 width: 1050,
1169 height: 400,
1170 source: hopAdapter,
1171 theme: theme,
1172 selectionmode: 'singlerow',
1173 editmode: 'selectedcell',
1174 editable: true,
1175 localization: getLocalization(),
1176 showtoolbar: true,
1177 rendertoolbar: function (toolbar) {
1178 var me = this;
1179 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
1180 toolbar.append(container);
1181 container.append('<div style="float: left; margin-left: 165px;" id="haddrowbutton"></div>');
1182 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>');
1183 container.append('<div style="float: left; margin-left: 10px;" id="hinstockbutton"></div>');
1184 container.append('<input style="float: left; margin-left: 280px;" id="hdeleterowbutton" type="button" value="Verwijder hop" />');
1185 // add hop from dropdownlist.
1186 $("#haddrowbutton").jqxDropDownList({
1187 placeHolder: "Kies hop:",
1188 theme: theme,
1189 source: hoplist,
1190 displayMember: "name",
1191 width: 150,
1192 height: 27,
1193 dropDownWidth: 500,
1194 dropDownHeight: 500,
1195 renderer: function (index, label, value) {
1196 var datarecord = hoplist.records[index];
1197 return datarecord.origin+ " / " + datarecord.name + " (" + datarecord.alpha + "% &alpha;)";
1198 }
1199 });
1200 $("#haddrowbutton").on('select', function (event) {
1201 if (event.args) {
1202 var index = event.args.index;
1203 var datarecord = hoplist.records[index];
1204 var row = {};
1205 row["h_name"] = datarecord.name;
1206 row["h_origin"] = datarecord.origin;
1207 row["h_amount"] = 0;
1208 row["h_cost"] = datarecord.cost;
1209 row["h_type"] = datarecord.type;
1210 row["h_form"] = datarecord.form;
1211 row["h_useat"] = datarecord.useat;
1212 row["h_time"] = 0;
1213 row["h_alpha"] = datarecord.alpha;
1214 row["h_beta"] = datarecord.beta;
1215 row["h_hsi"] = datarecord.hsi;
1216 row["h_humulene"] = datarecord.humulene;
1217 row["h_carophyllene"] = datarecord.carophyllene;
1218 row["h_cohumulone"] = datarecord.cohumulone;
1219 row["h_myrcene"] = datarecord.myrcene;
1220 row["h_total_oil"] = datarecord.total_oil;
1221 row["h_weight"] = 0;
1222 var commit = $("#hopGrid").jqxGrid('addrow', null, row);
1223 }
1224 });
1225
1226 $("#hinstockbutton").jqxCheckBox({ theme: theme, height: 27 });
1227 $("#hinstockbutton").on('change', function (event) {
1228 hopinstock = event.args.checked;
1229 hoplist.dataBind();
1230 });
1231
1232 // delete selected hop.
1233 $("#hdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 });
1234 $("#hdeleterowbutton").on('click', function () {
1235 var selectedrowindex = $("#hopGrid").jqxGrid('getselectedrowindex');
1236 var rowscount = $("#hopGrid").jqxGrid('getdatainformation').rowscount;
1237 if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
1238 var id = $("#hopGrid").jqxGrid('getrowid', selectedrowindex);
1239 var commit = $("#hopGrid").jqxGrid('deleterow', id);
1240 }
1241 });
1242 },
1243 ready: function() {
1244 $('#jqxTabs').jqxTabs('next');
1245 },
1246 columns: [
1247 { text: 'Hop', editable: false, datafield: 'h_name',
1248 cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties) {
1249 var rowData = $("#hopGrid").jqxGrid('getrowdata', row);
1250 return "<span style='margin: 3px; margin-top: 6px; float: "+
1251 columnproperties.cellsalign+"'>" +rowData.h_origin+" / "+rowData.h_name+"</span>";
1252 },
1253 },
1254 { text: 'Type', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_type' },
1255 { text: 'Vorm', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_form' },
1256 { text: 'Alpha', editable: false, datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' },
1257 { text: 'Amount', hidden: true, datafield: 'h_amount' },
1258 { text: 'Gewicht gr', datafield: 'h_weight', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f1',
1259 columntype: 'numberinput',
1260 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
1261 return "<div style='margin: 4px;' class='jqx-right-align'>" + dataAdapter.formatNumber(value, "f1") + " gr</div>";
1262 },
1263 initeditor: function (row, cellvalue, editor, celltext, pressedChar) {
1264 editor.jqxNumberInput({
1265 inputMode: 'simple', decimalDigits: 1, min: 0, max: parseFloat(dataRecord.batch_size * 200),
1266 spinButtons: false
1267 });
1268 },
1269 validation: function (cell, value) {
1270 var maxhops = parseFloat(dataRecord.batch_size) * 200;
1271 if (value < 0 || value > maxhops ) {
1272 return { result: false, message: "Gewicht moet tussen 0 en "+maxhops+" gram zijn" };
1273 }
1274 return true;
1275 }
1276 },
1277 { text: 'Gebruik', width: 110, align: 'center', cellsalign: 'center', datafield: 'h_useat', columntype: 'dropdownlist',
1278 createeditor: function (row, column, editor) {
1279 var srcUse = [ "Boil", "Dry Hop", "Mash", "First Wort", "Aroma" ];
1280 editor.jqxDropDownList({ autoDropDownHeight: true, source: srcUse });
1281 },
1282 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
1283 if ((newvalue == "Mash") || (newvalue == "First Wort")) {
1284 $("#hopGrid").jqxGrid('setcellvalue', row, "h_time", parseFloat(dataRecord.boil_time));
1285 } else if (newvalue == "Aroma") {
1286 $("#hopGrid").jqxGrid('setcellvalue', row, "h_time", 0);
1287 }
1288 }
1289 },
1290 { text: 'Tijd', datafield: 'h_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0',
1291 columntype: 'numberinput',
1292 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
1293 if ((rowdata.h_useat == "Boil") || (rowdata.h_useat == "Dry Hop") || (rowdata.h_useat == "Dry hop"))
1294 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+"</div>";
1295 else
1296 return "<div style='margin: 4px;' class='jqx-right-align'> </div>";
1297 },
1298 initeditor: function (row, cellvalue, editor, celltext, pressedChar) {
1299 editor.jqxNumberInput({ decimalDigits: 0, digits: 3, min: 0, max: parseFloat(dataRecord.boil_time) });
1300 },
1301 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
1302 var use = $("#hopGrid").jqxGrid('getcellvalue', row, "h_useat");
1303 if ((use == "Mash") || (use == "First Wort") || (use == "First wort") || (use == "Aroma"))
1304 return oldvalue;
1305 },
1306 validation: function (cell, value) {
1307 var high = parseFloat(dataRecord.boil_time);
1308 if (value < 0 || value > high ) {
1309 return { result: false, message: "De tijd moet 0-"+high+" zijn" };
1310 }
1311 return true;
1312 }
1313 },
1314 { text: 'IBU', editable: false, datafield: 'ibu', width: 80, align: 'right',
1315 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
1316 var ibu = toIBU(rowdata.h_useat,
1317 rowdata.h_form,
1318 preboil_sg,
1319 parseFloat($("#batch_size").jqxNumberInput('decimal')),
1320 parseFloat(rowdata.h_amount),
1321 parseFloat(rowdata.h_time),
1322 parseFloat(rowdata.h_alpha),
1323 $("#ibu_method").val()
1324 );
1325 calcIBUs();
1326 return "<div style='margin: 4px;' class='jqx-right-align'>" + dataAdapter.formatNumber(ibu, "f1") + "</div>";
1327 }
1328 }
1329 ]
1330 });
1331 $("#hopGrid").on('cellendedit', function (event) {
1332 var args = event.args;
1333 console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value);
1334 $("#hopGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value);
1335 if (args.datafield == 'h_weight')
1336 $("#hopGrid").jqxGrid('setcellvalue', args.rowindex, 'h_amount', args.value / 1000);
1337 //$('#hopGrid').jqxGrid('sortby', 'f_amount', 'desc');
1338 });
1339 };
1340
1341 // Inline miscs editor
1342 var editMisc = function (data) {
1343 var miscSource = {
1344 localdata: data.miscs,
1345 datatype: "local",
1346 cache: false,
1347 datafields: [
1348 { name: 'm_name', type: 'string' },
1349 { name: 'm_amount', type: 'float' },
1350 { name: 'm_cost', type: 'float' },
1351 { name: 'm_type', type: 'string' },
1352 { name: 'm_use_use', type: 'string' },
1353 { name: 'm_time', type: 'float' },
1354 { name: 'm_amount_is_weight', type: 'bool' },
1355 { name: 'm_weight', type: 'float' }
1356 ],
1357 addrow: function (rowid, rowdata, position, commit) {
1358 commit(true);
1359 },
1360 deleterow: function (rowid, commit) {
1361 commit(true);
1362 }
1363 };
1364 var miscAdapter = new $.jqx.dataAdapter(miscSource, {
1365 beforeLoadComplete: function (records) {
1366 var data = new Array();
1367 for (var i = 0; i < records.length; i++) {
1368 var row = records[i];
1369 row.m_weight = row.m_amount * 1000;
1370 data.push(row);
1371 // Initial set water agent values.
1372 switch (row.m_name) {
1373 case 'CaCl2': $("#wa_cacl2").val(row.m_weight);
1374 break;
1375 case 'CaSO4': $("#wa_caso4").val(row.m_weight);
1376 break;
1377 case 'MgSO4': $("#wa_mgso4").val(row.m_weight);
1378 break;
1379 case 'NaCl': $("#wa_nacl").val(row.m_weight);
1380 break;
1381 case 'Melkzuur': $("#wa_acid_name").val('Melkzuur');
1382 $("#wa_acid").val(row.m_weight);
1383 $("#wa_acid_perc").val(80);
1384 last_acid = 'Melkzuur';
1385 break;
1386 case 'Zoutzuur': $("#wa_acid_name").val('Zoutzuur');
1387 $("#wa_acid").val(row.m_weight);
1388 $("#wa_acid_perc").val(80);
1389 last_acid = 'Zoutzuur';
1390 break;
1391 case 'Fosforzuur': $("#wa_acid_name").val('Fosforzuur');
1392 $("#wa_acid").val(row.m_weight);
1393 $("#wa_acid_perc").val(80);
1394 last_acid = 'Fosforzuur';
1395 break;
1396 case 'Zwavelzuur': $("#wa_acid_name").val('Zwavelzuur');
1397 $("#wa_acid").val(row.m_weight);
1398 $("#wa_acid_perc").val(80);
1399 last_acid = 'Zwavelzuur';
1400 break;
1401 case 'NaHCO3': $("#wa_base_name").val('NaHCO3');
1402 $("#wa_base").val(row.m_weight);
1403 last_base = 'NaHCO3';
1404 break;
1405 case 'Na2CO3': $("#wa_base_name").val('Na2CO3');
1406 $("#wa_base").val(row.m_weight);
1407 last_base = 'Na2CO3';
1408 break;
1409 case 'CaCO3': $("#wa_base_name").val('CaCO3');
1410 $("#wa_base").val(row.m_weight);
1411 last_base = 'CaCO3';
1412 break;
1413 case 'Ca(OH)2': $("#wa_base_name").val('Ca(OH)2');
1414 $("#wa_base").val(row.m_weight);
1415 last_base = 'Ca(OH)2';
1416 break;
1417 }
1418 }
1419 return data;
1420 },
1421 loadError: function(jqXHR, status, error) {
1422 $('#err').text(status + ' ' + error);
1423 },
1424 });
1425 $("#miscGrid").jqxGrid({
1426 width: 960,
1427 height: 400,
1428 source: miscAdapter,
1429 theme: theme,
1430 selectionmode: 'singlerow',
1431 editmode: 'selectedcell',
1432 editable: true,
1433 localization: getLocalization(),
1434 showtoolbar: true,
1435 rendertoolbar: function (toolbar) {
1436 var me = this;
1437 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
1438 toolbar.append(container);
1439 container.append('<div style="float: left; margin-left: 165px;" id="maddrowbutton"></div>');
1440 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>');
1441 container.append('<div style="float: left; margin-left: 10px;" id="minstockbutton"></div>');
1442 container.append('<input style="float: left; margin-left: 200px;" id="mdeleterowbutton" type="button" value="Verwijder ingredient" />');
1443 // add misc from dropdownlist.
1444 $("#maddrowbutton").jqxDropDownList({
1445 placeHolder: "Kies ingredient:",
1446 theme: theme,
1447 source: misclist,
1448 displayMember: "name",
1449 width: 150,
1450 height: 27,
1451 dropDownWidth: 500,
1452 dropDownHeight: 500
1453 });
1454 $("#maddrowbutton").on('select', function (event) {
1455 if (event.args) {
1456 var index = event.args.index;
1457 var datarecord = misclist.records[index];
1458 var row = {};
1459 row["m_name"] = datarecord.name;
1460 row["m_amount"] = 0;
1461 row["m_cost"] = datarecord.cost;
1462 row["m_type"] = datarecord.type;
1463 row["m_use_use"] = datarecord.use_use;
1464 row["m_time"] = 0;
1465 row["m_weight"] = 0;
1466 row["m_amount_is_weight"] = datarecord.amount_is_weight;
1467 var commit = $("#miscGrid").jqxGrid('addrow', null, row);
1468 }
1469 });
1470 $("#minstockbutton").jqxCheckBox({ theme: theme, height: 27 });
1471 $("#minstockbutton").on('change', function (event) {
1472 miscinstock = event.args.checked;
1473 misclist.dataBind();
1474 });
1475 // delete selected misc.
1476 $("#mdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 });
1477 $("#mdeleterowbutton").on('click', function () {
1478 var selectedrowindex = $("#miscGrid").jqxGrid('getselectedrowindex');
1479 var rowscount = $("#miscGrid").jqxGrid('getdatainformation').rowscount;
1480 var type = $("#miscGrid").jqxGrid('getcellvalue', selectedrowindex, "m_type");
1481 if (selectedrowindex >= 0 && selectedrowindex < rowscount && type != "Water agent") {
1482 var id = $("#miscGrid").jqxGrid('getrowid', selectedrowindex);
1483 var commit = $("#miscGrid").jqxGrid('deleterow', id);
1484 }
1485 });
1486 },
1487 ready: function() {
1488 $('#jqxTabs').jqxTabs('next');
1489 },
1490 columns: [
1491 { text: 'Ingredient', editable: false, datafield: 'm_name' },
1492 { text: 'Type', editable: false, width: 120, align: 'center', cellsalign: 'center', datafield: 'm_type' },
1493 { text: 'Gebruik', width: 110, align: 'center', cellsalign: 'center', datafield: 'm_use_use', columntype: 'dropdownlist',
1494 createeditor: function (row, column, editor) {
1495 var srcUseUse = [ "Mash", "Boil", "Primary", "Secondary", "Bottling" ];
1496 editor.jqxDropDownList({ autoDropDownHeight: true, source: srcUseUse });
1497 },
1498 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
1499 var type = $("#miscGrid").jqxGrid('getcellvalue', row, "m_type");
1500 if (type == "Water agent")
1501 return oldvalue;
1502 }
1503 },
1504 { datafield: 'm_amount_is_weight', hidden: true }, // We need to declare this column
1505 { datafield: 'm_amount', hidden: true }, // We need to declare this column
1506 { text: 'Hoeveelheid', datafield: 'm_weight', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f2',
1507 columntype: 'numberinput',
1508 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
1509 var vstr = rowdata.m_amount_is_weight ? "gr":"ml";
1510 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value,"f2")+" "+vstr+"</div>";
1511 },
1512 validation: function (cell, value) {
1513 var high = parseFloat(dataRecord.boil_size) * 1000;
1514 if (value < 0 || value > high) {
1515 return { result: false, message: "Hoeveelheid moet tussen 0 en "+high+" zijn" };
1516 }
1517 return true;
1518 },
1519 initeditor: function (row, cellvalue, editor) {
1520 editor.jqxNumberInput({
1521 inputMode: 'simple', min: 0, max: parseFloat(dataRecord.boil_size) * 1000,
1522 decimalDigits: 2, spinButtons: false
1523 });
1524 },
1525 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
1526 var type = $("#miscGrid").jqxGrid('getcellvalue', row, "m_type");
1527 if (type == "Water agent")
1528 return oldvalue;
1529 }
1530 },
1531 { text: 'Tijd', datafield: 'm_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0',
1532 columntype: 'numberinput',
1533 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
1534 if (rowdata.m_use_use == 'Boil') {
1535 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" m</div>";
1536 } else if (rowdata.m_use_use == 'Secondary') {
1537 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" d</div>";
1538 } else {
1539 var tijd = 0;
1540 return "<div style='margin: 4px;' class='jqx-right-align'> </div>";
1541 }
1542 },
1543 initeditor: function (row, cellvalue, editor, celltext, pressedChar) {
1544 editor.jqxNumberInput({ decimalDigits: 0, digits: 3, min: 0, max: parseFloat(dataRecord.boil_time) });
1545 },
1546 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
1547 var use = $("#miscGrid").jqxGrid('getcellvalue', row, "m_use_use");
1548 if ((use != "Boil") && (use != "Secondary"))
1549 return oldvalue;
1550 },
1551 validation: function (cell, value) {
1552 var high = parseFloat(dataRecord.boil_time);
1553 if (value < 0 || value > high ) {
1554 return { result: false, message: "De tijd moet 0-"+high+" zijn" };
1555 }
1556 return true;
1557 }
1558 }
1559 ]
1560 });
1561 $("#miscGrid").on('cellendedit', function (event) {
1562 var args = event.args;
1563 console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value);
1564 $("#miscGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value);
1565 if (args.datafield == 'm_weight') {
1566 $("#miscGrid").jqxGrid('setcellvalue', args.rowindex, 'm_amount', parseFloat(args.value) / 1000);
1567 }
1568 });
1569 };
1570
1571 // Inline yeasts editor
1572 var editYeast = function (data) {
1573 var yeastSource = {
1574 localdata: data.yeasts,
1575 datatype: "local",
1576 cache: false,
1577 datafields: [
1578 { name: 'y_name', type: 'string' },
1579 { name: 'y_laboratory', type: 'string' },
1580 { name: 'y_product_id', type: 'string' },
1581 { name: 'y_amount', type: 'float' },
1582 { name: 'y_cost', type: 'float' },
1583 { name: 'y_type', type: 'string' },
1584 { name: 'y_form', type: 'string' },
1585 { name: 'y_time', type: 'float' },
1586 { name: 'y_min_temperature', type: 'float' },
1587 { name: 'y_max_temperature', type: 'float' },
1588 { name: 'y_attenuation', type: 'float' },
1589 { name: 'y_amount_is_weight', type: 'bool' },
1590 { name: 'y_use', type: 'string' },
1591 { name: 'y_weight', type: 'float' }
1592 ],
1593 addrow: function (rowid, rowdata, position, commit) {
1594 commit(true);
1595 },
1596 deleterow: function (rowid, commit) {
1597 commit(true);
1598 }
1599 };
1600 var yeastAdapter = new $.jqx.dataAdapter(yeastSource, {
1601 beforeLoadComplete: function (records) {
1602 var data = new Array();
1603 for (var i = 0; i < records.length; i++) {
1604 var row = records[i];
1605 if (row.y_form == 'Liquid')
1606 row.y_weight = Math.round(row.y_amount * 17);
1607 else
1608 row.y_weight = row.y_amount * 1000;
1609 data.push(row);
1610 }
1611 return data;
1612 },
1613 loadError: function(jqXHR, status, error) {
1614 $('#err').text(status + ' ' + error);
1615 },
1616 });
1617 $("#yeastGrid").jqxGrid({
1618 width: 1050,
1619 height: 300,
1620 source: yeastAdapter,
1621 theme: theme,
1622 selectionmode: 'singlerow',
1623 editmode: 'selectedcell',
1624 editable: true,
1625 localization: getLocalization(),
1626 showtoolbar: true,
1627 rendertoolbar: function (toolbar) {
1628 var me = this;
1629 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
1630 toolbar.append(container);
1631 container.append('<div style="float: left; margin-left: 165px;" id="yaddrowbutton"></div>');
1632 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>');
1633 container.append('<div style="float: left; margin-left: 10px;" id="yinstockbutton"></div>');
1634 container.append('<input style="float: left; margin-left: 230px;" id="ydeleterowbutton" type="button" value="Verwijder gist" />');
1635 // add yeast from dropdownlist.
1636 $("#yaddrowbutton").jqxDropDownList({
1637 placeHolder: "Kies gist:",
1638 theme: theme,
1639 source: yeastlist,
1640 displayMember: "name",
1641 width: 150,
1642 height: 27,
1643 dropDownWidth: 500,
1644 dropDownHeight: 500,
1645 renderer: function (index, label, value) {
1646 var datarecord = yeastlist.records[index];
1647 return datarecord.laboratory+" "+datarecord.product_id+" "+datarecord.name;
1648 }
1649 });
1650 $("#yaddrowbutton").on('select', function (event) {
1651 if (event.args) {
1652 var index = event.args.index;
1653 var datarecord = yeastlist.records[index];
1654 var row = {};
1655 row["y_name"] = datarecord.name;
1656 row["y_laboratory"] = datarecord.laboratory;
1657 row["y_product_id"] = datarecord.product_id;
1658 row["y_type"] = datarecord.type;
1659 row["y_form"] = datarecord.form;
1660 row["y_amount"] = 0;
1661 row["y_cost"] = datarecord.cost;
1662 row["y_use"] = "Primary";
1663 row["y_time"] = 0;
1664 if (datarecord.form == "Dry") {
1665 row["y_amount_is_weight"] = 1;
1666 } else {
1667 row["y_amount_is_weight"] = 0;
1668 }
1669 row["y_min_temperature"] = datarecord.min_temperature;
1670 row["y_max_temperature"] = datarecord.max_temperature;
1671 row["y_attenuation"] = datarecord.attenuation;
1672 row["y_weight"] = 0;
1673 var commit = $("#yeastGrid").jqxGrid('addrow', null, row);
1674 }
1675 });
1676 $("#yinstockbutton").jqxCheckBox({ theme: theme, height: 27 });
1677 $("#yinstockbutton").on('change', function (event) {
1678 yeastinstock = event.args.checked;
1679 yeastlist.dataBind();
1680 });
1681 // delete selected yeast.
1682 $("#ydeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 });
1683 $("#ydeleterowbutton").on('click', function () {
1684 var selectedrowindex = $("#yeastGrid").jqxGrid('getselectedrowindex');
1685 var rowscount = $("#yeastGrid").jqxGrid('getdatainformation').rowscount;
1686 if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
1687 var id = $("#yeastGrid").jqxGrid('getrowid', selectedrowindex);
1688 var commit = $("#yeastGrid").jqxGrid('deleterow', id);
1689 }
1690 });
1691 },
1692 ready: function() {
1693 // calcSVG();
1694 $('#jqxTabs').jqxTabs('next');
1695 },
1696 columns: [
1697 { text: 'Gist', editable: false, datafield: 'y_name' },
1698 { text: 'Laboratorium', editable: false, width: 150, datafield: 'y_laboratory' },
1699 { text: 'Code', editable: false, width: 90, datafield: 'y_product_id' },
1700 { text: 'Soort', editable: false, width: 80, align: 'center', cellsalign: 'center', datafield: 'y_form' },
1701 { text: 'Min.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_min_temperature' },
1702 { text: 'Max.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_max_temperature' },
1703 { text: 'Attn.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_attenuation', cellsformat: 'f1' },
1704 { text: 'Voor', width: 100, align: 'center', cellsalign: 'center', datafield: 'y_use', columntype: 'dropdownlist',
1705 createeditor: function (row, column, editor) {
1706 var srcYUse = [ "Primary", "Secondary", "Bottle" ];
1707 editor.jqxDropDownList({ autoDropDownHeight: true, source: srcYUse });
1708 }
1709 },
1710 { datafield: 'y_amount', width: 90 },
1711 { text: 'Hoeveel', datafield: 'y_weight', width: 110, align: 'right', cellsalign: 'right',
1712 cellsformat: 'f1', columntype: 'numberinput',
1713 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
1714 if (rowdata.y_form == 'Liquid') {
1715 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" pk</div>";
1716 } else if (rowdata.y_form == 'Dry') {
1717 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f1")+" gr</div>";
1718 } else {
1719 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" ml</div>";
1720 }
1721 },
1722 initeditor: function (row, cellvalue, editor, celltext, pressedChar) {
1723 var form = $("#yeastGrid").jqxGrid('getcellvalue', args.rowindex, 'y_form');
1724 if (form == 'Dry') {
1725 editor.jqxNumberInput({ decimalDigits: 1, min: 0, spinButtons: false });
1726 } else {
1727 editor.jqxNumberInput({ decimalDigits: 0, min: 0, spinButtons: false });
1728 }
1729 },
1730 validation: function (cell, value) {
1731 if (value < 0 || value > 100000000000 ) {
1732 return { result: false, message: "Hoeveelheid moet 0-~ zijn" };
1733 }
1734 return true;
1735 }
1736 }
1737 ]
1738 });
1739 $("#yeastGrid").on('cellendedit', function (event) {
1740 var args = event.args;
1741 console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value);
1742 $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value);
1743 if (args.datafield == 'y_weight') {
1744 var form = $("#yeastGrid").jqxGrid('getcellvalue', args.rowindex, 'y_form');
1745 if (form == 'Liquid')
1746 $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, 'y_amount', parseFloat(args.value * 0.0588));
1747 else
1748 $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, 'y_amount', parseFloat(args.value / 1000));
1749 }
1750 });
1751 };
1752
1753 // inline mash editor
1754 var editMash = function (data) {
1755 var generaterow = function () {
1756 var row = {};
1757 row["step_name"] = "Stap 1";
1758 row["step_type"] = "Infusion";
1759 row["step_infuse_amount"] = 15;
1760 row["step_temp"] = 62.0;
1761 row['step_time'] = 20.0;
1762 row['ramp_time'] = 1.0;
1763 row['end_temp'] = 62.0;
1764 return row;
1765 }
1766 var mashSource = {
1767 localdata: data.mashs,
1768 datatype: "local",
1769 cache: false,
1770 datafields: [
1771 { name: 'step_name', type: 'string' },
1772 { name: 'step_type', type: 'string' },
1773 { name: 'step_infuse_amount', type: 'float' },
1774 { name: 'step_temp', type: 'float' },
1775 { name: 'step_time', type: 'float' },
1776 { name: 'ramp_time', type: 'float' },
1777 { name: 'end_temp', type: 'float' }
1778 ],
1779 addrow: function (rowid, rowdata, position, commit) {
1780 commit(true);
1781 },
1782 deleterow: function (rowid, commit) {
1783 commit(true);
1784 }
1785 };
1786 var mashAdapter = new $.jqx.dataAdapter(mashSource, {
1787 beforeLoadComplete: function (records) {
1788 mash_infuse = 0;
1789 var data = new Array();
1790 for (var i = 0; i < records.length; i++) {
1791 var row = records[i];
1792 if (row.step_type == 'Infusion')
1793 mash_infuse += parseFloat(row.step_infuse_amount);
1794 }
1795 },
1796 });
1797 $("#mashGrid").jqxGrid({
1798 width: 960,
1799 height: 400,
1800 source: mashAdapter,
1801 theme: theme,
1802 selectionmode: 'singlerow',
1803 editmode: 'selectedcell',
1804 editable: true,
1805 localization: getLocalization(),
1806 showtoolbar: true,
1807 rendertoolbar: function (toolbar) {
1808 var me = this;
1809 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
1810 toolbar.append(container);
1811 container.append('<input style="float: left; margin-left: 165px;" id="saddrowbutton" type="button" value="Nieuwe stap" />');
1812 container.append('<input style="float: left; margin-left: 230px;" id="sdeleterowbutton" type="button" value="Verwijder stap" />');
1813 $("#saddrowbutton").jqxButton({ theme: theme, height: 27, width: 150 });
1814 $("#saddrowbutton").on('click', function () {
1815 var datarow = generaterow();
1816 var commit = $("#mashGrid").jqxGrid('addrow', null, datarow);
1817 });
1818 // delete selected yeast.
1819 $("#sdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 });
1820 $("#sdeleterowbutton").on('click', function () {
1821 var selectedrowindex = $("#mashGrid").jqxGrid('getselectedrowindex');
1822 var rowscount = $("#mashGrid").jqxGrid('getdatainformation').rowscount;
1823 if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
1824 var id = $("#mashGrid").jqxGrid('getrowid', selectedrowindex);
1825 var commit = $("#mashGrid").jqxGrid('deleterow', id);
1826 }
1827 });
1828 },
1829 ready: function() {
1830 var fg = estimate_fg(psugar, pcara, 0, 0, 0, svg, parseFloat(parseFloat($("#est_og").jqxNumberInput('decimal'))));
1831 dataRecord.est_fg = fg;
1832 $('#est_fg').val(fg);
1833 calcInit();
1834 $('#jqxLoader').jqxLoader('close');
1835 $('#jqxTabs').jqxTabs('first');
1836 },
1837 columns: [
1838 { text: 'Stap naam', datafield: 'step_name' },
1839 { text: 'Stap type', datafield: 'step_type', width: 110, columntype: 'dropdownlist',
1840 createeditor: function (row, cellvalue, editor, celltext, cellwidth, cellheight) {
1841 var dataSource = [ "Infusion", "Temperature", "Decoction" ];
1842 editor.jqxDropDownList({ source: dataSource, dropDownHeight: 105 });
1843 }
1844 },
1845 { text: 'Temperatuur', datafield: 'step_temp', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1',
1846 validation: function (cell, value) {
1847 if (value < 35 || value > 80) {
1848 return { result: false, message: "De temperatuur moet tussen 35 en 80 zijn." };
1849 }
1850 return true;
1851 }
1852 },
1853 { text: 'Eind', datafield: 'end_temp', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1',
1854 validation: function (cell, value) {
1855 if (value < 35 || value > 80) {
1856 return { result: false, message: "De temperatuur moet tussen 35 en 80 zijn." };
1857 }
1858 return true;
1859 }
1860 },
1861 { text: 'Tijd', datafield: 'step_time', width: 70, align: 'right', cellsalign: 'right',
1862 validation: function (cell, value) {
1863 if (value < 1 || value > 360) {
1864 return { result: false, message: "De tijd moet tussen 1 en 360 zijn." };
1865 }
1866 return true;
1867 }
1868 },
1869 { text: 'Stap', datafield: 'ramp_time', width: 70, align: 'right', cellsalign: 'right',
1870 validation: function (cell, value) {
1871 if (value < 1 || value > 60) {
1872 return { result: false, message: "De tijd moet tussen 1 en 60 zijn." };
1873 }
1874 return true;
1875 }
1876 },
1877 { text: 'Infuse', datafield: 'step_infuse_amount', width: 70, align: 'right', cellsalign: 'right',
1878 validation: function (cell, value) {
1879 if (value < 0 || value > 60) {
1880 return { result: false, message: "De waarde moet tussen 0 en 60 zijn." };
1881 }
1882 return true;
1883 }
1884 }
1885 ]
1886 });
1887 $("#mashGrid").on('cellendedit', function (event) {
1888 $('#mashGrid').jqxGrid('sortby', 'step_temp', 'asc');
1889 });
1890 };
1891
611 // initialize the input fields. 1892 // initialize the input fields.
1893 var srcType = [ "All Grain", "Partial Mash", "Extract" ];
1894 var srcColor = [ "Morey", "Mosher", "Daniels" ];
1895 var srcIBU = [ "Tinseth", "Rager", "Daniels" ]; // Only these are supported at this time.
1896 var srcBase = [ "NaHCO3", "Na2CO3", "CaCO3", "Ca(OH)2" ];
1897 var srcAcid = [ "Melkzuur", "Zoutzuur", "Fosforzuur", "Zwavelzuur" ];
612 var srcMaterial= [ "RVS", "Aluminium", "Kunststof", "Koper" ]; 1898 var srcMaterial= [ "RVS", "Aluminium", "Kunststof", "Koper" ];
613 var srcAeration= [ 'None', 'Air', 'Oxygen' ]; 1899 var srcAeration= [ 'None', 'Air', 'Oxygen' ];
614 var srcCooling= [ '-', 'Emersion chiller', 'Counterflow chiller', 'Au bain marie', 'Natural' ]; 1900 var srcCooling= [ '-', 'Emersion chiller', 'Counterflow chiller', 'Au bain marie', 'Natural' ];
615 // '-', 'Dompelkoeler', 'Tegenstroomkoeler', 'Au bain marie', 'Laten afkoelen' 1901 // '-', 'Dompelkoeler', 'Tegenstroomkoeler', 'Au bain marie', 'Laten afkoelen'
616 $("#pname").jqxInput({ theme: theme, width: 640, height: 23 }); 1902 $("#name").jqxInput({ theme: theme, width: 640, height: 23 });
617 $("#code").jqxInput({ theme: theme, width: 100, height: 23 }); 1903 $("#code").jqxInput({ theme: theme, width: 100, height: 23 });
618 $("#birth").jqxDateTimeInput({ theme: theme, width: 150, height: 23, formatString: 'yyyy-MM-dd' }); 1904 $("#birth").jqxDateTimeInput({ theme: theme, width: 150, height: 23, formatString: 'yyyy-MM-dd' });
619 $("#stage").jqxInput({ theme: theme, width: 100, height: 23 }); 1905 $("#stage").jqxInput({ theme: theme, width: 100, height: 23 });
620 $("#pnotes").jqxInput({ theme: theme, width: 960, height: 200 }); 1906 $("#notes").jqxInput({ theme: theme, width: 960, height: 200 });
621 $("#log_brew").jqxCheckBox({ theme: theme, width: 120, height: 23, disabled : true }); 1907 $("#log_brew").jqxCheckBox({ theme: theme, width: 120, height: 23, disabled : true });
622 $("#log_fermentation").jqxCheckBox({ theme: theme, width: 120, height: 23, disabled : true }); 1908 $("#log_fermentation").jqxCheckBox({ theme: theme, width: 120, height: 23, disabled : true });
623 $("#inventory_reduced").jqxCheckBox({ theme: theme, width: 120, height: 23 }); 1909 $("#inventory_reduced").jqxCheckBox({ theme: theme, width: 120, height: 23 });
624 $('#inventory_reduced').on('checked', function (event) { 1910 $('#inventory_reduced').on('checked', function (event) {
625 // Call a script to do the work and block this. 1911 // Call a script to do the work and block this.
626 // Note that this script must set this flag too, so if the user doesn't Save it is still set. 1912 // Note that this script must set this flag too, so if the user doesn't Save it is still set.
627 // Call the script with the uuid. 1913 // Call the script with the uuid.
628 $("#inventory_reduced").jqxCheckBox({ disabled : true }); 1914 $("#inventory_reduced").jqxCheckBox({ disabled : true });
629 }); 1915 });
630 $("#plocked").jqxCheckBox({ theme: theme, width: 120, height: 23, disabled : true }); 1916 $("#locked").jqxCheckBox({ theme: theme, width: 120, height: 23, disabled : true });
631 $('#plocked').on('checked', function (event) { 1917 $('#locked').on('checked', function (event) {
632 if (brewstage >= 10) { 1918 if (brewstage >= 10) {
633 $("#stage").val('Closed'); 1919 $("#stage").val('Closed');
634 brewstage = 11; 1920 brewstage = 11;
635 } 1921 }
636 }); 1922 });
637 $('#plocked').on('unchecked', function (event) { 1923 $('#locked').on('unchecked', function (event) {
638 if (brewstage >= 10) { 1924 if (brewstage >= 10) {
639 $("#stage").val('Ready'); 1925 $("#stage").val('Ready');
640 brewstage = 10; 1926 brewstage = 10;
641 } 1927 }
642 }); 1928 });
693 $("#brew_date_end").jqxDateTimeInput({ theme: theme, width: 230, height: 23, formatString: 'yyyy-MM-dd HH:mm:ss', showTimeButton: true }); 1979 $("#brew_date_end").jqxDateTimeInput({ theme: theme, width: 230, height: 23, formatString: 'yyyy-MM-dd HH:mm:ss', showTimeButton: true });
694 // Vergisting 1980 // Vergisting
695 // Packaging 1981 // Packaging
696 // Tasting 1982 // Tasting
697 1983
698 // Recipe 1984 $("#batch_size").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: 'L', symbolPosition: 'right' });
1985 $("#boil_size").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 2, readOnly: true, symbol: 'L', symbolPosition: 'right' });
1986 $("#boil_time").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 360, decimalDigits: 0, spinButtons: true });
1987 $("#efficiency").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 40, max: 100, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' });
699 $("#est_og").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 3 }); 1988 $("#est_og").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 3 });
700 $("#est_ibu").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 0 }); 1989 $("#est_og2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 3, readOnly: true });
701 $("#est_color").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 0 }); 1990 $("#st_og_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true });
1991 $("#st_og_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true });
1992
1993 $("#est_fg").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 3, readOnly: true });
1994 $("#st_fg_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true });
1995 $("#st_fg_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true });
1996
1997 $("#est_abv").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
1998 $("#st_abv_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
1999 $("#st_abv_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
2000
2001 $("#est_color").jqxNumberInput({ inputMode: 'simple', theme: theme, symbol: ' EBC', symbolPosition: 'right', width: 100, height: 23, decimalDigits: 0, readOnly: true });
2002 $("#est_color2").jqxNumberInput({ inputMode: 'simple', theme: theme, symbol: ' EBC', symbolPosition: 'right', width: 100, height: 23, decimalDigits: 0, readOnly: true });
2003 $("#st_color_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
2004 $("#st_color_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
2005 $("#color_method").jqxDropDownList({ theme: theme, source: srcColor, width: 125, height: 23, dropDownHeight: 95 });
2006
2007 $("#est_ibu").jqxNumberInput({ inputMode: 'simple', theme: theme, symbol: ' IBU', symbolPosition: 'right', width: 100, height: 23, decimalDigits: 0, readOnly: true });
2008 $("#est_ibu2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
2009 $("#st_ibu_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
2010 $("#st_ibu_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
2011 $("#ibu_method").jqxDropDownList({ theme: theme, source: srcIBU, width: 125, height: 23, dropDownHeight: 95, dropDownVerticalAlignment: 'top' });
2012
2013 $("#est_carb").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
2014 $("#st_carb_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
2015 $("#st_carb_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
2016
2017 $("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 });
2018 $("#mash_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 8, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 });
2019 $("#tgt_mash_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 1, readOnly: true });
2020 $("#sparge_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 70, max: 98, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 });
2021
702 $("#est_mash_sg").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 3 }); 2022 $("#est_mash_sg").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 3 });
2023
2024 // Several gauges
2025 $("#hop_flavour").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true });
2026 $("#hop_aroma").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true });
2027 $("#perc_malts").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true });
2028 $("#perc_sugars").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true });
2029 $("#perc_cara").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true });
2030
2031 // Water treatment
2032 $("#w1_name").jqxDropDownList({
2033 placeHolder: "Kies hoofd water:",
2034 theme: theme,
2035 source: waterlist,
2036 displayMember: "name",
2037 width: 250,
2038 height: 27,
2039 dropDownWidth: 400,
2040 dropDownHeight: 400
2041 });
2042 $("#w1_name").on('select', function (event) {
2043 if (event.args) {
2044 var index = event.args.index;
2045 var datarecord = waterlist.records[index];
2046 dataRecord.w1_name = datarecord.name;
2047 $("#w1_calcium").val(datarecord.calcium);
2048 dataRecord.w1_calcium = datarecord.calcium;
2049 $("#w1_sulfate").val(datarecord.sulfate);
2050 dataRecord.w1_sulfate = datarecord.sulfate;
2051 $("#w1_chloride").val(datarecord.chloride);
2052 dataRecord.w1_chloride = datarecord.chloride;
2053 $("#w1_sodium").val(datarecord.sodium);
2054 dataRecord.w1_sodium = datarecord.sodium;
2055 $("#w1_magnesium").val(datarecord.magnesium);
2056 dataRecord.w1_magnesium = datarecord.magnesium;
2057 $("#w1_total_alkalinity").val(datarecord.total_alkalinity);
2058 dataRecord.w1_total_alkalinity = datarecord.total_alkalinity;
2059 $("#w1_ph").val(datarecord.ph);
2060 dataRecord.w1_ph = datarecord.ph;
2061 $("#w1_cost").val(datarecord.cost);
2062 dataRecord.w1_cost = datarecord.cost;
2063 calcWater();
2064 }
2065 });
2066 $("#w1_amount").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2067 $("#w1_calcium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2068 $("#w1_magnesium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2069 $("#w1_sodium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2070 $("#w1_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2071 $("#w1_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2072 $("#w1_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2073 $("#w1_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2074
2075 $("#w2_name").jqxDropDownList({
2076 placeHolder: "Kies meng water:",
2077 theme: theme,
2078 source: waterlist,
2079 displayMember: "name",
2080 width: 250,
2081 height: 27,
2082 dropDownWidth: 400,
2083 dropDownHeight: 400
2084 });
2085 $("#w2_name").on('select', function (event) {
2086 if (event.args) {
2087 var index = event.args.index;
2088 var datarecord = waterlist.records[index];
2089 dataRecord.w2_name = datarecord.name;
2090 $("#w2_calcium").val(datarecord.calcium);
2091 dataRecord.w2_calcium = datarecord.calcium;
2092 $("#w2_sulfate").val(datarecord.sulfate);
2093 dataRecord.w2_sulfate = datarecord.sulfate;
2094 $("#w2_chloride").val(datarecord.chloride);
2095 dataRecord.w2_chloride = datarecord.chloride;
2096 $("#w2_sodium").val(datarecord.sodium);
2097 dataRecord.w2_sodium = datarecord.sodium;
2098 $("#w2_magnesium").val(datarecord.magnesium);
2099 dataRecord.w2_magnesium = datarecord.magnesium;
2100 $("#w2_total_alkalinity").val(datarecord.total_alkalinity);
2101 dataRecord.w2_total_alkalinity = datarecord.total_alkalinity;
2102 $("#w2_ph").val(datarecord.ph);
2103 dataRecord.w2_ph = datarecord.ph;
2104 $("#w2_cost").val(datarecord.cost);
2105 dataRecord.w2_cost = datarecord.cost;
2106 $("#w2_amount").jqxNumberInput({ max: 100000, readOnly: false }); // Set high max to enable the spinbuttons.
2107 calcWater();
2108 }
2109 });
2110 $("#w2_amount").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 94, height: 23, min: 0, max: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5, readOnly: true });
2111 $("#w2_calcium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2112 $("#w2_magnesium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2113 $("#w2_sodium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2114 $("#w2_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2115 $("#w2_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2116 $("#w2_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2117 $("#w2_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2118
2119 $("#wg_amount").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2120 $("#wg_calcium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2121 $("#wg_magnesium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2122 $("#wg_sodium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2123 $("#wg_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2124 $("#wg_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2125 $("#wg_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2126 $("#wg_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2127 $("#wb_calcium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2128 $("#wb_magnesium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2129 $("#wb_sodium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2130 $("#wb_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2131 $("#wb_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2132 $("#wb_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2133 $("#wb_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2134
2135 $("#pr_name").jqxDropDownList({
2136 placeHolder: "Kies doel profiel:",
2137 theme: theme,
2138 source: waterprofiles,
2139 displayMember: "name",
2140 width: 250,
2141 height: 27,
2142 dropDownWidth: 400,
2143 dropDownHeight: 300
2144 });
2145 $("#pr_name").on('select', function (event) {
2146 if (event.args) {
2147 var index = event.args.index;
2148 var datarecord = waterprofiles.records[index];
2149 $("#pr_calcium").val(datarecord.calcium);
2150 $("#pr_sulfate").val(datarecord.sulfate);
2151 $("#pr_chloride").val(datarecord.chloride);
2152 $("#pr_sodium").val(datarecord.sodium);
2153 $("#pr_magnesium").val(datarecord.magnesium);
2154 $("#pr_total_alkalinity").val(datarecord.total_alkalinity);
2155 }
2156 });
2157 $("#pr_calcium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2158 $("#pr_magnesium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2159 $("#pr_sodium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2160 $("#pr_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2161 $("#pr_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2162 $("#pr_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
2163 $("#wa_cacl2").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' });
2164 $("#wa_caso4").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' });
2165 $("#wa_mgso4").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' });
2166 $("#wa_nacl").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' });
2167
2168 $("#calc_acid").jqxCheckBox({ theme: theme, width: 120, height: 23 });
2169 $("#wa_base_name").jqxDropDownList({ theme: theme, source: srcBase, width: 125, height: 23, dropDownHeight: 128 });
2170 $("#wa_base").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.05, symbol: ' gr', symbolPosition: 'right' });
2171 $("#wa_acid_name").jqxDropDownList({ theme: theme, source: srcAcid, width: 125, height: 23, dropDownHeight: 128 })
2172 $("#wa_acid").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.05, symbol: ' ml', symbolPosition: 'right' });
2173 $("#wa_acid_perc").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 80, height: 23, min: 0, max: 100, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' });
2174
2175 $("#sparge_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 });
2176 $("#sparge_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 });
2177 $("#sparge_acid_amount").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 5, readOnly: true });
703 2178
704 $('#jqxTabs').jqxTabs({ 2179 $('#jqxTabs').jqxTabs({
705 theme: theme, 2180 theme: theme,
706 width: 1280, 2181 width: 1280,
707 height: 630, 2182 height: 630,
708 autoHeight: false, 2183 autoHeight: false,
709 position: 'top' 2184 position: 'top'
710 }); 2185 });
711 2186
712 // Buttons sidebar
713 $("#rec_edit").jqxButton({ template: "primary", width: '140px', theme: theme });
714 $("#brew_log").jqxButton({ template: "primary", width: '140px', theme: theme });
715 $("#ferment_log").jqxButton({ template: "primary", width: '140px', theme: theme });
716
717 // Buttons below 2187 // Buttons below
718 $("#Delete").jqxButton({ template: "danger", width: '80px', theme: theme }); 2188 $("#Delete").jqxButton({ template: "danger", width: '80px', theme: theme });
719 $("#Delete").click(function () { 2189 $("#Delete").click(function () {
720 // Open a popup to confirm this action. 2190 // Open a popup to confirm this action.
721 $('#eventWindow').jqxWindow('open'); 2191 $('#eventWindow').jqxWindow('open');
722 $("#delOk").click(function () { 2192 $("#delOk").click(function () {
723 var data = "delete=true&" + $.param({ uuid: dataRecord.puuid }); 2193 var data = "delete=true&" + $.param({ uuid: dataRecord.uuid });
724 $.ajax({ 2194 $.ajax({
725 dataType: 'json', 2195 dataType: 'json',
726 url: url, 2196 url: url,
727 cache: false, 2197 cache: false,
728 data: data, 2198 data: data,
742 window.location.href = my_return; 2212 window.location.href = my_return;
743 }); 2213 });
744 2214
745 $("#Save").jqxButton({ template: "success", width: '90px', theme: theme }); 2215 $("#Save").jqxButton({ template: "success", width: '90px', theme: theme });
746 $("#Save").click(function () { 2216 $("#Save").click(function () {
747 console.log(dataRecord.puuid); 2217 console.log(dataRecord.uuid);
748 2218 var fermentablerow = $('#fermentableGrid').jqxGrid('getrows');
2219 var hoprow = $('#hopGrid').jqxGrid('getrows');
2220 var miscrow = $('#miscGrid').jqxGrid('getrows');
2221 var yeastrow = $('#yeastGrid').jqxGrid('getrows');
2222 var mashrow = $('#mashGrid').jqxGrid('getrows');
749 var row = { 2223 var row = {
750 record: my_record, 2224 record: my_record,
751 puuid: dataRecord.puuid, 2225 uuid: dataRecord.uuid,
752 pname: $("#pname").val(), 2226 name: $("#name").val(),
753 code: $("#code").val(), 2227 code: $("#code").val(),
754 birth: $("#birth").val(), 2228 birth: $("#birth").val(),
755 stage: $("#stage").val(), 2229 stage: $("#stage").val(),
756 pnotes: $("#pnotes").val(), 2230 notes: $("#notes").val(),
757 log_brew: $("#log_brew").val(), 2231 log_brew: $("#log_brew").val(),
758 log_fermentation: $("#log_fermentation").val(), 2232 log_fermentation: $("#log_fermentation").val(),
759 inventory_reduced: $("#inventory_reduced").val(), 2233 inventory_reduced: $("#inventory_reduced").val(),
760 plocked: $("#plocked").val(), 2234 locked: $("#locked").val(),
761 eq_name: $("#eq_name").val(), 2235 eq_name: $("#eq_name").val(),
762 eq_boil_size: parseFloat($("#eq_boil_size").jqxNumberInput('decimal')), 2236 eq_boil_size: parseFloat($("#eq_boil_size").jqxNumberInput('decimal')),
763 eq_batch_size: parseFloat($("#eq_batch_size").jqxNumberInput('decimal')), 2237 eq_batch_size: parseFloat($("#eq_batch_size").jqxNumberInput('decimal')),
764 eq_tun_volume: parseFloat($("#eq_tun_volume").jqxNumberInput('decimal')), 2238 eq_tun_volume: parseFloat($("#eq_tun_volume").jqxNumberInput('decimal')),
765 eq_tun_weight: dataRecord.eq_tun_weight, 2239 eq_tun_weight: dataRecord.eq_tun_weight,
779 eq_lauter_deadspace: parseFloat($("#eq_lauter_deadspace").jqxNumberInput('decimal')), 2253 eq_lauter_deadspace: parseFloat($("#eq_lauter_deadspace").jqxNumberInput('decimal')),
780 eq_kettle_volume: parseFloat($("#eq_kettle_volume").jqxNumberInput('decimal')), 2254 eq_kettle_volume: parseFloat($("#eq_kettle_volume").jqxNumberInput('decimal')),
781 eq_kettle_height: dataRecord.eq_kettle_height, 2255 eq_kettle_height: dataRecord.eq_kettle_height,
782 eq_mash_volume: parseFloat($("#eq_mash_volume").jqxNumberInput('decimal')), 2256 eq_mash_volume: parseFloat($("#eq_mash_volume").jqxNumberInput('decimal')),
783 eq_mash_max: parseFloat($("#eq_mash_max").jqxNumberInput('decimal')), 2257 eq_mash_max: parseFloat($("#eq_mash_max").jqxNumberInput('decimal')),
784 eq_efficiency: parseFloat($("#eq_efficiency").jqxNumberInput('decimal')) 2258 eq_efficiency: parseFloat($("#eq_efficiency").jqxNumberInput('decimal')),
2259 // st_name: $('#st_name').val(),
2260 // st_letter: $('#st_letter').val(),
2261 // st_guide: $('#st_guide').val(),
2262 // st_type: $('#st_type').val(),
2263 // st_category: $('#st_category').val(),
2264 // st_category_number: parseFloat($("#st_category_number").jqxNumberInput('decimal')),
2265 st_og_min: parseFloat($("#st_og_min").jqxNumberInput('decimal')),
2266 st_og_max: parseFloat($("#st_og_max").jqxNumberInput('decimal')),
2267 st_fg_min: parseFloat($("#st_fg_min").jqxNumberInput('decimal')),
2268 st_fg_max: parseFloat($("#st_fg_max").jqxNumberInput('decimal')),
2269 st_ibu_min: parseFloat($("#st_ibu_min").jqxNumberInput('decimal')),
2270 st_ibu_max: parseFloat($("#st_ibu_max").jqxNumberInput('decimal')),
2271 st_color_min: parseFloat($("#st_color_min").jqxNumberInput('decimal')),
2272 st_color_max: parseFloat($("#st_color_max").jqxNumberInput('decimal')),
2273 st_carb_min: parseFloat($("#st_carb_min").jqxNumberInput('decimal')),
2274 st_carb_max: parseFloat($("#st_carb_max").jqxNumberInput('decimal')),
2275 st_abv_min: parseFloat($("#st_abv_min").jqxNumberInput('decimal')),
2276 st_abv_max: parseFloat($("#st_abv_max").jqxNumberInput('decimal')),
2277 type: $("#type").val(),
2278 batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')),
2279 boil_size: parseFloat($("#boil_size").jqxNumberInput('decimal')),
2280 boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')),
2281 efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')),
2282 est_og: parseFloat($("#est_og").jqxNumberInput('decimal')),
2283 est_fg: parseFloat($("#est_fg").jqxNumberInput('decimal')),
2284 est_abv: parseFloat($("#est_abv").jqxNumberInput('decimal')),
2285 est_color: parseFloat($("#est_color").jqxNumberInput('decimal')),
2286 color_method: $("#color_method").val(),
2287 est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')),
2288 ibu_method: $("#ibu_method").val(),
2289 est_carb: parseFloat($("#est_carb").jqxNumberInput('decimal')),
2290 mash_name: $("#mash_name").val(),
2291 mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal')),
2292 sparge_temp: parseFloat($("#sparge_temp").jqxNumberInput('decimal')),
2293 sparge_ph: parseFloat($("#sparge_ph").jqxNumberInput('decimal')),
2294 sparge_volume: parseFloat($("#sparge_volume").jqxNumberInput('decimal')),
2295 // sparge_acid_type: $("#sparge_acid_type").val(),
2296 // sparge_acid_perc: parseFloat($("#sparge_acid_perc").jqxNumberInput('decimal')),
2297 // sparge_acid_amount: parseFloat($("#sparge_acid_amount").jqxNumberInput('decimal')),
2298 calc_acid: $("#calc_acid").val(),
2299 w1_name: $("#w1_name").val(),
2300 w1_amount: parseFloat($("#w1_amount").jqxNumberInput('decimal')),
2301 w1_calcium: parseFloat($("#w1_calcium").jqxNumberInput('decimal')),
2302 w1_sulfate: parseFloat($("#w1_sulfate").jqxNumberInput('decimal')),
2303 w1_chloride: parseFloat($("#w1_chloride").jqxNumberInput('decimal')),
2304 w1_sodium: parseFloat($("#w1_sodium").jqxNumberInput('decimal')),
2305 w1_magnesium: parseFloat($("#w1_magnesium").jqxNumberInput('decimal')),
2306 w1_total_alkalinity: parseFloat($("#w1_total_alkalinity").jqxNumberInput('decimal')),
2307 w1_ph: parseFloat($("#w1_ph").jqxNumberInput('decimal')),
2308 w1_cost: dataRecord.w1_cost,
2309 w2_name: $("#w2_name").val(),
2310 w2_amount: parseFloat($("#w2_amount").jqxNumberInput('decimal')),
2311 w2_calcium: parseFloat($("#w2_calcium").jqxNumberInput('decimal')),
2312 w2_sulfate: parseFloat($("#w2_sulfate").jqxNumberInput('decimal')),
2313 w2_chloride: parseFloat($("#w2_chloride").jqxNumberInput('decimal')),
2314 w2_sodium: parseFloat($("#w2_sodium").jqxNumberInput('decimal')),
2315 w2_magnesium: parseFloat($("#w2_magnesium").jqxNumberInput('decimal')),
2316 w2_total_alkalinity: parseFloat($("#w2_total_alkalinity").jqxNumberInput('decimal')),
2317 w2_ph: parseFloat($("#w2_ph").jqxNumberInput('decimal')),
2318 w2_cost: dataRecord.w2_cost,
2319 fermentables: fermentablerow,
2320 hops: hoprow,
2321 miscs: miscrow,
2322 yeasts: yeastrow,
2323 mashs: mashrow
785 }; 2324 };
786 var data = "update=true&" + $.param(row); 2325 var data = "update=true&" + $.param(row);
787 $.ajax({ 2326 $.ajax({
788 dataType: 'json', 2327 dataType: 'json',
789 url: url, 2328 url: url,

mercurial