From: Kilian Saffran Date: Mon, 28 Dec 2020 08:01:53 +0000 (+0100) Subject: v20201227 X-Git-Url: http://cloud.dks.lu/git/?a=commitdiff_plain;h=31deefcae86e55e5d374961d2bc6c9ef77170ba0;p=invoicejournal.git v20201227 --- diff --git a/desktopapp/index.html b/desktopapp/index.html index 7ad8ffb..67046ec 100644 --- a/desktopapp/index.html +++ b/desktopapp/index.html @@ -7,6 +7,7 @@ + Invoice Journal @@ -32,7 +33,7 @@
@@ -52,6 +53,11 @@ + diff --git a/desktopapp/js/dataform.js b/desktopapp/js/dataform.js index 4def5c5..861eb4f 100644 --- a/desktopapp/js/dataform.js +++ b/desktopapp/js/dataform.js @@ -194,12 +194,12 @@ let dataform = { } if (frm[f].tagName == "TEXTAREA"){ //console.log("Set TextArea: " + frm[f].id + " => "+ data[tblid]); - if (frm[f].classList.contains("richeditarea")){ + // if (frm[f].classList.contains("richeditarea")){ - tinymce.get(frm[f].id).setContent(data[tblid]); - } else { + // tinymce.get(frm[f].id).setContent(data[tblid]); + // } else { frm[f].value = data[tblid]; - } + // } } } } diff --git a/desktopapp/js/email.js b/desktopapp/js/email.js index 30df56f..7767ecc 100644 --- a/desktopapp/js/email.js +++ b/desktopapp/js/email.js @@ -13,51 +13,51 @@ let email = { const mailappout = spawn(preferences.global.mailapp, args); mailappout.stdout.on('data', (data) => { - console.log(`mailappout stdout: ${data}`); + // console.log(`mailappout stdout: ${data}`); }); mailappout.stderr.on('data', (data) => { - console.error(`mailappout stderr: ${data}`); + // console.error(`mailappout stderr: ${data}`); }); mailappout.on('close', (code) => { - console.log(`mailappout: child process exited with code ${code}`); + // console.log(`mailappout: child process exited with code ${code}`); }); }, openOutlook: function(){ //outlook.exe /c ipm.note /m "someone@microsoft.com&subject=test%20subject&body=test%20body" /a test.txt }, - sendWithSMTP: function(maildata){ - const transporter = nodemailer.createTransport({ - host: preferences.global.mailserver, - port: preferences.global.mailport, - auth: { - user: preferences.global.mailuser, - pass: preferences.global.mailpassword - } - }); - let afiles = []; - for (var a=0;a 0){ - await transporter.sendMail({ - from: maildata.from, - to: maildata.to, - subject: maildata.subject, - html: maildata.body, - attachments: afiles - }); - } else { - await transporter.sendMail({ - from: maildata.from, - to: maildata.to, - subject: maildata.subject, - html: maildata.body - }); - } - // send email + // sendWithSMTP: function(maildata){ + // const transporter = nodemailer.createTransport({ + // host: preferences.global.mailserver, + // port: preferences.global.mailport, + // auth: { + // user: preferences.global.mailuser, + // pass: preferences.global.mailpassword + // } + // }); + // let afiles = []; + // for (var a=0;a 0){ + // await transporter.sendMail({ + // from: maildata.from, + // to: maildata.to, + // subject: maildata.subject, + // html: maildata.body, + // attachments: afiles + // }); + // } else { + // await transporter.sendMail({ + // from: maildata.from, + // to: maildata.to, + // subject: maildata.subject, + // html: maildata.body + // }); + // } + // // send email - //console.log("Message sent: %s", info.messageId); - } + // //console.log("Message sent: %s", info.messageId); + // } } \ No newline at end of file diff --git a/desktopapp/js/myapp.js b/desktopapp/js/myapp.js index cfe4fad..9b782c1 100644 --- a/desktopapp/js/myapp.js +++ b/desktopapp/js/myapp.js @@ -17,6 +17,7 @@ let myapp = { function(resolve, reject){ if (document.getElementById("mod_" + idmodule).innerHTML == ''){ var pnldoc = usersystem.readAppFile('modules/'+ module + '/' + idmodule + '.html'); + if (pnldoc == ""){ reject('modules/'+ module + '/' + idmodule + '.html' + " data is empty"); }else { @@ -50,7 +51,7 @@ let myapp = { }, viewtab: function(idtab){ var mytabs = document.getElementsByClassName("tab"); - console.log(idtab,mytabs); + //console.log(idtab,mytabs); for (let i=0;i { - console.log(data); - report.id_report = id_report; + report.id_report = id_report; report.tmpoutput = report.tmpfolder + fname + ".pdf"; - report.output = preferences.global.currentdataset.datapath + '/' + data.reporttype + '/' + fname + ".pdf"; + report.output = preferences.global.currentdataset.datapath + '/' + 'invoice' + '/' + fname + ".pdf"; report.reportfile = fname+ ".pdf"; - report.pdfoptions = JSON.parse(data.pdfoptions); + //report.pdfoptions = JSON.parse(data.pdfoptions); report.callback = callback; - if (!fs.existsSync(report.tmpfolder)){ - fs.mkdirSync(usersystem.profilepath() + 'tmp/'); - } - if (!fs.existsSync(path.dirname(report.tmpoutput))){ - fs.mkdirSync(path.dirname(report.tmpoutput)); - } - if (fs.existsSync(report.tmpfolder + fname + ".pdf")){ - fs.unlinkSync(report.tmpfolder + fname + ".pdf"); - } - if (fs.existsSync(report.tmpfolder + id_report + ".content.html")){ - fs.unlinkSync(report.tmpfolder + id_report + ".content.html"); - } - if (fs.existsSync(report.tmpfolder + id_report + ".header.html")){ - fs.unlinkSync(report.tmpfolder + id_report + ".header.html"); - } - if (fs.existsSync(report.tmpfolder + id_report + ".footer.html")){ - fs.unlinkSync(report.tmpfolder + id_report + ".footer.html"); - } - - let doQueries = async() => { - let queryres = {}; - console.log("data.reportsql",data.reportsql); - let qq = JSON.parse(data.reportsql); - for (var i in qq){ - console.log(i); - let qsql = qq[i].sql; - console.log(qsql); - for (var dd in reportdata){ - qsql = qsql.replace('%%' + dd + '%%',reportdata[dd]); - } - console.log(qsql); - if (qq[i].type == 'query'){ - queryres[i] = await db.query(qsql).catch(e => { console.log(e);});; - } else if (qq[i].type == 'queryarray'){ - queryres[i] = await db.queryarray(qsql).catch(e => { console.log(e);});; - } - - } - return queryres; - } - doQueries().then(result => { - console.log(result); - let content = Mustache.render(data.contenthtml,result); - let header = Mustache.render(data.headerhtml,result); - let footer = Mustache.render(data.footerhtml,result); - console.log(report.tmpfolder + id_report + ".content.html"); - var result = fs.writeFileSync(report.tmpfolder + id_report + ".content.html",content); - result = fs.writeFileSync(report.tmpfolder + id_report + ".header.html", header); - result = fs.writeFileSync(report.tmpfolder + id_report + ".footer.html",footer); - //result = fs.writeFileSync(report.tmpfolder + id_report + ".data.js",JSON.stringify(result)); - report.compile(); - }); - }).catch(e => { console.log(e);});; - - }, - compile: function(){ - let args = []; - console.log("id_report",report.id_report) - console.log("pdfoptions",report.pdfoptions); - if (report.pdfoptions.bottom){ args.push("-B",report.pdfoptions.bottom + report.pdfoptions.unit); } - if (report.pdfoptions.left){ args.push("-L",report.pdfoptions.left+report.pdfoptions.unit); } - if (report.pdfoptions.right){ args.push("-R",report.pdfoptions.right+report.pdfoptions.unit); } - if (report.pdfoptions.top){ args.push("-T",report.pdfoptions.top+report.pdfoptions.unit); } - if (report.pdfoptions.orientation){ args.push("-O",report.pdfoptions.orientation); } - if (report.pdfoptions.size){ args.push("-s",report.pdfoptions.size); } - if (report.pdfoptions.encoding){ args.push("--encoding",report.pdfoptions.encoding); } - if (fs.existsSync(report.tmpfolder+ report.id_report + ".header.html")){ - args.push("--header-html",report.tmpfolder+ report.id_report + ".header.html"); - } - if (fs.existsSync(report.tmpfolder+ report.id_report + ".footer.html")){ - args.push("--footer-html",report.tmpfolder+ report.id_report + ".footer.html" ); - } - args.push(report.tmpfolder+ report.id_report + ".content.html" ); - report.tmpoutput = report.tmpoutput.replace(/\\/g,"/"); - args.push(report.tmpoutput); - console.log("Output to",report.tmpoutput); - console.log("AppPath",usersystem.getApplicationPath()); - console.log(args); - const pdfout = spawn(usersystem.getApplicationPath()+ '/tools/wkhtmltopdf.exe', args); - pdfout.stdout.on('data', (data) => { - - console.log(`pdfout stdout: ${data}`); - }); - - pdfout.stderr.on('data', (data) => { - console.error(`pdfout stderr: ${data}`); - }); - - pdfout.on('close', (code) => { - console.log(`pdfout: child process exited with code ${code}`); - if (code == 0){ - console.log("Copy",report.tmpoutput,"to",report.output); + let data = reportdata; + + var options = { + convertTo : 'pdf' //can be docx, txt, ... + }; + console.log("Render",preferences.global.currentdataset.datapath + '/templates/' + id_report); + console.log("to",report.tmpoutput); + carbone.render(preferences.global.currentdataset.datapath + '/templates/' + id_report, data, options, function(err, result){ + if (err) return console.log("XX ERR",err); + console.log("docresult",result); + fs.writeFileSync(report.tmpoutput, result); + // to kill automatically LibreOffice workers + console.log("Copy",report.tmpoutput,"to",report.output); if (fs.existsSync(report.output)){ - fs.unlinkSync(report.output); + fs.unlinkSync(report.output); } fs.copyFileSync(report.tmpoutput,report.output); + console.log("test callback",{"file":report.reportfile}); + if (report.callback){ report.callback({"file":report.reportfile}); } - + process.exit(); }); } -} - +} \ No newline at end of file diff --git a/desktopapp/modules/bookings/booking.js b/desktopapp/modules/bookings/booking.js index 21c1340..43f5ae5 100644 --- a/desktopapp/modules/bookings/booking.js +++ b/desktopapp/modules/bookings/booking.js @@ -4,31 +4,17 @@ let booking = { tinymce.init({ selector: '#invoicebooking_description', - plugins: 'paste importcss searchreplace autolink directionality visualblocks visualchars template charmap nonbreaking advlist lists textpattern noneditable charmap autoresize ', + plugins: 'paste searchreplace autolink directionality visualblocks visualchars template charmap nonbreaking textpattern noneditable charmap autoresize ', menubar: false, entity_encoding : 'raw', - toolbar: 'undo redo | bold italic underline strikethrough | fontsizeselect | outdent indent | forecolor removeformat | charmap', + toolbar: 'undo redo | bold italic underline strikethrough | fontselect fontsizeselect | forecolor removeformat | charmap', toolbar_sticky: true, language: 'de', - content_css: [ - '../../css/theme.css' - ], statusbar: false, forced_root_block : '', min_height: 150, branding: false, - importcss_append: true, - noneditable_noneditable_class: "mceNonEditable", contextmenu: false, - setup: function(editor) { - editor.on('blur', function(e) { - console.log("tmce blur:",e.target.id); - - //dataform.savefield(document.getElementById(e.id)); - //e.id - //console.log('The Editor has initialized.'); - }); - } }); } // current_id: null, diff --git a/desktopapp/modules/invoices/invoice.js b/desktopapp/modules/invoices/invoice.js index 9efa690..576e9fd 100644 --- a/desktopapp/modules/invoices/invoice.js +++ b/desktopapp/modules/invoices/invoice.js @@ -118,10 +118,21 @@ let invoice = { }).catch(e => { console.log(e);});; }, getReportList: function(){ - db.queryarray("SELECT id as value,reportname as text FROM newreports where reporttype ='invoice' ORDER BY reportname;").then(data => { - //console.log("ReportList",data); - dataform.fillselectlist(invoice.selects["invoices_id_template"],data,'value','text'); - }).catch(e => { console.log(e);});; + console.log("read template path",preferences.global.currentdataset.datapath + '/templates/invoice'); + fs.readdir(preferences.global.currentdataset.datapath + '/templates/invoice', (err, files) => { + if (err) console.log(err); + else { + let replist = []; + console.log(files); + let fileext = /\.(docx$|odt$)+/i; + files.forEach(file => { + if (fileext.match(file)) { + replist.push({"value":file,"text":file}); + } + }); + dataform.fillselectlist(invoice.selects["invoices_id_template"],replist,'value','text'); + } + }); return false; }, getStatusList: function(){ @@ -335,19 +346,40 @@ let invoice = { console.log("Init or not" + isinit); }, createPDF: function(){ - let idreport = invoice.selects["invoices_id_template"].selected(); + //let idreport = invoice.selects["invoices_id_template"].selected(); + let idreport= 'invoice/' + 'simple.odt'; let fname = document.getElementById("invoices_businessyear").value +"/" + preferences.defaultdata.fileprefix +document.getElementById("invoices_reference").value; - report.generate(idreport,{"id": invoice.current_id}, fname,invoice.afterPDFCreation); + //"book":{"type":"queryarray","sql":"SELECT sku, replace(quantity,'.',',') as quantity, replace(printf('%.2f',unitamount),'.',',') as unitamount, unit, name, description, replace(printf('%.2f',taxamount),'.',',') as taxamount, replace(printf('%.2f',taxpercent),'.',',') as taxpercent, replace(printf('%.2f',netamount),'.',',') as netamount FROM bookings where id_invoices= '%%id%%';"}, +//"vat":{"type":"query","sql":"select case when count(taxpercent)=1 then taxpercent else null end as taxpercent from (select replace(taxpercent,'.',',') as taxpercent from bookings where id_invoices= '%%id%%' group by taxpercent) xx;"} +//} + db.query("select inv.accountvatid, inv.clientnumber, inv.payedamount, strftime('%d.%m.%Y',inv.invoicedate) as invoicedate, strftime('%d.%m.%Y',inv.deadlinedate) as deadlinedate, inv.footertext, inv.reference, inv.headertext, inv.pdffile, inv.offerreference, inv.referencenumber, inv.accountname, inv.accountaddress, inv.accountzip, inv.accountcity, inv.accountcountry, replace(printf('%.2f',sum(bk.netamount)),'.',',') as netamount,inv.footertext,inv.headertext,replace(printf('%.2f',sum(bk.taxamount)),'.',',') as vatamount, replace(printf('%.2f',sum(bk.netamount + bk.taxamount)),'.',',') as grossamount from invoices inv join bookings bk on (inv.id=bk.id_invoices) where inv.id = '"+ invoice.current_id +"';").then(repdata => { + db.queryarray("SELECT sku, replace(quantity,'.',',') as quantity, replace(printf('%.2f',unitamount),'.',',') as unitamount, unit, name, description, replace(printf('%.2f',taxamount),'.',',') as taxamount, replace(printf('%.2f',taxpercent),'.',',') as taxpercent, replace(printf('%.2f',netamount),'.',',') as netamount FROM bookings where id_invoices= '"+ invoice.current_id +"';").then(book => { + repdata["book"] = book; + let gtaxpercent = book[0].taxpercent; + for (var b in book){ + if (book[b].taxpercent != gtaxpercent){ + gtaxpercent = ""; + } + } + if (gtaxpercent != ""){ + gtaxpercent = gtaxpercent + "%"; + } + repdata["vatpercent"] = gtaxtpercent; + reportnew.generate(idreport,repdata, fname,invoice.afterPDFCreation); + }); + }); + //req.reqreport({"generate":idreport,data:{"id":invoice.current_id}},invoice.afterPDFCreation) }, afterPDFCreation: function(data){ - if (data && data.file){ - document.getElementById("invoices_pdffile").value=data.file; - invoice.openPDF(); - dataform.savefield(document.getElementById("invoices_pdffile")); - } - invoice.hasPDF(); + console.log(data); + // if (data && data.file){ + // document.getElementById("invoices_pdffile").value=data.file; + // invoice.openPDF(); + // dataform.savefield(document.getElementById("invoices_pdffile")); + // } + // invoice.hasPDF(); }, openPDF: function(){ if (document.getElementById("invoices_pdffile").value != ''){ diff --git a/desktopapp/modules/modules.json b/desktopapp/modules/modules.json index 92c9ca5..ef57e0a 100644 --- a/desktopapp/modules/modules.json +++ b/desktopapp/modules/modules.json @@ -7,7 +7,6 @@ ], "config":[ {"module":"settings","icon":"icon-settings","name":"Einstellungen"}, - {"module":"templates","icon":"icon-template","name":"Vorlagen"}, {"module":"datasets","icon":"icon-datasets","name":"Datensätze"}, {"module":"backup","icon":"icon-backup","name":"Backup"} ], diff --git a/desktopapp/modules/offers/offer.js b/desktopapp/modules/offers/offer.js index 4b073b2..c010490 100644 --- a/desktopapp/modules/offers/offer.js +++ b/desktopapp/modules/offers/offer.js @@ -66,33 +66,33 @@ let offer = { {title: "Brutto", field: "grossamount",headerSort: false, formatter:"money",hozAlign:"right", formatterParams:{ decimal:",", thousand:".", symbol:"€", symbolAfter:"p", precision:2}}, ] }); - tinymce.init({ - selector: '#offers_headertext,#offers_footertext', - plugins: 'paste importcss searchreplace autolink directionality visualblocks visualchars template charmap nonbreaking advlist lists textpattern noneditable charmap autoresize ', - menubar: false, - toolbar: 'undo redo | bold italic underline strikethrough | fontsizeselect | outdent indent | forecolor removeformat | charmap', - toolbar_sticky: true, - language: 'de', - content_css: [ - '../../css/theme.css' - ], - statusbar: false, - forced_root_block : '', - min_height: 150, - branding: false, - importcss_append: true, - noneditable_noneditable_class: "mceNonEditable", - contextmenu: false, - setup: function(editor) { - editor.on('blur', function(e) { - console.log("tmce blur:",e.target.id); + // tinymce.init({ + // selector: '#offers_headertext,#offers_footertext', + // plugins: 'paste importcss searchreplace autolink directionality visualblocks visualchars template charmap nonbreaking advlist lists textpattern noneditable charmap autoresize ', + // menubar: false, + // toolbar: 'undo redo | bold italic underline strikethrough | fontsizeselect | outdent indent | forecolor removeformat | charmap', + // toolbar_sticky: true, + // language: 'de', + // content_css: [ + // '../../css/theme.css' + // ], + // statusbar: false, + // forced_root_block : '', + // min_height: 150, + // branding: false, + // importcss_append: true, + // noneditable_noneditable_class: "mceNonEditable", + // contextmenu: false, + // setup: function(editor) { + // editor.on('blur', function(e) { + // console.log("tmce blur:",e.target.id); - //dataform.savefield(document.getElementById(e.id)); - //e.id - //console.log('The Editor has initialized.'); - }); - } - }); + // //dataform.savefield(document.getElementById(e.id)); + // //e.id + // //console.log('The Editor has initialized.'); + // }); + // } + // }); //offer.hasPDF(); //offer.changedDirection(true); diff --git a/desktopapp/modules/products/product.js b/desktopapp/modules/products/product.js index d4f79ca..46936a4 100644 --- a/desktopapp/modules/products/product.js +++ b/desktopapp/modules/products/product.js @@ -32,34 +32,34 @@ let product = { {title: "Anzahl", field: "quantity",width: 80}, ] }); - tinymce.init({ - selector: '#products_description,#products_note', - plugins: 'paste importcss searchreplace autolink directionality visualblocks visualchars template charmap nonbreaking advlist lists textpattern noneditable charmap', - menubar: false, - toolbar: 'bold italic underline strikethrough fontsizeselect forecolor removeformat charmap', - toolbar_sticky: true, - language: 'de', - content_css: [ - 'css/theme.css' - ], - statusbar: false, - min_height: 200, - max_height: 200, - forced_root_block : '', - branding: false, - importcss_append: true, - noneditable_noneditable_class: "mceNonEditable", - contextmenu: false, - setup: function(editor) { - editor.on('blur', function(e) { - console.log("tmce blur:",e.target.id); + // tinymce.init({ + // selector: '#products_description,#products_note', + // plugins: 'paste importcss searchreplace autolink directionality visualblocks visualchars template charmap nonbreaking advlist lists textpattern noneditable charmap', + // menubar: false, + // toolbar: 'bold italic underline strikethrough fontsizeselect forecolor removeformat charmap', + // toolbar_sticky: true, + // language: 'de', + // content_css: [ + // 'css/theme.css' + // ], + // statusbar: false, + // min_height: 200, + // max_height: 200, + // forced_root_block : '', + // branding: false, + // importcss_append: true, + // noneditable_noneditable_class: "mceNonEditable", + // contextmenu: false, + // setup: function(editor) { + // editor.on('blur', function(e) { + // console.log("tmce blur:",e.target.id); - //dataform.savefield(document.getElementById(e.id)); - //e.id - //console.log('The Editor has initialized.'); - }); - } - }); + // //dataform.savefield(document.getElementById(e.id)); + // //e.id + // //console.log('The Editor has initialized.'); + // }); + // } + // }); }, viewmodule: function(id){ // myapp.loadmodule('product').then(result => { diff --git a/desktopapp/modules/settings/settings.html b/desktopapp/modules/settings/settings.html index 0e57aab..e4ad244 100644 --- a/desktopapp/modules/settings/settings.html +++ b/desktopapp/modules/settings/settings.html @@ -92,32 +92,7 @@
- -
-
- -
-
- - -
-
-
-
- - -
-
-
-
- -
-
- +
diff --git a/desktopapp/modules/templates/templates.html b/desktopapp/modules/templates/templates.html deleted file mode 100644 index 6713411..0000000 --- a/desktopapp/modules/templates/templates.html +++ /dev/null @@ -1,89 +0,0 @@ -
- -
- Vorlagen -
- - -
- -
-
-
-
-
-
- - - -
-
-
- diff --git a/desktopapp/modules/templates/templates.js b/desktopapp/modules/templates/templates.js deleted file mode 100644 index c9bf371..0000000 --- a/desktopapp/modules/templates/templates.js +++ /dev/null @@ -1,137 +0,0 @@ -let templates = { - tbl:null, - editors: {"templates_headerhtml": null,"templates_contenthtml":null,"templates_footerhtml":null}, - current_id: null, - viewmodule: function(){ - myapp.loadmodule('templates','templates').then(result => { - myapp.viewmodule('templates'); - }); - }, - - init: function(){ - // tinymce.init({ - // selector: '#templates_headerhtml, #templates_contenthtml, #templates_footerhtml', - // //all plugins: paste importcss searchreplace autolink directionality code visualblocks visualchars image template codesample table charmap hr pagebreak nonbreaking advlist lists imagetools textpattern noneditable charmap quickbars emoticons - // plugins: 'paste importcss searchreplace autolink directionality visualblocks visualchars template charmap nonbreaking advlist lists textpattern noneditable charmap autoresize table code fullpage visualblocks image imagetools', - // menubar: false, - // entity_encoding : 'raw', - // font_formats: 'Arial=arial,sans-sherif,sans', - // //tabledelete | tableprops tablerowprops tablecellprops | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol - // toolbar: 'undo redo | bold italic underline strikethrough | fontselect fontsizeselect | outdent indent | forecolor removeformat | charmap | table image imagetools | code fullpage', - // toolbar_sticky: true, - // extended_valid_elements: 'script,style', - // fullpage_hide_in_source_view: false, - // content_css: "", - // element_format : 'html', - // statusbar: false, - // forced_root_block : '', - // min_height: 150, - // branding: false, - // importcss_append: true, - // noneditable_noneditable_class: "mceNonEditable", - // contextmenu: "link image imagetools table", - // setup: function(editor) { - // editor.on('blur', function(e) { - // console.log("tmce blur:",e.target.id); - // }); - // }, - // visualblocks_default_state: true, - // end_container_on_empty_block: true, - // image_advtab: true, - // image_title: true, - // automatic_uploads: true, - // file_picker_types: 'image', - // file_picker_callback: function (cb, value, meta) { - // var input = document.createElement('input'); - // input.setAttribute('type', 'file'); - // input.setAttribute('accept', 'image/*'); - // input.onchange = function () { - // var file = this.files[0]; - - // var reader = new FileReader(); - // reader.onload = function () { - // var id = 'blobid' + (new Date()).getTime(); - // var blobCache = tinymce.activeEditor.editorUpload.blobCache; - // var base64 = reader.result.split(',')[1]; - // var blobInfo = blobCache.create(id, file, base64); - // blobCache.add(blobInfo); - // cb(blobInfo.blobUri(), { title: file.name }); - // }; - // reader.readAsDataURL(file); - // }; - - // input.click(); - - // }, - // image_caption: true - // }); - templates.tbl = new Tabulator("#tbl_templates",{ - headerFilterPlaceholder: "filter...", - height: "calc(100vh - 60px)", - layout: "fitDataStretch", - selectable: 1, - rowClick:function(e, row){ - //console.log("Filter selected"); - - // console.log(fsel); - // templates.current_id = fsel[0].id; - templates.edit(); - //invoices.getsums(fsel); - }, - rowContext:function(e, row){ e.preventDefault(); }, - columns: [ - {title: "Name", field: "reportname"}, - {title: "Typ", field: "reporttype"}, - ] - }); - templates.gettbldata(); - }, - gettbldata: function(){ - if (templates.tbl){ - db.queryarray("select * from newreports order by reportname,reporttype;").then(data => { - console.log(data); - templates.tbl.setData(data); - }); - } - }, - edit: function(){ - let fsel = templates.tbl.getSelectedData(); - if (fsel[0] ){ - if (fsel[0].type == 'email'){ - myapp.viewmodule('templateemail') - db.query("select * from newreports where id='"+ id+"';").then(data => { - - }).catch(e => { console.log(e);}); - }else { - db.query("select * from newreports where id='"+ id+"';").then(data => { - - document.getElementById("templates_headerhtml").value= data.headerhtml; - document.getElementById("templates_contenthtml").value= data.contenthtml; - document.getElementById("templates_footerhtml").value= data.footerhtml; - document.getElementById("templates_styles").value= data.styles; - // let dataheader=data.headerhtml.replace(/\<\/head\>/,""); - // let datafooter=data.footerhtml.replace(/\<\/head\>/,""); - // templates.setEditorData("templates_headerhtml",data.headerhtml,data.styles); - // templates.setEditorData("templates_contenthtml",data.contenthtml,data.styles); - // templates.setEditorData("templates_footerhtml",data.footerhtml,data.styles); - - }).catch(e => { console.log(e);}); - } - } - }, - add: function(){ - - }, - confirmRemove: function(){ - - }, - remove: function(){ - - }, - duplicate: function(){ - - }, - preview: function(){ - - } -} \ No newline at end of file diff --git a/desktopapp/package-lock.json b/desktopapp/package-lock.json index a4c9f4e..e85e9d4 100644 --- a/desktopapp/package-lock.json +++ b/desktopapp/package-lock.json @@ -234,8 +234,7 @@ "buffer-crc32": { "version": "0.2.13", "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", - "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=", - "dev": true + "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=" }, "buffer-fill": { "version": "1.0.0", @@ -281,6 +280,29 @@ } } }, + "carbone": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/carbone/-/carbone-2.1.1.tgz", + "integrity": "sha512-LVFAKftoKu+K6/o2rzmthuRpq3YxxyqNlNqysmiPpSYWtUJhoclxfwcGLczAmrp+cPLFyAZgFYaXehEli5LxTw==", + "requires": { + "debug": "=4.1.1", + "moment": "=2.27.0", + "timsort": "=0.3.0", + "which": "=2.0.2", + "yauzl": "=2.10.0", + "yazl": "=2.5.1" + }, + "dependencies": { + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "requires": { + "isexe": "^2.0.0" + } + } + } + }, "caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", @@ -312,11 +334,6 @@ "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" }, - "codemirror": { - "version": "5.59.0", - "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.59.0.tgz", - "integrity": "sha512-UGzSkCacY9z0rSpQ3wnTWRN2nvRE6foDXnJltWW8pazInR/R+3gXHrao4IFQMv/bSBvFBxt8/HPpkpKAS54x5Q==" - }, "combined-stream": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", @@ -396,7 +413,6 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", - "dev": true, "requires": { "ms": "^2.1.1" } @@ -730,7 +746,6 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", "integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=", - "dev": true, "requires": { "pend": "~1.2.0" } @@ -1124,8 +1139,7 @@ "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "optional": true + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" }, "isstream": { "version": "0.1.2", @@ -1317,10 +1331,10 @@ "minimist": "^1.2.5" } }, - "monaco-editor": { - "version": "0.21.2", - "resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.21.2.tgz", - "integrity": "sha512-jS51RLuzMaoJpYbu7F6TPuWpnWTLD4kjRW0+AZzcryvbxrTwhNy1KC9yboyKpgMTahpUbDUsuQULoo0GV1EPqg==" + "moment": { + "version": "2.27.0", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.27.0.tgz", + "integrity": "sha512-al0MUK7cpIcglMv3YF13qSgdAIqxHTO7brRtaz3DlSULbqfazqkc5kEjNrLDOM7fsjshoFIihnU8snrP7zUvhQ==" }, "ms": { "version": "2.1.2", @@ -1642,8 +1656,7 @@ "pend": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", - "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=", - "dev": true + "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=" }, "performance-now": { "version": "2.1.0", @@ -2039,6 +2052,11 @@ "inherits": "2" } }, + "timsort": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/timsort/-/timsort-0.3.0.tgz", + "integrity": "sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=" + }, "to-readable-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/to-readable-stream/-/to-readable-stream-1.0.0.tgz", @@ -2227,11 +2245,18 @@ "version": "2.10.0", "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", "integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=", - "dev": true, "requires": { "buffer-crc32": "~0.2.3", "fd-slicer": "~1.1.0" } + }, + "yazl": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/yazl/-/yazl-2.5.1.tgz", + "integrity": "sha512-phENi2PLiHnHb6QBVot+dJnaAZ0xosj7p3fWl+znIjBDlnMI2PsZCJZ306BPTFOaHf5qdDEI8x5qFrSOBN5vrw==", + "requires": { + "buffer-crc32": "~0.2.3" + } } } } diff --git a/desktopapp/package.json b/desktopapp/package.json index 047a51f..9b3ac12 100644 --- a/desktopapp/package.json +++ b/desktopapp/package.json @@ -20,8 +20,7 @@ "electron-packager": "^15.1.0" }, "dependencies": { - "codemirror": "^5.59.0", - "monaco-editor": "^0.21.2", + "carbone": "^2.1.1", "sqlite3": "^5.0.0" } } diff --git a/desktopapp/test.html b/desktopapp/test.html index f0e441b..1ebff57 100644 --- a/desktopapp/test.html +++ b/desktopapp/test.html @@ -35,7 +35,7 @@ - + diff --git a/dev/test.bat b/dev/test.bat new file mode 100644 index 0000000..708ecd0 --- /dev/null +++ b/dev/test.bat @@ -0,0 +1,2 @@ +@echo off +"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" C:\Users\ksaff\test.eml \ No newline at end of file diff --git a/install/install_choco.ps1 b/install/install_choco.ps1 new file mode 100644 index 0000000..ac618d6 --- /dev/null +++ b/install/install_choco.ps1 @@ -0,0 +1,6 @@ +$InstallDir= 'C:\ProgramData\chocoportable' +$env:ChocolateyInstall="$InstallDir" +Set-ExecutionPolicy Bypass -Scope Process -Force; +iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) +choco install python -y +choco install libreoffice-still -y \ No newline at end of file diff --git a/install/windows/setup_64bit.iss b/install/windows/setup_64bit.iss index a01a473..ae6b273 100644 --- a/install/windows/setup_64bit.iss +++ b/install/windows/setup_64bit.iss @@ -1,16 +1,17 @@ ; Script generated by the Inno Setup Script Wizard. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! -; #define public MyAppVersion "" -; #define public MyOutputDir "" -; #define public MySourceDir "" -; #define public MySetupName "" +#define public MyAppVersion "1.0.1" +#define public MyOutputDir "D:\Workspace\invoicejournal\release" +#define public MySourceDir "D:\Workspace\invoicejournal" +#define public MySetupName "setup_invoicejournal.exe" #define MyAppName "Invoice Journal" -#define MyAppPublisher "DKS s.à r.l." +#define MyAppPublisher "DKS s.�r.l." #define MyAppURL "https://www.dks.lu/" #define MyAppExeName "invoicejournal.exe" + [Setup] ; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications. ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) @@ -23,13 +24,15 @@ AppPublisherURL={#MyAppURL} AppSupportURL={#MyAppURL} AppUpdatesURL={#MyAppURL} DefaultDirName={autopf}\InvoiceJournal +DisableWelcomePage=yes DisableProgramGroupPage=yes DisableDirPage=yes +UserInfoPage=yes CloseApplications=force CloseApplicationsFilter=invoicejournal.exe LicenseFile={#MySourceDir}\install\EULA_Default.rtf ; Uncomment the following line to run in non administrative install mode (install for current user only.) -PrivilegesRequired=lowest +;PrivilegesRequired=lowest ;PrivilegesRequiredOverridesAllowed=dialog OutputDir={#MyOutputDir} OutputBaseFilename={#MySetupName} @@ -50,11 +53,45 @@ Name: "french"; MessagesFile: "compiler:Languages\French.isl" [Files] Source: "{#MySourceDir}\release-builds\invoicejournal-win32-x64\invoicejournal.exe"; DestDir: "{app}"; Flags: overwritereadonly ignoreversion Source: "{#MySourceDir}\release-builds\invoicejournal-win32-x64\*"; DestDir: "{app}"; Flags: overwritereadonly ignoreversion recursesubdirs createallsubdirs +Source: "{#MySourceDir}\install\iinstall_choco.ps1"; DestDir: "{tmp}" [Icons] Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" [Run] +Filename: "powershell.exe";Parameters: "-ExecutionPolicy Bypass -File ""{tmp}\setup.ps1"""; WorkingDir: {tmp}; Flags: runhidden Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent +[Code] +function CheckSerial(Serial: String): Boolean; +begin + Result := (Serial <> ''); +end; + +function NextButtonClick(CurPageID: Integer): Boolean; +var + WinHttpReq: Variant; + WMIResult: Variant; + Url: string; +begin + Result := True; + if CurPageID = wpUserInfo then + begin + WMIResult := GetWMIInfo('') + WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1'); + Url := 'http://localhost/license/licensecheck.php?serial=' + + WizardForm.UserInfoSerialEdit.Text; + + WinHttpReq.Open('GET', Url, False); + WinHttpReq.Send(''); + { Depending on implementation of the server, use wither HTTP status code (.Status) or } + { contents of returned "page" (.ResponseText) } + { Here we use the HTTP status code: } + { 200 = serial is valid, anything else = serial is invalid, } + { and when invalid, we display .ResponseText } + Result := (WinHttpReq.Status = 200); + if not Result then + MsgBox(WinHttpReq.ResponseText, mbError, MB_OK); + end; +end; \ No newline at end of file diff --git a/server/licensecheck.php b/server/licensecheck.php new file mode 100644 index 0000000..9e277bc --- /dev/null +++ b/server/licensecheck.php @@ -0,0 +1,15 @@ + \ No newline at end of file diff --git a/server/serialdata.txt b/server/serialdata.txt new file mode 100644 index 0000000..2c7d0a4 --- /dev/null +++ b/server/serialdata.txt @@ -0,0 +1 @@ +{"serial":"20","useragent":"Mozilla\/4.0 (compatible; Win32; WinHttp.WinHttpRequest.5)"} \ No newline at end of file