sharee.bike/copri4/main/src/Mod/Printpreview.pm

747 lines
25 KiB
Perl
Raw Normal View History

2021-12-30 12:05:56 +01:00
package Printpreview;
#
# SPDX-License-Identifier: AGPL-3.0-or-later
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
#
#
use strict;
use warnings;
use POSIX;
use CGI::Cookie ();
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use CGI ':standard';
use DateTime;
use DateTime::Format::Pg;
use Scalar::Util qw(looks_like_number);
use Lib::Config;
use Mod::Libenz;
use Mod::Libenzdb;
2022-07-08 07:32:42 +02:00
use Mod::DBtank;
2022-02-10 16:45:22 +01:00
use Mod::Pricing;
2021-12-30 12:05:56 +01:00
sub new {
my $class = shift;
my $self = {};
bless($self,$class);
return $self;
}
sub printpre(){
my $q = new CGI;
my $cf = new Config;
my $lb = new Libenz;
my $db = new Libenzdb;
2022-07-08 07:32:42 +02:00
my $dbt = new DBtank;
2022-02-10 16:45:22 +01:00
my $pri = new Pricing;
2021-12-30 12:05:56 +01:00
my %varenv = $cf->envonline();
my $path = $q->path_info();
my $script = $q->script_name();
my $user_agent = $q->user_agent();
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
my $lang="de";
my $printer_id=$R::printer_id;
my $u_id=$R::u_id;
my $c_id=$R::c_id4trans;
my $mandant_main_id=$R::mandant_main_id;
my $main_id=$R::main_id;
my $ct_name2print=$R::ct_name2print;
my $wc= $1 if($R::wc =~ /(\d+\.\d+)/);
my $node = $db->get_node4multi($R::main_id,$lang);
2022-02-01 20:53:23 +01:00
print $q->start_html(-title=>'',
2021-12-30 12:05:56 +01:00
-base=>'true',
-target=>'Printpre'
);
my $width="1400px";
if(1==1){
print "<style type='text/css'><!--
body,html {
background-color: white;
width: $width;
margin: 0px; padding: 0;
border: 0px solid black;
text-align: left;
font-family: Arial,sans-serif;
font-size:22px;
}
.Oline {
border-bottom-width:1px;
border-bottom-style:solid;
border-color:black;
margin:0.5em 0;
}
th {
border-bottom: solid thin gray;
}
td {
border:0px;
}
.tdtxt {
2022-05-01 18:31:03 +02:00
font-size:0.91em;
2021-12-30 12:05:56 +01:00
padding:0.1em 0.5em;
vertical-align: top;
text-align: left;
min-width:5em;
}
.tdtxt2 {
font-size:1em;
padding:0.1em 0.5em;
vertical-align: top;
text-align: left;
width:50%;
}
2022-03-02 14:16:30 +01:00
2021-12-30 12:05:56 +01:00
.tdsum {
font-size:1em;
padding:0.1em 0.5em;
vertical-align: top;
text-align: right;
}
.tdint {
2022-05-01 18:31:03 +02:00
font-size:0.91em;
2021-12-30 12:05:56 +01:00
padding:0.1em 0.5em;
vertical-align: top;
text-align: right;
min-width:20px;
}
.tdpdf1 {
font-size:1.2em;
padding:0.1em 0;
vertical-align: top;
text-align: left;
}
.tdpdf2 {
background-color:white;
padding:0.1em 1.2em 0 0;
vertical-align: top;
text-align: left;
font-size:0.85em;
}
.tdpdf3 {
padding:0.1em 0 0.3em 0;
vertical-align: top;
text-align: center;
font-size:1em;
}
.tdpdf4 {
padding:0.2em 0;
vertical-align: top;
text-align: left;
font-size:1em;
}
.tdpdf5 {
padding:0.2em 0;
vertical-align: top;
text-align: right;
font-size:1em;
}
//--></style>";
}
my $users = $db->select_users($u_id);
my $ctf = $db->get_content1("contentuser","$mandant_main_id");
$ctf->{txt13} = $1 if($ctf->{txt13} =~ /(\d+)/);
my $ctt = $db->get_content1("contenttrans",$c_id);
my $ctt_users = $db->get_owner($ctt->{owner});
my $vendor = $ctt_users->{u_name};#Login-ID
$vendor = $ctt->{txt13} if($ctt->{txt13});#full Name
my $kd_nr = " Kunden Nr.: $ctt->{int10}";
my $mandat_nr;
$mandat_nr = " Mandatsreferenz: $ctt->{txt26}" if($ctt->{txt26} =~ /PO-/);
my $invoice_time = $ctt->{invoice_time} || $ctt->{mtime};
my $mtime = $lb->time4de("$invoice_time","");
$db->updater("contenttrans","c_id",$ctt->{c_id},"invoice_time","$invoice_time","");
2022-02-10 16:45:22 +01:00
#my $scol = "c_id";
my $scol = "itime";
2021-12-30 12:05:56 +01:00
my $i=0;
my $tplf = $db->get_tpl("201");#Firma tpl
my @tplf_order = split /,/,$tplf->{tpl_order};
2022-02-01 20:53:23 +01:00
my $logo = "$ctf->{img01}" || "";
2021-12-30 12:05:56 +01:00
#logging siteformat
open(PMA, ">> $varenv{logdir}/Printpreview.log");
print PMA "$now_dt --> $ct_name2print\n";
my $site=1;
my $site_all=1;
my ($address_wc,$table_wc) = split(/\./,$wc);
$wc = $address_wc + $table_wc;
print PMA "wc: $wc = $address_wc + $table_wc\n";
print PMA "wc: $wc\n";
my $max_site_wc = "40";
2022-07-08 07:32:42 +02:00
my $max_table_wc = "10";
2021-12-30 12:05:56 +01:00
print PMA "max_site_wc: $max_site_wc | max_table_wc: $max_table_wc\n";
my $h_top = "0";
my $footer_top = "1820";#ende der 1.seite
print PMA "top: $h_top | $footer_top\n";
#1.seite
2022-07-08 07:32:42 +02:00
&header_big("0",$mandant_main_id,$c_id,$logo);
2021-12-30 12:05:56 +01:00
&data_invoice("0",$vendor,$kd_nr,$mandat_nr,$ctt->{txt00},$ct_name2print,$mtime);
2022-02-10 16:45:22 +01:00
my ($sum_paid,$break_table_wc,$nullcount) = &data_table("0",$c_id,$scol,"",$mandant_main_id,"0",$max_table_wc,$ctt);
2021-12-30 12:05:56 +01:00
#print "$site_all++ if(($wc > $max_site_wc) || ($table_wc > $max_table_wc)) --> $break_table_wc";
#$site_all++ if(($wc > $max_site_wc) || ($table_wc > $max_table_wc));
if($break_table_wc > $max_table_wc){
$site_all++;
print PMA "max_site_wc: $max_site_wc | max_table_wc: $max_table_wc\n";
print PMA "site_all: $site_all if($break_table_wc > $max_table_wc)\n";
}
print PMA "$site_all,$footer_top,$site,$site_all,$wc\n";
if($site_all == 1){
2022-02-10 16:45:22 +01:00
&text_description("0",$mandant_main_id,$ctt->{txt21},$ctt->{txt12},$ctt->{txt00},$nullcount);
2022-07-08 07:32:42 +02:00
&text_footer($mandant_main_id,$footer_top,$site,$site_all,$wc);
2021-12-30 12:05:56 +01:00
}else{
2022-07-08 07:32:42 +02:00
&text_footer($mandant_main_id,$footer_top,$site,$site_all,$wc);
2021-12-30 12:05:56 +01:00
}
#2.seite
if($site_all > 1){
#Alles horizontal absolut zum obersten Punkt ausrichten
2022-02-04 15:42:58 +01:00
$h_top = $footer_top + 220;# second header top, depence from footer_top
2021-12-30 12:05:56 +01:00
&header_small($h_top,$mandant_main_id,$logo);
$h_top +=250;
&data_invoice($h_top,$vendor,$kd_nr,$mandat_nr,$ctt->{txt00},$ct_name2print,$mtime);
$h_top +=60;
#table_break
if($break_table_wc >= $max_table_wc){
2022-02-10 16:45:22 +01:00
my ($sum_paid,$exit_table_wc,$nullcount) = &data_table($h_top,$c_id,$scol,"",$mandant_main_id,$break_table_wc,$max_table_wc,$ctt,$sum_paid);
2021-12-30 12:05:56 +01:00
$h_top += ($table_wc - $max_table_wc) * 65;
print PMA "h_top: $h_top += ($table_wc - $max_table_wc) * 65\n";
}
#print "$h_top | $table_wc | $break_table_wc >= $max_table_wc";
2022-02-10 16:45:22 +01:00
&text_description($h_top,$mandant_main_id,$ctt->{txt21},$ctt->{txt12},$ctt->{txt00},$nullcount);
2022-07-08 07:32:42 +02:00
$footer_top +=100;
2021-12-30 12:05:56 +01:00
$site++;
print PMA "$site_all,$footer_top,$site,$site_all,$wc\n";
2022-07-08 07:32:42 +02:00
&text_footer($mandant_main_id,$footer_top,$site,$site_all,$wc);
2021-12-30 12:05:56 +01:00
}
##########
#
close PMA;
#Briefkopf
sub header_small(){
my ($h_top,$mandant_main_id,$logo) = @_;
my $position;
my $h_toppx = "$h_top" . "px";
$position = "position:absolute; top: $h_toppx;" if($h_top);
2022-07-08 07:32:42 +02:00
my $height = "120px;";
my $margin = "0 0 200px 0;";
if($dbt->{operator}->{$varenv{dbname}}->{project} eq "Bayern"){
$height = "200px;";
$margin = "0;";
}
print $q->div({-style=>"$position width:$width;text-align:right;border:0px solid black;margin:$margin"},$q->img({-src=>"$varenv{metahost}/img/$logo",-height=>"$height"})),"\n";
2021-12-30 12:05:56 +01:00
}
#Briefkopf + Adresse
sub header_big(){
my ($h_top,$mandant_main_id,$c_id,$logo) = @_;
$ctf = $db->get_content1("contentuser","$mandant_main_id");
my $ctt = $db->get_content1("contenttrans",$c_id);
2022-07-08 07:32:42 +02:00
$ctt->{txt01} = $lb->newline($ctt->{txt01},"","0");
2021-12-30 12:05:56 +01:00
2022-07-08 07:32:42 +02:00
my $height = "120px;";
my $margin = "0 0 200px 0;";
if($dbt->{operator}->{$varenv{dbname}}->{project} eq "Bayern"){
$height = "200px;";
$margin = "0;";
}
print $q->div({-style=>"width:$width;text-align:right;border:0px solid black;margin:$margin"},$q->img({-src=>"$varenv{metahost}/img/$logo",-height=>"$height"})),"\n";
2021-12-30 12:05:56 +01:00
print $q->start_table({-width=>'100%',-border=>'0',-align=>'center', -cellpadding=>'3', -cellspacing=>'0'}),"\n";
print "<tr>\n";
2022-02-04 15:42:58 +01:00
print "<td style='border:0px solid black;vertical-align:top;width:60%;height:250px;padding:0 0 0 2em;'>\n";
2021-12-30 12:05:56 +01:00
print $q->start_table({-width=>'100%',-border=>'0',-align=>'left', -cellpadding=>'3', -cellspacing=>'0'}),"\n";
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf4', -style=>'padding-bottom:0.8em;text-decoration:underline;color:black;'}, "$ctf->{txt01} | $ctf->{txt02} | $ctf->{txt03}"),"\n";
2021-12-30 12:05:56 +01:00
#print $q->Tr();
2022-07-08 07:32:42 +02:00
#print $q->td({-class=>'tdpdf1'}, "$ctt->{txt02} &nbsp;"),"\n";
2021-12-30 12:05:56 +01:00
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf1'}, "$ctt->{txt01} &nbsp;"),"\n";
2021-12-30 12:05:56 +01:00
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf1'}, "$ctt->{txt03} &nbsp;"),"\n";
2021-12-30 12:05:56 +01:00
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf1'}, "$ctt->{txt06} &nbsp;"),"\n";
2021-12-30 12:05:56 +01:00
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-style=>'padding:0.8em 0;'}),"\n";
2021-12-30 12:05:56 +01:00
print $q->end_table;
print "</td>";
my $txid = "";
2022-02-01 20:53:23 +01:00
$txid = "Verwendungszweck TXID: $ctt->{txt16}" if($ctt->{txt16} && $ctt->{state} =~ /payone/i);
2021-12-30 12:05:56 +01:00
my $mailaccount = "";
$mailaccount = "Account: $ctt->{txt08}" if($ctt->{txt08});
2022-02-04 15:42:58 +01:00
my $invoice_period = "";
$invoice_period = "Leistungszeitraum: $ctt->{txt20}" if($ctt->{txt20});
2021-12-30 12:05:56 +01:00
2022-02-04 15:42:58 +01:00
print "<td style='width:40%;vertical-align:right;border:0px solid black;'>";
2021-12-30 12:05:56 +01:00
print $q->start_table({-border=>'0',-align=>'right', -cellpadding=>'0', -cellspacing=>'0'});
print $q->Tr();
print $q->td({-style=>'padding:2em 0;'},"&nbsp;"),"\n";
print $q->Tr();
print $q->td({-class=>'tdpdf5'}, "$txid"),"\n";
print $q->Tr();
print $q->td({-class=>'tdpdf5'}, "$mailaccount"),"\n";
print $q->Tr();
2022-02-04 15:42:58 +01:00
print $q->td({-class=>'tdpdf5'}, "$invoice_period"),"\n";
2021-12-30 12:05:56 +01:00
print $q->end_table;
print "</td>";
print "</tr>";
print $q->end_table;
}
#end Adresse
sub data_invoice(){
my ($h_top,$vendor,$kd_nr,$mandat_nr,$node_name,$ct_name2print,$mtime) = @_;
my $position;
my $h_toppx = "$h_top" . "px";
$position = "position:absolute; top: $h_toppx;" if($h_top);
$node_name =~ s/steuerfrei//;
2022-03-02 14:16:30 +01:00
my $praefix = "$varenv{praefix}";
2021-12-30 12:05:56 +01:00
print $q->div({-style=>"width:$width;$position border: 0px solid black;"},
$q->span({-style=>'font-size:1.5em;margin:0.5em 0 0.5em 0.5em;'},"$node_name"),
$q->span({-style=>'font-size:1em;margin:0.5em 0.5em 0.5em 0;'},"Nr.: $praefix-$ct_name2print"),
$q->span({-style=>'float:right;text-align:right;font-size:1em;margin:0.5em 0 0.5em 0;'},"Datum: $mtime&nbsp;"),
$q->span({-style=>'font-size:1em;margin:0.5em;'}," $kd_nr"),
$q->span({-style=>'font-size:1em;margin:0.5em;'}," $mandat_nr"),
#$q->span({-style=>'font-size:1.1em;margin:0.5em;'},$q->img({-src=>"$varenv{metahost}/pdf/barcode-$ctt->{ct_name}.jpeg", -height=>'60px;'})),
);
}
sub data_table(){
2022-02-10 16:45:22 +01:00
my ($h_top,$c_id,$scol,$ctt_dummy,$mandant_main_id,$break_table_wc,$max_table_wc,$ctt,$sum_break) = @_;
2021-12-30 12:05:56 +01:00
$ctf = $db->get_content1("contentuser","$mandant_main_id");
2022-02-10 16:45:22 +01:00
#my $umst1619 = $lb->umst_breaking($ctt,"");
2021-12-30 12:05:56 +01:00
2022-05-01 18:31:03 +02:00
my @tpl_order = ("txt01=Beschreibung","ct_name=Nummer","date_time=Mietzeit","int03=Menge (Std:Min)","int02=Preis","int07=Rabatt","int04=Gesamt");
2021-12-30 12:05:56 +01:00
my ($cttpos,$rows) = $db->collect_contentpos("contenttrans",$c_id);
2022-02-10 16:45:22 +01:00
foreach my $id (keys(%$cttpos)){
if($cttpos->{$id}->{int26}){
2022-05-01 18:31:03 +02:00
@tpl_order = ("txt01=Beschreibung","ct_name=Nummer","date_time=Mietzeit","int26=Einsparung","int03=Menge (Std:Min)","int02=Preis","int07=Rabatt","int04=Gesamt");
2022-02-10 16:45:22 +01:00
}
}
2021-12-30 12:05:56 +01:00
my $h_toppx = "$h_top" . "px";
my $position;
$position = "position:absolute; top: $h_toppx;" if($h_top);
print "\n<div style='width:$width;$position border:0px solid black;'>\n";
2022-03-02 14:16:30 +01:00
print $q->start_table({ -border=>'0', -width=>"$width",-align=>'center', -cellpadding=>'3', -cellspacing=>'0'}),"\n";
2021-12-30 12:05:56 +01:00
#Tableheader
my $h=0;
print $q->Tr(),"\n";
foreach (@tpl_order){
my ($key,$val) = split /=/,$_;
$h++ if($val && $key !~ /int07/);
print $q->th({-class=>'tdint'},"$val"),"\n" if("$key" eq "ct_name");
print $q->th({-class=>'tdtxt2'},"$val"),"\n" if($key =~ /txt01/);
2022-02-10 16:45:22 +01:00
print $q->th({-class=>'tdint'},"$val"),"\n" if($key =~ /int02|int03|int04|int26/);
2021-12-30 12:05:56 +01:00
}
$h--;
#Übertrag Zwischensumme
2022-07-08 07:32:42 +02:00
#if($break_table_wc){
# print "<tr>\n";
# print "<td colspan='2'></td>\n";
# print "<td colspan='3' style='font-size:1em;'>\n";
# print $q->start_table({-style=>'border:1px solid silver;', -border=>'0', -width=>'100%',-align=>'center', -cellpadding=>'3', -cellspacing=>'0'}),"\n";
#
# print $q->Tr("\n");
# print $q->td({-class=>'tdsum',-colspan=>"$h"},"<b>Übertrag:</b>");
# print $q->td({-class=>'tdint',-nowrap=>"1"},"<b>$sum_break €<b/>");
# print $q->end_table,"\n";
# print "</td>\n";
# print "</tr>\n";
#}
2021-12-30 12:05:56 +01:00
#Tablecontent (ct_name(primary key))
my $sum_parts19=0;
2022-05-01 18:31:03 +02:00
my $diff19 = 100 + 19;
my $sum_umst19=0;
2021-12-30 12:05:56 +01:00
my $j=0;
my $k=0;
my $nullcount=0;
2022-02-10 16:45:22 +01:00
#foreach my $id (sort { $cttpos->{$a}->{$scol} <=> $cttpos->{$b}->{$scol} } keys(%$cttpos)){
foreach my $id (sort { $cttpos->{$b}->{$scol} cmp $cttpos->{$a}->{$scol} } keys(%$cttpos)){
2021-12-30 12:05:56 +01:00
my $cttpos_timestamp = $1 . $2 . $3 . "0000" if($cttpos->{$id}->{itime} =~ /(\d+)\-(\d+)\-(\d+)/);
2022-02-16 15:56:45 +01:00
my $gesamt = 0;
my $rabatt = "";
2022-05-01 18:31:03 +02:00
my $pricing = {};
my $counting = {};
my $rental_feed = {};
if($cttpos->{$id}->{int35} && $cttpos->{$id}->{start_time} && $cttpos->{$id}->{end_time}){
($pricing,$counting) = $pri->counting_rental(\%varenv,$cttpos->{$id},"calc_price");
$rental_feed = $pri->fetch_rentalfeed(\%varenv,$cttpos->{$id},$counting);
$rabatt = $pricing->{discount};
$sum_parts19 += $pricing->{total_price};
$gesamt = $pri->round($pricing->{total_price});
$gesamt = sprintf('%.2f', $gesamt);
}else{
($gesamt,$rabatt) = $pri->price2calc($cttpos->{$id});
$sum_parts19 += $gesamt;
$gesamt = $pri->round($gesamt);
$gesamt = sprintf('%.2f', $gesamt);
}
2021-12-30 12:05:56 +01:00
2022-02-16 15:56:45 +01:00
if($gesamt == 0){
2021-12-30 12:05:56 +01:00
$nullcount++;
}
2022-02-16 15:56:45 +01:00
if($gesamt != 0){
2021-12-30 12:05:56 +01:00
$j++;
if($j<=$max_table_wc || $break_table_wc){
#2. empty loop for sum
if($break_table_wc){
#print "$j|";
next if($j<=$max_table_wc);
}
#Tablecontent (parameter)
print $q->Tr(),"\n";
my $k=0;
foreach (@tpl_order){
#$k++;
my ($key,$val) = split /=/,$_;
$cttpos->{$id}->{$key} = $q->unescapeHTML("$cttpos->{$id}->{$key}");
$cttpos->{$id}->{$key} = $lb->newline($cttpos->{$id}->{$key},"");
if("$key" eq "ct_name"){
my $ct_pos = "";
if($cttpos->{$id}->{int09}){#if Tarif defined
2022-05-24 10:46:05 +02:00
$ct_pos = "Mietrad: $cttpos->{$id}->{ct_name}";
$ct_pos .= "<br />Endstation: $cttpos->{$id}->{txt13}$cttpos->{$id}->{int04}" if($cttpos->{$id}->{int04});
2021-12-30 12:05:56 +01:00
}else{
$ct_pos = "$cttpos->{$id}->{ct_name}";
}
2022-02-16 15:56:45 +01:00
print $q->td({-class=>'tdint',-nowrap=>'1'},"$ct_pos&nbsp;"),"\n";
2021-12-30 12:05:56 +01:00
}
if($key =~ /txt01/){
2022-03-02 14:16:30 +01:00
print "<td class='tdtxt'>\n";
2021-12-30 12:05:56 +01:00
if($cttpos->{$id}->{$key}){
2022-05-01 18:31:03 +02:00
$cttpos->{$id}->{$key} =~ s/\<br \/\>/, &nbsp; /g;
my $tariff = "";
$tariff = "<br />Tarif: $cttpos->{$id}->{int09} $cttpos->{$id}->{txt04}" if($cttpos->{$id}->{txt04});
print "$cttpos->{$id}->{$key} $tariff<br />\n";
2021-12-30 12:05:56 +01:00
}
2022-02-10 16:45:22 +01:00
if($cttpos->{$id}->{start_time} && $cttpos->{$id}->{end_time}){
2021-12-30 12:05:56 +01:00
#print "<br />\n";
2022-02-10 16:45:22 +01:00
$cttpos->{$id}->{start_time} = $lb->time4de($cttpos->{$id}->{start_time},"1");
$cttpos->{$id}->{end_time} = $lb->time4de($cttpos->{$id}->{end_time},"1");
2022-05-01 18:31:03 +02:00
print $q->span("$cttpos->{$id}->{start_time} $cttpos->{$id}->{end_time}"),"\n";
2021-12-30 12:05:56 +01:00
}
print "</td>\n";
}
2022-02-10 16:45:22 +01:00
if($key eq "int26"){
my $co2saving = "";
if($cttpos->{$id}->{int26}){
$co2saving = "Einsparung</br>";
my $co2diff = $pri->co2calc($cttpos->{$id});
my $sprit_price = $pri->sprit2calc($cttpos->{$id});
$co2saving .= "$co2diff kg CO&sup2;<br />";
2022-06-30 16:35:02 +02:00
$co2saving .= "$sprit_price EUR<br />" if($sprit_price !~ /-/);
2022-02-10 16:45:22 +01:00
$cttpos->{$id}->{int26} =~ s/\./,/;
$co2saving .= "bei $cttpos->{$id}->{int26} KM";
}
2022-02-16 15:56:45 +01:00
print $q->td({-class=>'tdint',-nowrap=>'1'},"$co2saving");
2022-02-10 16:45:22 +01:00
}
2021-12-30 12:05:56 +01:00
if($key =~ /int03/){
2022-05-01 18:31:03 +02:00
if($cttpos->{$id}->{int35} && $cttpos->{$id}->{start_time} && $cttpos->{$id}->{end_time}){
print $q->td({-class=>'tdint',-nowrap=>1},"$pricing->{real_clock} $pricing->{freed_time}"),"\n";
}else{
$cttpos->{$id}->{$key} =~ s/\./,/;
print $q->td({-class=>'tdint'},"$cttpos->{$id}->{$key}"),"\n";
}
2021-12-30 12:05:56 +01:00
}
2022-05-01 18:31:03 +02:00
if($key =~ /int02/){
if($cttpos->{$id}->{int35} && $cttpos->{$id}->{start_time} && $cttpos->{$id}->{end_time}){
print "<td class='tdint' nowrap>\n";
2022-05-04 17:50:14 +02:00
foreach my $fid (sort keys(%{ $rental_feed->{rental_description}->{tarif_elements} })){
if(ref($rental_feed->{rental_description}->{tarif_elements}->{$fid}) eq "ARRAY"){
print "$rental_feed->{rental_description}->{tarif_elements}->{$fid}[0]: $rental_feed->{rental_description}->{tarif_elements}->{$fid}[1]<br />\n";
2022-05-01 18:31:03 +02:00
}
}
print "</td>\n";
2021-12-30 12:05:56 +01:00
}else{
2022-05-01 18:31:03 +02:00
$cttpos->{$id}->{$key} =~ s/\./,/;
print $q->td({-class=>'tdint',-nowrap=>1},"$cttpos->{$id}->{$key} €"),"\n";
}
}
2021-12-30 12:05:56 +01:00
2022-05-01 18:31:03 +02:00
if($key =~ /int04/){
$gesamt =~ s/\./,/;
2022-02-10 16:45:22 +01:00
if($rabatt != 0){
2022-05-01 18:31:03 +02:00
$rabatt =~ s/\./,/;
print $q->td({-nowrap=>'1',-class=>'tdint'},"$rabatt $gesamt €"),"\n";
2021-12-30 12:05:56 +01:00
}else{
2022-05-01 18:31:03 +02:00
print $q->td({-nowrap=>'1',-class=>'tdint'},"$gesamt €"),"\n";
2021-12-30 12:05:56 +01:00
}
}
}
}
}
}#end foreach
#Zahlungstext Text & Vorbelegungen
2022-02-01 20:53:23 +01:00
my $payment_text = "";
2021-12-30 12:05:56 +01:00
foreach(@tplf_order){
my ($key,$des,$size) = split /=/,$_;
2022-02-01 20:53:23 +01:00
if($key =~ /txt5\d/){
2021-12-30 12:05:56 +01:00
$ctf->{$key} = $q->unescapeHTML("$ctf->{$key}");
2022-02-01 20:53:23 +01:00
$ctf->{$key} = $lb->newline($ctf->{$key},"","");
2021-12-30 12:05:56 +01:00
$ctt->{state} =~ s/\(payone.*//;
2022-02-01 20:53:23 +01:00
if($des =~ /$ctt->{state}/ && ($j <= $max_table_wc || $break_table_wc)){
2021-12-30 12:05:56 +01:00
if($sum_parts19 < 0){
$payment_text = "$ctf->{txt58}";
}else{
$payment_text = "$ctf->{$key}";
}
}
}
}
2022-05-01 18:31:03 +02:00
if($sum_parts19 && $sum_parts19 != 0){
$sum_umst19 = $sum_parts19 / $diff19 * 19;
$sum_umst19 = $pri->round($sum_umst19);
}
2021-12-30 12:05:56 +01:00
my $sum_netto19 = $sum_parts19 - $sum_umst19;
2022-05-01 18:31:03 +02:00
$sum_netto19 = sprintf('%.2f', $sum_netto19);
$sum_netto19 =~ s/\./,/;
2022-02-10 16:45:22 +01:00
my $sum_paid = $sum_parts19;
2022-05-01 18:31:03 +02:00
$sum_paid = $pri->round($sum_paid);
my $sum_preauth = $sum_paid || 0;
$sum_paid = sprintf('%.2f', $sum_paid);
$sum_paid =~ s/\./,/;
$sum_parts19 = sprintf('%.2f', $sum_parts19);
$sum_umst19 = sprintf('%.2f', $sum_umst19);
$sum_umst19 =~ s/\./,/;
2021-12-30 12:05:56 +01:00
print $q->Tr(),"\n";
2022-02-10 16:45:22 +01:00
print $q->td({-class=>'Oline',-colspan=>6},"&nbsp;"),"\n";
2021-12-30 12:05:56 +01:00
print "<tr>\n";
2022-02-10 16:45:22 +01:00
print "<td colspan='3' style='border:0px solid silver;vertical-align:top;padding:0.2em 0.5em;font-size:1em;'>$payment_text</td>\n";
2021-12-30 12:05:56 +01:00
print "<td colspan='3' style='font-size:1em;'>\n";
print $q->start_table({-style=>'border:1px solid silver;', -border=>'0', -width=>'100%',-align=>'center', -cellpadding=>'3', -cellspacing=>'0'}),"\n";
#Summe Endrechnung
if($j <= $max_table_wc || $break_table_wc){
print $q->Tr(),"\n";
print $q->td({-class=>'tdint'},"<b>Summe:</b>"),"\n";
print $q->td({-class=>'tdint',-nowrap=>"1"},"<b>$sum_paid €<b/>"),"\n";
print $q->Tr(),"\n";
print $q->td({-class=>'tdint'},"Betrag Netto:"),"\n";
2022-05-01 18:31:03 +02:00
print $q->td({-class=>'tdint',-nowrap=>"1"},"$sum_netto19 €"),"\n";
2021-12-30 12:05:56 +01:00
if($sum_parts19 != "0"){
print $q->Tr();
2022-02-10 16:45:22 +01:00
print $q->td({-class=>'tdint',-nowrap=>"1"},"19% UmSt auf $sum_netto19 €:"),"\n";
2021-12-30 12:05:56 +01:00
print $q->td({-class=>'tdint',-nowrap=>"1"},"$sum_umst19 €"),"\n";
}
#Zwischensumme
2022-07-08 07:32:42 +02:00
#}else{
# print $q->Tr(),"\n";
# print $q->td({-class=>'tdsum',-colspan=>"$h"},"<b>Zwischensumme:</b>"),"\n";
# print $q->td({-class=>'tdint',-nowrap=>"1"},"<b>$sum_paid €</b>"),"\n";
2021-12-30 12:05:56 +01:00
}
print $q->end_table,"\n";
print "</td>\n";
print "</tr>\n";
print $q->end_table,"\n";
print "</div>\n";
return ("$sum_paid","$j","$nullcount");
}
#Beschreibungs-Text
sub text_description(){
2022-02-10 16:45:22 +01:00
my ($h_top,$mandant_main_id,$ctt_txt21,$ctt_txt12,$node_name,$nullcount) = @_;
2021-12-30 12:05:56 +01:00
my $ctf = $db->get_content1("contentuser","$mandant_main_id");
my $position;
my $h_toppx = "$h_top" . "px";
$position = "position:absolute; top: $h_toppx;" if($h_top);
print "\n<div style='width:$width;$position border:0px solid black;'>\n";
print $q->start_table({-style=>"margin-top:0.5em;", -border=>'0', -width=>'100%',-align=>'center', -cellpadding=>'0', -cellspacing=>'0'});
#Frei-Text
my $style = "padding:0.4em;text-align:left;font-size:1em;";
if($nullcount > 0){
print $q->Tr();
print $q->td({-style=>"$style",-colspan=>3},"In diesem Zeitraum gab es $nullcount kostenfreie Buchungsvorgänge.");
}
if($ctt_txt12){
$ctt_txt12 = $q->unescapeHTML("$ctt_txt12");
2022-07-08 07:32:42 +02:00
$ctt_txt12 = $lb->newline($ctt_txt12,"","");
2021-12-30 12:05:56 +01:00
print $q->Tr();
print $q->td({-style=>"$style",-colspan=>3},"$ctt_txt12");
}
#Text & Vorbelegungen
print $q->Tr();
foreach(@tplf_order){
my ($key,$des,$size) = split /=/,$_;
if($key =~ /txt6/){
$ctf->{$key} = $q->unescapeHTML("$ctf->{$key}");
2022-07-08 07:32:42 +02:00
$ctf->{$key} = $lb->newline($ctf->{$key},"","");
2021-12-30 12:05:56 +01:00
my @rechnungstext = split(/\<br \/\>/,$ctf->{$key});
if($ctt_txt21 =~ /$key/){
foreach(@rechnungstext){
$style = "padding:0.4em;text-align:left;font-size:1em;";
$style = "padding:0.4em;text-align:left;font-size:1em;" if($_ =~ s/\<b\>// && $node_name ne "Rückgabe");
print $q->Tr();
print $q->td({-style=>"$style",-colspan=>3},"$_");
}
}
}
}
print $q->end_table;
print "</div>\n";
}
sub text_footer(){
2022-07-08 07:32:42 +02:00
my ($mandant_main_id,$top,$site,$site_all,$wc) = @_;
2021-12-30 12:05:56 +01:00
my $ctf = $db->get_content1("contentuser","$mandant_main_id");
$ctf->{txt01} = $q->unescapeHTML("$ctf->{txt01}");
2022-07-05 11:44:00 +02:00
my @txt11 = split (/;/,"$ctf->{txt11}");#Tel usw.
my @txt12 = split (/;/,"$ctf->{txt12}");#Geschäftsführer
2022-07-08 07:32:42 +02:00
my @txt19 = split (/;/,"$ctf->{txt19}");#Bank usw.
2021-12-30 12:05:56 +01:00
$top *= $site;
my $top2 = $top + 120;
$top .= "px";
$top2 .= "px";
my $zeilen;
#$zeilen = "Top: $top , Zeilen: $wc , " if($wc);
#if($logo =~ /empty/){
# print $q->div({-style=>"min-width:1799px;position:absolute;top:$top;"},"");
#}else{
print "<div style='border:0px solid black;background-color:white;height:150px;width:$width;position:absolute;top:$top;'>";
print $q->start_table({-width=>'100%',-border=>'0',-align=>'center', -cellpadding=>'2', -cellspacing=>'0'});
print "<tr>";
print "<td style='width:25%;'>";
print $q->start_table({-border=>'0',-align=>'left'});
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf2'}, "$txt12[0]"),"\n";
2021-12-30 12:05:56 +01:00
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf2'}, "$txt12[1]"),"\n";
2021-12-30 12:05:56 +01:00
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf2'}, "$txt12[2]"),"\n";
2021-12-30 12:05:56 +01:00
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf2'}, "$txt12[3]"),"\n";
2021-12-30 12:05:56 +01:00
print $q->end_table;
print "</td>";
print "<td style='width:25%;'>";
print $q->start_table({-border=>'0',-align=>'left'});
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf2'}, "TEL: $ctf->{txt08}"),"\n";
2021-12-30 12:05:56 +01:00
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf2'}, "$ctf->{txt10}"),"\n";
2021-12-30 12:05:56 +01:00
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf2'}, "$txt11[0]"),"\n";
2021-12-30 12:05:56 +01:00
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf2'}, "$txt11[1]"),"\n";
2021-12-30 12:05:56 +01:00
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf2'}, "$txt11[2]"),"\n";
2021-12-30 12:05:56 +01:00
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf2'}, "$txt11[3]"),"\n";
2021-12-30 12:05:56 +01:00
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf2'}, "$txt11[4]"),"\n";
2021-12-30 12:05:56 +01:00
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf2'}, "$txt11[5]"),"\n";
2021-12-30 12:05:56 +01:00
print $q->end_table;
print "</td>";
print "<td style='width:25%'>";
print $q->start_table({-border=>'0',-align=>'left'});
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf2'}, "$txt19[0]"),"\n";
2021-12-30 12:05:56 +01:00
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf2'}, "$txt19[1]"),"\n";
2021-12-30 12:05:56 +01:00
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf2'}, "$txt19[2]"),"\n";
2021-12-30 12:05:56 +01:00
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf2'}, "$txt19[3]"),"\n";
2021-12-30 12:05:56 +01:00
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf2'}, "$txt19[4]"),"\n";
2021-12-30 12:05:56 +01:00
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf2'}, "$txt19[5]"),"\n";
2021-12-30 12:05:56 +01:00
print $q->end_table;
print "</td>";
print "<td style='width:25%;'>";
print $q->start_table({-width=>'100%',-border=>'0',-align=>'left'});
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf2'}, "$txt19[6]"),"\n";
2021-12-30 12:05:56 +01:00
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf2'}, "$txt19[7]"),"\n";
2021-12-30 12:05:56 +01:00
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf2'}, "$txt19[8]"),"\n";
2021-12-30 12:05:56 +01:00
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf2'}, "$txt19[9]"),"\n";
2021-12-30 12:05:56 +01:00
print $q->Tr();
2022-07-08 07:32:42 +02:00
print $q->td({-class=>'tdpdf2'}, "$txt19[10]"),"\n";
2021-12-30 12:05:56 +01:00
print $q->end_table;
print "</td>";
print "</tr>";
print $q->end_table;
print "</div>";
#end Adresse
#}
my $debug = "";
#$debug = "(address_wc:$address_wc + table_wc:$table_wc) site_all:$site_all++ | break_table_wc:$break_table_wc if((wc:$wc > max_site_wc:$max_site_wc) || (table_wc:$table_wc > max_table_wc:$max_table_wc)) ... (sum_paid:$sum_paid,break_table_wc:$break_table_wc) = &data_table" if($ctt->{owner} eq "101");
print $q->div({-style=>"text-align:right;width:$width;position:absolute;top:$top2;font-size:0.61em;"},"$debug $zeilen Seite: $site/$site_all");
}
print $q->end_html;
return Apache2::Const::OK;
}
1;