From 532b8a2607f1d73f1f651f9b7bccc601f459f9a6 Mon Sep 17 00:00:00 2001 From: Kilian Saffran Date: Sun, 17 Mar 2019 10:21:22 +0100 Subject: [PATCH] print template form --- js/moduleglobal.js | 2 +- modules/accounts/index.html | 3 - modules/accounts/index.js | 56 ++++++----------- modules/templates/form_printtemplate.html | 76 ++++++++++++++++++++--- modules/templates/form_printtemplate.js | 30 +++++++++ modules/templates/index.js | 53 +++++++++++++++- modules/templates/lib/printtemplate.js | 4 +- 7 files changed, 172 insertions(+), 52 deletions(-) diff --git a/js/moduleglobal.js b/js/moduleglobal.js index 5efb098..de543ce 100644 --- a/js/moduleglobal.js +++ b/js/moduleglobal.js @@ -21,4 +21,4 @@ var mpref ={ //appdb.dbfile = this.cfg.dbfile; appdb.url = decodeURIComponent(this.cfg.serviceurl) + 'sqlite/' + decodeURIComponent(this.cfg.dbfile); } -} \ No newline at end of file +} diff --git a/modules/accounts/index.html b/modules/accounts/index.html index e5539ff..2897c37 100644 --- a/modules/accounts/index.html +++ b/modules/accounts/index.html @@ -30,9 +30,6 @@ Kunden-Nr. Company / Name Adresse - PLZ - Ort - Land E-mail Telefon diff --git a/modules/accounts/index.js b/modules/accounts/index.js index 6b5bdc9..f5fa6b5 100644 --- a/modules/accounts/index.js +++ b/modules/accounts/index.js @@ -10,38 +10,22 @@ function initpage(){ function loadtable(){ - // var sql = 'select ij.id,ij.byear,ij.date as datesortable, STRFTIME("%d.%m.%Y",ij.date) as date,ij.id,rec.company as recepient, sen.company as sender,ij.reference, ' + - // 'printf("%.2f",CAST(sum(pos.quantity * pos.unitamount) as real)) as netamount, ' + - // 'printf("%.2f",CAST(case when pos.taxpercent > 0 then sum(pos.taxpercent * pos.quantity * pos.unitamount) else 0.0 end AS REAL)) as taxamount, ' + - // 'printf("%.2f",CAST(sum(pos.quantity * pos.unitamount) + case when pos.taxpercent > 0 then sum(pos.taxpercent * pos.quantity * pos.unitamount) else 0.0 end AS real)) as totalamount, ' + - // 'printf("%.2f",COALESCE(ij.payedamount,0.0)) as payedamount, ' + - // 'ij.status ' + - // 'from invoicejournal ij ' + - // 'left join invoicepositions pos on (ij.id=pos.id_invoice) ' + - // 'left join accounts rec on (ij.id_receipient = rec.id) ' + - // 'left join accounts sen on (ij.id_sender = sen.id) where ij.byear=' + cfg.byear +' group by pos.id_invoice order by date desc;'; - // var data = appdb.dbquery(sql); - // //console.log(data.sqldata); - // for (var i in data.sqldata){ - // var cstatus = "secondary"; - // if (data.sqldata[i].status== "bezahlt"){ cstatus = "success"; } - // if (data.sqldata[i].status== "überfällig"){ cstatus = "danger"; } - // if (data.sqldata[i].status== "verschickt"){ cstatus = "warning"; } - // var acolor = ""; - // if (data.sqldata[i].totalamount.startsWith("-")){ acolor = "text-danger"; } - // var row = ''+ - // '' + - // ''+data.sqldata[i].datesortable+' ' + data.sqldata[i].date+ '' + - // '' + data.sqldata[i].recepient+ '' + - // '' + data.sqldata[i].sender+ '' + - // '' + data.sqldata[i].reference+ '' + - // '' + data.sqldata[i].status+ '' + - // '' + data.sqldata[i].totalamount+ ' €' + - - // ''; - // $("#tbl_invoices").append(row); - // } - $('#tbl_invoices').bootstrapTable({ + + var sql = 'SELECT id, company, prename,surname, address, zip, city, country, email, phone, mobile, ident FROM accounts;'; + var data = appdb.dbquery(sql); + console.log(data.sqldata); + for (var i in data.sqldata){ + var row = ''+ + '' + + '' + data.sqldata[i].ident+ '' + + '' + data.sqldata[i].company + (( data.sqldata[i].company != null)?'
':'') + data.sqldata[i].surname + ' ' + data.sqldata[i].surname + '' + + '' + data.sqldata[i].address+ ((data.sqldata[i].address != null)?'
':'') + data.sqldata[i].zip + ' ' + data.sqldata[i].city + ((data.sqldata[i].country != null)?'
':'')+ data.sqldata[i].country + '' + + '' + data.sqldata[i].email+ '' + + '' + data.sqldata[i].phone+ '' + + ''; + $("#tbl_accounts").append(row.replace(/null/g,'')); + } + $('#tbl_accounts').bootstrapTable({ pagination: false, search: false, height: tblh, @@ -54,9 +38,9 @@ function loadtable(){ function account_edit(){ - var inv_id= getTableSelectionID(); - if (inv_id){ - parent.browserapp.loadmodulepage('addresses','account',{"id":inv_id}); + var id= getTableSelectionID(); + if (id){ + parent.browserapp.loadmodulepage('accounts','form_account',{"id":d}); } } @@ -80,7 +64,7 @@ function getTableSelectionID(){ } function getTableSelectionIDs(){ - var sel = $('#tbl_invoices').bootstrapTable('getSelections'); + var sel = $('#tbl_accounts').bootstrapTable('getSelections'); var ids = []; if (sel){ for (var s in sel){ diff --git a/modules/templates/form_printtemplate.html b/modules/templates/form_printtemplate.html index 47ad799..abc8e03 100644 --- a/modules/templates/form_printtemplate.html +++ b/modules/templates/form_printtemplate.html @@ -64,25 +64,85 @@ +
+
+ + + + + + +
+
-
+ +
Seite 1
-
+
Seite 2
-
+
-
+
- - + + +
+
+
+
+
+ + +
+
+
+ + + + + + +
+
+
+
+
+
+ + + + +
+
+
+
+ + + + + + + + +
+
+
+
diff --git a/modules/templates/form_printtemplate.js b/modules/templates/form_printtemplate.js index ea81536..d02a0b6 100644 --- a/modules/templates/form_printtemplate.js +++ b/modules/templates/form_printtemplate.js @@ -1,4 +1,34 @@ function initpage(){ console.log(parent.usersystem.getsysinfo()); + if (mpref.cfg.id){ + gettemplatedata(mpref.cfg.id); + } else { + //load default new invoice data + } //parent.usersystem.setProperty("testproperty",{id:"TEST"}); +} + +function gettemplatedata(id){ + var sql = "select * from printtemplates where id='"+ id +"';"; + var data = appdb.dbquery(sql); + if (data.sqldata){ + for (var i in data.sqldata[0]){ + if ($("#" + i).prop("tagName") == "SELECT"){ + $("#" + i).val(data.sqldata[0][i]); + } else if ($("#" + i).prop("tagName") == "INPUT" ) { + console.log(i + ">=" + data.sqldata[0][i]); + $("#" + i).val(data.sqldata[0][i]); + } else { + $("#" + i).html(data.sqldata[0][i]); + } + } + } +} + +function gettemplateelements(id_printtemplate){ + var sql ="select id,name from printtemplateelements where id_printtemplate='"+ id_printtemplate +"';"; + var data = appdb.dbquery(sql); + for (var i in data.sqldata){ + + } } \ No newline at end of file diff --git a/modules/templates/index.js b/modules/templates/index.js index fca4ca2..f49aacf 100644 --- a/modules/templates/index.js +++ b/modules/templates/index.js @@ -1,10 +1,39 @@ +var winh = Math.max(document.documentElement.clientHeight, window.innerHeight || 0); +var tblh = winh-54; + function initpage(){ - + loadtable(); } +function loadtable(){ + var sql = "SELECT id, name,'Druck' as form,'printtemplate' as formtmpl, \"type\", lang,isdefault FROM printtemplates;"; + var data = appdb.dbquery(sql); + for (var i in data.sqldata){ + var row = ''+ + '' + + '' + data.sqldata[i].name+ '' + + '' + data.sqldata[i].lang + '' + + '' + data.sqldata[i].form + '' + + '' + data.sqldata[i].type+ '' + + '' + data.sqldata[i].isdefault+ '' + + ''; + $("#tbl_templates").append(row.replace(/null/g,'')); + } + $('#tbl_templates').bootstrapTable({ + pagination: false, + search: false, + height: tblh, + clickToSelect: true + }); +} function template_edit(){ - + var id= getTableSelectionID(); + if (id){ + if ($("#" + id ).data("tmpl") == 'printtemplate'){ + printtemplate.edit(id); + } + } } function template_duplicate(){ @@ -13,4 +42,24 @@ function template_duplicate(){ function template_delete(){ +} + +function getTableSelectionID(){ + var sel = $('#tbl_templates').bootstrapTable('getSelections'); + var id = null; + + if (sel){ id=sel[0]._id; } + console.log("Selected ID:" + id); + return id; +} + +function getTableSelectionIDs(){ + var sel = $('#tbl_templates').bootstrapTable('getSelections'); + var ids = []; + if (sel){ + for (var s in sel){ + ids.push(s._id); + } + } + return ids; } \ No newline at end of file diff --git a/modules/templates/lib/printtemplate.js b/modules/templates/lib/printtemplate.js index a0346f2..b507686 100644 --- a/modules/templates/lib/printtemplate.js +++ b/modules/templates/lib/printtemplate.js @@ -2,8 +2,8 @@ var printtemplate = { new: function(){ parent.browserapp.loadmodulepage('templates','form_printtemplate',{"id":""}); }, - edit: function(){ - + edit: function(id){ + parent.browserapp.loadmodulepage('templates','form_printtemplate',{"id":id}); }, duplicate: function(){ -- 2.39.5