mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2024-11-05 02:36:30 +01:00
567 lines
25 KiB
Perl
Executable file
567 lines
25 KiB
Perl
Executable file
package TransPositionen;
|
||
#
|
||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
|
||
#
|
||
#
|
||
use strict;
|
||
use warnings;
|
||
use POSIX;
|
||
use CGI;
|
||
use CGI::Carp qw(fatalsToBrowser);
|
||
use CGI ':standard';
|
||
use DateTime;
|
||
use DateTime::Format::Pg;
|
||
use Date::Calc::Object qw(:ALL);
|
||
use Scalar::Util qw(looks_like_number);
|
||
use Lib::Config;
|
||
use Mod::Buttons;
|
||
use Mod::Libenz;
|
||
use Mod::Libenzdb;
|
||
use Mod::DBtank;
|
||
use Mod::APIfunc;
|
||
|
||
sub new {
|
||
my $class = shift;
|
||
my $self = {};
|
||
bless($self,$class);
|
||
return $self;
|
||
}
|
||
|
||
#Template
|
||
sub tpl(){
|
||
my $self=shift;
|
||
my ($node_meta,$users_dms,$set_main_id,$main_id,$rel_id,$c_id,$lang,$return,$node_name) = @_;
|
||
my $q = new CGI;
|
||
my $cf = new Config;
|
||
my $lb = new Libenz;
|
||
my $db = new Libenzdb;
|
||
my $dbt = new DBtank;
|
||
my $apif = new APIfunc;
|
||
my $but = new Buttons;
|
||
my %varenv = $cf->envonline();
|
||
my $script = $q->script_name();
|
||
my $path_info = $q->path_info();
|
||
my $path = $path_info;
|
||
#with meta_host,
|
||
if("$varenv{metahost}"){
|
||
$path = "$script" . "$path_info";
|
||
$script="";
|
||
}
|
||
my %ib = $but->ibuttons();
|
||
my $today = strftime("%d.%m.%Y",localtime(time));
|
||
my $dbh = "";
|
||
my $channel_map = $dbt->channel_map();
|
||
|
||
my $mapref = {};
|
||
my $ct_users = $dbt->users_map($dbh,$mapref);#get serviceAPP and DMS users from contentadr
|
||
|
||
my $line_count2;
|
||
my $k=0;
|
||
my $spart_ct_name = $R::spart_ct_name || "";
|
||
my $c_idpos = $R::c_idpos || $R::pos_id || "";
|
||
|
||
my $ctf = $db->get_content1("contentuser",$dbt->{shareedms_conf}->{parent_id});
|
||
my $ctt = $db->get_content1("contenttrans",$c_id);
|
||
|
||
my $umst1619 = $lb->umst_breaking($ctt,"");
|
||
|
||
my $ctadr = $db->get_content1("contentadr",$ctt->{int10});
|
||
my $buchen_mtime = $lb->time4de($ctt->{mtime});
|
||
my $vibuchen_mtime = "";
|
||
$vibuchen_mtime = "Payone post " . $lb->time4de($ctt->{pay_time},1) . " . " if($ctt->{pay_time});
|
||
|
||
my $tpl = $db->get_tpl("208");
|
||
my @tpl_order = split /,/,$tpl->{tpl_order};
|
||
my $tplf = $db->get_tpl("201");#Firma tpl
|
||
my @tplf_order = split /,/,$tplf->{tpl_order};
|
||
|
||
my $txt20 = $R::txt20 || $ctt->{txt20} || "";#Leistungsdatum
|
||
my $int05 = $R::int05 || $ctt->{int05} || "";#manuell
|
||
my $max_timestamp = "210001012359";
|
||
if($ctf->{txt80} && $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 = { c_id => 0 };
|
||
my $rows = 0;
|
||
($cttpos,$rows) = $db->collect_contentpos("contenttrans",$c_id);# if($c_id);
|
||
|
||
if($varenv{orga} eq "dms"){#obsolete after migrating lx-rad and mobile ...
|
||
print<<EOF
|
||
<style>
|
||
.ui-autocomplete {
|
||
text-align:left;
|
||
font-size:14px;
|
||
background:#eeeeee;
|
||
border:1px solid silver;
|
||
}
|
||
</style>
|
||
|
||
<script>
|
||
\$(function() {
|
||
\$('#json_select').autocomplete({
|
||
source: '/ajax_json?main_id=$dbt->{shareedms_conf}->{parent_id}&table=content',
|
||
minLength: 2,
|
||
select: function(event, ui) {
|
||
\$('#spart_ct_name').val(ui.item.spart_ct_name);
|
||
\$('#c_id').val(ui.item.c_id);
|
||
}
|
||
});
|
||
});
|
||
</script>
|
||
EOF
|
||
;
|
||
}
|
||
#print $q->div({ -class=>"ui-widget"}, $q->label({ -for=>"birds"},"Birds: "),$q->input({ -id=>"birds"},"")),"\n";
|
||
|
||
|
||
print $q->start_table({-class=>'list', -border=>'0', -width=>'100%',-align=>'left', -cellpadding=>'3', -cellspacing=>'0'});
|
||
|
||
|
||
#my $action_sort = "itime";
|
||
#Parts Header
|
||
print $q->start_form(-name=>'spartform');
|
||
print $q->Tr(); $line_count2++;
|
||
print $q->th($but->singlesubmit("select_part","*"),"\n");
|
||
foreach (@tpl_order){
|
||
my ($key,$val) = split /=/,$_;
|
||
$k++ if($val);
|
||
if("$key" eq "ct_name"){
|
||
my $ctpos;
|
||
print $q->hidden(-name=>'c_id4trans', -override=>'1', -value=>"$c_id");
|
||
print $q->hidden(-name=>'tpl_id4trans', -override=>'1', -value=>"$node_meta->{tpl_id}");
|
||
print $q->hidden(-id=>'c_id', -name=>"c_id", -override=>'1');
|
||
print $q->hidden(-id=>'spart_ct_name', -name=>"spart_ct_name", -override=>'1');
|
||
print $q->th($q->textfield(-class=>'etxt',-style=>'height:19px;width:140px;font-size:1.3em;text-align:right;',-id=>"json_select",-name=>"json_select",-value=>"", -override=>'1',-size=>"25",-maxlength=>50, -placeholder=>'Nummer'),"");
|
||
}
|
||
if($key =~ /int03/){
|
||
print $q->th("$val");
|
||
}elsif($key =~ /int|txt03/){
|
||
print $q->th("$val");
|
||
}elsif($key =~ /txt01/){
|
||
|
||
my $cal_button = "";
|
||
my $ter_button = "";
|
||
my $war_button = "";
|
||
print $q->th("Beschreibung"),"\n";
|
||
|
||
}elsif($key =~ /txt/){
|
||
print $q->th("$val");
|
||
}
|
||
}
|
||
|
||
$c_idpos = $1 if($return && $return =~ /pos_id=(\d+)/);
|
||
print $q->hidden(-name=>'trans2edit', -value=>"transpos", -override=>'1');
|
||
print $q->hidden(-name=>'offset', -override=>'1', -value=>"$R::offset") if($R::offset);
|
||
print $q->hidden(-name=>'limit', -override=>'1', -value=>"$R::limit") if($R::limit);
|
||
print $q->hidden(-name=>'relids', -override=>'1', -value=>"$R::relids") if($R::relids);
|
||
print $q->end_form,"\n";
|
||
|
||
print $q->start_form(-name=>'transposform'),"\n";
|
||
|
||
#Tablecontent (buttons and ct_name(primary key))
|
||
#my $scol = "c_id";#changed to itime because of Storno resorts
|
||
my $scol = "itime";
|
||
my $sum_parts0=0;
|
||
my $sum_parts7=0;
|
||
my $sum_parts19=0;
|
||
my $diff7 = 100 + 7;
|
||
my $diff19 = 100 + $umst1619;
|
||
my $sum_umst7=0;
|
||
my $sum_umst19=0;
|
||
my $i=0;
|
||
my $accounting_start;
|
||
my $accounting_end;
|
||
|
||
#foreach my $id (sort { $cttpos->{$b}->{$scol} <=> $cttpos->{$a}->{$scol} } keys(%$cttpos)){
|
||
foreach my $id (sort { $cttpos->{$b}->{$scol} cmp $cttpos->{$a}->{$scol} } keys(%$cttpos)){
|
||
my $set_style="";
|
||
my $gesamt="0";
|
||
my $occupied_style = "";
|
||
my $time_style = "";
|
||
#$occupied_style = "color:#ff1493" if($cttpos->{$id}->{txt10} =~ /occupied|requested|canceled/);
|
||
$occupied_style = "color:#ff1493" if($cttpos->{$id}->{int10} == 2 ||$cttpos->{$id}->{int10} == 3 || $cttpos->{$id}->{int10} == 6);
|
||
|
||
my $cttpos_timestamp = $1 . $2 . $3 . "0000" if($cttpos->{$id}->{itime} =~ /(\d+)\-(\d+)\-(\d+)/);
|
||
#max. Rechnungspositionen
|
||
if(($cttpos_timestamp <= $max_timestamp) && ($sum_parts19 <= $max_sum)){
|
||
$i++;
|
||
#print "$i (($id: $cttpos_timestamp <= $max_timestamp) && ($sum_parts19 <= $max_sum))<br>";
|
||
if($i==1){
|
||
$accounting_end = "$3.$2.$1" if($cttpos->{$id}->{itime} =~ /(\d+)\-(\d+)\-(\d+)/);
|
||
}else{
|
||
$accounting_start = "$3.$2.$1" if($cttpos->{$id}->{itime} =~ /(\d+)\-(\d+)\-(\d+)/);
|
||
}
|
||
#print "$accounting_start - $accounting_end<br>";
|
||
|
||
my @line_txt01 = split(/\n/,$cttpos->{$id}->{txt01});
|
||
if($cttpos->{$id}->{int02} != 0){
|
||
$line_count2++;
|
||
#$line_count2 += scalar(@line_txt01);
|
||
}
|
||
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);
|
||
my $einzel = $cttpos->{$id}->{int02};
|
||
my $menge = $cttpos->{$id}->{int03} || 0;
|
||
|
||
#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});
|
||
}
|
||
|
||
|
||
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($dt2 < $dt0){
|
||
#$time_style="color:red;";
|
||
#}
|
||
|
||
if(looks_like_number($einzel) && $einzel != 0 && looks_like_number($menge) && $menge != 0){
|
||
$gesamt = $einzel * $menge;
|
||
|
||
my $rabatt_val = $cttpos->{$id}->{int07} || "";
|
||
if($rabatt_val != 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);
|
||
if($cttpos->{$id}->{int05} =~ /\d/){
|
||
$sum_parts19 += $gesamt;
|
||
}else{
|
||
$sum_parts19 += $gesamt;
|
||
}
|
||
|
||
#1. Spalte
|
||
print $q->Tr(),"\n";
|
||
print "<td class='tdtxt'>";
|
||
if(($c_idpos == $cttpos->{$id}->{c_id}) && ($R::trans2edit && $R::trans2edit =~ /transpos/)){
|
||
print $q->hidden(-name=>'c_idpos', -value=>"$cttpos->{$id}->{c_id}", -override=>'1');
|
||
print $q->hidden(-name=>'cc_id', -value=>"$cttpos->{$id}->{cc_id}", -override=>'1');
|
||
print $q->hidden(-name=>'c_id4trans', -override=>'1', -value=>"$c_id");
|
||
print $q->hidden(-name=>'tpl_id4trans', -override=>'1', -value=>"$node_meta->{tpl_id}");
|
||
print $but->singlesubmit2("ct_trans","save_pos","$ib{save_pos}","","ebutton5"),
|
||
$but->singlesubmit2("ct_trans","delete_pos","$ib{delete_pos}"),"\n";
|
||
}elsif(!$ctt->{close_time}){
|
||
print $q->a({-class=>"editnav",-href=>"/DMS/Faktura?trans2edit=transpos\&c_idpos=$cttpos->{$id}->{c_id}\&c_id4trans=$c_id\&tpl_id4trans=$node_meta->{tpl_id}\&owner=$users_dms->{u_id}",-title=>"Datensatz bearbeiten"}, $q->img({-src=>"$varenv{metahost}/glyphicons/glyphicons-151-edit.png"})),"\n";
|
||
}
|
||
my $calpath = "Mietjournal";
|
||
print $q->a({-class=>"linknav3", -style=>"background-color:$varenv{calendar_active_color}",-href=>"/DMS/$calpath/?cttpos_id=$cttpos->{$id}->{c_id}",-title=>"Im $calpath öffnen"},"<br /><br />ID $cttpos->{$id}->{c_id}"),"\n";
|
||
print "</td>\n";
|
||
|
||
#Tablecontent (parameter)
|
||
foreach (@tpl_order){
|
||
my ($key,$val,$inputsize) = split /=/,$_;
|
||
$cttpos->{$id}->{$key} = $q->unescapeHTML($cttpos->{$id}->{$key});
|
||
$cttpos->{$id}->{$key} = $lb->newline($cttpos->{$id}->{$key},"",$R::trans2edit) if($R::trans2edit);
|
||
my $ct_pos = "$cttpos->{$id}->{ct_name}";
|
||
my $txtstyle = "text-align:left;min-width:150px;";
|
||
my $isize = "30";
|
||
$isize = $inputsize if($inputsize);
|
||
if($key =~ /int|txt03/){ #für zahlen etwas kleiner
|
||
$txtstyle = "text-align:right;min-width:50px;";
|
||
$isize = "5";
|
||
}
|
||
if(($c_idpos == $cttpos->{$id}->{c_id}) && ($R::trans2edit && $R::trans2edit =~ /transpos/)){
|
||
if($key =~ /ct_name/){
|
||
print $q->td({-class=>'element',-style=>"$set_style text-align:right;"}, $q->textfield(-class=>'etxt',-style=>"text-align:right;min-width:120px;",-name=>"ct_name",-default=>"$ct_pos", -override=>'1',-size=>10,-readonly=>'1'),"\n");
|
||
}elsif($key =~ /int03/){
|
||
print $q->td({-colspan=>'1',-class=>'element',-style=>"$txtstyle $set_style"},$q->textfield(-class=>'etxt',-style=>"$txtstyle",-name=>"col_$key",-default=>"$menge", -override=>'1',-size=>"$isize",-maxlength=>10, -autofocus=>1),"\n");
|
||
}elsif($key =~ /int02/){
|
||
print $q->td({-class=>'element',-style=>"$txtstyle $set_style"},$q->textfield(-class=>'etxt',-style=>"$txtstyle",-name=>"col_$key",-default=>"$einzel", -override=>'1',-size=>"$isize",-maxlength=>100),"\n");
|
||
}elsif($key =~ /int07/){
|
||
print $q->td({-class=>'element',-style=>"$txtstyle $set_style",-nowrap=>'1'},$q->textfield(-class=>'etxt',-style=>"$txtstyle",-name=>"col_$key",-default=>"$cttpos->{$id}->{$key}", -override=>'1',-size=>"$isize",-maxlength=>100),$but->selector("int08","40px","$cttpos->{$id}->{int08}",("0.00:%","1.00:€"))),"\n";
|
||
}elsif($key =~ /int04/){
|
||
print $q->td({-class=>'element',-style=>'text-align:right;padding:0.1em 0.5em;',-nowrap=>"1"},"$gesamt €");
|
||
}elsif($key =~ /txt01/){
|
||
if($cttpos->{$id}->{int09} && $cttpos->{$id}->{$key} !~ /Manuell/){
|
||
$cttpos->{$id}->{$key} .= "\nManuell bearbeitet\n";
|
||
}
|
||
print "<td class='element' style='$txtstyle $set_style;background-color: #ededed;$occupied_style;'\n>";
|
||
print $q->textarea(-class=>'autos',-style=>"border: 1px solid #ededed;background-color: #ededed;",-name=>"col_$key",-default=>"$cttpos->{$id}->{$key}", -override=>'1',-rows=>"1",-cols=>65),"<br />\n";
|
||
|
||
if($cttpos->{$id}->{int09}){#2020-12-07 Verleihräder werden anhand der TarifNr als solches erkannt
|
||
print $q->span({-style=>"$txtstyle $set_style"},
|
||
"Tarif Nr.: ", $q->textfield(-class=>'etxt',-name=>"int09",-default=>"$cttpos->{$id}->{int09}",-size=>"5",-maxlength=>5),
|
||
"Tarif Text", $q->textfield(-class=>'etxt',-name=>"txt04",-default=>"$cttpos->{$id}->{txt04}",-size=>"30",-maxlength=>50)),"<br />\n";
|
||
|
||
print $q->span({-style=>"$txtstyle $set_style"},
|
||
"Endstation: ", $q->textfield(-class=>'etxt',-name=>"int04",-default=>"$cttpos->{$id}->{int04}",-size=>"5",-maxlength=>40),
|
||
"GPS: ", $q->textfield(-class=>'etxt',-name=>"txt06",-default=>"$cttpos->{$id}->{txt06}",-size=>"35",-maxlength=>40)),"<br />\n";
|
||
|
||
print $q->span({-style=>"$txtstyle $set_style"},"Mietzeit: ",
|
||
$q->textfield(-id=>'datepicker1',-class=>'etxt',-name=>"start_date",-default=>"$s_dd.$s_mo.$s_yy",-size=>"10",-maxlength=>10),
|
||
$q->textfield(-class=>'etxt',-name=>"s_hh",-default=>"$s_hh",-size=>"2",-maxlength=>2),":",
|
||
$q->textfield(-class=>'etxt',-name=>"s_mi",-default=>"$s_mi",-size=>"2",-maxlength=>2)," – ",
|
||
$q->textfield(-id=>'datepicker2',-class=>'etxt',-name=>"end_date",-default=>"$e_dd.$e_mo.$e_yy",-size=>"10",-maxlength=>10),
|
||
$q->textfield(-class=>'etxt',-name=>"e_hh",-default=>"$e_hh",-size=>"2",-maxlength=>2),":",
|
||
$q->textfield(-class=>'etxt',-name=>"e_mi",-default=>"$e_mi",-size=>"2",-maxlength=>2)),"\n";
|
||
}
|
||
|
||
print "</td>\n";
|
||
}elsif($key =~ /txt/){
|
||
print $q->td({-class=>'element',-style=>"$txtstyle $set_style"},$q->textfield(-class=>'etxt',-style=>"$txtstyle",-name=>"col_$key",-default=>"$cttpos->{$id}->{$key}", -override=>'1',-size=>"$isize",-maxlength=>100),"\n");
|
||
#}elsif($key =~ /save/){
|
||
#print $q->td({-class=>'element',-style=>"$set_style"},$but->singlesubmit2("ct_trans","save_pos","$ib{save_pos}"));
|
||
}elsif($key =~ /int/){
|
||
print $q->td({-class=>'tdint',-nowrap=>"1"}," \n");
|
||
}
|
||
}else{
|
||
if($key =~ /ct_name/){
|
||
#print $q->td({-class=>'tdint',-style=>"min-width:60px;"},"$ct_pos");
|
||
my $stamm_style = "background-color:#98c13b;padding:2px;";
|
||
my $article = $cttpos->{$id}->{ct_name};
|
||
if($cttpos->{$id}->{int09}){
|
||
print $q->td({-class=>'tdint',-style=>"min-width:60px;padding-top:5px;"}, $q->a({-class=>"linknav3",-style=>"$stamm_style",-href=>"/DMS/Waren/?detail_search=1&s_barcode=$cttpos->{$id}->{barcode}",-title=>"Im Warenstamm"},"$article")),"\n";
|
||
}else{
|
||
print $q->td({-class=>'tdint'},"$article"),"\n";
|
||
}
|
||
}elsif($key =~ /int02/){
|
||
$einzel =~ s/\./,/;
|
||
print $q->td({-class=>'tdint'},"$einzel"),"\n";
|
||
}elsif($key =~ /int03/){
|
||
$menge =~ s/\./,/;
|
||
print $q->td({-colspan=>'1',-class=>'tdint'},"$menge"),"\n";
|
||
}elsif($key =~ /int04/){
|
||
$gesamt =~ s/\./,/;
|
||
print $q->td({-class=>'tdint',-nowrap=>"1"},"$gesamt €"),"\n";
|
||
}elsif($key =~ /int02/){
|
||
print $q->td({-class=>'tdint'},"$einzel"),"\n";
|
||
}elsif($key =~ /int07/){
|
||
my $proz="";
|
||
$proz = "%" if($cttpos->{$id}->{$key} && $cttpos->{$id}->{$key} != 0);
|
||
$proz = "€" if($cttpos->{$id}->{$key} && $cttpos->{$id}->{$key} != 0 && $cttpos->{$id}->{int08} && $cttpos->{$id}->{int08} == 1);
|
||
print $q->td({-class=>'tdint',-nowrap=>"1"},"$cttpos->{$id}->{$key} $proz"),"\n";
|
||
}elsif($key =~ /txt03/){
|
||
print $q->td({-class=>'tdint'},"$cttpos->{$id}->{$key}"),"\n";
|
||
}elsif($key =~ /txt01/){
|
||
$cttpos->{$id}->{$key} = $q->unescapeHTML("$cttpos->{$id}->{$key}");
|
||
$cttpos->{$id}->{$key} = $lb->newline($cttpos->{$id}->{$key},"","");
|
||
print "<td class='tdtxt', style='$occupied_style;'>\n";
|
||
if($cttpos->{$id}->{barcode} && $cttpos->{$id}->{int09}){#bike with tariff-nr
|
||
my $u_name = $cttpos->{$id}->{owner};
|
||
my $u_name_end = $cttpos->{$id}->{owner_end};
|
||
foreach my $ctu_id (keys (%$ct_users)){
|
||
if($channel_map->{$u_name}){
|
||
$u_name = $channel_map->{$u_name};
|
||
}elsif($cttpos->{$id}->{owner} eq $ct_users->{$ctu_id}->{c_id}){
|
||
$u_name = $ct_users->{$ctu_id}->{txt01};
|
||
}
|
||
if($channel_map->{$u_name_end}){
|
||
$u_name_end = $channel_map->{$u_name_end};
|
||
}elsif($cttpos->{$id}->{owner_end} eq $ct_users->{$ctu_id}->{c_id}){
|
||
$u_name_end = $ct_users->{$ctu_id}->{txt01};
|
||
}
|
||
}
|
||
if($cttpos->{$id}->{itime} =~ /(\d{4})-(\d{2})-(\d{2})\s(\d{2}):(\d{2})/){
|
||
print $q->span("$dbt->{copri_conf}->{bike_state}->{$cttpos->{$id}->{int10}} → $dbt->{copri_conf}->{lock_state}->{$cttpos->{$id}->{int20}} → $u_name / $u_name_end"),"\n";
|
||
print "<br />\n";
|
||
}
|
||
}
|
||
if($cttpos->{$id}->{txt01} || $cttpos->{$id}->{int09}){
|
||
#$line_count2++;
|
||
$cttpos->{$id}->{txt01} =~ s/fixed/\<span style='color:red'\>fixed\<\/span\>/;
|
||
$cttpos->{$id}->{txt01} =~ s/defect/\<span style='color:red'\>defect\<\/span\>/;
|
||
my $bike="";
|
||
my $tariff = "";
|
||
$bike = "$cttpos->{$id}->{$key}" if($cttpos->{$id}->{$key});
|
||
$tariff = ", Tarif: $cttpos->{$id}->{int09} $cttpos->{$id}->{txt04}" if($cttpos->{$id}->{txt04});
|
||
print $q->span("$bike $tariff<br />"),"\n";
|
||
}
|
||
if($cttpos->{$id}->{int06} || $cttpos->{$id}->{int04}){
|
||
print $q->span("Start/End Station: $cttpos->{$id}->{int06} / $cttpos->{$id}->{int04}, GPS: $cttpos->{$id}->{txt06}"),"\n";
|
||
}
|
||
if($cttpos->{$id}->{start_time}){
|
||
print "<br />\n";
|
||
print $q->span({-style=>"$time_style"}, "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";
|
||
}elsif($key =~ /txt/){
|
||
print $q->td({-class=>'tdtxt'},"$cttpos->{$id}->{$key}");
|
||
}elsif($key =~ /int/){
|
||
print $q->td({-class=>'tdint',-nowrap=>"1"}," \n");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}#foreach end
|
||
|
||
if($sum_parts7 != "0"){
|
||
$sum_umst7 = $sum_parts7 / $diff7 * 7;
|
||
$sum_umst7 = $lb->round($sum_umst7);
|
||
}
|
||
if($sum_parts19 != "0"){
|
||
$sum_umst19 = $sum_parts19 / $diff19 * $umst1619;
|
||
$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->round($sum_nettoall);
|
||
$sum_nettoall = $lb->cashme($sum_nettoall,",");
|
||
my $sum_paid = $sum_parts0 + $sum_parts7 + $sum_parts19;
|
||
$sum_paid = $lb->round($sum_paid);
|
||
my $sum_preauth = $sum_paid || 0;
|
||
$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->round($sum_umst19);
|
||
$sum_umst19 = $lb->cashme($sum_umst19,",");
|
||
$sum_paid = $lb->cashme($sum_paid,",");
|
||
|
||
my $payment_text = "";
|
||
foreach(@tplf_order){
|
||
my ($key,$des,$size) = split /=/,$_;
|
||
if($key =~ /txt5\d/){
|
||
$ctf->{$key} = $q->unescapeHTML("$ctf->{$key}");
|
||
$ctf->{$key} = $lb->newline($ctf->{$key},"","");
|
||
$ctt->{state} =~ s/\(payone.*//;
|
||
if($des =~ /$ctt->{state}/){
|
||
if($sum_parts19 < 0){
|
||
$payment_text = "$ctf->{txt58}";
|
||
}else{
|
||
$payment_text = "$ctf->{$key}";
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
my $n="5";
|
||
my $m= 1 + $k - $n;
|
||
$m++;
|
||
print "<tr>\n";
|
||
print "<td class='element' style='border:0;' colspan='$m'>$payment_text</td>\n";
|
||
print "<td style='font-size:1em;' colspan='$n'>\n";
|
||
|
||
print $q->start_table({-class=>'list',-style=>'border-top:1px;border-style:solid;border-color:black;', -border=>'0', -width=>'100%',-align=>'center', -cellpadding=>'3', -cellspacing=>'0'}),"\n";
|
||
print $q->Tr("\n");
|
||
print $q->td(" ");
|
||
|
||
if($node_name !~ /steuerfrei/){
|
||
print $q->Tr("\n"); $line_count2++;
|
||
print $q->td({-class=>'tdint'},"Nettobetrag:");
|
||
print $q->td({-class=>'tdint',-nowrap=>"1"},"$sum_nettoall €");
|
||
|
||
if($sum_parts0 != "0"){
|
||
print $q->Tr("\n");$line_count2++;
|
||
print $q->td({-class=>'tdint',-nowrap=>"1"},"0% UmSt auf $sum_parts0 €:");
|
||
print $q->td({-class=>'tdint',-nowrap=>"1"},"0,00 €");
|
||
}
|
||
if($sum_netto7 != "0"){
|
||
print $q->Tr("\n");$line_count2++;
|
||
print $q->td({-class=>'tdint',-nowrap=>"1"},"7% UmSt auf $sum_netto7 €:");
|
||
print $q->td({-class=>'tdint',-nowrap=>"1"},"$sum_umst7 €");
|
||
}
|
||
if($sum_netto19 != "0"){
|
||
print $q->Tr("\n");$line_count2++;
|
||
print $q->td({-class=>'tdint',-nowrap=>"1"},"$umst1619% UmSt auf $sum_netto19 €:");
|
||
print $q->td({-class=>'tdint',-nowrap=>"1"},"$sum_umst19 €");
|
||
}
|
||
}
|
||
my $summe = "Summe";
|
||
print $q->Tr("\n");$line_count2++;
|
||
print $q->td({-class=>'tdsum'},"<b>$summe:</b>");
|
||
print $q->td({-class=>'tdint',-nowrap=>"1"},"<b>$sum_paid €<b/>");
|
||
print $q->hidden(-name=>'sum_paid', -override=>'1',-value=>"$sum_paid");
|
||
|
||
print $q->end_table;
|
||
print "</td><td> </td>";
|
||
print "</tr>";
|
||
print $q->end_table;
|
||
|
||
print $q->hidden(-name=>'owner', -override=>'1', -value=>"$users_dms->{u_id}");
|
||
print $q->hidden(-name=>'offset', -override=>'1', -value=>"$R::offset") if($R::offset);
|
||
print $q->hidden(-name=>'c_id4trans', -override=>'1', -value=>"$c_id");
|
||
print $q->hidden(-name=>'tpl_id4trans', -override=>'1', -value=>"$node_meta->{tpl_id}");
|
||
print $q->hidden(-name=>'offset', -override=>'1', -value=>"$R::offset") if($R::offset);
|
||
print $q->hidden(-name=>'limit', -override=>'1', -value=>"$R::limit") if($R::limit);
|
||
print $q->hidden(-name=>'relids', -override=>'1', -value=>"$R::relids") if($R::relids);
|
||
|
||
$set_main_id=$main_id if($main_id && $main_id > "300000");
|
||
print $q->hidden(-name=>'set_main_id', -value=>"$set_main_id", -override=>'1');
|
||
|
||
|
||
#if(!$ctt->{close_time} && $varenv{Zahlungsweise} && $users_dms->{u_id} == $dbt->{copri_conf}->{superu_id}){
|
||
if($users_dms->{int03} == 2){
|
||
#only if user is also a primary DMS user with invoice rw
|
||
my $dbh_primary = $dbt->dbconnect_extern("sharee_primary");
|
||
my $users_dms_primary = { u_id => 0 };
|
||
$users_dms_primary = $dbt->select_users($dbh_primary,$users_dms->{u_id},"and int03=2");
|
||
|
||
if($users_dms_primary->{int03} == 2 && !$ctt->{close_time} && $varenv{Zahlungsweise}){
|
||
my @_paymentstate = split(/\|/,$varenv{Zahlungsweise});
|
||
push @_paymentstate, "";
|
||
my $kind_of_payment = "";
|
||
if($ctadr->{int03} == 1 && ($ctadr->{ct_name} =~ /PO-\d+/ || $ctadr->{ct_name} =~ /TM-\d+/)){
|
||
$kind_of_payment = "$_paymentstate[0]";
|
||
}else{
|
||
undef $_paymentstate[0];
|
||
}
|
||
if($ctadr->{int03} == 2 && length($ctadr->{ct_name}) >= 19){
|
||
$kind_of_payment = "$_paymentstate[1]";
|
||
}else{
|
||
undef $_paymentstate[1];
|
||
}
|
||
$kind_of_payment = "$ctt->{state}" if($ctt->{state});
|
||
|
||
print $q->hidden(-name=>'printer_id', -value=>"PDF - Normalpapier", -override=>'1');
|
||
my $send_invoice_checkbox = 1;
|
||
$send_invoice_checkbox = 0 if($ctt->{txt30});
|
||
print $q->div({-class=>'element',-style=>'float:right;'},
|
||
"buchen incl. drucken ",$but->checkbox("print_pdf","ct_trans","1","PDF drucken",""),
|
||
" eMail Versand ",$but->checkbox("1","send_invoice","$send_invoice_checkbox","eMail Rechnung",""),
|
||
$but->singlesubmit1("set_state","buchen"),
|
||
$but->selector("state","150px",$kind_of_payment,@_paymentstate)),"\n";
|
||
}
|
||
}
|
||
|
||
my $praefix = "$ctt->{txt00}-$varenv{praefix}";
|
||
if($ctt->{state} && $ctt->{int01}){
|
||
|
||
$ctt->{int01} =~ s/\./,/;
|
||
my $style = "color:red;" if($ctt->{int01} ne $sum_paid);
|
||
my $opos = "";
|
||
$opos = "OPOS" if($ctt->{int14} eq "1");
|
||
print $q->div({-style=>"float:right;padding:0.71em;font-size:0.81em;$style"},"[<span style='color:red;'>$opos</span> $vibuchen_mtime Gebucht $ctt->{int01} € \"$ctt->{state}\"]") if($ctt->{state});
|
||
}
|
||
print $q->end_form;
|
||
print $q->div({-style=>"clear:both;height:0.1px;"},""),"\n";
|
||
if($ctt->{txt30}){
|
||
print $q->div({-style=>"padding:0.5em;font-size:0.81em;width:98%;text-align:right;"}, "$ctt->{txt30}"),"\n";
|
||
}elsif( -f "$varenv{pdf}/$praefix-$ctt->{ct_name}.pdf" ){
|
||
print $q->start_form(),"\n";
|
||
print $q->hidden(-name=>'offset', -override=>'1', -value=>"$R::offset") if($R::offset);
|
||
print $q->hidden(-name=>'limit', -override=>'1', -value=>"$R::limit") if($R::limit);
|
||
print $q->hidden(-name=>'relids', -override=>'1', -value=>"$R::relids") if($R::relids);
|
||
print $q->div({-style=>"padding:0.5em;font-size:0.81em;width:98%;text-align:right;"}, "eMail wurde nicht versandt! Rechnung eMail ", $but->singlesubmit1("ct_trans","send_invoice_again","send_invoice_again")),"\n" if($users_dms->{u_id} == $dbt->{copri_conf}->{superu_id});
|
||
print $q->end_form;
|
||
}
|
||
|
||
if( -f "$varenv{pdf}/$praefix-$ctt->{ct_name}.pdf" && $varenv{metahost}){
|
||
print $q->div({-style=>"padding:0.5em;font-size:0.81em;width:98%;text-align:right;"}, "Download: ", $q->a({-href=>"$varenv{metahost}/pdf/$praefix-$ctt->{ct_name}.pdf", -target=>'_blank'},"$praefix-$ctt->{ct_name}.pdf"));
|
||
}
|
||
|
||
|
||
if($ctt->{state} && $ctt->{state} =~ /payone/ && $ctt->{txt28} && $ctt->{txt28} =~ /error/i){
|
||
print $q->div({-style=>"clear:both;padding:0.5em;font-size:0.81em;width:98%;text-align:right;color:red;"}, "Payone error: $ctt->{txt28}"),"\n";
|
||
}elsif($ctt->{txt28} =~ /settleaccount=yes/i){
|
||
print $q->div({-style=>"clear:both;padding:0.5em;font-size:0.81em;width:98%;text-align:right;color:green;"}, "Payone SEPA-Lastschrifteinzug war erfolgreich"),"\n";
|
||
}
|
||
|
||
$db->updater("contenttrans","c_id","$c_id","txt20","$accounting_start - $accounting_end","","","","","no_time") if(!$int05 && $accounting_start && $accounting_end);
|
||
$db->updater("contenttrans","c_id","$c_id","int15","$sum_preauth","","","","","no_time") if($sum_preauth || $sum_preauth == 0);
|
||
return "$line_count2";
|
||
}
|
||
1;
|