config and paywindow
authorKilian Saffran <ksaffran@dks.lu>
Sun, 24 Mar 2019 08:27:05 +0000 (09:27 +0100)
committerKilian Saffran <ksaffran@dks.lu>
Sun, 24 Mar 2019 08:27:05 +0000 (09:27 +0100)
db.cashboxdev.json
db/cashbox.sqlite.schema.sql
js/database.js
modules/paywindow/index.html
modules/paywindow/index.js

index 8489aa0..8ae9a67 100644 (file)
@@ -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
index 3b7d137..09fcdf6 100644 (file)
Binary files a/db/cashbox.sqlite.schema.sql and b/db/cashbox.sqlite.schema.sql differ
index 54a0a59..ff1d391 100644 (file)
@@ -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:[]};
index cf9ef2e..7ba959a 100644 (file)
@@ -18,6 +18,7 @@
         <button class="btn btn-primary" onclick="loadadmin();"><i class="fas fa-toolbox"></i><br/>Verwaltung</button>
         <button class="btn btn-primary" onclick="loadadmin();"><i class="fas fa-cash-register"></i><br/>Offene Posten</button>
         <button class="btn btn-primary" onclick="loadadmin();"><i class="fas fa-cash-register"></i><br/>Bestellungen</button>
+        <button class="btn btn-danger" onclick="clean_checkout();"><i class="fas fa-shopping-cart"></i><br/>Neuer Einkauf</button>
       </div>
   </div> 
   <div class="ml-auto">
 <div class="cotainer-fluid bg-white" style="margin-top: 52px;">
   <div class="row" style="margin: 0px;">
     <div class="col-sm-3">
-      <table class="table table-bordered table-striped" id="checkout" style="width: 100%;min-height: 75vh;">
+      <div border: 1px solid grey;">
+      <table class="table table-bordered table-striped w-100" id="checkout" >
         <thead class="thead-dark">
           <tr>
-            <th style="vertical-align: middle;width: 45px;">Anz.</th>
-            <th style="vertical-align: middle;">Einkauf</th>
-            <th style="padding: 0px;width: 45px;"><button class="btn btn-danger"><i class="fas fa-broom"></i><br/>Neu</button></th>
+            <th>Anz.</th>
+            <th>Einkauf</th>
+            <th></th>
           </tr>
         </thead>
         <tbody>
         </tbody>
       </table>
+      </div>
+      <div class="row"  style="margin: 0px;">
+          <div class="col-sm-12" style="background-color: black; font-weight: bold; text-align: right; border: 1px solid green;; height: 40px; font-size: 30px; color: green; vertical-align: middle; padding-right: 5px;">
+            <span id="sumtotal">0,00</span>€
+          </div>
+      </div>
       <div class="row"  style="margin: 0px;">
         <div class="col-sm-6">
           <button class="btn btn-primary btn-block"><i class="fas fa-money-bill-alt"></i><br>Bargeld-Buchung</button>
@@ -49,7 +57,7 @@
           </div>
       </div>
     </div>
-    <div class="col-sm-3">
+    <div class="col-sm-3" style="border: 1px solid grey">
       <table class="table table-bordered table-striped" data-table="toggle" id="producttable1" style="width: 100%;">
         <thead class="thead-dark">
           <tr>
@@ -60,7 +68,7 @@
         </tbody>
       </table>
     </div>
-    <div class="col-sm-3">
+    <div class="col-sm-3" style="border: 1px solid grey">
       <table class="table table-bordered table-striped" data-table="toggle"  id="producttable2" style="width: 100%;">
         <thead class="thead-dark">
           <tr>
@@ -71,7 +79,7 @@
         </tbody>
       </table>
     </div>
-    <div class="col-sm-3">
+    <div class="col-sm-3" style="border: 1px solid grey">
       <table class="table table-bordered table-striped" data-table="toggle"  id="producttable3" style="width: 100%;"  >
         <thead class="thead-dark">
           <tr>
index 515c742..403268e 100644 (file)
@@ -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 = '<option value=""></option>';
   var data = appdb.dbquery(sql);
   for (var i in data.sqldata){
     opts += '<option value="'+data.sqldata[i].productgroup+'">'+data.sqldata[i].productgroup+'</option>';
   }
   $("#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 += '</tr>';
     $('#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 = '<tr id="checkout_'+ idprod+'">';
+      trow +=  '<td>1</td>' ;
+      trow +=  '<td class="font-weight-bold">' + product.sqldata[0].name+'<br/><span class="font-weight-normal">'+ product.sqldata[0].specification +'</span><span class="badge badge-secondary float-right">'+product.sqldata[0].grossamount+'€</span></td>'; 
+      trow += '<td><button class="btn btn-danger" onclick="remove_co_product(\''+ idprod +'\');"><i class="fas fa-times"></i></button></td>';
+      trow += '</tr>';
+      console.log(trow);
+      $("#checkout > tbody").append(trow);
+    }
+  }
+  calctotal();
   
 }
+
+function remove_co_product(id){
+
+}
+
+function calctotal(){
+
+}
+
+function clean_checkout(){
+  $("#checkout > tbody").html("");
+}