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
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({
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");
// 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()
});
}
item.setSavePath(savepath);
-
-
-
item.on('updated', (event, state) => {
if (state === 'interrupted') {
console.log('Download is interrupted but can be resumed')
}
})
})
-
+ mainWindow.show()
//mainWindow.show()
// Open the DevTools.
mainWindow.webContents.openDevTools()
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;
}
}
+.portal tbody tr:nth-child(even) {
+ background-color: rgb(247, 247, 247);
+}
+
.portal tbody tr:hover{
background-color: #959fb9;
}
background-color: #acacac!important;
}
-.portal tbody tr:nth-child(even) {
-background-color: rgb(247, 247, 247);
-}
+
::-webkit-scrollbar {
--- /dev/null
+[% 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
+[% 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);
}
}
},
-
+ 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);
[% 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
</div>
<div class="w3-row">
<div class="w3-cell" style="max-width: 130px;">
- [% inputbox('invoicedate','invoices',inv.0.id,'Datum','date','','','',inv.0.invoicedate,'') %]
+ [% inputbox('invoicedate','invoices',inv.0.id,'Datum','date','','','',inv.0.invoicedate,'','invoice.setInvoiceDates();') %]
</div>
<div class="w3-cell" style="width: 40px;">
- [% inputbox('deadlinedays','invoices',inv.0.id,'Tage','number','','','',inv.0.deadlinedays,'') %]
+ [% inputbox('deadlinedays','invoices',inv.0.id,'Tage','number','','','',inv.0.deadlinedays,'','invoice.setDeadlineDate();') %]
</div>
<div class="w3-cell" style="max-width: 130px;">
- [% 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();') %]
</div>
</div>
<td style="min-width: [% cols.unit %]px;width: [% cols.unit %]px;max-width: [% cols.unit %]px;">[% bk.unit %]</td>
<td class="w3-right-align" style="min-width: [% cols.unit %]px;width: [% cols.unit %]px;max-width: [% cols.unit %]px;">[% bk.unitamount %]€</td>
<td class="w3-right-align" style="min-width: [% cols.vatpercent %]px;width: [% cols.vatpercent %]px;max-width: [% cols.vatpercent %]px;">[% bk.vatpercent %]%</td>
- <td class="w3-right-align" style="min-width: [% cols.vat %]px;width: [% cols.vat %]px;max-width: [% cols.vat %]px;">[% bk.vatamount %]€</td>
+ <td class="w3-right-align" style="min-width: [% cols.vat %]px;width: [% cols.vat %]px;max-width: [% cols.vat %]px;">[% bk.taxamount %]€</td>
<td class="w3-right-align" style="min-width: [% cols.netamount %]px;width: [% cols.netamount %]px;max-width: [% cols.netamount %]px;">[% bk.netamount %]€</td>
<td class="w3-right-align" style="min-width: [% cols.grossamount %]px;width: [% cols.grossamount %]px;max-width: [% cols.grossamount %]px;">[% bk.grossamount %]€</td>
<td></td>