www/js/inv_fermentables.js

changeset 18
395833e20f88
parent 11
d341f0a91a91
child 30
f5ab22446aa5
equal deleted inserted replaced
17:bb97e0de63cf 18:395833e20f88
70 { name: 'acid_to_ph_57', type: 'float' }, 70 { name: 'acid_to_ph_57', type: 'float' },
71 { name: 'graintype', type: 'string' }, 71 { name: 'graintype', type: 'string' },
72 { name: 'inventory', type: 'float' }, 72 { name: 'inventory', type: 'float' },
73 { name: 'cost', type: 'float' }, 73 { name: 'cost', type: 'float' },
74 { name: 'production_date', type: 'string' }, 74 { name: 'production_date', type: 'string' },
75 { name: 'tht_date', type: 'string' }, 75 { name: 'tht_date', type: 'string' }
76 { name: 'supplier_rec', type: 'float' }
77 ], 76 ],
78 id: 'record', 77 id: 'record',
79 url: url, 78 url: url,
80 deleterow: function (rowid, commit) { 79 deleterow: function (rowid, commit) {
81 // synchronize with the server - send delete command 80 // synchronize with the server - send delete command
125 } 124 }
126 }); 125 });
127 } 126 }
128 }; 127 };
129 var srcType = [ "Grain", "Sugar", "Extract", "Dry Extract", "Adjunct" ]; 128 var srcType = [ "Grain", "Sugar", "Extract", "Dry Extract", "Adjunct" ];
129 var srcGraintype = [ "Base", "Crystal", "Special", "Roast", "Kilned", "No malt" ];
130 // initialize the input fields. 130 // initialize the input fields.
131 $("#name").jqxInput({ theme: theme, width: 250, height: 23 }); 131 $("#name").jqxInput({ theme: theme, width: 250, height: 23 });
132 $("#type").jqxDropDownList({ theme: theme, source: srcType, width: 90, height: 23, dropDownHeight: 130 }); 132 $("#type").jqxDropDownList({ theme: theme, source: srcType, width: 100, height: 23, dropDownHeight: 156 });
133 $("#yield").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); 133 $("#yield").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true });
134 $("#color").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); 134 $("#color").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true });
135 $("#add_after_boil").jqxCheckBox({ theme: theme, width: 120, height: 23 }); 135 $("#add_after_boil").jqxCheckBox({ theme: theme, width: 120, height: 23 });
136 $("#origin").jqxInput({ theme: theme, width: 250, height: 23 }); 136 $("#origin").jqxInput({ theme: theme, width: 250, height: 23 });
137 $("#supplier").jqxInput({ theme: theme, width: 250, height: 23 }); 137 $("#supplier").jqxInput({ theme: theme, width: 250, height: 23 });
138 $("#notes").jqxInput({ theme: theme, width: 640, height: 48 }); 138 $("#notes").jqxInput({ theme: theme, width: 640, height: 100 });
139 $("#coarse_fine_diff").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); 139 $("#coarse_fine_diff").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true });
140 $("#moisture").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); 140 $("#moisture").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true });
141 $("#diastatic_power").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); 141 $("#diastatic_power").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true });
142 $("#protein").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); 142 $("#protein").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true });
143 $("#max_in_batch").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); 143 $("#max_in_batch").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true });
144 $("#recommend_mash").jqxCheckBox({ theme: theme, width: 120, height: 23 }); 144 $("#recommend_mash").jqxCheckBox({ theme: theme, width: 120, height: 23 });
145 $("#ibu_gal_per_lb").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); 145 $("#ibu_gal_per_lb").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true });
146 $("#always_on_stock").jqxCheckBox({ theme: theme, width: 120, height: 23 }); 146 $("#always_on_stock").jqxCheckBox({ theme: theme, width: 120, height: 23 });
147 $("#di_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); 147 $("#di_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true });
148 $("#acid_to_ph_57").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); 148 $("#acid_to_ph_57").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true });
149 149 $("#graintype").jqxDropDownList({ theme: theme, source: srcGraintype, width: 100, height: 23, dropDownHeight: 185 });
150 $("#graintype").jqxInput({ theme: theme, width: 250, height: 23 });
151 150
152 $("#inventory").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); 151 $("#inventory").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true });
153 $("#production_date").jqxDateTimeInput({ theme: theme, width: 100, height: 23, formatString: 'yyyy-MM-dd' }); 152 $("#production_date").jqxDateTimeInput({ theme: theme, width: 100, height: 23, formatString: 'yyyy-MM-dd' });
154 153
155 $("#cost").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 2, spinButtons: true }); 154 $("#cost").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 2, spinButtons: true });
156 $("#tht_date").jqxDateTimeInput({ theme: theme, width: 100, height: 23, formatString: 'yyyy-MM-dd' }); 155 $("#tht_date").jqxDateTimeInput({ theme: theme, width: 100, height: 23, formatString: 'yyyy-MM-dd' });
157 $("#supplier_rec").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true });
158 // supplier_rec
159 var dataAdapter = new $.jqx.dataAdapter(source); 156 var dataAdapter = new $.jqx.dataAdapter(source);
160 var editrow = -1; 157 var editrow = -1;
161 // initialize jqxGrid 158 // initialize jqxGrid
162 $("#jqxgrid").jqxGrid({ 159 $("#jqxgrid").jqxGrid({
163 width: 1280, 160 width: 1280,
173 statusbar.append(container); 170 statusbar.append(container);
174 addButton.jqxButton({ width: 60, height: 20 }); 171 addButton.jqxButton({ width: 60, height: 20 });
175 // add new row. 172 // add new row.
176 addButton.click(function (event) { 173 addButton.click(function (event) {
177 editrow = -1; 174 editrow = -1;
178 $("#popupWindow").jqxWindow({ position: { x: 230, y: 10 } }); 175 $("#popupWindow").jqxWindow({ position: { x: 230, y: 30 } });
179 $("#name").val(''); 176 $("#name").val('');
180 $("#type").val('Grain'); 177 $("#type").val('Grain');
181 $("#origin").val(''); 178 $("#origin").val('');
182 $("#supplier").val(''); 179 $("#supplier").val('');
183 $("#notes").val(''); 180 $("#notes").val('');
194 $("#graintype").val(''); 191 $("#graintype").val('');
195 $("#inventory").val(''); 192 $("#inventory").val('');
196 $("#cost").val(''); 193 $("#cost").val('');
197 $("#production_date").val(''); 194 $("#production_date").val('');
198 $("#tht_date").val(''); 195 $("#tht_date").val('');
199 $("#supplier_rec").val('');
200 $("#popupWindow").jqxWindow('open'); 196 $("#popupWindow").jqxWindow('open');
201 }); 197 });
202 }, 198 },
203 filterable: true, 199 filterable: true,
204 filtermode: 'excel', 200 filtermode: 'excel',
205 columns: [ 201 columns: [
206 { text: 'Vergistbaar product', datafield: 'name', width: 250 }, 202 { text: 'Vergistbaar product', datafield: 'name', width: 250 },
207 { text: 'Soort', datafield: 'type', width: 90 }, 203 { text: 'Soort', datafield: 'type', width: 90 },
204 { text: 'Mout type', datafield: 'graintype', width: 90 },
208 { text: 'Herkomst', datafield: 'origin', width: 150 }, 205 { text: 'Herkomst', datafield: 'origin', width: 150 },
209 { text: 'Producent', datafield: 'supplier', width: 150 }, 206 { text: 'Producent', datafield: 'supplier', width: 150 },
210 { text: 'Kleur', datafield: 'color', width: 70, cellsalign: 'right' }, 207 { text: 'Kleur', datafield: 'color', width: 70, cellsalign: 'right' },
211 { text: 'Opbrengst', datafield: 'yield', width: 70, cellsalign: 'right' }, 208 { text: 'Opbrengst', datafield: 'yield', width: 70, cellsalign: 'right' },
212 { text: 'Inv.', datafield: 'inventory', width: 70, cellsalign: 'right' }, 209 { text: 'Inv.', datafield: 'inventory', width: 70, cellsalign: 'right' },
214 { text: 'Edit', datafield: 'Edit', width: 120, columntype: 'button', cellsrenderer: function () { 211 { text: 'Edit', datafield: 'Edit', width: 120, columntype: 'button', cellsrenderer: function () {
215 return "Edit"; 212 return "Edit";
216 }, buttonclick: function (row) { 213 }, buttonclick: function (row) {
217 // open the popup window when the user clicks a button. 214 // open the popup window when the user clicks a button.
218 editrow = row; 215 editrow = row;
219 $("#popupWindow").jqxWindow({ position: { x: 230, y: 10 } }); 216 $("#popupWindow").jqxWindow({ position: { x: 230, y: 30 } });
220 // get the clicked row's data and initialize the input fields. 217 // get the clicked row's data and initialize the input fields.
221 var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); 218 var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow);
222 $("#name").val(dataRecord.name); 219 $("#name").val(dataRecord.name);
223 $("#type").val(dataRecord.type); 220 $("#type").val(dataRecord.type);
224 $("#yield").val(dataRecord.yield); 221 $("#yield").val(dataRecord.yield);
240 $("#graintype").val(dataRecord.graintype); 237 $("#graintype").val(dataRecord.graintype);
241 $("#inventory").val(dataRecord.inventory); 238 $("#inventory").val(dataRecord.inventory);
242 $("#cost").val(dataRecord.cost); 239 $("#cost").val(dataRecord.cost);
243 $("#production_date").val(dataRecord.production_date); 240 $("#production_date").val(dataRecord.production_date);
244 $("#tht_date").val(dataRecord.tht_date); 241 $("#tht_date").val(dataRecord.tht_date);
245 $("#supplier_rec").val(dataRecord.supplier_rec);
246 // show the popup window. 242 // show the popup window.
247 $("#popupWindow").jqxWindow('open'); 243 $("#popupWindow").jqxWindow('open');
248 } 244 }
249 } 245 }
250 ] 246 ]
297 graintype: $("#graintype").val(), 293 graintype: $("#graintype").val(),
298 inventory: parseFloat($("#inventory").jqxNumberInput('decimal')), 294 inventory: parseFloat($("#inventory").jqxNumberInput('decimal')),
299 cost: parseFloat($("#cost").jqxNumberInput('decimal')), 295 cost: parseFloat($("#cost").jqxNumberInput('decimal')),
300 production_date: $("#production_date").val(), 296 production_date: $("#production_date").val(),
301 tht_date: $("#tht_date").val(), 297 tht_date: $("#tht_date").val(),
302 supplier_rec: parseFloat($("#supplier_rec").jqxNumberInput('decimal'))
303 }; 298 };
304 $('#jqxgrid').jqxGrid('updaterow', rowID, row); 299 $('#jqxgrid').jqxGrid('updaterow', rowID, row);
305 $("#popupWindow").jqxWindow('hide'); 300 $("#popupWindow").jqxWindow('hide');
306 } else { 301 } else {
307 // Insert a record 302 // Insert a record
328 graintype: $("#graintype").val(), 323 graintype: $("#graintype").val(),
329 inventory: parseFloat($("#inventory").jqxNumberInput('decimal')), 324 inventory: parseFloat($("#inventory").jqxNumberInput('decimal')),
330 cost: parseFloat($("#cost").jqxNumberInput('decimal')), 325 cost: parseFloat($("#cost").jqxNumberInput('decimal')),
331 production_date: $("#production_date").val(), 326 production_date: $("#production_date").val(),
332 tht_date: $("#tht_date").val(), 327 tht_date: $("#tht_date").val(),
333 supplier_rec: parseFloat($("#supplier_rec").jqxNumberInput('decimal'))
334 }; 328 };
335 $('#jqxgrid').jqxGrid('addrow', null, newrow); 329 $('#jqxgrid').jqxGrid('addrow', null, newrow);
336 $("#popupWindow").jqxWindow('hide'); 330 $("#popupWindow").jqxWindow('hide');
337 } 331 }
338 }); 332 });

mercurial