sharee.bike/copri4/shareeapp-operator/src/Tpl/PayoneSEPA.pm

179 lines
7.3 KiB
Perl
Raw Normal View History

2021-12-30 12:05:56 +01:00
package PayoneSEPA;
#
# SPDX-License-Identifier: AGPL-3.0-or-later
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
#
use strict;
use warnings;
use POSIX;
use CGI ':standard';
use Mod::Buttons;
use Mod::Basework;
2021-12-30 12:05:56 +01:00
use Mod::Shareework;
use Mod::DBtank;
use Mod::Pricing;
2021-12-30 12:05:56 +01:00
use Sys::Hostname;
sub new {
my $class = shift;
my $self = {};
bless($self,$class);
return $self;
}
#Template
sub tpl(){
my $self = shift;
my $tpl_id = shift;
my $node_meta = shift;
my $users_dms = shift || "";
my $varenv = shift;
my $users_sharee = shift || "";
my $feedb = shift || "";
2021-12-30 12:05:56 +01:00
my $q = new CGI;
my $bw = new Basework;
2021-12-30 12:05:56 +01:00
my $tk = new Shareework;
my $dbt = new DBtank;
my $pri = new Pricing;
2021-12-30 12:05:56 +01:00
my $but = new Buttons;
$q->import_names('R');
my @keywords = $q->param;
2022-01-09 18:31:20 +01:00
my $dbh = "";
my $bgcolor1 = "009899";#sharee
$bgcolor1 = $dbt->{website}->{$varenv->{syshost}}->{bgcolor1} if($dbt->{website}->{$varenv->{syshost}}->{bgcolor1});
$bgcolor1 = $dbt->{merchant_ids}->{$varenv->{merchant_id}}->{bgcolor1} if($dbt->{merchant_ids}->{$varenv->{merchant_id}}->{bgcolor1});
2021-12-30 12:05:56 +01:00
my $coo = $q->cookie(-name=>'domcookie') || $R::sessionid;
my $ctadr = $users_sharee if(ref($users_sharee) eq "HASH" && $users_sharee->{c_id});
my $payable_check=0;
$payable_check = $bw->isuser_rentable($ctadr,$varenv);
2021-12-30 12:05:56 +01:00
2022-01-09 18:31:20 +01:00
my $tpl = $dbt->get_tpl($dbh,$tpl_id);
2021-12-30 12:05:56 +01:00
my @tpl_order = split /,/,$tpl->{tpl_order};
print $q->start_form(),"\n";
print $q->hidden(-name=>"sessionid",-override=>1,-value=>"$R::sessionid");
print $q->hidden(-name=>"tinkc_id",-override=>1,-value=>"$ctadr->{c_id}");
print $q->hidden(-name=>"request",-override=>1,-value=>"managemandate");
print "<div class='form-group' style='clear:both;'>\n";
#SEPA
if($tpl_id == 309){
print $q->div({-class=>'content_title3'},"$varenv->{cms}->{'iframe-bank-account'}->{txt}"),"\n";
print $q->div({-class=>'content2'}, "$varenv->{cms}->{'iframe-sepa-mandat-prolog'}->{txt}"),"\n";
#print $q->div({-class=>'content2'}, "Zur Validierung Ihrer Zahlungsdaten wird eine 1,- € Testbuchung vorgenommen. Wir werden nach erfolgreicher Abbuchung den Betrag als Mietgutschrift in Ihrem Account hinterlegen."),"\n";
2021-12-30 12:05:56 +01:00
foreach (@tpl_order){
2021-12-30 12:05:56 +01:00
my ($key,$des,$size) = split /=/,$_;
$ctadr->{$key} = $q->unescapeHTML("$ctadr->{$key}");
my $label_des="";
my $red = "#c83434";
my $required="required";
if($key eq "txt22"){
if($R::IBAN){
$label_des = "<span style=color:$red>IBAN error</span>";
2021-12-30 12:05:56 +01:00
$ctadr->{$key} = $R::IBAN;
}
if($R::failure eq $key){
$varenv->{cms}->{'iframe-correct-input'}->{txt} =~ s/::input::/$des/;
$label_des = "<span style=color:$red>$varenv->{cms}->{'iframe-correct-input'}->{txt}</span>";
2021-12-30 12:05:56 +01:00
}
print $q->label({-for=>"$key", -style=>'padding-top:1.5em;'},"$label_des"),"\n";
print "<input id='$key' type='text' class='form-control' name='$key' override=1 value='$ctadr->{$key}' placeholder='$des' $required />\n";
}elsif($key eq "txt23"){
print $q->label({-for=>"$key", -style=>'padding-top:1.5em;'},"$label_des"),"\n";
print "<input id='$key' type='text' class='form-control' name='$key' override=1 value='$ctadr->{$key}' placeholder='$des' $required />\n";
#------------------------
}elsif($key =~ /int03/ && $size eq "checkbox"){
if(!$payable_check){
2021-12-30 12:05:56 +01:00
my $int03 = "";
#$int03 = $ctadr->{$key} if($ctadr->{$key} == 1);
print $q->div({-style=>'margin:10px 0;'},"$varenv->{cms}->{'iframe-sepa-mandat'}->{txt}"),"\n";
2021-12-30 12:05:56 +01:00
if($ctadr->{txt27} !~ /active|pending/ && $R::failure eq $key){
$varenv->{cms}->{'iframe-please-confirm'}->{txt} =~ s/::value::/$des/;
$label_des = "<span style=color:$red>$varenv->{cms}->{'iframe-please-confirm'}->{txt}</span>";
2021-12-30 12:05:56 +01:00
print $q->label({-for=>"$key", -style=>'padding-top:10px;'},"$label_des"),"\n";
}
my $des = "$varenv->{cms}->{'iframe-sepa-mandat-accept'}->{txt}";
2021-12-30 12:05:56 +01:00
print $q->div({-id=>"$key"},$but->checkbox("1","$key","$int03","","$required"), " $des"),"\n";
}else{
#if payone fails/error
if($ctadr->{txt27} =~ /active|pending/){
2021-12-30 12:05:56 +01:00
if($ctadr->{ct_name} && ($ctadr->{ct_name} =~ /PO-/ || $ctadr->{ct_name} =~ /TM-/) && $coo){
my $webtarget = "_blank";
my $dtext = "";
if($varenv->{syshost} =~ /app/){
$webtarget = "_self";
$dtext = "<br /><br />$varenv->{cms}->{'iframe-pdf-download-info'}->{txt}";
2021-12-30 12:05:56 +01:00
}
2022-10-04 12:14:03 +02:00
if( -f "$varenv->{basedir}/pdfinvoice/SEPA-Lastschriftmandat-$varenv->{praefix}-$ctadr->{ct_name}.pdf"){
2022-12-10 15:47:22 +01:00
print $q->div({-style=>'padding:10px;margin:10px 0;'},$q->a({-href=>"$varenv->{wwwhost}/FileOut?file=SEPA-Lastschriftmandat-$varenv->{praefix}-$ctadr->{ct_name}.pdf&sessionid=$coo", -target=>"$webtarget" , -type=>'application/octet-stream', -style=>'text-decoration:underline;font-size:1.1em;'}, $q->span({-class=>"bi bi-file-earmark-pdf"}), "SEPA-Lastschriftmandat.pdf"),"$dtext"),"\n";
2022-10-04 12:14:03 +02:00
}
2021-12-30 12:05:56 +01:00
}else{
print $q->div({-style=>'padding:10px;margin:10px 0;border:1px solid silver;color:#c83434;'},"$varenv->{cms}->{'iframe-mandate-problem'}->{txt}"),"\n";
2021-12-30 12:05:56 +01:00
}
}elsif($ctadr->{txt22}){ #if IBAN but no mandat_status
print $q->div({-style=>'padding:10px;margin:10px 0;border:1px solid silver;color:#c83434;'}, "$varenv->{cms}->{'iframe-mandate-error'}->{txt}"),"\n";
2021-12-30 12:05:56 +01:00
}
}
}
}
print $q->div({-style=>'margin-top:1em;text-align:center;'},"<button type='submit' name='sharee_edit' value='save_account' class='btn btn-primary btn-lg btn-block' style='border:1px solid #$bgcolor1;background-color:#$bgcolor1;'>$varenv->{cms}->{'iframe-next'}->{txt}</button>"),"\n";
2021-12-30 12:05:56 +01:00
}#end SEPA
#prepay
elsif($tpl_id == 313){
my $posref = {
table => "contenttrans",
table_pos => "contenttranspos",
fetch => "all",
keyfield => "c_id",
ca_id => "$ctadr->{c_id}",
'ct.state' => "is::null",
'ct.int14' => "is::null",
};
my $cttpos = { c_id => 0 };
$cttpos = $dbt->collect_post($dbh,$posref);
#TODO negative counting booked operator invoices
my $total_prepaid = 0;
my $prepay_id = 0;
foreach my $id (sort { $cttpos->{$b}->{c_id} <=> $cttpos->{$a}->{c_id} } keys(%$cttpos)){
#print $cttpos->{$id}->{barcode} . ":" . $cttpos->{$id}->{int02},"<br>";
if($cttpos->{$id}->{int02} > 0){
$total_prepaid += $cttpos->{$id}->{int02};
}
if($cttpos->{$id}->{int02} == 0){
$prepay_id = $cttpos->{$id}->{barcode};
}
}
print $q->div({-class=>'content_title3'},"$varenv->{cms}->{'iframe-prepay-account'}->{txt}"),"\n";
if(!$prepay_id){
print $q->div({-class=>'content2'}, "$varenv->{cms}->{'iframe-failure-contact-hotline'}->{txt} $prepay_id"),"\n";
}else{
$total_prepaid = sprintf('%.2f',$total_prepaid);
$total_prepaid =~ s/\./,/;
$varenv->{cms}->{'iframe-prepay-prolog'}->{txt} =~ s/\n/<br \/>/g;
$varenv->{cms}->{'iframe-prepay-prolog'}->{txt} =~ s/::total_prepaid::/<b>$total_prepaid €<\/b>/g;
$varenv->{cms}->{'iframe-prepay-prolog'}->{txt} =~ s/::app_name::/<b>$dbt->{merchant_ids}->{$varenv->{merchant_id}}->{app_name}<\/b>/g;
$varenv->{cms}->{'iframe-prepay-prolog'}->{txt} =~ s/::prepaid_id::/<b>$prepay_id<\/b>/g;
print $q->div({-class=>'content2'}, "$varenv->{cms}->{'iframe-prepay-prolog'}->{txt}"),"\n";
}
}
2021-12-30 12:05:56 +01:00
print "</div>\n";
print $q->end_form,"\n";
}
1;