From: kilian (ksmachome) Date: Sun, 27 Oct 2019 17:21:57 +0000 (+0100) Subject: v20191027 X-Git-Url: http://cloud.dks.lu/git/?a=commitdiff_plain;h=1e3661fdec9fab1c0d9d9c6419e9ef307cf6b4f7;p=dksnas.git v20191027 --- diff --git a/CGI/api/db.cgi b/CGI/api/db.cgi index 3f7ed3c..899ab94 100644 --- a/CGI/api/db.cgi +++ b/CGI/api/db.cgi @@ -58,6 +58,7 @@ if (($cgi->request_method() eq "GET") || ($cgi->request_method() eq "POST")){ if (exists($p->{filter})){ $sql .= " WHERE ".$p->{filter}.";"; } + $html->{result}->{view} = $p->{get}; $html->{result}->{sqldata} = $db->query($sql); } elsif (exists($p->{set})){ diff --git a/CGI/tmpl/app/invoicejournal/module/invoicejournal/index.js b/CGI/tmpl/app/invoicejournal/module/invoicejournal/index.js index 491fe3a..0f5d27d 100644 --- a/CGI/tmpl/app/invoicejournal/module/invoicejournal/index.js +++ b/CGI/tmpl/app/invoicejournal/module/invoicejournal/index.js @@ -1,4 +1,32 @@ var tbl=null; +var statustypes = [{"value":"planned","label":"geplant"}, +{"value":"sended","label":"verschickt"}, +{"value":"received","label":"erhalten"}, +{"value":"payed","label":"bezahlt"}, +{"value":"overdue","label":"überfällig"} +]; +var quarters =[{"value":"Q1","label":"Q1"},{"value":"Q2","label":"Q2"},{"value":"Q3","label":"Q3"},{"value":"Q4","label":"Q4"}]; +var invoicetypes = [{"value":"inv-out","label":"Ausgangs-Rechnung"},{"value":"inv-in","label":"Eingangs-Rechnung"},{"value":"crn-out","label":"Ausgangs-Gutschrift"},{"value":"crn-in","label":"Eingangs-Gutschrift"}]; + +var choice = { + "invoices":{ + "status":null, + "id_receipient":null, + "id_sender":null, + "bquarter":null, + "byear": null, + "invoicetype":null + }}; + +var choicedata = { + "invoices":{ + "status":{"data":statustypes}, + "id_receipient":{"view":"receipients"}, + "id_sender":{"view":"receipients"}, + "bquarter":{"data":quarters}, + "byear": {"view":"businessyears"}, + "invoicetype":{"data":invoicetypes} + }}; function initpage(){ console.log(mpref.cfg); @@ -9,6 +37,7 @@ function initpage(){ allowInput: true, "locale": "de", }); + tbl = new Tabulator("#tbl_invoices", { headerFilterPlaceholder:"filter...", height: "95vh", @@ -50,10 +79,13 @@ function initpage(){ }}] }); gettbldata(); + fillchoices(); + return false; } function gettbldata(){ req.reqdata("POST","db.cgi",{"db":parent.app + "/" + mpref.cfg.db, "get":"invoices"},loadtbldata); + return false; } function loadtbldata(data){ @@ -61,20 +93,33 @@ function loadtbldata(data){ if (data && data.sqldata){ tbl.setData(data.sqldata); } + return false; } function edit(){ var udata = tbl.getSelectedData(); + //cleanform("invoices"); if (udata[0]){ - console.log(udata); + console.log(udata[0]); + req.reqdata("POST","db.cgi",{"db":parent.app + "/" + mpref.cfg.db, "get":"invoices","filter":"id=" + udata[0].id},fillinvoice); viewinvoicepanel(); } - + return false; +} + +function fillinvoice(data){ + if (data && data.sqldata){ + //console.log(data); + fillformbydataclass("invoices",data.sqldata[0],false); + } + return false; } function add(){ + //cleanform("invoices"); //TODO Clean form viewinvoicepanel(); + return false; } function remove(){ @@ -94,3 +139,40 @@ function viewtable(){ return false; } +function getchoicedata(view){ + req.reqdata("POST","db.cgi",{"db":parent.app + "/" + mpref.cfg.db, "get":view},setchoicesdata); + return false; +} + +function setchoicesdata(data){ + if (data && data.sqldata && data.view){ + for (var f in choice){ + for (var c in choice[f]){ + if (choicedata[f][c]['view'] && choicedata[f][c]['view'] == data.view){ + fillselectlist(choice[f][c],data.sqldata,"value","label"); + } + } + } + } + return false; +} + +function fillchoices(){ + for (var f in choice){ + for (var c in choice[f]){ + choice[f][c] = new Choices('#' + c,{ + searchEnabled: false, + itemSelectText: '', + removeItemButton: true, + choices : ((choicedata[f][c]['data'])?choicedata[f][c]['data']:[]), + shouldSort: false + }); + if (choicedata[f][c]['view']){ + console.log("We have a view:"+ choicedata[f][c]['view']); + getchoicedata(choicedata[f][c]['view']); + } + } + } + return false; +} + diff --git a/CGI/tmpl/app/invoicejournal/module/invoicejournal/index.tt b/CGI/tmpl/app/invoicejournal/module/invoicejournal/index.tt index 537b40c..3dea234 100644 --- a/CGI/tmpl/app/invoicejournal/module/invoicejournal/index.tt +++ b/CGI/tmpl/app/invoicejournal/module/invoicejournal/index.tt @@ -11,8 +11,8 @@