www/js/inv_miscs.js

changeset 488
77f1617b6994
parent 395
463d64cce768
child 514
3c680d1dea35
equal deleted inserted replaced
487:06df1320327c 488:77f1617b6994
40 } 40 }
41 41
42 42
43 $(document).ready(function () { 43 $(document).ready(function () {
44 44
45 var dataRecord = {};
46
47 function calcTotal(cost, inventory) { 45 function calcTotal(cost, inventory) {
48 46
49 $('#totval').val(cost * (inventory / 1000)); 47 $('#totval').val(cost * (inventory / 1000));
50 } 48 }
51 49
58 $("#pmpt_cost").html('Prijs per liter:'); 56 $("#pmpt_cost").html('Prijs per liter:');
59 $("#pmpt_inventory").html('Voorraad ml:'); 57 $("#pmpt_inventory").html('Voorraad ml:');
60 } 58 }
61 } 59 }
62 60
63 var url = "includes/db_inventory_miscs.php"; 61 var dataRecord = {},
62 url = 'includes/db_inventory_miscs.php',
64 // prepare the data 63 // prepare the data
65 var source = { 64 source = {
66 datatype: "json", 65 datatype: "json",
67 cache: false, 66 cache: false,
68 datafields: [ 67 datafields: [
69 { name: 'record', type: 'number' }, 68 { name: 'record', type: 'number' },
70 { name: 'name', type: 'string' }, 69 { name: 'name', type: 'string' },
91 url: url, 90 url: url,
92 cache: false, 91 cache: false,
93 data: data, 92 data: data,
94 type: "POST", 93 type: "POST",
95 success: function (data, status, xhr) { 94 success: function (data, status, xhr) {
96 // delete command is executed.
97 commit(true); 95 commit(true);
96 location.reload( true );
98 }, 97 },
99 error: function (jqXHR, textStatus, errorThrown) { 98 error: function (jqXHR, textStatus, errorThrown) {
100 commit(false); 99 commit(false);
101 } 100 }
102 }); 101 });
109 cache: false, 108 cache: false,
110 data: data, 109 data: data,
111 type: "POST", 110 type: "POST",
112 success: function (data, status, xhr) { 111 success: function (data, status, xhr) {
113 commit(true); 112 commit(true);
113 location.reload( true );
114 }, 114 },
115 error: function(jqXHR, textStatus, errorThrown) { 115 error: function(jqXHR, textStatus, errorThrown) {
116 commit(false); 116 commit(false);
117 } 117 }
118 }); 118 });
124 url: url, 124 url: url,
125 cache: false, 125 cache: false,
126 data: data, 126 data: data,
127 type: "POST", 127 type: "POST",
128 success: function (data, status, xhr) { 128 success: function (data, status, xhr) {
129 // update command is executed.
130 commit(true); 129 commit(true);
130 location.reload( true );
131 }, 131 },
132 error: function(jqXHR, textStatus, errorThrown) { 132 error: function(jqXHR, textStatus, errorThrown) {
133 commit(false); 133 commit(false);
134 } 134 }
135 }); 135 });
136 } 136 }
137 }; 137 },
138 dataAdapter = new $.jqx.dataAdapter(source),
139 editrow = -1;
140
138 // initialize the input fields. 141 // initialize the input fields.
139 $("#name").jqxInput({ theme: theme, width: 640, height: 23 }); 142 $("#name").jqxInput({ theme: theme, width: 640, height: 23 });
140 $("#notes").jqxInput({ theme: theme, width: 800, height: 100 }); 143 $("#notes").jqxInput({ theme: theme, width: 800, height: 100 });
141 144
142 $("#type").jqxDropDownList({theme: theme, 145 $("#type").jqxDropDownList({theme: theme,
164 $("#production_date").jqxDateTimeInput( Dateopts ); 167 $("#production_date").jqxDateTimeInput( Dateopts );
165 $("#cost").jqxNumberInput( Spin2dec ); 168 $("#cost").jqxNumberInput( Spin2dec );
166 $("#tht_date").jqxDateTimeInput( Dateopts ); 169 $("#tht_date").jqxDateTimeInput( Dateopts );
167 $("#totval").jqxNumberInput( Show2dec ); 170 $("#totval").jqxNumberInput( Show2dec );
168 171
169 var dataAdapter = new $.jqx.dataAdapter(source);
170 var editrow = -1;
171 // initialize jqxGrid 172 // initialize jqxGrid
172 $("#jqxgrid").jqxGrid({ 173 $("#jqxgrid").jqxGrid({
173 width: 1280, 174 width: 1280,
174 height: 630, 175 height: 630,
175 source: dataAdapter, 176 source: dataAdapter,
176 theme: theme, 177 theme: theme,
177 showstatusbar: true, 178 showstatusbar: true,
178 renderstatusbar: function (statusbar) { 179 renderstatusbar: function (statusbar) {
179 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); 180 var container, addButton, impButton;
180 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>"); 181 container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
181 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>"); 182 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>");
183 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>");
182 container.append(addButton); 184 container.append(addButton);
183 container.append(impButton); 185 container.append(impButton);
184 statusbar.append(container); 186 statusbar.append(container);
185 addButton.jqxButton({ theme: theme, width: 90, height: 20 }); 187 addButton.jqxButton({ theme: theme, width: 90, height: 20 });
186 impButton.jqxButton({ theme: theme, width: 90, height: 20 }); 188 impButton.jqxButton({ theme: theme, width: 90, height: 20 });
201 $("#production_date").val(''); 203 $("#production_date").val('');
202 $("#tht_date").val(''); 204 $("#tht_date").val('');
203 $("#popupWindow").jqxWindow('open'); 205 $("#popupWindow").jqxWindow('open');
204 }); 206 });
205 impButton.click(function (event) { 207 impButton.click(function (event) {
206 var url="import_ingredients.php?select=miscs"; 208 window.location.href = 'import_ingredients.php?select=miscs';
207 window.location.href = url;
208 }); 209 });
209 }, 210 },
210 filterable: true, 211 filterable: true,
211 filtermode: 'excel', 212 filtermode: 'excel',
212 columns: [ 213 columns: [
252 } 253 }
253 return "<span style='margin: 3px; margin-top: 6px; float: right;'>" + amount + "</span>"; 254 return "<span style='margin: 3px; margin-top: 6px; float: right;'>" + amount + "</span>";
254 } 255 }
255 }, 256 },
256 { text: 'THT datum', datafield: 'tht_date', width: 100, menu: false, align: 'center', cellsalign: 'center' }, 257 { text: 'THT datum', datafield: 'tht_date', width: 100, menu: false, align: 'center', cellsalign: 'center' },
257 { text: '', datafield: 'Edit', columntype: 'button', width: 100, menu: false, align: 'center', cellsrenderer: function () { 258 { text: '', datafield: 'Edit', columntype: 'button', width: 100, menu: false, align: 'center',
258 return "Wijzig"; 259 cellsrenderer: function () {
260 return "Wijzig";
259 }, buttonclick: function (row) { 261 }, buttonclick: function (row) {
260 // open the popup window when the user clicks a button. 262 // open the popup window when the user clicks a button.
261 editrow = row; 263 editrow = row;
262 $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } }); 264 $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } });
263 // get the clicked row's data and initialize the input fields. 265 // get the clicked row's data and initialize the input fields.
328 }); 330 });
329 $("#Cancel").jqxButton({ template: "primary", width: '90px', theme: theme }); 331 $("#Cancel").jqxButton({ template: "primary", width: '90px', theme: theme });
330 $("#Save").jqxButton({ template: "success", width: '90px', theme: theme }); 332 $("#Save").jqxButton({ template: "success", width: '90px', theme: theme });
331 // update the edited row when the user clicks the 'Save' button. 333 // update the edited row when the user clicks the 'Save' button.
332 $("#Save").click(function () { 334 $("#Save").click(function () {
333 var rowID = -1; 335 var row, rowID = -1;
334 if (editrow >= 0) { 336 if (editrow >= 0) {
335 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); 337 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow);
336 } 338 }
337 var row = { 339 row = {
338 record: rowID, 340 record: rowID,
339 name: $("#name").val(), 341 name: $("#name").val(),
340 type: $("#type").val(), 342 type: $("#type").val(),
341 use_use: $("#use_use").val(), 343 use_use: $("#use_use").val(),
342 time: parseFloat($("#time").jqxNumberInput('decimal')), 344 time: parseFloat($("#time").jqxNumberInput('decimal')),
351 }; 353 };
352 if (editrow >= 0) { 354 if (editrow >= 0) {
353 $('#jqxgrid').jqxGrid('updaterow', rowID, row); 355 $('#jqxgrid').jqxGrid('updaterow', rowID, row);
354 } else { 356 } else {
355 $('#jqxgrid').jqxGrid('addrow', null, row); 357 $('#jqxgrid').jqxGrid('addrow', null, row);
356 location.reload( true ); // reload ourself.
357 } 358 }
358 $("#popupWindow").jqxWindow('hide'); 359 $("#popupWindow").jqxWindow('hide');
359 }); 360 });
360 createDelElements(); 361 createDelElements();
361 }); 362 });

mercurial