sharee.bike/copri4/main/src/Mod/Printpreview.pm
2022-01-09 18:31:20 +01:00

825 lines
29 KiB
Perl
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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::Buttons;
use Mod::Libenz;
use Mod::Libenzdb;
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;
my $but = new Buttons;
my %varenv = $cf->envonline();
my $path = $q->path_info();
my $script = $q->script_name();
my $user_agent = $q->user_agent();
my %ib = $but->ibuttons();
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);
#print "$u_id,$c_id,$mandant_main_id,$main_id,$ct_name2print,$wc";
print $q->start_html(-title=>'COPRIprint',
-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 {
background-color: silver;
border-bottom: solid thin gray;
}
td {
border:0px;
}
.tdtxt {
font-size:1em;
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%;
}
.tdsum {
font-size:1em;
padding:0.1em 0.5em;
vertical-align: top;
text-align: right;
}
.tdint {
font-size:1em;
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 $tpl = $db->get_tpl($ctf->{txt34});#Verkauf template
$tpl = $db->get_tpl($ctf->{txt36}) if($users->{kind_of_trans} =~ /Faktur/);
my $ctt = $db->get_content1("contenttrans",$c_id);
#payone Bank
my $footer_bank = $ctf->{txt19};
#sparkasse Bank
$footer_bank = $ctf->{txt20} if($ctt->{state} !~ /payone/i);
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","");
#
my $scol = "c_id";
#$scol = "$users->{cash_sort}" if($users->{cash_sort});
my $i=0;
my $tplf = $db->get_tpl("201");#Firma tpl
my @tplf_order = split /,/,$tplf->{tpl_order};
my $logo = "$ctf->{img01}" || "000empty";
if($printer_id =~ /Briefpapier/){
#Ohne Logo da Briefpapier
$logo = "000empty";
}
#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";
$wc += 3 if($ctt->{txt00} !~ /Lieferschein/);#Netto+UmSt+Summe Zeilen
print PMA "wc: $wc\n";
my $max_site_wc = "40";
my $max_table_wc = "14";
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
&header_small("0",$mandant_main_id,$logo) if("$ctt->{txt00}" =~ /Quittung/);
&header_big("0",$mandant_main_id,$c_id,$logo) if("$ctt->{txt00}" !~ /Quittung/);
&data_invoice("0",$vendor,$kd_nr,$mandat_nr,$ctt->{txt00},$ct_name2print,$mtime);
#table
my ($sum_paid,$break_table_wc,$nullcount) = &data_table("0",$c_id,$scol,"",$mandant_main_id,$users->{kind_of_trans},$tpl->{tpl_order},"0",$max_table_wc,$ctt);
#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){
&text_description("0",$mandant_main_id,$ctt->{txt21},$ctt->{txt12},$users->{kind_of_trans},$ctt->{txt00},$nullcount);
&text_footer($mandant_main_id,$footer_top,$site,$site_all,$wc,$footer_bank,$logo);
}else{
&text_footer($mandant_main_id,$footer_top,$site,$site_all,$wc,$footer_bank,$logo);
}
#2.seite
if($site_all > 1){
#Alles horizontal absolut zum obersten Punkt ausrichten
$h_top = $footer_top + 270;# second header top, depence from footer_top
&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){
my ($sum_paid,$exit_table_wc,$nullcount) = &data_table($h_top,$c_id,$scol,"",$mandant_main_id,$users->{kind_of_trans},$tpl->{tpl_order},$break_table_wc,$max_table_wc,$ctt,$sum_paid);
$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";
&text_description($h_top,$mandant_main_id,$ctt->{txt21},$ctt->{txt12},$users->{kind_of_trans},$ctt->{txt00},$nullcount);
$footer_top +=130;
$site++;
print PMA "$site_all,$footer_top,$site,$site_all,$wc\n";
&text_footer($mandant_main_id,$footer_top,$site,$site_all,$wc,$footer_bank,$logo);
}
##########
#
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);
print $q->div({-style=>"$position width:$width;text-align:right;border:0px solid black;margin:0 0 200px 0;"},$q->span({-style=>'margin:0em;'},$q->img({-src=>"$varenv{metahost}/img/$logo",-height=>'120px;'})),$q->span({-style=>'font-size:1em;'},"\n"));
}
#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);
$ctt->{txt01} = $lb->newline($ctt->{txt01},$users->{tiny_mce},"0");
print $q->div({-style=>"width:$width; text-align:right;border:0px solid black;margin:0 0 200px 0;"},$q->span({-style=>'margin:0em;'},$q->img({-src=>"$varenv{metahost}/img/$logo",-height=>'120px;'})),$q->span({-style=>'font-size:1em;'},"")),"\n";
print $q->start_table({-width=>'100%',-border=>'0',-align=>'center', -cellpadding=>'3', -cellspacing=>'0'}),"\n";
print "<tr>\n";
print "<td style='border:0px solid black;vertical-align:top;width:65%;height:250px;padding:0 0 0 2em;'>\n";
print $q->start_table({-width=>'100%',-border=>'0',-align=>'left', -cellpadding=>'3', -cellspacing=>'0'}),"\n";
print $q->Tr();
print $q->td({-class=>'tdpdf4', -style=>'padding-bottom:0.8em;text-decoration:underline;color:black;'}, "$ctf->{txt01} | $ctf->{txt02} | $ctf->{txt03}","\n");
#print $q->Tr();
#print $q->td({-class=>'tdpdf1'}, "$ctt->{txt02} &nbsp;","\n");
print $q->Tr();
print $q->td({-class=>'tdpdf1'}, "$ctt->{txt01} &nbsp;","\n");
print $q->Tr();
print $q->td({-class=>'tdpdf1'}, "$ctt->{txt03} &nbsp;","\n");
print $q->Tr();
print $q->td({-class=>'tdpdf1'}, "$ctt->{txt06} &nbsp;","\n");
print $q->Tr();
print $q->td({-style=>'padding:0.8em 0;'},"\n");
print $q->end_table;
print "</td>";
my $txid = "";
$txid = "TXID: $ctt->{txt16}" if($ctt->{txt16} && $ctt->{state} =~ /payone/i);
my $mailaccount = "";
$mailaccount = "Account: $ctt->{txt08}" if($ctt->{txt08});
print "<td style='width:35%;vertical-align:right;border:0px solid black;'>";
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();
print $q->td({-class=>'tdpdf5'}, "Leistungsdatum: $ctt->{txt20}"),"\n";
print $q->end_table;
print "</td>";
print "</tr>";
print $q->end_table;
#print $q->div({-style=>"text-align:right;width:$width;font-size:1em;"},"Login: $ctt->{txt08}&nbsp;"),"\n";
#print $q->div({-style=>"text-align:right;width:$width;font-size:1em;"},"Leistungsdatum: $ctt->{txt20}&nbsp;"),"\n" if($ctt->{txt20});
}
#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//;
my $praefix = "";
$praefix = "konrad-TINK" if($varenv{wwwhost} =~ /tink/);
$praefix = "$varenv{praefix}" if($varenv{syshost} =~ /sharee/);
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(){
my ($h_top,$c_id,$scol,$ctt_dummy,$mandant_main_id,$kind_of_trans,$tpl_order,$break_table_wc,$max_table_wc,$ctt,$sum_break) = @_;
#print "($h_top,$c_id,$scol,$ctt_dummy,$mandant_main_id,$kind_of_trans,$tpl_order,$break_table_wc,$max_table_wc)";
$ctf = $db->get_content1("contentuser","$mandant_main_id");
my $umst1619 = $lb->umst_breaking($ctt,"");
my $txt20 = $ctt->{txt20};
my $max_timestamp = "210001012359";
if($node->{node_name} !~ /journal/){
if($txt20 =~ /(\d{2})\.(\d{2})\.(\d{4})$/){
$max_timestamp = $3 . $2 . $1 . "2359";
}elsif($ctf->{txt80} =~ /(\d{2})\.(\d{2})\.(\d{4})$/){
$max_timestamp = $3 . $2 . $1 . "2359";
}
}
my $max_sum = $ctf->{int03} || "10000";
my ($cttpos,$rows) = $db->collect_contentpos("contenttrans",$c_id);
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";
print $q->start_table({ -border=>'0', -width=>'100%',-align=>'center', -cellpadding=>'3', -cellspacing=>'0'}),"\n";
my @tpl_order = split /,/,$tpl_order;
#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/);
print $q->th({-class=>'tdint'},"$val"),"\n" if($key =~ /int03/);
if($ctt->{txt00} =~ /Lieferschein/){
print $q->th(""),"\n" if($key =~ /int02|int03/);
}else{
print $q->th({-class=>'tdint'},"$val"),"\n" if($key =~ /int02/);
print $q->th({-class=>'tdint'},"$val"),"\n" if($key =~ /int04/);
}
}
$h--;
#Übertrag Zwischensumme
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";
}
#Tablecontent (ct_name(primary key))
my $sum_parts0=0;
my $sum_parts7=0;
my $sum_parts19=0;
my $j=0;
my $k=0;
my $nullcount=0;
foreach my $id (sort { $cttpos->{$a}->{$scol} <=> $cttpos->{$b}->{$scol} } keys(%$cttpos)){
my $cttpos_timestamp = $1 . $2 . $3 . "0000" if($cttpos->{$id}->{itime} =~ /(\d+)\-(\d+)\-(\d+)/);
#$k++;
my $menge="0";my $gesamt="0";my $kaution="0";my $gesamt_kaution="0";
my $timeing="0";my $times;my $rent_time;my $start_time;my $end_time;
#Mietzeit wenn Verleihräder
if($kind_of_trans =~ /Faktur|Verleih/ && $cttpos->{$id}->{int12} =~ /$ctf->{txt29}/){
$timeing="1";
$times = $db->get_time4ct("contenttranspos",$cttpos->{$id}->{c_id});
$start_time = $lb->time4de($times->{start_time},"1");
$end_time = $lb->time4de($times->{end_time},"1");
}
my $einzel = $cttpos->{$id}->{int02};
my $menge = $cttpos->{$id}->{int03} || 0;
my $unit = $cttpos->{$id}->{txt03};
#start copri pricing on 2018-03-21
my $dt1 = DateTime->new(year => 2018, month => 3, day => 20);
my $dt0 = $dt1;
my $dt2 = $dt1;
$dt0 = DateTime::Format::Pg->parse_datetime($cttpos->{$id}->{start_time}) if($cttpos->{$id}->{start_time});
$dt2 = DateTime::Format::Pg->parse_datetime($cttpos->{$id}->{end_time}) if($cttpos->{$id}->{end_time});
if(looks_like_number($einzel) && $einzel != 0 && looks_like_number($menge) && $menge != 0){
$gesamt = $einzel * $menge;
}
#max. Rechnungspositionen
if(($gesamt == 0) && ($cttpos_timestamp <= $max_timestamp || $ctt->{int05} == 1) && ($sum_parts19 <= $max_sum)){
$nullcount++;
}
#print "if(($gesamt != 0) && ($cttpos_timestamp <= $max_timestamp || $ctt->{int05} == 1) && ($sum_parts19 <= $max_sum)){";
if(($gesamt != 0) && ($cttpos_timestamp <= $max_timestamp || $ctt->{int05} == 1) && ($sum_parts19 <= $max_sum)){
$j++;
if($j<=$max_table_wc || $break_table_wc){
my $rabatt_val = $cttpos->{$id}->{int07} || "";
if($rabatt_val != 0 && looks_like_number($einzel) && $einzel != 0 && looks_like_number($menge) && $menge != 0){
my $rabatt_eur = $rabatt_val;
$rabatt_eur = $einzel * $menge * $rabatt_val/100 if($cttpos->{$id}->{int08} != 1);#wenn int08 != 1 alias €
$gesamt = $einzel * $menge - $rabatt_eur;
}
$gesamt = $lb->round($gesamt);
$gesamt = $lb->cashme($gesamt);
#summieren
if("$cttpos->{$id}->{int05}" =~ /\d/){
#print "xxx $gesamt $cttpos->{$id}->{int05} |";
$sum_parts0 += $gesamt if("$cttpos->{$id}->{int05}" == "0");
$sum_parts7 += $gesamt if("$cttpos->{$id}->{int05}" == "7");
$sum_parts19 += $gesamt if("$cttpos->{$id}->{int05}" >= "16");
}else{
#print "yyy $gesamt $ctf->{txt13} |";
$sum_parts0 += $gesamt if("$ctf->{txt13}" == "0");
$sum_parts7 += $gesamt if("$ctf->{txt13}" == "7");
$sum_parts19 += $gesamt if($ctf->{txt13} >= 16);
}
#2. empty loop for sum
if($break_table_wc){
#print "$j|";
next if($j<=$max_table_wc);
}
my ($s_date,$s_dd,$s_mo,$s_yy,$s_hh,$s_mi,$e_date,$e_yy,$e_mo,$e_dd,$e_hh,$e_mi,$times_id);
#Make date and time
if($cttpos->{$id}->{start_time} && $cttpos->{$id}->{end_time}){
($s_yy,$s_mo,$s_dd,$s_hh,$s_mi) = $lb->split_date($cttpos->{$id}->{start_time});
($e_yy,$e_mo,$e_dd,$e_hh,$e_mi) = $lb->split_date($cttpos->{$id}->{end_time});
}
#Tablecontent (parameter)
print $q->Tr(),"\n";
my $k=0;
foreach (@tpl_order){
#$k++;
my ($key,$val) = split /=/,$_;
#if($cttpos->{$id}->{sort} =~ /^\d+$/){
# $txtstyle = "border-bottom-width:1px;border-bottom-style:dotted;border-bottom-color:silver;";
#}
$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
$ct_pos = "Endstation: $cttpos->{$id}->{int04} &nbsp;" if($cttpos->{$id}->{int04});
$ct_pos .= "Rad: $cttpos->{$id}->{ct_name}";
}else{
$ct_pos = "$cttpos->{$id}->{ct_name}";
}
print $q->td({-class=>'tdint'},"$ct_pos&nbsp;"),"\n";
}
if($key =~ /txt01/){
print "<td class='tdtxt'>\n";
if($cttpos->{$id}->{$key}){
$cttpos->{$id}->{$key} =~ s/\<br \/\>/; &nbsp; /g;
print "$cttpos->{$id}->{$key}<br />\n";
}
#if($cttpos->{$id}->{int04}){
# print $q->span("Station: $cttpos->{$id}->{int04}"),"\n";
#}
#if($cttpos->{$id}->{txt06}){
# print $q->span(" (GPS: $cttpos->{$id}->{txt06})"),"\n";
#}
if($cttpos->{$id}->{start_time}){
#print "<br />\n";
print $q->span("Mietzeit: $s_dd.$s_mo.$s_yy $s_hh:$s_mi $e_dd.$e_mo.$e_yy $e_hh:$e_mi"),"\n";
}
print "</td>\n";
}
if($key =~ /int03/){
$menge =~ s/\./,/;
print $q->td({-class=>'tdint'},"$menge"),"\n";
}
if($ctt->{txt00} =~ /Lieferschein/){
print $q->td(""),"\n" if($key =~ /int02|int04/);
}else{
if($key =~ /int02/){
if($einzel == "0"){
$einzel="";
}else{
$einzel =~ s/\./,/;
}
print $q->td({-nowrap=>'1',-class=>'tdint'},"$einzel"),"\n";
}
if($key =~ /int04/){
if($gesamt == "0"){
$gesamt="";
}else{
$gesamt .= " €";
$gesamt =~ s/\./,/;
}
#if($rabatt_val != 0 && $gesamt != 0){
if($rabatt_val != 0){
my $proz="%";
$proz = "€" if($cttpos->{$id}->{int08} == 1);
print $q->td({-nowrap=>'1',-class=>'tdint'},"(Rabatt $rabatt_val $proz) $gesamt"),"\n";
}else{
print $q->td({-nowrap=>'1',-class=>'tdint'},"$gesamt"),"\n";
}
}
}
}
}
}
}#end foreach
#Zahlungstext Text & Vorbelegungen
my $payment_text;
foreach(@tplf_order){
my ($key,$des,$size) = split /=/,$_;
if($key =~ /txt52|txt53|txt54|txt55|txt56|txt57|txt58|txt59|txt60/){
$ctf->{$key} = $q->unescapeHTML("$ctf->{$key}");
$ctf->{$key} = $lb->newline($ctf->{$key},$users->{tiny_mce},"");
$ctt->{state} =~ s/\(payone.*//;
if("$des" =~ /$ctt->{state}/ && ($j <= $max_table_wc || $break_table_wc)){
if($sum_parts19 < 0){
$payment_text = "$ctf->{txt58}";
}else{
$payment_text = "$ctf->{$key}";
}
}
}
}
my $diff7 = 100 + 7;
my $diff19 = 100 + $umst1619;
my $sum_umst7 = $sum_parts7 / $diff7 * 7;
my $sum_umst19 = $sum_parts19 / $diff19 * $umst1619;
$sum_umst7 = $lb->round($sum_umst7);
$sum_umst19 = $lb->round($sum_umst19);
my $sum_netto7 = $sum_parts7 - $sum_umst7;
my $sum_netto19 = $sum_parts19 - $sum_umst19;
$sum_netto7 = $lb->cashme($sum_netto7);
$sum_netto19 = $lb->cashme($sum_netto19);
my $sum_nettoall = $sum_parts0 + $sum_netto7 + $sum_netto19;
$sum_nettoall = $lb->cashme($sum_nettoall,",");
my $sum_paid = $sum_parts0 + $sum_parts7 + $sum_parts19;
$sum_parts0 = $lb->cashme($sum_parts0,",");
$sum_parts7 = $lb->cashme($sum_parts7,",");
$sum_parts19 = $lb->cashme($sum_parts19,",");
$sum_umst7 = $lb->cashme($sum_umst7,",");
$sum_umst19 = $lb->cashme($sum_umst19,",");
$sum_paid = $lb->cashme($sum_paid,",");
if($ctt->{txt00} !~ /Lieferschein/){
print $q->Tr(),"\n";
print $q->td({-class=>'Oline',-colspan=>5},"&nbsp;"),"\n";
print "<tr>\n";
print "<td colspan='2' style='border:0px solid silver;vertical-align:top;padding:0.2em 0.5em;font-size:1em;'>$payment_text</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";
#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";
if($ctt->{txt00} !~ /steuerfrei/){#dirty hack
print $q->Tr(),"\n";
print $q->td({-class=>'tdint'},"Betrag Netto:"),"\n";
print $q->td({-class=>'tdint',-nowrap=>"1"},"$sum_nettoall €"),"\n";
if($sum_parts0 != "0"){
print $q->Tr(),"\n";
print $q->td({-class=>'tdint',-nowrap=>"1"},"0% UmSt auf $sum_parts0 €:"),"\n";
print $q->td({-class=>'tdint',-nowrap=>"1"},"0,00 €"),"\n";
}
if($sum_netto7 != "0"){
print $q->Tr(),"\n";
print $q->td({-class=>'tdint',-nowrap=>"1"},"7% UmSt auf $sum_netto7 €:"),"\n";
print $q->td({-class=>'tdint',-nowrap=>"1"},"$sum_umst7 €"),"\n";
}
if($sum_parts19 != "0"){
print $q->Tr();
print $q->td({-class=>'tdint',-nowrap=>"1"},"$umst1619% UmSt auf $sum_netto19 €:"),"\n";
print $q->td({-class=>'tdint',-nowrap=>"1"},"$sum_umst19 €"),"\n";
}
}
#Zwischensumme
}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";
#print $q->end_table;
}
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(){
my ($h_top,$mandant_main_id,$ctt_txt21,$ctt_txt12,$kind_of_trans,$node_name,$nullcount) = @_;
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");
$ctt_txt12 = $lb->newline($ctt_txt12,$users->{tiny_mce},"");
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}");
$ctf->{$key} = $lb->newline($ctf->{$key},$users->{tiny_mce},"");
my @rechnungstext = split(/\<br \/\>/,$ctf->{$key});
if($ctt_txt21 =~ /$key/){
foreach(@rechnungstext){
if($_ =~ /signature/){
print $q->Tr();
print $q->td({-style=>'border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:black;'},"&nbsp;");
print $q->td({-style=>'width:4em;height:2em;'},"&nbsp;");
print $q->td({-style=>'border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:black;'},"&nbsp;");
print $q->Tr();
print $q->td({-class=>'tdpdf3'}, "&nbsp;&nbsp; Unterschrift Mieterin / Mieter &nbsp;&nbsp;","\n");
print $q->td("&nbsp;");
print $q->td({-class=>'tdpdf3'}, "Unterschrift ","\n");
print $q->Tr();
print $q->td({-colspan=>3, -style=>'border-bottom-width:2px;border-bottom-style:solid;border-bottom-color:black;'},"&nbsp;");
}else{
$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(){
my ($mandant_main_id,$top,$site,$site_all,$wc,$footer_bank,$logo) = @_;
my $ctf = $db->get_content1("contentuser","$mandant_main_id");
$ctf->{txt01} = $q->unescapeHTML("$ctf->{txt01}");
my @txt11 = split (/;/,"$ctf->{txt11}");#www
my @txt19 = split (/;/,"$footer_bank");#Fußzeile
$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();
print $q->td({-class=>'tdpdf2'}, "KONTAKT:","\n");
print $q->Tr();
print $q->td({-class=>'tdpdf2'}, "$ctf->{txt01}","\n");
print $q->Tr();
print $q->td({-class=>'tdpdf2'}, "$ctf->{txt04}","\n");
print $q->Tr();
print $q->td({-class=>'tdpdf2'}, "$ctf->{txt05}","\n");
print $q->end_table;
print "</td>";
print "<td style='width:25%;'>";
print $q->start_table({-border=>'0',-align=>'left'});
print $q->Tr();
print $q->td({-class=>'tdpdf2'}, "TEL: $ctf->{txt08}","\n");
#if($ctf->{txt09}){
# print $q->Tr();
# print $q->td({-class=>'tdpdf2'}, "FAX: $ctf->{txt09}","\n");
#}
print $q->Tr();
print $q->td({-class=>'tdpdf2'}, "$ctf->{txt10}","\n");
print $q->Tr();
print $q->td({-class=>'tdpdf2'}, "$txt11[0]","\n");
print $q->Tr();
print $q->td({-class=>'tdpdf2'}, "$txt11[1]","\n");
print $q->Tr();
print $q->td({-class=>'tdpdf2'}, "$txt11[2]","\n");
print $q->Tr();
print $q->td({-class=>'tdpdf2'}, "$txt11[3]","\n");
print $q->Tr();
print $q->td({-class=>'tdpdf2'}, "$txt11[4]","\n");
print $q->Tr();
print $q->td({-class=>'tdpdf2'}, "$txt11[5]","\n");
print $q->end_table;
print "</td>";
print "<td style='width:25%'>";
print $q->start_table({-border=>'0',-align=>'left'});
print $q->Tr();
print $q->td({-class=>'tdpdf2'}, "$txt19[0]","\n");
print $q->Tr();
print $q->td({-class=>'tdpdf2'}, "$txt19[1]","\n");
print $q->Tr();
print $q->td({-class=>'tdpdf2'}, "$txt19[2]","\n");
print $q->Tr();
print $q->td({-class=>'tdpdf2'}, "$txt19[3]","\n");
print $q->Tr();
print $q->td({-class=>'tdpdf2'}, "$txt19[4]","\n");
print $q->Tr();
print $q->td({-class=>'tdpdf2'}, "$txt19[5]","\n");
print $q->end_table;
print "</td>";
print "<td style='width:25%;'>";
print $q->start_table({-width=>'100%',-border=>'0',-align=>'left'});
print $q->Tr();
print $q->td({-class=>'tdpdf2'}, "$txt19[6]","\n");
print $q->Tr();
print $q->td({-class=>'tdpdf2'}, "$txt19[7]","\n");
print $q->Tr();
print $q->td({-class=>'tdpdf2'}, "$txt19[8]","\n");
print $q->Tr();
print $q->td({-class=>'tdpdf2'}, "$txt19[9]","\n");
print $q->Tr();
print $q->td({-class=>'tdpdf2'}, "$txt19[10]","\n");
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;