From: kilian Date: Mon, 20 Apr 2020 10:55:51 +0000 (+0200) Subject: v20200420 X-Git-Tag: 0.7beta~7 X-Git-Url: http://cloud.dks.lu/git/?a=commitdiff_plain;h=d78a50f2cca18a95cb8f47ea9982b583b928a28f;p=invoicejournal.git v20200420 --- diff --git a/dev/profile/server/invoicejournal.sqlite b/dev/profile/server/invoicejournal.sqlite index 77ee2f8..1e80208 100644 Binary files a/dev/profile/server/invoicejournal.sqlite and b/dev/profile/server/invoicejournal.sqlite differ diff --git a/main.js b/main.js index ccbb02e..ddf44a0 100644 --- a/main.js +++ b/main.js @@ -5,6 +5,8 @@ const os = require('os') const fs = require('fs') const {ipcMain} = require('electron') var child = require('child_process').execFile; +var { spawn } = require('child_process'); +//var { spawn } = require('child_process').execFile; // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. let mainWindow @@ -20,10 +22,10 @@ function createWindow () { console.log(os.platform()); if (os.platform() == "win32"){ executablePath = "C:\\Strawberry\\perl\\bin\\perl.exe"; - parameters = [app.getAppPath() + "\\server\\invoicejournal.pl"]; + parameters = [app.getAppPath() + "\\invoicejournal.pl"]; } else { //os.platform() == "darwin" executablePath = "/Users/kilian/perl5/perlbrew/perls/perl-5.28.1/bin/perl"; - parameters = [app.getAppPath() + "/server/invoicejournal.pl"]; + parameters = [app.getAppPath() + "/invoicejournal.pl"]; } console.log(parameters); mainWindow = new BrowserWindow({ @@ -45,15 +47,15 @@ function createWindow () { appcfg.type = "standalone"; } if (appcfg){ - if (!appcfg.host){ - appcfg.host ="localhost"; - } - if (!appcfg.host){ - appcfg.port ="6060"; - } - if (!appcfg.protocol){ - appcfg.protocol ="http"; - } + // if (!appcfg.host){ + // appcfg.host ="localhost"; + // } + // if (!appcfg.host){ + // appcfg.port ="6060"; + // } + // if (!appcfg.protocol){ + // appcfg.protocol ="http"; + // } console.log(appcfg); if (appcfg.type == "standalone"){ console.log("Start Child"); @@ -66,13 +68,18 @@ function createWindow () { // var test = app.getPath('USERPROFILE'); // console.log("Path:" + test); // console.log(data.toString()); - mainWindow.show() + } }); - } + } else if (appcfg.type == "server"){ + console.log("Start Spawned"); + const subprocess = spawn(executablePath,parameters,{ detached: true, stdio: 'ignore'}); + subprocess.unref(); + } } console.log(appcfg.protocol + '://'+appcfg.host+':'+ appcfg.port+'/index.html'); // and load the index.html of the app. + mainWindow.loadURL(appcfg.protocol + '://'+appcfg.host+':'+ appcfg.port+'/index.html') mainWindow.setMenu(null) mainWindow.maximize() @@ -87,9 +94,6 @@ function createWindow () { }); } item.setSavePath(savepath); - - - item.on('updated', (event, state) => { if (state === 'interrupted') { console.log('Download is interrupted but can be resumed') @@ -111,7 +115,7 @@ function createWindow () { } }) }) - + mainWindow.show() //mainWindow.show() // Open the DevTools. mainWindow.webContents.openDevTools() diff --git a/server/api/lib/pdfreport.pm b/server/api/lib/pdfreport.pm index a49197f..f8063b0 100644 --- a/server/api/lib/pdfreport.pm +++ b/server/api/lib/pdfreport.pm @@ -12,7 +12,7 @@ sub new { my $self = bless {}, $class; $self->{tmplpath} =$p->{tmplpath}; $self->{tmp} =$p->{tmp}; - $self->{wkhtmltopdf} = $RealBin.'/tools/wkhtmltopdf'.(($^O eq "MSWin32")?'.exe':''); + $self->{wkhtmltopdf} = $RealBin.'/server/tools/wkhtmltopdf'.(($^O eq "MSWin32")?'.exe':''); return $self; } diff --git a/server/htdocs/css/dkstheme.css b/server/htdocs/css/dkstheme.css index 10bb72b..842bde5 100644 --- a/server/htdocs/css/dkstheme.css +++ b/server/htdocs/css/dkstheme.css @@ -1826,6 +1826,10 @@ width: 100%; } +.portal tbody tr:nth-child(even) { + background-color: rgb(247, 247, 247); +} + .portal tbody tr:hover{ background-color: #959fb9; } @@ -1834,9 +1838,7 @@ width: 100%; background-color: #acacac!important; } -.portal tbody tr:nth-child(even) { -background-color: rgb(247, 247, 247); -} + ::-webkit-scrollbar { diff --git a/server/tmpl/lists/invoicedefaults.tt b/server/tmpl/lists/invoicedefaults.tt new file mode 100644 index 0000000..f5a4789 --- /dev/null +++ b/server/tmpl/lists/invoicedefaults.tt @@ -0,0 +1,3 @@ +[% FOREACH idef= dksdb.query("select id,defvalue from invoicejournal where id in ('vat','id_invoicetemplate','invoicedeadlinedays','id_address','sql_autoinvoicereference');") %] +[% invdefaults.${idef.item('id')} = idef %] +[% END %] \ No newline at end of file diff --git a/server/tmpl/module/invoices/invoice.js b/server/tmpl/module/invoices/invoice.js index 4df109a..e6f348e 100644 --- a/server/tmpl/module/invoices/invoice.js +++ b/server/tmpl/module/invoices/invoice.js @@ -1,7 +1,12 @@ +[% USE dksdb = DBI(dsn,dbuser,dbpassword) %] +[% PROCESS lists/invoicedefaults.tt %] -// function initmodule(){ var invoice = { - + defaultdata: { + [% FOREACH key IN invdefaults.keys %] + "[% invdefaults.item(key).item('id') %]":"[% invdefaults.item(key).item('defvalue') %]", + [% END %] + }, init: function(){ invoice.hasPDF(); invoice.changedDirection(true); @@ -37,7 +42,44 @@ } } }, - + setInvoiceDates(){ + invoice.setDeadlineDate(); + invoice.setReference(); + }, + setDeadlineDate: function(){ + var invid = document.getElementById("invoices_id").value; + var invdate = document.getElementById("invoices_invoicedate-" + invid).value; + var dldays = parseInt(document.getElementById("invoices_deadlinedays-" + invid).value); + var dldate = new Date(invdate); + dldate.setDate(dldate.getDate() + dldays); + record.setValue(document.getElementById("invoices_deadlinedate-" + invid),dldate.toISOString().substring(0,10)); + }, + setDeadlineDays: function(){ + var invid = document.getElementById("invoices_id").value; + var invdate = new Date(document.getElementById("invoices_invoicedate-" + invid).value); + var dldate = new Date(document.getElementById("invoices_deadlinedate-" + invid).value); + var days = dldate-invdate; + record.setValue(document.getElementById("invoices_deadlinedays-" + invid),days); + }, + setReference(){ + var invid = document.getElementById("invoices_id").value; + var direction = document.getElementById("invoices_direction-" + invid).value; + var strinvdate = document.getElementById("invoices_invoicedate-" + invid).value; + if (direction == "out"){ + invdate = new Date(strinvdate); + var nsql = invoice.defaultdata.sql_autoinvoicereference; + nsql = nsql.replace(/date\('now','localtime'\)/g,"date('"+ invdate.toISOString().substring(0,10) +"')"); + console.log("SQL:" + nsql) + req.reqdata("POST","db.cgi",{"sql":nsql},invoice.fillReference); + } + }, + fillReference: function(data){ + console.log(data); + if (data){ + var invid = document.getElementById("invoices_id").value; + record.setValue(document.getElementById("invoices_reference-" + invid),data["0"].reference); + } + }, addProduct: function(){ req.reqdata("POST","db.cgi",{"get":"products","id":table.selection},invoice.setProduct); diff --git a/server/tmpl/module/invoices/invoice.tt b/server/tmpl/module/invoices/invoice.tt index 12d21b6..58347e5 100644 --- a/server/tmpl/module/invoices/invoice.tt +++ b/server/tmpl/module/invoices/invoice.tt @@ -9,9 +9,9 @@ [% PROCESS lists/reportlist.tt %] [% USE Dumper %] [% qinv =dksdb.query("select inv.* -,printf('%.2f',sum(netamount)) as netamount -,printf('%.2f',sum(taxamount)) as vatamount -,printf('%.2f',sum(netamount + taxamount)) as grossamount +,printf('%.2f',sum(bk.netamount)) as netamount +,printf('%.2f',sum(bk.taxamount)) as vatamount +,printf('%.2f',sum(bk.netamount + bk.taxamount)) as grossamount from invoices inv join bookings bk on (inv.id=bk.id_invoices) where inv.id='${params.id}';") %] [% qbook =dksdb.prepare("SELECT id, id_invoices, id_products, producttype, sku, replace(quantity,'.',',') as quantity, replace(printf('%.2f',coalesce(unitamount,0.0)),'.',',') as unitamount, unit,name, description, taxpercent @@ -54,13 +54,13 @@ from bookings where id_invoices='${params.id}';") %]
- [% inputbox('invoicedate','invoices',inv.0.id,'Datum','date','','','',inv.0.invoicedate,'') %] + [% inputbox('invoicedate','invoices',inv.0.id,'Datum','date','','','',inv.0.invoicedate,'','invoice.setInvoiceDates();') %]
- [% inputbox('deadlinedays','invoices',inv.0.id,'Tage','number','','','',inv.0.deadlinedays,'') %] + [% inputbox('deadlinedays','invoices',inv.0.id,'Tage','number','','','',inv.0.deadlinedays,'','invoice.setDeadlineDate();') %]
- [% inputbox('deadlinedate','invoices',inv.0.id,'Fälligkeit','date','','','',inv.0.deadlinedate,'') %] + [% inputbox('deadlinedate','invoices',inv.0.id,'Fälligkeit','date','','','',inv.0.deadlinedate,'','invoice.setDeadlineDays();') %]
@@ -193,7 +193,7 @@ from bookings where id_invoices='${params.id}';") %] [% bk.unit %] [% bk.unitamount %]€ [% bk.vatpercent %]% - [% bk.vatamount %]€ + [% bk.taxamount %]€ [% bk.netamount %]€ [% bk.grossamount %]€