diff -r 06df1320327c -r 77f1617b6994 www/js/inv_hops.js
--- a/www/js/inv_hops.js Fri Sep 13 16:54:51 2019 +0200
+++ b/www/js/inv_hops.js Fri Sep 13 20:24:31 2019 +0200
@@ -44,16 +44,15 @@
$(document).ready(function () {
- var dataRecord = {};
-
function calcTotal(cost, inventory) {
$('#totval').val(cost * (inventory / 1000));
}
- var url = "includes/db_inventory_hops.php";
+ var dataRecord = {},
+ url = 'includes/db_inventory_hops.php',
// prepare the data
- var source = {
+ source = {
datatype: "json",
cache: false,
datafields: [
@@ -90,8 +89,8 @@
data: data,
type: "POST",
success: function (data, status, xhr) {
- // delete command is executed.
commit(true);
+ location.reload( true );
},
error: function (jqXHR, textStatus, errorThrown) {
commit(false);
@@ -108,6 +107,7 @@
type: "POST",
success: function (data, status, xhr) {
commit(true);
+ location.reload( true );
},
error: function(jqXHR, textStatus, errorThrown) {
commit(false);
@@ -123,15 +123,18 @@
data: data,
type: "POST",
success: function (data, status, xhr) {
- // update command is executed.
commit(true);
+ location.reload( true );
},
error: function(jqXHR, textStatus, errorThrown) {
commit(false);
}
});
}
- };
+ },
+ dataAdapter = new $.jqx.dataAdapter(source),
+ editrow = -1;
+
// initialize the input fields.
$("#name").jqxInput({ theme: theme, width: 640, height: 23 });
$("#alpha").jqxNumberInput( Perc1dec );
@@ -171,8 +174,6 @@
$("#total_oil").jqxNumberInput( Perc1dec );
$("#totval").jqxNumberInput( Show2dec );
- var dataAdapter = new $.jqx.dataAdapter(source);
- var editrow = -1;
// initialize jqxGrid
$("#jqxgrid").jqxGrid({
width: 1280,
@@ -181,9 +182,10 @@
theme: theme,
showstatusbar: true,
renderstatusbar: function (statusbar) {
- var container = $("
");
- var addButton = $("Nieuw ");
- var impButton = $("Import ");
+ var container, addButton, impButton;
+ container = $("");
+ addButton = $("Nieuw ");
+ impButton = $("Import ");
container.append(addButton);
container.append(impButton);
statusbar.append(container);
@@ -215,8 +217,7 @@
$("#popupWindow").jqxWindow('open');
});
impButton.click(function (event) {
- var url="import_ingredients.php?select=hops";
- window.location.href = url;
+ window.location.href = 'import_ingredients.php?select=hops';
});
},
filterable: true,
@@ -251,8 +252,9 @@
return '' + amount + '';
}
},
- { text: '', datafield: 'Wijzig', columntype: 'button', width: 100, align: 'center', menu: false, cellsrenderer: function () {
- return "Wijzig";
+ { text: '', datafield: 'Wijzig', columntype: 'button', width: 100, align: 'center', menu: false,
+ cellsrenderer: function () {
+ return "Wijzig";
}, buttonclick: function (row) {
// open the popup window when the user clicks a button.
editrow = row;
@@ -348,16 +350,15 @@
};
$('#jqxgrid').jqxGrid('addrow', null, row);
$("#popupWindow").jqxWindow('hide');
- location.reload( true ); // reload ourself.
});
$("#Save").jqxButton({ template: "success", width: '90px', theme: theme });
// update the edited row when the user clicks the 'Save' button.
$("#Save").click(function () {
- var rowID = -1;
+ var row, rowID = -1;
if (editrow >= 0) {
- var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow);
+ rowID = $('#jqxgrid').jqxGrid('getrowid', editrow);
}
- var row = {
+ row = {
record: rowID,
name: $("#name").val(),
alpha: parseFloat($("#alpha").jqxNumberInput('decimal')),
@@ -383,7 +384,6 @@
$('#jqxgrid').jqxGrid('updaterow', rowID, row);
} else {
$('#jqxgrid').jqxGrid('addrow', null, row);
- location.reload( true ); // reload ourself.
}
$("#popupWindow").jqxWindow('hide');
});