www/js/inv_yeasts.js

changeset 481
fc21dcfbe51d
parent 395
463d64cce768
child 488
77f1617b6994
equal deleted inserted replaced
480:0c106302e74a 481:fc21dcfbe51d
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 var dataRecord = {}; 47 var dataRecord = {};
48 48
49 function calcTotal() { 49 function calcTotal() {
50 50
65 $("#pmpt_cells").html('Miljard cellen per ml:'); 65 $("#pmpt_cells").html('Miljard cellen per ml:');
66 $("#inventory").jqxNumberInput({ decimalDigits: 1 }); 66 $("#inventory").jqxNumberInput({ decimalDigits: 1 });
67 } 67 }
68 } 68 }
69 69
70 var url = "includes/db_inventory_yeasts.php"; 70 var url = 'includes/db_inventory_yeasts.php',
71 // prepare the data 71 source = {
72 var source = { 72 datatype: 'json',
73 datatype: "json",
74 cache: false, 73 cache: false,
75 datafields: [ 74 datafields: [
76 { name: 'record', type: 'number' }, 75 { name: 'record', type: 'number' },
77 { name: 'name', type: 'string' }, 76 { name: 'name', type: 'string' },
78 { name: 'type', type: 'int' }, 77 { name: 'type', type: 'int' },
193 $("#totval").jqxNumberInput( Show2dec ); 192 $("#totval").jqxNumberInput( Show2dec );
194 $("#cells").jqxNumberInput( Spin1dec ); 193 $("#cells").jqxNumberInput( Spin1dec );
195 $("#tolerance").jqxNumberInput( Perc1dec ); 194 $("#tolerance").jqxNumberInput( Perc1dec );
196 $("#tolerance").jqxNumberInput({ max: 25 }); 195 $("#tolerance").jqxNumberInput({ max: 25 });
197 196
198 var dataAdapter = new $.jqx.dataAdapter(source); 197 var dataAdapter = new $.jqx.dataAdapter(source),
199 var editrow = -1; 198 editrow = -1;
200 // initialize jqxGrid 199 // initialize jqxGrid
201 $("#jqxgrid").jqxGrid({ 200 $("#jqxgrid").jqxGrid({
202 width: 1280, 201 width: 1280,
203 height: 630, 202 height: 630,
204 source: dataAdapter, 203 source: dataAdapter,
205 theme: theme, 204 theme: theme,
206 showstatusbar: true, 205 showstatusbar: true,
207 renderstatusbar: function (statusbar) { 206 renderstatusbar: function(statusbar) {
208 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); 207 var container, addButton, impButton;
209 var 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>"); 208 container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
210 var 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>"); 209 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>");
210 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>");
211 container.append(addButton); 211 container.append(addButton);
212 container.append(impButton); 212 container.append(impButton);
213 statusbar.append(container); 213 statusbar.append(container);
214 addButton.jqxButton({ theme: theme, width: 90, height: 20 }); 214 addButton.jqxButton({ theme: theme, width: 90, height: 20 });
215 impButton.jqxButton({ theme: theme, width: 90, height: 20 }); 215 impButton.jqxButton({ theme: theme, width: 90, height: 20 });
236 $("#cells").val(1); 236 $("#cells").val(1);
237 $("#tolerance").val(0); 237 $("#tolerance").val(0);
238 $("#popupWindow").jqxWindow('open'); 238 $("#popupWindow").jqxWindow('open');
239 }); 239 });
240 impButton.click(function (event) { 240 impButton.click(function (event) {
241 var url="import_ingredients.php?select=yeasts"; 241 window.location.href = 'import_ingredients.php?select=yeasts';
242 window.location.href = url;
243 }); 242 });
244 }, 243 },
245 filterable: true, 244 filterable: true,
246 filtermode: 'excel', 245 filtermode: 'excel',
247 columns: [ 246 columns: [
352 }); 351 });
353 $("#popupWindow").on('open', function () { 352 $("#popupWindow").on('open', function () {
354 $("#name").jqxInput('selectAll'); 353 $("#name").jqxInput('selectAll');
355 }); 354 });
356 $("#Delete").jqxButton({ template: "danger", width: '90px', theme: theme }); 355 $("#Delete").jqxButton({ template: "danger", width: '90px', theme: theme });
357 $("#Delete").click(function () { 356 $("#Delete").click(function() {
358 if (editrow >= 0) { 357 if (editrow >= 0) {
359 // Open a popup to confirm this action. 358 // Open a popup to confirm this action.
360 $('#eventWindow').jqxWindow('open'); 359 $('#eventWindow').jqxWindow('open');
361 $("#delOk").click(function () { 360 $("#delOk").click(function () {
362 var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); 361 var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow);
365 } 364 }
366 $("#popupWindow").jqxWindow('hide'); 365 $("#popupWindow").jqxWindow('hide');
367 }); 366 });
368 $("#Cancel").jqxButton({ template: "primary", width: '90px', theme: theme }); 367 $("#Cancel").jqxButton({ template: "primary", width: '90px', theme: theme });
369 $("#Clone").jqxButton({ template: "warning", width: '90px', theme: theme }); 368 $("#Clone").jqxButton({ template: "warning", width: '90px', theme: theme });
370 $("#Clone").click(function () { 369 $("#Clone").click(function() {
371 var row = { 370 var row = {
372 record: -1, 371 record: -1,
373 name: $("#name").val()+" kopie", 372 name: $("#name").val()+" kopie",
374 type: $("#type").val(), 373 type: $("#type").val(),
375 form: $("#form").val(), 374 form: $("#form").val(),
393 $("#popupWindow").jqxWindow('hide'); 392 $("#popupWindow").jqxWindow('hide');
394 location.reload( true ); // reload ourself. 393 location.reload( true ); // reload ourself.
395 }); 394 });
396 $("#Save").jqxButton({ template: "success", width: '90px', theme: theme }); 395 $("#Save").jqxButton({ template: "success", width: '90px', theme: theme });
397 // update the edited row when the user clicks the 'Save' button. 396 // update the edited row when the user clicks the 'Save' button.
398 $("#Save").click(function () { 397 $("#Save").click(function() {
399 var rowID = -1; 398 var n_inventory, row, rowID = -1;
400 if (editrow >= 0) { 399 if (editrow >= 0) {
401 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); 400 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow);
402 } 401 }
403 if (dataRecord.form == 0) 402 if (dataRecord.form == 0)
404 var n_inventory = parseFloat($("#inventory").jqxNumberInput('decimal')); 403 n_inventory = parseFloat($("#inventory").jqxNumberInput('decimal'));
405 else 404 else
406 var n_inventory = parseFloat($("#inventory").jqxNumberInput('decimal')) / 1000.0; 405 n_inventory = parseFloat($("#inventory").jqxNumberInput('decimal')) / 1000.0;
407 var row = { 406 row = {
408 record: rowID, 407 record: rowID,
409 name: $("#name").val(), 408 name: $("#name").val(),
410 type: $("#type").val(), 409 type: $("#type").val(),
411 form: $("#form").val(), 410 form: $("#form").val(),
412 laboratory: $("#laboratory").val(), 411 laboratory: $("#laboratory").val(),

mercurial