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::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 || "" ;
2023-01-17 20:43:36 +01:00
my $ feedb = shift || "" ;
2021-12-30 12:05:56 +01:00
my $ q = new CGI ;
my $ cf = new Config ;
my $ lb = new Libenz ;
my $ dbt = new DBtank ;
my $ apif = new APIfunc ;
my $ but = new Buttons ;
my $ pri = new Pricing ;
2022-11-17 20:36:53 +01:00
my $ dbh = "" ;
2021-12-30 12:05:56 +01:00
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 = "" ;
}
2022-11-17 20:36:53 +01:00
my $ tpl = $ dbt - > get_tpl ( $ dbh , $ node_meta - > { tpl_id } ) ;
2021-12-30 12:05:56 +01:00
my @ tpl_order = split /,/ , $ tpl - > { tpl_order } ;
my $ coo = $ q - > cookie ( - name = > 'domcookie' ) || "" ;
my @ viewsel = split /\// , $ 1 if ( $ path =~ /^\/(.*)/ ) ;
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 } ) ;
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" ;
2022-01-02 14:57:19 +01:00
print $ q - > hidden ( - name = > "merchant_id" , - override = > 1 , - value = > "$varenv->{merchant_id}" ) if ( $ varenv - > { merchant_id } ) ;
2021-12-30 12:05:56 +01:00
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" ;
2023-03-10 11:35:56 +01:00
if ( $ viewsel [ 1 ] eq "Account" && $ R:: sharee_edit =~ /delete_account/ ) {
2021-12-30 12:05:56 +01:00
if ( $ R:: sharee_edit eq "delete_account1" && $ users_sharee - > { c_id } ) {
#
2022-05-19 16:00:41 +02:00
my ( $ cttpos , $ operator_hash ) = $ apif - > user_rentals_history ( $ q , $ users_sharee ) ;
my $ pricing = { } ;
my $ counting = { } ;
my $ cttpos_count = 0 ;
2021-12-30 12:05:56 +01:00
my $ sum = 0 ;
2022-05-19 16:00:41 +02:00
foreach my $ id ( keys ( %$ cttpos ) ) {
$ cttpos_count + + ;
if ( $ cttpos - > { $ id } - > { int35 } && $ cttpos - > { $ id } - > { start_time } && $ cttpos - > { $ id } - > { end_time } ) {
( $ pricing , $ counting ) = $ pri - > counting_rental ( $ varenv , $ cttpos - > { $ id } , "calc_price" ) ;
$ sum += $ pricing - > { total_price } ;
} else {
my ( $ gesamt , $ rabatt ) = $ pri - > price2calc ( $ cttpos - > { $ id } ) ;
$ sum += $ gesamt ;
}
2021-12-30 12:05:56 +01:00
}
$ sum = $ lb - > round ( $ sum ) ;
2022-05-19 16:00:41 +02:00
$ sum = sprintf ( '%.2f' , $ sum ) ;
$ sum =~ s/\./,/ ;
if ( $ cttpos_count > 0 && $ sum > 0 ) {
print $ q - > div ( { - class = > 'content2' } , "Ihr Konto ist nicht ausgeglichen, es ist ein Betrag von $sum € offen. Bitte kontaktieren Sie uns unter <a href='mailto:post\@sharee.bike'>post\@sharee.bike</a> damit wir die Rechnungstellung für sie beschleunigen. Anschließend können Sie Ihren Account löschen. Danke für Ihr Verständnis" ) , "\n" ;
2022-03-30 13:06:39 +02:00
print $ q - > div ( { - style = > 'margin-top:1em;text-align:center;' } , $ q - > a ( { - class = > "btn btn-primary btn-lg btn-block" , - href = > 'javascript:history.back()' , - style = > "border:1px solid #$bgcolor1;background-color:#$bgcolor1;color:#fffffe;" } , "zurück" ) ) , "\n" ;
2021-12-30 12:05:56 +01:00
} else {
print $ q - > div ( { - class = > 'content2' } , "Wollen Sie wirklich Ihre Daten löschen?" ) , "\n" ;
2022-03-30 13:06:39 +02:00
print $ q - > div ( { - style = > 'margin-top:1em;text-align:center;' } , "<button type='submit' name='sharee_edit' value='delete_account2' class='btn btn-primary btn-lg btn-block' style='border:1px solid #$bgcolor1;background-color:#$bgcolor1;color:#fffffe;'>Ja</button>" ) , "\n" ;
2021-12-30 12:05:56 +01:00
}
} 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" ) ;
2022-03-30 13:06:39 +02:00
print $ q - > div ( { - style = > 'margin-top:1em;text-align:center;' } , "<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;color:#fffffe;'>Passwort E-Mail senden</button>" ) , "\n" ;
2021-12-30 12:05:56 +01:00
#Login
} elsif ( ! $ R:: password_forgotten ) {
if ( $ R:: conflict_failure ) {
2022-01-15 12:03:21 +01:00
print $ q - > div ( { - class = > 'content2' , - style = > 'color:#c83434' } , "Uhps - da hat etwas nicht funktioniert!" ) , "\n" ;
print $ q - > div ( { - class = > 'content2' } , " Entweder sind die von Ihnen eingetragenen Daten unvollständig ; dann loggen Sie sich bitte mit der von Ihnen hinterlegten E - Mail - Adresse und Passwort wieder ein und vervollständigen das Formular . < br /><br / >
Oder es besteht bereits ein Account mit Ihrer E - Mail - Adresse oder Telefonnummer und Sie haben Ihr Passwort vergessen ? Dann schicken wir Ihnen gerne ein neues Passwort zu: klicken Sie auf < br / > ")," \ n " ;
#Bitte beachten Sie: nach 60 Minuten verfallen unbestätigte Formulare und Zugangsdaten.
2022-03-24 14:58:12 +01:00
print $ q - > div ( $ q - > a ( { - style = > "background-color:#ffffff;color:#$bgcolor1;font-size:1.1em;text-decoration:none;" , - role = > 'button' , - href = > "$varenv->{wwwhost}/$varenv->{mandant}/Account" } , 'Neues Passwort anfordern' ) ) , "\n" ;
2022-01-15 12:03:21 +01:00
print $ q - > div ( { - class = > 'content2' } , "Sollte es noch immer nicht klappen, dann nehmen Sie Kontakt mit uns auf." ) , "\n" ;
2021-12-30 12:05:56 +01:00
}
2022-01-15 12:03:21 +01:00
print $ q - > div ( { - class = > 'content2' , - style = > 'font-size:1.2em;' } , "Anmelden" ) , "\n" ;
2022-01-09 18:31:20 +01:00
print $ q - > div ( { - style = > 'color:#c83434' } , "Login verweigert. " , $ q - > a ( { - class = > "" , - style = > "color:gray;" , - role = > "button" , - href = > "$varenv->{wwwhost}/$varenv->{mandant}/Account" } , "Neues Passwort anfordern" ) ) , "\n" if ( $ R:: failure ) ;
2021-12-30 12:05:56 +01:00
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";
2022-03-30 13:06:39 +02:00
print $ q - > div ( { - style = > 'margin-top:1em;text-align:center;' } , "<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" ;
2021-12-30 12:05:56 +01:00
2022-03-30 13:06:39 +02:00
print $ q - > div ( { - style = > 'margin-top:1em;text-align:center;' } , $ q - > a ( { - class = > "btn btn-default btn-lg btn-block" , - style = > "background-color:#ffffff;color:#$bgcolor1;" , - role = > "button" , - href = > "$varenv->{wwwhost}/$varenv->{mandant}/Account/$varenv->{accounting_1}" } , "Neues Nutzerkonto eröffnen" ) ) , "\n" ;
2021-12-30 12:05:56 +01:00
2022-03-30 13:06:39 +02:00
print $ q - > div ( { - style = > 'margin-top:1em;text-align:center;' } , $ q - > a ( { - class = > "" , - style = > "background-color:#ffffff;color:#$bgcolor1;font-size:1.1em;text-decoration:underline;" , - role = > "button" , - href = > "$varenv->{wwwhost}/$varenv->{mandant}/Account" } , "Neues Passwort anfordern" ) ) , "\n" ;
2021-12-30 12:05:56 +01:00
}
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 ;