www/js/inv_fermentables.js

changeset 199
dad62ec9af18
parent 197
63174cff2cc1
child 202
64a9c935a66b
equal deleted inserted replaced
198:f0ec83e1e01f 199:dad62ec9af18
41 $('#eventWindow').jqxWindow('hide'); 41 $('#eventWindow').jqxWindow('hide');
42 } 42 }
43 43
44 44
45 $(document).ready(function () { 45 $(document).ready(function () {
46
47 var dataRecord = {};
48
49 function calcTotal(cost, inventory) {
50
51 $('#totval').val(cost * inventory);
52 }
53
46 var url = "includes/db_inventory_fermentables.php"; 54 var url = "includes/db_inventory_fermentables.php";
47 // prepare the data 55 // prepare the data
48 var source = { 56 var source = {
49 datatype: "json", 57 datatype: "json",
50 cache: false, 58 cache: false,
176 }); 184 });
177 $("#inventory").jqxNumberInput( Spin1dec1 ); 185 $("#inventory").jqxNumberInput( Spin1dec1 );
178 $("#production_date").jqxDateTimeInput( Dateopts ); 186 $("#production_date").jqxDateTimeInput( Dateopts );
179 $("#cost").jqxNumberInput( Spin2dec1 ); 187 $("#cost").jqxNumberInput( Spin2dec1 );
180 $("#tht_date").jqxDateTimeInput( Dateopts ); 188 $("#tht_date").jqxDateTimeInput( Dateopts );
189 $("#totval").jqxNumberInput( Spin2dec1 );
190 $("#totval").jqxNumberInput({ width: 90, readOnly: true, spinButtons: false });
191
181 var dataAdapter = new $.jqx.dataAdapter(source); 192 var dataAdapter = new $.jqx.dataAdapter(source);
182 var editrow = -1; 193 var editrow = -1;
183 // initialize jqxGrid 194 // initialize jqxGrid
184 $("#jqxgrid").jqxGrid({ 195 $("#jqxgrid").jqxGrid({
185 width: 1280, 196 width: 1280,
261 }, buttonclick: function (row) { 272 }, buttonclick: function (row) {
262 // open the popup window when the user clicks a button. 273 // open the popup window when the user clicks a button.
263 editrow = row; 274 editrow = row;
264 $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } }); 275 $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } });
265 // get the clicked row's data and initialize the input fields. 276 // get the clicked row's data and initialize the input fields.
266 var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); 277 dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow);
267 $("#name").val(dataRecord.name); 278 $("#name").val(dataRecord.name);
268 $("#type").val(dataRecord.type); 279 $("#type").val(dataRecord.type);
269 $("#yield").val(dataRecord.yield); 280 $("#yield").val(dataRecord.yield);
270 $("#color").val(dataRecord.color); 281 $("#color").val(dataRecord.color);
271 $("#add_after_boil").val(dataRecord.add_after_boil); 282 $("#add_after_boil").val(dataRecord.add_after_boil);
286 $("#graintype").val(dataRecord.graintype); 297 $("#graintype").val(dataRecord.graintype);
287 $("#inventory").val(dataRecord.inventory); 298 $("#inventory").val(dataRecord.inventory);
288 $("#cost").val(dataRecord.cost); 299 $("#cost").val(dataRecord.cost);
289 $("#production_date").val(dataRecord.production_date); 300 $("#production_date").val(dataRecord.production_date);
290 $("#tht_date").val(dataRecord.tht_date); 301 $("#tht_date").val(dataRecord.tht_date);
302 calcTotal(dataRecord.cost, dataRecord.inventory);
291 // show the popup window. 303 // show the popup window.
292 $("#popupWindow").jqxWindow('open'); 304 $("#popupWindow").jqxWindow('open');
293 } 305 }
294 } 306 }
295 ] 307 ]
296 }); 308 });
309
310 $("#cost").on('change', function (event) {
311 dataRecord.cost = parseFloat(event.args.value);
312 calcTotal(dataRecord.cost, dataRecord.inventory);
313 });
314 $("#inventory").on('change', function (event) {
315 dataRecord.inventory = parseFloat(event.args.value);
316 calcTotal(dataRecord.cost, dataRecord.inventory);
317 });
318
297 // initialize the popup window and buttons. 319 // initialize the popup window and buttons.
298 $("#popupWindow").jqxWindow({ 320 $("#popupWindow").jqxWindow({
299 width: 1050, 321 width: 1050,
300 height: 550, 322 height: 550,
301 resizable: false, 323 resizable: false,

mercurial