misc changes
authorKilian Saffran <ksaffran@dks.lu>
Sun, 19 May 2019 10:09:04 +0000 (12:09 +0200)
committerKilian Saffran <ksaffran@dks.lu>
Sun, 19 May 2019 10:09:04 +0000 (12:09 +0200)
modules/bookings/index.js
modules/invoices/form_invoice.html
modules/invoices/form_invoice.js
modules/invoices/index.js
modules/products/index.html
modules/products/index.js

index 3cbb2fb..6797a4f 100644 (file)
@@ -193,10 +193,13 @@ function setselection(id){
   if (shiftdown === true){
     if ($("#" + id).hasClass('highlight')){
       $("#" + id).removeClass('highlight');  
+      selection.splice($.inArray(id, selection),1);
     }else {
       $("#" + id).addClass('highlight');
+      selection.push(id);
     }
   } else {
     $("#" + id).addClass('highlight').siblings().removeClass('highlight');
+    selection = [id];
   }
 }
index 09b7480..745ba7b 100644 (file)
             </nav>
           </div>
         </div>
-        <div class="row">
-          <table class="table table-bordered table-hover table-striped" id="tbl_invoicedata">
-            <thead class="thead-dark">
-              <tr>
-                <th data-checkbox="true"></th>
-                <th data-sortable="true">Description</th>
-                <th data-sortable="true">Qty</th>
-                <th data-sortable="true">Unit</th>
-                <th data-sortable="true">Price</th>
-                <th data-sortable="true">VAT</th>
-                <th data-sortable="true">Discount</th>
-                <th data-sortable="true">Sums</th>
-              </tr>
-            </thead>
-          </table>
+        <div class="row"  style="margin: 0px;">
+          <table style="width: 100%;" class="noselect">
+            <tr>
+              <td style="padding: 0px; margin: 0px;">
+                <table class="table" style="width: 100%; margin: 0px;"  id="tbl_bookings_head">
+                  <thead class="thead-dark"> 
+                    <tr>
+                    <th>Beschreibung</th>
+                    <th>Anz.</th>
+                    <th>Einheit</th>
+                    <th>Betrag</th>
+                    <th>MwSt.</th>
+                    <th>Rabatt.</th>
+                    <th>Netto</th>
+                  </tr>
+                    </thead>
+                </table>
+              </td>
+            </tr>
+            <tr>
+              <td>
+                <div style="width: 100%; height: 60vh; overflow-y: scroll;">
+                <table id="tbl_bookings" style="width: 100%;" class="table table-bordered table-hover table-striped">
+                  <tbody></tbody>
+                </table>
+              </div>
+              </td>
+            </tr>
+          </table> 
         </div>
       </div>
       <div aria-labelledby="files-tab" class="tab-pane fade" id="files" role="tabpanel">
index e98ccbc..23f3e47 100644 (file)
@@ -13,6 +13,7 @@ function initpage(){
     getaccounts();
     if (mpref.cfg.id){
         getinvoicedata(mpref.cfg.id);
+        loadinvoicepositions(mpref.cfg.id);
     } else {
         //load default new invoice data
     }
@@ -75,7 +76,44 @@ function getinvoicedata(id){
     }
 }
 
-function loadinvoicepositions(){
-    
+function loadinvoicepositions(id){
+    var sql = "select id,quantity, printf(\"%.2f\",unitamount) as unitamount,coalesce(unit,'') as unit,description,printf(\"%.2f\",taxpercent) as taxpercent,printf(\"%.2f\",discountpercent) as discountpercent,printf(\"%.2f\",quantity * unitamount) as netamount from invoicepositions where id_invoice='"+id+"';";
+    var data = appdb.dbquery(sql);
+    $("#tbl_bookings > tbody").html("");
+    for (var i in data.sqldata){
+      var row = '<tr onclick="setselection(\''+ data.sqldata[i].id +'\');" id="' +data.sqldata[i].id + '">'+
+      '<td>'+data.sqldata[i].description+ '</td>' +
+      '<td>'+data.sqldata[i].quantity+ '</td>' +
+      '<td>' + data.sqldata[i].unit+ '</td>' +
+      '<td>' + data.sqldata[i].unitamount+ '</td>' +
+      '<td>' + data.sqldata[i].taxpercent+ '</td>' +
+      '<td>' + data.sqldata[i].discountpercent+ '</td>' +
+      '<td>' + data.sqldata[i].netamount+ ' €</td>' +
+      
+      '</tr>';
+      $("#tbl_bookings > tbody").append(row);
+    }
+    var cols =  $("#tbl_bookings > tbody > tr:first-child").children();
+    var colnum = cols.length -1;
+    console.log("childnum:" + colnum);
+    for (var i=1;i<=colnum;i++){
+      wx = $("#tbl_bookings > tbody > tr:first-child > td:nth-child("+ i +")").width();
+      wx = wx +3;
+      $("#tbl_bookings > thead > tr > th:nth-child("+ i +")").width(wx);
+    }
 }
 
+function setselection(id){
+  if (shiftdown === true){
+    if ($("#" + id).hasClass('highlight')){
+      $("#" + id).removeClass('highlight');  
+      selection.splice($.inArray(id, selection),1);
+    }else {
+      $("#" + id).addClass('highlight');
+      selection.push(id);
+    }
+  } else {
+    $("#" + id).addClass('highlight').siblings().removeClass('highlight');
+    selection = [id];
+  }
+}
\ No newline at end of file
index 32d1cf4..bdaab6b 100644 (file)
@@ -112,10 +112,10 @@ function loadtable(){
 // }
 
 function invoice_edit(){
-  // var inv_id= 
-  // if (inv_id){
-  //   parent.browserapp.loadmodulepage('invoices','form_invoice',{"id":inv_id});
-  // }
+  var inv_id= selection[0];
+   if (inv_id){
+     parent.browserapp.loadmodulepage('invoices','form_invoice',{"id":inv_id});
+  }
   
 }
 
@@ -191,10 +191,13 @@ function setselection(id){
   if (shiftdown === true){
     if ($("#" + id).hasClass('highlight')){
       $("#" + id).removeClass('highlight');  
+      selection.splice($.inArray(id, selection),1);
     }else {
       $("#" + id).addClass('highlight');
+      selection.push(id);
     }
   } else {
     $("#" + id).addClass('highlight').siblings().removeClass('highlight');
+    selection = [id];
   }
 }
index be31319..6bf10d2 100644 (file)
@@ -30,7 +30,7 @@
           <table class="table" style="width: 100%; margin: 0px;"  id="tbl_products_head">
             <thead class="thead-dark"> 
               <tr>
-              <th>ID</th>
+              <!-- <th>ID</th> -->
               <th>Type</th>
               <th>Unit</th>
               <th>Beschreibung</th>
@@ -43,7 +43,7 @@
       </tr>
       <tr>
         <td>
-          <div style="width: 100%; height: 80vh; overflow-y: scroll;">
+          <div style="width: 100%; height: 90vh; overflow-y: scroll;">
           <table id="tbl_products" style="width: 100%;" class="table table-bordered table-hover table-striped">
             <tbody></tbody>
           </table>
index cb89619..923c73d 100644 (file)
@@ -58,7 +58,7 @@ function loadtable(){
   //console.log(data.sqldata);
   for (var i in data.sqldata){
     var row = '<tr onclick="setselection(\''+ data.sqldata[i].id +'\');" id="' +data.sqldata[i].id + '">'+
-    '<td>' + ((data.sqldata[i].ident != null)?data.sqldata[i].ident:'')+ '</td>' +
+    // '<td>' + ((data.sqldata[i].ident != null)?data.sqldata[i].ident:'')+ '</td>' +
     '<td>' + ((data.sqldata[i].ptype != null)?data.sqldata[i].ptype:'')+ '</td>' +
     '<td>' + ((data.sqldata[i].unit != null)?data.sqldata[i].unit:'')+ '</td>' +
     '<td>' + ((data.sqldata[i].description != null)?data.sqldata[i].description:'')+ '</td>' +
@@ -120,10 +120,13 @@ function setselection(id){
   if (shiftdown === true){
     if ($("#" + id).hasClass('highlight')){
       $("#" + id).removeClass('highlight');  
+      selection.splice($.inArray(id, selection),1);
     }else {
       $("#" + id).addClass('highlight');
+      selection.push(id);
     }
   } else {
     $("#" + id).addClass('highlight').siblings().removeClass('highlight');
+    selection = [id];
   }
-}
+}
\ No newline at end of file