www/js/inv_miscs.js

changeset 701
3ce3df681be0
parent 690
10ff024acff1
child 702
f0896a6f9b64
equal deleted inserted replaced
700:89b7449d1fd9 701:3ce3df681be0
1 /***************************************************************************** 1 /*****************************************************************************
2 * Copyright (C) 2014-2020 2 * Copyright (C) 2014-2020
3 * 3 *
4 * Michiel Broek <mbroek at mbse dot eu> 4 * Michiel Broek <mbroek at mbse dot eu>
5 *
6 * This file is part of Brewery Management System
5 * 7 *
6 * 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
7 * 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
8 * Free Software Foundation; either version 2, or (at your option) any 10 * Free Software Foundation; either version 2, or (at your option) any
9 * later version. 11 * later version.
93 type: 'POST', 95 type: 'POST',
94 success: function(data, status, xhr) { 96 success: function(data, status, xhr) {
95 commit(true); 97 commit(true);
96 location.reload(true); 98 location.reload(true);
97 }, 99 },
98 error: function(jqXHR, textStatus, errorThrown) { 100 error: function(jqXHR, textStatus, errorThrown) { commit(false); }
99 commit(false);
100 }
101 }); 101 });
102 }, 102 },
103 addrow: function(rowid, rowdata, position, commit) { 103 addrow: function(rowid, rowdata, position, commit) {
104 var data = 'insert=true&' + $.param(rowdata); 104 var data = 'insert=true&' + $.param(rowdata);
105 $.ajax({ 105 $.ajax({
110 type: 'POST', 110 type: 'POST',
111 success: function(data, status, xhr) { 111 success: function(data, status, xhr) {
112 commit(true); 112 commit(true);
113 location.reload(true); 113 location.reload(true);
114 }, 114 },
115 error: function(jqXHR, textStatus, errorThrown) { 115 error: function(jqXHR, textStatus, errorThrown) { commit(false); }
116 commit(false);
117 }
118 }); 116 });
119 }, 117 },
120 updaterow: function(rowid, rowdata, commit) { 118 updaterow: function(rowid, rowdata, commit) {
121 var data = 'update=true&' + $.param(rowdata); 119 var data = 'update=true&' + $.param(rowdata);
122 $.ajax({ 120 $.ajax({
127 type: 'POST', 125 type: 'POST',
128 success: function(data, status, xhr) { 126 success: function(data, status, xhr) {
129 commit(true); 127 commit(true);
130 location.reload(true); 128 location.reload(true);
131 }, 129 },
132 error: function(jqXHR, textStatus, errorThrown) { 130 error: function(jqXHR, textStatus, errorThrown) { commit(false); }
133 commit(false);
134 }
135 }); 131 });
136 } 132 }
137 }, 133 },
138 dataAdapter = new $.jqx.dataAdapter(source), 134 dataAdapter = new $.jqx.dataAdapter(source),
139 editrow = -1; 135 editrow = -1;
166 $('#inventory').jqxNumberInput(Spin1dec); 162 $('#inventory').jqxNumberInput(Spin1dec);
167 $('#production_date').jqxDateTimeInput(Dateopts); 163 $('#production_date').jqxDateTimeInput(Dateopts);
168 $('#cost').jqxNumberInput(Spin2dec); 164 $('#cost').jqxNumberInput(Spin2dec);
169 $('#tht_date').jqxDateTimeInput(Dateopts); 165 $('#tht_date').jqxDateTimeInput(Dateopts);
170 $('#totval').jqxNumberInput(Show2dec); 166 $('#totval').jqxNumberInput(Show2dec);
167
168 var localizationobj = {};
169 localizationobj.filterchoosestring= "Keuze:";
171 170
172 // initialize jqxGrid 171 // initialize jqxGrid
173 $('#jqxgrid').jqxGrid({ 172 $('#jqxgrid').jqxGrid({
174 width: 1280, 173 width: 1280,
175 height: 630, 174 height: 630,
177 theme: theme, 176 theme: theme,
178 showstatusbar: true, 177 showstatusbar: true,
179 renderstatusbar: function(statusbar) { 178 renderstatusbar: function(statusbar) {
180 var container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>'); 179 var container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>');
181 var addButton = $('<div style="float: right; margin-right: 15px;"><img style="position: relative; margin-top: 2px;" ' + 180 var addButton = $('<div style="float: right; margin-right: 15px;"><img style="position: relative; margin-top: 2px;" ' +
182 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -3px;">Nieuw</span></div>'); 181 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -4px;">Nieuw</span></div>');
183 var impButton = $('<div style="float: right; margin-right: 50px;"><img style="position: relative; margin-top: 2px;" ' + 182 var impButton = $('<div style="float: right; margin-right: 50px;"><img style="position: relative; margin-top: 2px;" ' +
184 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -3px;">Import</span></div>'); 183 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -4px;">Import</span></div>');
185 var expButton = $('<div style="float: right; margin-right: 50px;"><img style="position: relative; margin-top: 2px;" ' + 184 var expButton = $('<div style="float: right; margin-right: 50px;"><img style="position: relative; margin-top: 2px;" ' +
186 'src="images/database.png"/><span style="margin-left: 4px; position: relative; top: -3px;">Export</span></div>'); 185 'src="images/database.png"/><span style="margin-left: 4px; position: relative; top: -10px;">Export</span></div>');
187 container.append(addButton); 186 container.append(addButton);
188 container.append(impButton); 187 container.append(impButton);
189 container.append(expButton); 188 container.append(expButton);
190 statusbar.append(container); 189 statusbar.append(container);
191 addButton.jqxButton({ theme: theme, width: 90, height: 20 }); 190 addButton.jqxButton({ theme: theme, width: 90, height: 17 });
192 impButton.jqxButton({ theme: theme, width: 90, height: 20 }); 191 impButton.jqxButton({ theme: theme, width: 90, height: 17 });
193 expButton.jqxButton({ theme: theme, width: 90, height: 20 }); 192 expButton.jqxButton({ theme: theme, width: 90, height: 17 });
194 // add new row. 193 // add new row.
195 addButton.click(function(event) { 194 addButton.click(function(event) {
196 editrow = -1; 195 editrow = -1;
197 $('#popupWindow').jqxWindow({ position: { x: 110, y: 30 } }); 196 $('#popupWindow').jqxWindow({ position: { x: 110, y: 30 } });
198 $('#name').val(''); 197 $('#name').val('');
214 }); 213 });
215 expButton.click(function(event) { 214 expButton.click(function(event) {
216 window.open('export_miscs.php'); 215 window.open('export_miscs.php');
217 }); 216 });
218 }, 217 },
218 ready: function () {
219 $("#jqxgrid").jqxGrid('localizestrings', localizationobj);
220 },
219 filterable: true, 221 filterable: true,
220 filtermode: 'excel', 222 showfilterrow: true,
221 columns: [ 223 columns: [
222 { text: 'Ingredient naam', datafield: 'name', menu: false }, 224 { text: 'Ingredient naam', datafield: 'name', filtertype: 'textbox' },
223 { text: 'Type', datafield: 'type', align: 'left', width: 120 }, 225 { text: 'Type', datafield: 'type', align: 'left', width: 120, filtertype: 'list' },
224 { text: 'Gebruik', datafield: 'use_use', align: 'left', width: 120 }, 226 { text: 'Gebruik', datafield: 'use_use', align: 'left', width: 120, filtertype: 'list' },
225 { text: 'Tijd', datafield: 'time', width: 90, align: 'left', menu: false, 227 { text: 'Tijd', datafield: 'time', width: 90, align: 'left', filterable: false,
226 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { 228 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) {
227 var duration = ''; 229 var duration = '';
228 if (value > 0) { 230 if (value > 0) {
229 if (value == 1) 231 if (value == 1)
230 duration = '1 minuut'; 232 duration = '1 minuut';
240 duration = dataAdapter.formatNumber(value / 1440, 'f0') + ' dagen'; 242 duration = dataAdapter.formatNumber(value / 1440, 'f0') + ' dagen';
241 } 243 }
242 return '<span style="margin: 3px; margin-top: 6px; float: left;">' + duration + '</span>'; 244 return '<span style="margin: 3px; margin-top: 6px; float: left;">' + duration + '</span>';
243 } 245 }
244 }, 246 },
245 { text: 'Voorraad', datafield: 'inventory', width: 110, menu: false, align: 'right', 247 { text: 'Voorraad', datafield: 'inventory', width: 110, align: 'right', filtertype: 'number', filtercondition: 'not_equal',
246 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { 248 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) {
247 var amount = ''; 249 var amount = '';
248 if (value > 0) { 250 if (value > 0) {
249 if (rowdata.amount_is_weight) 251 if (rowdata.amount_is_weight)
250 amount = dataAdapter.formatNumber(value, 'f1') + ' gr'; 252 amount = dataAdapter.formatNumber(value, 'f1') + ' gr';
252 amount = dataAdapter.formatNumber(value, 'f1') + ' ml'; 254 amount = dataAdapter.formatNumber(value, 'f1') + ' ml';
253 } 255 }
254 return '<span style="margin: 3px; margin-top: 6px; float: right;">' + amount + '</span>'; 256 return '<span style="margin: 3px; margin-top: 6px; float: right;">' + amount + '</span>';
255 } 257 }
256 }, 258 },
257 { text: 'THT datum', datafield: 'tht_date', width: 100, menu: false, align: 'center', cellsalign: 'center' }, 259 { text: 'THT datum', datafield: 'tht_date', width: 100, align: 'center', cellsalign: 'center', filtertype: 'date' },
258 { text: '', datafield: 'Edit', columntype: 'button', width: 100, menu: false, align: 'center', 260 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', filterable: false,
259 cellsrenderer: function() { 261 cellsrenderer: function() {
260 return 'Wijzig'; 262 return 'Wijzig';
261 }, buttonclick: function(row) { 263 }, buttonclick: function(row) {
262 // open the popup window when the user clicks a button. 264 // open the popup window when the user clicks a button.
263 editrow = row; 265 editrow = row;

mercurial