42 } |
42 } |
43 |
43 |
44 |
44 |
45 $(document).ready(function() { |
45 $(document).ready(function() { |
46 |
46 |
47 var dataRecord = {}; |
|
48 |
|
49 function calcTotal() { |
47 function calcTotal() { |
50 |
48 |
51 $('#totval').val(dataRecord.cost * dataRecord.inventory); |
49 $('#totval').val(dataRecord.cost * dataRecord.inventory); |
52 if (dataRecord.form == 0) { // Liquid |
50 if (dataRecord.form == 0) { // Liquid |
53 $("#pmpt_cost").html('Prijs per pak:'); |
51 $("#pmpt_cost").html('Prijs per pak:'); |
65 $("#pmpt_cells").html('Miljard cellen per ml:'); |
63 $("#pmpt_cells").html('Miljard cellen per ml:'); |
66 $("#inventory").jqxNumberInput({ decimalDigits: 1 }); |
64 $("#inventory").jqxNumberInput({ decimalDigits: 1 }); |
67 } |
65 } |
68 } |
66 } |
69 |
67 |
70 var url = 'includes/db_inventory_yeasts.php', |
68 var dataRecord = {}, |
|
69 url = 'includes/db_inventory_yeasts.php', |
71 source = { |
70 source = { |
72 datatype: 'json', |
71 datatype: 'json', |
73 cache: false, |
72 cache: false, |
74 datafields: [ |
73 datafields: [ |
75 { name: 'record', type: 'number' }, |
74 { name: 'record', type: 'number' }, |
135 url: url, |
135 url: url, |
136 cache: false, |
136 cache: false, |
137 data: data, |
137 data: data, |
138 type: "POST", |
138 type: "POST", |
139 success: function (data, status, xhr) { |
139 success: function (data, status, xhr) { |
140 // update command is executed. |
|
141 commit(true); |
140 commit(true); |
|
141 location.reload( true ); |
142 }, |
142 }, |
143 error: function(jqXHR, textStatus, errorThrown) { |
143 error: function(jqXHR, textStatus, errorThrown) { |
144 commit(false); |
144 commit(false); |
145 } |
145 } |
146 }); |
146 }); |
147 } |
147 } |
148 }; |
148 }, |
|
149 dataAdapter = new $.jqx.dataAdapter(source), |
|
150 editrow = -1; |
|
151 |
149 // initialize the input fields. |
152 // initialize the input fields. |
150 $("#name").jqxInput({ theme: theme, width: 640, height: 23 }); |
153 $("#name").jqxInput({ theme: theme, width: 640, height: 23 }); |
151 $("#laboratory").jqxInput({ theme: theme, width: 320, height: 23 }); |
154 $("#laboratory").jqxInput({ theme: theme, width: 320, height: 23 }); |
152 $("#product_id").jqxInput({ theme: theme, width: 320, height: 23 }); |
155 $("#product_id").jqxInput({ theme: theme, width: 320, height: 23 }); |
153 $("#type").jqxDropDownList({ |
156 $("#type").jqxDropDownList({ |
192 $("#totval").jqxNumberInput( Show2dec ); |
195 $("#totval").jqxNumberInput( Show2dec ); |
193 $("#cells").jqxNumberInput( Spin1dec ); |
196 $("#cells").jqxNumberInput( Spin1dec ); |
194 $("#tolerance").jqxNumberInput( Perc1dec ); |
197 $("#tolerance").jqxNumberInput( Perc1dec ); |
195 $("#tolerance").jqxNumberInput({ max: 25 }); |
198 $("#tolerance").jqxNumberInput({ max: 25 }); |
196 |
199 |
197 var dataAdapter = new $.jqx.dataAdapter(source), |
|
198 editrow = -1; |
|
199 // initialize jqxGrid |
200 // initialize jqxGrid |
200 $("#jqxgrid").jqxGrid({ |
201 $("#jqxgrid").jqxGrid({ |
201 width: 1280, |
202 width: 1280, |
202 height: 630, |
203 height: 630, |
203 source: dataAdapter, |
204 source: dataAdapter, |
388 cells: parseFloat($("#cells").jqxNumberInput('decimal')), |
389 cells: parseFloat($("#cells").jqxNumberInput('decimal')), |
389 tolerance: parseFloat($("#tolerance").jqxNumberInput('decimal')) |
390 tolerance: parseFloat($("#tolerance").jqxNumberInput('decimal')) |
390 }; |
391 }; |
391 $('#jqxgrid').jqxGrid('addrow', null, row); |
392 $('#jqxgrid').jqxGrid('addrow', null, row); |
392 $("#popupWindow").jqxWindow('hide'); |
393 $("#popupWindow").jqxWindow('hide'); |
393 location.reload( true ); // reload ourself. |
|
394 }); |
394 }); |
395 $("#Save").jqxButton({ template: "success", width: '90px', theme: theme }); |
395 $("#Save").jqxButton({ template: "success", width: '90px', theme: theme }); |
396 // update the edited row when the user clicks the 'Save' button. |
396 // update the edited row when the user clicks the 'Save' button. |
397 $("#Save").click(function() { |
397 $("#Save").click(function() { |
398 var n_inventory, row, rowID = -1; |
398 var n_inventory, row, rowID = -1; |
426 }; |
426 }; |
427 if (editrow >= 0) { |
427 if (editrow >= 0) { |
428 $('#jqxgrid').jqxGrid('updaterow', rowID, row); |
428 $('#jqxgrid').jqxGrid('updaterow', rowID, row); |
429 } else { |
429 } else { |
430 $('#jqxgrid').jqxGrid('addrow', null, row); |
430 $('#jqxgrid').jqxGrid('addrow', null, row); |
431 location.reload( true ); // reload ourself. |
|
432 } |
431 } |
433 $("#popupWindow").jqxWindow('hide'); |
432 $("#popupWindow").jqxWindow('hide'); |
434 }); |
433 }); |
435 createDelElements(); |
434 createDelElements(); |
436 }); |
435 }); |