mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2024-11-05 02:36:30 +01:00
262 lines
8.4 KiB
Perl
262 lines
8.4 KiB
Perl
package ModalboxDialog;
|
|
#
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
|
|
#
|
|
use strict;
|
|
use warnings;
|
|
|
|
use CGI::Cookie ();
|
|
use CGI ':standard';
|
|
use DateTime;
|
|
use DateTime::Format::Pg;
|
|
use Lib::Config;
|
|
use Mod::Buttons;
|
|
use Mod::DBtank;
|
|
use Mod::APIfunc;
|
|
use Mod::Libenzdb;
|
|
|
|
sub new {
|
|
my $class = shift;
|
|
my $self = {};
|
|
bless($self,$class);
|
|
return $self;
|
|
}
|
|
|
|
sub mobox2(){
|
|
my $node_meta = shift;
|
|
my $users_dms = shift || "";
|
|
my $mode = shift || "";
|
|
my $varenv = shift;
|
|
my $users_sharee = shift || "";
|
|
my $return = shift || "";
|
|
my $ask_radID = shift || "";
|
|
|
|
my $q = new CGI;
|
|
my $cf = new Config;
|
|
my $dbt = new DBtank;
|
|
my $apif = new APIfunc;
|
|
|
|
my $db = new Libenzdb;
|
|
my $but = new Buttons;
|
|
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 $dbh = "";
|
|
my $bg_color = "white";
|
|
my $bg_color2 = $varenv->{brand_color} || "";
|
|
|
|
my $session="";
|
|
my $session_and="";
|
|
if(length($R::sessionid) > 20){
|
|
$session = "?sessionid=$R::sessionid";
|
|
$session_and = "&sessionid=$R::sessionid";
|
|
}
|
|
|
|
my $ctadr = $users_sharee if(ref($users_sharee) eq "HASH" && $users_sharee->{c_id});
|
|
|
|
my $main_ids;
|
|
my ($bike_group,$user_group,$tariff_content,$user_tour) = $apif->fetch_tariff($ctadr,"");
|
|
$main_ids = join(",",@{$bike_group});
|
|
$main_ids =~ s/[a-z_]+//ig;
|
|
|
|
my $title = "";
|
|
my $ct = {};
|
|
if($ask_radID){
|
|
my $pref_cc = {
|
|
table => "content",
|
|
fetch => "one",
|
|
main_id => "IN::($main_ids)",
|
|
barcode => $ask_radID,
|
|
int10 => 1,
|
|
};
|
|
|
|
$ct = $dbt->fetch_record($dbh,$pref_cc) if($ask_radID && $main_ids);
|
|
$title = "Fahrrad Buchungsbestätigung";
|
|
}
|
|
|
|
my $height = "250";
|
|
my $width = "400";
|
|
|
|
print<<EOF
|
|
<style>
|
|
.ui-dialog .ui-dialog-content {
|
|
background: $bg_color;
|
|
}
|
|
.ui-dialog > .ui-widget-header {
|
|
color:$varenv->{color};
|
|
font-weight:normal;
|
|
border:1px solid $bg_color2;
|
|
background: $bg_color2;
|
|
}
|
|
.ui-widget-overlay {
|
|
background: #666 url("$varenv->{metahost}/jquery-ui/images/ui-bg_diagonals-thick_20_666666_40x40.png") 50% 50% repeat;
|
|
opacity: .5;
|
|
filter: Alpha(Opacity=50);
|
|
}
|
|
</style>
|
|
EOF
|
|
;
|
|
|
|
#int04 != 1 --> no mailACK
|
|
#int13 != 1 --> no telACK
|
|
#int01 != 3 --> no sync
|
|
#int12 == 1 --> Vde
|
|
|
|
my $ctadr_int13 = 1;#default to activ
|
|
if($varenv->{telAck_startdate} && $ctadr->{mtime}){
|
|
my ($ty,$tm,$td) = split(/-/,$varenv->{telAck_startdate});
|
|
my $dt1telAck_start = DateTime->new(year => $ty, month => $tm, day => $td);
|
|
my $dt2mtime = DateTime::Format::Pg->parse_datetime($ctadr->{mtime});
|
|
#will be only evaluated if mtime never than global conf
|
|
if($ctadr->{owner} == 197 && $dt2mtime > $dt1telAck_start){
|
|
$ctadr_int13 = $ctadr->{int13};
|
|
}
|
|
}
|
|
if($node_meta->{main_id} && $ctadr->{c_id} && ($ctadr->{int04} != 1 || $ctadr_int13 != 1 || $ctadr->{int12} || $ask_radID)){
|
|
|
|
|
|
print<<EOF
|
|
<script>
|
|
\$(function() {
|
|
\$( "#dialog-form2" )
|
|
.css("background-color","$bg_color")
|
|
.dialog({
|
|
height: $height,
|
|
width: $width,
|
|
closeOnEscape: false,
|
|
modal: true
|
|
});
|
|
\$('.ui-widget-overlay').click(function() {
|
|
\$(".ui-dialog-titlebar-close").trigger('click');});
|
|
|
|
\$( "#btn_no1" ).click(function() {
|
|
\$( "#dialog-form2" ).dialog( "close" );
|
|
});
|
|
\$( "#btn_no2" ).click(function() {
|
|
\$( "#dialog-form2" ).dialog( "close" );
|
|
});
|
|
|
|
\$( "#btn_yes" ).click(function() {
|
|
window.location.href = '$varenv->{wwwhost}?radID=$ask_radID$session_and';
|
|
});
|
|
|
|
});
|
|
</script>
|
|
EOF
|
|
;
|
|
|
|
print "<div id='dialog-form2' style='text-align:left;margin:auto;max-width:1000px;' title='$title'>";
|
|
|
|
|
|
print $q->start_form(-name=>'modaldialog');
|
|
print $q->hidden(-name=>"sessionid",-override=>1,-value=>"$R::sessionid");
|
|
|
|
print "<div class='form-group' style='clear:both;'>\n";
|
|
|
|
if($ctadr->{int04} != 1 || $ctadr_int13 != 1){
|
|
my $required = "required";
|
|
if($ctadr->{int04} != 1){
|
|
my $des = "E-Mail Bestätigungscode";
|
|
my $key = "confirm_code";
|
|
my $label_des="* $des";
|
|
print $q->label({-for=>"$key", -style=>'padding-top:1em;'},"$label_des"),"\n";
|
|
print "<input id='$key' type='text' class='form-control' name='$key' value='' placeholder='$des' $required />\n";
|
|
}else{
|
|
print $q->div({-class=>'content2', -style=>'color:gray;'}, "* E-Mail Bestätigungscode wurde bereits erfolgreich eingegeben."),"\n";
|
|
}
|
|
if($ctadr_int13 != 1 && $varenv->{telAck_startdate}){
|
|
my $des = "SMS Bestätigungscode";
|
|
my $key = "confirm_smscode";
|
|
my $label_des="* $des";
|
|
print $q->label({-for=>"$key", -style=>'padding-top:1em;'},"$label_des"),"\n";
|
|
print "<input id='$key' type='text' class='form-control' name='$key' value='' placeholder='$des' $required />\n";
|
|
}elsif($varenv->{telAck_startdate}){
|
|
print $q->div({-class=>'content2', -style=>'color:gray;'}, "* SMS Bestätigungscode wurde bereits erfolgreich eingegeben."),"\n";
|
|
}
|
|
my $button_name = "Weiter";
|
|
print $q->div({-style=>'margin-top:1em;'},"<button type='submit' name='confirm_email' value='$ctadr->{txt08}' class='btn btn-primary btn-lg btn-block'>$button_name</button>"),"\n";
|
|
|
|
}elsif($ctadr->{int04} && $R::confirm_code){
|
|
|
|
my $des = "Danke! Die Bestätigung war erfolgreich.";
|
|
my $key = "nothing";
|
|
my $label_des="$des";
|
|
print $q->label({-for=>"$key", -style=>'padding-top:2.5em;'},"$label_des"),"\n";
|
|
print $q->div({-style=>'margin-top:2em;text-align:center;'},"<button type='button' id='btn_no1' class='btn btn-primary'>Schließen</button>"),"\n";
|
|
|
|
|
|
}elsif($ctadr->{int12} || $ctadr->{int01} != 3 || !$ct->{c_id}){
|
|
my $des = "Leider ist das Fahrradmietsystem für Ihren Account nicht freigeschaltet.<br /><br />Bitte überprüfen Sie Ihre Profildaten auf Vollständigkeit.";
|
|
$des = "Leider ist das Fahrradmietsystem für Ihren Account nicht freigeschaltet.<br /><br />Bitte kontaktieren Sie uns damit wir das Problem lösen und Ihren Account wieder freischalten können.</a>." if($ctadr->{int12} == 2);
|
|
my $key = "nothing";
|
|
my $label_des="$des";
|
|
print $q->label({-for=>"$key", -style=>'padding-top:2.5em;'},"$label_des"),"\n";
|
|
print $q->div({-style=>'margin-top:2em;text-align:center;'},"<button type='button' id='btn_no1' class='btn btn-primary'>Schließen</button>"),"\n";
|
|
|
|
|
|
|
|
}elsif($ask_radID){
|
|
|
|
my $des = "Fahrrad Nr. $R::ask_radID kostenlos für 15 Min. reservieren?";
|
|
my $key = "radID";
|
|
my $label_des="$des";
|
|
print $q->label({-for=>"$key", -style=>'padding-top:2.5em;'},"$label_des"),"\n";
|
|
#print "<input id='$key' type='text' class='form-control' name='$key' value='' placeholder='$des' $required />\n";
|
|
#print $q->hidden(-name=>"$key",-override=>1,-value=>"$ask_radID");
|
|
print $q->div({-style=>'margin-top:2em;text-align:center;'},"<button type='button' id='btn_no2' class='btn btn-primary' style='width:5em;margin:0 2.5em;'>Nein</button>","<button type='button' id='btn_yes' class='btn btn-primary' style='width:5em;;margin:0 2.5em;'>Ja</button>"),"\n";
|
|
|
|
}
|
|
|
|
print "</div>\n";
|
|
|
|
print $q->end_form,"\n";
|
|
print "</div>\n";
|
|
|
|
}elsif($ask_radID){
|
|
#If no Login
|
|
print<<EOF
|
|
<script>
|
|
\$(function() {
|
|
\$( "#dialog-form2" )
|
|
.css("background-color","$bg_color")
|
|
.dialog({
|
|
height: $height,
|
|
width: $width,
|
|
closeOnEscape: false,
|
|
modal: true
|
|
});
|
|
\$('.ui-widget-overlay').click(function() {
|
|
\$(".ui-dialog-titlebar-close").trigger('click');});
|
|
|
|
\$( "#btn_no3" ).click(function() {
|
|
\$( "#dialog-form2" ).dialog( "close" );
|
|
});
|
|
\$( "#btn_anmelden" ).click(function() {
|
|
window.location.href = '$varenv->{wwwhost}/$varenv->{mandant}/Anmelden';
|
|
});
|
|
|
|
});
|
|
</script>
|
|
EOF
|
|
;
|
|
print "<div id='dialog-form2' style='text-align:left;margin:auto;max-width:1000px;' title='$title'>";
|
|
print "<div class='form-group' style='clear:both;'>\n";
|
|
|
|
my $des = "Bitte erst anmelden.";
|
|
my $label_des="$des";
|
|
print $q->label({-for=>"no_access", -style=>'padding-top:2.5em;'},"$label_des"),"\n";
|
|
print $q->div({-style=>'margin-top:2em;text-align:center;'},"<button type='button' id='btn_no3' class='btn btn-primary' style='margin:0 2em;'>Schließen</button>","<button type='button' id='btn_anmelden' class='btn btn-primary' style='margin:0 2em;'>Anmelden</button>"),"\n";
|
|
|
|
|
|
print "</div>\n";
|
|
print "</div>\n";
|
|
|
|
}
|
|
}
|
|
1;
|