From 8680bbb1909809680ee9a0c8e5a2583b1ed37c0d Mon Sep 17 00:00:00 2001 From: Kilian Saffran Date: Sun, 24 Mar 2019 09:27:05 +0100 Subject: [PATCH] config and paywindow --- db.cashboxdev.json | 2 +- db/cashbox.sqlite.schema.sql | Bin 4904 -> 5060 bytes js/database.js | 23 ++++++++++ modules/paywindow/index.html | 22 +++++++--- modules/paywindow/index.js | 82 ++++++++++++++++++++++++++++++++++- 5 files changed, 119 insertions(+), 10 deletions(-) diff --git a/db.cashboxdev.json b/db.cashboxdev.json index 8489aa0..8ae9a67 100644 --- a/db.cashboxdev.json +++ b/db.cashboxdev.json @@ -1 +1 @@ -{"name":"CashBox Dev","type":"local","server":"localhost","dbfile":"cashbox","vpn":"","vat":"0,17","currency":"€","mailserver":"","mailencryption":"","mailport":"","maillogin":"","mailpassword":""} \ No newline at end of file +{"name":"CashBox Dev","type":"local","server":"localhost","dbfile":"cashboxdev","vpn":"","vat":"0,17","currency":"€","mailserver":"","mailencryption":"","mailport":"","maillogin":"","mailpassword":""} \ No newline at end of file diff --git a/db/cashbox.sqlite.schema.sql b/db/cashbox.sqlite.schema.sql index 3b7d1372b5f62da13357f91b8b8ba1e2bf68dbb5..09fcdf66b9eecd0ed6b82803933db0b188c4d6a4 100644 GIT binary patch delta 99 zcmZ3Xc0_%HhOjv=0~dn=gEK=AgDZn0LkN&mU?^coWJqGjVMqnClNs_E@)*(>G8xi= tJPihrdQJv~iT2{$3JhgHg*gnR45^a?S%n!DChIb)aw#xqGFXF^0RU%}599y< delta 7 OcmX@2zCvw-hA;pOpaP`; diff --git a/js/database.js b/js/database.js index 54a0a59..ff1d391 100644 --- a/js/database.js +++ b/js/database.js @@ -27,6 +27,29 @@ var appdb = { }); return result; }, + dbquerykey: function(key,sQuery){ + var type='query'; + var result= {sqldata:[]}; + //console.log(this.url + 'db=' + this.dbfile + '&type=' + type + '&sql=' +encodeURIComponent(sQuery)); + //dump(this.url + 'db=' + this.dbfile + '&type=' + type + '&sql=' +encodeURIComponent(sQuery) + "\n"); + $.ajax({ + encoding:"UTF-8", + url:this.url, + crossDomain: true, + method: "POST", + data: 'key=' + key +'&type=' + type + '&sql=' +encodeURIComponent(sQuery), + success: function (data){ + //dump(data + "\n"); + result=data.result; + }, + error: function(data){ + alert("Error:" + JSON.stringify(data)); + console.log("Error:" + JSON.stringify(data)); + }, + async:false + }); + return result; + }, dbqueryarray: function(sQuery){ var type='queryarray'; var result= {sqldata:[]}; diff --git a/modules/paywindow/index.html b/modules/paywindow/index.html index cf9ef2e..7ba959a 100644 --- a/modules/paywindow/index.html +++ b/modules/paywindow/index.html @@ -18,6 +18,7 @@ +
@@ -29,17 +30,24 @@
- +
+
- - - + + +
Anz.EinkaufAnz.Einkauf
+
+
+
+ 0,00€ +
+
@@ -49,7 +57,7 @@
-
+
@@ -60,7 +68,7 @@
-
+
@@ -71,7 +79,7 @@
-
+
diff --git a/modules/paywindow/index.js b/modules/paywindow/index.js index 515c742..403268e 100644 --- a/modules/paywindow/index.js +++ b/modules/paywindow/index.js @@ -1,23 +1,61 @@ var winh = Math.max(document.documentElement.clientHeight, window.innerHeight || 0); - +var config = {}; +var tblheight1=winh-150; function initpage(){ + loadconfig(); load_group_selects(); + load_local_config_product_tables(); + $('#checkout').bootstrapTable({ + height: tblheight1, + }); + $('#checkout > tbody').html(""); +} + +function loadconfig(){ + + sql = "select id,value from config where id in ('cardpayement_enabled','checkout_grouping');"; + var dataconfig = appdb.dbquerykey("id",sql); + if (dataconfig != null){ + config = dataconfig.sqldata; + } + console.log("config loaded"); + console.log(config); } function loadadmin(){ parent.browserapp.loadmodule('overview'); } +function load_local_config_product_tables(){ + +} + function load_group_selects(){ var sql = "select productgroup from products group by productgroup;"; - var opts = ""; + var opts = ''; var data = appdb.dbquery(sql); for (var i in data.sqldata){ opts += ''; } $("#grouplist1").append(opts); + var gl1 = parent.usersystem.getPreference('product_table_1'); + //console.log("grouplist1:" + gl1); + if (gl1 != null){ + $("#grouplist1").val(gl1); + load_productgroup(1); + } $("#grouplist2").append(opts); + var gl2 = parent.usersystem.getPreference('product_table_2'); + if (gl2 != null){ + $("#grouplist2").val(gl2); + load_productgroup(2); + } $("#grouplist3").append(opts); + var gl3 = parent.usersystem.getPreference('product_table_3'); + if (gl3 != null){ + $("#grouplist3 ").val(gl3); + load_productgroup(3); + } } function load_productgroup(listnum){ @@ -33,9 +71,49 @@ function load_productgroup(listnum){ trow += ''; $('#producttable' + listnum + " > tbody").append(trow.replace(/null/g,'')); } + parent.usersystem.setPreference('product_table_' + listnum,listval); } function addproduct(idproduct){ console.log(idproduct); + var sql = "select * from products where id='"+idproduct+"';"; + var product = appdb.dbquery(sql); + var trow = ""; + var bdone = false; + if ((product) && product.sqldata){ + var idprod = product.sqldata[0].id; + if ((config.checkout_grouping) && (config.checkout_grouping == "1")){ + if ($("#checkout_" + idprod) != null){ + console.log("Product " + idprod +" exists!"); + var cnum = $("#checkout_" + idprod + " td:first").text(); + cnum = cnum + 1; + $("#checkout_" + idprod + " td:first").html(cnum); + bdone = true; + } + } + if (bdone == false) { + //console.log("Add Product " + idprod +" to list!"); + trow = ''; + trow += '' ; + trow += ''; + trow += ''; + trow += ''; + console.log(trow); + $("#checkout > tbody").append(trow); + } + } + calctotal(); } + +function remove_co_product(id){ + +} + +function calctotal(){ + +} + +function clean_checkout(){ + $("#checkout > tbody").html(""); +} -- 2.39.5
1' + product.sqldata[0].name+'
'+ product.sqldata[0].specification +''+product.sqldata[0].grossamount+'€