From 2cdae1520b27f71b8746ca0c981821d3724a7cbd Mon Sep 17 00:00:00 2001 From: Kilian Saffran Date: Thu, 11 Apr 2019 00:34:13 +0200 Subject: [PATCH] checkout optimisation --- modules/paywindow/index.html | 62 +++++++++---------- modules/paywindow/index.js | 113 +++++++++++++++++++++++++++++++++-- 2 files changed, 139 insertions(+), 36 deletions(-) diff --git a/modules/paywindow/index.html b/modules/paywindow/index.html index 6cfa754..cc57875 100644 --- a/modules/paywindow/index.html +++ b/modules/paywindow/index.html @@ -168,14 +168,14 @@
- +
@@ -185,7 +185,7 @@ Zu Bezahlen:
- 0,00€ + 0,00€
@@ -193,7 +193,7 @@ Erhalten:
- 0,00€ + 0,00€
@@ -201,69 +201,69 @@ Wechselgeld:
- 0,00€ + 0,00€
-
+
- - - + + +
- - - + + +
- - - + + +
- - - + + +
- - - + + +
- - - + + +
- - + +
diff --git a/modules/paywindow/index.js b/modules/paywindow/index.js index 7a3ae82..7360d2b 100644 --- a/modules/paywindow/index.js +++ b/modules/paywindow/index.js @@ -1,11 +1,12 @@ var winh = Math.max(document.documentElement.clientHeight, window.innerHeight || 0); var config = {}; +var localconfig = {}; var shoppingcart = {products:{},transaction:{}}; var tblheight1=winh-180; function initpage(){ loadconfig(); load_group_selects(); - load_local_config_product_tables(); + //load_local_config_product_tables(); $('#checkout').bootstrapTable({ height: tblheight1, }); @@ -21,15 +22,17 @@ function loadconfig(){ } console.log("config loaded"); console.log(config); + localconfig = parent.usersystem.getPreference('paywindow'); + } function loadadmin(){ parent.browserapp.loadmodule('overview'); } -function load_local_config_product_tables(){ +// function load_local_config_product_tables(){ -} +// } function load_group_selects(){ var sql = "select productgroup from products group by productgroup;"; @@ -132,7 +135,9 @@ function calctotal(){ sum += shoppingcart["products"][i].quantity * parseFloat(shoppingcart["products"][i].grossamount); } $("#sumtotal").html(sum.toFixed(2).replace('.',',') ); + shoppingcart['transaction']['grossamount'] = sum; return sum.toFixed(2); + } function clean_shoppingcart(){ @@ -154,11 +159,50 @@ function view_payementdlg(ptype){ function book_shoppingcart(ptype){ shoppingcart['transaction']['id']= appdb.generate_uuid(); - // appdb.dbexec("INSERT INTO transactions (id, payementtype, id_table, payedamount, cashbackamount, status, statusdate) VALUES('"+shoppingcart['transaction']['id']+"', '"+ptype+"', '"+shoppingcart['transaction']['id_table']+"', 0, 0, '', now());"); + if (shoppingcart['transaction']['table'] && shoppingcart['transaction']['table']['name']){ + $("#pay_commandtable").html(shoppingcart['transaction']['table']['name']); + } else { + $("#pay_commandtable").html(""); + } + if (shoppingcart['transaction']['grossamount']){ + $("#pay_sumtotal").html(shoppingcart['transaction']['grossamount'].toFixed(2).replace('.',',')); + } + + shoppingcart['transaction']['paymenttype'] = ptype; + shoppingcart['transaction']['changeamount'] = null; + shoppingcart['transaction']['cashamount'] = null; + shoppingcart['transaction']['payedamount'] = null; + $("#sumtotalcashamount").html(""); + $("#sumtotalchangeamount").html(""); + //$("#sumtotalpayedamount").html(""); + if (localconfig && localconfig['printtype'] && localconfig['printtype']['receipt'] && localconfig['printtype']['receipt'] == 1){ + $("#printreceipt").attr("checked","checked"); + } + if (localconfig && localconfig['printtype'] && localconfig['printtype']['ticket'] && localconfig['printtype']['ticket'] == 1){ + $("#printticket").attr("checked","checked"); + } + $('#'+ptype).attr('checked', 'checked'); + //$('#'+ptype).attr('checked', 'checked'); + //parent.usersystem.setPreference('paywindow',localconfig); + // appdb.dbexec("INSERT INTO transactions (id, payementtype, id_table, payedamount, cashbackamount, status, statusdate) VALUES('"+shoppingcart['transaction']['id']+"', '"+ptype+"', '"+shoppingcart['transaction']['id_table']+"', 0, 0, '', now());"); + $('#dlgPayement').modal('show'); } +function setprinttype(id){ + console.log("set printtypes"); + if (!localsystem['printtype']){ + localsystem['printtype'] = {}; + } + if ($("#print"+id).prop('checked')){ + localsystem['printtype'][id] = 1; + }else { + localsystem['printtype'][id] = 0; + } + parent.usersystem.setPreference('paywindow',localconfig); +} + function view_tables(){ var tbls = appdb.dbquery("select id,name from tables;"); $("#tableslist").html(""); @@ -171,6 +215,65 @@ function view_tables(){ function setTable(id,name){ $("#commandtable").html(name); - shoppingcart['transaction']['id_table'] = id; + if (!shoppingcart['transaction']['table']){ + shoppingcart['transaction']['table'] ={}; + } + shoppingcart['transaction']['table']['id'] = id; + shoppingcart['transaction']['table']['name'] = name; $('#dlgTables').modal('hide'); +} + +function setpayementtype(ptype){ + console.log("set payement type: " + ptype); + if ($("#"+id).prop('checked')){ + shoppingcart['transaction']['payementtype'] =ptype; + } +} + +function addvalue(num,type){ + //type 0=string add, 1 = sum add, 2 = 1:1, 3 =backspace, 4=clear + if (type == 1){ + var cval = $("#sumtotalcashamount").html(); + if (cval == ""){ cval = 0;} + else { + cval = parseFloat(cval.replace(',','.')) + } + cval = cval+parseFloat(num); + $("#sumtotalcashamount").html(cval.toString().replace('.',',')); + } else if (type == 0) { + var cval = $("#sumtotalcashamount").html(); + if (num == ','){ + if (cval.indexOf(',') < 0){ + $("#sumtotalcashamount").html(cval + num); + } + }else { + $("#sumtotalcashamount").html(cval + num); + } + } else if (type == 2) { + $("#sumtotalcashamount").html($("#pay_sumtotal").html()); + } else if (type == 3) { + var cval = $("#sumtotalcashamount").html(); + cval = cval.substring(0,cval.length-1); + $("#sumtotalcashamount").html(cval); + } else if (type == 4) { + $("#sumtotalcashamount").html(""); + } + var ncash = $("#sumtotalcashamount").html(); + var ntotal = parseFloat($("#pay_sumtotal").html().replace(',','.')); + if (ncash == ""){ + ncash = 0.00; + }else { + ncash = parseFloat(ncash.replace(',','.')); + } + nchange = ncash-ntotal; + if (nchange > 0.00){ + $("#sumtotalchangeamount").html(nchange.toFixed(2).replace('.',',')); + }else { + $("#sumtotalchangeamount").html(""); + } + // if (ncash >= ntotal){ + // $("#sumtotalpayedamount").html($("#sumtotalcashamount").html()); + // } else { + // $("#sumtotalpayedamount").html($("#pay_sumtotal").html()); + // } } \ No newline at end of file -- 2.39.5