|
1 /***************************************************************************** |
|
2 * Copyright (C) 2018 |
|
3 * |
|
4 * Michiel Broek <mbroek at mbse dot eu> |
|
5 * |
|
6 * This file is part of BMS |
|
7 * |
|
8 * This is free software; you can redistribute it and/or modify it |
|
9 * under the terms of the GNU General Public License as published by the |
|
10 * Free Software Foundation; either version 2, or (at your option) any |
|
11 * later version. |
|
12 * |
|
13 * BrewCloud is distributed in the hope that it will be useful, but |
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16 * General Public License for more details. |
|
17 * |
|
18 * You should have received a copy of the GNU General Public License |
|
19 * along with ThermFerm; see the file COPYING. If not, write to the Free |
|
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
|
21 *****************************************************************************/ |
|
22 |
|
23 |
|
24 function createDelElements() { |
|
25 $('#eventWindow').jqxWindow({ |
|
26 theme: theme, |
|
27 position: { x: 490, y: 210 }, |
|
28 width: 300, |
|
29 height: 175, |
|
30 resizable: false, |
|
31 isModal: true, |
|
32 modalOpacity: 0.4, |
|
33 okButton: $('#delOk'), |
|
34 cancelButton: $('#delCancel'), |
|
35 initContent: function () { |
|
36 $('#delOk').jqxButton({ template: "danger", width: '65px', theme: theme }); |
|
37 $('#delCancel').jqxButton({ template: "success", width: '65px', theme: theme }); |
|
38 $('#delCancel').focus(); |
|
39 } |
|
40 }); |
|
41 $('#eventWindow').jqxWindow('hide'); |
|
42 } |
|
43 |
|
44 |
|
45 $(document).ready(function () { |
|
46 |
|
47 console.log("record:" + my_record + " return:" + my_return + " theme:" + theme); |
|
48 |
|
49 // $("#jqxNotification").jqxNotification({ width: "auto", position: "top-right", opacity: 0.9, |
|
50 // autoOpen: false, closeOnClick: true, autoClose: true, template: "info", blink: false, |
|
51 // icon: { width: 25, height: 25, url: '../../images/smiley.png', padding: 5 } |
|
52 // }); |
|
53 |
|
54 var dataReecord = {}; |
|
55 var url = "includes/db_recipes.php"; |
|
56 // tooltips |
|
57 $("#name").jqxTooltip({ content: 'De naam voor dit recept.' }); |
|
58 $("#notes").jqxTooltip({ content: 'De uitgebreide opmerkingen over dit recept.' }); |
|
59 $("#st_name").jqxTooltip({ content: 'De bierstijl naam voor dit recept.'}); |
|
60 $("#type").jqxTooltip({ content: 'Het brouw type van dit recept.' }); |
|
61 // prepare the data |
|
62 var source = { |
|
63 datatype: "json", |
|
64 cache: false, |
|
65 datafields: [ |
|
66 { name: 'record', type: 'number' }, |
|
67 { name: 'st_name', type: 'string' }, |
|
68 { name: 'st_letter', type: 'string' }, |
|
69 { name: 'st_guide', type: 'string' }, |
|
70 { name: 'st_og_min', type: 'float' }, |
|
71 { name: 'st_og_max', type: 'float' }, |
|
72 { name: 'st_fg_min', type: 'float' }, |
|
73 { name: 'st_fg_max', type: 'float' }, |
|
74 { name: 'st_ibu_min', type: 'float' }, |
|
75 { name: 'st_ibu_max', type: 'float' }, |
|
76 { name: 'st_color_min', type: 'float' }, |
|
77 { name: 'st_color_max', type: 'float' }, |
|
78 { name: 'st_carb_min', type: 'float' }, |
|
79 { name: 'st_carb_max', type: 'float' }, |
|
80 { name: 'st_abv_min', type: 'float' }, |
|
81 { name: 'st_abv_max', type: 'float' }, |
|
82 { name: 'name', type: 'string' }, |
|
83 { name: 'notes', type: 'string' }, |
|
84 { name: 'type', type: 'number' }, |
|
85 { name: 'batch_size', type: 'float' }, |
|
86 { name: 'boil_time', type: 'float' }, |
|
87 { name: 'efficiency', type: 'float' }, |
|
88 { name: 'est_og', type: 'float' }, |
|
89 { name: 'est_fg', type: 'float' }, |
|
90 { name: 'est_color', type: 'float' }, |
|
91 { name: 'color_method', type: 'string' }, |
|
92 { name: 'est_ibu', type: 'float' }, |
|
93 { name: 'ibu_method', type: 'string' }, |
|
94 { name: 'mash_sparge_temp', type: 'float' }, |
|
95 { name: 'mash_ph', type: 'float' }, |
|
96 { name: 'mash_name', type: 'string' }, |
|
97 { name: 'fermentables', type: 'string' }, |
|
98 { name: 'hops', type: 'string' }, |
|
99 { name: 'miscs', type: 'string' }, |
|
100 { name: 'yeasts', type: 'string' }, |
|
101 { name: 'waters', type: 'array' }, |
|
102 { name: 'mashs', type: 'string' } |
|
103 ], |
|
104 id: 'record', |
|
105 url: url |
|
106 }; |
|
107 // Load data and select one record. |
|
108 var dataAdapter = new $.jqx.dataAdapter(source, { |
|
109 loadComplete: function () { |
|
110 var records = dataAdapter.records; |
|
111 dataRecord = records[0]; |
|
112 $("#name").val(dataRecord.name); |
|
113 $("#notes").val(dataRecord.notes); |
|
114 $("#st_name").val(dataRecord.st_name); |
|
115 $("#st_letter").val(dataRecord.st_letter); |
|
116 $("#st_guide").val(dataRecord.st_guide); |
|
117 $("#type").val(dataRecord.type); |
|
118 $("#batch_size").val(dataRecord.batch_size); |
|
119 $("#boil_time").val(dataRecord.boil_time); |
|
120 $("#efficiency").val(dataRecord.efficiency); |
|
121 $("#est_og").val(dataRecord.est_og); |
|
122 $("#st_og_min").val(dataRecord.st_og_min); |
|
123 $("#st_og_max").val(dataRecord.st_og_max); |
|
124 $("#est_fg").val(dataRecord.est_fg); |
|
125 $("#est_color").val(dataRecord.est_color); |
|
126 $("#color_method").val(dataRecord.color_method); |
|
127 $("#est_ibu").val(dataRecord.est_ibu); |
|
128 $("#ibu_method").val(dataRecord.ibu_method); |
|
129 $("#mash_name").val(dataRecord.mash_name); |
|
130 $("#mash_ph").val(dataRecord.mash_ph); |
|
131 $("#mash_sparge_temp").val(dataRecord.mash_sparge_temp); |
|
132 editFermentable(dataRecord); |
|
133 editHop(dataRecord); |
|
134 editMisc(dataRecord); |
|
135 editYeast(dataRecord); |
|
136 editWater(dataRecord); |
|
137 editMash(dataRecord); |
|
138 }, |
|
139 loadError: function (jqXHR, status, error) { |
|
140 }, |
|
141 beforeLoadComplete: function (records) { |
|
142 var filteredRecords = []; |
|
143 for (var i = 0; i < records.length; i++) { |
|
144 if (records[i].record == my_record) { |
|
145 filteredRecords.push(records[i]); |
|
146 } |
|
147 } |
|
148 return filteredRecords; |
|
149 } |
|
150 }); |
|
151 dataAdapter.dataBind(); |
|
152 |
|
153 // Inline fermentables editor |
|
154 var editFermentable = function (data) { |
|
155 var fermentableSource = { |
|
156 localdata: data.fermentables, |
|
157 datatype: "local", |
|
158 datafields: [ |
|
159 { name: 'f_name', type: 'string' }, |
|
160 { name: 'f_origin', type: 'string' }, |
|
161 { name: 'f_supplier', type: 'string' }, |
|
162 { name: 'f_amount', type: 'float' }, |
|
163 { name: 'f_cost', type: 'float' }, |
|
164 { name: 'f_type', type: 'string' }, |
|
165 { name: 'f_yield', type: 'float' }, |
|
166 { name: 'f_color', type: 'float' }, |
|
167 { name: 'f_coarse_fine_diff', type: 'float' }, |
|
168 { name: 'f_moisture', type: 'float' }, |
|
169 { name: 'f_diastatic_power', type: 'float' }, |
|
170 { name: 'f_protein', type: 'float' }, |
|
171 { name: 'f_max_in_batch', type: 'float' }, |
|
172 { name: 'f_graintype', type: 'string' }, |
|
173 { name: 'f_added', type: 'string' }, |
|
174 { name: 'f_dissolved_protein', type: 'float' }, |
|
175 { name: 'f_recommend_mash', type: 'bool' }, |
|
176 { name: 'f_add_after_boil', type: 'bool' }, |
|
177 { name: 'f_adjust_to_total_100', type: 'bool' }, |
|
178 { name: 'f_percentage', type: 'float' }, |
|
179 { name: 'f_di_ph', type: 'float' } |
|
180 ], |
|
181 addrow: function (rowid, rowdata, position, commit) { |
|
182 commit(true); |
|
183 }, |
|
184 deleterow: function (rowid, commit) { |
|
185 commit(true); |
|
186 } |
|
187 }; |
|
188 var fermentableAdapter = new $.jqx.dataAdapter(fermentableSource); |
|
189 // dropdownlist datasource from inventory_fermentables |
|
190 var fermentableUrl = "getfermentablesources.php"; |
|
191 var fermentableInvSource = { |
|
192 datatype: "json", |
|
193 datafields: [ |
|
194 { name: 'record', type: 'number' }, |
|
195 { name: 'name', type: 'string' }, |
|
196 { name: 'type', type: 'string' }, |
|
197 { name: 'yield', type: 'float' }, |
|
198 { name: 'color', type: 'float' }, |
|
199 { name: 'add_after_boil', type: 'bool' }, |
|
200 { name: 'origin', type: 'string' }, |
|
201 { name: 'supplier', type: 'string' }, |
|
202 { name: 'coarse_fine_diff', type: 'float' }, |
|
203 { name: 'moisture', type: 'float' }, |
|
204 { name: 'diastatic_power', type: 'float' }, |
|
205 { name: 'protein', type: 'float' }, |
|
206 { name: 'max_in_batch', type: 'float' }, |
|
207 { name: 'recommend_mash', type: 'bool' }, |
|
208 { name: 'graintype', type: 'string' }, |
|
209 { name: 'di_ph', type: 'float' }, |
|
210 { name: 'inventory', type: 'float' }, |
|
211 { name: 'cost', type: 'float' } |
|
212 ], |
|
213 url: fermentableUrl, |
|
214 async: true |
|
215 }; |
|
216 var fermentablelist = new $.jqx.dataAdapter(fermentableInvSource); |
|
217 |
|
218 $("#fermentableGrid").jqxGrid({ |
|
219 width: 960, |
|
220 height: 400, |
|
221 source: fermentableAdapter, |
|
222 theme: theme, |
|
223 selectionmode: 'singlerow', |
|
224 editmode: 'selectedrow', |
|
225 editable: true, |
|
226 localization: getLocalization(), |
|
227 showtoolbar: true, |
|
228 rendertoolbar: function (toolbar) { |
|
229 var me = this; |
|
230 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
|
231 toolbar.append(container); |
|
232 container.append('<div style="float: left; margin-left: 165px;" id="faddrowbutton"></div>'); |
|
233 container.append('<input style="float: left; margin-left: 230px;" id="fdeleterowbutton" type="button" value="Verwijder mout" />'); |
|
234 // add fermentable from dropdownlist. |
|
235 $("#faddrowbutton").jqxDropDownList({ |
|
236 placeHolder: "Kies mout:", |
|
237 theme: theme, |
|
238 source: fermentablelist, |
|
239 displayMember: "name", |
|
240 width: 150, |
|
241 height: 27, |
|
242 dropDownWidth: 500, |
|
243 dropDownHeight: 500, |
|
244 renderer: function (index, label, value) { |
|
245 var datarecord = fermentablelist.records[index]; |
|
246 return datarecord.supplier+ " / " + datarecord.name + " (" + datarecord.color + " EBC)"; |
|
247 } |
|
248 }); |
|
249 $("#faddrowbutton").on('select', function (event) { |
|
250 if (event.args) { |
|
251 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; |
|
252 var index = event.args.index; |
|
253 var datarecord = fermentablelist.records[index]; |
|
254 var row = {}; |
|
255 row["f_name"] = datarecord.name; |
|
256 row["f_origin"] = datarecord.origin; |
|
257 row["f_supplier"] = datarecord.supplier; |
|
258 row["f_amount"] = 0; |
|
259 row["f_cost"] = datarecord.cost; |
|
260 row["f_type"] = datarecord.type; |
|
261 row["f_yield"] = datarecord.yield; |
|
262 row["f_color"] = datarecord.color; |
|
263 row["f_coarse_fine_diff"] = datarecord.coarse_fine_diff; |
|
264 row["f_moisture"] = datarecord.moisture; |
|
265 row["f_diastatic_power"] = datarecord.diastatic_power; |
|
266 row["f_protein"] = datarecord.protein; |
|
267 row["f_max_in_batch"] = datarecord.max_in_batch; |
|
268 row["f_graintype"] = datarecord.graintype; |
|
269 if (datarecord.type == "Sugar") { |
|
270 row["f_added"] = "Boil"; |
|
271 } else { |
|
272 row["f_added"] = "Mash"; |
|
273 } |
|
274 row["f_dissolved_protein"] = 0; |
|
275 row["f_recommend_mash"] = datarecord.recommend_mash; |
|
276 row["f_add_after_boil"] = datarecord.add_after_boil; |
|
277 if (rowscount == 0) { |
|
278 // The first fermentable |
|
279 row["f_adjust_to_total_100"] = 1; |
|
280 row["f_percentage"] = 100; |
|
281 } else { |
|
282 row["f_adjust_to_total_100"] = 0; |
|
283 row["f_percentage"] = 0; |
|
284 } |
|
285 row["f_di_ph"] = datarecord.di_ph; |
|
286 var commit = $("#fermentableGrid").jqxGrid('addrow', null, row); |
|
287 } |
|
288 }); |
|
289 |
|
290 // delete selected fermentable. |
|
291 // Precentage aanpassen basis mout. |
|
292 $("#fdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
|
293 $("#fdeleterowbutton").on('click', function () { |
|
294 var selectedrowindex = $("#fermentableGrid").jqxGrid('getselectedrowindex'); |
|
295 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; |
|
296 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
|
297 var id = $("#fermentableGrid").jqxGrid('getrowid', selectedrowindex); |
|
298 var commit = $("#fermentableGrid").jqxGrid('deleterow', id); |
|
299 } |
|
300 }); |
|
301 }, |
|
302 columns: [ |
|
303 { text: 'Mout/suiker', editable: false, datafield: 'f_name', |
|
304 cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties) { |
|
305 var rowData = $("#fermentableGrid").jqxGrid('getrowdata', row); |
|
306 return rowData.f_name + " (" + rowData.f_color + " EBC)"; |
|
307 } |
|
308 }, |
|
309 { text: 'Type', editable: false, width: 100, datafield: 'f_type' }, |
|
310 { text: 'Opbrengst', editable: false, datafield: 'f_yield', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
|
311 { text: 'Gewicht', datafield: 'f_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f3', |
|
312 columntype: 'numberinput', |
|
313 validation: function (cell, value) { |
|
314 // Maximum weight is the batch_size, just a simple check. |
|
315 var maxmout = parseFloat($("#batch_size").jqxNumberInput('decimal')); |
|
316 if (value < 0 || value > maxmout) { |
|
317 return { result: false, message: "Gewicht moet 0-"+maxmout+" zijn" }; |
|
318 } |
|
319 return true; |
|
320 }, |
|
321 initeditor: function (row, cellvalue, editor) { |
|
322 editor.jqxNumberInput({ decimalDigits: 3 }); |
|
323 } |
|
324 }, |
|
325 { text: 'Procent', datafield: 'f_percentage', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'p1', |
|
326 columntype: 'numberinput', |
|
327 validation: function (cell, value) { |
|
328 if (value < 0 || value > 100) { |
|
329 return { result: false, message: "Percentage moet 0-100 zijn" }; |
|
330 } |
|
331 return true; |
|
332 }, |
|
333 initeditor: function (row, cellvalue, editor) { |
|
334 editor.jqxNumberInput({ decimalDigits: 1 }); |
|
335 } |
|
336 }, |
|
337 { text: '100%', datafield: 'f_adjust_to_total_100', columntype: 'checkbox', width: 80 } |
|
338 ] |
|
339 }); |
|
340 $("#fermentableGrid").on('cellendedit', function (event) { |
|
341 $('#fermentableGrid').jqxGrid('sortby', 'f_amount', 'desc'); |
|
342 }); |
|
343 }; |
|
344 |
|
345 // Inline hops editor |
|
346 var editHop = function (data) { |
|
347 var hopSource = { |
|
348 localdata: data.hops, |
|
349 datatype: "local", |
|
350 cache: false, |
|
351 datafields: [ |
|
352 { name: 'h_name', type: 'string' }, |
|
353 { name: 'h_origin', type: 'string' }, |
|
354 { name: 'h_amount', type: 'float' }, |
|
355 { name: 'h_cost', type: 'float' }, |
|
356 { name: 'h_type', type: 'string' }, |
|
357 { name: 'h_form', type: 'string' }, |
|
358 { name: 'h_useat', type: 'string' }, |
|
359 { name: 'h_time', type: 'float' }, |
|
360 { name: 'h_alpha', type: 'float' }, |
|
361 { name: 'h_beta', type: 'float' }, |
|
362 { name: 'h_hsi', type: 'float' }, |
|
363 { name: 'h_humulene', type: 'float' }, |
|
364 { name: 'h_carophyllene', type: 'float' }, |
|
365 { name: 'h_cohumulone', type: 'float' }, |
|
366 { name: 'h_myrcene', type: 'float' }, |
|
367 { name: 'h_total_oil', type: 'float' } |
|
368 ], |
|
369 addrow: function (rowid, rowdata, position, commit) { |
|
370 commit(true); |
|
371 }, |
|
372 deleterow: function (rowid, commit) { |
|
373 commit(true); |
|
374 } |
|
375 }; |
|
376 var hopAdapter = new $.jqx.dataAdapter(hopSource); |
|
377 // dropdownlist datasource from inventory_hops |
|
378 var hopUrl = "gethopsources.php"; |
|
379 var hopInvSource = { |
|
380 datatype: "json", |
|
381 datafields: [ |
|
382 { name: 'record', type: 'number' }, |
|
383 { name: 'name', type: 'string' }, |
|
384 { name: 'origin', type: 'string' }, |
|
385 { name: 'type', type: 'string' }, |
|
386 { name: 'alpha', type: 'float' }, |
|
387 { name: 'beta', type: 'float' }, |
|
388 { name: 'humulene', type: 'float' }, |
|
389 { name: 'caryophyllene', type: 'float' }, |
|
390 { name: 'cohumulone', type: 'float' }, |
|
391 { name: 'myrcene', type: 'float' }, |
|
392 { name: 'hsi', type: 'float' }, |
|
393 { name: 'useat', type: 'string' }, |
|
394 { name: 'form', type: 'string' }, |
|
395 { name: 'total_oil', type: 'float' }, |
|
396 { name: 'cost', type: 'float' } |
|
397 ], |
|
398 url: hopUrl, |
|
399 async: true |
|
400 }; |
|
401 var hoplist = new $.jqx.dataAdapter(hopInvSource); |
|
402 |
|
403 $("#hopGrid").jqxGrid({ |
|
404 width: 960, |
|
405 height: 400, |
|
406 source: hopAdapter, |
|
407 theme: theme, |
|
408 selectionmode: 'singlerow', |
|
409 editmode: 'selectedrow', |
|
410 editable: true, |
|
411 localization: getLocalization(), |
|
412 showtoolbar: true, |
|
413 rendertoolbar: function (toolbar) { |
|
414 var me = this; |
|
415 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
|
416 toolbar.append(container); |
|
417 container.append('<div style="float: left; margin-left: 165px;" id="haddrowbutton"></div>'); |
|
418 container.append('<input style="float: left; margin-left: 230px;" id="hdeleterowbutton" type="button" value="Verwijder hop" />'); |
|
419 // add hop from dropdownlist. |
|
420 $("#haddrowbutton").jqxDropDownList({ |
|
421 placeHolder: "Kies hop:", |
|
422 theme: theme, |
|
423 source: hoplist, |
|
424 displayMember: "name", |
|
425 width: 150, |
|
426 height: 27, |
|
427 dropDownWidth: 300 |
|
428 }); |
|
429 $("#haddrowbutton").on('select', function (event) { |
|
430 if (event.args) { |
|
431 var index = event.args.index; |
|
432 var datarecord = hoplist.records[index]; |
|
433 var row = {}; |
|
434 row["h_name"] = datarecord.name; |
|
435 row["h_origin"] = datarecord.origin; |
|
436 row["h_amount"] = 0; |
|
437 row["h_cost"] = datarecord.cost; |
|
438 row["h_type"] = datarecord.type; |
|
439 row["h_form"] = datarecord.form; |
|
440 row["h_useat"] = datarecord.useat; |
|
441 row["h_time"] = 0; |
|
442 row["h_alpha"] = datarecord.alpha; |
|
443 row["h_beta"] = datarecord.beta; |
|
444 row["h_hsi"] = datarecord.hsi; |
|
445 row["h_humulene"] = datarecord.humulene; |
|
446 row["h_carophyllene"] = datarecord.carophyllene; |
|
447 row["h_cohumulone"] = datarecord.cohumulone; |
|
448 row["h_myrcene"] = datarecord.myrcene; |
|
449 row["h_total_oil"] = datarecord.total_oil; |
|
450 var commit = $("#hopGrid").jqxGrid('addrow', null, row); |
|
451 } |
|
452 }); |
|
453 |
|
454 // delete selected hop. |
|
455 $("#hdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
|
456 $("#hdeleterowbutton").on('click', function () { |
|
457 var selectedrowindex = $("#hopGrid").jqxGrid('getselectedrowindex'); |
|
458 var rowscount = $("#hopGrid").jqxGrid('getdatainformation').rowscount; |
|
459 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
|
460 var id = $("#hopGrid").jqxGrid('getrowid', selectedrowindex); |
|
461 var commit = $("#hopGrid").jqxGrid('deleterow', id); |
|
462 } |
|
463 }); |
|
464 }, |
|
465 columns: [ |
|
466 { text: 'Hop', editable: false, datafield: 'h_name' }, |
|
467 { text: 'Type', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_type' }, |
|
468 { text: 'Vorm', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_form' }, |
|
469 { text: 'Alpha', datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
|
470 { text: 'Gewicht', datafield: 'h_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f3', |
|
471 columntype: 'numberinput', |
|
472 validation: function (cell, value) { |
|
473 if (value < 0 || value > 100000000000 ) { |
|
474 return { result: false, message: "Volume moet 0-~ zijn" }; |
|
475 } |
|
476 return true; |
|
477 } |
|
478 }, |
|
479 { text: 'Gebruik', width: 110, align: 'center', cellsalign: 'center', datafield: 'h_useat' }, |
|
480 { text: 'Tijd', datafield: 'h_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0', |
|
481 columntype: 'numberinput', |
|
482 validation: function (cell, value) { |
|
483 if (value < 0 || value > 100000000000 ) { |
|
484 return { result: false, message: "De tijd moet 0-~ zijn" }; |
|
485 } |
|
486 return true; |
|
487 } // TODO: Only enable editing if Boil, else use fixed values. |
|
488 }, |
|
489 { text: 'IBU', editable: false, datafield: 'ibu', width: 80, align: 'right', |
|
490 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
|
491 var ibu = toIBU(rowdata.h_useat, |
|
492 rowdata.h_form, |
|
493 parseFloat($("#est_og").jqxNumberInput('decimal')), |
|
494 parseFloat($("#batch_size").jqxNumberInput('decimal')), |
|
495 parseFloat(rowdata.h_amount), |
|
496 parseFloat(rowdata.h_time), |
|
497 parseFloat(rowdata.h_alpha), |
|
498 $("#ibu_method").val() |
|
499 ); |
|
500 return "<div style='margin: 4px;' class='jqx-right-align'>" + dataAdapter.formatNumber(ibu, "f1") + "</div>"; |
|
501 } |
|
502 } |
|
503 ] |
|
504 }) |
|
505 }; |
|
506 |
|
507 // Inline miscs editor |
|
508 var editMisc = function (data) { |
|
509 var miscSource = { |
|
510 localdata: data.miscs, |
|
511 datatype: "local", |
|
512 cache: false, |
|
513 datafields: [ |
|
514 { name: 'm_name', type: 'string' }, |
|
515 { name: 'm_amount', type: 'float' }, |
|
516 { name: 'm_cost', type: 'float' }, |
|
517 { name: 'm_type', type: 'string' }, |
|
518 { name: 'm_use_use', type: 'string' }, |
|
519 { name: 'm_time', type: 'float' }, |
|
520 { name: 'm_amount_is_weight', type: 'bool' } |
|
521 ], |
|
522 addrow: function (rowid, rowdata, position, commit) { |
|
523 commit(true); |
|
524 }, |
|
525 deleterow: function (rowid, commit) { |
|
526 commit(true); |
|
527 } |
|
528 }; |
|
529 var miscAdapter = new $.jqx.dataAdapter(miscSource); |
|
530 // dropdownlist datasource from inventory_miscs |
|
531 var miscUrl = "getmiscsources.php"; |
|
532 var miscInvSource = { |
|
533 datatype: "json", |
|
534 datafields: [ |
|
535 { name: 'record', type: 'number' }, |
|
536 { name: 'name', type: 'string' }, |
|
537 { name: 'type', type: 'string' }, |
|
538 { name: 'use_use', type: 'string' }, |
|
539 { name: 'amount_is_weight', type: 'bool' }, |
|
540 { name: 'time', type: 'float' }, |
|
541 { name: 'cost', type: 'float' } |
|
542 ], |
|
543 url: miscUrl, |
|
544 async: true |
|
545 }; |
|
546 var misclist = new $.jqx.dataAdapter(miscInvSource); |
|
547 |
|
548 $("#miscGrid").jqxGrid({ |
|
549 width: 960, |
|
550 height: 400, |
|
551 source: miscAdapter, |
|
552 theme: theme, |
|
553 selectionmode: 'singlerow', |
|
554 editmode: 'selectedrow', |
|
555 editable: true, |
|
556 localization: getLocalization(), |
|
557 showtoolbar: true, |
|
558 rendertoolbar: function (toolbar) { |
|
559 var me = this; |
|
560 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
|
561 toolbar.append(container); |
|
562 container.append('<div style="float: left; margin-left: 165px;" id="maddrowbutton"></div>'); |
|
563 container.append('<input style="float: left; margin-left: 230px;" id="mdeleterowbutton" type="button" value="Verwijder ingredient" />'); |
|
564 // add misc from dropdownlist. |
|
565 $("#maddrowbutton").jqxDropDownList({ |
|
566 placeHolder: "Kies ingredient:", |
|
567 theme: theme, |
|
568 source: misclist, |
|
569 displayMember: "name", |
|
570 width: 150, |
|
571 height: 27, |
|
572 dropDownWidth: 300 |
|
573 }); |
|
574 $("#maddrowbutton").on('select', function (event) { |
|
575 if (event.args) { |
|
576 var index = event.args.index; |
|
577 var datarecord = misclist.records[index]; |
|
578 var row = {}; |
|
579 row["m_name"] = datarecord.name; |
|
580 row["m_amount"] = 0; |
|
581 row["m_cost"] = datarecord.cost; |
|
582 row["m_type"] = datarecord.type; |
|
583 row["m_use_use"] = datarecord.use_use; |
|
584 row["m_time"] = 0; |
|
585 row["m_amount_is_weight"] = datarecord.amount_is_weight; |
|
586 var commit = $("#miscGrid").jqxGrid('addrow', null, row); |
|
587 } |
|
588 }); |
|
589 // delete selected misc. |
|
590 $("#mdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
|
591 $("#mdeleterowbutton").on('click', function () { |
|
592 var selectedrowindex = $("#miscGrid").jqxGrid('getselectedrowindex'); |
|
593 var rowscount = $("#miscGrid").jqxGrid('getdatainformation').rowscount; |
|
594 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
|
595 var id = $("#miscGrid").jqxGrid('getrowid', selectedrowindex); |
|
596 var commit = $("#miscGrid").jqxGrid('deleterow', id); |
|
597 } |
|
598 }); |
|
599 }, |
|
600 columns: [ |
|
601 { text: 'Ingredient', editable: false, datafield: 'm_name' }, |
|
602 { text: 'Type', editable: false, width: 120, align: 'center', cellsalign: 'center', datafield: 'm_type' }, |
|
603 { text: 'Gebruik', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'm_use_use' }, |
|
604 { text: 'Gewicht', datafield: 'm_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f5', |
|
605 columntype: 'numberinput', |
|
606 validation: function (cell, value) { |
|
607 if (value < 0 || value > 100000000000 ) { |
|
608 return { result: false, message: "Volume moet 0-~ zijn" }; |
|
609 } |
|
610 return true; |
|
611 } |
|
612 }, |
|
613 { text: 'Tijd', datafield: 'm_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0', |
|
614 columntype: 'numberinput', |
|
615 validation: function (cell, value) { |
|
616 if (value < 0 || value > 100000000000 ) { |
|
617 return { result: false, message: "De tijd moet 0-~ zijn" }; |
|
618 } |
|
619 return true; |
|
620 } |
|
621 } |
|
622 ] |
|
623 }) |
|
624 }; |
|
625 |
|
626 // Inline yeasts editor |
|
627 var editYeast = function (data) { |
|
628 var yeastSource = { |
|
629 localdata: data.yeasts, |
|
630 datatype: "local", |
|
631 cache: false, |
|
632 datafields: [ |
|
633 { name: 'y_name', type: 'string' }, |
|
634 { name: 'y_laboratory', type: 'string' }, |
|
635 { name: 'y_product_id', type: 'string' }, |
|
636 { name: 'y_amount', type: 'float' }, |
|
637 { name: 'y_cost', type: 'float' }, |
|
638 { name: 'y_type', type: 'string' }, |
|
639 { name: 'y_form', type: 'string' }, |
|
640 { name: 'y_time', type: 'float' }, |
|
641 { name: 'y_min_temperature', type: 'float' }, |
|
642 { name: 'y_max_temperature', type: 'float' }, |
|
643 { name: 'y_attenuation', type: 'float' }, |
|
644 { name: 'y_amount_is_weight', type: 'bool' }, |
|
645 { name: 'y_use', type: 'string' } |
|
646 ], |
|
647 addrow: function (rowid, rowdata, position, commit) { |
|
648 commit(true); |
|
649 }, |
|
650 deleterow: function (rowid, commit) { |
|
651 commit(true); |
|
652 } |
|
653 }; |
|
654 var yeastAdapter = new $.jqx.dataAdapter(yeastSource); |
|
655 // dropdownlist datasource from inventory_yeasts |
|
656 var yeastUrl = "getyeastsources.php"; |
|
657 var yeastInvSource = { |
|
658 datatype: "json", |
|
659 datafields: [ |
|
660 { name: 'record', type: 'number' }, |
|
661 { name: 'name', type: 'string' }, |
|
662 { name: 'type', type: 'string' }, |
|
663 { name: 'form', type: 'string' }, |
|
664 { name: 'laboratory', type: 'string' }, |
|
665 { name: 'product_id', type: 'string' }, |
|
666 { name: 'min_temperature', type: 'float' }, |
|
667 { name: 'max_temperature', type: 'float' }, |
|
668 { name: 'attenuation', type: 'float' }, |
|
669 { name: 'cost', type: 'float' } |
|
670 ], |
|
671 url: yeastUrl, |
|
672 async: true |
|
673 }; |
|
674 var yeastlist = new $.jqx.dataAdapter(yeastInvSource); |
|
675 |
|
676 $("#yeastGrid").jqxGrid({ |
|
677 width: 1050, |
|
678 height: 300, |
|
679 source: yeastAdapter, |
|
680 theme: theme, |
|
681 selectionmode: 'singlerow', |
|
682 editmode: 'selectedrow', |
|
683 editable: true, |
|
684 localization: getLocalization(), |
|
685 showtoolbar: true, |
|
686 rendertoolbar: function (toolbar) { |
|
687 var me = this; |
|
688 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
|
689 toolbar.append(container); |
|
690 container.append('<div style="float: left; margin-left: 165px;" id="yaddrowbutton"></div>'); |
|
691 container.append('<input style="float: left; margin-left: 230px;" id="ydeleterowbutton" type="button" value="Verwijder gist" />'); |
|
692 // add yeast from dropdownlist. |
|
693 $("#yaddrowbutton").jqxDropDownList({ |
|
694 placeHolder: "Kies gist:", |
|
695 theme: theme, |
|
696 source: yeastlist, |
|
697 displayMember: "name", |
|
698 width: 150, |
|
699 height: 27, |
|
700 dropDownWidth: 300 |
|
701 }); |
|
702 $("#yaddrowbutton").on('select', function (event) { |
|
703 if (event.args) { |
|
704 var index = event.args.index; |
|
705 var datarecord = yeastlist.records[index]; |
|
706 var row = {}; |
|
707 row["y_name"] = datarecord.name; |
|
708 row["y_laboratory"] = datarecord.laboratory; |
|
709 row["y_product_id"] = datarecord.product_id; |
|
710 row["y_type"] = datarecord.type; |
|
711 row["y_form"] = datarecord.form; |
|
712 row["y_amount"] = 0; |
|
713 row["y_cost"] = datarecord.cost; |
|
714 row["y_use"] = "Primary"; |
|
715 row["y_time"] = 0; |
|
716 if (datarecord.form == "Dry") { |
|
717 row["y_amount_is_weight"] = 1; |
|
718 } else { |
|
719 row["y_amount_is_weight"] = 0; |
|
720 } |
|
721 row["y_min_temperature"] = datarecord.min_temperature; |
|
722 row["y_max_temperature"] = datarecord.max_temperature; |
|
723 row["y_attenuation"] = datarecord.attenuation; |
|
724 var commit = $("#yeastGrid").jqxGrid('addrow', null, row); |
|
725 } |
|
726 }); |
|
727 // delete selected yeast. |
|
728 $("#ydeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
|
729 $("#ydeleterowbutton").on('click', function () { |
|
730 var selectedrowindex = $("#yeastGrid").jqxGrid('getselectedrowindex'); |
|
731 var rowscount = $("#yeastGrid").jqxGrid('getdatainformation').rowscount; |
|
732 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
|
733 var id = $("#yeastGrid").jqxGrid('getrowid', selectedrowindex); |
|
734 var commit = $("#yeastGrid").jqxGrid('deleterow', id); |
|
735 } |
|
736 }); |
|
737 }, |
|
738 columns: [ |
|
739 { text: 'Gist', editable: false, datafield: 'y_name' }, |
|
740 { text: 'Laboratorium', editable: false, width: 150, datafield: 'y_laboratory' }, |
|
741 { text: 'Code', editable: false, width: 90, datafield: 'y_product_id' }, |
|
742 { text: 'Soort', editable: false, width: 80, align: 'center', cellsalign: 'center', datafield: 'y_form' }, |
|
743 { text: 'Min.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_min_temperature' }, |
|
744 { text: 'Max.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_max_temperature' }, |
|
745 { text: 'Attn.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_attenuation', cellsformat: 'f1' }, |
|
746 { text: 'Voor', editable: false, width: 80, align: 'center', cellsalign: 'center', datafield: 'y_use' }, |
|
747 { text: 'Hoeveel', datafield: 'y_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f5', |
|
748 columntype: 'numberinput', |
|
749 validation: function (cell, value) { |
|
750 if (value < 0 || value > 100000000000 ) { |
|
751 return { result: false, message: "Volume moet 0-~ zijn" }; |
|
752 } |
|
753 return true; |
|
754 } |
|
755 } |
|
756 ] |
|
757 }) |
|
758 }; |
|
759 |
|
760 // Inline waters editor |
|
761 var editWater = function (data) { |
|
762 var waterSource = { |
|
763 localdata: data.waters, |
|
764 datatype: "local", |
|
765 datafields: [ |
|
766 { name: 'w_name', type: 'string' }, |
|
767 { name: 'w_amount', type: 'float' }, |
|
768 { name: 'w_calcium', type: 'float' }, |
|
769 { name: 'w_sulfate', type: 'float' }, |
|
770 { name: 'w_chloride', type: 'float' }, |
|
771 { name: 'w_sodium', type: 'float' }, |
|
772 { name: 'w_magnesium', type: 'float' }, |
|
773 { name: 'w_ph', type: 'float' }, |
|
774 { name: 'w_total_alkalinity', type: 'float' }, |
|
775 { name: 'w_cost', type: 'float' }, |
|
776 { name: 'w_default_water', type: 'bool' } |
|
777 ], |
|
778 addrow: function (rowid, rowdata, position, commit) { |
|
779 commit(true); |
|
780 }, |
|
781 deleterow: function (rowid, commit) { |
|
782 commit(true); |
|
783 } |
|
784 }; |
|
785 var waterAdapter = new $.jqx.dataAdapter(waterSource); |
|
786 // dropdownlist datasource from inventory_waters |
|
787 var waterUrl = "getwatersources.php"; |
|
788 var waterInvSource = { |
|
789 datatype: "json", |
|
790 datafields: [ |
|
791 { name: 'record', type: 'number' }, |
|
792 { name: 'name', type: 'string' }, |
|
793 { name: 'unlimited_stock', type: 'bool' }, |
|
794 { name: 'calcium', type: 'float' }, |
|
795 { name: 'sulfate', type: 'float' }, |
|
796 { name: 'chloride', type: 'float' }, |
|
797 { name: 'sodium', type: 'float' }, |
|
798 { name: 'magnesium', type: 'float' }, |
|
799 { name: 'ph', type: 'float' }, |
|
800 { name: 'total_alkalinity', type: 'float' }, |
|
801 { name: 'cost', type: 'float' }, |
|
802 { name: 'default_water', type: 'bool' } |
|
803 ], |
|
804 url: waterUrl, |
|
805 async: true |
|
806 }; |
|
807 var waterlist = new $.jqx.dataAdapter(waterInvSource); |
|
808 |
|
809 $("#waterGrid").jqxGrid({ |
|
810 width: 960, |
|
811 height: 200, |
|
812 source: waterAdapter, |
|
813 theme: theme, |
|
814 selectionmode: 'singlerow', |
|
815 editmode: 'selectedrow', |
|
816 editable: true, |
|
817 localization: getLocalization(), |
|
818 showtoolbar: true, |
|
819 rendertoolbar: function (toolbar) { |
|
820 var me = this; |
|
821 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
|
822 toolbar.append(container); |
|
823 container.append('<div style="float: left; margin-left: 165px;" id="waddrowbutton"></div>'); |
|
824 container.append('<input style="float: left; margin-left: 230px;" id="wdeleterowbutton" type="button" value="Verwijder water" />'); |
|
825 // add water from dropdownlist. |
|
826 $("#waddrowbutton").jqxDropDownList({ |
|
827 placeHolder: "Kies water:", |
|
828 theme: theme, |
|
829 source: waterlist, |
|
830 displayMember: "name", |
|
831 width: 150, |
|
832 height: 27, |
|
833 dropDownWidth: 300 |
|
834 }); |
|
835 $("#waddrowbutton").on('select', function (event) { |
|
836 if (event.args) { |
|
837 var index = event.args.index; |
|
838 var datarecord = waterlist.records[index]; |
|
839 var row = {}; |
|
840 row["w_name"] = datarecord.name; |
|
841 row["w_amount"] = 0; |
|
842 row["w_calcium"] = datarecord.calcium; |
|
843 row["w_sulfate"] = datarecord.sulfate; |
|
844 row["w_chloride"] = datarecord.chloride; |
|
845 row["w_sodium"] = datarecord.sodium; |
|
846 row["w_magnesium"] = datarecord.magnesium; |
|
847 row["w_ph"] = datarecord.ph; |
|
848 row["w_total_alkalinity"] = datarecord.total_alkalinity; |
|
849 row["w_default_water"] = datarecord.default_water; |
|
850 row["w_cost"] = datarecord.cost; |
|
851 var commit = $("#waterGrid").jqxGrid('addrow', null, row); |
|
852 } |
|
853 }); |
|
854 |
|
855 // delete selected water. |
|
856 // Overgebleven waters in volume verhogen met het verwijderde water. |
|
857 $("#wdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
|
858 $("#wdeleterowbutton").on('click', function () { |
|
859 var selectedrowindex = $("#waterGrid").jqxGrid('getselectedrowindex'); |
|
860 var rowscount = $("#waterGrid").jqxGrid('getdatainformation').rowscount; |
|
861 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
|
862 var id = $("#waterGrid").jqxGrid('getrowid', selectedrowindex); |
|
863 var commit = $("#waterGrid").jqxGrid('deleterow', id); |
|
864 } |
|
865 }); |
|
866 }, |
|
867 columns: [ |
|
868 { text: 'Water bron', editable: false, datafield: 'w_name' }, |
|
869 { text: 'Volume', datafield: 'w_amount', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', |
|
870 columntype: 'numberinput', |
|
871 validation: function (cell, value) { |
|
872 if (value < 0 || value > 100000000000 ) { |
|
873 return { result: false, message: "Volume moet 0-~ zijn" }; |
|
874 } |
|
875 return true; |
|
876 } |
|
877 }, |
|
878 // TODO: validator test max is hoeveelheid maischwater. Dan water verdelen voor totaal. |
|
879 { text: 'Ca', editable: false, datafield: 'w_calcium', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
|
880 { text: 'Mg', editable: false, datafield: 'w_magnesium', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
|
881 { text: 'Na', editable: false, datafield: 'w_sodium', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
|
882 { text: 'Tot Alk', editable: false, datafield: 'w_total_alkalinity', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
|
883 { text: 'CaSO4', editable: false, datafield: 'w_sulfate', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
|
884 { text: 'Cl', editable: false, datafield: 'w_chloride', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
|
885 { text: 'pH', editable: false, datafield: 'w_ph', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' } |
|
886 ] |
|
887 }); |
|
888 }; // editWater = function (data) { |
|
889 |
|
890 // inline mash editor |
|
891 var editMash = function (data) { |
|
892 var generaterow = function () { |
|
893 var row = {}; |
|
894 row["step_name"] = "Stap 1"; |
|
895 row["step_type"] = "Infusion"; |
|
896 row["step_infuse_amount"] = 15; |
|
897 row["step_temp"] = 62.0; |
|
898 row['step_time'] = 20.0; |
|
899 row['ramp_time'] = 1.0; |
|
900 row['end_temp'] = 62.0; |
|
901 return row; |
|
902 } |
|
903 var mashSource = { |
|
904 localdata: data.mashs, |
|
905 datatype: "local", |
|
906 cache: false, |
|
907 datafields: [ |
|
908 { name: 'step_name', type: 'string' }, |
|
909 { name: 'step_type', type: 'string' }, |
|
910 { name: 'step_infuse_amount', type: 'float' }, |
|
911 { name: 'step_temp', type: 'float' }, |
|
912 { name: 'step_time', type: 'float' }, |
|
913 { name: 'ramp_time', type: 'float' }, |
|
914 { name: 'end_temp', type: 'float' } |
|
915 ], |
|
916 addrow: function (rowid, rowdata, position, commit) { |
|
917 commit(true); |
|
918 }, |
|
919 deleterow: function (rowid, commit) { |
|
920 commit(true); |
|
921 } |
|
922 }; |
|
923 var mashAdapter = new $.jqx.dataAdapter(mashSource); |
|
924 // dropdownlist datasource from profile_mash |
|
925 var mashUrl = "include/db_profile_mash.php"; |
|
926 var mashInvSource = { |
|
927 datatype: "json", |
|
928 datafields: [ |
|
929 { name: 'record', type: 'number' }, |
|
930 { name: 'name', type: 'string' }, |
|
931 { name: 'steps', type: 'array' } |
|
932 ], |
|
933 url: mashUrl, |
|
934 async: true |
|
935 }; |
|
936 var mashlist = new $.jqx.dataAdapter(mashInvSource); |
|
937 |
|
938 $("#mashGrid").jqxGrid({ |
|
939 width: 960, |
|
940 height: 400, |
|
941 source: mashAdapter, |
|
942 theme: theme, |
|
943 selectionmode: 'singlerow', |
|
944 editmode: 'selectedrow', |
|
945 editable: true, |
|
946 localization: getLocalization(), |
|
947 showtoolbar: true, |
|
948 rendertoolbar: function (toolbar) { |
|
949 var me = this; |
|
950 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
|
951 toolbar.append(container); |
|
952 container.append('<input style="float: left; margin-left: 165px;" id="saddrowbutton" type="button" value="Nieuwe stap" />'); |
|
953 container.append('<input style="float: left; margin-left: 230px;" id="sdeleterowbutton" type="button" value="Verwijder stap" />'); |
|
954 $("#saddrowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
|
955 $("#saddrowbutton").on('click', function () { |
|
956 var datarow = generaterow(); |
|
957 var commit = $("#mashGrid").jqxGrid('addrow', null, datarow); |
|
958 }); |
|
959 // delete selected yeast. |
|
960 $("#sdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
|
961 $("#sdeleterowbutton").on('click', function () { |
|
962 var selectedrowindex = $("#mashGrid").jqxGrid('getselectedrowindex'); |
|
963 var rowscount = $("#mashGrid").jqxGrid('getdatainformation').rowscount; |
|
964 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
|
965 var id = $("#mashGrid").jqxGrid('getrowid', selectedrowindex); |
|
966 var commit = $("#mashGrid").jqxGrid('deleterow', id); |
|
967 } |
|
968 }); |
|
969 }, |
|
970 columns: [ |
|
971 { text: 'Stap naam', datafield: 'step_name' }, |
|
972 { text: 'Stap type', datafield: 'step_type', width: 110, columntype: 'dropdownlist', |
|
973 createeditor: function (row, cellvalue, editor, celltext, cellwidth, cellheight) { |
|
974 var dataSource = [ "Infusion", "Temperature", "Decoction" ]; |
|
975 editor.jqxDropDownList({ source: dataSource, dropDownHeight: 105 }); |
|
976 } |
|
977 }, |
|
978 { text: 'Temperatuur', datafield: 'step_temp', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', |
|
979 validation: function (cell, value) { |
|
980 if (value < 35 || value > 80) { |
|
981 return { result: false, message: "De temperatuur moet tussen 35 en 80 zijn." }; |
|
982 } |
|
983 return true; |
|
984 } |
|
985 }, |
|
986 { text: 'Eind', datafield: 'end_temp', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', |
|
987 validation: function (cell, value) { |
|
988 if (value < 35 || value > 80) { |
|
989 return { result: false, message: "De temperatuur moet tussen 35 en 80 zijn." }; |
|
990 } |
|
991 return true; |
|
992 } |
|
993 }, |
|
994 { text: 'Tijd', datafield: 'step_time', width: 70, align: 'right', cellsalign: 'right', |
|
995 validation: function (cell, value) { |
|
996 if (value < 1 || value > 360) { |
|
997 return { result: false, message: "De tijd moet tussen 1 en 360 zijn." }; |
|
998 } |
|
999 return true; |
|
1000 } |
|
1001 }, |
|
1002 { text: 'Stap', datafield: 'ramp_time', width: 70, align: 'right', cellsalign: 'right', |
|
1003 validation: function (cell, value) { |
|
1004 if (value < 1 || value > 60) { |
|
1005 return { result: false, message: "De tijd moet tussen 1 en 60 zijn." }; |
|
1006 } |
|
1007 return true; |
|
1008 } |
|
1009 }, |
|
1010 { text: 'Infuse', datafield: 'step_infuse_amount', width: 70, align: 'right', cellsalign: 'right', |
|
1011 validation: function (cell, value) { |
|
1012 if (value < 0 || value > 60) { |
|
1013 return { result: false, message: "De waarde moet tussen 0 en 60 zijn." }; |
|
1014 } |
|
1015 return true; |
|
1016 } |
|
1017 } |
|
1018 ] |
|
1019 }); |
|
1020 $("#mashGrid").on('cellendedit', function (event) { |
|
1021 $('#mashGrid').jqxGrid('sortby', 'step_temp', 'asc'); |
|
1022 }); |
|
1023 }; |
|
1024 |
|
1025 // initialize the input fields. |
|
1026 var srcType = [ "All Grain", "Partial Mash", "Extract" ]; |
|
1027 var srcColor = [ "Morey", "Mosher", "Daniels" ]; |
|
1028 var srcIBU = [ "Tinseth", "Rager", "Garetz", "Daniels", "Mosher", "Noonan" ]; |
|
1029 $("#name").jqxInput({ theme: theme, width: 640, height: 23 }); |
|
1030 $("#notes").jqxInput({ theme: theme, width: 960, height: 200 }); |
|
1031 $("#st_name").jqxInput({ theme: theme, width: 250, height: 23 }); |
|
1032 $("#st_letter").jqxInput({ theme: theme, width: 100, height: 23 }); |
|
1033 $("#st_guide").jqxInput({ theme: theme, width: 250, height: 23 }); |
|
1034 $("#type").jqxDropDownList({ theme: theme, source: srcType, width: 125, height: 23, dropDownHeight: 95 }); |
|
1035 $("#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' }); |
|
1036 $("#boil_time").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', template: "success", theme: theme, width: 100, height: 23, min: 4, max: 360, decimalDigits: 0, spinButtons: true }); |
|
1037 $("#efficiency").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 40, max: 100, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
|
1038 $("#est_og").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 1, max: 1.9, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 }); |
|
1039 $("#st_og_min").jqxNumberInput({ disabled: true, inputMode: 'simple', width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
|
1040 $("#st_og_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
|
1041 $("#est_fg").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, min: 0.980, max: 1.040, decimalDigits: 3, readOnly: true }); |
|
1042 $("#est_color").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 1, max: 200, decimalDigits: 0, spinButtons: true }); |
|
1043 $("#color_method").jqxDropDownList({ theme: theme, source: srcColor, width: 125, height: 23, dropDownHeight: 95 }); |
|
1044 $("#est_ibu").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, max: 200, decimalDigits: 0, spinButtons: true }); |
|
1045 $("#ibu_method").jqxDropDownList({ theme: theme, source: srcIBU, width: 125, height: 23, dropDownHeight: 180 }); |
|
1046 $("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 }); |
|
1047 $("#mash_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 8, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); |
|
1048 $("#mash_sparge_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 70, max: 98, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); |
|
1049 |
|
1050 // Tabs inside the popup window. |
|
1051 $('#jqxTabs').jqxTabs({ |
|
1052 theme: theme, |
|
1053 width: 1280, |
|
1054 height: 630, |
|
1055 autoHeight: false, |
|
1056 position: 'top' |
|
1057 }); |
|
1058 |
|
1059 $("#Delete").jqxButton({ template: "danger", width: '80px', theme: theme }); |
|
1060 $("#Delete").click(function () { |
|
1061 // Open a popup to confirm this action. |
|
1062 $('#eventWindow').jqxWindow('open'); |
|
1063 $("#delOk").click(function () { |
|
1064 var data = "delete=true&" + $.param({ record: my_record }); |
|
1065 $.ajax({ |
|
1066 dataType: 'json', |
|
1067 url: url, |
|
1068 cache: false, |
|
1069 data: data, |
|
1070 type: "POST", |
|
1071 success: function (data, status, xhr) { |
|
1072 // delete command is executed. |
|
1073 window.location.href = my_return; |
|
1074 }, |
|
1075 error: function (jqXHR, textStatus, errorThrown) { |
|
1076 } |
|
1077 }); |
|
1078 }); |
|
1079 }); |
|
1080 |
|
1081 $("#Cancel").jqxButton({ template: "primary", width: '80px', theme: theme }); |
|
1082 $("#Cancel").click(function () { |
|
1083 window.location.href = my_return; |
|
1084 }); |
|
1085 |
|
1086 $("#Save").jqxButton({ template: "success", width: '90px', theme: theme }); |
|
1087 $("#Save").click(function () { |
|
1088 var fermentablerow = $('#fermentableGrid').jqxGrid('getrows'); |
|
1089 var hoprow = $('#hopGrid').jqxGrid('getrows'); |
|
1090 var miscrow = $('#miscGrid').jqxGrid('getrows'); |
|
1091 var yeastrow = $('#yeastGrid').jqxGrid('getrows'); |
|
1092 var waterrow = $('#waterGrid').jqxGrid('getrows'); |
|
1093 var mashrow = $('#mashGrid').jqxGrid('getrows'); |
|
1094 var row = { |
|
1095 record: my_record, |
|
1096 name: $("#name").val(), |
|
1097 notes: $("#notes").val(), |
|
1098 st_name: $('#st_name').val(), |
|
1099 st_letter: $('#st_letter').val(), |
|
1100 st_guide: $('#st_guide').val(), |
|
1101 st_og_min: dataRecord.st_og_min, |
|
1102 st_og_max: dataRecord.st_og_max, |
|
1103 st_fg_min: dataRecord.st_fg_min, |
|
1104 st_fg_max: dataRecord.st_fg_max, |
|
1105 st_ibu_min: dataRecord.st_ibu_min, |
|
1106 st_ibu_max: dataRecord.st_ibu_max, |
|
1107 st_color_min: dataRecord.st_color_min, |
|
1108 st_color_max: dataRecord.st_color_max, |
|
1109 st_carb_min: dataRecord.st_carb_min, |
|
1110 st_carb_max: dataRecord.st_carb_max, |
|
1111 st_abv_min: dataRecord.st_abv_min, |
|
1112 st_abv_max: dataRecord.st_abv_max, |
|
1113 type: $("#type").val(), |
|
1114 batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')), |
|
1115 boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')), |
|
1116 efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')), |
|
1117 est_og: parseFloat($("#est_og").jqxNumberInput('decimal')), |
|
1118 est_fg: parseFloat($("#est_fg").jqxNumberInput('decimal')), |
|
1119 est_color: parseFloat($("#est_color").jqxNumberInput('decimal')), |
|
1120 color_method: $("#color_method").val(), |
|
1121 est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')), |
|
1122 ibu_method: $("#ibu_method").val(), |
|
1123 mash_name: $("#mash_name").val(), |
|
1124 mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal')), |
|
1125 mash_sparge_temp: parseFloat($("#mash_sparge_temp").jqxNumberInput('decimal')), |
|
1126 fermentables: fermentablerow, |
|
1127 hops: hoprow, |
|
1128 miscs: miscrow, |
|
1129 yeasts: yeastrow, |
|
1130 waters: waterrow, |
|
1131 mashs: mashrow |
|
1132 }; |
|
1133 var data = "update=true&" + $.param(row); |
|
1134 $.ajax({ |
|
1135 dataType: 'json', |
|
1136 url: url, |
|
1137 cache: false, |
|
1138 data: data, |
|
1139 type: "POST", |
|
1140 success: function (data, status, xhr) { |
|
1141 // update command is executed. |
|
1142 window.location.href = my_return; |
|
1143 }, |
|
1144 error: function(jqXHR, textStatus, errorThrown) { |
|
1145 } |
|
1146 }); |
|
1147 }); |
|
1148 createDelElements(); |
|
1149 }); |
|
1150 |