www/js/inv_hops.js

changeset 199
dad62ec9af18
parent 196
531d5458782f
child 203
e29b53962cd1
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 / 1000));
52 }
53
46 var url = "includes/db_inventory_hops.php"; 54 var url = "includes/db_inventory_hops.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,
161 $("#inventory").jqxNumberInput( Spin1dec1 ); 169 $("#inventory").jqxNumberInput( Spin1dec1 );
162 $("#production_date").jqxDateTimeInput( Dateopts ); 170 $("#production_date").jqxDateTimeInput( Dateopts );
163 $("#cost").jqxNumberInput( Spin2dec1 ); 171 $("#cost").jqxNumberInput( Spin2dec1 );
164 $("#tht_date").jqxDateTimeInput( Dateopts ); 172 $("#tht_date").jqxDateTimeInput( Dateopts );
165 $("#total_oil").jqxNumberInput( Perc1dec1 ); 173 $("#total_oil").jqxNumberInput( Perc1dec1 );
174 $("#totval").jqxNumberInput( Spin2dec1 );
175 $("#totval").jqxNumberInput({ width: 90, readOnly: true, spinButtons: false });
176
166 var dataAdapter = new $.jqx.dataAdapter(source); 177 var dataAdapter = new $.jqx.dataAdapter(source);
167 var editrow = -1; 178 var editrow = -1;
168 // initialize jqxGrid 179 // initialize jqxGrid
169 $("#jqxgrid").jqxGrid({ 180 $("#jqxgrid").jqxGrid({
170 width: 1280, 181 width: 1280,
232 }, buttonclick: function (row) { 243 }, buttonclick: function (row) {
233 // open the popup window when the user clicks a button. 244 // open the popup window when the user clicks a button.
234 editrow = row; 245 editrow = row;
235 $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } }); 246 $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } });
236 // get the clicked row's data and initialize the input fields. 247 // get the clicked row's data and initialize the input fields.
237 var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); 248 dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow);
238 $("#name").val(dataRecord.name); 249 $("#name").val(dataRecord.name);
239 $("#alpha").val(dataRecord.alpha); 250 $("#alpha").val(dataRecord.alpha);
240 $("#beta").val(dataRecord.beta); 251 $("#beta").val(dataRecord.beta);
241 $("#humulene").val(dataRecord.humulene); 252 $("#humulene").val(dataRecord.humulene);
242 $("#caryophyllene").val(dataRecord.caryophyllene); 253 $("#caryophyllene").val(dataRecord.caryophyllene);
252 $("#inventory").val(dataRecord.inventory); 263 $("#inventory").val(dataRecord.inventory);
253 $("#cost").val(dataRecord.cost); 264 $("#cost").val(dataRecord.cost);
254 $("#production_date").val(dataRecord.production_date); 265 $("#production_date").val(dataRecord.production_date);
255 $("#tht_date").val(dataRecord.tht_date); 266 $("#tht_date").val(dataRecord.tht_date);
256 $("#total_oil").val(dataRecord.total_oil); 267 $("#total_oil").val(dataRecord.total_oil);
268 calcTotal(dataRecord.cost, dataRecord.inventory);
257 // show the popup window. 269 // show the popup window.
258 $("#popupWindow").jqxWindow('open'); 270 $("#popupWindow").jqxWindow('open');
259 } 271 }
260 } 272 }
261 ] 273 ]
262 }); 274 });
275
276 $("#cost").on('change', function (event) {
277 dataRecord.cost = parseFloat(event.args.value);
278 calcTotal(dataRecord.cost, dataRecord.inventory);
279 });
280 $("#inventory").on('change', function (event) {
281 dataRecord.inventory = parseFloat(event.args.value);
282 calcTotal(dataRecord.cost, dataRecord.inventory);
283 });
284
263 // initialize the popup window and buttons. 285 // initialize the popup window and buttons.
264 $("#popupWindow").jqxWindow({ 286 $("#popupWindow").jqxWindow({
265 width: 1050, 287 width: 1050,
266 height: 550, 288 height: 550,
267 resizable: false, 289 resizable: false,

mercurial