www/js/inv_yeasts.js

changeset 528
202272a28052
parent 515
9d771385a8a0
child 563
acdd54144838
equal deleted inserted replaced
527:9dfefad3ae1d 528:202272a28052
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 *****************************************************************************/ 21 *****************************************************************************/
22 22
23 23
24 function createDelElements() { 24 function createDelElements() {
25 $('#eventWindow').jqxWindow({ 25 $('#eventWindow').jqxWindow({
26 theme: theme, 26 theme: theme,
27 position: { x: 490, y: 210 }, 27 position: { x: 490, y: 210 },
28 width: 300, 28 width: 300,
29 height: 175, 29 height: 175,
30 resizable: false, 30 resizable: false,
31 isModal: true, 31 isModal: true,
32 modalOpacity: 0.4, 32 modalOpacity: 0.4,
33 okButton: $('#delOk'), 33 okButton: $('#delOk'),
34 cancelButton: $('#delCancel'), 34 cancelButton: $('#delCancel'),
35 initContent: function () { 35 initContent: function() {
36 $('#delOk').jqxButton({ template: 'danger', width: '65px', theme: theme }); 36 $('#delOk').jqxButton({ template: 'danger', width: '65px', theme: theme });
37 $('#delCancel').jqxButton({ template: 'success', width: '65px', theme: theme }); 37 $('#delCancel').jqxButton({ template: 'success', width: '65px', theme: theme });
38 $('#delCancel').focus(); 38 $('#delCancel').focus();
39 } 39 }
40 }); 40 });
41 $('#eventWindow').jqxWindow('hide'); 41 $('#eventWindow').jqxWindow('hide');
42 } 42 }
43 43
44 44
45 $(document).ready(function() { 45 $(document).ready(function() {
46 46
47 function calcTotal() { 47 function calcTotal() {
48 48
49 $('#totval').val(dataRecord.cost * dataRecord.inventory); 49 $('#totval').val(dataRecord.cost * dataRecord.inventory);
50 if (dataRecord.form == 'Vloeibaar') { // Liquid 50 if (dataRecord.form == 'Vloeibaar') { // Liquid
51 $("#pmpt_cost").html('Prijs per pak:'); 51 $('#pmpt_cost').html('Prijs per pak:');
52 $("#pmpt_inventory").html('Voorraad pak(ken):'); 52 $('#pmpt_inventory').html('Voorraad pak(ken):');
53 $("#pmpt_cells").html('Miljard cellen per pak:'); 53 $('#pmpt_cells').html('Miljard cellen per pak:');
54 $("#inventory").jqxNumberInput({ decimalDigits: 0 }); 54 $('#inventory').jqxNumberInput({ decimalDigits: 0 });
55 } else if (dataRecord.form == 'Droog' || dataRecord.form == 'Gedroogd') { // Dry 55 } else if (dataRecord.form == 'Droog' || dataRecord.form == 'Gedroogd') { // Dry
56 $("#pmpt_cost").html('Prijs per kg:'); 56 $('#pmpt_cost').html('Prijs per kg:');
57 $("#pmpt_inventory").html('Voorraad gram:'); 57 $('#pmpt_inventory').html('Voorraad gram:');
58 $("#pmpt_cells").html('Miljard cellen per gram:'); 58 $('#pmpt_cells').html('Miljard cellen per gram:');
59 $("#inventory").jqxNumberInput({ decimalDigits: 1 }); 59 $('#inventory').jqxNumberInput({ decimalDigits: 1 });
60 } else { 60 } else {
61 $("#pmpt_cost").html('Prijs per liter:'); 61 $('#pmpt_cost').html('Prijs per liter:');
62 $("#pmpt_inventory").html('Voorraad ml:'); 62 $('#pmpt_inventory').html('Voorraad ml:');
63 $("#pmpt_cells").html('Miljard cellen per ml:'); 63 $('#pmpt_cells').html('Miljard cellen per ml:');
64 $("#inventory").jqxNumberInput({ decimalDigits: 1 }); 64 $('#inventory').jqxNumberInput({ decimalDigits: 1 });
65 } 65 }
66 } 66 }
67 67
68 var dataRecord = {}, 68 var dataRecord = {},
69 url = 'includes/db_inventory_yeasts.php', 69 url = 'includes/db_inventory_yeasts.php',
70 source = { 70 source = {
71 datatype: 'json', 71 datatype: 'json',
72 cache: false, 72 cache: false,
73 datafields: [ 73 datafields: [
74 { name: 'record', type: 'number' }, 74 { name: 'record', type: 'number' },
75 { name: 'name', type: 'string' }, 75 { name: 'name', type: 'string' },
76 { name: 'type', type: 'string' }, 76 { name: 'type', type: 'string' },
77 { name: 'form', type: 'string' }, 77 { name: 'form', type: 'string' },
78 { name: 'laboratory', type: 'string' }, 78 { name: 'laboratory', type: 'string' },
79 { name: 'product_id', type: 'string' }, 79 { name: 'product_id', type: 'string' },
80 { name: 'min_temperature', type: 'float' }, 80 { name: 'min_temperature', type: 'float' },
81 { name: 'max_temperature', type: 'float' }, 81 { name: 'max_temperature', type: 'float' },
82 { name: 'flocculation', type: 'int' }, 82 { name: 'flocculation', type: 'int' },
83 { name: 'attenuation', type: 'float' }, 83 { name: 'attenuation', type: 'float' },
84 { name: 'notes', type: 'string' }, 84 { name: 'notes', type: 'string' },
85 { name: 'best_for', type: 'string' }, 85 { name: 'best_for', type: 'string' },
86 { name: 'max_reuse', type: 'int' }, 86 { name: 'max_reuse', type: 'int' },
87 { name: 'inventory', type: 'float' }, 87 { name: 'inventory', type: 'float' },
88 { name: 'cost', type: 'float' }, 88 { name: 'cost', type: 'float' },
89 { name: 'production_date', type: 'string' }, 89 { name: 'production_date', type: 'string' },
90 { name: 'tht_date', type: 'string' }, 90 { name: 'tht_date', type: 'string' },
91 { name: 'cells', type: 'float' }, 91 { name: 'cells', type: 'float' },
92 { name: 'tolerance', type: 'float' }, 92 { name: 'tolerance', type: 'float' },
93 { name: 'sta1', type: 'int' }, 93 { name: 'sta1', type: 'int' },
94 { name: 'bacteria', type: 'int' }, 94 { name: 'bacteria', type: 'int' },
95 { name: 'harvest_top', type: 'int' }, 95 { name: 'harvest_top', type: 'int' },
96 { name: 'harvest_time', type: 'int' }, 96 { name: 'harvest_time', type: 'int' },
97 { name: 'pitch_temperature', type: 'float' }, 97 { name: 'pitch_temperature', type: 'float' },
98 { name: 'pofpos', type: 'int' }, 98 { name: 'pofpos', type: 'int' },
99 { name: 'zymocide', type: 'int' } 99 { name: 'zymocide', type: 'int' }
100 ], 100 ],
101 id: 'record', 101 id: 'record',
102 url: url, 102 url: url,
103 deleterow: function (rowid, commit) { 103 deleterow: function(rowid, commit) {
104 // synchronize with the server - send delete command 104 // synchronize with the server - send delete command
105 var data = "delete=true&" + $.param({ record: rowid }); 105 var data = 'delete=true&' + $.param({ record: rowid });
106 $.ajax({ 106 $.ajax({
107 dataType: 'json', 107 dataType: 'json',
108 url: url, 108 url: url,
109 cache: false, 109 cache: false,
110 data: data, 110 data: data,
111 type: "POST", 111 type: 'POST',
112 success: function (data, status, xhr) { 112 success: function(data, status, xhr) {
113 commit(true); 113 commit(true);
114 location.reload( true ); 114 location.reload(true);
115 }, 115 },
116 error: function (jqXHR, textStatus, errorThrown) { 116 error: function(jqXHR, textStatus, errorThrown) {
117 commit(false); 117 commit(false);
118 } 118 }
119 }); 119 });
120 }, 120 },
121 addrow: function (rowid, rowdata, position, commit) { 121 addrow: function(rowid, rowdata, position, commit) {
122 var data = "insert=true&" + $.param(rowdata); 122 var data = 'insert=true&' + $.param(rowdata);
123 $.ajax({ 123 $.ajax({
124 dataType: 'json', 124 dataType: 'json',
125 url: url, 125 url: url,
126 cache: false, 126 cache: false,
127 data: data, 127 data: data,
128 type: "POST", 128 type: 'POST',
129 success: function (data, status, xhr) { 129 success: function(data, status, xhr) {
130 commit(true); 130 commit(true);
131 location.reload( true ); 131 location.reload(true);
132 }, 132 },
133 error: function(jqXHR, textStatus, errorThrown) { 133 error: function(jqXHR, textStatus, errorThrown) {
134 commit(false); 134 commit(false);
135 } 135 }
136 }); 136 });
137 }, 137 },
138 updaterow: function (rowid, rowdata, commit) { 138 updaterow: function(rowid, rowdata, commit) {
139 var data = "update=true&" + $.param(rowdata); 139 var data = 'update=true&' + $.param(rowdata);
140 $.ajax({ 140 $.ajax({
141 dataType: 'json', 141 dataType: 'json',
142 url: url, 142 url: url,
143 cache: false, 143 cache: false,
144 data: data, 144 data: data,
145 type: "POST", 145 type: 'POST',
146 success: function (data, status, xhr) { 146 success: function(data, status, xhr) {
147 commit(true); 147 commit(true);
148 location.reload( true ); 148 location.reload(true);
149 }, 149 },
150 error: function(jqXHR, textStatus, errorThrown) { 150 error: function(jqXHR, textStatus, errorThrown) {
151 commit(false); 151 commit(false);
152 } 152 }
153 }); 153 });
154 } 154 }
155 }, 155 },
156 dataAdapter = new $.jqx.dataAdapter(source), 156 dataAdapter = new $.jqx.dataAdapter(source),
157 editrow = -1; 157 editrow = -1;
158 158
159 // initialize the input fields. 159 // initialize the input fields.
160 $("#name").jqxInput({ theme: theme, width: 640, height: 23 }); 160 $('#name').jqxInput({ theme: theme, width: 640, height: 23 });
161 $("#laboratory").jqxInput({ theme: theme, width: 320, height: 23 }); 161 $('#laboratory').jqxInput({ theme: theme, width: 320, height: 23 });
162 $("#product_id").jqxInput({ theme: theme, width: 320, height: 23 }); 162 $('#product_id').jqxInput({ theme: theme, width: 320, height: 23 });
163 $("#type").jqxDropDownList({ 163 $('#type').jqxDropDownList({
164 theme: theme, 164 theme: theme,
165 source: YeastTypeAdapter, 165 source: YeastTypeAdapter,
166 valueMember: 'nl', 166 valueMember: 'nl',
167 displayMember: 'nl', 167 displayMember: 'nl',
168 width: 180, 168 width: 180,
169 height: 23, 169 height: 23,
170 autoDropDownHeight: true 170 autoDropDownHeight: true
171 }); 171 });
172 $("#form").jqxDropDownList({ 172 $('#form').jqxDropDownList({
173 theme: theme, 173 theme: theme,
174 source: YeastFormAdapter, 174 source: YeastFormAdapter,
175 valueMember: 'nl', 175 valueMember: 'nl',
176 displayMember: 'nl', 176 displayMember: 'nl',
177 width: 180, 177 width: 180,
178 height: 23, 178 height: 23,
179 autoDropDownHeight: true 179 autoDropDownHeight: true
180 }); 180 });
181 $("#notes").jqxInput({ theme: theme, width: 800, height: 120 }); 181 $('#notes').jqxInput({ theme: theme, width: 800, height: 120 });
182 $("#best_for").jqxInput({ theme: theme, width: 320, height: 100 }); 182 $('#best_for').jqxInput({ theme: theme, width: 320, height: 100 });
183 $("#inventory").jqxNumberInput( Spin1dec ); 183 $('#inventory').jqxNumberInput(Spin1dec);
184 $("#production_date").jqxDateTimeInput( Dateopts ); 184 $('#production_date').jqxDateTimeInput(Dateopts);
185 $("#min_temperature").jqxNumberInput( YeastT ); 185 $('#min_temperature').jqxNumberInput(YeastT);
186 $("#max_temperature").jqxNumberInput( YeastT ); 186 $('#max_temperature').jqxNumberInput(YeastT);
187 $("#flocculation").jqxDropDownList({ 187 $('#flocculation').jqxDropDownList({
188 theme: theme, 188 theme: theme,
189 source: FlocculationAdapter, 189 source: FlocculationAdapter,
190 valueMember: 'id', 190 valueMember: 'id',
191 displayMember: 'nl', 191 displayMember: 'nl',
192 width: 180, 192 width: 180,
193 height: 23, 193 height: 23,
194 autoDropDownHeight: true 194 autoDropDownHeight: true
195 }); 195 });
196 $("#attenuation").jqxNumberInput( Perc1dec ); 196 $('#attenuation').jqxNumberInput(Perc1dec);
197 $("#max_reuse").jqxNumberInput( PosInt ); 197 $('#max_reuse').jqxNumberInput(PosInt);
198 $("#max_reuse").jqxNumberInput({ max: 10 }); 198 $('#max_reuse').jqxNumberInput({ max: 10 });
199 $("#cost").jqxNumberInput( Spin2dec ); 199 $('#cost').jqxNumberInput(Spin2dec);
200 $("#tht_date").jqxDateTimeInput( Dateopts ); 200 $('#tht_date').jqxDateTimeInput(Dateopts);
201 $("#totval").jqxNumberInput( Show2dec ); 201 $('#totval').jqxNumberInput(Show2dec);
202 $("#cells").jqxNumberInput( Spin1dec ); 202 $('#cells').jqxNumberInput(Spin1dec);
203 $("#tolerance").jqxNumberInput( Perc1dec ); 203 $('#tolerance').jqxNumberInput(Perc1dec);
204 $("#tolerance").jqxNumberInput({ max: 25 }); 204 $('#tolerance').jqxNumberInput({ max: 25 });
205 $('#sta1').jqxCheckBox({ theme: theme, width: 120, height: 23 }); 205 $('#sta1').jqxCheckBox({ theme: theme, width: 120, height: 23 });
206 $('#sta1').on('checked', function(event) { dataRecord.sta1 = 1; }); 206 $('#sta1').on('checked', function(event) { dataRecord.sta1 = 1; });
207 $('#sta1').on('unchecked', function(event) { dataRecord.sta1 = 0; }); 207 $('#sta1').on('unchecked', function(event) { dataRecord.sta1 = 0; });
208 $('#bacteria').jqxCheckBox({ theme: theme, width: 120, height: 23 }); 208 $('#bacteria').jqxCheckBox({ theme: theme, width: 120, height: 23 });
209 $('#bacteria').on('checked', function(event) { dataRecord.bacteria = 1; }); 209 $('#bacteria').on('checked', function(event) { dataRecord.bacteria = 1; });
210 $('#bacteria').on('unchecked', function(event) { dataRecord.bacteria = 0; }); 210 $('#bacteria').on('unchecked', function(event) { dataRecord.bacteria = 0; });
211 $('#harvest_top').jqxCheckBox({ theme: theme, width: 120, height: 23 }); 211 $('#harvest_top').jqxCheckBox({ theme: theme, width: 120, height: 23 });
212 $('#harvest_top').on('checked', function(event) { dataRecord.harvest_top = 1; }); 212 $('#harvest_top').on('checked', function(event) { dataRecord.harvest_top = 1; });
213 $('#harvest_top').on('unchecked', function(event) { dataRecord.harvest_top = 0; }); 213 $('#harvest_top').on('unchecked', function(event) { dataRecord.harvest_top = 0; });
214 $('#harvest_time').jqxNumberInput( PosInt ); 214 $('#harvest_time').jqxNumberInput(PosInt);
215 $("#pitch_temperature").jqxNumberInput( YeastT ); 215 $('#pitch_temperature').jqxNumberInput(YeastT);
216 $('#pofpos').jqxCheckBox({ theme: theme, width: 120, height: 23 }); 216 $('#pofpos').jqxCheckBox({ theme: theme, width: 120, height: 23 });
217 $('#pofpos').on('checked', function(event) { dataRecord.pofpos = 1; }); 217 $('#pofpos').on('checked', function(event) { dataRecord.pofpos = 1; });
218 $('#pofpos').on('unchecked', function(event) { dataRecord.pofpos = 0; }); 218 $('#pofpos').on('unchecked', function(event) { dataRecord.pofpos = 0; });
219 $("#zymocide").jqxDropDownList({ 219 $('#zymocide').jqxDropDownList({
220 theme: theme, 220 theme: theme,
221 source: ZymocideAdapter, 221 source: ZymocideAdapter,
222 valueMember: 'id', 222 valueMember: 'id',
223 displayMember: 'nl', 223 displayMember: 'nl',
224 width: 80, 224 width: 80,
225 height: 23, 225 height: 23,
226 autoDropDownHeight: true 226 autoDropDownHeight: true
227 }); 227 });
228 228
229 // initialize jqxGrid 229 // initialize jqxGrid
230 $("#jqxgrid").jqxGrid({ 230 $('#jqxgrid').jqxGrid({
231 width: 1280, 231 width: 1280,
232 height: 630, 232 height: 630,
233 source: dataAdapter, 233 source: dataAdapter,
234 theme: theme, 234 theme: theme,
235 showstatusbar: true, 235 showstatusbar: true,
236 renderstatusbar: function(statusbar) { 236 renderstatusbar: function(statusbar) {
237 var container, addButton, impButton; 237 var container, addButton, impButton;
238 container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); 238 container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>');
239 addButton = $("<div style='float: right; margin-right: 15px;'><img style='position: relative; margin-top: 2px;' src='images/add.png'/><span style='margin-left: 4px; position: relative; top: -3px;'>Nieuw</span></div>"); 239 addButton = $('<div style="float: right; margin-right: 15px;"><img style="position: relative; margin-top: 2px;" ' +
240 impButton = $("<div style='float: right; margin-right: 50px;'><img style='position: relative; margin-top: 2px;' src='images/add.png'/><span style='margin-left: 4px; position: relative; top: -3px;'>Import</span></div>"); 240 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -3px;">Nieuw</span></div>');
241 container.append(addButton); 241 impButton = $('<div style="float: right; margin-right: 50px;"><img style="position: relative; margin-top: 2px;" ' +
242 container.append(impButton); 242 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -3px;">Import</span></div>');
243 statusbar.append(container); 243 container.append(addButton);
244 addButton.jqxButton({ theme: theme, width: 90, height: 20 }); 244 container.append(impButton);
245 impButton.jqxButton({ theme: theme, width: 90, height: 20 }); 245 statusbar.append(container);
246 // add new row. 246 addButton.jqxButton({ theme: theme, width: 90, height: 20 });
247 addButton.click(function (event) { 247 impButton.jqxButton({ theme: theme, width: 90, height: 20 });
248 editrow = -1; 248 // add new row.
249 $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } }); 249 addButton.click(function(event) {
250 $("#name").val(''); 250 editrow = -1;
251 $("#laboratory").val(''); 251 $('#popupWindow').jqxWindow({ position: { x: 110, y: 30 } });
252 $("#product_id").val(''); 252 $('#name').val('');
253 $("#type").val('Bovengist'); 253 $('#laboratory').val('');
254 $("#form").val('Vloeibaar'); 254 $('#product_id').val('');
255 $("#min_temperature").val(18); 255 $('#type').val('Bovengist');
256 $("#max_temperature").val(22); 256 $('#form').val('Vloeibaar');
257 $("#flocculation").val(0); 257 $('#min_temperature').val(18);
258 $("#attenuation").val(77); 258 $('#max_temperature').val(22);
259 $("#notes").val(''); 259 $('#flocculation').val(0);
260 $("#best_for").val(''); 260 $('#attenuation').val(77);
261 $("#max_reuse").val(10); 261 $('#notes').val('');
262 $("#inventory").val(0); 262 $('#best_for').val('');
263 $("#cost").val(0); 263 $('#max_reuse').val(10);
264 $("#production_date").val(''); 264 $('#inventory').val(0);
265 $("#tht_date").val(''); 265 $('#cost').val(0);
266 $("#cells").val(1); 266 $('#production_date').val('');
267 $("#tolerance").val(0); 267 $('#tht_date').val('');
268 $("#sta1").val(0); 268 $('#cells').val(1);
269 $("#bacteria").val(0); 269 $('#tolerance').val(0);
270 $("#harvest_top").val(0); 270 $('#sta1').val(0);
271 $("#harvest_time").val(0); 271 $('#bacteria').val(0);
272 $("#pitch_temperature").val(0); 272 $('#harvest_top').val(0);
273 $("#pofpos").val(0); 273 $('#harvest_time').val(0);
274 $("#zymocide").val(0); 274 $('#pitch_temperature').val(0);
275 $("#popupWindow").jqxWindow('open'); 275 $('#pofpos').val(0);
276 }); 276 $('#zymocide').val(0);
277 impButton.click(function (event) { 277 $('#popupWindow').jqxWindow('open');
278 window.location.href = 'import_ingredients.php?select=yeasts'; 278 });
279 }); 279 impButton.click(function(event) {
280 }, 280 window.location.href = 'import_ingredients.php?select=yeasts';
281 filterable: true, 281 });
282 filtermode: 'excel', 282 },
283 columns: [ 283 filterable: true,
284 { text: 'Laboratorium', datafield: 'laboratory', width: 150 }, 284 filtermode: 'excel',
285 { text: 'Product ID', datafield: 'product_id', width: 120, menu: false }, 285 columns: [
286 { text: 'Gist naam', datafield: 'name', menu: false }, 286 { text: 'Laboratorium', datafield: 'laboratory', width: 150 },
287 { text: 'Type', datafield: 'type', align: 'center', cellsalign: 'center', width: 110 }, 287 { text: 'Product ID', datafield: 'product_id', width: 120, menu: false },
288 { text: 'Vorm', datafield: 'form', align: 'center', cellsalign: 'center', width: 110 }, 288 { text: 'Gist naam', datafield: 'name', menu: false },
289 { text: 'SVG', datafield: 'attenuation', width: 70, align: 'right', cellsalign: 'right', menu: false, cellsformat: 'p1' }, 289 { text: 'Type', datafield: 'type', align: 'center', cellsalign: 'center', width: 110 },
290 { text: 'Tol%', datafield: 'tolerance', width: 60, align: 'right', cellsalign: 'right', menu: false, 290 { text: 'Vorm', datafield: 'form', align: 'center', cellsalign: 'center', width: 110 },
291 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { 291 { text: 'SVG', datafield: 'attenuation', width: 70, align: 'right', cellsalign: 'right', menu: false, cellsformat: 'p1' },
292 var amount = ""; 292 { text: 'Tol%', datafield: 'tolerance', width: 60, align: 'right', cellsalign: 'right', menu: false,
293 if (value > 0) 293 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) {
294 amount = dataAdapter.formatNumber(value, "p0"); 294 var amount = '';
295 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + amount + '</span>'; 295 if (value > 0)
296 } 296 amount = dataAdapter.formatNumber(value, 'p0');
297 }, 297 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + amount + '</span>';
298 { text: 'Voorraad', datafield: 'inventory', width: 100, align: 'right', menu: false, 298 }
299 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { 299 },
300 var amount = ""; 300 { text: 'Voorraad', datafield: 'inventory', width: 100, align: 'right', menu: false,
301 if (value > 0) { 301 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) {
302 if ((rowdata.form == 'Vloeibaar') && (value > 1)) 302 var amount = '';
303 amount = dataAdapter.formatNumber(value,"f0")+" pakken"; 303 if (value > 0) {
304 else if (rowdata.form == 'Vloeibaar') 304 if ((rowdata.form == 'Vloeibaar') && (value > 1))
305 amount = dataAdapter.formatNumber(value,"f0")+" pak"; 305 amount = dataAdapter.formatNumber(value, 'f0') + ' pakken';
306 else if (rowdata.form == 'Droog' || rowdata.form == 'Gedroogd') 306 else if (rowdata.form == 'Vloeibaar')
307 amount = dataAdapter.formatNumber(value * 1000,"f1")+" gram"; 307 amount = dataAdapter.formatNumber(value, 'f0') + ' pak';
308 else 308 else if (rowdata.form == 'Droog' || rowdata.form == 'Gedroogd')
309 amount = dataAdapter.formatNumber(value * 1000,"f1")+" ml"; 309 amount = dataAdapter.formatNumber(value * 1000, 'f1') + ' gram';
310 } 310 else
311 return "<span style='margin: 3px; margin-top: 6px; float: right;'>" + amount + "</span>"; 311 amount = dataAdapter.formatNumber(value * 1000, 'f1') + ' ml';
312 } 312 }
313 }, 313 return '<span style="margin: 3px; margin-top: 6px; float: right;">' + amount + '</span>';
314 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', menu: false, cellsrenderer: function () { 314 }
315 return "Wijzig"; 315 },
316 }, buttonclick: function (row) { 316 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', menu: false, cellsrenderer: function() {
317 // open the popup window when the user clicks a button. 317 return 'Wijzig';
318 editrow = row; 318 }, buttonclick: function(row) {
319 $("#popupWindow").jqxWindow({ position: { x: 110, y: 15 } }); 319 // open the popup window when the user clicks a button.
320 // get the clicked row's data and initialize the input fields. 320 editrow = row;
321 dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); 321 $('#popupWindow').jqxWindow({ position: { x: 110, y: 15 } });
322 $("#name").val(dataRecord.name); 322 // get the clicked row's data and initialize the input fields.
323 $("#laboratory").val(dataRecord.laboratory); 323 dataRecord = $('#jqxgrid').jqxGrid('getrowdata', editrow);
324 $("#product_id").val(dataRecord.product_id); 324 $('#name').val(dataRecord.name);
325 $("#type").val(dataRecord.type); 325 $('#laboratory').val(dataRecord.laboratory);
326 $("#form").val(dataRecord.form); 326 $('#product_id').val(dataRecord.product_id);
327 $("#min_temperature").val(parseFloat(dataRecord.min_temperature)); 327 $('#type').val(dataRecord.type);
328 $("#max_temperature").val(parseFloat(dataRecord.max_temperature)); 328 $('#form').val(dataRecord.form);
329 $("#flocculation").val(dataRecord.flocculation); 329 $('#min_temperature').val(parseFloat(dataRecord.min_temperature));
330 $("#attenuation").val(dataRecord.attenuation); 330 $('#max_temperature').val(parseFloat(dataRecord.max_temperature));
331 $("#notes").val(dataRecord.notes); 331 $('#flocculation').val(dataRecord.flocculation);
332 $("#best_for").val(dataRecord.best_for); 332 $('#attenuation').val(dataRecord.attenuation);
333 $("#max_reuse").val(dataRecord.max_reuse); 333 $('#notes').val(dataRecord.notes);
334 if (dataRecord.form == 'Vloeibaar') 334 $('#best_for').val(dataRecord.best_for);
335 $("#inventory").val(dataRecord.inventory); 335 $('#max_reuse').val(dataRecord.max_reuse);
336 else 336 if (dataRecord.form == 'Vloeibaar')
337 $("#inventory").val(dataRecord.inventory * 1000); 337 $('#inventory').val(dataRecord.inventory);
338 $("#cost").val(dataRecord.cost); 338 else
339 $("#production_date").val(dataRecord.production_date); 339 $('#inventory').val(dataRecord.inventory * 1000);
340 $("#tht_date").val(dataRecord.tht_date); 340 $('#cost').val(dataRecord.cost);
341 $("#cells").val(dataRecord.cells); 341 $('#production_date').val(dataRecord.production_date);
342 $("#tolerance").val(dataRecord.tolerance); 342 $('#tht_date').val(dataRecord.tht_date);
343 $("#sta1").val(dataRecord.sta1); 343 $('#cells').val(dataRecord.cells);
344 $("#bacteria").val(dataRecord.bacteria); 344 $('#tolerance').val(dataRecord.tolerance);
345 $("#harvest_top").val(dataRecord.harvest_top); 345 $('#sta1').val(dataRecord.sta1);
346 $("#harvest_time").val(dataRecord.harvest_time); 346 $('#bacteria').val(dataRecord.bacteria);
347 $("#pitch_temperature").val(parseFloat(dataRecord.pitch_temperature)); 347 $('#harvest_top').val(dataRecord.harvest_top);
348 $("#pofpos").val(dataRecord.pofpos); 348 $('#harvest_time').val(dataRecord.harvest_time);
349 $("#zymocide").val(dataRecord.zymocide); 349 $('#pitch_temperature').val(parseFloat(dataRecord.pitch_temperature));
350 calcTotal(); 350 $('#pofpos').val(dataRecord.pofpos);
351 // show the popup window. 351 $('#zymocide').val(dataRecord.zymocide);
352 $("#popupWindow").jqxWindow('open'); 352 calcTotal();
353 } 353 // show the popup window.
354 } 354 $('#popupWindow').jqxWindow('open');
355 ] 355 }
356 }); 356 }
357 357 ]
358 $('#popupWindow').on('open', function (event) { calcTotal(); }); 358 });
359 $("#cost").on('change', function (event) { 359
360 dataRecord.cost = parseFloat(event.args.value); 360 $('#popupWindow').on('open', function(event) { calcTotal(); });
361 calcTotal(); 361 $('#cost').on('change', function(event) {
362 }); 362 dataRecord.cost = parseFloat(event.args.value);
363 $("#inventory").on('change', function (event) { 363 calcTotal();
364 if (dataRecord.form == 'Vloeibaar') 364 });
365 dataRecord.inventory = parseFloat(event.args.value); 365 $('#inventory').on('change', function(event) {
366 else 366 if (dataRecord.form == 'Vloeibaar')
367 dataRecord.inventory = parseFloat(event.args.value) / 1000.0; 367 dataRecord.inventory = parseFloat(event.args.value);
368 calcTotal(); 368 else
369 }); 369 dataRecord.inventory = parseFloat(event.args.value) / 1000.0;
370 $("#form").on('select', function (event) { 370 calcTotal();
371 dataRecord.form = $("#form").val(); 371 });
372 calcTotal(); 372 $('#form').on('select', function(event) {
373 }); 373 dataRecord.form = $('#form').val();
374 374 calcTotal();
375 // initialize the popup window and buttons. 375 });
376 $("#popupWindow").jqxWindow({ 376
377 width: 1050, 377 // initialize the popup window and buttons.
378 height: 625, 378 $('#popupWindow').jqxWindow({
379 resizable: false, 379 width: 1050,
380 theme: theme, 380 height: 625,
381 isModal: true, 381 resizable: false,
382 autoOpen: false, 382 theme: theme,
383 cancelButton: $("#Cancel"), 383 isModal: true,
384 modalOpacity: 0.40 384 autoOpen: false,
385 }); 385 cancelButton: $('#Cancel'),
386 $("#popupWindow").on('open', function () { 386 modalOpacity: 0.40
387 $("#name").jqxInput('selectAll'); 387 });
388 }); 388 $('#popupWindow').on('open', function() {
389 $("#Delete").jqxButton({ template: "danger", width: '90px', theme: theme }); 389 $('#name').jqxInput('selectAll');
390 $("#Delete").click(function() { 390 });
391 if (editrow >= 0) { 391 $('#Delete').jqxButton({ template: 'danger', width: '90px', theme: theme });
392 // Open a popup to confirm this action. 392 $('#Delete').click(function() {
393 $('#eventWindow').jqxWindow('open'); 393 if (editrow >= 0) {
394 $("#delOk").click(function () { 394 // Open a popup to confirm this action.
395 var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); 395 $('#eventWindow').jqxWindow('open');
396 $("#jqxgrid").jqxGrid('deleterow', rowID); 396 $('#delOk').click(function() {
397 }); 397 var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow);
398 } 398 $('#jqxgrid').jqxGrid('deleterow', rowID);
399 $("#popupWindow").jqxWindow('hide'); 399 });
400 }); 400 }
401 $("#Cancel").jqxButton({ template: "primary", width: '90px', theme: theme }); 401 $('#popupWindow').jqxWindow('hide');
402 $("#Clone").jqxButton({ template: "warning", width: '90px', theme: theme }); 402 });
403 $("#Clone").click(function() { 403 $('#Cancel').jqxButton({ template: 'primary', width: '90px', theme: theme });
404 var row = { 404 $('#Clone').jqxButton({ template: 'warning', width: '90px', theme: theme });
405 record: -1, 405 $('#Clone').click(function() {
406 name: $("#name").val()+" kopie", 406 var row = {
407 type: $("#type").val(), 407 record: -1,
408 form: $("#form").val(), 408 name: $('#name').val() + ' kopie',
409 laboratory: $("#laboratory").val(), 409 type: $('#type').val(),
410 product_id: $("#product_id").val(), 410 form: $('#form').val(),
411 min_temperature: parseFloat($("#min_temperature").jqxNumberInput('decimal')), 411 laboratory: $('#laboratory').val(),
412 max_temperature: parseFloat($("#max_temperature").jqxNumberInput('decimal')), 412 product_id: $('#product_id').val(),
413 flocculation: $("#flocculation").val(), 413 min_temperature: parseFloat($('#min_temperature').jqxNumberInput('decimal')),
414 attenuation: parseFloat($("#attenuation").jqxNumberInput('decimal')), 414 max_temperature: parseFloat($('#max_temperature').jqxNumberInput('decimal')),
415 notes: $("#notes").val(), 415 flocculation: $('#flocculation').val(),
416 best_for: $("#best_for").val(), 416 attenuation: parseFloat($('#attenuation').jqxNumberInput('decimal')),
417 max_reuse: parseInt($("#max_reuse").jqxNumberInput('decimal')), 417 notes: $('#notes').val(),
418 inventory: 0, 418 best_for: $('#best_for').val(),
419 cost: parseFloat($("#cost").jqxNumberInput('decimal')), 419 max_reuse: parseInt($('#max_reuse').jqxNumberInput('decimal')),
420 production_date: '', 420 inventory: 0,
421 tht_date: '', 421 cost: parseFloat($('#cost').jqxNumberInput('decimal')),
422 cells: parseFloat($("#cells").jqxNumberInput('decimal')), 422 production_date: '',
423 tolerance: parseFloat($("#tolerance").jqxNumberInput('decimal')), 423 tht_date: '',
424 sta1: $("#sta1").val(), 424 cells: parseFloat($('#cells').jqxNumberInput('decimal')),
425 bacteria: $("#bacteria").val(), 425 tolerance: parseFloat($('#tolerance').jqxNumberInput('decimal')),
426 harvest_top: $("#harvest_top").val(), 426 sta1: $('#sta1').val(),
427 harvest_time: $("#harvest_time").val(), 427 bacteria: $('#bacteria').val(),
428 pitch_temperature: parseFloat($("#pitch_temperature").jqxNumberInput('decimal')), 428 harvest_top: $('#harvest_top').val(),
429 pofpos: $("#pofpos").val(), 429 harvest_time: $('#harvest_time').val(),
430 zymocide: $("#zymocide").val() 430 pitch_temperature: parseFloat($('#pitch_temperature').jqxNumberInput('decimal')),
431 }; 431 pofpos: $('#pofpos').val(),
432 $('#jqxgrid').jqxGrid('addrow', null, row); 432 zymocide: $('#zymocide').val()
433 $("#popupWindow").jqxWindow('hide'); 433 };
434 }); 434 $('#jqxgrid').jqxGrid('addrow', null, row);
435 $("#Save").jqxButton({ template: "success", width: '90px', theme: theme }); 435 $('#popupWindow').jqxWindow('hide');
436 // update the edited row when the user clicks the 'Save' button. 436 });
437 $("#Save").click(function() { 437 $('#Save').jqxButton({ template: 'success', width: '90px', theme: theme });
438 var n_inventory, row, rowID = -1; 438 // update the edited row when the user clicks the 'Save' button.
439 if (editrow >= 0) { 439 $('#Save').click(function() {
440 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); 440 var n_inventory, row, rowID = -1;
441 } 441 if (editrow >= 0) {
442 if (dataRecord.form == 'Vloeibaar') 442 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow);
443 n_inventory = parseFloat($("#inventory").jqxNumberInput('decimal')); 443 }
444 else 444 if (dataRecord.form == 'Vloeibaar')
445 n_inventory = parseFloat($("#inventory").jqxNumberInput('decimal')) / 1000.0; 445 n_inventory = parseFloat($('#inventory').jqxNumberInput('decimal'));
446 row = { 446 else
447 record: rowID, 447 n_inventory = parseFloat($('#inventory').jqxNumberInput('decimal')) / 1000.0;
448 name: $("#name").val(), 448 row = {
449 type: $("#type").val(), 449 record: rowID,
450 form: $("#form").val(), 450 name: $('#name').val(),
451 laboratory: $("#laboratory").val(), 451 type: $('#type').val(),
452 product_id: $("#product_id").val(), 452 form: $('#form').val(),
453 min_temperature: parseFloat($("#min_temperature").jqxNumberInput('decimal')), 453 laboratory: $('#laboratory').val(),
454 max_temperature: parseFloat($("#max_temperature").jqxNumberInput('decimal')), 454 product_id: $('#product_id').val(),
455 flocculation: $("#flocculation").val(), 455 min_temperature: parseFloat($('#min_temperature').jqxNumberInput('decimal')),
456 attenuation: parseFloat($("#attenuation").jqxNumberInput('decimal')), 456 max_temperature: parseFloat($('#max_temperature').jqxNumberInput('decimal')),
457 notes: $("#notes").val(), 457 flocculation: $('#flocculation').val(),
458 best_for: $("#best_for").val(), 458 attenuation: parseFloat($('#attenuation').jqxNumberInput('decimal')),
459 max_reuse: parseInt($("#max_reuse").jqxNumberInput('decimal')), 459 notes: $('#notes').val(),
460 inventory: n_inventory, 460 best_for: $('#best_for').val(),
461 cost: parseFloat($("#cost").jqxNumberInput('decimal')), 461 max_reuse: parseInt($('#max_reuse').jqxNumberInput('decimal')),
462 production_date: $("#production_date").val(), 462 inventory: n_inventory,
463 tht_date: $("#tht_date").val(), 463 cost: parseFloat($('#cost').jqxNumberInput('decimal')),
464 cells: parseFloat($("#cells").jqxNumberInput('decimal')), 464 production_date: $('#production_date').val(),
465 tolerance: parseFloat($("#tolerance").jqxNumberInput('decimal')), 465 tht_date: $('#tht_date').val(),
466 sta1: $("#sta1").val(), 466 cells: parseFloat($('#cells').jqxNumberInput('decimal')),
467 bacteria: $("#bacteria").val(), 467 tolerance: parseFloat($('#tolerance').jqxNumberInput('decimal')),
468 harvest_top: $("#harvest_top").val(), 468 sta1: $('#sta1').val(),
469 harvest_time: $("#harvest_time").val(), 469 bacteria: $('#bacteria').val(),
470 pitch_temperature: parseFloat($("#pitch_temperature").jqxNumberInput('decimal')), 470 harvest_top: $('#harvest_top').val(),
471 pofpos: $("#pofpos").val(), 471 harvest_time: $('#harvest_time').val(),
472 zymocide: $("#zymocide").val() 472 pitch_temperature: parseFloat($('#pitch_temperature').jqxNumberInput('decimal')),
473 }; 473 pofpos: $('#pofpos').val(),
474 if (editrow >= 0) { 474 zymocide: $('#zymocide').val()
475 $('#jqxgrid').jqxGrid('updaterow', rowID, row); 475 };
476 } else { 476 if (editrow >= 0) {
477 $('#jqxgrid').jqxGrid('addrow', null, row); 477 $('#jqxgrid').jqxGrid('updaterow', rowID, row);
478 } 478 } else {
479 $("#popupWindow").jqxWindow('hide'); 479 $('#jqxgrid').jqxGrid('addrow', null, row);
480 }); 480 }
481 createDelElements(); 481 $('#popupWindow').jqxWindow('hide');
482 });
483 createDelElements();
482 }); 484 });
483 485

mercurial