From: Kilian Saffran Date: Sun, 28 Apr 2019 13:59:13 +0000 (+0200) Subject: bookings invoices prodocts X-Git-Tag: 0.7beta~25 X-Git-Url: http://cloud.dks.lu/git/?a=commitdiff_plain;h=2c1e0c0f367c7e004808135e7a399f05d2213a93;p=invoicejournal.git bookings invoices prodocts --- diff --git a/db/invoicejournal.sqlite b/db/invoicejournal.sqlite new file mode 100755 index 0000000..49c345e Binary files /dev/null and b/db/invoicejournal.sqlite differ diff --git a/modules/bookings/index.html b/modules/bookings/index.html index 400fe78..7daac10 100644 --- a/modules/bookings/index.html +++ b/modules/bookings/index.html @@ -18,16 +18,7 @@ -
- - - -
- +
@@ -61,18 +52,6 @@
- -
@@ -181,9 +160,6 @@ - diff --git a/modules/bookings/index.js b/modules/bookings/index.js index e6f2687..3cbb2fb 100644 --- a/modules/bookings/index.js +++ b/modules/bookings/index.js @@ -54,9 +54,10 @@ function loadtable(){ } } + console.log(where); sums = { planned: {cnt:0,sum:0},sended: {cnt:0,sum:0},payed: {cnt:0,sum:0},delayed: {cnt:0,sum:0},total: {cnt:0,sum:0}}; - var sql = "select strftime('%d.%m.%Y',invoicepositions.bookingdate) as bookingdate, invoicepositions.bookingdate as datesortable,invoicepositions.id,sender.company as sender,receipient.company as receipient, invoicepositions.description,replace(printf('%.2f€',quantity * unitamount),'.',',') as amount,quantity * unitamount as sumamount , invoicejournal.status from invoicepositions left join accounts sender on (invoicepositions.id_sender=sender.id) left join invoicejournal on (invoicepositions.id_invoice=invoicejournal.id) left join accounts receipient on (invoicepositions.id_receipient=receipient.id)" + where + " order by invoicepositions.bookingdate desc;"; - console.log(sql); + var sql = "select strftime('%d.%m.%Y',invoicepositions.bookingdate) as bookingdate, invoicepositions.bookingdate as datesortable,invoicepositions.id,sender.company as sender,receipient.company as receipient, invoicepositions.description,replace(printf('%.2f€',quantity * unitamount),'.',',') as amount,quantity * unitamount as sumamount , invoicejournal.status from invoicepositions left join accounts sender on (invoicepositions.id_sender=sender.id) left join invoicejournal on (invoicepositions.id_invoice=invoicejournal.id) left join accounts receipient on (invoicepositions.id_receipient=receipient.id) " + where + " order by invoicepositions.bookingdate desc;"; + //console.log(sql); //$('#tbl_bookings').bootstrapTable('destroy'); $("#tbl_bookings > tbody").html(""); var data = appdb.dbquery(sql); @@ -168,9 +169,12 @@ function setfilter(id,field){ loadtable(); } +function booking_new(){ + parent.browserapp.loadmodulepage('bookings','form_booking',{"id":null}); +} function booking_edit(){ - var inv_id= getTableSelectionID(); + //var inv_id= getTableSelectionID(); if (inv_id){ parent.browserapp.loadmodulepage('bookings','form_booking',{"id":inv_id}); } diff --git a/modules/invoices/index.html b/modules/invoices/index.html index f6c0642..77a0dab 100644 --- a/modules/invoices/index.html +++ b/modules/invoices/index.html @@ -4,7 +4,7 @@ - + @@ -31,24 +31,48 @@
-
- - - - - - - - - - - -
DatumEmpfängerSenderReferenzStatusBetrag
+
+ + + + + + + +
+ + + + + + + + + + + +
Referenz + + Betrag
+
+
+ + +
+
+
+
- diff --git a/modules/invoices/index.js b/modules/invoices/index.js index d43a041..32d1cf4 100644 --- a/modules/invoices/index.js +++ b/modules/invoices/index.js @@ -1,18 +1,57 @@ var winh = Math.max(document.documentElement.clientHeight, window.innerHeight || 0); var tblh = winh-54; -var cfg = { - byear: 2018 -} +var pagepref = undefined; +var selection = []; +var shiftdown = false; function initpage(){ - console.log(appdb.url); - loadyears(); + + pagepref = parent.usersystem.getPreference("invoices"); + if (pagepref === null){ + pagepref= {}; + } + console.log(pagepref); + //loadyears(); loadtable(); + load_senders(); + load_receipients(); + load_dateranges(); } +$(document).on('keydown',function(evt){ + if (evt.key= "Shift"){ + shiftdown = true; + } +}); + +$(document).on('keyup',function(evt){ + if (evt.key = "Shift"){ + shiftdown = false; + } +}); 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, ' + + var where = ''; + if (pagepref && pagepref.filter && Object.keys(pagepref.filter).length > 0){ + var whfilter = []; + for (var i in pagepref.filter){ + console.log(i); + if (i == 'date'){ + if ($("#daterange :selected").text() != ''){ + whfilter.push(pagepref.filter[i] + "='" + $("#daterange :selected").text() + "'"); + } + + } else { + whfilter.push(i + "='" + pagepref.filter[i] + "'"); + } + + } + if (whfilter.length > 0){ + where = ' where ' + whfilter.join( " AND "); + } + + } + var sql = 'select ij.id,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, ' + @@ -21,9 +60,10 @@ function loadtable(){ 'from invoicejournal 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;'; + 'join accounts sen on (ij.id_sender = sen.id) ' + where +' group by pos.id_invoice order by date desc;'; + $("#tbl_invoices > tbody").html(""); var data = appdb.dbquery(sql); - //console.log(data.sqldata); + //console.log(sql); for (var i in data.sqldata){ var cstatus = "secondary"; if (data.sqldata[i].status== "bezahlt"){ cstatus = "success"; } @@ -31,8 +71,8 @@ function loadtable(){ if (data.sqldata[i].status== "verschickt"){ cstatus = "warning"; } var acolor = ""; if (data.sqldata[i].totalamount.startsWith("-")){ acolor = "text-danger"; } - var row = ''+ - '' + + var row = ''+ + ''+data.sqldata[i].datesortable+' ' + data.sqldata[i].date+ '' + '' + data.sqldata[i].recepient+ '' + '' + data.sqldata[i].sender+ '' + @@ -41,34 +81,41 @@ function loadtable(){ '' + data.sqldata[i].totalamount+ ' €' + ''; - $("#tbl_invoices").append(row); + $("#tbl_invoices > tbody").append(row); } - - $('#tbl_invoices').bootstrapTable({ - pagination: false, - search: false, - height: tblh, - clickToSelect: true - }); + var cols = $("#tbl_invoices > tbody > tr:first-child").children(); + var colnum = cols.length -1 + console.log("childnum:" + colnum); + for (var i=1;i<=colnum;i++){ + wx = $("#tbl_invoices > tbody > tr:first-child > td:nth-child("+ i +")").width(); + wx = wx +3; + $("#tbl_invoices_head > thead > tr > th:nth-child("+ i +")").width(wx); + } + // $('#tbl_invoices').bootstrapTable({ + // pagination: false, + // search: false, + // height: tblh, + // clickToSelect: true + // }); } -function loadyears(){ - sql = "select byear from invoicejournal group by byear order by byear asc;"; - var data = appdb.dbquery(sql); - //onsole.log(data.sqldata); - for (var i in data.sqldata){ - $("#timerange").append('' + data.sqldata[i].byear+''); - } +// function loadyears(){ +// sql = "select byear from invoicejournal group by byear order by byear asc;"; +// var data = appdb.dbquery(sql); +// //onsole.log(data.sqldata); +// for (var i in data.sqldata){ +// $("#timerange").append('' + data.sqldata[i].byear+''); +// } -} +// } function invoice_edit(){ - var inv_id= getTableSelectionID(); - if (inv_id){ - parent.browserapp.loadmodulepage('invoices','form_invoice',{"id":inv_id}); - } + // var inv_id= + // if (inv_id){ + // parent.browserapp.loadmodulepage('invoices','form_invoice',{"id":inv_id}); + // } } @@ -80,26 +127,74 @@ function invoice_duplicate(){ } -function change_timerange(){ +// function change_timerange(){ +// } + +function load_senders(){ + var sql = "select distinct (sender.company) as sender from invoicepositions left join accounts sender on (invoicepositions.id_sender=sender.id) order by sender.company;"; + $("#sender").html(''); + var data = appdb.dbquery(sql); + + for (var i in data.sqldata){ + $("#sender").append(''); + } + if (pagepref && pagepref.filter && pagepref.filter.sender && pagepref.filter.sender != ''){ + //console.log("set selection:" + pagepref.filter.sender); + $("#sender").val(pagepref.filter.sender); + } } -function getTableSelectionID(){ - var sel = $('#tbl_invoices').bootstrapTable('getSelections'); - var id = null; - - if (sel){ id=sel[0]._id; } - console.log("Selected ID:" + id); - return id; +function load_receipients(){ + var sql = "select distinct (receipient.company) as receipient from invoicepositions left join accounts receipient on (invoicepositions.id_receipient=receipient.id) order by receipient.company;"; + $("#receipient").html(''); + var data = appdb.dbquery(sql); + + for (var i in data.sqldata){ + $("#receipient").append(''); + } + if (pagepref && pagepref.filter && pagepref.filter.receipient && pagepref.filter.receipient != ''){ + //console.log("set selection:" + pagepref.filter.receipient); + $("#receipient").val(pagepref.filter.receipient); + } +} + +function load_dateranges(){ + var sql = "select strftime('%Y',date) as daterange, 'strftime(''%Y'',date)' as filter from invoicejournal where date is not null group by daterange union select strftime('%Y %m',date) as daterange , 'strftime(''%Y %m'',date)' as filter from invoicejournal where date is not null group by daterange union select strftime('%Y Q',date) || (((CAST(strftime('%m',date) AS INT) -1 ) / 3) +1) as daterange ,'strftime(''%Y Q'',date) || (((CAST(strftime(''%m'',date) AS INT) -1 ) / 3) +1)' as filter from invoicejournal where date is not null group by daterange order by daterange desc;"; + $("#daterange").html(''); + var data = appdb.dbquery(sql); + + for (var i in data.sqldata){ + $("#daterange").append(''); + } } -function getTableSelectionIDs(){ - var sel = $('#tbl_invoices').bootstrapTable('getSelections'); - var ids = []; - if (sel){ - for (var s in sel){ - ids.push(s._id); + +function setfilter(id,field){ + console.log("setFilter"); + if (pagepref['filter'] === undefined){ + pagepref['filter'] = {}; + } + if ($("#" + id + " :selected").val() != ""){ + pagepref['filter'][field] = $("#" + id + " :selected").val(); + } + else { + delete pagepref['filter'][field]; + $("#" + id + "").val($("#"+ id +" option:first").val()); + } + parent.usersystem.setPreference('invoices',pagepref); + loadtable(); +} + + +function setselection(id){ + if (shiftdown === true){ + if ($("#" + id).hasClass('highlight')){ + $("#" + id).removeClass('highlight'); + }else { + $("#" + id).addClass('highlight'); } + } else { + $("#" + id).addClass('highlight').siblings().removeClass('highlight'); } - return ids; -} \ No newline at end of file +} diff --git a/modules/products/index.html b/modules/products/index.html index 496178c..be31319 100644 --- a/modules/products/index.html +++ b/modules/products/index.html @@ -4,7 +4,6 @@ - @@ -25,12 +24,37 @@
- + + + + + + + +
+ + + + + + + + + + + +
IDTypeUnitBeschreibungMwSt.Betrag
+
+
+ + +
+
+
- diff --git a/modules/products/index.js b/modules/products/index.js index 2f60333..cb89619 100644 --- a/modules/products/index.js +++ b/modules/products/index.js @@ -1,3 +1,129 @@ +var winh = Math.max(document.documentElement.clientHeight, window.innerHeight || 0); +var tblh = winh-54; +var pagepref = undefined; +var selection = []; + +var shiftdown = false; function initpage(){ + console.log(appdb.url); + pagepref = parent.usersystem.getPreference("products"); + if (pagepref === null){ + pagepref= {}; + } + console.log(pagepref); + loadtable(); +} + +$(document).on('keydown',function(evt){ + if (evt.key= "Shift"){ + shiftdown = true; + } +}); + +$(document).on('keyup',function(evt){ + if (evt.key = "Shift"){ + shiftdown = false; + } +}); + +function loadtable(){ + // var where = ''; + // if (pagepref && pagepref.filter && Object.keys(pagepref.filter).length > 0){ + // var whfilter = []; + // for (var i in pagepref.filter){ + // console.log(i); + // if (i == 'bookingdate'){ + // if ($("#daterange :selected").text() != ''){ + // whfilter.push(pagepref.filter[i] + "='" + $("#daterange :selected").text() + "'"); + // } + + // } else { + // whfilter.push(i + "='" + pagepref.filter[i] + "'"); + // } + + // } + // if (whfilter.length > 0){ + // where = ' where ' + whfilter.join( " AND "); + // } -} \ No newline at end of file + // } + // console.log(where); + // sums = { planned: {cnt:0,sum:0},sended: {cnt:0,sum:0},payed: {cnt:0,sum:0},delayed: {cnt:0,sum:0},total: {cnt:0,sum:0}}; + + var sql = "SELECT id, ident, ptype, unit, replace(printf('%.2f€',unitamount),'.',',') as unitamount, printf('%.2f%',100 * vatpercent,'.',',') as vatpercent, description FROM products;"; + //console.log(sql); + //$('#tbl_bookings').bootstrapTable('destroy'); + $("#tbl_products > tbody").html(""); + var data = appdb.dbquery(sql); + //console.log(data.sqldata); + for (var i in data.sqldata){ + var row = ''+ + '' + ((data.sqldata[i].ident != null)?data.sqldata[i].ident:'')+ '' + + '' + ((data.sqldata[i].ptype != null)?data.sqldata[i].ptype:'')+ '' + + '' + ((data.sqldata[i].unit != null)?data.sqldata[i].unit:'')+ '' + + '' + ((data.sqldata[i].description != null)?data.sqldata[i].description:'')+ '' + + '' + ((data.sqldata[i].vatpercent != null)?data.sqldata[i].vatpercent:'') + '' + + '' + ((data.sqldata[i].unitamount != null)?data.sqldata[i].unitamount:'')+ '' + + ''; + + $("#tbl_products > tbody").append(row); + } + var cols = $("#tbl_products > tbody > tr:first-child").children(); + var colnum = cols.length -1 + console.log("childnum:" + colnum); + for (var i=1;i<=colnum;i++){ + wx = $("#tbl_products > tbody > tr:first-child > td:nth-child("+ i +")").width(); + wx = wx +3; + $("#tbl_products_head > thead > tr > th:nth-child("+ i +")").width(wx); + } +} + + + +function setfilter(id,field){ + console.log("setFilter"); + if (pagepref['filter'] === undefined){ + pagepref['filter'] = {}; + } + if ($("#" + id + " :selected").val() != ""){ + pagepref['filter'][field] = $("#" + id + " :selected").val(); + } + else { + delete pagepref['filter'][field]; + $("#" + id + "").val($("#"+ id +" option:first").val()); + } + parent.usersystem.setPreference('products',pagepref); + loadtable(); +} + +function product_new(){ + parent.browserapp.loadmodulepage('products','form_product',{"id":null}); +} + +function product_edit(){ + //var inv_id= getTableSelectionID(); + if (inv_id){ + parent.browserapp.loadmodulepage('bookings','form_booking',{"id":inv_id}); + } + +} + +function product_delete(){ + +} + +function product_duplicate(){ + +} + +function setselection(id){ + if (shiftdown === true){ + if ($("#" + id).hasClass('highlight')){ + $("#" + id).removeClass('highlight'); + }else { + $("#" + id).addClass('highlight'); + } + } else { + $("#" + id).addClass('highlight').siblings().removeClass('highlight'); + } +} diff --git a/server/Module/PDFExtract.pm b/server/Module/PDFExtract.pm index 393a1f9..d92b6d8 100644 --- a/server/Module/PDFExtract.pm +++ b/server/Module/PDFExtract.pm @@ -141,8 +141,6 @@ sub parsestatement(){ ]; } - - my $pxdata = (); my @pdata = (); my $jdata = ();