www/js/inv_hops.js

changeset 701
3ce3df681be0
parent 563
acdd54144838
child 702
f0896a6f9b64
equal deleted inserted replaced
700:89b7449d1fd9 701:3ce3df681be0
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.
87 type: 'POST', 87 type: 'POST',
88 success: function(data, status, xhr) { 88 success: function(data, status, xhr) {
89 commit(true); 89 commit(true);
90 location.reload(true); 90 location.reload(true);
91 }, 91 },
92 error: function(jqXHR, textStatus, errorThrown) { 92 error: function(jqXHR, textStatus, errorThrown) { commit(false); }
93 commit(false);
94 }
95 }); 93 });
96 }, 94 },
97 addrow: function(rowid, rowdata, position, commit) { 95 addrow: function(rowid, rowdata, position, commit) {
98 var data = 'insert=true&' + $.param(rowdata); 96 var data = 'insert=true&' + $.param(rowdata);
99 $.ajax({ 97 $.ajax({
104 type: 'POST', 102 type: 'POST',
105 success: function(data, status, xhr) { 103 success: function(data, status, xhr) {
106 commit(true); 104 commit(true);
107 location.reload(true); 105 location.reload(true);
108 }, 106 },
109 error: function(jqXHR, textStatus, errorThrown) { 107 error: function(jqXHR, textStatus, errorThrown) { commit(false); }
110 commit(false);
111 }
112 }); 108 });
113 }, 109 },
114 updaterow: function(rowid, rowdata, commit) { 110 updaterow: function(rowid, rowdata, commit) {
115 var data = 'update=true&' + $.param(rowdata); 111 var data = 'update=true&' + $.param(rowdata);
116 $.ajax({ 112 $.ajax({
121 type: 'POST', 117 type: 'POST',
122 success: function(data, status, xhr) { 118 success: function(data, status, xhr) {
123 commit(true); 119 commit(true);
124 location.reload(true); 120 location.reload(true);
125 }, 121 },
126 error: function(jqXHR, textStatus, errorThrown) { 122 error: function(jqXHR, textStatus, errorThrown) { commit(false); }
127 commit(false);
128 }
129 }); 123 });
130 } 124 }
131 }, 125 },
132 dataAdapter = new $.jqx.dataAdapter(source), 126 dataAdapter = new $.jqx.dataAdapter(source),
133 editrow = -1; 127 editrow = -1;
169 $('#cost').jqxNumberInput(Spin2dec); 163 $('#cost').jqxNumberInput(Spin2dec);
170 $('#tht_date').jqxDateTimeInput(Dateopts); 164 $('#tht_date').jqxDateTimeInput(Dateopts);
171 $('#total_oil').jqxNumberInput(Perc1dec); 165 $('#total_oil').jqxNumberInput(Perc1dec);
172 $('#totval').jqxNumberInput(Show2dec); 166 $('#totval').jqxNumberInput(Show2dec);
173 167
168 var localizationobj = {};
169 localizationobj.filterchoosestring= "Keuze:";
170
174 // initialize jqxGrid 171 // initialize jqxGrid
175 $('#jqxgrid').jqxGrid({ 172 $('#jqxgrid').jqxGrid({
176 width: 1280, 173 width: 1280,
177 height: 630, 174 height: 630,
178 source: dataAdapter, 175 source: dataAdapter,
180 showstatusbar: true, 177 showstatusbar: true,
181 renderstatusbar: function(statusbar) { 178 renderstatusbar: function(statusbar) {
182 var container, addButton, impButton; 179 var container, addButton, impButton;
183 container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>'); 180 container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>');
184 addButton = $('<div style="float: right; margin-right: 15px;"><img style="position: relative; margin-top: 2px;" ' + 181 addButton = $('<div style="float: right; margin-right: 15px;"><img style="position: relative; margin-top: 2px;" ' +
185 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -3px;">Nieuw</span></div>'); 182 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -4px;">Nieuw</span></div>');
186 impButton = $('<div style="float: right; margin-right: 50px;"><img style="position: relative; margin-top: 2px;" ' + 183 impButton = $('<div style="float: right; margin-right: 50px;"><img style="position: relative; margin-top: 2px;" ' +
187 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -3px;">Import</span></div>'); 184 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -4px;">Import</span></div>');
188 expButton = $('<div style="float: right; margin-right: 50px;"><img style="position: relative; margin-top: 2px;" ' + 185 expButton = $('<div style="float: right; margin-right: 50px;"><img style="position: relative; margin-top: 2px;" ' +
189 'src="images/database.png"/><span style="margin-left: 4px; position: relative; top: -3px;">Export</span></div>'); 186 'src="images/database.png"/><span style="margin-left: 4px; position: relative; top: -10px;">Export</span></div>');
190 container.append(addButton); 187 container.append(addButton);
191 container.append(impButton); 188 container.append(impButton);
192 container.append(expButton); 189 container.append(expButton);
193 statusbar.append(container); 190 statusbar.append(container);
194 addButton.jqxButton({ theme: theme, width: 90, height: 20 }); 191 addButton.jqxButton({ theme: theme, width: 90, height: 17 });
195 impButton.jqxButton({ theme: theme, width: 90, height: 20 }); 192 impButton.jqxButton({ theme: theme, width: 90, height: 17 });
196 expButton.jqxButton({ theme: theme, width: 90, height: 20 }); 193 expButton.jqxButton({ theme: theme, width: 90, height: 17 });
197 // add new row. 194 // add new row.
198 addButton.click(function(event) { 195 addButton.click(function(event) {
199 editrow = -1; 196 editrow = -1;
200 $('#popupWindow').jqxWindow({ position: { x: 110, y: 30 } }); 197 $('#popupWindow').jqxWindow({ position: { x: 110, y: 30 } });
201 $('#name').val('Nieuwe hop'); 198 $('#name').val('Nieuwe hop');
224 }); 221 });
225 expButton.click(function(event) { 222 expButton.click(function(event) {
226 window.open('export_hops.php'); 223 window.open('export_hops.php');
227 }); 224 });
228 }, 225 },
226 ready: function () {
227 $("#jqxgrid").jqxGrid('localizestrings', localizationobj);
228 },
229 filterable: true, 229 filterable: true,
230 filtermode: 'excel', 230 showfilterrow: true,
231 columns: [ 231 columns: [
232 { text: 'Herkomst', datafield: 'origin', width: 150 }, 232 { text: 'Herkomst', datafield: 'origin', width: 150, filtertype: 'list' },
233 { text: 'Hop Naam', datafield: 'name', menu: false }, 233 { text: 'Hop Naam', datafield: 'name', filtertype: 'textbox' },
234 { text: 'Soort', datafield: 'type', align: 'left', width: 90 }, 234 { text: 'Soort', datafield: 'type', align: 'left', width: 90, filtertype: 'list' },
235 { text: 'Vorm', datafield: 'form', align: 'left', width: 90 }, 235 { text: 'Vorm', datafield: 'form', align: 'left', width: 90, filtertype: 'list' },
236 { text: 'Alpha %', datafield: 'alpha', width: 80, align: 'right', cellsalign: 'right', menu: false, cellsformat: 'p1' }, 236 { text: 'Alpha %', datafield: 'alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1', filtertype: 'number' },
237 { text: 'Beta %', datafield: 'beta', width: 80, align: 'right', cellsalign: 'right', menu: false, cellsformat: 'p1' }, 237 { text: 'Beta %', datafield: 'beta', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1', filtertype: 'number' },
238 { text: 'Cohumuloon %%', datafield: 'cohumulone', width: 80, align: 'right', cellsalign: 'right', menu: false, cellsformat: 'p1' }, 238 { text: 'Cohumuloon %%', datafield: 'cohumulone', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1', filterable: false },
239 { text: 'HSI', datafield: 'hsi', width: 60, align: 'right', cellsalign: 'right', menu: false, cellsformat: 'f1' }, 239 { text: 'HSI', datafield: 'hsi', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f1', filterable: false },
240 { text: 'Oogst datum', datafield: 'production_date', align: 'center', cellsalign: 'center', menu: false, width: 110 }, 240 { text: 'Oogst datum', datafield: 'production_date', align: 'center', cellsalign: 'center', width: 110, filtertype: 'date' },
241 { text: 'Voorraad', datafield: 'inventory', width: 100, align: 'right', cellsalign: 'right', menu: false, cellsformat: 'f1', 241 { text: 'Voorraad', datafield: 'inventory', width: 100, align: 'right', filtertype: 'number', filtercondition: 'not_equal',
242 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { 242 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) {
243 var amount = ''; 243 var amount = '';
244 if (value > 0) { 244 if (value > 0) {
245 if (value < 1000) 245 if (value < 1000)
246 amount = dataAdapter.formatNumber(value, 'f1') + ' gr'; 246 amount = dataAdapter.formatNumber(value, 'f1') + ' gr';
248 amount = dataAdapter.formatNumber(value / 1000.0, 'f1') + ' kg'; 248 amount = dataAdapter.formatNumber(value / 1000.0, 'f1') + ' kg';
249 } 249 }
250 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + amount + '</span>'; 250 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + amount + '</span>';
251 } 251 }
252 }, 252 },
253 { text: '', datafield: 'Wijzig', columntype: 'button', width: 100, align: 'center', menu: false, 253 { text: '', datafield: 'Wijzig', columntype: 'button', width: 100, align: 'center', filterable: false,
254 cellsrenderer: function() { 254 cellsrenderer: function() {
255 return 'Wijzig'; 255 return 'Wijzig';
256 }, buttonclick: function(row) { 256 }, buttonclick: function(row) {
257 // open the popup window when the user clicks a button. 257 // open the popup window when the user clicks a button.
258 editrow = row; 258 editrow = row;

mercurial