v20201227
authorKilian Saffran <ksaffran@dks.lu>
Mon, 28 Dec 2020 08:01:53 +0000 (09:01 +0100)
committerKilian Saffran <ksaffran@dks.lu>
Mon, 28 Dec 2020 08:01:53 +0000 (09:01 +0100)
21 files changed:
desktopapp/index.html
desktopapp/js/dataform.js
desktopapp/js/email.js
desktopapp/js/myapp.js
desktopapp/js/report.js
desktopapp/modules/bookings/booking.js
desktopapp/modules/invoices/invoice.js
desktopapp/modules/modules.json
desktopapp/modules/offers/offer.js
desktopapp/modules/products/product.js
desktopapp/modules/settings/settings.html
desktopapp/modules/templates/templates.html [deleted file]
desktopapp/modules/templates/templates.js [deleted file]
desktopapp/package-lock.json
desktopapp/package.json
desktopapp/test.html
dev/test.bat [new file with mode: 0644]
install/install_choco.ps1 [new file with mode: 0644]
install/windows/setup_64bit.iss
server/licensecheck.php [new file with mode: 0644]
server/serialdata.txt [new file with mode: 0644]

index 7ad8ffb..67046ec 100644 (file)
@@ -7,6 +7,7 @@
     <link href="vendor/slimselect/slimselect.css?v=6" rel="stylesheet">
     <link href="vendor/flatpickr/flatpickr.min.css?v=6" rel="stylesheet">
     <link href="vendor/flatpickr/themes/airbnb.css?v=6" rel="stylesheet">
+    <link href="vendor/codemirror/lib/codemirror.css" rel="stylesheet">
     <link href="css/icons.css?v=6" rel="stylesheet">
     <link href="css/theme.css?v=6" rel="stylesheet">
     <title>Invoice Journal</title>
@@ -32,7 +33,7 @@
               </div>
               <div class="container third">
                 <div class="bar" id="idxbar_quicklinks">
-                  
+                  <button class="bar-item bodybtn border padding margin" onclick="reportnew.generate('invoice/simple.odt',{},'testsimple',null);"><span class="icon-pdf" style="font-size: 64px;"></span>Gen Report</button>
                 </div>
               </div>
             </div>
       <script src="vendor/flatpickr/l10n/de.js?v=6" type="text/javascript"></script> 
       <script src="vendor/mustache/mustache.min.js?v=6" type="text/javascript"></script>
       <script src="vendor/tinymce/js/tinymce/tinymce.min.js" type="text/javascript"></script>
+      <!-- <script src="vendor/codemirror/lib/codemirror.js" type="text/javascript"></script>
+      <script src="vendor/codemirror/addon/mode/overlay.js" type="text/javascript"></script>
+      <script src="vendor/codemirror/mode/xml/xml.js" type="text/javascript"></script>
+      <script src="vendor/codemirror/mode/css/css.js" type="text/javascript"></script>
+      <script src="vendor/codemirror/mode/javascript/javascript.js" type="text/javascript"></script> -->
       <script src="js/request.js?v=6" type="text/javascript"></script> 
       <script src="js/myapp.js?v=6" type="text/javascript"></script>
       <script src="js/dataform.js?v=6" type="text/javascript"></script> 
index 4def5c5..861eb4f 100644 (file)
@@ -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];
-            } 
+            // 
           }
         } 
       }
index 30df56f..7767ecc 100644 (file)
@@ -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<maildata.attachments.length;a++){
-      afiles.push({"filename":path.basename(maildata.attachments[a]),"path":maildata.attachments[a]});
-    }
-    if (afiles.length >  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<maildata.attachments.length;a++){
+  //     afiles.push({"filename":path.basename(maildata.attachments[a]),"path":maildata.attachments[a]});
+  //   }
+  //   if (afiles.length >  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
index cfe4fad..9b782c1 100644 (file)
@@ -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<mytabs.length;i++){
         mytabs[i].style.display = 'none';
       }
@@ -59,11 +60,11 @@ let myapp = {
     },
     viewpanel: function(idpanel){
       var mypanels = document.getElementsByClassName("panel");
-      console.log("Panel",idpanel,mypanels);
+      //console.log("Panel",idpanel,mypanels);
       for (let i=0;i<mypanels.length;i++){
         mypanels[i].style.display = 'none';
       }
-      document.getElementById("tab_" + idpanel).style.display = 'block';
+      document.getElementById("pnl_" + idpanel).style.display = 'block';
       return false;
     },
     loaddialog: function( dlgname ){
index d1deb58..b3d0c46 100644 (file)
+const carbone = require('carbone');
 
-//const fs = require('fs');
-let report = {
+let report ={
   id_report: null,
   tmpfolder: usersystem.profilepath() + 'tmp/',
   tmpoutput: null,
   output: null,
-  pdfoptions: null,
   callback: null,
   data: null,
   reportfile:null,
   open: function(reporttype,fname){
-    console.log("prefs",preferences.global.currentdataset.datapath);
+    //console.log("prefs",preferences.global.currentdataset.datapath);
     console.log("open", preferences.global.currentdataset.datapath + '/' + reporttype + '/' + fname);
     if (fs.existsSync(preferences.global.currentdataset.datapath + '/' + reporttype + '/' + fname)){
       window.open(preferences.global.currentdataset.datapath + '/' + reporttype + '/' + fname);
     }
   },
   generate: function(id_report,reportdata,fname,callback){
-    db.query("select * from newreports WHERE id='"+id_report+"';").then(data => {
-      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
index 21c1340..43f5ae5 100644 (file)
@@ -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,
index 9efa690..576e9fd 100644 (file)
@@ -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 != ''){
index 92c9ca5..ef57e0a 100644 (file)
@@ -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"}
   ],
index 4b073b2..c010490 100644 (file)
@@ -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);
 
index d4f79ca..46936a4 100644 (file)
@@ -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 => {
index 0e57aab..e4ad244 100644 (file)
     <div class="container group_container">
       <div class="">
         <label class="label" for="defaultdata_mailapp">Mail-Programm</label>
-        <select class="select border data_defaultdata" data-column="pref" data-id="mailapp" data-selected="" data-table="defaultdata" id="defaultdata_mailapp">
-          <option value="smtp">SMTP</option>
-          <option value="outlook">Outlook</option>
-          <option value="thunderbird">Thunderbird</option>
-        </select>
-      </div>
-      <div class="row">
-        
-        <div class="cell">
-          <div class="">
-            <label class="label" for="defaultdata_smtpserver">Mail-Server</label> 
-            <input class="input border text  data_defaultdata" data-column="pref" data-id="smtpserver" data-table="defaultdata" id="defaultdata_smtpserver"  onblur="dataform.savefield(this);" placeholder="Mail-Server" type="text" value="mail.your-server.de">
-          </div>
-        </div>
-        <div class="cell">
-          <div class="">
-            <label class="label" for="defaultdata_smtpport">Port</label> 
-            <input class="input border number right-align text-align-right data_defaultdata" data-column="pref" data-id="smtpport" data-table="defaultdata" id="defaultdata_smtpport" onblur="dataform.savefield(this);" text-align-right="" type="number" value="587">
-          </div>
-        </div>
-      </div>
-      <div class="">
-        <label class="label" for="defaultdata_smtplogin">Login</label> <input class="input border text data_defaultdata" data-column="pref" data-id="smtplogin" data-table="defaultdata" id="defaultdata_smtplogin"  onblur="dataform.savefield(this);" placeholder="Login" type="text" value="ksaffran@dks.lu">
-      </div>
-      <div class="">
-        <label class="label" for="defaultdata_pref">Passwort</label> <input class="input border password data_defaultdata" data-column="pref" data-id="smtppassword" data-table="defaultdata" id="defaultdata_smtppassword" onblur="dataform.savefield(this);" placeholder="Passwort" type="password" value="fb1ia1ka">
+        <input class="input border text  data_defaultdata" data-column="pref" data-id="mailapp" data-table="defaultdata" id="defaultdata_mailapp"  onblur="dataform.savefield(this);" placeholder="Mail-App" type="text" value="">
       </div>
     </div>
   </fieldset>
diff --git a/desktopapp/modules/templates/templates.html b/desktopapp/modules/templates/templates.html
deleted file mode 100644 (file)
index 6713411..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-<div class="display-container bar toolbar">
-  <button class="bar-item toolbarbtn" onclick="myapp.gotoHome();"><span class="icon-back" style="font-size: 16px;"></span>zurück</button>
-  <div class="bar-item PageHeadTitle">
-    Vorlagen
-  </div><button class="bar-item toolbarbtn text-red right" onclick="templates.confirmRemove();"><span class="icon-trash tlbicon"></span>löschen</button> <button class="bar-item toolbarbtn right" onclick="templates.edit();"><span class="icon-edit tlbicon"></span>bearbeiten</button> 
-  <button class="bar-item toolbarbtn right" onclick="templates.duplicate();"><span class="icon-duplicate tlbicon"></span>dupl</button>
-  <button class="bar-item toolbarbtn right" onclick="templates.add();"><span class="icon-add tlbicon"></span>neu</button>
-</div>
-
-<div class="display-container">
-  <div class="row">
-    <div class="cell" style="width: 400px;">
-      <div id="tbl_templates"></div>
-    </div>
-    <div class="cell">
-      <div class="panel" id="pnl_templatereport" style="display: none;">
-        <form id="frm_templates">
-          <div class="row">
-            <div class="cell container" style="width: 400px;">
-              <label class="label" for="templates_reporttype">Kategorie</label> 
-              <select class="select border data_templates" data-column="column" data-id="" data-selected="" data-table="label" id="data_templates"></select>
-            </div>
-            <div class="cell container" style="width: 400px;">
-              <label class="label" for="templates_reportname">Name</label> 
-              <input class="input data_templates border text" data-column="reportname" data-id="" data-table="newreports" id="templates_reportname" onblur="dataform.savefield(this);" type="text">
-            </div>
-          </div>
-          <div class="bar moduletoolbar">
-            <button class="bar-item toolbarbtn" onclick="myapp.viewtab('templatedesign');return false;">Design</button>
-            <button class="bar-item toolbarbtn" onclick="myapp.viewtab('templatepdfoptions');return false;">Options</button>
-            <button class="bar-item toolbarbtn" onclick="myapp.viewtab('templatestyle');return false;">Style</button>
-          </div>
-          
-          <div id="tab_templatedesign" class="row tab" style="height:calc(100vh - 120px); overflow-y: scroll;">
-            <div class="row" style="width: calc(100vw);">
-              <div class="cell container" style="color: black;background-color: #c6c6c6; width: 60px;"><label class="label" style="transform-origin: bottom;transform: rotate(-90deg); ">Header</label></div>
-              <div class="cell">
-              <textarea class="input border data_templates richeditarea" style="height: 300px;" data-id="" data-column="headerhtml" data-table="newreports"  id="templates_headerhtml"></textarea>
-            </div>
-            </div>
-            <div class="row"  style="width: calc(100vw);">   
-              <div class="cell" style="color: black;background-color: #b4b3b3; width: 60px;"><label class="label" style="transform-origin: bottom;transform: rotate(-90deg); ">Body</label></div>
-              <div class="cell">
-              <textarea class="input border data_templates richeditarea" style="height: 500px; width:calc(100vw -500px);" data-id="" data-column="contenthtml" data-table="newreports"  id="templates_contenthtml" ></textarea>
-              </div>
-            </div>
-          
-            <div class="row"   style="width: calc(100vw);">  
-              <div class="cell" style="color: black;background-color: #c6c6c6; width: 60px;"><label class="label" style="transform-origin: bottom;transform: rotate(-90deg); ">Footer</label></div>
-              <div class="cell"> 
-              <label for="templates_footerhtml" class="label">Footer</label>
-              <textarea class="input border data_templates richeditarea" style="height: 300px;width:calc(100vw -500px);" data-id="" data-column="footerhtml" data-table="newreports"  id="templates_footerhtml" ></textarea>
-              </div>
-            </div>
-          </div>
-          <div id="tab_templatestyle" class="row tab" style="height:calc(100vh - 120px); overflow-y: scroll;display: none;" >
-            <div class="cell" style="width: 100%;">
-              <label class="label" for="templates_styles">Style Definition</label>
-              <textarea class="input border data_templates richeditarea" style="height: calc(100vh - 300px);width:calc(100vw -500px);"  data-id="" data-column="styles" data-table="newreports"  id="templates_styles" ></textarea>
-            </div>
-          </div>
-          <div id="tab_templatepdfoptions" class="row tab" style="height: calc(100vh - 120px); overflow-y: scroll;display: none;">
-            <div id="tbl_pdfoptions"></div>
-            <div id="tbl_dataoptions"></div>
-          </div>
-          
-        </form> 
-      </div>
-      <div class="tab" id="tab_templatereport"  style="display: none;">
-        <div class="container" style="width: 400px;">
-          <label class="label" for="email_subject">Betreff</label> 
-          <input class="input data_templates border text" data-column="headerhtml" data-id="" data-table="newreports" id="email_subject" onblur="dataform.savefield(this);" type="text">
-        </div>
-        <div class="cell" style="width: 100%;">
-          <label class="label" for="email_body">Nachricht</label>
-          <textarea class="input border data_templates richeditarea" style="height: calc(100vh - 300px);width:calc(100vw -500px);"  data-id="" data-column="contenthtml" data-table="newreports"  id="email_body" ></textarea>
-        </div>
-      </div>
-          
-      </div>
-  </div>
-</div>
-<!--
-  <div class="cell container" style="width: 200px; background-color: #e4e4e4; padding-bottom: 10px;" style="background-color: #e4e4e4; padding-bottom: 10px;">
-          <div class="cell container" style="width: 400px;">
-            
-          </div>
-        </div>
--->
diff --git a/desktopapp/modules/templates/templates.js b/desktopapp/modules/templates/templates.js
deleted file mode 100644 (file)
index c9bf371..0000000
+++ /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\>/,"<style>" + data.styles + "</style></head>");
-          // let datafooter=data.footerhtml.replace(/\<\/head\>/,"<style>" + data.styles + "</style></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
index a4c9f4e..e85e9d4 100644 (file)
     "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",
         }
       }
     },
+    "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",
       "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",
       "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"
       }
       "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"
       }
     "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",
         "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",
     "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",
         "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",
       "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"
+      }
     }
   }
 }
index 047a51f..9b3ac12 100644 (file)
@@ -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"
   }
 }
index f0e441b..1ebff57 100644 (file)
@@ -35,7 +35,7 @@
       <script src="vendor/flatpickr/flatpickr.min.js?v=6" type="text/javascript"></script> 
       <script src="vendor/flatpickr/l10n/de.js?v=6" type="text/javascript"></script> 
       <script src="vendor/mustache/mustache.min.js?v=6" type="text/javascript"></script>
-      <script src="vendor/tinymce/js/tinymce/tinymce.min.js" type="text/javascript"></script>
+      <!-- <script src="vendor/tinymce/js/tinymce/tinymce.min.js" type="text/javascript"></script> -->
       <script src="js/request.js?v=6" type="text/javascript"></script> 
       <script src="js/myapp.js?v=6" type="text/javascript"></script>
       <script src="js/dataform.js?v=6" type="text/javascript"></script> 
diff --git a/dev/test.bat b/dev/test.bat
new file mode 100644 (file)
index 0000000..708ecd0
--- /dev/null
@@ -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 (file)
index 0000000..ac618d6
--- /dev/null
@@ -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
index a01a473..ae6b273 100644 (file)
@@ -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 (file)
index 0000000..9e277bc
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+$data = array();
+$data["serial"] = $_REQUEST["serial"];
+$data["useragent"] = $_SERVER["HTTP_USER_AGENT"];
+
+if (empty($_REQUEST["serial"]) || ($_REQUEST["serial"] != "2020"))
+{
+    
+    header("HTTP/1.0 401 The serial number is not valid");
+    // error message to be displayed in installer
+    echo "The serial number is not valid".json_encode($data);
+} else {
+  file_put_contents("./serialdata.txt",json_encode($data));
+}
+?>
\ No newline at end of file
diff --git a/server/serialdata.txt b/server/serialdata.txt
new file mode 100644 (file)
index 0000000..2c7d0a4
--- /dev/null
@@ -0,0 +1 @@
+{"serial":"20","useragent":"Mozilla\/4.0 (compatible; Win32; WinHttp.WinHttpRequest.5)"}
\ No newline at end of file