1 /***************************************************************************** |
1 /***************************************************************************** |
2 * Copyright (C) 2014-2019 |
2 * Copyright (C) 2014-2020 |
3 * |
3 * |
4 * Michiel Broek <mbroek at mbse dot eu> |
4 * Michiel Broek <mbroek at mbse dot eu> |
5 * |
5 * |
6 * This file is part of BrewCloud |
6 * This file is part of Brewery Management System |
7 * |
7 * |
8 * This is free software; you can redistribute it and/or modify it |
8 * This is free software; you can redistribute it and/or modify it |
9 * under the terms of the GNU General Public License as published by the |
9 * under the terms of the GNU General Public License as published by the |
10 * Free Software Foundation; either version 2, or (at your option) any |
10 * Free Software Foundation; either version 2, or (at your option) any |
11 * later version. |
11 * later version. |
92 type: 'POST', |
92 type: 'POST', |
93 success: function(data, status, xhr) { |
93 success: function(data, status, xhr) { |
94 commit(true); |
94 commit(true); |
95 location.reload(true); |
95 location.reload(true); |
96 }, |
96 }, |
97 error: function(jqXHR, textStatus, errorThrown) { |
97 error: function(jqXHR, textStatus, errorThrown) { commit(false); } |
98 commit(false); |
|
99 } |
|
100 }); |
98 }); |
101 }, |
99 }, |
102 addrow: function(rowid, rowdata, position, commit) { |
100 addrow: function(rowid, rowdata, position, commit) { |
103 var data = 'insert=true&' + $.param(rowdata); |
101 var data = 'insert=true&' + $.param(rowdata); |
104 $.ajax({ |
102 $.ajax({ |
109 type: 'POST', |
107 type: 'POST', |
110 success: function(data, status, xhr) { |
108 success: function(data, status, xhr) { |
111 commit(true); |
109 commit(true); |
112 location.reload(true); |
110 location.reload(true); |
113 }, |
111 }, |
114 error: function(jqXHR, textStatus, errorThrown) { |
112 error: function(jqXHR, textStatus, errorThrown) { commit(false); } |
115 commit(false); |
|
116 } |
|
117 }); |
113 }); |
118 }, |
114 }, |
119 updaterow: function(rowid, rowdata, commit) { |
115 updaterow: function(rowid, rowdata, commit) { |
120 var data = 'update=true&' + $.param(rowdata); |
116 var data = 'update=true&' + $.param(rowdata); |
121 $.ajax({ |
117 $.ajax({ |
186 $('#production_date').jqxDateTimeInput(Dateopts); |
180 $('#production_date').jqxDateTimeInput(Dateopts); |
187 $('#cost').jqxNumberInput(Spin2dec); |
181 $('#cost').jqxNumberInput(Spin2dec); |
188 $('#tht_date').jqxDateTimeInput(Dateopts); |
182 $('#tht_date').jqxDateTimeInput(Dateopts); |
189 $('#totval').jqxNumberInput(Show2dec); |
183 $('#totval').jqxNumberInput(Show2dec); |
190 |
184 |
|
185 var localizationobj = {}; |
|
186 localizationobj.filterchoosestring= "Keuze:"; |
|
187 |
191 // initialize jqxGrid |
188 // initialize jqxGrid |
192 $('#jqxgrid').jqxGrid({ |
189 $('#jqxgrid').jqxGrid({ |
193 width: 1280, |
190 width: 1280, |
194 height: 630, |
191 height: 630, |
195 source: dataAdapter, |
192 source: dataAdapter, |
197 showstatusbar: true, |
194 showstatusbar: true, |
198 renderstatusbar: function(statusbar) { |
195 renderstatusbar: function(statusbar) { |
199 var container, addButton, impButton; |
196 var container, addButton, impButton; |
200 container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>'); |
197 container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>'); |
201 addButton = $('<div style="float: right; margin-right: 15px;"><img style="position: relative; margin-top: 2px;" ' + |
198 addButton = $('<div style="float: right; margin-right: 15px;"><img style="position: relative; margin-top: 2px;" ' + |
202 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -3px;">Nieuw</span></div>'); |
199 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -4px;">Nieuw</span></div>'); |
203 impButton = $('<div style="float: right; margin-right: 50px;"><img style="position: relative; margin-top: 2px;" ' + |
200 impButton = $('<div style="float: right; margin-right: 50px;"><img style="position: relative; margin-top: 2px;" ' + |
204 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -3px;">Import</span></div>'); |
201 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -4px;">Import</span></div>'); |
205 expButton = $('<div style="float: right; margin-right: 50px;"><img style="position: relative; margin-top: 2px;" ' + |
202 expButton = $('<div style="float: right; margin-right: 50px;"><img style="position: relative; margin-top: 2px;" ' + |
206 'src="images/database.png"/><span style="margin-left: 4px; position: relative; top: -3px;">Export</span></div>'); |
203 'src="images/database.png"/><span style="margin-left: 4px; position: relative; top: -10px;">Export</span></div>'); |
207 container.append(addButton); |
204 container.append(addButton); |
208 container.append(impButton); |
205 container.append(impButton); |
209 container.append(expButton); |
206 container.append(expButton); |
210 statusbar.append(container); |
207 statusbar.append(container); |
211 addButton.jqxButton({ theme: theme, width: 90, height: 20 }); |
208 addButton.jqxButton({ theme: theme, width: 90, height: 17 }); |
212 impButton.jqxButton({ theme: theme, width: 90, height: 20 }); |
209 impButton.jqxButton({ theme: theme, width: 90, height: 17 }); |
213 expButton.jqxButton({ theme: theme, width: 90, height: 20 }); |
210 expButton.jqxButton({ theme: theme, width: 90, height: 17 }); |
214 // add new row. |
211 // add new row. |
215 addButton.click(function(event) { |
212 addButton.click(function(event) { |
216 editrow = -1; |
213 editrow = -1; |
217 $('#popupWindow').jqxWindow({ position: { x: 110, y: 30 } }); |
214 $('#popupWindow').jqxWindow({ position: { x: 110, y: 30 } }); |
218 $('#name').val('Nieuw product'); |
215 $('#name').val('Nieuw product'); |
246 }); |
243 }); |
247 expButton.click(function(event) { |
244 expButton.click(function(event) { |
248 window.open('export_fermentables.php'); |
245 window.open('export_fermentables.php'); |
249 }); |
246 }); |
250 }, |
247 }, |
|
248 ready: function () { |
|
249 $("#jqxgrid").jqxGrid('localizestrings', localizationobj); |
|
250 }, |
251 filterable: true, |
251 filterable: true, |
252 filtermode: 'excel', |
252 showfilterrow: true, |
253 columns: [ |
253 columns: [ |
254 { text: 'Herkomst', datafield: 'origin', width: 150 }, |
254 { text: 'Herkomst', datafield: 'origin', width: 150, filtertype: 'list' }, |
255 { text: 'Producent', datafield: 'supplier', width: 140 }, |
255 { text: 'Producent', datafield: 'supplier', width: 140, filtertype: 'list' }, |
256 { text: 'Vergistbaar product', datafield: 'name', menu: false }, |
256 { text: 'Vergistbaar product', datafield: 'name', filtertype: 'textbox' }, |
257 { text: 'Soort', width: 135, filtertype: 'list', datafield: 'type' }, |
257 { text: 'Soort', datafield: 'type', width: 135, filtertype: 'list' }, |
258 { text: 'Graan type', datafield: 'graintype', align: 'center', cellsalign: 'center', width: 125 }, |
258 { text: 'Graan type', datafield: 'graintype', width: 125, align: 'center', cellsalign: 'center', filtertype: 'list' }, |
259 { text: 'EBC', datafield: 'color', width: 60, align: 'right', menu: false, cellsalign: 'right' }, |
259 { text: 'EBC', datafield: 'color', width: 70, align: 'right', cellsalign: 'right', filtertype: 'number' }, |
260 { text: 'Opbrengst', datafield: 'yield', width: 70, align: 'right', menu: false, cellsalign: 'right', cellsformat: 'p1' }, |
260 { text: 'Opbrengst', datafield: 'yield', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'p1', filterable: false }, |
261 { text: 'Voorraad', datafield: 'inventory', width: 100, align: 'right', menu: false, |
261 { text: 'Voorraad', datafield: 'inventory', width: 100, align: 'right', filtertype: 'number', filtercondition: 'not_equal', |
262 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
262 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
263 var amount = ''; |
263 var amount = ''; |
264 if (value > 0) { |
264 if (value > 0) { |
265 if (value < 1.000) |
265 if (value < 1.000) |
266 amount = dataAdapter.formatNumber(value * 1000, 'f0') + ' gr'; |
266 amount = dataAdapter.formatNumber(value * 1000, 'f0') + ' gr'; |
268 amount = dataAdapter.formatNumber(value, 'f1') + ' kg'; |
268 amount = dataAdapter.formatNumber(value, 'f1') + ' kg'; |
269 } |
269 } |
270 return '<span style="margin: 3px; margin-top: 6px; float: right;">' + amount + '</span>'; |
270 return '<span style="margin: 3px; margin-top: 6px; float: right;">' + amount + '</span>'; |
271 } |
271 } |
272 }, |
272 }, |
273 { text: '', datafield: 'Edit', width: 100, align: 'center', menu: false, columntype: 'button', |
273 { text: '', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', filterable: false, |
274 cellsrenderer: function() { |
274 cellsrenderer: function() { |
275 return 'Wijzig'; |
275 return 'Wijzig'; |
276 }, buttonclick: function(row) { |
276 }, buttonclick: function(row) { |
277 // open the popup window when the user clicks a button. |
277 // open the popup window when the user clicks a button. |
278 editrow = row; |
278 editrow = row; |