From: Kilian Saffran Date: Fri, 12 Apr 2019 12:57:41 +0000 (+0200) Subject: all window bug fixes X-Git-Url: http://cloud.dks.lu/git/?a=commitdiff_plain;h=e1c3147e005e729e9ace8a53f896042d0ab8ecc3;p=cashbox.git all window bug fixes --- diff --git a/modules/accounts/index.html b/modules/accounts/index.html index 2478e87..f3b124d 100644 --- a/modules/accounts/index.html +++ b/modules/accounts/index.html @@ -8,7 +8,7 @@ -Kunden +Konten -
+
diff --git a/modules/accounts/index.js b/modules/accounts/index.js index 1004456..7dfd848 100644 --- a/modules/accounts/index.js +++ b/modules/accounts/index.js @@ -11,13 +11,14 @@ function loadtable(){ var data = appdb.dbquery(sql); console.log("load accounts table " + sql); console.log(data.sqldata); + $('#tbl_accounts').bootstrapTable('destroy'); $('#tbl_accounts > tbody').html(""); for (var i in data.sqldata){ var row = ''+ '' + '' + '' + - '' + + '' + ''; $("#tbl_accounts").append(row); } @@ -37,21 +38,23 @@ function account_new(){ '' + '' + '' + - '' + + '' + ''; $("#tbl_accounts").prepend(row); } function account_delete(){ - var ret = parent.usersystem.showMessage("Bestätigung erforderlich","Ausgewählte Konten löschen?",null,"question",msgButtons=["JA","NEIN"],0,1); - console.log("Delete return:" + ret); - if (ret == 0){ + // var ret = parent.usersystem.showMessage("Bestätigung erforderlich","Ausgewählte Konten löschen?",null,"question",msgButtons=["JA","NEIN"],0,1); + // console.log("Delete return:" + ret); + // if (ret == 0){ //delete var ids= getTableSelectionIDs(); console.log(ids); account.delete(ids); - loadtable(); - } + for (var i in ids){ + $("#tbl_accounts tr#" + ids[i]).remove(); + } + // } } function loaddatalist_accounttypes(){ @@ -77,7 +80,7 @@ function getTableSelectionIDs(){ var ids = []; if (sel){ for (var s in sel){ - ids.push(s._id); + ids.push(sel[s]._id); } } return ids; diff --git a/modules/paywindow/index.js b/modules/paywindow/index.js index 01aef47..69635d2 100644 --- a/modules/paywindow/index.js +++ b/modules/paywindow/index.js @@ -89,7 +89,7 @@ function load_productgroup(listnum){ var listval = $("#grouplist" + listnum + " :selected").val(); //console.log(listval); $('#producttable' + listnum + " > tbody").html(""); - var sql ="select id,name,specification,replace(printf(\"%.2f\",grossamount),'.',',') as grossamount from products where productgroup='"+appdb.secvalue(listval)+"';"; + var sql ="select id,name,specification,replace(printf(\"%.2f\",grossamount),'.',',') as grossamount from products where productgroup='"+appdb.secvalue(listval)+"' order by name, specification;"; var products = appdb.dbquery(sql); for (var i in products.sqldata){ @@ -104,7 +104,7 @@ function load_productgroup(listnum){ function addproduct(idproduct){ //console.log(idproduct); - var sql = "select id,name,specification,grossamount,netamount,vatpercent,replace(printf(\"%.2f\",grossamount),'.',',') as dsp_grossamount from products where id='"+idproduct+"';"; + var sql = "select id,name,specification,productgroup,grossamount,netamount,vatpercent,replace(printf(\"%.2f\",grossamount),'.',',') as dsp_grossamount from products where id='"+idproduct+"';"; //console.log(sql); var product = appdb.dbquery(sql); var trow = ""; @@ -137,7 +137,7 @@ function addproduct(idproduct){ $("#checkout > tbody").append(trow); //console.log(sc_idprod); - shoppingcart['products'][sc_idprod] = {quantity:1,id_product:idprod,grossamount: product.sqldata[0].grossamount,vatamount: product.sqldata[0].vatamount,netamount: product.sqldata[0].netamount}; + shoppingcart['products'][sc_idprod] = {quantity:1,id_product:idprod,productname:product.sqldata[0].name,productgroup:product.sqldata[0].productgroup,grossamount: product.sqldata[0].grossamount,vatamount: product.sqldata[0].vatamount,netamount: product.sqldata[0].netamount}; } } calctotal(); @@ -174,7 +174,7 @@ function view_unpayedshoppingcarts(){ var sql = "select tr.id,strftime('%d.%m.%Y %H:%M:%S',tr.created) as created,acc.name,printf('%.2f€',sum(td.grossamount * td.quantity)) as totalamount, sum(td.quantity) as products_nbr from transactions tr left join accounts acc on (tr.id_account=acc.id) left join transactiondata td on (tr.id=td.id_transaction) where tr.status='command' group by tr.id order by tr.created asc;"; $('#tbl_commands > tbody').html(""); var data = appdb.dbquery(sql); - console.log("commands table list") + console.log("commands table list"); console.log(data); for (var i in data.sqldata){ var row = ''+ @@ -210,7 +210,13 @@ function loadcommand(id){ } function save_shoppingcart(){ - console.log(shoppingcart['products'].length); + console.log(shoppingcart['transaction']['status']); + if (shoppingcart['transaction']['status'] === undefined){ + + shoppingcart['transaction']['status'] = 'unknown'; + } + console.log(shoppingcart['transaction']); + if (Object.keys(shoppingcart['products']) == 0){ return; } @@ -227,11 +233,10 @@ function save_shoppingcart(){ if ($("#sumtotalcashamount").html() != ""){ shoppingcart['transaction']['cashamount'] = parseFloat($("#sumtotalcashamount").html().replace(',','.')); } - if (shoppingcart['transaction']['payedamount'] && shoppingcart['transaction']['payedamount'] != null){ - shoppingcart['transaction']['status'] = "payed"; - + if (shoppingcart['transaction']['payedamount'] >= 0.0){ + shoppingcart['transaction']['status'] = "payed"; } else { - shoppingcart['transaction']['status'] = "command"; + shoppingcart['transaction']['status'] = "command"; } console.log('save shoppingcard'); if (newtrans == true){ @@ -247,10 +252,10 @@ function save_shoppingcart(){ var updsql = "UPDATE transactions SET payementtype="+((shoppingcart['transaction']['paymenttype'])?"'"+shoppingcart['transaction']['paymenttype']+"'":'null')+", id_account="+((shoppingcart['transaction']['account'] && shoppingcart['transaction']['account']['id'])?"'"+shoppingcart['transaction']['account']['id']+"'":'null')+", payedamount="+((shoppingcart['transaction']['payedamount'])?shoppingcart['transaction']['payedamount']:'null')+", cashbackamount="+((shoppingcart['transaction']['cashbackamount'])?shoppingcart['transaction']['cashbackamount']:'null')+", cashamount="+((shoppingcart['transaction']['cashamount'])?shoppingcart['transaction']['cashamount']:'null')+", status='"+shoppingcart['transaction']['status']+"', statusdate=date('now') WHERE id='"+shoppingcart['transaction']['id']+"';"; appdb.dbexec(updsql); } - console.log(tsql); + //console.log(tsql); for (var i in shoppingcart["products"]){ - var tdsql = "INSERT INTO transactiondata (id, id_transaction, id_product, id_account, netamount, vatamount, grossamount, quantity) VALUES('" +appdb.generate_uuid()+"', '"+shoppingcart['transaction']['id']+"', '"+shoppingcart["products"][i]['id_product']+"', "+((shoppingcart['transaction']['account'] && shoppingcart['transaction']['account']['id'])?"'"+shoppingcart['transaction']['account']['id']+"'":'null')+", "+((shoppingcart["products"][i]['netamount'])?shoppingcart["products"][i]['netamount']:'null')+", "+((shoppingcart["products"][i]['vatamount'])?shoppingcart["products"][i]['vatamount']:'null')+", "+((shoppingcart["products"][i]['grossamount'])?shoppingcart["products"][i]['grossamount']:'null')+", "+shoppingcart["products"][i]['quantity']+");"; - console.log(tdsql); + var tdsql = "INSERT INTO transactiondata (id, id_transaction, id_product, id_account, netamount, vatamount, grossamount, quantity,productname,productgroup) VALUES('" +appdb.generate_uuid()+"', '"+shoppingcart['transaction']['id']+"', '"+shoppingcart["products"][i]['id_product']+"', "+((shoppingcart['transaction']['account'] && shoppingcart['transaction']['account']['id'])?"'"+shoppingcart['transaction']['account']['id']+"'":'null')+", "+((shoppingcart["products"][i]['netamount'])?shoppingcart["products"][i]['netamount']:'null')+", "+((shoppingcart["products"][i]['vatamount'])?shoppingcart["products"][i]['vatamount']:'null')+", "+((shoppingcart["products"][i]['grossamount'])?shoppingcart["products"][i]['grossamount']:'null')+", "+shoppingcart["products"][i]['quantity']+","+((shoppingcart['products'][i]['productname'])?"'"+shoppingcart['products'][i]['productname']+"'":'null')+","+((shoppingcart['products'][i]['productgroup'])?"'"+shoppingcart['products'][i]['productgroup']+"'":'null')+");"; + // console.log(tdsql); appdb.dbexec(tdsql); } console.log(shoppingcart); @@ -288,6 +293,7 @@ function book_shoppingcart(ptype){ $("#sumtotalchangeamount").html(""); $('#'+ptype).attr('checked', 'checked'); setpayementtype(ptype); + //console.log(shoppingcart['transaction']); $('#dlgPayement').modal('show'); } @@ -341,7 +347,7 @@ function setpayementtype(ptype){ shoppingcart['transaction']['cashbackamount'] = null; } if ($("#"+ptype).prop('checked')){ - shoppingcart['transaction']['payementtype'] =ptype; + shoppingcart['transaction']['paymenttype'] =ptype; } } @@ -389,10 +395,5 @@ function addvalue(num,type){ if (ncash >= ntotal){ shoppingcart['transaction']['payedamount'] = shoppingcart['transaction']['grossamount']; } - - // if (ncash >= ntotal){ - // $("#sumtotalpayedamount").html($("#sumtotalcashamount").html()); - // } else { - // $("#sumtotalpayedamount").html($("#pay_sumtotal").html()); - // } + //console.log(shoppingcart['transaction']); } \ No newline at end of file diff --git a/modules/products/index.html b/modules/products/index.html index a887ac4..fdacd9f 100644 --- a/modules/products/index.html +++ b/modules/products/index.html @@ -16,9 +16,8 @@
- - +
@@ -28,6 +27,7 @@
+ diff --git a/modules/products/index.js b/modules/products/index.js index 0ced1c5..8d7df96 100644 --- a/modules/products/index.js +++ b/modules/products/index.js @@ -32,11 +32,13 @@ function loadtable(){ var data = appdb.dbquery(sql); console.log(data.sqldata); + $('#tbl_products').bootstrapTable('destroy'); $('#tbl_products > tbody').html(""); for (var i in data.sqldata){ var row = ''+ '' + - '' + + ''+ + '' + '' + '' + '' + @@ -53,36 +55,41 @@ function loadtable(){ } function product_new (){ - var prid = products.new(); - var row = ''+ - '' + - '' + - '' + - '' + - '' + - '' + - ''; + var prid = product.new(); + console.log(prid) + var row = ''+ + '' + + '' + + '' + + '' + + '' + + '' + + '' + + ''; $("#tbl_products").prepend(row); + $('#tbl_products').bootstrapTable('refresh'); } function product_delete(){ - var ret = parent.usersystem.showMessage("Bestätigung erforderlich","Ausgewählte Produkte löschen?",null,"question",msgButtons=["JA","NEIN"],0,1); - console.log("Delete return:" + ret); - if (ret == 0){ + // var ret = parent.usersystem.showMessage("Bestätigung erforderlich","Ausgewählte Produkte löschen?",null,"question",msgButtons=["JA","NEIN"],0,1); + // console.log("Delete return:" + ret); + // if (ret == 0){ //delete var ids= getTableSelectionIDs(); console.log(ids); - //product.delete(ids); - loadtable(); - } + product.delete(ids); + for (var i in ids){ + $("#tbl_products tr#" + ids[i]).remove(); + } + // } } -function product_duplicate(){ - var ids= getTableSelectionIDs(); - console.log(ids); - product.duplicate(ids); - loadtable(); -} +// function product_duplicate(){ +// var ids= getTableSelectionIDs(); +// console.log(ids); +// // product.duplicate(ids); +// loadtable(); +// } function getTableSelectionID(){ var sel = $('#tbl_products').bootstrapTable('getSelections'); @@ -96,9 +103,10 @@ function getTableSelectionID(){ function getTableSelectionIDs(){ var sel = $('#tbl_products').bootstrapTable('getSelections'); var ids = []; + console.log(sel); if (sel){ for (var s in sel){ - ids.push(s._id); + ids.push(sel[s]._id); } } return ids; diff --git a/modules/products/lib/product.js b/modules/products/lib/product.js index 216274a..d139688 100644 --- a/modules/products/lib/product.js +++ b/modules/products/lib/product.js @@ -15,9 +15,44 @@ var product = { 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); + + if ((ds[1]) == 'grossamount'){ + savevalue=parseFloat(savevalue.replace("'",'')); + var tmpvat =parseFloat($("#" +obj.parentNode.parentNode.id).find("#"+ds[0] + '-vatpercent').val().replace(',','.'))/100; + //console.log("VAT:" + tmpvat); + var netamount = savevalue - ((savevalue / 1 +tmpvat) * tmpvat); + var sql2 = "update " + ds[0]+" set netamount="+netamount+" where id='"+obj.parentNode.parentNode.id+"';"; + console.log(sql2); + appdb.dbexec(sql2); + $("#" +obj.parentNode.parentNode.id).find("#"+ds[0] + '-netamount').val(netamount.toFixed(2).toString().replace('.',',')); + } + + if ((ds[1]) == 'vatpercent'){ + savevalue=parseFloat(savevalue.replace("'",'')); + savevalue = savevalue/100; + var tmpgross = parseFloat($("#" +obj.parentNode.parentNode.id).find("#"+ds[0] + '-grossamount').val().replace(',','.')); + console.log("VAT:" + savevalue + " Gross:" + tmpgross); + var netamount = tmpgross - ((tmpgross / (1 +savevalue)) * savevalue); + var sql2 = "update " + ds[0]+" set netamount="+netamount+" where id='"+obj.parentNode.parentNode.id+"';"; + console.log(sql2); + appdb.dbexec(sql2); + $("#" +obj.parentNode.parentNode.id).find("#"+ds[0] + '-netamount').val(netamount.toFixed(2).toString().replace('.',',')); + } + if ((ds[1]) == 'netamount'){ + savevalue=parseFloat(savevalue.replace("'",'')); + var tmpvat =parseFloat($("#" +obj.parentNode.parentNode.id).find("#"+ds[0] + '-vatpercent').val().replace(',','.'))/100; + //console.log("VAT:" + tmpvat); + var grossamount = savevalue + (savevalue * tmpvat); + var sql2 = "update " + ds[0]+" set grossamount="+grossamount+" where id='"+obj.parentNode.parentNode.id+"';"; + //console.log(sql2); + appdb.dbexec(sql2); + $("#" +obj.parentNode.parentNode.id).find("#"+ds[0] + '-grossamount').val(grossamount.toFixed(2).toString().replace('.',',')); + } + }, import: function(){ @@ -30,8 +65,8 @@ var product = { appdb.dbexec(sql); }, new: function(){ - var prid = appdb.generate_uuid; - appdb.dbexec("insert into products (id) VALUES ('"+ prid+"');"); + var prid = appdb.generate_uuid(); + appdb.dbexec("insert into products (id,netamount,vatpercent,grossamount) VALUES ('"+ prid+"',0.0,0.0,0.0);"); return prid; }, duplicate: function(ids){ diff --git a/modules/sales/index.html b/modules/sales/index.html index d3cbd62..dc44220 100644 --- a/modules/sales/index.html +++ b/modules/sales/index.html @@ -15,7 +15,7 @@ Verkäufe
-
+
-
+
ProduktSpecifikation Gruppe Netto (€) MwSt. (%)


- - + + - - - - + + + + + + + + +
Product
Produkt Anz.NettoBruttoBetrag
Betrag
Total00,00€
diff --git a/modules/sales/index.js b/modules/sales/index.js index cfdaefb..997823a 100644 --- a/modules/sales/index.js +++ b/modules/sales/index.js @@ -12,42 +12,28 @@ function initpage(){ function loadtable(){ - // var sql = 'select ij.id,ij.byear,ij.date as datesortable, STRFTIME("%d.%m.%Y",ij.date) as date,ij.id,rec.company as recepient, sen.company as sender,ij.reference, ' + - // 'printf("%.2f",CAST(sum(pos.quantity * pos.unitamount) as real)) as netamount, ' + - // 'printf("%.2f",CAST(case when pos.taxpercent > 0 then sum(pos.taxpercent * pos.quantity * pos.unitamount) else 0.0 end AS REAL)) as taxamount, ' + - // 'printf("%.2f",CAST(sum(pos.quantity * pos.unitamount) + case when pos.taxpercent > 0 then sum(pos.taxpercent * pos.quantity * pos.unitamount) else 0.0 end AS real)) as totalamount, ' + - // 'printf("%.2f",COALESCE(ij.payedamount,0.0)) as payedamount, ' + - // 'ij.status ' + - // 'from salesjournal ij ' + - // 'left join salespositions pos on (ij.id=pos.id_sales) ' + - // 'left join accounts rec on (ij.id_receipient = rec.id) ' + - // 'left join accounts sen on (ij.id_sender = sen.id) where ij.byear=' + cfg.byear +' group by pos.id_sales order by date desc;'; - // var data = appdb.dbquery(sql); - // //console.log(data.sqldata); - // for (var i in data.sqldata){ - // var cstatus = "secondary"; - // if (data.sqldata[i].status== "bezahlt"){ cstatus = "success"; } - // if (data.sqldata[i].status== "überfällig"){ cstatus = "danger"; } - // if (data.sqldata[i].status== "verschickt"){ cstatus = "warning"; } - // var acolor = ""; - // if (data.sqldata[i].totalamount.startsWith("-")){ acolor = "text-danger"; } - // var row = ''+ - // '' + - // ''+data.sqldata[i].datesortable+' ' + data.sqldata[i].date+ '' + - // '' + data.sqldata[i].recepient+ '' + - // '' + data.sqldata[i].sender+ '' + - // '' + data.sqldata[i].reference+ '' + - // '' + data.sqldata[i].status+ '' + - // '' + data.sqldata[i].totalamount+ ' €' + - - // ''; - // $("#tbl_saless").append(row); - // } + var sql = "select td.productname,sum(td.quantity) as quantity,replace(printf('%.2f€',sum(td.quantity *td.grossamount)),'.',',') as grossamount,sum(td.quantity *td.grossamount) as grossamount_calc from transactiondata td left join transactions tr on (td.id_transaction=tr.id) where tr.status='payed' group by td.productname;"; + var data = appdb.dbquery(sql); + $('#tbl_accounts').bootstrapTable('destroy'); + $('#tbl_accounts > tbody').html(""); + var sumquantity = 0; + var sumgross = 0.00; + for (var i in data.sqldata){ + var row = ''+ + ''+ data.sqldata[i].productname +'' + + ''+ data.sqldata[i].quantity +'' + + ''+ data.sqldata[i].grossamount +'' + + ''; + $("#tbl_sales").append(row); + sumquantity = sumquantity + parseInt(data.sqldata[i].quantity); + sumgross = sumgross + parseFloat(data.sqldata[i].grossamount_calc); + } + $("#sumquantity").html(sumquantity); + $("#sumgross").html(sumgross.toFixed(2).replace('.',',') + "€"); $('#tbl_sales').bootstrapTable({ pagination: false, search: false, - height: tblh, - clickToSelect: true + height: tblh }); diff --git a/modules/transactions/index.html b/modules/transactions/index.html index cfb0709..10cb6c6 100644 --- a/modules/transactions/index.html +++ b/modules/transactions/index.html @@ -15,36 +15,72 @@ Transaktionen
- - - - -
- + + + + +
-
- +
+
+ + + + - - + -
ZeitpunktKontoBetragBezahltCash / Wechselgeld BezahlartKundeTischAnz. Produkte StatusBetrag
+ diff --git a/modules/transactions/index.js b/modules/transactions/index.js index 7c61e85..ac6dd6b 100644 --- a/modules/transactions/index.js +++ b/modules/transactions/index.js @@ -1,49 +1,45 @@ var winh = Math.max(document.documentElement.clientHeight, window.innerHeight || 0); var tblh = winh-54; -var cfg = { - byear: 2018 -} +// var cfg = { +// byear: 2018 +// } function initpage(){ console.log(appdb.url); - loadyears(); + // loadyears(); loadtable(); } function loadtable(){ - var sql = 'select ij.id,ij.byear,ij.date as datesortable, STRFTIME("%d.%m.%Y",ij.date) as date,ij.id,rec.company as recepient, sen.company as sender,ij.reference, ' + - 'printf("%.2f",CAST(sum(pos.quantity * pos.unitamount) as real)) as netamount, ' + - 'printf("%.2f",CAST(case when pos.taxpercent > 0 then sum(pos.taxpercent * pos.quantity * pos.unitamount) else 0.0 end AS REAL)) as taxamount, ' + - 'printf("%.2f",CAST(sum(pos.quantity * pos.unitamount) + case when pos.taxpercent > 0 then sum(pos.taxpercent * pos.quantity * pos.unitamount) else 0.0 end AS real)) as totalamount, ' + - 'printf("%.2f",COALESCE(ij.payedamount,0.0)) as payedamount, ' + - 'ij.status ' + - 'from cashbox ij ' + - 'left join invoicepositions pos on (ij.id=pos.id_invoice) ' + - 'left join accounts rec on (ij.id_receipient = rec.id) ' + - 'left join accounts sen on (ij.id_sender = sen.id) where ij.byear=' + cfg.byear +' group by pos.id_invoice order by date desc;'; + var sql = "select tr.id,strftime('%d.%m.%Y %H:%M:%S',tr.created) as created ,tr.created as datesort,acc.name,replace(printf('%.2f€',sum(td.grossamount * td.quantity)),'.',',') as totalamount,replace(printf('%.2f€',payedamount),'.',',') as payedamount,payementtype, replace(printf('%.2f€',cashamount),'.',',') as cashamount,replace(printf('%.2f€',cashbackamount),'.',',') as cashbackamount, sum(td.quantity) as products_nbr,status from transactions tr left join accounts acc on (tr.id_account=acc.id) left join transactiondata td on (tr.id=td.id_transaction) group by tr.id order by tr.created desc;"; + $('#tbl_transactions').bootstrapTable('destroy'); + $("#tbl_transactions > tbody").html(""); var data = appdb.dbquery(sql); //console.log(data.sqldata); for (var i in data.sqldata){ var cstatus = "secondary"; - if (data.sqldata[i].status== "bezahlt"){ cstatus = "success"; } - if (data.sqldata[i].status== "überfällig"){ cstatus = "danger"; } - if (data.sqldata[i].status== "verschickt"){ cstatus = "warning"; } - var acolor = ""; - if (data.sqldata[i].totalamount.startsWith("-")){ acolor = "text-danger"; } + if (data.sqldata[i].status== "command"){ cstatus = "warning"; } + if (data.sqldata[i].status== "payed"){ cstatus = "success"; } + if (data.sqldata[i].status== "canceled"){ cstatus = "danger"; } + if (data.sqldata[i].status== "payed") { data.sqldata[i].status= "bezahlt";} + if (data.sqldata[i].status== "canceled") { data.sqldata[i].status= "storniert";} + if (data.sqldata[i].status== "command") { data.sqldata[i].status= "bestellt";} var row = ''+ '' + - ''+data.sqldata[i].datesortable+' ' + data.sqldata[i].date+ '' + - '' + data.sqldata[i].recepient+ '' + - '' + data.sqldata[i].sender+ '' + - '' + data.sqldata[i].reference+ '' + - '' + data.sqldata[i].status+ '' + - '' + data.sqldata[i].totalamount+ ' €' + + ''+data.sqldata[i].datesort+' ' + data.sqldata[i].created+ '' + + '' + ((data.sqldata[i].name == null)?'':data.sqldata[i].name)+ '' + + '' + data.sqldata[i].totalamount+ '' + + '' + data.sqldata[i].payedamount+ '' + + '' + data.sqldata[i].cashamount+ '/'+ data.sqldata[i].cashbackamount+ '' + + '' + ((data.sqldata[i].payementtype == null)?'':data.sqldata[i].payementtype)+ '' + + '' + ((data.sqldata[i].products_nbr == null)?'':data.sqldata[i].products_nbr)+ '' + + '' + data.sqldata[i].status+ '' + ''; - $("#tbl_invoices").append(row); + $("#tbl_transactions").append(row); } - $('#tbl_invoices').bootstrapTable({ + $('#tbl_transactions').bootstrapTable({ pagination: false, search: false, height: tblh, @@ -53,30 +49,61 @@ function loadtable(){ } -function loadyears(){ - sql = "select byear from cashbox group by byear order by byear asc;"; + +function view_details(){ + var trid= getTableSelectionID(); + //console.log(trid); + var sql = "select tr.id,tr.quantity,pr.name, pr.productgroup,replace(printf('%.2f€',tr.grossamount),'.',',') as grossamount from transactiondata tr join products pr on (tr.id_product=pr.id) where tr.id_transaction='"+trid+"'"; + $('#tbl_transdata > tbody').html(""); var data = appdb.dbquery(sql); - //onsole.log(data.sqldata); + //console.log("commands table list") + //console.log(data); for (var i in data.sqldata){ - $("#timerange").append('' + data.sqldata[i].byear+''); + var row = ''+ + ''+data.sqldata[i].quantity+ '' + + ''+((data.sqldata[i].name != null)?data.sqldata[i].name:'')+ '' + + ''+data.sqldata[i].grossamount+ '' + + '' + + ''; + $("#tbl_transdata").append(row); } - + $('#tbl_transdata').bootstrapTable({ + pagination: false, + search: false, + }); + $('#dlgTransdata').modal('show'); } -function invoice_edit(){ - var inv_id= getTableSelectionID(); - if (inv_id){ - parent.browserapp.loadmodulepage('invoices','invoice',{"id":inv_id}); +function delete_transaction(){ + var ids = getTableSelectionIDs(); + console.log(ids); + var sql="DELETE FROM transactiondata WHERE id_transaction in ('"+ ids.join("','")+"')"; + appdb.dbexec(sql); + var sql2="DELETE FROM transactions WHERE id in ('"+ ids.join("','")+"')"; + appdb.dbexec(sql2); + for ( i in ids){ + $("#tbl_transactions tr#" + ids[i]).remove(); } - + //$('#tbl_transactions').bootstrapTable('refresh'); } -function invoice_delete(){ - +function deletetransdata(id){ + var sql="DELETE FROM transactiondata WHERE id='"+ id+"';"; + appdb.dbexec(sql); + $('#tbl_transdata tr#' + id).remove(); + loadtable(); + //$('#tbl_transactions').bootstrapTable('refresh'); } -function invoice_duplicate(){ - + +function cancel_transactions(){ + var ids = getTableSelectionIDs(); + var sql="UPDATE transactions set status='canceled',statusdate=date('now') WHERE in ('"+ ids.join("','")+"');"; + appdb.dbexec(sql); + for ( i in ids){ + $("#tbl_transactions tr#" + ids[i] + " > td.status").attr("class",'status btn-danger'); + $("#tbl_transactions tr#" + ids[i] + " > td.status").html("storniert"); + } } function change_timerange(){ @@ -84,7 +111,7 @@ function change_timerange(){ } function getTableSelectionID(){ - var sel = $('#tbl_invoices').bootstrapTable('getSelections'); + var sel = $('#tbl_transactions').bootstrapTable('getSelections'); var id = null; if (sel){ id=sel[0]._id; } @@ -93,11 +120,15 @@ function getTableSelectionID(){ } function getTableSelectionIDs(){ - var sel = $('#tbl_invoices').bootstrapTable('getSelections'); + + var sel = $('#tbl_transactions').bootstrapTable('getSelections'); + //console.log("selections"); + //console.log(sel); var ids = []; if (sel){ for (var s in sel){ - ids.push(s._id); + //console.log(sel[s]._id); + ids.push(sel[s]._id); } } return ids;