db and products
authorKilian Saffran <ksaffran@dks.lu>
Wed, 6 Mar 2019 05:53:02 +0000 (06:53 +0100)
committerKilian Saffran <ksaffran@dks.lu>
Wed, 6 Mar 2019 05:53:02 +0000 (06:53 +0100)
db.cashboxdev.json [new file with mode: 0644]
db/cashbox.sqlite.dev.full.sql [new file with mode: 0644]
db/cashbox.sqlite.schema.sql [new file with mode: 0644]
js/moduleglobal.js
main.js
modules/products/index.html
modules/products/index.js
modules/products/lib/group.js [deleted file]
modules/products/lib/product.js
modules/settings/index.html
renderer.js

diff --git a/db.cashboxdev.json b/db.cashboxdev.json
new file mode 100644 (file)
index 0000000..8489aa0
--- /dev/null
@@ -0,0 +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
diff --git a/db/cashbox.sqlite.dev.full.sql b/db/cashbox.sqlite.dev.full.sql
new file mode 100644 (file)
index 0000000..1352a95
Binary files /dev/null and b/db/cashbox.sqlite.dev.full.sql differ
diff --git a/db/cashbox.sqlite.schema.sql b/db/cashbox.sqlite.schema.sql
new file mode 100644 (file)
index 0000000..3b7d137
Binary files /dev/null and b/db/cashbox.sqlite.schema.sql differ
index 5efb098..20b0b17 100644 (file)
@@ -20,5 +20,16 @@ var mpref ={
     //apppref.getpreference(page);
     //appdb.dbfile = this.cfg.dbfile; 
     appdb.url = decodeURIComponent(this.cfg.serviceurl) + 'sqlite/' + decodeURIComponent(this.cfg.dbfile);
+  },
+  formatvalue(value){
+    var valret = value;
+    var isnumber= new RegExp("^[0-9]*,[0-9]*$");
+    if (value == ''){
+      valret = null;
+    } else if (isnumber.test(value)){
+      valret = value.replace(",",".");
+    } 
+    return valret;
   }
-}
\ No newline at end of file
+}
+
diff --git a/main.js b/main.js
index f49e854..56cf9c1 100644 (file)
--- a/main.js
+++ b/main.js
@@ -15,7 +15,7 @@ function createWindow () {
        var parameters = [];
         if (os.platform() == "win32"){
                executablePath = "C:\\Strawberry\\perl\\bin\\perl.exe";
-               parameters = ["C:\\Users\\ksaff\\Workspace\\DKSService\\dkslocalserver.pl"];
+               parameters = ["C:\\Users\\ksaff\\Workspace\\dks_server\\dkslocalserver.pl"];
         } else { //os.platform() == "darwin"
                executablePath = "/Users/kilian/perl5/perlbrew/perls/perl-5.28.1/bin/perl";
                parameters = ["/Users/kilian/Workspace/DKSService/dkslocalserver.pl"];
index 3c12976..9ddaea9 100644 (file)
@@ -45,7 +45,7 @@
 <script src="../../js/moduleglobal.js"></script>
 <script src="../../js/database.js"></script>
 <script src="lib/product.js"></script>
-<script src="lib/group.js"></script>
+
 <script src="index.js"></script>
 <script>if (window.module) module = window.module;</script>
 </body>
index 903fc88..02e802b 100644 (file)
@@ -1,5 +1,3 @@
-import { on } from "cluster";
-
 var winh = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
 var tblh = winh-54;
 
@@ -9,9 +7,9 @@ function initpage(){
   loadtable();
 }
 
-$("input,select").on('focusout',function(){
-  console.log($(this).attr("id"));
-});
+// $("input,select").on('focusout',function(){
+//   console.log("TEST");
+// });
 
 function loaddatalist_productgroup(){
   var sql = "select productgroup from products where productgroup is not null group by productgroup;";
@@ -34,15 +32,15 @@ function loadtable(){
   
   var data = appdb.dbquery(sql);
   console.log(data.sqldata);
-  $('#tbl_products').html("");
+  $('#tbl_products > tbody').html("");
   for (var i in data.sqldata){
     var row = '<tr id="' +data.sqldata[i].id + '"><td></td>'+
-    '<td><input type="checkbox" class="form-control" id="visible" name="visible" value="'+data.sqldata[i].visible+ '" '+ ((data.sqldata[i].visible == '1')?"checked":'')+'/></td>' +
-    '<td><input type="text" class="form-control" value="'+((data.sqldata[i].name != null)?data.sqldata[i].name:'')+'"/><br><input class="form-control" type="text" value="' + ((data.sqldata[i].specification != null)?data.sqldata[i].specification:'')+ '" /></td>' +
-    '<td><input type="text" class="form-control" list="productgroup" value="' + (( data.sqldata[i].productgroup!= null)?data.sqldata[i].productgroup:'')+ '"/></td>' +
-    '<td><input type="text" class="form-control right" value="' + data.sqldata[i].netamount+ '" /></td>' +
-    '<td><input type="text" class="form-control right" list="vatpercent" value="' + data.sqldata[i].vatpercent+ '" /></td>' +
-    '<td><input type="text" class="form-control right" value="' + data.sqldata[i].grossamount+ '" /></td>' +
+    '<td><input type="checkbox" class="form-control" id="products-visible" name="products-visible"  onfocusout="product.savevalue(this);" value="'+data.sqldata[i].visible+ '" '+ ((data.sqldata[i].visible == '1')?"checked":'')+'/></td>' +
+    '<td><input type="text" class="form-control font-weight-bold" id="products-name" name="products-name" onfocusout="product.savevalue(this);" value="'+((data.sqldata[i].name != null)?data.sqldata[i].name:'')+'"/><br><input class="form-control" type="text" onfocusout="product.savevalue(this);" id="products-specification" name="products-specification" value="' + ((data.sqldata[i].specification != null)?data.sqldata[i].specification:'')+ '" /></td>' +
+    '<td><input type="text" class="form-control" list="productgroup" id="products-productgroup" name="products-productgroup"  onfocusout="product.savevalue(this);" value="' + (( data.sqldata[i].productgroup!= null)?data.sqldata[i].productgroup:'')+ '"/></td>' +
+    '<td><input type="text" class="form-control right" id="products-netamount" name="products-netamount"  onfocusout="product.savevalue(this);" value="' + data.sqldata[i].netamount+ '" /></td>' +
+    '<td><input type="text" class="form-control right" list="vatpercent" id="products-vatpercent" name="products-vatpercent" onfocusout="product.savevalue(this);" value="' + data.sqldata[i].vatpercent+ '" /></td>' +
+    '<td><input type="text" class="form-control right" id="products-grossamount" name="products-grossamount" onfocusout="product.savevalue(this);" value="' + data.sqldata[i].grossamount+ '" /></td>' +
     '</tr>';
     $("#tbl_products").append(row);
   }
@@ -103,4 +101,4 @@ function getTableSelectionIDs(){
     }
   }
   return ids;
-}
\ No newline at end of file
+}
diff --git a/modules/products/lib/group.js b/modules/products/lib/group.js
deleted file mode 100644 (file)
index b6ece23..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-var group = {
-  new: function(){
-
-  },
-  edit: function(){
-    
-  },
-  delete: function(){
-    
-  },
-  duplicate: function(){
-    
-  }
-}
\ No newline at end of file
index 0a4334f..798d63d 100644 (file)
@@ -1,4 +1,24 @@
 var product = {
+  savevalue: function(obj){
+    console.log(obj.type);
+    var savevalue= mpref.formatvalue(obj.value);
+    if (obj.type == "checkbox"){
+      if (obj.checked){
+        savevalue='1';
+      } else {
+        savevalue=null;
+      }
+    }
+    if (savevalue==null){
+      savevalue='null';
+    }else {
+      savevalue="'"+ savevalue+"'";
+    }
+    var ds = obj.id.split("-");
+    var sql = "update " + ds[0]+" set "+ds[1]+ "="+savevalue+" where id='"+obj.parentNode.parentNode.id+"';";
+    console.log(sql);
+    appdb.dbexec(sql);
+  },
   import: function(){
 
   },
index 631f384..3a37071 100644 (file)
@@ -24,7 +24,7 @@
            </div>
                 </div>
               </nav>
-    <div class="cotainer-fluid" style="margin-top: 52px;">            
+    <div class="cotainer-fluid bg-white" style="margin-top: 52px;">            
     <!-- <button class="btn btn-secondary" onclick="parent.usersystem.showError('MyError','My Error Message from settings!');">Show Error</button> -->
     <table class="table table-bordered table-hover table-striped" id="tbl_datasets">
         <thead class="thead-dark">
index 596f3dc..866763e 100644 (file)
@@ -4,9 +4,11 @@ const os = require('os');
 var usersystem = {
     profilepath: function(){
         var ppath="";
+        console.log(os.platform());
+        console.log(os.homedir());
         if (os.platform() == "darwin"){
             ppath = os.homedir() + '/Library/Application Support/cashbox/';
-        } else if (os.platform() == "Win32") {
+        } else if (os.platform() == "win32") {
             ppath = os.homedir() + '/AppData/Roaming/cashbox/';
         }
         return ppath;
@@ -51,6 +53,7 @@ var usersystem = {
     },
     getLocalDataSets: function(){
         var datasets =[];
+        console.log(this.profilepath());
         var files = fs.readdirSync(this.profilepath());
         files.forEach(function(file) {
             if (file.match('db\..*\.json')){