2021-12-30 12:05:56 +01:00
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 ) ;
2022-04-30 08:12:55 +02:00
use Data::Dumper ;
2021-12-30 12:05:56 +01:00
use Lib::Config ;
use Mod::Buttons ;
use Mod::Libenz ;
use Mod::Libenzdb ;
use Mod::DBtank ;
use Mod::APIfunc ;
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 ;
}
#Template
sub tpl () {
2022-02-10 16:45:22 +01:00
my $ self = shift ;
my $ node_meta = shift ;
my $ users_dms = shift ;
my $ set_main_id = shift ;
2022-10-31 08:11:53 +01:00
my $ ctt = shift ;
2022-02-10 16:45:22 +01:00
my $ return = shift || "" ;
2021-12-30 12:05:56 +01:00
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 ;
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 % ib = $ but - > ibuttons ( ) ;
2022-05-17 09:24:02 +02:00
my $ today = strftime "%d.%m.%Y" , localtime ;
my $ now_dt = strftime "%Y-%m-%d %H:%M:%S" , localtime ;
2021-12-30 12:05:56 +01:00
my $ channel_map = $ dbt - > channel_map ( ) ;
2022-11-06 18:45:59 +01:00
my $ coo = $ q - > cookie ( - name = > 'domcookie' ) || "" ;
2022-10-31 08:11:53 +01:00
my $ dbh = "" ;
2021-12-30 12:05:56 +01:00
my $ mapref = { } ;
my $ ct_users = $ dbt - > users_map ( $ dbh , $ mapref ) ; #get serviceAPP and DMS users from contentadr
2022-09-15 17:06:08 +02:00
my $ line_count2 = 0 ;
2022-10-31 08:11:53 +01:00
my $ tc = 0 ;
my $ txt20 = $ R:: txt20 || $ ctt - > { txt20 } || "" ; #Leistungsdatum
my $ int05 = $ R:: int05 || $ ctt - > { int05 } || "" ; #manuell
my $ rows = 0 ;
2021-12-30 12:05:56 +01:00
my $ spart_ct_name = $ R:: spart_ct_name || "" ;
my $ c_idpos = $ R:: c_idpos || $ R:: pos_id || "" ;
2022-10-31 08:11:53 +01:00
my $ cttpos = { c_id = > 0 } ;
2021-12-30 12:05:56 +01:00
2022-10-31 08:11:53 +01:00
my $ ctf = { c_id = > 0 } ;
my $ pref_cu = {
table = > "contentuser" ,
fetch = > "one" ,
c_id = > $ dbt - > { shareedms_conf } - > { parent_id } ,
} ;
$ ctf = $ dbt - > fetch_tablerecord ( $ dbh , $ pref_cu ) ;
2021-12-30 12:05:56 +01:00
my $ ctadr = $ db - > get_content1 ( "contentadr" , $ ctt - > { int10 } ) ;
2023-03-10 11:35:56 +01:00
my $ vibuchen_mtime = "(nicht verfügbar, siehe Internas und log)" ;
2021-12-30 12:05:56 +01:00
2022-05-04 08:02:59 +02:00
my @ tpl_order = ( "txt01=Beschreibung" , "ct_name=Nummer" , "date_time=timerange" , "int03=Menge (Miet - Gratis Zeit)" , "int02=Preis" , "int07=Rabatt" , "int04=Gesamt" ) ;
2022-10-18 20:15:11 +02:00
my $ tplf = $ db - > get_tpl ( "201" ) ; #Kunden-Faktura, ex Firma
2022-02-01 20:53:23 +01:00
my @ tplf_order = split /,/ , $ tplf - > { tpl_order } ;
2021-12-30 12:05:56 +01:00
2022-10-31 08:11:53 +01:00
( $ cttpos , $ rows ) = $ dbt - > collect_contentpos ( $ dbh , "contenttrans" , $ ctt - > { content_id } ) ;
2022-02-10 16:45:22 +01:00
foreach my $ id ( keys ( %$ cttpos ) ) {
2022-04-04 14:57:43 +02:00
if ( ref ( $ cttpos - > { $ id } ) eq "HASH" ) {
2022-02-10 16:45:22 +01:00
if ( $ cttpos - > { $ id } - > { int26 } ) {
2022-05-04 08:02:59 +02:00
@ tpl_order = ( "txt01=Beschreibung" , "ct_name=Nummer" , "date_time=timerange" , "int26=Einsparung" , "int03=Menge (Miet - Gratis Zeit)" , "int02=Preis" , "int07=Rabatt" , "int04=Gesamt" ) ;
2022-02-10 16:45:22 +01:00
}
2022-04-26 20:57:13 +02:00
#enhanced tariff
#if($cttpos->{$id}->{int35}){
# @tpl_order = ("txt01=Beschreibung","ct_name=Nummer","date_time=timerange","int26=Einsparung","int35=Mietzeit Menge","int03=Artikel Menge","int02=Preis","int07=Rabatt","int04=Gesamt");
#}
2022-04-04 14:57:43 +02:00
} else {
2022-10-31 08:11:53 +01:00
$ lb - > failure3 ( "Der selekt einer Verkaufsposition ist fehlgeschlagen, errocode ($ctt->{content_id} | $ctt->{template_id} | $users_dms->{c_id4trans}). Bitte admin kontaktieren" ) ;
2022-04-26 20:57:13 +02:00
exit ;
2022-04-04 14:57:43 +02:00
}
2022-02-10 16:45:22 +01:00
}
2022-01-26 15:52:25 +01:00
2021-12-30 12:05:56 +01:00
print << EOF
<style>
. ui - autocomplete {
text - align:left ;
font - size:14px ;
background: #eeeeee;
border:1px solid silver ;
}
</style>
<script>
\ $ ( function ( ) {
\ $( '#json_select' ) . autocomplete ( {
2023-03-05 20:01:47 +01:00
source: '/ajax_json?table=content&template_id=224,229&catch_equal=0' ,
2021-12-30 12:05:56 +01:00
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 - > start_table ( { - class = > 'list' , - border = > '0' , - width = > '100%' , - align = > 'left' , - cellpadding = > '3' , - cellspacing = > '0' } ) ;
#Parts Header
print $ q - > start_form ( - name = > 'spartform' ) ;
2022-02-10 16:45:22 +01:00
$ c_idpos = $ 1 if ( $ return && $ return =~ /pos_id=(\d+)/ ) ;
2022-10-31 08:11:53 +01:00
print $ q - > hidden ( - name = > 'trans2edit' , - value = > "transpos" , - override = > '1' ) , "\n" ;
print $ q - > hidden ( - name = > 'offset' , - override = > '1' , - value = > "$R::offset" ) , "\n" if ( $ R:: offset ) ;
print $ q - > hidden ( - name = > 'limit' , - override = > '1' , - value = > "$R::limit" ) , "\n" if ( $ R:: limit ) ;
print $ q - > hidden ( - name = > 'c_id4trans' , - override = > '1' , - value = > "$ctt->{content_id}" ) , "\n" ;
print $ q - > hidden ( - name = > 'tpl_id4trans' , - override = > '1' , - value = > "$ctt->{template_id}" ) , "\n" ;
print $ q - > hidden ( - id = > 'c_id' , - name = > "c_id" , - override = > '1' ) , "\n" ;
print $ q - > hidden ( - id = > 'spart_ct_name' , - name = > "spart_ct_name" , - override = > '1' ) , "\n" ;
2022-02-10 16:45:22 +01:00
$ line_count2 + + ;
print $ q - > Tr ( ) ;
2022-10-31 08:11:53 +01:00
print $ q - > th ( $ but - > singlesubmit ( "select_part" , "*" ) ) , "\n" ;
2021-12-30 12:05:56 +01:00
foreach ( @ tpl_order ) {
my ( $ key , $ val ) = split /=/ , $ _ ;
2022-10-31 08:11:53 +01:00
$ tc + + if ( $ val ) ;
2022-02-10 16:45:22 +01:00
if ( $ key eq "ct_name" ) {
2023-02-12 08:23:52 +01:00
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' , - autofocus = > 1 ) , "" ) , "\n" ;
2022-04-26 20:57:13 +02:00
} elsif ( $ key =~ /int|txt|time\d+/ ) {
2022-10-31 08:11:53 +01:00
print $ q - > th ( "$val" ) , "\n" ;
2021-12-30 12:05:56 +01:00
}
}
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_parts19 = 0 ;
2022-02-10 16:45:22 +01:00
my $ diff19 = 100 + 19 ;
2021-12-30 12:05:56 +01:00
my $ sum_umst19 = 0 ;
my $ i = 0 ;
2022-02-15 13:17:10 +01:00
my $ accounting_start = "" ;
my $ accounting_end = "" ;
2021-12-30 12:05:56 +01:00
#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 ) ) {
2022-04-26 20:57:13 +02:00
2022-05-01 18:31:03 +02:00
my $ gesamt = 0 ;
2022-04-26 20:57:13 +02:00
my $ pricing = { } ;
my $ counting = { } ;
my $ rental_feed = { } ;
2022-05-01 18:31:03 +02:00
2022-04-26 20:57:13 +02:00
if ( $ cttpos - > { $ id } - > { int35 } && $ cttpos - > { $ id } - > { start_time } && $ cttpos - > { $ id } - > { end_time } ) {
2022-05-17 09:24:02 +02:00
$ cttpos - > { $ id } - > { end_time } = $ now_dt if ( $ cttpos - > { $ id } - > { int10 } == 3 ) ;
2023-04-17 15:30:19 +02:00
$ pri - > count_freedrental ( $ q , \ % varenv , $ ctadr - > { c_id } , $ cttpos - > { $ id } ) ;
( $ pricing , $ counting ) = $ pri - > counting_rental ( \ % varenv , $ cttpos - > { $ id } ) ;
2022-05-01 18:31:03 +02:00
$ rental_feed = $ pri - > fetch_rentalfeed ( \ % varenv , $ cttpos - > { $ id } , $ counting ) ;
$ sum_parts19 += $ pricing - > { total_price } ;
$ gesamt = $ pri - > round ( $ pricing - > { total_price } ) ;
$ gesamt = sprintf ( '%.2f' , $ gesamt ) ;
} else {
( $ gesamt , my $ rabatt ) = $ pri - > price2calc ( $ cttpos - > { $ id } ) ;
$ sum_parts19 += $ gesamt ;
$ gesamt = $ pri - > round ( $ gesamt ) ;
$ gesamt = sprintf ( '%.2f' , $ gesamt ) ;
2022-04-26 20:57:13 +02:00
}
2021-12-30 12:05:56 +01:00
my $ set_style = "" ;
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 ) ;
#max. Rechnungspositionen
2022-05-01 18:31:03 +02:00
if ( 1 == 1 ) {
2021-12-30 12:05:56 +01:00
$ i + + ;
2023-01-25 07:25:12 +01:00
if ( $ ctt - > { ct_name } =~ /^\d+$/ ) {
if ( $ i == 1 ) {
2021-12-30 12:05:56 +01:00
$ accounting_end = "$3.$2.$1" if ( $ cttpos - > { $ id } - > { itime } =~ /(\d+)\-(\d+)\-(\d+)/ ) ;
2022-02-15 13:17:10 +01:00
$ accounting_end = "$3.$2.$1" if ( $ cttpos - > { $ id } - > { end_time } =~ /(\d+)\-(\d+)\-(\d+)/ ) ;
$ accounting_start = $ accounting_end ;
2023-01-25 07:25:12 +01:00
} else {
2021-12-30 12:05:56 +01:00
$ accounting_start = "$3.$2.$1" if ( $ cttpos - > { $ id } - > { itime } =~ /(\d+)\-(\d+)\-(\d+)/ ) ;
2023-01-25 07:25:12 +01:00
}
2021-12-30 12:05:56 +01:00
}
#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);
}
#1. Spalte
print $ q - > Tr ( ) , "\n" ;
2022-10-31 08:11:53 +01:00
print "<td class='tdtxt' nowrap>" , "\n" ;
2021-12-30 12:05:56 +01:00
if ( ( $ c_idpos == $ cttpos - > { $ id } - > { c_id } ) && ( $ R:: trans2edit && $ R:: trans2edit =~ /transpos/ ) ) {
2022-10-31 08:11:53 +01:00
print $ q - > hidden ( - name = > 'c_idpos' , - value = > "$cttpos->{$id}->{c_id}" , - override = > '1' ) , "\n" ;
print $ q - > hidden ( - name = > 'cc_id' , - value = > "$cttpos->{$id}->{cc_id}" , - override = > '1' ) , "\n" ;
print $ q - > hidden ( - name = > 'c_id4trans' , - override = > '1' , - value = > "$ctt->{content_id}" ) , "\n" ;
print $ q - > hidden ( - name = > 'tpl_id4trans' , - override = > '1' , - value = > "$ctt->{template_id}" ) , "\n" ;
2022-12-06 19:57:49 +01:00
print $ but - > singlesubmit2glyph ( "ct_trans" , "save_pos" , "$ib{save_pos}" , "background-color:white;padding:5px 5px 0 0;" , "" ) , " " ,
$ but - > singlesubmit2glyph ( "ct_trans" , "delete_pos" , "$ib{delete_pos}" , "background-color:white;padding:5px 0 0 5px;" , "" ) , "\n" ;
2021-12-30 12:05:56 +01:00
} elsif ( ! $ ctt - > { close_time } ) {
2022-12-06 19:57:49 +01:00
print $ q - > a ( { - class = > "editnav3" , - href = > "/DMS/Faktura?trans2edit=transpos\&c_idpos=$cttpos->{$id}->{c_id}\&c_id4trans=$ctt->{content_id}\&tpl_id4trans=$ctt->{template_id}\&owner=$users_dms->{u_id}" , - title = > "Datensatz bearbeiten" } , $ q - > span ( { - class = > "bi bi-file-earmark-text" , - style = > 'font-size:1.7em;' } ) ) , "\n" ;
2021-12-30 12:05:56 +01:00
}
my $ calpath = "Mietjournal" ;
2022-12-06 19:57:49 +01:00
print $ q - > a ( { - class = > "linknav3" , - href = > "/DMS/$calpath/?cttpos_id=$cttpos->{$id}->{c_id}" , - title = > "Im $calpath anzeigen" } , "<br /><br />→ ID $cttpos->{$id}->{c_id}" ) , "\n" ;
2021-12-30 12:05:56 +01:00
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}" ;
2022-05-18 10:53:29 +02:00
my $ txtstyle = "text-align:left;min-width:130px;" ;
2021-12-30 12:05:56 +01:00
my $ isize = "30" ;
$ isize = $ inputsize if ( $ inputsize ) ;
2022-04-26 20:57:13 +02:00
if ( $ key =~ /int\d+/ ) {
2021-12-30 12:05:56 +01:00
$ txtstyle = "text-align:right;min-width:50px;" ;
$ isize = "5" ;
}
2022-04-26 20:57:13 +02:00
#edit position
2021-12-30 12:05:56 +01:00
if ( ( $ c_idpos == $ cttpos - > { $ id } - > { c_id } ) && ( $ R:: trans2edit && $ R:: trans2edit =~ /transpos/ ) ) {
if ( $ key =~ /ct_name/ ) {
2022-02-19 13:20:23 +01:00
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" ;
2022-02-10 16:45:22 +01:00
} elsif ( $ key eq "int26" ) {
my $ co2saving = "" ;
if ( $ cttpos - > { $ id } - > { int26 } ) {
$ co2saving = "Einsparung</br>" ;
my $ co2diff = $ pri - > co2calc ( $ cttpos - > { $ id } ) ;
2022-10-31 08:11:53 +01:00
#my $sprit_price = $pri->sprit2calc($cttpos->{$id});
2022-02-10 16:45:22 +01:00
$ co2saving . = "$co2diff kg CO²<br />" ;
2022-10-31 08:11:53 +01: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-10-31 08:11:53 +01:00
print $ q - > td ( { - class = > 'tdint' } , "$co2saving" ) , "\n" ;
2022-02-10 16:45:22 +01:00
2021-12-30 12:05:56 +01:00
} elsif ( $ key =~ /int03/ ) {
2022-04-26 20:57:13 +02:00
if ( $ cttpos - > { $ id } - > { int35 } && $ cttpos - > { $ id } - > { start_time } && $ cttpos - > { $ id } - > { end_time } ) {
2022-05-18 10:53:29 +02:00
print $ q - > td ( { - class = > 'tdint' , - nowrap = > 1 } , "$pricing->{real_clock} $pricing->{freed_time}" ) , "\n" ;
2022-04-26 20:57:13 +02:00
} else {
2022-05-24 10:46:05 +02:00
print $ q - > td ( { - colspan = > '1' , - class = > 'element' , - style = > "$txtstyle $set_style" } , $ q - > textfield ( - class = > 'etxt' , - style = > "$txtstyle" , - name = > "col_$key" , - default = > "$cttpos->{$id}->{$key}" , - override = > '1' , - size = > "$isize" , - maxlength = > 10 ) ) , "\n" ;
2022-04-26 20:57:13 +02:00
}
2021-12-30 12:05:56 +01:00
} elsif ( $ key =~ /int02/ ) {
2022-04-26 20:57:13 +02:00
if ( $ cttpos - > { $ id } - > { int35 } && $ cttpos - > { $ id } - > { start_time } && $ cttpos - > { $ id } - > { end_time } ) {
2022-05-18 10:53:29 +02:00
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-04-26 20:57:13 +02:00
}
}
print "</td>\n" ;
} else {
2022-10-31 08:11:53 +01:00
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" ;
2022-04-26 20:57:13 +02:00
}
2021-12-30 12:05:56 +01:00
} elsif ( $ key =~ /int07/ ) {
2022-05-01 18:31:03 +02:00
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" ;
2021-12-30 12:05:56 +01:00
} elsif ( $ key =~ /int04/ ) {
2022-10-31 08:11:53 +01:00
print $ q - > td ( { - class = > 'tdint' , - nowrap = > "1" } , "$gesamt €" ) , "\n" ;
2021-12-30 12:05:56 +01:00
} elsif ( $ key =~ /txt01/ ) {
if ( $ cttpos - > { $ id } - > { int09 } && $ cttpos - > { $ id } - > { $ key } !~ /Manuell/ ) {
$ cttpos - > { $ id } - > { $ key } . = "\nManuell bearbeitet\n" ;
}
2022-02-10 16:45:22 +01:00
my ( $ s_yy , $ s_mo , $ s_dd , $ s_hh , $ s_mi ) = $ lb - > split_date ( $ cttpos - > { $ id } - > { start_time } ) ;
my ( $ e_yy , $ e_mo , $ e_dd , $ e_hh , $ e_mi ) = $ lb - > split_date ( $ cttpos - > { $ id } - > { end_time } ) ;
2022-12-06 19:57:49 +01:00
print "<td class='tdtxt3' style='$txtstyle $set_style;$occupied_style;'>\n" ;
print $ q - > textarea ( - class = > 'autos' , - style = > "border: 1px solid #ededed;" , - name = > "col_$key" , - default = > "$cttpos->{$id}->{$key}" , - override = > '1' , - rows = > "3" , - cols = > 60 , - autofocus = > 1 ) , "<br />\n" ;
2021-12-30 12:05:56 +01:00
2022-05-01 18:31:03 +02:00
#if Traiff Nr.
if ( $ cttpos - > { $ id } - > { int09 } ) {
2022-12-06 19:57:49 +01:00
print $ q - > span ( { - style = > "$txtstyle $set_style" } , "Tarif: $cttpos->{$id}->{int09} $cttpos->{$id}->{txt04}<br />" ) , "\n" ;
2021-12-30 12:05:56 +01:00
print $ q - > span ( { - style = > "$txtstyle $set_style" } ,
"Endstation: " , $ q - > textfield ( - class = > 'etxt' , - name = > "int04" , - default = > "$cttpos->{$id}->{int04}" , - size = > "5" , - maxlength = > 40 ) ,
2022-05-04 08:02:59 +02:00
"GPS: " , $ q - > textfield ( - class = > 'etxt' , - name = > "txt06" , - default = > "$cttpos->{$id}->{txt06}" , - size = > "30" , - maxlength = > 40 ) ) , "<br />\n" ;
2021-12-30 12:05:56 +01:00
print $ q - > span ( { - style = > "$txtstyle $set_style" } , "Mietzeit: " ,
2022-04-26 20:57:13 +02:00
$ q - > textfield ( - id = > 'datepicker1' , - class = > 'etxt' , - name = > "start_date" , - default = > "$s_dd.$s_mo.$s_yy" , - size = > "8" , - maxlength = > 10 ) ,
$ q - > textfield ( - class = > 'etxt' , - name = > "s_hh" , - default = > "$s_hh" , - size = > "1" , - maxlength = > 2 ) , ":" ,
2022-04-30 08:12:55 +02:00
$ q - > textfield ( - class = > 'etxt' , - name = > "s_mi" , - default = > "$s_mi" , - size = > "1" , - maxlength = > 2 ) , " → " ,
2022-04-26 20:57:13 +02:00
$ q - > textfield ( - id = > 'datepicker2' , - class = > 'etxt' , - name = > "end_date" , - default = > "$e_dd.$e_mo.$e_yy" , - size = > "8" , - maxlength = > 10 ) ,
$ q - > textfield ( - class = > 'etxt' , - name = > "e_hh" , - default = > "$e_hh" , - size = > "1" , - maxlength = > 2 ) , ":" ,
$ q - > textfield ( - class = > 'etxt' , - name = > "e_mi" , - default = > "$e_mi" , - size = > "1" , - maxlength = > 2 ) ) , "\n" ;
2021-12-30 12:05:56 +01:00
}
2022-12-10 15:47:22 +01:00
print "<br /><b>Bemerkung (Mietjournal)</b> $cttpos->{$id}->{txt23}\n" if ( $ cttpos - > { $ id } - > { txt23 } ) ;
2021-12-30 12:05:56 +01:00
print "</td>\n" ;
} elsif ( $ key =~ /txt/ ) {
2022-10-31 08:11:53 +01:00
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" ;
2021-12-30 12:05:56 +01:00
} elsif ( $ key =~ /int/ ) {
2022-10-31 08:11:53 +01:00
print $ q - > td ( { - class = > 'tdint' , - nowrap = > "1" } , " " ) , "\n" ;
2021-12-30 12:05:56 +01:00
}
2022-04-26 20:57:13 +02:00
}
#end edit position
#
#start view position
else {
2021-12-30 12:05:56 +01:00
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 } ) {
2022-01-26 15:52:25 +01:00
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" ;
2021-12-30 12:05:56 +01:00
} else {
print $ q - > td ( { - class = > 'tdint' } , "$article" ) , "\n" ;
}
2022-02-10 16:45:22 +01:00
} elsif ( $ key eq "int26" ) {
my $ co2saving = "" ;
if ( $ cttpos - > { $ id } - > { int26 } ) {
$ co2saving = "Einsparung</br>" ;
my $ co2diff = $ pri - > co2calc ( $ cttpos - > { $ id } ) ;
2022-10-31 08:11:53 +01:00
#my $sprit_price = $pri->sprit2calc($cttpos->{$id});
2022-02-10 16:45:22 +01:00
$ co2saving . = "$co2diff kg CO²<br />" ;
2022-10-31 08:11:53 +01:00
#$co2saving .= "$sprit_price EUR<br />";
2022-02-10 16:45:22 +01:00
$ cttpos - > { $ id } - > { int26 } =~ s/\./,/ ;
$ co2saving . = "bei $cttpos->{$id}->{int26} KM" ;
}
2022-10-31 08:11:53 +01:00
print $ q - > td ( { - class = > 'tdint' } , "$co2saving" ) , "\n" ;
2022-02-10 16:45:22 +01:00
2022-04-26 20:57:13 +02:00
}
2022-04-30 08:12:55 +02:00
#yes, int03=Menge on parts, int35=unit_price1 on rental
2022-04-26 20:57:13 +02:00
elsif ( $ key =~ /int03/ ) {
if ( $ cttpos - > { $ id } - > { int35 } && $ cttpos - > { $ id } - > { start_time } && $ cttpos - > { $ id } - > { end_time } ) {
2022-04-30 08:12:55 +02:00
print $ q - > td ( { - class = > 'tdint' , - nowrap = > 1 } , "$pricing->{real_clock} $pricing->{freed_time}" ) , "\n" ;
2022-04-26 20:57:13 +02:00
} else {
$ cttpos - > { $ id } - > { $ key } =~ s/\./,/ ;
print $ q - > td ( { - class = > 'tdint' } , "$cttpos->{$id}->{$key}" ) , "\n" ;
}
} elsif ( $ key =~ /int02/ ) {
if ( $ cttpos - > { $ id } - > { int35 } && $ cttpos - > { $ id } - > { start_time } && $ cttpos - > { $ id } - > { end_time } ) {
print "<td class='tdint'>\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-04-26 20:57:13 +02:00
}
}
print "</td>\n" ;
} else {
$ cttpos - > { $ id } - > { $ key } =~ s/\./,/ ;
print $ q - > td ( { - class = > 'tdint' } , "$cttpos->{$id}->{$key} €" ) , "\n" ;
}
2021-12-30 12:05:56 +01:00
} elsif ( $ key =~ /int04/ ) {
2022-05-01 18:31:03 +02:00
$ gesamt =~ s/\./,/ ;
print $ q - > td ( { - class = > 'tdint' , - nowrap = > 1 } , "$gesamt €" ) , "\n" ;
2021-12-30 12:05:56 +01:00
} elsif ( $ key =~ /int07/ ) {
2022-05-01 18:31:03 +02:00
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 ) ;
$ cttpos - > { $ id } - > { $ key } =~ s/\./,/ ;
print $ q - > td ( { - class = > 'tdint' , - nowrap = > "1" } , "$cttpos->{$id}->{$key} $proz" ) , "\n" ;
2021-12-30 12:05:56 +01:00
} elsif ( $ key =~ /txt01/ ) {
$ cttpos - > { $ id } - > { $ key } = $ q - > unescapeHTML ( "$cttpos->{$id}->{$key}" ) ;
$ cttpos - > { $ id } - > { $ key } = $ lb - > newline ( $ cttpos - > { $ id } - > { $ key } , "" , "" ) ;
2022-12-06 19:57:49 +01:00
print "<td class='tdtxt3', style='$occupied_style;'>\n" ;
2021-12-30 12:05:56 +01:00
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" ;
2022-05-01 18:31:03 +02:00
my $ pos_raw = "" ;
2022-04-30 08:12:55 +02:00
if ( $ users_dms - > { u_id } && $ users_dms - > { u_id } =~ /1842/ ) {
my $ pos_details = "" ;
foreach my $ did ( sort keys ( % { $ pricing - > { rentalog } } ) ) {
$ pos_details . = $ did . " = " . $ pricing - > { rentalog } - > { $ did } . "</br>" if ( $ pricing - > { rentalog } - > { $ did } ) ;
}
#$pos_details = Dumper($pricing->{rentalog});
2022-05-01 18:31:03 +02:00
$ pos_raw = $ q - > div ( { - class = > "popup" , - onclick = > "toggle_box('$id')" } , "$cttpos->{$id}->{c_id}" , $ q - > span ( { - class = > "popuptext" , - id = > "$id" } , "$pos_details" ) ) ;
2022-05-13 20:00:25 +02:00
print "(raw $pos_raw)<br />\n" ;
2022-04-30 08:12:55 +02:00
}
2021-12-30 12:05:56 +01:00
}
2022-05-20 19:37:57 +02:00
print "<br />\n" ;
2021-12-30 12:05:56 +01:00
}
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 } ) ;
2022-05-01 18:31:03 +02:00
$ tariff = ", Tarif: $cttpos->{$id}->{int09} $cttpos->{$id}->{txt04}" if ( $ cttpos - > { $ id } - > { txt04 } ) ;
print $ q - > span ( "$bike $tariff<br />" ) , "\n" ;
2021-12-30 12:05:56 +01:00
}
2023-02-10 12:04:30 +01:00
if ( $ cttpos - > { $ id } - > { int06 } && $ cttpos - > { $ id } - > { int04 } ) {
2021-12-30 12:05:56 +01:00
print $ q - > span ( "Start/End Station: $cttpos->{$id}->{int06} / $cttpos->{$id}->{int04}, GPS: $cttpos->{$id}->{txt06}" ) , "\n" ;
}
2022-02-10 16:45:22 +01:00
if ( $ cttpos - > { $ id } - > { start_time } && $ cttpos - > { $ id } - > { end_time } ) {
2022-04-26 20:57:13 +02:00
my $ start_time = $ lb - > time4de ( $ cttpos - > { $ id } - > { start_time } , "1" ) ;
my $ end_time = $ lb - > time4de ( $ cttpos - > { $ id } - > { end_time } , "1" ) ;
2021-12-30 12:05:56 +01:00
print "<br />\n" ;
2022-04-30 08:12:55 +02:00
print $ q - > span ( { - style = > "$time_style" } , "Mietzeit: $start_time → $end_time" ) , "\n" ;
2021-12-30 12:05:56 +01:00
}
2022-12-10 15:47:22 +01:00
print "<br /><b>Bemerkung (Mietjournal)</b> $cttpos->{$id}->{txt23}\n" if ( $ cttpos - > { $ id } - > { txt23 } ) ;
2021-12-30 12:05:56 +01:00
print "</td>\n" ;
} elsif ( $ key =~ /txt/ ) {
2022-10-31 08:11:53 +01:00
print $ q - > td ( { - class = > 'tdtxt' } , "$cttpos->{$id}->{$key}" ) , "\n" ;
2021-12-30 12:05:56 +01:00
} elsif ( $ key =~ /int/ ) {
2022-10-31 08:11:53 +01:00
print $ q - > td ( { - class = > 'tdint' , - nowrap = > "1" } , " " ) , "\n" ;
2021-12-30 12:05:56 +01:00
}
2022-04-26 20:57:13 +02:00
} #end view position
2021-12-30 12:05:56 +01:00
}
}
} #foreach end
2023-02-10 12:04:30 +01:00
print $ q - > end_form , "\n" ; #en transposform
print $ q - > start_form ( - name = > 'set_stateform' ) , "\n" ;
2022-02-14 16:06:02 +01:00
if ( $ sum_parts19 && $ sum_parts19 != 0 ) {
2022-02-10 16:45:22 +01:00
$ sum_umst19 = $ sum_parts19 / $ diff19 * 19 ;
2022-05-01 18:31:03 +02:00
$ 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-14 16:06:02 +01:00
my $ sum_paid = $ sum_parts19 ;
2022-05-01 18:31:03 +02:00
$ sum_paid = $ pri - > round ( $ sum_paid ) ;
2021-12-30 12:05:56 +01:00
my $ sum_preauth = $ sum_paid || 0 ;
2022-05-01 18:31:03 +02:00
$ 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
2022-02-01 20:53:23 +01:00
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}" ;
}
}
}
}
2022-10-31 08:11:53 +01:00
my $ cs = $ tc - 3 ;
2022-02-01 20:53:23 +01:00
print "<tr>\n" ;
2022-10-31 08:11:53 +01:00
print "<td colspan='$cs'><div style='font-size:0.81em;padding:0.3em 0em;border:0px;'>$payment_text</div></td>\n" ;
print "<td style='font-size:1em;' colspan='3'>\n" ;
2021-12-30 12:05:56 +01:00
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 ( " " ) ;
2022-02-10 16:45:22 +01:00
if ( $ node_meta - > { node_name } !~ /steuerfrei/ ) {
2021-12-30 12:05:56 +01:00
print $ q - > Tr ( "\n" ) ; $ line_count2 + + ;
print $ q - > td ( { - class = > 'tdint' } , "Nettobetrag:" ) ;
2022-05-01 18:31:03 +02:00
print $ q - > td ( { - class = > 'tdint' , - nowrap = > "1" } , "$sum_netto19 €" ) ;
2021-12-30 12:05:56 +01:00
2022-02-14 16:06:02 +01:00
if ( $ sum_netto19 != 0 ) {
2021-12-30 12:05:56 +01:00
print $ q - > Tr ( "\n" ) ; $ line_count2 + + ;
2022-02-10 16:45:22 +01:00
#print $q->td({-class=>'tdint',-nowrap=>"1"},"$umst1619% UmSt auf $sum_netto19 €:");
print $ q - > td ( { - class = > 'tdint' , - nowrap = > "1" } , "19% UmSt auf $sum_netto19 €:" ) ;
2021-12-30 12:05:56 +01:00
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 ;
2022-10-31 08:11:53 +01:00
print $ q - > hidden ( - name = > 'owner' , - override = > '1' , - value = > "$users_dms->{u_id}" ) , "\n" ;
print $ q - > hidden ( - name = > 'offset' , - override = > '1' , - value = > "$R::offset" ) , "\n" if ( $ R:: offset ) ;
print $ q - > hidden ( - name = > 'c_id4trans' , - override = > '1' , - value = > "$ctt->{content_id}" ) , "\n" ;
print $ q - > hidden ( - name = > 'tpl_id4trans' , - override = > '1' , - value = > "$ctt->{template_id}" ) , "\n" ;
print $ q - > hidden ( - name = > 'offset' , - override = > '1' , - value = > "$R::offset" ) , "\n" if ( $ R:: offset ) ;
print $ q - > hidden ( - name = > 'limit' , - override = > '1' , - value = > "$R::limit" ) , "\n" if ( $ R:: limit ) ;
2021-12-30 12:05:56 +01:00
2022-10-31 08:11:53 +01:00
$ set_main_id = $ ctt - > { main_id } if ( $ ctt - > { main_id } && $ ctt - > { main_id } > "300000" ) ;
print $ q - > hidden ( - name = > 'set_main_id' , - value = > "$set_main_id" , - override = > '1' ) , "\n" ;
2021-12-30 12:05:56 +01:00
if ( $ users_dms - > { int03 } == 2 ) {
#only if user is also a primary DMS user with invoice rw
2022-10-11 07:00:25 +02:00
print $ q - > hidden ( - name = > 'printer_id' , - value = > "PDF" , - override = > '1' ) ;
2022-11-16 21:22:00 +01:00
my $ dbh_primary = $ dbt - > dbconnect_extern ( $ dbt - > { primary } - > { sharee_primary } - > { database } - > { dbname } ) ;
2021-12-30 12:05:56 +01:00
my $ users_dms_primary = { u_id = > 0 } ;
$ users_dms_primary = $ dbt - > select_users ( $ dbh_primary , $ users_dms - > { u_id } , "and int03=2" ) ;
2022-10-31 08:11:53 +01:00
if ( $ users_dms_primary - > { u_id } && $ users_dms_primary - > { int03 } == 2 ) {
2022-10-14 08:28:51 +02:00
my @ _paymentstate = split ( /\|/ , $ dbt - > { shareedms_conf } - > { payment_state } ) ;
2021-12-30 12:05:56 +01:00
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 ] ;
}
2023-01-27 06:55:30 +01:00
if ( $ ctt - > { state } && $ ctt - > { int01 } ) {
$ kind_of_payment = "$ctt->{state}" ;
2023-01-30 20:59:19 +01:00
} elsif ( $ ctt - > { int06 } && $ ctt - > { int06 } >= 3 || $ ctt - > { ct_name } =~ /\d-\d/ ) {
2023-01-27 06:55:30 +01:00
#default to Überw.
$ kind_of_payment = "$_paymentstate[2]" ;
}
2021-12-30 12:05:56 +01:00
2022-10-31 08:11:53 +01:00
if ( $ ctt - > { state } && $ ctt - > { int01 } ) {
$ ctt - > { int01 } =~ s/\./,/ ;
my $ style = "color:red;" if ( $ ctt - > { int01 } ne $ sum_paid ) ;
2023-02-10 12:04:30 +01:00
$ vibuchen_mtime = $ lb - > time4de ( $ ctt - > { pay_time } , 1 ) if ( $ ctt - > { pay_time } ) ;
my $ opos = "" ;
$ opos = "OPOS" if ( $ ctt - > { int14 } && $ ctt - > { int14 } > 0 ) ;
2023-02-12 08:23:52 +01:00
if ( $ ctt - > { int16 } && $ ctt - > { int16 } > 0 ) {
print $ q - > div ( { - style = > "padding:0.5em;font-size:0.81em;width:98%;text-align:right;" } , "<span style='color:red;'>$opos</span> Summe $ctt->{int01} € gebucht per \"$ctt->{state}\", Payone Saldo $ctt->{int16} € vom $vibuchen_mtime " ) , "\n" ;
} else {
print $ q - > div ( { - style = > "padding:0.5em;font-size:0.81em;width:98%;text-align:right;" } , "<span style='color:red;'>$opos</span> Summe $ctt->{int01} € gebucht per \"$ctt->{state}\" am $vibuchen_mtime " ) , "\n" ;
}
} else {
print $ q - > div ( { - style = > "padding:0.5em;font-size:0.81em;width:98%;text-align:right;" } , "<span style='color:silver;'>Summe ist nicht gebucht!</span>" ) , "\n" ;
2022-10-31 08:11:53 +01:00
}
2022-02-19 13:20:23 +01:00
2022-10-31 08:11:53 +01:00
if ( ! $ ctt - > { close_time } ) {
my $ send_invoice_checkbox = 1 ;
2023-01-27 06:55:30 +01:00
$ send_invoice_checkbox = 0 if ( $ ctt - > { txt30 } || $ ctt - > { ct_name } =~ /\d-\d/ ) ;
2023-02-12 08:23:52 +01:00
print $ q - > div ( { - class = > 'element6' , - style = > 'float:right;background-color:silver;' } , $ q - > b ( "$ctt->{txt00}" ) ,
2023-01-31 14:58:22 +01:00
": PDF drucken " , $ but - > checkbox ( "print_pdf" , "ct_trans" , "1" , "PDF drucken" , "" ) ,
" – eMail senden " , $ but - > checkbox ( "1" , "send_invoice" , "$send_invoice_checkbox" , "eMail $ctt->{txt00}" , "" ) ,
2023-03-22 08:24:08 +01:00
" – Zahlungsart/Status " ,
2023-01-30 20:59:19 +01:00
$ but - > selector ( "state" , "250px" , $ kind_of_payment , @ _paymentstate ) ,
$ but - > singlesubmit1 ( "set_state" , "buchen" ) ) ,
"\n" ;
2023-02-10 12:04:30 +01:00
2023-02-16 19:52:49 +01:00
if ( $ ctt - > { txt00 } ne "Storno" && $ ctt - > { ct_name } =~ /\d+-\d/ ) {
my @ s_valxx = ( "" ) ;
my $ s_hash = { } ;
$ s_hash = $ dbt - > { shareedms_conf } - > { warning_state } ;
foreach my $ s_key ( sort keys ( % { $ s_hash } ) ) {
2023-02-10 12:04:30 +01:00
push @ s_valxx , "$s_key:($s_key) $s_hash->{$s_key}" ;
2023-02-16 19:52:49 +01:00
}
my $ warn_time = $ ctt - > { warn_time } || "" ;
$ warn_time = $ lb - > time4de ( $ warn_time , 0 ) if ( $ warn_time ) ;
2023-02-10 12:04:30 +01:00
2023-02-16 19:52:49 +01:00
if ( $ ctt - > { ct_name } =~ /\d+-\d/ ) {
2023-02-10 12:04:30 +01:00
undef @ s_valxx [ 1 ] ;
undef @ s_valxx [ 2 ] ;
2023-02-16 19:52:49 +01:00
}
print $ q - > div ( { - class = > 'element6' , - style = > 'float:right;background-color:silver;' } , "Mahnstufe" , $ but - > selector_class ( "int06" , "" , "" , $ ctt - > { int06 } , @ s_valxx ) ,
2023-02-10 12:04:30 +01:00
"Fälligkeit" , $ q - > textfield ( - id = > 'datepicker3' , - class = > 'etxt' , - name = > "warn_time" , - default = > "$warn_time" , - override = > 1 , - size = > "8" , - maxlength = > 10 ) ) , "\n" ;
2023-02-16 19:52:49 +01:00
print $ q - > hidden ( - name = > 'int14' , - override = > '1' , - value = > "1" ) , "\n" ; #set OPOS
}
2023-02-10 12:04:30 +01:00
}
2021-12-30 12:05:56 +01:00
}
2023-02-10 12:04:30 +01:00
2022-11-24 12:50:23 +01:00
#disabled 2022-11-23, needs more testing. Add +10.- on preauth
2023-02-10 12:04:30 +01:00
if ( 1 == 2 && $ users_dms - > { u_id } == $ dbt - > { copri_conf } - > { superu_id } ) {
2022-02-22 08:31:35 +01:00
#further payone capture are only allowed if OPOS && sequence && TXID is set
if ( $ ctt - > { int14 } && $ ctt - > { int18 } && $ ctt - > { txt16 } ) {
2022-11-24 12:50:23 +01:00
print $ q - > div ( { - class = > 'element6' , - style = > 'clear:both;' } , "Test. Weitere Payone Einzüge über die vorhandene TXID $ctt->{txt16} (vorautorisiert Summe beachten) durch manuelle inkrement der Sequencenr mit +1" , $ q - > textfield ( - class = > 'etxt' , - name = > "payone_sequence" , - default = > "" , - override = > '1' , - size = > "1" , - maxlength = > 1 ) ) , "\n" ;
2022-02-22 08:31:35 +01:00
}
#Payone reset if OPOS and TXID
if ( $ ctt - > { int14 } && $ ctt - > { txt16 } ) {
2022-11-24 12:50:23 +01:00
print $ q - > div ( { - class = > 'element6' , - style = > 'clear:both;' } , "Test. Payone reset löscht den Vorgang mit der TXID $ctt->{txt16} und versucht einen erneuten Einzug" , $ but - > checkbox ( "1" , "payone_reset" , "0" , "Payone reset" , "" ) ) , "\n" ;
}
2022-02-22 08:31:35 +01:00
}
2021-12-30 12:05:56 +01:00
}
print $ q - > end_form ;
2022-02-18 20:23:45 +01:00
my $ praefix = "$ctt->{txt00}-$varenv{praefix}" ;
2021-12-30 12:05:56 +01:00
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" ;
2023-01-17 20:43:36 +01:00
} elsif ( - f "$varenv{pdfinvoice}/$praefix-$ctt->{ct_name}.pdf" ) {
2021-12-30 12:05:56 +01:00
print $ q - > start_form ( ) , "\n" ;
2022-10-31 08:11:53 +01:00
print $ q - > hidden ( - name = > 'offset' , - override = > '1' , - value = > "$R::offset" ) , "\n" if ( $ R:: offset ) ;
print $ q - > hidden ( - name = > 'limit' , - override = > '1' , - value = > "$R::limit" ) , "\n" if ( $ R:: limit ) ;
print $ q - > div ( { - style = > "padding:0.5em;font-size:0.81em;width:98%;text-align:right;" } , "eMail wurde nicht versandt! $ctt->{txt00} eMail " , $ but - > singlesubmit1 ( "ct_trans" , "send_invoice_again" , "send_invoice_again" ) ) , "\n" if ( $ users_dms - > { u_id } == $ dbt - > { copri_conf } - > { superu_id } ) ;
2021-12-30 12:05:56 +01:00
print $ q - > end_form ;
}
2022-09-16 16:33:52 +02:00
if ( - f "$varenv{basedir}/pdfinvoice/$praefix-$ctt->{ct_name}.pdf" ) {
2023-02-12 08:23:52 +01:00
print $ q - > div ( { - style = > 'padding:0.5em;font-size:0.91em;width:98%;text-align:right;' } , "Download: " , $ q - > a ( { - href = > "$varenv{wwwhost}/FileOut?file=$praefix-$ctt->{ct_name}.pdf&sessionid=$coo" , - target = > "_blank" , - type = > 'application/octet-stream' , - style = > 'text-decoration:underline;' } , "$praefix-$ctt->{ct_name}.pdf" ) ) , "\n" ;
2021-12-30 12:05:56 +01:00
}
2022-10-31 08:11:53 +01:00
$ db - > updater ( "contenttrans" , "c_id" , "$ctt->{content_id}" , "txt20" , "$accounting_start - $accounting_end" , "" , "" , "" , "" , "no_time" ) if ( ! $ int05 && $ accounting_start && $ accounting_end ) ;
$ db - > updater ( "contenttrans" , "c_id" , "$ctt->{content_id}" , "int15" , "$sum_preauth" , "" , "" , "" , "" , "no_time" ) if ( $ sum_preauth || $ sum_preauth == 0 ) ;
2021-12-30 12:05:56 +01:00
return "$line_count2" ;
}
1 ;