www/js/inv_fermentables.js

changeset 528
202272a28052
parent 514
3c680d1dea35
child 563
acdd54144838
equal deleted inserted replaced
527:9dfefad3ae1d 528:202272a28052
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 *****************************************************************************/ 21 *****************************************************************************/
22 22
23 23
24 function createDelElements() { 24 function createDelElements() {
25 $('#eventWindow').jqxWindow({ 25 $('#eventWindow').jqxWindow({
26 theme: theme, 26 theme: theme,
27 position: { x: 490, y: 210 }, 27 position: { x: 490, y: 210 },
28 width: 300, 28 width: 300,
29 height: 175, 29 height: 175,
30 resizable: false, 30 resizable: false,
31 isModal: true, 31 isModal: true,
32 modalOpacity: 0.4, 32 modalOpacity: 0.4,
33 okButton: $('#delOk'), 33 okButton: $('#delOk'),
34 cancelButton: $('#delCancel'), 34 cancelButton: $('#delCancel'),
35 initContent: function () { 35 initContent: function() {
36 $('#delOk').jqxButton({ template: "danger", width: '65px', theme: theme }); 36 $('#delOk').jqxButton({ template: 'danger', width: '65px', theme: theme });
37 $('#delCancel').jqxButton({ template: "success", width: '65px', theme: theme }); 37 $('#delCancel').jqxButton({ template: 'success', width: '65px', theme: theme });
38 $('#delCancel').focus(); 38 $('#delCancel').focus();
39 } 39 }
40 }); 40 });
41 $('#eventWindow').jqxWindow('hide'); 41 $('#eventWindow').jqxWindow('hide');
42 } 42 }
43 43
44 44
45 $(document).ready(function () { 45 $(document).ready(function() {
46 46
47 function calcTotal(cost, inventory) { 47 function calcTotal(cost, inventory) {
48 48 $('#totval').val(cost * inventory);
49 $('#totval').val(cost * inventory); 49 }
50 } 50
51 51 var dataRecord = {},
52 var dataRecord = {}, 52 url = 'includes/db_inventory_fermentables.php',
53 url = 'includes/db_inventory_fermentables.php', 53 source = {
54 // prepare the data 54 datatype: 'json',
55 source = { 55 cache: false,
56 datatype: "json", 56 datafields: [
57 cache: false, 57 { name: 'record', type: 'number' },
58 datafields: [ 58 { name: 'name', type: 'string' },
59 { name: 'record', type: 'number' }, 59 { name: 'type', type: 'string' },
60 { name: 'name', type: 'string' }, 60 { name: 'yield', type: 'float' },
61 { name: 'type', type: 'string' }, 61 { name: 'color', type: 'float' },
62 { name: 'yield', type: 'float' }, 62 { name: 'add_after_boil', type: 'int' },
63 { name: 'color', type: 'float' }, 63 { name: 'origin', type: 'string' },
64 { name: 'add_after_boil', type: 'int' }, 64 { name: 'supplier', type: 'string' },
65 { name: 'origin', type: 'string' }, 65 { name: 'notes', type: 'string' },
66 { name: 'supplier', type: 'string' }, 66 { name: 'coarse_fine_diff', type: 'float' },
67 { name: 'notes', type: 'string' }, 67 { name: 'moisture', type: 'float' },
68 { name: 'coarse_fine_diff', type: 'float' }, 68 { name: 'diastatic_power', type: 'float' },
69 { name: 'moisture', type: 'float' }, 69 { name: 'protein', type: 'float' },
70 { name: 'diastatic_power', type: 'float' }, 70 { name: 'dissolved_protein', type: 'float' },
71 { name: 'protein', type: 'float' }, 71 { name: 'max_in_batch', type: 'float' },
72 { name: 'dissolved_protein', type: 'float' }, 72 { name: 'recommend_mash', type: 'int' },
73 { name: 'max_in_batch', type: 'float' }, 73 { name: 'added', type: 'string' },
74 { name: 'recommend_mash', type: 'int' }, 74 { name: 'always_on_stock', type: 'int' },
75 { name: 'added', type: 'string' }, 75 { name: 'di_ph', type: 'float' },
76 { name: 'always_on_stock', type: 'int' }, 76 { name: 'acid_to_ph_57', type: 'float' },
77 { name: 'di_ph', type: 'float' }, 77 { name: 'graintype', type: 'string' },
78 { name: 'acid_to_ph_57', type: 'float' }, 78 { name: 'inventory', type: 'float' },
79 { name: 'graintype', type: 'string' }, 79 { name: 'cost', type: 'float' },
80 { name: 'inventory', type: 'float' }, 80 { name: 'production_date', type: 'string' },
81 { name: 'cost', type: 'float' }, 81 { name: 'tht_date', type: 'string' }
82 { name: 'production_date', type: 'string' }, 82 ],
83 { name: 'tht_date', type: 'string' } 83 id: 'record',
84 ], 84 url: url,
85 id: 'record', 85 deleterow: function(rowid, commit) {
86 url: url, 86 var data = 'delete=true&' + $.param({ record: rowid });
87 deleterow: function (rowid, commit) { 87 $.ajax({
88 // synchronize with the server - send delete command 88 dataType: 'json',
89 var data = "delete=true&" + $.param({ record: rowid }); 89 url: url,
90 $.ajax({ 90 cache: false,
91 dataType: 'json', 91 data: data,
92 url: url, 92 type: 'POST',
93 cache: false, 93 success: function(data, status, xhr) {
94 data: data, 94 commit(true);
95 type: "POST", 95 location.reload(true);
96 success: function (data, status, xhr) { 96 },
97 commit(true); 97 error: function(jqXHR, textStatus, errorThrown) {
98 location.reload( true ); 98 commit(false);
99 }, 99 }
100 error: function (jqXHR, textStatus, errorThrown) { 100 });
101 commit(false); 101 },
102 } 102 addrow: function(rowid, rowdata, position, commit) {
103 }); 103 var data = 'insert=true&' + $.param(rowdata);
104 }, 104 $.ajax({
105 addrow: function (rowid, rowdata, position, commit) { 105 dataType: 'json',
106 var data = "insert=true&" + $.param(rowdata); 106 url: url,
107 $.ajax({ 107 cache: false,
108 dataType: 'json', 108 data: data,
109 url: url, 109 type: 'POST',
110 cache: false, 110 success: function(data, status, xhr) {
111 data: data, 111 commit(true);
112 type: "POST", 112 location.reload(true);
113 success: function (data, status, xhr) { 113 },
114 commit(true); 114 error: function(jqXHR, textStatus, errorThrown) {
115 location.reload( true ); 115 commit(false);
116 }, 116 }
117 error: function(jqXHR, textStatus, errorThrown) { 117 });
118 commit(false); 118 },
119 } 119 updaterow: function(rowid, rowdata, commit) {
120 }); 120 var data = 'update=true&' + $.param(rowdata);
121 }, 121 $.ajax({
122 updaterow: function (rowid, rowdata, commit) { 122 dataType: 'json',
123 var data = "update=true&" + $.param(rowdata); 123 url: url,
124 $.ajax({ 124 cache: false,
125 dataType: 'json', 125 data: data,
126 url: url, 126 type: 'POST',
127 cache: false, 127 success: function(data, status, xhr) {
128 data: data, 128 commit(true);
129 type: "POST", 129 location.reload(true);
130 success: function (data, status, xhr) { 130 },
131 commit(true); 131 error: function(jqXHR, textStatus, errorThrown) {
132 location.reload( true ); 132 commit(false);
133 }, 133 }
134 error: function(jqXHR, textStatus, errorThrown) { 134 });
135 commit(false); 135 }
136 } 136 },
137 }); 137 dataAdapter = new $.jqx.dataAdapter(source),
138 } 138 editrow = -1;
139 }, 139
140 dataAdapter = new $.jqx.dataAdapter(source), 140 // initialize the input fields.
141 editrow = -1; 141 $('#name').jqxInput({ theme: theme, width: 640, height: 23 });
142 142 $('#type').jqxDropDownList({
143 // initialize the input fields. 143 theme: theme,
144 $("#name").jqxInput({ theme: theme, width: 640, height: 23 }); 144 source: FermentableTypeAdapter,
145 $("#type").jqxDropDownList({ 145 valueMember: 'nl',
146 theme: theme, 146 displayMember: 'nl',
147 source: FermentableTypeAdapter, 147 width: 180,
148 valueMember: 'nl', 148 height: 23,
149 displayMember: 'nl', 149 autoDropDownHeight: true
150 width: 180, 150 });
151 height: 23, 151 $('#yield').jqxNumberInput(Spin1dec);
152 autoDropDownHeight: true 152 $('#color').jqxNumberInput(Spin1dec);
153 }); 153 $('#add_after_boil').jqxCheckBox({ theme: theme, width: 120, height: 23 });
154 $("#yield").jqxNumberInput( Spin1dec ); 154 $('#origin').jqxInput({ theme: theme, width: 250, height: 23 });
155 $("#color").jqxNumberInput( Spin1dec ); 155 $('#supplier').jqxInput({ theme: theme, width: 250, height: 23 });
156 $("#add_after_boil").jqxCheckBox({ theme: theme, width: 120, height: 23 }); 156 $('#notes').jqxInput({ theme: theme, width: 640, height: 100 });
157 $("#origin").jqxInput({ theme: theme, width: 250, height: 23 }); 157 $('#coarse_fine_diff').jqxNumberInput(Spin1dec);
158 $("#supplier").jqxInput({ theme: theme, width: 250, height: 23 }); 158 $('#moisture').jqxNumberInput(Spin1dec);
159 $("#notes").jqxInput({ theme: theme, width: 640, height: 100 }); 159 $('#diastatic_power').jqxNumberInput(PosInt);
160 $("#coarse_fine_diff").jqxNumberInput( Spin1dec ); 160 $('#protein').jqxNumberInput(Spin1dec);
161 $("#moisture").jqxNumberInput( Spin1dec ); 161 $('#dissolved_protein').jqxNumberInput(Spin1dec);
162 $("#diastatic_power").jqxNumberInput( PosInt ); 162 $('#max_in_batch').jqxNumberInput(Perc1dec);
163 $("#protein").jqxNumberInput( Spin1dec ); 163 $('#recommend_mash').jqxCheckBox({ theme: theme, width: 120, height: 23 });
164 $("#dissolved_protein").jqxNumberInput( Spin1dec ); 164 $('#added').jqxDropDownList({
165 $("#max_in_batch").jqxNumberInput( Perc1dec ); 165 theme: theme,
166 $("#recommend_mash").jqxCheckBox({ theme: theme, width: 120, height: 23 }); 166 source: AddedAdapter,
167 $("#added").jqxDropDownList({ 167 valueMember: 'nl',
168 theme: theme, 168 displayMember: 'nl',
169 source: AddedAdapter, 169 width: 180,
170 valueMember: 'nl', 170 height: 23,
171 displayMember: 'nl', 171 autoDropDownHeight: true
172 width: 180, 172 });
173 height: 23, 173 $('#always_on_stock').jqxCheckBox({ theme: theme, width: 120, height: 23 });
174 autoDropDownHeight: true 174 $('#di_ph').jqxNumberInput(Spin2pH);
175 }); 175 $('#acid_to_ph_57').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 110, height: 23, min: -1000, max: 1000, decimalDigits: 4, spinButtons: true });
176 $("#always_on_stock").jqxCheckBox({ theme: theme, width: 120, height: 23 }); 176 $('#graintype').jqxDropDownList({
177 $("#di_ph").jqxNumberInput( Spin2pH ); 177 theme: theme,
178 $("#acid_to_ph_57").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 110, height: 23, min: -1000, max: 1000, decimalDigits: 4, spinButtons: true }); 178 source: GrainTypeAdapter,
179 $("#graintype").jqxDropDownList({ 179 valueMember: 'nl',
180 theme: theme, 180 displayMember: 'nl',
181 source: GrainTypeAdapter, 181 width: 180,
182 valueMember: 'nl', 182 height: 23,
183 displayMember: 'nl', 183 autoDropDownHeight: true
184 width: 180, 184 });
185 height: 23, 185 $('#inventory').jqxNumberInput(Spin3dec);
186 autoDropDownHeight: true 186 $('#production_date').jqxDateTimeInput(Dateopts);
187 }); 187 $('#cost').jqxNumberInput(Spin2dec);
188 $("#inventory").jqxNumberInput( Spin3dec ); 188 $('#tht_date').jqxDateTimeInput(Dateopts);
189 $("#production_date").jqxDateTimeInput( Dateopts ); 189 $('#totval').jqxNumberInput(Show2dec);
190 $("#cost").jqxNumberInput( Spin2dec ); 190
191 $("#tht_date").jqxDateTimeInput( Dateopts ); 191 // initialize jqxGrid
192 $("#totval").jqxNumberInput( Show2dec ); 192 $('#jqxgrid').jqxGrid({
193 193 width: 1280,
194 // initialize jqxGrid 194 height: 630,
195 $("#jqxgrid").jqxGrid({ 195 source: dataAdapter,
196 width: 1280, 196 theme: theme,
197 height: 630, 197 showstatusbar: true,
198 source: dataAdapter, 198 renderstatusbar: function(statusbar) {
199 theme: theme, 199 var container, addButton, impButton;
200 showstatusbar: true, 200 container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>');
201 renderstatusbar: function (statusbar) { 201 addButton = $('<div style="float: right; margin-right: 15px;"><img style="position: relative; margin-top: 2px;" ' +
202 var container, addButton, impButton; 202 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -3px;">Nieuw</span></div>');
203 container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); 203 impButton = $('<div style="float: right; margin-right: 50px;"><img style="position: relative; margin-top: 2px;" ' +
204 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>"); 204 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -3px;">Import</span></div>');
205 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>"); 205 container.append(addButton);
206 container.append(addButton); 206 container.append(impButton);
207 container.append(impButton); 207 statusbar.append(container);
208 statusbar.append(container); 208 addButton.jqxButton({ theme: theme, width: 90, height: 20 });
209 addButton.jqxButton({ theme: theme, width: 90, height: 20 }); 209 impButton.jqxButton({ theme: theme, width: 90, height: 20 });
210 impButton.jqxButton({ theme: theme, width: 90, height: 20 }); 210 // add new row.
211 // add new row. 211 addButton.click(function(event) {
212 addButton.click(function (event) { 212 editrow = -1;
213 editrow = -1; 213 $('#popupWindow').jqxWindow({ position: { x: 110, y: 30 } });
214 $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } }); 214 $('#name').val('Nieuw product');
215 $("#name").val('Nieuw product'); 215 $('#type').val('Mout');
216 $("#type").val('Mout'); 216 $('#origin').val('');
217 $("#origin").val(''); 217 $('#supplier').val('');
218 $("#supplier").val(''); 218 $('#notes').val('');
219 $("#notes").val(''); 219 $('#yield').val(80);
220 $("#yield").val(80); 220 $('#color').val(3);
221 $("#color").val(3); 221 $('#coarse_fine_diff').val(3);
222 $("#coarse_fine_diff").val(3); 222 $('#moisture').val(4);
223 $("#moisture").val(4); 223 $('#diastatic_power').val(0);
224 $("#diastatic_power").val(0); 224 $('#protein').val(0);
225 $("#protein").val(0); 225 $('#dissolved_protein').val(0);
226 $("#dissolved_protein").val(0); 226 $('#max_in_batch').val(100);
227 $("#max_in_batch").val(100); 227 $('#recommend_mash').val(1);
228 $("#recommend_mash").val(1); 228 $('#always_on_stock').val(0);
229 $("#always_on_stock").val(0); 229 $('#di_ph').val(0);
230 $("#di_ph").val(0); 230 $('#acid_to_ph_57').val(0);
231 $("#acid_to_ph_57").val(0); 231 $('#graintype').val('Basismout');
232 $("#graintype").val('Basismout'); 232 $('#add_after_boil').val(0);
233 $("#add_after_boil").val(0); 233 $('#added').val('Maischen');
234 $("#added").val('Maischen'); 234 $('#inventory').val(0);
235 $("#inventory").val(0); 235 $('#cost').val(0);
236 $("#cost").val(0); 236 $('#production_date').val('');
237 $("#production_date").val(''); 237 $('#tht_date').val('');
238 $("#tht_date").val(''); 238 $('#popupWindow').jqxWindow('open');
239 $("#popupWindow").jqxWindow('open'); 239 });
240 }); 240 impButton.click(function(event) {
241 impButton.click(function (event) { 241 window.location.href = 'import_ingredients.php?select=fermentables';
242 window.location.href = 'import_ingredients.php?select=fermentables'; 242 });
243 }); 243 },
244 }, 244 filterable: true,
245 filterable: true, 245 filtermode: 'excel',
246 filtermode: 'excel', 246 columns: [
247 columns: [ 247 { text: 'Herkomst', datafield: 'origin', width: 150 },
248 { text: 'Herkomst', datafield: 'origin', width: 150 }, 248 { text: 'Producent', datafield: 'supplier', width: 140 },
249 { text: 'Producent', datafield: 'supplier', width: 140 }, 249 { text: 'Vergistbaar product', datafield: 'name', menu: false },
250 { text: 'Vergistbaar product', datafield: 'name', menu: false }, 250 { text: 'Soort', width: 135, filtertype: 'list', datafield: 'type' },
251 { text: 'Soort', width: 135, filtertype: 'list', datafield: 'type' }, 251 { text: 'Graan type', datafield: 'graintype', align: 'center', cellsalign: 'center', width: 125 },
252 { text: 'Graan type', datafield: 'graintype', align: 'center', cellsalign: 'center', width: 125 }, 252 { text: 'EBC', datafield: 'color', width: 60, align: 'right', menu: false, cellsalign: 'right' },
253 { text: 'EBC', datafield: 'color', width: 60, align: 'right', menu: false, cellsalign: 'right' }, 253 { text: 'Opbrengst', datafield: 'yield', width: 70, align: 'right', menu: false, cellsalign: 'right', cellsformat: 'p1' },
254 { text: 'Opbrengst', datafield: 'yield', width: 70, align: 'right', menu: false, cellsalign: 'right', cellsformat: 'p1' }, 254 { text: 'Voorraad', datafield: 'inventory', width: 100, align: 'right', menu: false,
255 { text: 'Voorraad', datafield: 'inventory', width: 100, align: 'right', menu: false, 255 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) {
256 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { 256 var amount = '';
257 var amount = ""; 257 if (value > 0) {
258 if (value > 0) { 258 if (value < 1.000)
259 if (value < 1.000) 259 amount = dataAdapter.formatNumber(value * 1000, 'f0') + ' gr';
260 amount = dataAdapter.formatNumber(value * 1000,"f0")+" gr"; 260 else
261 else 261 amount = dataAdapter.formatNumber(value, 'f1') + ' kg';
262 amount = dataAdapter.formatNumber(value,"f1")+" kg"; 262 }
263 } 263 return '<span style="margin: 3px; margin-top: 6px; float: right;">' + amount + '</span>';
264 return "<span style='margin: 3px; margin-top: 6px; float: right;'>" + amount + "</span>"; 264 }
265 } 265 },
266 }, 266 { text: '', datafield: 'Edit', width: 100, align: 'center', menu: false, columntype: 'button',
267 { text: '', datafield: 'Edit', width: 100, align: 'center', menu: false, columntype: 'button', 267 cellsrenderer: function() {
268 cellsrenderer: function () { 268 return 'Wijzig';
269 return "Wijzig"; 269 }, buttonclick: function(row) {
270 }, buttonclick: function (row) { 270 // open the popup window when the user clicks a button.
271 // open the popup window when the user clicks a button. 271 editrow = row;
272 editrow = row; 272 $('#popupWindow').jqxWindow({ position: { x: 110, y: 30 } });
273 $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } }); 273 // get the clicked row's data and initialize the input fields.
274 // get the clicked row's data and initialize the input fields. 274 dataRecord = $('#jqxgrid').jqxGrid('getrowdata', editrow);
275 dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); 275 $('#name').val(dataRecord.name);
276 $("#name").val(dataRecord.name); 276 $('#type').val(dataRecord.type);
277 $("#type").val(dataRecord.type); 277 $('#yield').val(dataRecord.yield);
278 $("#yield").val(dataRecord.yield); 278 $('#color').val(dataRecord.color);
279 $("#color").val(dataRecord.color); 279 $('#add_after_boil').val(dataRecord.add_after_boil);
280 $("#add_after_boil").val(dataRecord.add_after_boil); 280 $('#origin').val(dataRecord.origin);
281 $("#origin").val(dataRecord.origin); 281 $('#supplier').val(dataRecord.supplier);
282 $("#supplier").val(dataRecord.supplier); 282 $('#notes').val(dataRecord.notes);
283 $("#notes").val(dataRecord.notes); 283 $('#coarse_fine_diff').val(dataRecord.coarse_fine_diff);
284 $("#coarse_fine_diff").val(dataRecord.coarse_fine_diff); 284 $('#moisture').val(dataRecord.moisture);
285 $("#moisture").val(dataRecord.moisture); 285 $('#diastatic_power').val(lintner_to_kolbach(dataRecord.diastatic_power));
286 $("#diastatic_power").val(lintner_to_kolbach(dataRecord.diastatic_power)); 286 $('#protein').val(dataRecord.protein);
287 $("#protein").val(dataRecord.protein); 287 $('#dissolved_protein').val(dataRecord.dissolved_protein);
288 $("#dissolved_protein").val(dataRecord.dissolved_protein); 288 $('#max_in_batch').val(dataRecord.max_in_batch);
289 $("#max_in_batch").val(dataRecord.max_in_batch); 289 $('#recommend_mash').val(dataRecord.recommend_mash);
290 $("#recommend_mash").val(dataRecord.recommend_mash); 290 $('#added').val(dataRecord.added);
291 $("#added").val(dataRecord.added); 291 $('#always_on_stock').val(dataRecord.always_on_stock);
292 $("#always_on_stock").val(dataRecord.always_on_stock); 292 $('#di_ph').val(dataRecord.di_ph);
293 $("#di_ph").val(dataRecord.di_ph); 293 $('#acid_to_ph_57').val(dataRecord.acid_to_ph_57);
294 $("#acid_to_ph_57").val(dataRecord.acid_to_ph_57); 294 $('#graintype').val(dataRecord.graintype);
295 $("#graintype").val(dataRecord.graintype); 295 $('#inventory').val(dataRecord.inventory);
296 $("#inventory").val(dataRecord.inventory); 296 $('#cost').val(dataRecord.cost);
297 $("#cost").val(dataRecord.cost); 297 $('#production_date').val(dataRecord.production_date);
298 $("#production_date").val(dataRecord.production_date); 298 $('#tht_date').val(dataRecord.tht_date);
299 $("#tht_date").val(dataRecord.tht_date); 299 calcTotal(dataRecord.cost, dataRecord.inventory);
300 calcTotal(dataRecord.cost, dataRecord.inventory); 300 // show the popup window.
301 // show the popup window. 301 $('#popupWindow').jqxWindow('open');
302 $("#popupWindow").jqxWindow('open'); 302 }
303 } 303 }
304 } 304 ]
305 ] 305 });
306 }); 306
307 307 $('#cost').on('change', function(event) {
308 $("#cost").on('change', function (event) { 308 dataRecord.cost = parseFloat(event.args.value);
309 dataRecord.cost = parseFloat(event.args.value); 309 calcTotal(dataRecord.cost, dataRecord.inventory);
310 calcTotal(dataRecord.cost, dataRecord.inventory); 310 });
311 }); 311 $('#inventory').on('change', function(event) {
312 $("#inventory").on('change', function (event) { 312 dataRecord.inventory = parseFloat(event.args.value);
313 dataRecord.inventory = parseFloat(event.args.value); 313 calcTotal(dataRecord.cost, dataRecord.inventory);
314 calcTotal(dataRecord.cost, dataRecord.inventory); 314 });
315 }); 315
316 316 // initialize the popup window and buttons.
317 // initialize the popup window and buttons. 317 $('#popupWindow').jqxWindow({
318 $("#popupWindow").jqxWindow({ 318 width: 1050,
319 width: 1050, 319 height: 550,
320 height: 550, 320 resizable: false,
321 resizable: false, 321 theme: theme,
322 theme: theme, 322 isModal: true,
323 isModal: true, 323 autoOpen: false,
324 autoOpen: false, 324 cancelButton: $('#Cancel'),
325 cancelButton: $("#Cancel"), 325 modalOpacity: 0.40
326 modalOpacity: 0.40 326 });
327 }); 327 $('#popupWindow').on('open', function() {
328 $("#popupWindow").on('open', function () { 328 $('#name').jqxInput('selectAll');
329 $("#name").jqxInput('selectAll'); 329 });
330 }); 330 $('#Delete').jqxButton({ template: 'danger', width: '90px', theme: theme });
331 $("#Delete").jqxButton({ template: "danger", width: '90px', theme: theme }); 331 $('#Delete').click(function() {
332 $("#Delete").click(function() { 332 if (editrow >= 0) {
333 if (editrow >= 0) { 333 // Open a popup to confirm this action.
334 // Open a popup to confirm this action. 334 $('#eventWindow').jqxWindow('open');
335 $('#eventWindow').jqxWindow('open'); 335 $('#delOk').click(function() {
336 $("#delOk").click(function () { 336 var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow);
337 var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); 337 $('#jqxgrid').jqxGrid('deleterow', rowID);
338 $("#jqxgrid").jqxGrid('deleterow', rowID); 338 });
339 }); 339 }
340 } 340 $('#popupWindow').jqxWindow('hide');
341 $("#popupWindow").jqxWindow('hide'); 341 });
342 }); 342 $('#Cancel').jqxButton({ template: 'primary', width: '90px', theme: theme });
343 $('#Cancel').jqxButton({ template: 'primary', width: '90px', theme: theme }); 343 $('#Clone').jqxButton({ template: 'warning', width: '90px', theme: theme });
344 $('#Clone').jqxButton({ template: 'warning', width: '90px', theme: theme }); 344 $('#Clone').click(function() {
345 $('#Clone').click(function() { 345 var row = {
346 var row = { 346 record: -1,
347 record: -1, 347 name: $('#name').val() + ' kopie',
348 name: $('#name').val() + ' kopie', 348 type: $('#type').val(),
349 type: $('#type').val(), 349 yield: parseFloat($('#yield').jqxNumberInput('decimal')),
350 yield: parseFloat($('#yield').jqxNumberInput('decimal')), 350 color: parseFloat($('#color').jqxNumberInput('decimal')),
351 color: parseFloat($('#color').jqxNumberInput('decimal')), 351 add_after_boil: $('#add_after_boil').val(),
352 add_after_boil: $('#add_after_boil').val(), 352 origin: $('#origin').val(),
353 origin: $('#origin').val(), 353 supplier: $('#supplier').val(),
354 supplier: $('#supplier').val(), 354 notes: $('#notes').val(),
355 notes: $('#notes').val(), 355 coarse_fine_diff: parseFloat($('#coarse_fine_diff').jqxNumberInput('decimal')),
356 coarse_fine_diff: parseFloat($('#coarse_fine_diff').jqxNumberInput('decimal')), 356 moisture: parseFloat($('#moisture').jqxNumberInput('decimal')),
357 moisture: parseFloat($('#moisture').jqxNumberInput('decimal')), 357 diastatic_power: kolbach_to_lintner(parseFloat($('#diastatic_power').jqxNumberInput('decimal'))),
358 diastatic_power: kolbach_to_lintner(parseFloat($('#diastatic_power').jqxNumberInput('decimal'))), 358 protein: parseFloat($('#protein').jqxNumberInput('decimal')),
359 protein: parseFloat($('#protein').jqxNumberInput('decimal')), 359 dissolved_protein: parseFloat($('#dissolved_protein').jqxNumberInput('decimal')),
360 dissolved_protein: parseFloat($('#dissolved_protein').jqxNumberInput('decimal')), 360 max_in_batch: parseFloat($('#max_in_batch').jqxNumberInput('decimal')),
361 max_in_batch: parseFloat($('#max_in_batch').jqxNumberInput('decimal')), 361 recommend_mash: $('#recommend_mash').val(),
362 recommend_mash: $('#recommend_mash').val(), 362 added: $('#added').val(),
363 added: $('#added').val(), 363 always_on_stock: $('#always_on_stock').val(),
364 always_on_stock: $('#always_on_stock').val(), 364 di_ph: parseFloat($('#di_ph').jqxNumberInput('decimal')),
365 di_ph: parseFloat($('#di_ph').jqxNumberInput('decimal')), 365 acid_to_ph_57: parseFloat($('#acid_to_ph_57').jqxNumberInput('decimal')),
366 acid_to_ph_57: parseFloat($('#acid_to_ph_57').jqxNumberInput('decimal')), 366 graintype: $('#graintype').val(),
367 graintype: $('#graintype').val(), 367 inventory: 0,
368 inventory: 0, 368 cost: parseFloat($('#cost').jqxNumberInput('decimal')),
369 cost: parseFloat($('#cost').jqxNumberInput('decimal')), 369 production_date: '',
370 production_date: '', 370 tht_date: ''
371 tht_date: '' 371 };
372 }; 372 $('#jqxgrid').jqxGrid('addrow', null, row);
373 $('#jqxgrid').jqxGrid('addrow', null, row); 373 $('#popupWindow').jqxWindow('hide');
374 $('#popupWindow').jqxWindow('hide'); 374 });
375 }); 375 $('#Save').jqxButton({ template: 'success', width: '90px', theme: theme });
376 $("#Save").jqxButton({ template: "success", width: '90px', theme: theme }); 376 // update the edited row when the user clicks the 'Save' button.
377 // update the edited row when the user clicks the 'Save' button. 377 $('#Save').click(function() {
378 $("#Save").click(function() { 378 var row, rowID = -1;
379 var row, rowID = -1; 379 if (editrow >= 0) {
380 if (editrow >= 0) { 380 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow);
381 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); 381 }
382 } 382 row = {
383 row = { 383 record: rowID,
384 record: rowID, 384 name: $('#name').val(),
385 name: $("#name").val(), 385 type: $('#type').val(),
386 type: $("#type").val(), 386 yield: parseFloat($('#yield').jqxNumberInput('decimal')),
387 yield: parseFloat($("#yield").jqxNumberInput('decimal')), 387 color: parseFloat($('#color').jqxNumberInput('decimal')),
388 color: parseFloat($("#color").jqxNumberInput('decimal')), 388 add_after_boil: $('#add_after_boil').val(),
389 add_after_boil: $("#add_after_boil").val(), 389 origin: $('#origin').val(),
390 origin: $("#origin").val(), 390 supplier: $('#supplier').val(),
391 supplier: $("#supplier").val(), 391 notes: $('#notes').val(),
392 notes: $("#notes").val(), 392 coarse_fine_diff: parseFloat($('#coarse_fine_diff').jqxNumberInput('decimal')),
393 coarse_fine_diff: parseFloat($("#coarse_fine_diff").jqxNumberInput('decimal')), 393 moisture: parseFloat($('#moisture').jqxNumberInput('decimal')),
394 moisture: parseFloat($("#moisture").jqxNumberInput('decimal')), 394 diastatic_power: kolbach_to_lintner(parseFloat($('#diastatic_power').jqxNumberInput('decimal'))),
395 diastatic_power: kolbach_to_lintner(parseFloat($("#diastatic_power").jqxNumberInput('decimal'))), 395 protein: parseFloat($('#protein').jqxNumberInput('decimal')),
396 protein: parseFloat($("#protein").jqxNumberInput('decimal')), 396 dissolved_protein: parseFloat($('#dissolved_protein').jqxNumberInput('decimal')),
397 dissolved_protein: parseFloat($("#dissolved_protein").jqxNumberInput('decimal')), 397 max_in_batch: parseFloat($('#max_in_batch').jqxNumberInput('decimal')),
398 max_in_batch: parseFloat($("#max_in_batch").jqxNumberInput('decimal')), 398 recommend_mash: $('#recommend_mash').val(),
399 recommend_mash: $("#recommend_mash").val(), 399 added: $('#added').val(),
400 added: $("#added").val(), 400 always_on_stock: $('#always_on_stock').val(),
401 always_on_stock: $("#always_on_stock").val(), 401 di_ph: parseFloat($('#di_ph').jqxNumberInput('decimal')),
402 di_ph: parseFloat($("#di_ph").jqxNumberInput('decimal')), 402 acid_to_ph_57: parseFloat($('#acid_to_ph_57').jqxNumberInput('decimal')),
403 acid_to_ph_57: parseFloat($("#acid_to_ph_57").jqxNumberInput('decimal')), 403 graintype: $('#graintype').val(),
404 graintype: $("#graintype").val(), 404 inventory: parseFloat($('#inventory').jqxNumberInput('decimal')),
405 inventory: parseFloat($("#inventory").jqxNumberInput('decimal')), 405 cost: parseFloat($('#cost').jqxNumberInput('decimal')),
406 cost: parseFloat($("#cost").jqxNumberInput('decimal')), 406 production_date: $('#production_date').val(),
407 production_date: $("#production_date").val(), 407 tht_date: $('#tht_date').val(),
408 tht_date: $("#tht_date").val(), 408 };
409 }; 409 if (editrow >= 0) {
410 if (editrow >= 0) { 410 $('#jqxgrid').jqxGrid('updaterow', rowID, row);
411 $('#jqxgrid').jqxGrid('updaterow', rowID, row); 411 } else {
412 } else { 412 $('#jqxgrid').jqxGrid('addrow', null, row);
413 $('#jqxgrid').jqxGrid('addrow', null, row); 413 }
414 } 414 $('#popupWindow').jqxWindow('hide');
415 $("#popupWindow").jqxWindow('hide'); 415 });
416 }); 416 createDelElements();
417 createDelElements();
418 }); 417 });
419 418

mercurial