package Mlogic; # # SPDX-License-Identifier: AGPL-3.0-or-later # Copyright (c) Rainer Gümpelein, TeilRad GmbH # # use strict; use warnings; use CGI::Carp qw(fatalsToBrowser); use CGI ':standard'; use Config::General; use Mod::Buttons; use Mod::Basework; use Mod::Libenz; use Mod::Libenzdb; use Mod::DBtank; use POSIX; use Data::Dumper; sub new { my $class = shift; my $self = {}; bless($self,$class); return $self; } #Template sub tpl(){ my $self = shift; my $q = shift; my $node_meta = shift; my $users_dms = shift; my $mode = shift || ""; my $varenv = shift; my $users_sharee = shift || ""; my $feedb = shift || ""; $q->import_names('R'); my $bw = new Basework; my $lb = new Libenz; my $db = new Libenzdb; my $dbt = new DBtank; my $but = new Buttons; my %ib = $but->ibuttons(); my $script = $q->script_name(); my $path_info = $q->path_info(); my $path = $path_info; if("$varenv->{metahost}"){ $path = "$script" . "$path_info"; $script=""; } my $coo = $q->cookie(-name=>'domcookie'); my $debug = ""; my $lang = "de"; my @viewsel = split /\//,$1 if($path =~ /^\/(.*)/); my $view_root = $viewsel[0] || ""; my $mandant = $db->get_node("$view_root","$lang"); my $parent_id = $node_meta->{parent_id}; my $main_id = $node_meta->{main_id}; my $coprihome = "c o p r i "; $coprihome .= " home" if($dbt->{primary}->{$varenv->{dbname}}->{title}); my $title = ""; $title .= $dbt->{primary}->{$varenv->{dbname}}->{title} if($dbt->{primary}->{$varenv->{dbname}}->{title}); $title .= $dbt->{operator}->{$varenv->{dbname}}->{title} if($dbt->{operator}->{$varenv->{dbname}}->{title}); $title .= " | " . $dbt->{operator}->{$varenv->{dbname}}->{oprefix} if($dbt->{operator}->{$varenv->{dbname}}->{oprefix}); $title .= $dbt->{website}->{$varenv->{syshost}}->{title} if($dbt->{website}->{$varenv->{syshost}}->{title}); $title .= " (devel $varenv->{dbname})" if($dbt->{copri_conf}->{stage} eq "test"); ###User Panel if($users_dms->{u_id}){ ###header start print "
\n"; print "
\n"; if($users_dms->{c_id4trans} && $users_dms->{tpl_id4trans}){ my $table = "contenttrans"; my $limit = $R::limit || $varenv->{limit}; my $offset = $R::offset || "0"; if($R::go && $R::go eq "backward_list"){ $offset -= $limit if($offset >= $limit); }elsif($R::go && $R::go eq "forward_list"){ $offset += $limit; } my $ctrel = $db->get_ctrel($table,"",$lang,"",$users_dms->{c_id4trans},$users_dms->{tpl_id4trans}); print $q->div({-id=>'Headerlogin',-style=>"background-color:#f7ae37;"},$q->a({-class=>'elinkbutton1',-title=>"Faktura Terminal öffnen",-href=>"$varenv->{wwwhost}/DMS/Faktura?ct_trans=open\&c_id4trans=$users_dms->{c_id4trans}\&tpl_id4trans=$users_dms->{tpl_id4trans}\&owner=$users_dms->{owner}\&offset=$offset\&limit=$limit\&relids=$R::relids\&no_redirect=1"}," Faktura \#$ctrel->{ct_name} $ctrel->{txt01}", $q->span({-id=>"c_id4trans", -style=>"color:#f7ae37"}, "$users_dms->{c_id4trans}"))) if($ctrel->{ct_name}); } print $q->div({-id=>'Headerlogin'},"$users_sharee->{txt08} ", $q->span({-id=>"owner", -style=>"color:silver"}, "($users_dms->{u_id})")),"\n"; print $q->div({-id=>'Headerlogin'},$q->a({-href=>"logout",-title=>'logout'},$q->span({-class=>"bi bi-door-open", -style=>'font-size:1em;color:white;padding-right:1em;'}))),"\n"; print "
"; print "
"; } #end user panel ###header end #Mainlogin if(!$users_dms->{u_id}){ print "
\n"; print $q->start_multipart_form(-id=>'authform', -name=>'loginscreen'),"\n"; print $q->hidden(-name=>"merchant_id",-override=>1,-value=>"$varenv->{merchant_id}") if($varenv->{merchant_id}); print $q->hidden(-name=>"sessionid",-override=>1,-value=>"$R::sessionid") if($R::sessionid); print "
\n"; #Login print $q->div({-class=>'content2', -nowrap=>1}, $q->img({ -style=>"height:25px",-src=>"$varenv->{head_logo}"}),"Operator Login – $title"),"\n"; print $q->div({-style=>'color:#c83434'},"Login failure"),"\n" if("$R::login_dms" eq "Login" && !$users_dms->{u_id}); print $q->label({-for=>'Userid'},""),"\n"; print $q->textfield(-class=>'form-control', -name=>'user_id', -value=>'', -override=>1, -type=>'email',-class=>'form-control', -id=>'Userid', -placeholder=>'NutzerIn', -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=>'PW', -placeholder=>'Passwort', -required=>1),"\n"; print $q->div({-style=>'margin-top:1em;'},""),"\n"; print "
\n"; print $q->end_form,"\n"; #print $q->span({-style=>'color:white;'},"merchant_id:$varenv->{merchant_id}"),"\n"; print "
"; exit 0; } if($users_dms->{u_id} && $main_id){ $bw->return_feedback($node_meta,$users_dms,$feedb); if($main_id >= "100000"){ my $mstyle=""; my $dbh_primary = $dbt->dbconnect_extern($dbt->{primary}->{sharee_primary}->{database}->{dbname}); my $users_dms_primary = { u_id => 0 }; $users_dms_primary = $dbt->select_users($dbh_primary,$users_dms->{u_id},""); #print Dumper($users_dms_primary); my $mod_active = "$dbt->{shareedms_conf}->{mod_active}"; if($users_dms_primary->{u_id} && $users_dms_primary->{int02} >= 1 && $users_dms->{u_id} && $users_dms->{int02} >= 1){ $mod_active .= "|Kunden"; }else{ $mod_active .= "|App-feedback"; } if($users_dms_primary->{u_id} && $users_dms_primary->{int03} >= 1 && $users_dms->{u_id} && $users_dms->{int03} >= 1){ $mod_active .= "|Faktura"; } if($users_dms->{u_id} && ($users_dms->{int07} >= 1 || $users_dms->{int08} >= 1)){ $mod_active .= "|Einstellung"; } ###Top Menu #bootstrap menue print "\n"; ###end bootstrap menue #node_name=DMS if($varenv->{dbname} eq $dbt->{primary}->{sharee_primary}->{database}->{dbname} && $main_id == "100002"){ my $big2menu=""; #while (my ($key, $value) = each %{ $dbt->{operator} }) { foreach my $key (sort keys (%{ $dbt->{operator} })) { $big2menu .= $but->lia_button("$dbt->{operator}->{$key}->{operatorDMS}","DMS $key","","","color:#$dbt->{operator}->{$key}->{bgcolor1};","") if($dbt->{operator}->{$key}->{merchant_id}); } foreach my $key (sort keys (%{ $dbt->{website} })) { $big2menu .= $but->lia_button("$dbt->{website}->{$key}->{operatorWeb}","Web $key","","","color:#$dbt->{website}->{$key}->{bgcolor1};","") if($dbt->{website}->{$key}->{merchant_id}); } foreach my $key (sort keys (%{ $dbt->{appsframe} })) { if($key eq "shareetool"){ $big2menu .= $but->lia_button("$dbt->{appsframe}->{$key}->{uri}?sessionid=$dbt->{appsframe}->{$key}->{merchant_id}","App $key","","","color:#$dbt->{merchant_ids}->{$dbt->{appsframe}->{$key}->{merchant_id}}->{bgcolor1};",""); }else{ $big2menu .= $but->lia_button("$dbt->{primary}->{sharee_primary}->{primaryApp}?sessionid=$dbt->{appsframe}->{$key}->{merchant_id}","App $key","","","color:#$dbt->{merchant_ids}->{$dbt->{appsframe}->{$key}->{merchant_id}}->{bgcolor1};",""); } } print $q->div({-style=>'width:100%;margin:0;padding-top:70px;color:white;'}, ""),"\n"; print $q->div({-style=>'width:100%;margin:0;'}, $q->ul({-id=>'BigNavi'},$big2menu)),"\n"; } $debug = "syshost: $varenv->{syshost}, merchant_id: $varenv->{merchant_id}, (c_id4trans:$users_dms->{c_id4trans} && tpl_id4trans:$users_dms->{tpl_id4trans}) $node_meta->{tpl_name},$node_meta->{tpl_id},$node_meta->{ct_table},$parent_id,$main_id, permissions: ($users_dms->{int01},$users_dms->{int02},$users_dms->{int03},$users_dms->{int07},$users_dms->{int08},$users_dms->{int09})" if($users_dms->{u_id} == $dbt->{copri_conf}->{superu_id}); print $q->div({-style=>'position:fixed;bottom:0%;right:1%;z-index:10;padding:2px;font-size:13px;'},"$debug",$q->a({-style=>'color:black;text-decoration: none;',-href=>'https://sharee.bike',-target=>'_blank'},"sharee.bike © TeilRad GmbH 2022")),"\n"; print $q->div({-style=>'padding: 30px 0 0 0;'}, ""), "\n"; $self->tplselect($node_meta,$users_dms,$mode,$varenv,$feedb); print "\n"; }#end logedin environment } #2021-05-05 changed to Mlogic sub tplselect(){ my $self = shift; my $node_meta = shift; my $users_dms = shift; my $mode = shift || ""; my $varenv = shift; my $feedb = shift || ""; my $return = ""; my $sort = ""; my $lang = "de"; my $tpl_name = $node_meta->{tpl_name}; my $tpl_id = $node_meta->{tpl_id}; my $ct_table = $node_meta->{ct_table}; my $parent_id = $node_meta->{parent_id}; my $main_id = $node_meta->{main_id}; #print Dumper($node_meta); #exit; if($node_meta->{tpl_id} =~ /194|195|199/ && $node_meta->{ct_table} eq "contentuser"){ require "Tpl/SubListe.pm"; $return = &SubListe::tpl($node_meta,$users_dms,$feedb); }elsif($node_meta->{ct_table} eq "contentuser"){ require "Tpl/MandantConf.pm"; $return = &MandantConf::tpl($node_meta,$users_dms,$mode,$feedb); }elsif($node_meta->{tpl_id} == 1 && $node_meta->{main_id} == 200017){ require "Tpl/Karte_osm.pm"; &Karte_osm::tpl($node_meta,$users_dms,$mode,$varenv,"",$feedb); }elsif($node_meta->{ct_table} =~ /contentpos|contentadrpos|users$/){#contentpos or contentadrpos require "Tpl/SubListe.pm"; $return = &SubListe::tpl($node_meta,$users_dms,$feedb); }elsif($node_meta->{ct_table} =~ /content$|contentadr$|contenttrans$/){ require "Tpl/Liste3.pm"; $return = &Liste3::tpl($node_meta,$users_dms,$mode,$feedb); }elsif($node_meta->{ct_table} =~ /contenttranspos|contenttheftpos/){ require "Tpl/Calorin.pm"; &Calorin::tpl($node_meta,$users_dms,$mode,$feedb); } if(ref($feedb) eq "HASH" && $feedb->{message} =~ /failure/){ require "Mod/Failure.pm"; &Failure::tpl($varenv,$users_dms->{u_id},$feedb); }elsif($return =~ /failure/){ $feedb->{message} = "$return"; require "Mod/Failure.pm"; &Failure::tpl($varenv,$users_dms->{u_id},$feedb); }else{ if(($R::ct_trans !~ /close/) && ($ct_table =~ /contenttrans/) && ($R::ct_trans || $R::trans2edit || $R::ctpos_activ || $R::select_part || $R::set_main_id)){ &Modalbox::mobox($node_meta,$users_dms,$return); }elsif(($R::ct_trans !~ /close/) && ($ct_table =~ /content$|contentadr|contentuser|contentpos|users$|contenttranspos/ && ($R::ct_trans || $R::rel_edit || $R::base_edit)) || ($R::node2edit && $R::node2edit =~ /edit/)){ &Modalbox3::mobox3($node_meta,$users_dms,$feedb,$return,$mode) if($R::rel_edit !~ /delete|save/ && $R::ct_trans !~ /delete/ && $R::base_edit !~ /delete/ && !$R::service_id); } } } 1;