From: kilian (dks-laptop) Date: Wed, 15 Jan 2020 08:09:37 +0000 (+0100) Subject: v20200114 X-Git-Tag: 1.0.15~72 X-Git-Url: http://cloud.dks.lu/git/?a=commitdiff_plain;h=df2013a6c1c7a99f29a7ffa4ef0df69afa290889;p=pot_lu.git v20200114 --- diff --git a/backoffice/api/index.cgi b/backoffice/api/index.cgi index 2d926f82..9edf8d5b 100755 --- a/backoffice/api/index.cgi +++ b/backoffice/api/index.cgi @@ -74,7 +74,7 @@ if (($cgi->request_method() eq "GET") || ($cgi->request_method() eq "POST")){ # } if ($p->{fn} eq "saveform"){ - # $html->{p} = $p; + $html->{p} = $p; $html->{result}->{ident} = $p->{ident}; delete $p->{ident}; delete $p->{fn}; @@ -82,7 +82,7 @@ if (($cgi->request_method() eq "GET") || ($cgi->request_method() eq "POST")){ my $retid=undef; my $type = "upd"; foreach my $px (keys(%{$p})){ - $html->{result}->{datafield} = $px; + #$html->{result}->{datafield} = $px; if (($px =~ /\_id$/) && ($p->{$px} eq "")){ $type = "ins"; delete $p->{$px}; @@ -95,7 +95,7 @@ if (($cgi->request_method() eq "GET") || ($cgi->request_method() eq "POST")){ else { @sql = $db->create_ddl_update($p); } - #$html->{sql} = \@sql; + $html->{sql} = \@sql; foreach my $s (@sql){ #if ($type eq "ins"){ $retid= $db->dbquerysorted($s); @@ -104,7 +104,7 @@ if (($cgi->request_method() eq "GET") || ($cgi->request_method() eq "POST")){ #} } - $html->{result}->{id} = $retid->{0}; + $html->{result} = $retid->{0}; #$p->{table},#$p->{field},$p->{value},$p->{id},$p->{type} } if($p->{fn} eq "deleterow"){ @@ -188,10 +188,10 @@ if (($cgi->request_method() eq "GET") || ($cgi->request_method() eq "POST")){ } } if ($p->{fn} eq "getschemaaccess"){ - my $sql = "select schemata, company from companies where schemata in ( -select json_array_elements_text(schemaaccess) as schemaaccess from users where id=".$sess->{id}.") order by company;"; - if ($sess->{usergroups} =~ /admin/){ - $sql = "select schemata, company from companies order by company;"; + my $sql = "select schemata,company from companies where schemata in ( + select json_array_elements_text(schemaaccess) as schemaaccess from users where id=".$sess->{id}.") order by company;"; + if ($sess->{usergroup} eq "admin"){ + $sql = "select * from vw_schemata;"; } $html->{result} = $db->dbquerysorted($sql); } diff --git a/backoffice/api/lib/dksconfig.pm b/backoffice/api/lib/dksconfig.pm index e646d2b7..f79ba1c4 100644 --- a/backoffice/api/lib/dksconfig.pm +++ b/backoffice/api/lib/dksconfig.pm @@ -11,7 +11,7 @@ our @EXPORT_OK = qw($sitecfg); our $sitecfg ={ cookiename => 'potlu', dbtype => 'PgPP', - dsn => 'DBI:PgPP:dbname=potlu_db;host=DKS-LAPTOP.fritz.box', + dsn => 'DBI:PgPP:dbname=potlu_db;host=localhost', #dsn => 'DBI:PgPP:dbname=potlu_db;host=sql629.your-server.de', dbuser => 'potlu_user', dbpassword => 'r2btTTRfuJz4whez', diff --git a/backoffice/api/lib/pdfreport.pm b/backoffice/api/lib/pdfreport.pm new file mode 100644 index 00000000..7c1b7caf --- /dev/null +++ b/backoffice/api/lib/pdfreport.pm @@ -0,0 +1,112 @@ +package pdfreport; + +use strict; +use Template; +use File::Basename qw/dirname basename/; +use Data::Dumper; +use File::Copy::Recursive qw(dircopy); +sub new { + my $class = shift; + my $p = shift; + my $self = bless {}, $class; + $self->{tmplpath} =$p->{tmplpath}; + $self->{tmp} =$p->{tmp}; + $self->{pdf} = undef; + $self->{template} = undef; + #$self->{template} = $p->{template}; + $self->{pdf}->{app} = "/usr/local/bin/wkhtmltopdf"; + return $self; +} + +sub createpdf(){ + my $self = shift; + my $template = shift; + my $output = shift; + my $inputdata = shift; + my $r = -1; + print $self->{tmplpath}.'/'.$template.'.conf'."\n"; + if (-e $self->{tmplpath}.'/'.$template.'.conf'){ + $self->readpdfconfig($template,$inputdata); + print Dumper($self->{template}); + } + print Dumper($self->{pdf}); + print Dumper($self->{template}); + my $tmpreportpath=$self->{tmplpath}; + if (exists($self->{pdf}->{engine}) && ($self->{pdf}->{engine} eq "Template::Toolkit")){ + $template = $self->createTTReport($template); + $tmpreportpath = $self->{tmp}; + } + if ((keys(%{$self}) > 0) && (-e $tmpreportpath.'/'.$template.'.html')){ + my $cmd = '"'.$self->{pdf}->{app}.'"'; + if ($self->{pdf}->{bottom}){ $cmd .= " -B ".$self->{pdf}->{bottom}; } + if ($self->{pdf}->{left}){ $cmd .= " -L ".$self->{pdf}->{left}; } + if ($self->{pdf}->{right}){ $cmd .= " -R ".$self->{pdf}->{right}; } + if ($self->{pdf}->{top}){ $cmd .= " -T ".$self->{pdf}->{top}; } + if ($self->{pdf}->{orientation}){ $cmd .= " -O ".$self->{pdf}->{orientation}; } + if ($self->{pdf}->{size}){ $cmd .= " -s ".$self->{pdf}->{size}; } + if ($self->{pdf}->{encoding}){ $cmd .= " --encoding '".$self->{pdf}->{encoding}."'"; } + if (-e $tmpreportpath.'/'.$template.'.header.html'){ + $cmd .= ' --header-html "'.$tmpreportpath.'/'.$template.'.header.html"'; + } + if (-e $tmpreportpath.'/'.$template.'.footer.html'){ + $cmd .= ' --footer-html "'.$tmpreportpath.'/'.$template.'.footer.html"'; + } + $cmd .= ' "'.$tmpreportpath.'/'.$template.'.html"'; + $cmd .= ' "'.$output.'"'; + print $cmd."\n"; + $r = system($cmd); + } + if (-e $output){ + return ($r,$output); + } + return ($r,undef); +} + +sub createTTReport(){ + my $self = shift; + my $template = shift; + my $uniquekey = $$; + if (-e $self->{tmplpath}.'/'.$template.".tt"){ + $self->TTtoHTML($self->{tmplpath}.'/'.$template.".tt",$self->{tmp}.'/'.$template.$$.".html"); + } + if (-e $self->{tmplpath}.'/'.$template.".header.tt"){ + $self->TTtoHTML($self->{tmplpath}.'/'.$template.".header.tt",$self->{tmp}.'/'.$template.$$.".header.html"); + } + if (-e $self->{tmplpath}.'/'.$template.".footer.tt"){ + $self->TTtoHTML($self->{tmplpath}.'/'.$template.".footer.tt",$self->{tmp}.'/'.$template.$$.".footer.html"); + } + if (-d $self->{tmplpath}.'/'.$template){ + dircopy($self->{tmplpath}.'/'.$template,$self->{tmp}.'/'.$template); + } + return $template.$$; +} + +sub TTtoHTML(){ + my $self = shift; + my $ttfile = shift; + my $outfile = shift; + my $template = Template->new({INCLUDE_PATH => [dirname($ttfile)]});#,ENCODING => 'utf8' + $template->process(basename($ttfile),$self->{template},$outfile) || die "Template process failed: ", $template->error(), "\n";#,{binmode => ':utf8'} +} + +sub readpdfconfig(){ + my $self = shift; + my $template = shift; + my $inputdata = shift; + open(CFG,$self->{tmplpath}.'/'.$template.'.conf'); + while (my $l = ){ + chomp($l); + print $l."\n"; + $l =~ s/^\s+//; + if (($l =~ /^#/) || ($l eq "")) {next;} + if ($l =~ /\w+=.+/){ + my ($k1,$k2,$v) = $l =~ m/^(\w+)_(\w+)=\"(.+)\"$/; + $self->{lc($k1)}->{lc($k2)} = $v; + } + } + close(CFG); + foreach my $ik (keys(%{$inputdata})){ + $self->{template}->{lc($ik)} = $inputdata->{$ik}; + } +} +1; \ No newline at end of file diff --git a/backoffice/api/report.cgi b/backoffice/api/report.cgi new file mode 100644 index 00000000..d00a63d7 --- /dev/null +++ b/backoffice/api/report.cgi @@ -0,0 +1,118 @@ +#!/Users/kilian/perl5/perlbrew/perls/perl-5.24.1/bin/perl +use strict; +use FindBin qw($RealBin $Bin); +# use lib ('CGI/api/lib/perl5'); +# use lib ('CGI/api/lib'); +use lib ($Bin.'/CGI/api/lib/perl5'); +use lib ($Bin.'/CGI/api/lib'); +use lib ($RealBin.'/lib/perl5'); +use lib ($RealBin.'/lib'); +use CGI; +use CGI::Cookie; +# use CGI::Carp qw/fatalsToBrowser/; +use File::Basename; +use JSON::PP; +use MIME::Type::FileName; +use dksconfig qw/$sitecfg/; +use dksdb; + +# use session; +#use sendemail; +my $cgi = new CGI(); +my $scriptpath = $cgi->url(-absolute => 1); +my $p = (); +my @params = $cgi->param(); +foreach my $pe (@params){ + $p->{$pe} = $cgi->param($pe); +} +my $html->{result} = (); +# $p->{sid} = $cgi->cookie($sitecfg->{cookiename}); +# my $se = session->new(); +# my $sess = $se->getsession($p->{sid}); +print $cgi->header(-type=>"application/json", -charset => "utf-8"); +my $dbredirect = {}; +if ($sitecfg->{dbtype} eq "SQLite"){ + if (exists($p->{db})){ + $dbredirect->{dsn} = "DBI:SQLite:dbname=".$sitecfg->{datapath}.'/'.$p->{db}.'.sqlite'; + } +} +#$html->{conn} = $dbredirect; +# if ($sess == undef){ +# $html->{error} = "No Authorisation"; +# print JSON::PP::encode_json($html); +# exit(0); +# } +# $html->{p} = $p; +# $html->{sess} =$sess; +#my $datapath = $ENV{"DOCUMENT_ROOT"}.dirname(dirname($scriptpath)).'/data/'; +if (($cgi->request_method() eq "GET") || ($cgi->request_method() eq "POST")){ + + # my @params = $cgi->param(); + # foreach my $pp (@params){ + # $p->{$pp} = $cgi->param($pp); + # } + + if (exists($p->{list})){ + #$html->{param} = $p; + my $reppath = $sitecfg->{datapath}.'/'.$p->{app}.'/templates/'.$p->{list}; + #$html->{path} = $reppath; + if (-d $reppath){ + #print "OK!"; + my @allreps = (); + opendir(REP,$reppath); + while (my $f = readdir(REP)){ + if ($f =~ /\.conf$/){ + my $rep->{name}= $f; + $rep->{name} =~ s/\.conf$//; + $rep->{label} = $rep->{name}; + + open(RTPL,$reppath.'/'.$f); + while (my $l = ){ + chomp($l); + if ($l =~ /^REPORT_NAME/){ + my ($k1,$k2,$v) = $l =~ m/^(\w+)_(\w+)=\"(.+)\"$/; + $rep->{label} = $v; + } + } + close(RTPL); + push(@allreps,$rep); + } + } + closedir(REP); + $html->{result}->{reports} = \@allreps; + } + } + elsif (exists($p->{generate})){ + # my $data = { + # id_invoice => "469", + # dsn => 'DBI:SQLite:dbname='.$dbpath.'/invoicejournal/dksbuchhaltung.sqlite' + # }; + # my $rep = pdfreport->new({tmplpath => $RealBin.'/report', tmp => $RealBin.'/tmp'}); + # my ($result,$file) = $rep->createpdf('ttinvoice',$RealBin.'/output/textinvoice.pdf',$data); + # print "$result: $file\n"; + } + elsif (exists($p->{open})){ + if (exists($p->{file}) && -e ){ + + my $mimetype = MIME::Type::FileName::guess ($sitecfg->{data}.'/'.$p->{file}); + my @stat = stat($sitecfg->{data}.'/'.$p->{file}); + print $cgi->header( + -type => $mimetype, + -target => basename($p->{file}), + -attachment => basename($p->{file}) + ); + open(DLD,$sitecfg->{data}.'/'.$p->{file}); + binmode(DLD); + local $/ = \1024; + while (){ + print $_; + } + close(DLD); + exit(0); + } + } +} +print JSON::PP::encode_json($html); +# for my $e ( keys %ENV ) { +# print "$e: $ENV{$e}
"; +# } \ No newline at end of file diff --git a/backoffice/data/reports/invoices/dks-deutsch.conf b/backoffice/data/reports/invoices/dks-deutsch.conf new file mode 100644 index 00000000..d5f503a9 --- /dev/null +++ b/backoffice/data/reports/invoices/dks-deutsch.conf @@ -0,0 +1,12 @@ +PDF_TOP="40mm" +PDF_BOTTOM="20mm" +PDF_LEFT="20mm" +PDF_RIGHT="10mm" +PDF_SIZE="A4" +PDF_ORIENTATION="Portrait" +PDF_ENGINE="Template::Toolkit" +PDF_ENCODING="UTF-8" +TEMPLATE_DSN="" +TEMPLATE_DBUSER="" +TEMPLATE_DBPASSWORD="" +REPORT_NAME="DKS - deutsch" \ No newline at end of file diff --git a/backoffice/data/reports/invoices/dks-deutsch.footer.tt b/backoffice/data/reports/invoices/dks-deutsch.footer.tt new file mode 100644 index 00000000..0f199531 --- /dev/null +++ b/backoffice/data/reports/invoices/dks-deutsch.footer.tt @@ -0,0 +1,37 @@ + + + + + + + + + + + + +
SAFFRAN IT Consulting s.à r.l. ist eine Handelsbezeichnung von
DKS, Société à responsabilité limitée, RC B168572 - TVA: LU 2537 5617 - No. Aut: 10024550 / 0
+ IBAN: LU25 0020 1100 2783 8700; BIC: BILLLULL
+ Seite / +
+ \ No newline at end of file diff --git a/backoffice/data/reports/invoices/dks-deutsch.header.tt b/backoffice/data/reports/invoices/dks-deutsch.header.tt new file mode 100644 index 00000000..8e403506 --- /dev/null +++ b/backoffice/data/reports/invoices/dks-deutsch.header.tt @@ -0,0 +1,20 @@ + + + + + + + + + + +
+
+ SAFFRAN IT Consulting S.à r.l.
+ 4, rue Principale
+ L-3770 Tétange

+ Tel: +352 691 504 574
+ info@saffran.lu / www.saffran.lu
+
+
+ diff --git a/backoffice/data/reports/invoices/dks-deutsch.tt b/backoffice/data/reports/invoices/dks-deutsch.tt new file mode 100644 index 00000000..93f96d04 --- /dev/null +++ b/backoffice/data/reports/invoices/dks-deutsch.tt @@ -0,0 +1,126 @@ +[% USE DBI %] +[% USE dksdb = DBI(dsn, dbuser, dbpassword) %] + + + + Invoice + + + + [% qginv = dksdb.prepare("select * from vw_invoiceoutlist WHERE id= ?") %] + [% ginv = qginv.execute(id_invoice) %] + [% inv = ginv.get_all() %] + + + + + + + + + + +
Rechnung
+ [% inv.0.receipient %]
[% inv.0.address %]
[% inv.0.zip %] [% inv.0.city %]
[% inv.0.country %]
+
+ + + + + +
Rechnungs-Nr.[% inv.0.reference %]
Datum[% inv.0.invoicedate %]
Fälligkeit[% inv.0.deadlinedate %]
Kundennummer[% inv.0.ident %]
+
+ [% qbookings = dksdb.prepare("SELECT id, id_invoice, quantity, unit, description, unitamount, netamount, taxamount, taxpercent, totalamount FROM vw_bookingoutlist where id_invoice= ?;") %] + + + + + + + + + + + + [% FOREACH book = qbookings.execute(id_invoice) %] + + + + + + + + [% END %] + + + + + + + + + + + + + +
Produkt / DienstleistungAnz.Einzel-PreisNetto-Summe
[% book.description %][% book.quantity %][% book.unit %][% book.unitamount %] €[% book.netamount %] €
Total Netto + [% inv.0.totalnet %] €
MwSt. (17%) + [% inv.0.totalvat %] €
Gesamt zu bezahlen: + [% inv.0.totalgross %] €
+
Nous vous prions de virer le montant ci-dessus au compte
+ LU25 0020 1100 2783 8700 (BILLLULL)
+ + \ No newline at end of file diff --git a/backoffice/data/reports/invoices/dks-deutsch/dks_500.png b/backoffice/data/reports/invoices/dks-deutsch/dks_500.png new file mode 100644 index 00000000..35c6adb0 Binary files /dev/null and b/backoffice/data/reports/invoices/dks-deutsch/dks_500.png differ diff --git a/backoffice/data/reports/invoices/dks-deutsch/sitc.png b/backoffice/data/reports/invoices/dks-deutsch/sitc.png new file mode 100644 index 00000000..853b36a6 Binary files /dev/null and b/backoffice/data/reports/invoices/dks-deutsch/sitc.png differ diff --git a/backoffice/data/reports/pot/pot_period.conf b/backoffice/data/reports/pot/pot_period.conf new file mode 100644 index 00000000..9861e2b3 --- /dev/null +++ b/backoffice/data/reports/pot/pot_period.conf @@ -0,0 +1,12 @@ +PDF_TOP="40mm" +PDF_BOTTOM="20mm" +PDF_LEFT="20mm" +PDF_RIGHT="10mm" +PDF_SIZE="A4" +PDF_ORIENTATION="Landscape" +PDF_ENGINE="Template::Toolkit" +PDF_ENCODING="UTF-8" +TEMPLATE_DSN="" +TEMPLATE_DBUSER="" +TEMPLATE_DBPASSWORD="" +REPORT_NAME="POT - Periode" \ No newline at end of file diff --git a/backoffice/data/reports/pot/pot_period.footer.tt b/backoffice/data/reports/pot/pot_period.footer.tt new file mode 100644 index 00000000..0f199531 --- /dev/null +++ b/backoffice/data/reports/pot/pot_period.footer.tt @@ -0,0 +1,37 @@ + + + + + + + + + + + + +
SAFFRAN IT Consulting s.à r.l. ist eine Handelsbezeichnung von
DKS, Société à responsabilité limitée, RC B168572 - TVA: LU 2537 5617 - No. Aut: 10024550 / 0
+ IBAN: LU25 0020 1100 2783 8700; BIC: BILLLULL
+ Seite / +
+ \ No newline at end of file diff --git a/backoffice/data/reports/pot/pot_period.header.tt b/backoffice/data/reports/pot/pot_period.header.tt new file mode 100644 index 00000000..8e403506 --- /dev/null +++ b/backoffice/data/reports/pot/pot_period.header.tt @@ -0,0 +1,20 @@ + + + + + + + + + + +
+
+ SAFFRAN IT Consulting S.à r.l.
+ 4, rue Principale
+ L-3770 Tétange

+ Tel: +352 691 504 574
+ info@saffran.lu / www.saffran.lu
+
+
+ diff --git a/backoffice/data/reports/pot/pot_period.tt b/backoffice/data/reports/pot/pot_period.tt new file mode 100644 index 00000000..93f96d04 --- /dev/null +++ b/backoffice/data/reports/pot/pot_period.tt @@ -0,0 +1,126 @@ +[% USE DBI %] +[% USE dksdb = DBI(dsn, dbuser, dbpassword) %] + + + + Invoice + + + + [% qginv = dksdb.prepare("select * from vw_invoiceoutlist WHERE id= ?") %] + [% ginv = qginv.execute(id_invoice) %] + [% inv = ginv.get_all() %] + + + + + + + + + + +
Rechnung
+ [% inv.0.receipient %]
[% inv.0.address %]
[% inv.0.zip %] [% inv.0.city %]
[% inv.0.country %]
+
+ + + + + +
Rechnungs-Nr.[% inv.0.reference %]
Datum[% inv.0.invoicedate %]
Fälligkeit[% inv.0.deadlinedate %]
Kundennummer[% inv.0.ident %]
+
+ [% qbookings = dksdb.prepare("SELECT id, id_invoice, quantity, unit, description, unitamount, netamount, taxamount, taxpercent, totalamount FROM vw_bookingoutlist where id_invoice= ?;") %] + + + + + + + + + + + + [% FOREACH book = qbookings.execute(id_invoice) %] + + + + + + + + [% END %] + + + + + + + + + + + + + +
Produkt / DienstleistungAnz.Einzel-PreisNetto-Summe
[% book.description %][% book.quantity %][% book.unit %][% book.unitamount %] €[% book.netamount %] €
Total Netto + [% inv.0.totalnet %] €
MwSt. (17%) + [% inv.0.totalvat %] €
Gesamt zu bezahlen: + [% inv.0.totalgross %] €
+
Nous vous prions de virer le montant ci-dessus au compte
+ LU25 0020 1100 2783 8700 (BILLLULL)
+ + \ No newline at end of file diff --git a/backoffice/data/reports/pot/staff_workplan.conf b/backoffice/data/reports/pot/staff_workplan.conf new file mode 100644 index 00000000..5de8ad88 --- /dev/null +++ b/backoffice/data/reports/pot/staff_workplan.conf @@ -0,0 +1,12 @@ +PDF_TOP="40mm" +PDF_BOTTOM="20mm" +PDF_LEFT="20mm" +PDF_RIGHT="10mm" +PDF_SIZE="A4" +PDF_ORIENTATION="Landscape" +PDF_ENGINE="Template::Toolkit" +PDF_ENCODING="UTF-8" +TEMPLATE_DSN="" +TEMPLATE_DBUSER="" +TEMPLATE_DBPASSWORD="" +REPORT_NAME="POT - Salarié" \ No newline at end of file diff --git a/backoffice/data/reports/pot/staff_workplan.footer.tt b/backoffice/data/reports/pot/staff_workplan.footer.tt new file mode 100644 index 00000000..0f199531 --- /dev/null +++ b/backoffice/data/reports/pot/staff_workplan.footer.tt @@ -0,0 +1,37 @@ + + + + + + + + + + + + +
SAFFRAN IT Consulting s.à r.l. ist eine Handelsbezeichnung von
DKS, Société à responsabilité limitée, RC B168572 - TVA: LU 2537 5617 - No. Aut: 10024550 / 0
+ IBAN: LU25 0020 1100 2783 8700; BIC: BILLLULL
+ Seite / +
+ \ No newline at end of file diff --git a/backoffice/data/reports/pot/staff_workplan.header.tt b/backoffice/data/reports/pot/staff_workplan.header.tt new file mode 100644 index 00000000..8e403506 --- /dev/null +++ b/backoffice/data/reports/pot/staff_workplan.header.tt @@ -0,0 +1,20 @@ + + + + + + + + + + +
+
+ SAFFRAN IT Consulting S.à r.l.
+ 4, rue Principale
+ L-3770 Tétange

+ Tel: +352 691 504 574
+ info@saffran.lu / www.saffran.lu
+
+
+ diff --git a/backoffice/data/reports/pot/staff_workplan.tt b/backoffice/data/reports/pot/staff_workplan.tt new file mode 100644 index 00000000..93f96d04 --- /dev/null +++ b/backoffice/data/reports/pot/staff_workplan.tt @@ -0,0 +1,126 @@ +[% USE DBI %] +[% USE dksdb = DBI(dsn, dbuser, dbpassword) %] + + + + Invoice + + + + [% qginv = dksdb.prepare("select * from vw_invoiceoutlist WHERE id= ?") %] + [% ginv = qginv.execute(id_invoice) %] + [% inv = ginv.get_all() %] + + + + + + + + + + +
Rechnung
+ [% inv.0.receipient %]
[% inv.0.address %]
[% inv.0.zip %] [% inv.0.city %]
[% inv.0.country %]
+
+ + + + + +
Rechnungs-Nr.[% inv.0.reference %]
Datum[% inv.0.invoicedate %]
Fälligkeit[% inv.0.deadlinedate %]
Kundennummer[% inv.0.ident %]
+
+ [% qbookings = dksdb.prepare("SELECT id, id_invoice, quantity, unit, description, unitamount, netamount, taxamount, taxpercent, totalamount FROM vw_bookingoutlist where id_invoice= ?;") %] + + + + + + + + + + + + [% FOREACH book = qbookings.execute(id_invoice) %] + + + + + + + + [% END %] + + + + + + + + + + + + + +
Produkt / DienstleistungAnz.Einzel-PreisNetto-Summe
[% book.description %][% book.quantity %][% book.unit %][% book.unitamount %] €[% book.netamount %] €
Total Netto + [% inv.0.totalnet %] €
MwSt. (17%) + [% inv.0.totalvat %] €
Gesamt zu bezahlen: + [% inv.0.totalgross %] €
+
Nous vous prions de virer le montant ci-dessus au compte
+ LU25 0020 1100 2783 8700 (BILLLULL)
+ + \ No newline at end of file diff --git a/backoffice/index.cgi b/backoffice/index.cgi index 18ad2d47..020a59a5 100755 --- a/backoffice/index.cgi +++ b/backoffice/index.cgi @@ -191,9 +191,9 @@ $vars->{params}= $p; #END - iFrame - Modules $template->process($skl,$vars) || die "Template process failed: ", $template->error(), "\n"; -# print "/*".Dumper($vars)."*/"; +#print "/*".Dumper($vars)."*/"; # if ($vars->{page} =~ /\.tt/){ -# print '
'.Dumper($p)."
";
+#    print '
'.Dumper($vars)."
";
 # } 
 
 
diff --git a/backoffice/js/admin.js b/backoffice/js/admin.js
index e944507e..5fce5c97 100644
--- a/backoffice/js/admin.js
+++ b/backoffice/js/admin.js
@@ -78,7 +78,7 @@ document.addEventListener("DOMContentLoaded", function() {
   
   choice["company"]["schemata"] = new Choices('#schemata',{
     searchEnabled: false,
-    itemSelectText: 'x',
+    itemSelectText: '',
     removeItemButton: false,
     choices : []
   });
@@ -92,12 +92,14 @@ function getschemata(){
 
 function fillschematalist(data){
   console.log(data);
-  fillselectlist(choice["company"]["schemata"],data,'schemata','company');
+  fillselectlist(choice["company"]["schemata"],data,'schemaname','company');
   
   return false;
 }
 
 function fillselectlist(obj,data,vidcol,vvalcol){
+  console.log("fillselectlist");
+  console.log(data);
   var sellist = [];
   obj.clearStore();
   if (data){
diff --git a/backoffice/js/formsave.js b/backoffice/js/formsave.js
index 32c1f508..69efe9f6 100644
--- a/backoffice/js/formsave.js
+++ b/backoffice/js/formsave.js
@@ -1,7 +1,11 @@
-function saveform(frmid,aftercallback){
+function saveform(frmid,aftercallback,clientschema){
   var flds=getformcontent(frmid,null);
   flds["fn"] ="saveform";
-  flds["schemata"]=schemata;
+  flds["schemata"]=clientschema;
+  if (clientschema == null){
+    flds["schemata"]=schemata;
+  }
+  
   //console.log(flds);
   delete flds["null"]; 
   if (aftercallback){
@@ -14,6 +18,23 @@ function saveform(frmid,aftercallback){
   return false;
 }
 
+function saveformdata(flds,aftercallback,clientschema){
+  flds["fn"] ="saveform";
+  flds["schemata"]=clientschema;
+  if (clientschema == null){
+    flds["schemata"]=schemata;
+  }
+  delete flds["null"];
+  if (aftercallback){
+    req.reqdata("POST","index.cgi",flds,aftercallback);
+    formsaved({});
+  }
+  else {
+    req.reqdata("POST","index.cgi",flds,formsaved);
+  }
+  return false;
+}
+
 function formsaved(data){
   var sb = document.getElementById("snackbar");
   sb.className="show w3-green";
@@ -252,10 +273,15 @@ function fillformbydataclass2(dataclass,choices,data){
             frm[f]._flatpickr.setDate(data[frm[f].id]);
           } else if (frm[f].classList.contains("timefield")){ 
             frm[f]._flatpickr.setDate(data[frm[f].id]);
-          }else if (frm[f].classList.contains("choices__input")){  
+          }else if (frm[f].classList.contains("choices__input")){ 
             if ((data[frm[f].id] != null) && (data[frm[f].id] != '[""]')){
               console.log(frm[f].id);
-              choices[frm[f].id].setValue(JSON.parse(data[frm[f].id])); 
+              if (data[frm[f].id].startsWith('["')){
+                choices[frm[f].id].setValue(JSON.parse(data[frm[f].id]));
+              }
+              else {
+                choices[frm[f].id].setChoiceByValue(data[frm[f].id]);
+              } 
             }
           } else {
             frm[f].value=data[frm[f].id];
diff --git a/backoffice/js/request.js b/backoffice/js/request.js
index 19f2a332..4e80e025 100644
--- a/backoffice/js/request.js
+++ b/backoffice/js/request.js
@@ -82,7 +82,7 @@ var req = {
          //console.log("Status returned: " + request.status + "resp:" + request.getResponseHeader("Content-Type"));
         if (request.getResponseHeader("Content-Type").indexOf('application/json') == 0){
           if (request.responseText){
-            //console.log(request.responseText);
+            console.log(request.responseText);
             var xparse = JSON.parse(request.responseText);
             ret = xparse.result;
           } else {
diff --git a/backoffice/tmpl/block/dlgdeleterow.tt b/backoffice/tmpl/block/dlgdeleterow.tt
index b3d5fb79..21e4b323 100644
--- a/backoffice/tmpl/block/dlgdeleterow.tt
+++ b/backoffice/tmpl/block/dlgdeleterow.tt
@@ -9,6 +9,7 @@
     
     
êtes vous sûre de vouloir supprimer la rangé sélectionné? + [% fieldhidden("dlgdelschema","delete",'','') %] [% fieldhidden("dlgdeltable","delete",'','') %] [% fieldhidden("dlgdelrowid","delete",'','') %]
@@ -21,13 +22,14 @@ diff --git a/backoffice/tmpl/module/workplans/workplans.js b/backoffice/tmpl/module/workplans/workplans.js new file mode 100644 index 00000000..78ea434a --- /dev/null +++ b/backoffice/tmpl/module/workplans/workplans.js @@ -0,0 +1,130 @@ +var workplans ={ + name:"workplans", + choices:{}, + tbl: null, + initform: function(){ + flatpickr(".timefield",{ + dateFormat: "H:i", + enableTime: true, + noCalendar: true, + time_24hr: true, + defaultHour: "0", + defaultMinute: "0", + "locale": "fr", + }); + var tfields = document.getElementsByClassName("timefield"); + for (var i=0;iSemaine",field: "weektotal",formatter: "html" }, + { title: "Lundi",field: "dspmontimes",formatter: "html" }, + { title: "Mardi",field: "dsptuetimes",formatter: "html" }, + { title: "Mercredi",field: "dspwedtimes",formatter: "html" }, + { title: "Jeudi",field: "dspthutimes",formatter: "html" }, + { title: "Vendredi",field: "dspfritimes",formatter: "html" }, + { title: "Samedi",field: "dspsattimes",formatter: "html" }, + { title: "Dimanche",field: "dspsuntimes",formatter: "html" } + ] + }); + workplans.gettbldata(); + workplans.initform(); + }, + gettbldata: function(){ + req.reqdata("POST", "db.cgi", {"get": workplans.name ,"schemata":schemata}, workplans.loadtbldata); + }, + loadtbldata: function(data){ + if (data && data.sqldata) { + workplans.tbl.setData(data.sqldata); + } + }, + edit: function() { + cleanform(workplans.name); + var udata = workplans.tbl.getSelectedData(); + if (udata[0]) { + var uid = udata[0].id; + req.reqdata("POST", "db.cgi", { + "get": workplans.name +"data","filter":"id=" + uid,"schemata":schemata + }, workplans.fillform); + module.viewpanel("frm_" + workplans.name); + } + + }, + add: function() { + cleanform('workplans'); + module.viewpanel('frm_' + workplans.name); + }, + remove: function() { + var udata = workplans.tbl.getSelectedData(); + if (udata[0]) { + showdeletedlg(workplans.name,udata[0].id,null,gettbldata_workplan,schemata); + } + }, + fillform: function(data){ + if (data && data.sqldata) { + console.log("fill Data"); + console.log(data.sqldata[0]); + fillformbydataclass2(workplans.name,{},data.sqldata[0]); + } + }, + save: function(){ + var wpdata = getformcontent(workplans.name); + var wpdatanew = {}; + for (var w in wpdata){ + if ((!w.endsWith("total")) && (!w.endsWith("interruption"))){ + wpdatanew[w] = wpdata[w]; + } + } + saveformdata(wpdatanew,null,schemata); + return false; + }, + checktime: function(id){ + + var pp = id.split("_"); + + var wday=pp[0]; + var strappend=''; + if (pp.length > 2){ + strappend = "_" + pp[2]; + } + console.log("timefield: " + wday +"=>" + id + " changed " + strappend); + var mt1 = 0; + var mt2 = 0; + var mtp = 0; + var irupt = 0; + if ((document.getElementById(wday + "_timeend1" + strappend).value != "") && (document.getElementById(wday + "_timestart1" + strappend).value != "")){ + mt1 = timecalc.TimeToMinutes(document.getElementById(wday + "_timeend1" + strappend).value)-timecalc.TimeToMinutes(document.getElementById(wday + "_timestart1" + strappend).value); + } + if ((document.getElementById(wday + "_timeend2" + strappend).value != "") && (document.getElementById(wday + "_timestart2" + strappend).value != "")){ + mt2 = timecalc.TimeToMinutes(document.getElementById(wday + "_timeend2" + strappend).value)-timecalc.TimeToMinutes(document.getElementById(wday + "_timestart2" + strappend).value); + } + if (document.getElementById(wday + "_timepause" + strappend).value != ""){ + mtp = timecalc.TimeToMinutes(document.getElementById(wday + "_timepause" + strappend).value); + } + if ((document.getElementById(wday + "_timeend1" + strappend).value != "") && (document.getElementById(wday + "_timestart2" + strappend).value != "")){ + irupt = timecalc.TimeToMinutes(document.getElementById(wday + "_timestart2" + strappend).value)-timecalc.TimeToMinutes(document.getElementById(wday + "_timeend1" + strappend).value); + document.getElementById(wday + "_interruption" + strappend).value= timecalc.MinutesToTime(irupt); + }else { + document.getElementById(wday + "_interruption" + strappend).value=""; + } + document.getElementById(wday + "_total" + strappend).value= timecalc.MinutesToTime(mt1+mt2-mtp); + var totaltester = /\d+:\d\d/; + var valcheck= document.getElementById(wday + "_total" + strappend).value; + if (valcheck && valcheck != ''){ + if ((valcheck == '00:00') || (!totaltester.test(valcheck))) { + document.getElementById(wday + "_total" + strappend).value =""; + } + } + + + }, + +} \ No newline at end of file diff --git a/backoffice/tmpl/skeleton/index.tt b/backoffice/tmpl/skeleton/index.tt index b303c767..4de108e6 100644 --- a/backoffice/tmpl/skeleton/index.tt +++ b/backoffice/tmpl/skeleton/index.tt @@ -1,15 +1,12 @@ [% PROCESS macro/fields.tt %] [% USE dksdb = DBI(dsn, dbuser, dbpassword) %] -[% appgaccess = dksdb.prepare("select ap.icon,ap.app,ap.name,ug.usergroup +[% appgaccess = dksdb.prepare("select ap.icon,ap.app,ap.name,string_agg(ug.usergroup,',') as usergroup from (SELECT users.id,json_array_elements_text(users.id_usergroups)::INT4 AS id_usergroup FROM users) uig -join apps ap on (uig.id_usergroup=ap.id_usergroup) -join usergroups ug on (uig.id_usergroup=ug.id) where uig.id=? -order by ap.sort;") %] -[% appsaccess = dksdb.prepare("select ap.icon,ap.app,ap.name,ug.usergroup -from (SELECT users.id,json_array_elements_text(users.id_usergroups)::INT4 AS id_usergroup FROM users) uig -join apps ap on (uig.id_usergroup=ap.id_usergroup) -join usergroups ug on (uig.id_usergroup=ug.id) where uig.id=? and ap.menutype = 'schema' +join (SELECT apps.id,apps.icon,apps.app,apps.name,apps.sort,json_array_elements_text(apps.id_usergroups)::INT4 as id_usergroup FROM apps) ap on (uig.id_usergroup=ap.id_usergroup) +join usergroups ug on (uig.id_usergroup=ug.id) where uig.id=? +group by ap.id,ap.icon,ap.name,ap.app,ap.sort order by ap.sort;") %] +