www/js/inv_yeasts.js

changeset 514
3c680d1dea35
parent 512
4451af8b6295
child 515
9d771385a8a0
equal deleted inserted replaced
513:217ba4596c4d 514:3c680d1dea35
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 == 0) { // 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 == 1) { // Dry 55 } else if (dataRecord.form == 'Droog') { // 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 {
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: 'int' }, 76 { name: 'type', type: 'string' },
77 { name: 'form', type: 'int' }, 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' },
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: 'id', 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: 'id', 175 valueMember: 'nl',
176 displayMember: 'nl', 176 displayMember: 'nl',
177 selectedIndex: 0, 177 // selectedIndex: 0,
178 width: 180, 178 width: 180,
179 height: 23, 179 height: 23,
180 autoDropDownHeight: true 180 autoDropDownHeight: true
181 }); 181 });
182 $("#notes").jqxInput({ theme: theme, width: 800, height: 120 }); 182 $("#notes").jqxInput({ theme: theme, width: 800, height: 120 });
249 editrow = -1; 249 editrow = -1;
250 $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } }); 250 $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } });
251 $("#name").val(''); 251 $("#name").val('');
252 $("#laboratory").val(''); 252 $("#laboratory").val('');
253 $("#product_id").val(''); 253 $("#product_id").val('');
254 $("#type").val(0); 254 $("#type").val('Bovengist');
255 $("#form").val(0); 255 $("#form").val('Vloeibaar');
256 $("#min_temperature").val(18); 256 $("#min_temperature").val(18);
257 $("#max_temperature").val(22); 257 $("#max_temperature").val(22);
258 $("#flocculation").val(0); 258 $("#flocculation").val(0);
259 $("#attenuation").val(77); 259 $("#attenuation").val(77);
260 $("#notes").val(''); 260 $("#notes").val('');
268 $("#tolerance").val(0); 268 $("#tolerance").val(0);
269 $("#sta1").val(0); 269 $("#sta1").val(0);
270 $("#bacteria").val(0); 270 $("#bacteria").val(0);
271 $("#harvest_top").val(0); 271 $("#harvest_top").val(0);
272 $("#harvest_time").val(0); 272 $("#harvest_time").val(0);
273 $("pitch_temperature#").val(0); 273 $("#pitch_temperature").val(0);
274 $("#pofpos").val(0); 274 $("#pofpos").val(0);
275 $("#zymocide").val(0); 275 $("#zymocide").val(0);
276 $("#popupWindow").jqxWindow('open'); 276 $("#popupWindow").jqxWindow('open');
277 }); 277 });
278 impButton.click(function (event) { 278 impButton.click(function (event) {
283 filtermode: 'excel', 283 filtermode: 'excel',
284 columns: [ 284 columns: [
285 { text: 'Laboratorium', datafield: 'laboratory', width: 150 }, 285 { text: 'Laboratorium', datafield: 'laboratory', width: 150 },
286 { text: 'Product ID', datafield: 'product_id', width: 120, menu: false }, 286 { text: 'Product ID', datafield: 'product_id', width: 120, menu: false },
287 { text: 'Gist naam', datafield: 'name', menu: false }, 287 { text: 'Gist naam', datafield: 'name', menu: false },
288 { text: 'Type', datafield: 'type', align: 'center', cellsalign: 'center', menu: false, width: 110, 288 { text: 'Type', datafield: 'type', align: 'center', cellsalign: 'center', width: 110 },
289 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { 289 { text: 'Vorm', datafield: 'form', align: 'center', cellsalign: 'center', width: 110 },
290 return "<div style='margin: 4px;' class='jqx-center-align'>" + YeastTypeData[value].nl + "</div>";
291 }
292 },
293 { text: 'Vorm', datafield: 'form', align: 'center', cellsalign: 'center', menu: false, width: 110,
294 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
295 return "<div style='margin: 4px;' class='jqx-center-align'>" + YeastFormData[value].nl + "</div>";
296 }
297 },
298 { text: 'SVG', datafield: 'attenuation', width: 70, align: 'right', cellsalign: 'right', menu: false, cellsformat: 'p1' }, 290 { text: 'SVG', datafield: 'attenuation', width: 70, align: 'right', cellsalign: 'right', menu: false, cellsformat: 'p1' },
299 { text: 'Tol%', datafield: 'tolerance', width: 60, align: 'right', cellsalign: 'right', menu: false, 291 { text: 'Tol%', datafield: 'tolerance', width: 60, align: 'right', cellsalign: 'right', menu: false,
300 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { 292 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
301 var amount = ""; 293 var amount = "";
302 if (value > 0) 294 if (value > 0)
306 }, 298 },
307 { text: 'Voorraad', datafield: 'inventory', width: 100, align: 'right', menu: false, 299 { text: 'Voorraad', datafield: 'inventory', width: 100, align: 'right', menu: false,
308 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { 300 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
309 var amount = ""; 301 var amount = "";
310 if (value > 0) { 302 if (value > 0) {
311 if ((rowdata.form == 0) && (value > 1)) 303 if ((rowdata.form == 'Vloeibaar') && (value > 1))
312 amount = dataAdapter.formatNumber(value,"f0")+" pakken"; 304 amount = dataAdapter.formatNumber(value,"f0")+" pakken";
313 else if (rowdata.form == 0) 305 else if (rowdata.form == 'Vloeibaar')
314 amount = dataAdapter.formatNumber(value,"f0")+" pak"; 306 amount = dataAdapter.formatNumber(value,"f0")+" pak";
315 else if (rowdata.form == 1) 307 else if (rowdata.form == 'Droog')
316 amount = dataAdapter.formatNumber(value * 1000,"f1")+" gram"; 308 amount = dataAdapter.formatNumber(value * 1000,"f1")+" gram";
317 else 309 else
318 amount = dataAdapter.formatNumber(value * 1000,"f1")+" ml"; 310 amount = dataAdapter.formatNumber(value * 1000,"f1")+" ml";
319 } 311 }
320 return "<span style='margin: 3px; margin-top: 6px; float: right;'>" + amount + "</span>"; 312 return "<span style='margin: 3px; margin-top: 6px; float: right;'>" + amount + "</span>";
338 $("#flocculation").val(dataRecord.flocculation); 330 $("#flocculation").val(dataRecord.flocculation);
339 $("#attenuation").val(dataRecord.attenuation); 331 $("#attenuation").val(dataRecord.attenuation);
340 $("#notes").val(dataRecord.notes); 332 $("#notes").val(dataRecord.notes);
341 $("#best_for").val(dataRecord.best_for); 333 $("#best_for").val(dataRecord.best_for);
342 $("#max_reuse").val(dataRecord.max_reuse); 334 $("#max_reuse").val(dataRecord.max_reuse);
343 if (dataRecord.form == 0) 335 if (dataRecord.form == 'Vloeibaar')
344 $("#inventory").val(dataRecord.inventory); 336 $("#inventory").val(dataRecord.inventory);
345 else 337 else
346 $("#inventory").val(dataRecord.inventory * 1000); 338 $("#inventory").val(dataRecord.inventory * 1000);
347 $("#cost").val(dataRecord.cost); 339 $("#cost").val(dataRecord.cost);
348 $("#production_date").val(dataRecord.production_date); 340 $("#production_date").val(dataRecord.production_date);
368 $("#cost").on('change', function (event) { 360 $("#cost").on('change', function (event) {
369 dataRecord.cost = parseFloat(event.args.value); 361 dataRecord.cost = parseFloat(event.args.value);
370 calcTotal(); 362 calcTotal();
371 }); 363 });
372 $("#inventory").on('change', function (event) { 364 $("#inventory").on('change', function (event) {
373 if (dataRecord.form == 0) 365 if (dataRecord.form == 'Vloeibaar')
374 dataRecord.inventory = parseFloat(event.args.value); 366 dataRecord.inventory = parseFloat(event.args.value);
375 else 367 else
376 dataRecord.inventory = parseFloat(event.args.value) / 1000.0; 368 dataRecord.inventory = parseFloat(event.args.value) / 1000.0;
377 calcTotal(); 369 calcTotal();
378 }); 370 });
379 $("#form").on('select', function (event) { 371 $("#form").on('select', function (event) {
380 if (event.args) { 372 dataRecord.form = $("#form").val();
381 dataRecord.form = event.args.index; 373 calcTotal();
382 calcTotal();
383 }
384 }); 374 });
385 375
386 // initialize the popup window and buttons. 376 // initialize the popup window and buttons.
387 $("#popupWindow").jqxWindow({ 377 $("#popupWindow").jqxWindow({
388 width: 1050, 378 width: 1050,
448 $("#Save").click(function() { 438 $("#Save").click(function() {
449 var n_inventory, row, rowID = -1; 439 var n_inventory, row, rowID = -1;
450 if (editrow >= 0) { 440 if (editrow >= 0) {
451 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); 441 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow);
452 } 442 }
453 if (dataRecord.form == 0) 443 if (dataRecord.form == 'Vloeibaar')
454 n_inventory = parseFloat($("#inventory").jqxNumberInput('decimal')); 444 n_inventory = parseFloat($("#inventory").jqxNumberInput('decimal'));
455 else 445 else
456 n_inventory = parseFloat($("#inventory").jqxNumberInput('decimal')) / 1000.0; 446 n_inventory = parseFloat($("#inventory").jqxNumberInput('decimal')) / 1000.0;
457 row = { 447 row = {
458 record: rowID, 448 record: rowID,

mercurial