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

165 lines
8.7 KiB
Perl
Raw Normal View History

2021-12-30 12:05:56 +01:00
package Anmelden;
#
# SPDX-License-Identifier: AGPL-3.0-or-later
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
#
use strict;
use warnings;
use CGI ':standard';
use Lib::Config;
use Mod::Buttons;
use Mod::Libenz;
use Mod::Libenzdb;
use Mod::DBtank;
use Mod::APIfunc;
use Mod::Pricing;
sub new {
my $class = shift;
my $self = {};
bless($self,$class);
return $self;
}
#Template
sub tpl(){
my $node_meta = shift;
my $users_dms = shift || "";
my $mode = shift || "";
my $varenv = shift;
my $users_sharee = shift || "";
my $return = shift || "";
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 $pri = new Pricing;
my $script = $q->script_name();
my $user_agent = $q->user_agent();
my $path_info = $q->path_info();
my $path = $path_info;
my $clientIP = $q->remote_addr();
#with meta_host,
if("$varenv->{metahost}"){
$path = "$script" . "$path_info";
$script="";
}
my %ib = $but->ibuttons_arch();
my $tpl = $db->get_tpl($node_meta->{tpl_id});
my @tpl_order = split /,/,$tpl->{tpl_order};
my $coo = $q->cookie(-name=>'domcookie') || "";
my @viewsel = split /\//,$1 if($path =~ /^\/(.*)/);
my $bgcolor1 = "009899";#sharee
#my $bgcolor1 = "e2001a";
$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});
print "<div id='ContentLogin'>\n";
if($viewsel[1] eq "Account"){
if($R::sharee_edit =~ /delete_account/){
my $dummy;
}elsif($R::sharee_edit =~ /password_forgotten/){
print $q->div({-class=>'content2'}, "Es wurde eine Nachricht mit zurueckgesetzten Passwort an <b>$R::email</b> gesendet. Ersetzen Sie bitte das gesendete Passwort durch ein individuelles. Das neue Passwort muss min. 8 Zeichen mit 2 Zeichen ausserhalb des Alphabets beinhalten."),"\n";
}
}
print $q->start_multipart_form(-id=>'authform', -name=>'loginscreen'),"\n";
print $q->hidden(-name=>"sessionid",-override=>1,-value=>"$R::sessionid") if($R::sessionid);
print $q->hidden(-name=>"clientIP",-override=>1,-value=>"$clientIP");
print "<div class='form-group'>\n";
if($users_sharee->{c_id} && !$users_sharee->{int04} && $R::sharee_edit !~ /delete_account/){
print $q->div({-class=>'content1',-style=>'padding-top:1em;'}, "E-Mail Bestätigung"),"\n";
print $q->div({-class=>'content2'}, "Wir haben eine Nachricht an Ihre angegebene E-Mail Adresse versandt. Nach erfolgreicher Bestätigung können Sie unser Mietradsystem nutzen."),"\n";
print $q->div({-class=>'content2'},$q->a({-href=>"$varenv->{wwwhost}?sharee_edit=send_email"},"Senden wiederholen")),"\n";
#Account löschen
}elsif($viewsel[1] eq "Account" && $R::sharee_edit =~ /delete_account/){
if($R::sharee_edit eq "delete_account1" && $users_sharee->{c_id}){
#
my ($ctpos,$operator_hash) = $apif->user_rentals_history($q,$users_sharee);
my $ctpos_count = 0;
my $sum = 0;
foreach my $id (keys(%$ctpos)){
$ctpos_count++;
my $gesamt = 0;
my $rabatt = "";
($gesamt,$rabatt) = $pri->price2calc($ctpos->{$id});
$sum += $gesamt;
}
$sum = $lb->round($sum);
if($ctpos_count > 0 && $sum > 0){
print $q->div({-class=>'content2'}, "Ihr Konto ist nicht ausgeglichen ($sum). Bitte kontaktieren Sie uns damit wir Ihre Rechnungstellung beschleunigen. Anschließend können Sie Ihren Account löschen. Danke für Ihr Verständnis"),"\n";
print $q->div({-style=>'margin-top:1em;'},$q->a({-class=>"btn btn-primary btn-lg btn-block",-href=>'javascript:history.back()'}, "zurück")),"\n";
}else{
print $q->div({-class=>'content2'}, "Wollen Sie wirklich Ihre Daten löschen?"),"\n";
print $q->div({-style=>'margin-top:1em;'},"<button type='submit' name='sharee_edit' value='delete_account2' class='btn btn-primary btn-lg btn-block'>Ja</button>"),"\n";
}
}elsif($R::sharee_edit eq "delete_account2" && $users_sharee->{c_id}){
my $rows = 0;
$rows = $dbt->update_operatorsloop($varenv->{dbname},$users_sharee->{c_id},"delete");#only operator
$rows += $dbt->delete_content("","contentadr",$users_sharee->{c_id});#final delete on primary
if($rows >= 1){
print $q->div({-class=>'content2'}, "Ihr Zugang wurde gelöscht.<br />Auf Wiedersehen."),"\n";
}else{
print $q->div({-class=>'content2'}, "Anscheinend ist hier etwas schief gelaufen.<br />Bitte kontaktieren Sie uns damit wir das Problem lösen können."),"\n";
}
}
#Passwort senden
}elsif($viewsel[1] eq "Account" && !$R::password_forgotten){
print $q->div({-class=>'content2'}, "Wir benötigen dazu Ihre registrierte E-Mail Adresse."),"\n";
print $q->label({-for=>'Email'},""),"\n";
print $q->textfield(-class=>'form-control', -name=>'email', -value=>'', -override=>1, -type=>'email',-class=>'form-control', -id=>'Email', -placeholder=>'E-Mail Adresse', -required=>1, -autofocus=>1),"\n";
print $q->hidden(-name=>'password_forgotten',-value=>"1");
print $q->div({-style=>'margin-top:1em;'},"<button type='submit' name='sharee_edit' value='password_forgotten' class='btn btn-primary btn-lg btn-block' style='border:1px solid #$bgcolor1;background-color:#$bgcolor1;'>Passwort E-Mail senden</button>"),"\n";
#Login
}elsif(!$R::password_forgotten){
if($R::conflict_failure){
print $q->div({-class=>'content2',-style=>'color:#c83434'},"Registrierungsfehler!"),"\n";
print $q->div({-class=>'content2'}, "Die Registrierung wurde abgebrochen weil bereits ein Account mit Ihrer e-Mail oder Telefonnr. existiert. Bitte kontaktieren Sie uns falls hier ein Missbrauch vorliegt. Falls Sie ein neues Passwort benötigen drücken Sie bitte:"),"\n";
print $q->div({-style=>'margin-top:1em;'},$q->a({-class=>"", -style=>"color:#$bgcolor1;font-size:1.1em;text-decoration:underline;", -role=>"button", -href=>"$varenv->{wwwhost}/$varenv->{mandant}/Account"}, "Passwort vergessen?")),"\n";
}
print $q->div({-class=>'content2'}, "Dein Zugang zum Lastenradmietsystem"),"\n";
print $q->div({-style=>'color:#c83434'},"Login verweigert. ",$q->a({-class=>"", -style=>"color:gray;", -role=>"button", -href=>"$varenv->{wwwhost}/$varenv->{mandant}/Account"}, "Passwort vergessen?")),"\n" if($R::failure);
print $q->div({-style=>'color:#c83434'},"Login verweigert. "),"\n" if($R::basicauthfailure);
print $q->label({-for=>'Email'},""),"\n";
print $q->textfield(-class=>'form-control', -name=>'user_id', -value=>'', -override=>1, -type=>'email',-class=>'form-control', -id=>'Email', -placeholder=>'E-Mail Adresse', -required=>1, -autofocus=>1),"\n";
print $q->label({-for=>'PW'},""),"\n";
print $q->password_field(-class=>'form-control', -name=>'user_pw', -value=>'', -override=>1, -type=>'password',-class=>'form-control', -id=>'txt04', -placeholder=>'Passwort', -required=>1),"\n";
print $q->div({-style=>'text-align:left;color:grey;'}, "<input type='checkbox' onclick='show_passwd()'>", "Passwort anzeigen"),"\n";
#js auth
# print $q->div({-style=>'margin-top:1em;'},"<div type='text' onClick='javascript:request_apiauth(\"$varenv->{wwwhost}\",\"/$varenv->{mandant}/$varenv->{profile}\")' name='login_sharee' value='Login' class='btn btn-primary btn-lg btn-block'>Anmelden</div>"),"\n";
print $q->div({-style=>'margin-top:1em;'},"<button type='submit' name='login_sharee' value='Login' class='btn btn-primary btn-lg btn-block' style='border:1px solid #$bgcolor1;background-color:#$bgcolor1;'>Anmelden</button>"),"\n";
print $q->div({-style=>'margin-top:1em;'},$q->a({-class=>"btn btn-default btn-lg btn-block", -style=>"color:#$bgcolor1;", -role=>"button", -href=>"$varenv->{wwwhost}/$varenv->{mandant}/Account/$varenv->{accounting_1}"}, "Registrieren")),"\n";
print $q->div({-class=>'content2'}, "Zur Information! Falls Sie bereits einen \"konrad\" oder \"TINK\" Account besitzen, können Sie mit Ihren bestehendem Account die Nutzung beider Mietradsysteme einstellen! Einfach dazu die entsprechende AGB bestätigen."),"\n" if($varenv->{wwwhost} =~ /tink|konrad/);
print $q->div({-style=>'margin-top:1em;'},$q->a({-class=>"", -style=>"color:#$bgcolor1;font-size:1.1em;text-decoration:underline;", -role=>"button", -href=>"$varenv->{wwwhost}/$varenv->{mandant}/Account"}, "Passwort vergessen?")),"\n";
}
print "</div>\n";
print $q->end_form,"\n";
print $q->div({-style=>'position:fixed;bottom:2%;right:2%;z-index:10;font-size:13px;'},"--> $varenv->{syshost} | $varenv->{merchant_id} | $bgcolor1 | $node_meta->{tpl_name} | $users_sharee->{c_id}"),"\n" if($users_sharee->{c_id} eq $dbt->{copri_conf}->{superu_id} || $dbt->{copri_conf}->{stage} eq "test");
print "</div>";
}
1;