1 /***************************************************************************** |
|
2 * Copyright (C) 2014-2022 |
|
3 * |
|
4 * Michiel Broek <mbroek at mbse dot eu> |
|
5 * |
|
6 * This file is part of Brewery Management System |
|
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 function calcTotal() { |
|
48 |
|
49 $('#totval').val(dataRecord.cost * dataRecord.inventory); |
|
50 if (dataRecord.form == 'Vloeibaar') { // Liquid |
|
51 $('#pmpt_cost').html('Prijs per pak:'); |
|
52 $('#pmpt_inventory').html('Voorraad pak(ken):'); |
|
53 $('#pmpt_cells').html('Miljard cellen per pak:'); |
|
54 $('#inventory').jqxNumberInput({ decimalDigits: 0 }); |
|
55 } else if (dataRecord.form == 'Droog' || dataRecord.form == 'Gedroogd') { // Dry |
|
56 $('#pmpt_cost').html('Prijs per kg:'); |
|
57 $('#pmpt_inventory').html('Voorraad gram:'); |
|
58 $('#pmpt_cells').html('Miljard cellen per gram:'); |
|
59 $('#inventory').jqxNumberInput({ decimalDigits: 1 }); |
|
60 } else { |
|
61 $('#pmpt_cost').html('Prijs per liter:'); |
|
62 $('#pmpt_inventory').html('Voorraad ml:'); |
|
63 $('#pmpt_cells').html('Miljard cellen per ml:'); |
|
64 $('#inventory').jqxNumberInput({ decimalDigits: 1 }); |
|
65 } |
|
66 } |
|
67 |
|
68 var dataRecord = {}, |
|
69 url = 'includes/db_inventory_yeasts.php', |
|
70 source = { |
|
71 datatype: 'json', |
|
72 cache: false, |
|
73 datafields: [ |
|
74 { name: 'record', type: 'number' }, |
|
75 { name: 'uuid', type: 'string' }, |
|
76 { name: 'name', type: 'string' }, |
|
77 { name: 'type', type: 'string' }, |
|
78 { name: 'form', type: 'string' }, |
|
79 { name: 'laboratory', type: 'string' }, |
|
80 { name: 'product_id', type: 'string' }, |
|
81 { name: 'min_temperature', type: 'float' }, |
|
82 { name: 'max_temperature', type: 'float' }, |
|
83 { name: 'flocculation', type: 'int' }, |
|
84 { name: 'attenuation', type: 'float' }, |
|
85 { name: 'notes', type: 'string' }, |
|
86 { name: 'best_for', type: 'string' }, |
|
87 { name: 'max_reuse', type: 'int' }, |
|
88 { name: 'inventory', type: 'float' }, |
|
89 { name: 'cost', type: 'float' }, |
|
90 { name: 'production_date', type: 'string' }, |
|
91 { name: 'tht_date', type: 'string' }, |
|
92 { name: 'cells', type: 'float' }, |
|
93 { name: 'tolerance', type: 'float' }, |
|
94 { name: 'sta1', type: 'int' }, |
|
95 { name: 'bacteria', type: 'int' }, |
|
96 { name: 'harvest_top', type: 'int' }, |
|
97 { name: 'harvest_time', type: 'int' }, |
|
98 { name: 'pitch_temperature', type: 'float' }, |
|
99 { name: 'pofpos', type: 'int' }, |
|
100 { name: 'zymocide', type: 'int' }, |
|
101 { name: 'gr_hl_lo', type: 'int' }, |
|
102 { name: 'sg_lo', type: 'float' }, |
|
103 { name: 'gr_hl_hi', type: 'int' }, |
|
104 { name: 'sg_hi', type: 'float' }, |
|
105 { name: 'short_desc', type: 'string' } |
|
106 ], |
|
107 id: 'record', |
|
108 url: url, |
|
109 deleterow: function(rowid, commit) { |
|
110 // synchronize with the server - send delete command |
|
111 var data = 'delete=true&' + $.param({ record: rowid }); |
|
112 $.ajax({ |
|
113 dataType: 'json', |
|
114 url: url, |
|
115 cache: false, |
|
116 data: data, |
|
117 type: 'POST', |
|
118 success: function(data) { |
|
119 if (data.error) { |
|
120 console.log('delete: ' + data.msg); |
|
121 alert('Fout: ' + data.msg); |
|
122 } else { |
|
123 console.log('delete: success'); |
|
124 } |
|
125 location.reload(true); |
|
126 }, |
|
127 error: function(jqXHR, textStatus, errorThrown) { commit(false); } |
|
128 }); |
|
129 }, |
|
130 addrow: function(rowid, rowdata, position, commit) { |
|
131 var data = 'insert=true&' + $.param(rowdata); |
|
132 $.ajax({ |
|
133 dataType: 'json', |
|
134 url: url, |
|
135 cache: false, |
|
136 data: data, |
|
137 type: 'POST', |
|
138 success: function(data) { |
|
139 if (data.error) { |
|
140 console.log('insert: ' + data.msg); |
|
141 alert('Fout: ' + data.msg); |
|
142 } else { |
|
143 console.log('insert: success'); |
|
144 } |
|
145 location.reload(true); |
|
146 }, |
|
147 error: function(jqXHR, textStatus, errorThrown) { commit(false); } |
|
148 }); |
|
149 }, |
|
150 updaterow: function(rowid, rowdata, commit) { |
|
151 var data = 'update=true&' + $.param(rowdata); |
|
152 $.ajax({ |
|
153 dataType: 'json', |
|
154 url: url, |
|
155 cache: false, |
|
156 data: data, |
|
157 type: 'POST', |
|
158 success: function(data) { |
|
159 if (data.error) { |
|
160 console.log('updaterow: ' + data.msg); |
|
161 alert('Fout: ' + data.msg); |
|
162 } else { |
|
163 console.log('updaterow: success'); |
|
164 } |
|
165 location.reload(true); |
|
166 }, |
|
167 error: function(jqXHR, textStatus, errorThrown) { commit(false); } |
|
168 }); |
|
169 } |
|
170 }, |
|
171 dataAdapter = new $.jqx.dataAdapter(source), |
|
172 editrow = -1; |
|
173 |
|
174 // initialize the input fields. |
|
175 $('#name').jqxInput({ theme: theme, width: 640, height: 23 }); |
|
176 $('#laboratory').jqxInput({ theme: theme, width: 320, height: 23 }); |
|
177 $('#short_desc').jqxInput({ theme: theme, width: 320, height: 23 }); |
|
178 $('#product_id').jqxInput({ theme: theme, width: 320, height: 23 }); |
|
179 $('#type').jqxDropDownList({ |
|
180 theme: theme, |
|
181 source: YeastTypeAdapter, |
|
182 valueMember: 'nl', |
|
183 displayMember: 'nl', |
|
184 width: 180, |
|
185 height: 23, |
|
186 autoDropDownHeight: true |
|
187 }); |
|
188 $('#form').jqxDropDownList({ |
|
189 theme: theme, |
|
190 source: YeastFormAdapter, |
|
191 valueMember: 'nl', |
|
192 displayMember: 'nl', |
|
193 width: 180, |
|
194 height: 23, |
|
195 autoDropDownHeight: true |
|
196 }); |
|
197 $('#gr_hl_lo').jqxNumberInput(PosInt); |
|
198 $('#gr_hl_lo').jqxNumberInput({ min: 2, max: 400 }); |
|
199 $('#sg_lo').jqxNumberInput(SGopts); |
|
200 $('#gr_hl_hi').jqxNumberInput(PosInt); |
|
201 $('#gr_hl_hi').jqxNumberInput({ min: 5, max: 400 }); |
|
202 $('#sg_hi').jqxNumberInput(SGopts); |
|
203 $('#pitch_lo').jqxInput({ theme: theme, width: 100, height: 23 }); |
|
204 $('#but_pitch_lo').jqxButton({ template: 'success', width: '23px', height: 23, theme: theme }); |
|
205 $('#but_pitch_lo').bind('click', function() { $('#pitchloWindow').jqxWindow('open'); }); |
|
206 $('#pitchloReady').jqxButton({ template: 'success', width: '90px', theme: theme }); |
|
207 $('#pitchloReady').click(function() { |
|
208 $('#pitch_lo').val($('#gr_hl_lo').val() + '@' + $('#sg_lo').val().toFixed(3)); |
|
209 }); |
|
210 $('#pitch_hi').jqxInput({ theme: theme, width: 100, height: 23 }); |
|
211 $('#but_pitch_hi').jqxButton({ template: 'success', width: '23px', height: 23, theme: theme }); |
|
212 $('#but_pitch_hi').bind('click', function() { $('#pitchhiWindow').jqxWindow('open'); }); |
|
213 $('#pitchhiReady').jqxButton({ template: 'success', width: '90px', theme: theme }); |
|
214 $('#pitchhiReady').click(function() { |
|
215 $('#pitch_hi').val($('#gr_hl_hi').val() + '@' + $('#sg_hi').val().toFixed(3)); |
|
216 }); |
|
217 $('#notes').jqxInput({ theme: theme, width: 800, height: 120 }); |
|
218 $('#best_for').jqxInput({ theme: theme, width: 320, height: 100 }); |
|
219 $('#inventory').jqxNumberInput(Spin1dec); |
|
220 $('#production_date').jqxDateTimeInput(Dateopts); |
|
221 $('#min_temperature').jqxNumberInput(YeastT); |
|
222 $('#max_temperature').jqxNumberInput(YeastT); |
|
223 $('#flocculation').jqxDropDownList({ |
|
224 theme: theme, |
|
225 source: FlocculationAdapter, |
|
226 valueMember: 'id', |
|
227 displayMember: 'nl', |
|
228 width: 180, |
|
229 height: 23, |
|
230 autoDropDownHeight: true |
|
231 }); |
|
232 $('#attenuation').jqxNumberInput(Perc1dec); |
|
233 $('#max_reuse').jqxNumberInput(PosInt); |
|
234 $('#max_reuse').jqxNumberInput({ max: 10 }); |
|
235 $('#cost').jqxNumberInput(Spin2dec); |
|
236 $('#tht_date').jqxDateTimeInput(Dateopts); |
|
237 $('#totval').jqxNumberInput(Show2dec); |
|
238 $('#cells').jqxNumberInput(Spin1dec); |
|
239 $('#tolerance').jqxTooltip({ content: 'Alcohol tolerantie van de gist' }); |
|
240 $('#tolerance').jqxNumberInput(Perc1dec); |
|
241 $('#tolerance').jqxNumberInput({ max: 25 }); |
|
242 $('#sta1').jqxCheckBox({ theme: theme, width: 120, height: 23 }); |
|
243 // $('#sta1').jqxTooltip({ position: 'top-left', content: 'STA1 gen (var diastaticus), ook wel glucoamlylase+ genoemd.' }); |
|
244 $('#sta1').on('checked', function(event) { dataRecord.sta1 = 1; }); |
|
245 $('#sta1').on('unchecked', function(event) { dataRecord.sta1 = 0; }); |
|
246 $('#bacteria').jqxCheckBox({ theme: theme, width: 120, height: 23 }); |
|
247 $('#bacteria').on('checked', function(event) { dataRecord.bacteria = 1; }); |
|
248 $('#bacteria').on('unchecked', function(event) { dataRecord.bacteria = 0; }); |
|
249 $('#harvest_top').jqxCheckBox({ theme: theme, width: 120, height: 23 }); |
|
250 $('#harvest_top').on('checked', function(event) { dataRecord.harvest_top = 1; }); |
|
251 $('#harvest_top').on('unchecked', function(event) { dataRecord.harvest_top = 0; }); |
|
252 $('#harvest_time').jqxNumberInput(PosInt); |
|
253 $('#pitch_temperature').jqxNumberInput(YeastT); |
|
254 $('#pofpos').jqxCheckBox({ theme: theme, width: 120, height: 23 }); |
|
255 // $('#pofpos').jqxTooltip({ position: 'top-left', content: 'POF+ gist' }); |
|
256 $('#pofpos').on('checked', function(event) { dataRecord.pofpos = 1; }); |
|
257 $('#pofpos').on('unchecked', function(event) { dataRecord.pofpos = 0; }); |
|
258 $('#zymocide').jqxDropDownList({ |
|
259 theme: theme, |
|
260 source: ZymocideAdapter, |
|
261 valueMember: 'id', |
|
262 displayMember: 'nl', |
|
263 width: 80, |
|
264 height: 23, |
|
265 autoDropDownHeight: true |
|
266 }); |
|
267 |
|
268 var localizationobj = {}; |
|
269 localizationobj.filterchoosestring= "Keuze:"; |
|
270 |
|
271 // initialize jqxGrid |
|
272 $('#jqxgrid').jqxGrid({ |
|
273 width: 1280, |
|
274 height: 630, |
|
275 source: dataAdapter, |
|
276 theme: theme, |
|
277 showstatusbar: true, |
|
278 renderstatusbar: function(statusbar) { |
|
279 var rowCount = $("#jqxgrid").jqxGrid('getrows').length; |
|
280 statusbar.append('<div style="float: left; margin: 8px; color: orange !important;">Aantal items: ' + rowCount + '</div>'); |
|
281 var container, addButton, impButton; |
|
282 container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>'); |
|
283 addButton = $('<div style="float: right; margin-right: 15px;"><img style="position: relative; margin-top: 2px;" ' + |
|
284 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -4px;">Nieuw</span></div>'); |
|
285 impButton = $('<div style="float: right; margin-right: 50px;"><img style="position: relative; margin-top: 2px;" ' + |
|
286 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -4px;">Import</span></div>'); |
|
287 expButton = $('<div style="float: right; margin-right: 50px;"><img style="position: relative; margin-top: 2px;" ' + |
|
288 'src="images/database.png"/><span style="margin-left: 4px; position: relative; top: -10px;">Export</span></div>'); |
|
289 container.append(addButton); |
|
290 container.append(impButton); |
|
291 container.append(expButton); |
|
292 statusbar.append(container); |
|
293 addButton.jqxButton({ theme: theme, width: 90, height: 17 }); |
|
294 impButton.jqxButton({ theme: theme, width: 90, height: 17 }); |
|
295 expButton.jqxButton({ theme: theme, width: 90, height: 17 }); |
|
296 // add new row. |
|
297 addButton.click(function(event) { |
|
298 editrow = -1; |
|
299 $('#popupWindow').jqxWindow({ position: { x: 110, y: 30 } }); |
|
300 $('#name').val(''); |
|
301 dataRecord.uuid = ''; |
|
302 $('#laboratory').val(''); |
|
303 $('#short_desc').val(''); |
|
304 $('#product_id').val(''); |
|
305 $('#type').val('Bovengist'); |
|
306 $('#form').val('Vloeibaar'); |
|
307 $('#min_temperature').val(18); |
|
308 $('#max_temperature').val(22); |
|
309 $('#flocculation').val(0); |
|
310 $('#attenuation').val(77); |
|
311 $('#notes').val(''); |
|
312 $('#best_for').val(''); |
|
313 $('#max_reuse').val(10); |
|
314 $('#inventory').val(0); |
|
315 $('#cost').val(0); |
|
316 $('#production_date').val(''); |
|
317 $('#tht_date').val(''); |
|
318 $('#cells').val(1); |
|
319 $('#tolerance').val(0); |
|
320 $('#sta1').val(0); |
|
321 $('#bacteria').val(0); |
|
322 $('#harvest_top').val(0); |
|
323 $('#harvest_time').val(0); |
|
324 $('#pitch_temperature').val(0); |
|
325 $('#pofpos').val(0); |
|
326 $('#zymocide').val(0); |
|
327 $('#gr_hl_lo').val(50); |
|
328 $('#sg_lo').val(1.050); |
|
329 $('#gr_hl_hi').val(80); |
|
330 $('#sg_hi').val(1.080); |
|
331 $('#popupWindow').jqxWindow('open'); |
|
332 }); |
|
333 impButton.click(function(event) { |
|
334 window.location.href = 'import_ingredients.php?select=yeasts'; |
|
335 }); |
|
336 expButton.click(function(event) { |
|
337 window.open('export_yeasts.php'); |
|
338 }); |
|
339 }, |
|
340 ready: function () { |
|
341 $("#jqxgrid").jqxGrid('localizestrings', localizationobj); |
|
342 }, |
|
343 filterable: true, |
|
344 showfilterrow: true, |
|
345 columns: [ |
|
346 { text: 'Laboratorium', datafield: 'laboratory', width: 150, filtertype: 'list' }, |
|
347 { text: 'Product ID', datafield: 'product_id', width: 120, filtertype: 'textbox' }, |
|
348 { text: 'Gist naam', datafield: 'name', filtertype: 'textbox' }, |
|
349 { text: 'Type', datafield: 'type', align: 'center', cellsalign: 'center', width: 105, filtertype: 'list' }, |
|
350 { text: 'Vorm', datafield: 'form', align: 'center', cellsalign: 'center', width: 105, filtertype: 'list' }, |
|
351 { text: 'SVG', datafield: 'attenuation', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'p1', filtertype: 'number' }, |
|
352 { text: 'Tol%', datafield: 'tolerance', width: 60, align: 'right', cellsalign: 'right', filtertype: 'number', |
|
353 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
|
354 var amount = ''; |
|
355 if (value > 0) |
|
356 amount = dataAdapter.formatNumber(value, 'p1'); |
|
357 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + amount + '</span>'; |
|
358 } |
|
359 }, |
|
360 { text: 'POF+', datafield: 'pofpos', width: 60, align: 'center', cellsalign: 'center', |
|
361 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
|
362 if (value == 0) |
|
363 return '<span></span>'; |
|
364 return '<span><img style="float:left; margin-left:25px; margin-top:4px;" src="images/dialog-ok-apply.png"></span>'; |
|
365 } |
|
366 }, |
|
367 { text: 'STA1', datafield: 'sta1', width: 60, align: 'center', cellsalign: 'center', |
|
368 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
|
369 if (value == 0) |
|
370 return '<span></span>'; |
|
371 return '<span><img style="float:left; margin-left:25px; margin-top:4px;" src="images/dialog-ok-apply.png"></span>'; |
|
372 } |
|
373 }, |
|
374 { text: 'Voorraad', datafield: 'inventory', width: 100, align: 'right', filtertype: 'number', filtercondition: 'not_equal', |
|
375 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
|
376 var amount = ''; |
|
377 if (value > 0) { |
|
378 if ((rowdata.form == 'Vloeibaar') && (value > 1)) |
|
379 amount = dataAdapter.formatNumber(value, 'f0') + ' pakken'; |
|
380 else if (rowdata.form == 'Vloeibaar') |
|
381 amount = dataAdapter.formatNumber(value, 'f0') + ' pak'; |
|
382 else if (rowdata.form == 'Droog' || rowdata.form == 'Gedroogd') |
|
383 amount = dataAdapter.formatNumber(value * 1000, 'f1') + ' gram'; |
|
384 else |
|
385 amount = dataAdapter.formatNumber(value * 1000, 'f1') + ' ml'; |
|
386 } |
|
387 return '<span style="margin: 3px; margin-top: 6px; float: right;">' + amount + '</span>'; |
|
388 } |
|
389 }, |
|
390 { text: '', datafield: 'Edit', columntype: 'button', width: 80, align: 'center', filterable: false, cellsrenderer: function() { |
|
391 return 'Wijzig'; |
|
392 }, buttonclick: function(row) { |
|
393 // open the popup window when the user clicks a button. |
|
394 editrow = row; |
|
395 $('#popupWindow').jqxWindow({ position: { x: 110, y: 15 } }); |
|
396 // get the clicked row's data and initialize the input fields. |
|
397 dataRecord = $('#jqxgrid').jqxGrid('getrowdata', editrow); |
|
398 $('#name').val(dataRecord.name); |
|
399 $('#laboratory').val(dataRecord.laboratory); |
|
400 $('#product_id').val(dataRecord.product_id); |
|
401 $('#type').val(dataRecord.type); |
|
402 $('#form').val(dataRecord.form); |
|
403 $('#min_temperature').val(parseFloat(dataRecord.min_temperature)); |
|
404 $('#max_temperature').val(parseFloat(dataRecord.max_temperature)); |
|
405 $('#flocculation').val(dataRecord.flocculation); |
|
406 $('#attenuation').val(dataRecord.attenuation); |
|
407 $('#notes').val(dataRecord.notes); |
|
408 $('#best_for').val(dataRecord.best_for); |
|
409 $('#max_reuse').val(dataRecord.max_reuse); |
|
410 if (dataRecord.form == 'Vloeibaar') |
|
411 $('#inventory').val(dataRecord.inventory); |
|
412 else |
|
413 $('#inventory').val(dataRecord.inventory * 1000); |
|
414 $('#cost').val(dataRecord.cost); |
|
415 $('#production_date').val(dataRecord.production_date); |
|
416 $('#tht_date').val(dataRecord.tht_date); |
|
417 $('#cells').val(dataRecord.cells); |
|
418 $('#tolerance').val(dataRecord.tolerance); |
|
419 $('#sta1').val(dataRecord.sta1); |
|
420 $('#bacteria').val(dataRecord.bacteria); |
|
421 $('#harvest_top').val(dataRecord.harvest_top); |
|
422 $('#harvest_time').val(dataRecord.harvest_time); |
|
423 $('#pitch_temperature').val(parseFloat(dataRecord.pitch_temperature)); |
|
424 $('#pofpos').val(dataRecord.pofpos); |
|
425 $('#zymocide').val(dataRecord.zymocide); |
|
426 $('#gr_hl_lo').val(dataRecord.gr_hl_lo); |
|
427 $('#sg_lo').val(parseFloat(dataRecord.sg_lo)); |
|
428 $('#pitch_lo').val(dataRecord.gr_hl_lo + '@' + parseFloat(dataRecord.sg_lo).toFixed(3)); |
|
429 $('#gr_hl_hi').val(dataRecord.gr_hl_hi); |
|
430 $('#sg_hi').val(parseFloat(dataRecord.sg_hi)); |
|
431 $('#pitch_hi').val(dataRecord.gr_hl_hi + '@' + parseFloat(dataRecord.sg_hi).toFixed(3)); |
|
432 $('#short_desc').val(dataRecord.short_desc); |
|
433 if (dataRecord.form == 'Droog') { |
|
434 $('.yeast_wet').hide(); |
|
435 $('.yeast_dry').show(); |
|
436 } else { |
|
437 $('.yeast_wet').show(); |
|
438 $('.yeast_dry').hide(); |
|
439 } |
|
440 calcTotal(); |
|
441 // show the popup window. |
|
442 $('#popupWindow').jqxWindow('open'); |
|
443 } |
|
444 } |
|
445 ] |
|
446 }); |
|
447 |
|
448 $('#popupWindow').on('open', function(event) { calcTotal(); }); |
|
449 $('#cost').on('change', function(event) { |
|
450 dataRecord.cost = parseFloat(event.args.value); |
|
451 calcTotal(); |
|
452 }); |
|
453 $('#inventory').on('change', function(event) { |
|
454 if (dataRecord.form == 'Vloeibaar') |
|
455 dataRecord.inventory = parseFloat(event.args.value); |
|
456 else |
|
457 dataRecord.inventory = parseFloat(event.args.value) / 1000.0; |
|
458 calcTotal(); |
|
459 }); |
|
460 $('#form').on('select', function(event) { |
|
461 dataRecord.form = $('#form').val(); |
|
462 calcTotal(); |
|
463 if (dataRecord.form == 'Droog') { |
|
464 $('.yeast_wet').hide(); |
|
465 $('.yeast_dry').show(); |
|
466 } else { |
|
467 $('.yeast_wet').show(); |
|
468 $('.yeast_dry').hide(); |
|
469 } |
|
470 }); |
|
471 |
|
472 // initialize the popup window and buttons. |
|
473 $('#pitchloWindow').jqxWindow({ |
|
474 theme: theme, |
|
475 position: { x: 380, y: 210 }, |
|
476 width: 500, |
|
477 height: 200, |
|
478 resizable: false, |
|
479 isModal: true, |
|
480 modalOpacity: 0.4, |
|
481 autoOpen: false, |
|
482 cancelButton: $('#pitchloReady') |
|
483 }); |
|
484 $('#pitchhiWindow').jqxWindow({ |
|
485 theme: theme, |
|
486 position: { x: 380, y: 210 }, |
|
487 width: 500, |
|
488 height: 200, |
|
489 resizable: false, |
|
490 isModal: true, |
|
491 modalOpacity: 0.4, |
|
492 autoOpen: false, |
|
493 cancelButton: $('#pitchhiReady') |
|
494 }); |
|
495 $('#popupWindow').jqxWindow({ |
|
496 width: 1050, |
|
497 height: 625, |
|
498 resizable: false, |
|
499 theme: theme, |
|
500 isModal: true, |
|
501 autoOpen: false, |
|
502 cancelButton: $('#Cancel'), |
|
503 modalOpacity: 0.40 |
|
504 }); |
|
505 $('#popupWindow').on('open', function() { |
|
506 $('#name').jqxInput('selectAll'); |
|
507 }); |
|
508 $('#Delete').jqxButton({ template: 'danger', width: '90px', theme: theme }); |
|
509 $('#Delete').click(function() { |
|
510 if (editrow >= 0) { |
|
511 // Open a popup to confirm this action. |
|
512 $('#eventWindow').jqxWindow('open'); |
|
513 $('#delOk').click(function() { |
|
514 var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); |
|
515 $('#jqxgrid').jqxGrid('deleterow', rowID); |
|
516 }); |
|
517 } |
|
518 $('#popupWindow').jqxWindow('hide'); |
|
519 }); |
|
520 $('#Cancel').jqxButton({ template: 'primary', width: '90px', theme: theme }); |
|
521 $('#Clone').jqxButton({ template: 'warning', width: '90px', theme: theme }); |
|
522 $('#Clone').click(function() { |
|
523 var row = { |
|
524 record: -1, |
|
525 name: $('#name').val() + ' kopie', |
|
526 uuid: '', |
|
527 type: $('#type').val(), |
|
528 form: $('#form').val(), |
|
529 laboratory: $('#laboratory').val(), |
|
530 product_id: $('#product_id').val(), |
|
531 min_temperature: parseFloat($('#min_temperature').jqxNumberInput('decimal')), |
|
532 max_temperature: parseFloat($('#max_temperature').jqxNumberInput('decimal')), |
|
533 flocculation: $('#flocculation').val(), |
|
534 attenuation: parseFloat($('#attenuation').jqxNumberInput('decimal')), |
|
535 notes: $('#notes').val(), |
|
536 best_for: $('#best_for').val(), |
|
537 max_reuse: parseInt($('#max_reuse').jqxNumberInput('decimal')), |
|
538 inventory: 0, |
|
539 cost: parseFloat($('#cost').jqxNumberInput('decimal')), |
|
540 production_date: '', |
|
541 tht_date: '', |
|
542 cells: parseFloat($('#cells').jqxNumberInput('decimal')), |
|
543 tolerance: parseFloat($('#tolerance').jqxNumberInput('decimal')), |
|
544 sta1: $('#sta1').val(), |
|
545 bacteria: $('#bacteria').val(), |
|
546 harvest_top: $('#harvest_top').val(), |
|
547 harvest_time: $('#harvest_time').val(), |
|
548 pitch_temperature: parseFloat($('#pitch_temperature').jqxNumberInput('decimal')), |
|
549 pofpos: $('#pofpos').val(), |
|
550 zymocide: $('#zymocide').val(), |
|
551 gr_hl_lo: $('#gr_hl_lo').val(), |
|
552 sg_lo: parseFloat($('#sg_lo').jqxNumberInput('decimal')), |
|
553 gr_hl_hi: $('#gr_hl_hi').val(), |
|
554 sg_hi: parseFloat($('#sg_hi').jqxNumberInput('decimal')) |
|
555 }; |
|
556 $('#jqxgrid').jqxGrid('addrow', null, row); |
|
557 $('#popupWindow').jqxWindow('hide'); |
|
558 }); |
|
559 $('#Save').jqxButton({ template: 'success', width: '90px', theme: theme }); |
|
560 // update the edited row when the user clicks the 'Save' button. |
|
561 $('#Save').click(function() { |
|
562 var n_inventory, row, rowID = -1; |
|
563 if (editrow >= 0) { |
|
564 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); |
|
565 } |
|
566 if (dataRecord.form == 'Vloeibaar') |
|
567 n_inventory = parseFloat($('#inventory').jqxNumberInput('decimal')); |
|
568 else |
|
569 n_inventory = parseFloat($('#inventory').jqxNumberInput('decimal')) / 1000.0; |
|
570 row = { |
|
571 record: rowID, |
|
572 name: $('#name').val(), |
|
573 uuid: dataRecord.uuid, |
|
574 type: $('#type').val(), |
|
575 form: $('#form').val(), |
|
576 laboratory: $('#laboratory').val(), |
|
577 product_id: $('#product_id').val(), |
|
578 min_temperature: parseFloat($('#min_temperature').jqxNumberInput('decimal')), |
|
579 max_temperature: parseFloat($('#max_temperature').jqxNumberInput('decimal')), |
|
580 flocculation: $('#flocculation').val(), |
|
581 attenuation: parseFloat($('#attenuation').jqxNumberInput('decimal')), |
|
582 notes: $('#notes').val(), |
|
583 best_for: $('#best_for').val(), |
|
584 max_reuse: parseInt($('#max_reuse').jqxNumberInput('decimal')), |
|
585 inventory: n_inventory, |
|
586 cost: parseFloat($('#cost').jqxNumberInput('decimal')), |
|
587 production_date: $('#production_date').val(), |
|
588 tht_date: $('#tht_date').val(), |
|
589 cells: parseFloat($('#cells').jqxNumberInput('decimal')), |
|
590 tolerance: parseFloat($('#tolerance').jqxNumberInput('decimal')), |
|
591 sta1: $('#sta1').val(), |
|
592 bacteria: $('#bacteria').val(), |
|
593 harvest_top: $('#harvest_top').val(), |
|
594 harvest_time: $('#harvest_time').val(), |
|
595 pitch_temperature: parseFloat($('#pitch_temperature').jqxNumberInput('decimal')), |
|
596 pofpos: $('#pofpos').val(), |
|
597 zymocide: $('#zymocide').val(), |
|
598 gr_hl_lo: $('#gr_hl_lo').val(), |
|
599 sg_lo: parseFloat($('#sg_lo').jqxNumberInput('decimal')), |
|
600 gr_hl_hi: $('#gr_hl_hi').val(), |
|
601 sg_hi: parseFloat($('#sg_hi').jqxNumberInput('decimal')), |
|
602 short_desc: $('#short_desc').val() |
|
603 }; |
|
604 if (editrow >= 0) { |
|
605 $('#jqxgrid').jqxGrid('updaterow', rowID, row); |
|
606 } else { |
|
607 $('#jqxgrid').jqxGrid('addrow', null, row); |
|
608 } |
|
609 $('#popupWindow').jqxWindow('hide'); |
|
610 }); |
|
611 createDelElements(); |
|
612 }); |
|
613 |
|