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::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 $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 $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 $title = ""; $title .= $dbt->{primary}->{$varenv->{dbname}}->{pprefix} if($dbt->{primary}->{$varenv->{dbname}}->{pprefix}); $title .= $dbt->{operator}->{$varenv->{dbname}}->{project} if($dbt->{operator}->{$varenv->{dbname}}->{project}); $title .= " " . $dbt->{operator}->{$varenv->{dbname}}->{oprefix} if($dbt->{operator}->{$varenv->{dbname}}->{oprefix}); $title .= $dbt->{website}->{$varenv->{syshost}}->{project} if($dbt->{website}->{$varenv->{syshost}}->{project}); $title .= " DEVEL $varenv->{dbname}" if($dbt->{copri_conf}->{stage} eq "test"); ###User Panel if($users_dms->{u_id}){ ###header start print "
\n"; print "
\n"; #cleanup if(!$mandant->{node_name} || "$mandant->{node_name}" ne "$users_dms->{fullurl}"){ $db->cleanup_users($users_dms->{owner}) if($users_dms->{owner}); } if($users_dms->{c_id4trans} && $users_dms->{tpl_id4trans} && $users_dms->{kind_of_trans}){ my $table = "contenttrans"; if($users_dms->{kind_of_trans} =~ /Veranstaltung|Proje/){ $table = "contenttver"; } 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}); my $uri = "/$users_dms->{fullurl}/$users_dms->{kind_of_trans}"; print $q->div({-id=>'Headerlogin',-style=>"background-color:$varenv->{term_active_color};"},$q->a({-class=>'elinkbutton1',-title=>"$users_dms->{kind_of_trans} Terminal öffnen",-href=>"$uri?ct_trans=open\&c_id4trans=$users_dms->{c_id4trans}\&tpl_id4trans=$users_dms->{tpl_id4trans}\&kind_of_trans=$users_dms->{kind_of_trans}\&owner=$users_dms->{owner}\&offset=$offset\&limit=$limit\&relids=$R::relids\&no_redirect=1"}," $users_dms->{kind_of_trans} \#$ctrel->{ct_name} $ctrel->{txt01}", $q->span({-id=>"c_id4trans", -style=>"color:$varenv->{term_active_color}"}, "$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"},$q->img({-style=>'padding:0px 10px;',-src=>"$varenv->{metahost}/img/logout.svg"}))),"\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'}, "Zugang zum $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){ $return = $lb->return_feedback($return,$users_dms->{kind_of_trans},$users_dms->{owner}) if($return !~ /shareejson/); if($main_id >= "100000"){ my $mstyle=""; ###Top Menu #bootstrap menue print "\n"; ###end bootstrap menue #node_name=DMS if($varenv->{dbname} eq "sharee_primary" && $main_id == "100002"){ my $big2menu=""; while (my ($key, $value) = each %{ $dbt->{operator} }) { if($value->{operatorApp}){ $big2menu .= $but->lia_button("$value->{operatorDMS}","$key","","","",""); } } print $q->div({-style=>'width:100%;margin:0;padding-top:90px;color:white;'}, "sharee.bike Operatoren"),"\n"; print $q->div({-style=>'width:100%;margin:0;'}, $q->ul({-id=>'BigNavi'},$big2menu)),"\n"; } print "
\n"; #lefsitemenue disabled 2021-06.03 print "
\n"; $debug = "syshost: $varenv->{syshost}, merchant_id: $varenv->{merchant_id}, (c_id4trans:$users_dms->{c_id4trans} && tpl_id4trans:$users_dms->{tpl_id4trans} && kind_of_trans:$users_dms->{kind_of_trans}) $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 2021")),"\n"; #update c_id4trans on changing browser tab 2019-10-08 #FIXME, we need all $R::c_id4trans,$R::tpl_id4trans,$R::kind_of_trans if(1==2 && $mode eq "manager"){ print< function postc_id4trans(c_val,o_val) { \$.ajax({ url: '$varenv->{wwwhost}/ajax_post', type: 'POST', async: true, cache: false, data: { c_id4trans: c_val, owner: o_val }, }); } document.addEventListener('visibilitychange', function () { if(document.visibilityState != 'hidden') { var c_id4trans = document.getElementById("c_id4trans").innerText; var owner = document.getElementById("owner").innerText; if(c_id4trans){ postc_id4trans(c_id4trans,owner); } console.log("postc_id4trans:" + c_id4trans + " " + owner); } }, false); EOF ; } $self->tplselect($node_meta,$users_dms,$mode,$varenv,$return); 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 $return = shift || ""; 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}; my $u_id = $users_dms->{u_id}; #print Dumper($node_meta); #exit; print < \$(function(){ \$('.autos').autosize({append: '\\n'}); }); EOF ; if($mode eq "supervisor" || $node_meta->{tpl_name} eq "AttributMatrix"){ $tpl_name = "AttributMatrix"; require "Tpl/AttributMatrix.pm"; $return = &AttributMatrix::tpl($node_meta,$users_dms,$mode,$return); #}elsif($tpl_id && $tpl_id >= 400 && $tpl_id <= 699){#contentpos or contentadrpos }elsif($node_meta->{tpl_id} == 1 && $node_meta->{main_id} == 200017){ require "Tpl/Karte.pm"; &Karte::tpl($node_meta,$users_dms,$mode,$varenv,"",$return); }elsif($node_meta->{ct_table} =~ /contentpos|contentadrpos|users$/){#contentpos or contentadrpos require "Tpl/SubListe.pm"; $return = &SubListe::tpl($node_meta,$users_dms,$mode,$return); }elsif($node_meta->{ct_table} =~ /content$|contentadr$|contenttrans$/){ require "Tpl/Liste3.pm"; $return = &Liste3::tpl($node_meta,$users_dms,$mode,$return); }elsif($node_meta->{ct_table} eq "contentuser"){ require "Tpl/MandantConf.pm"; $return = &MandantConf::tpl($node_meta,$users_dms,$mode,$return); #}elsif($tpl_name =~ /Statistik/){ #require "Tpl/Statistik.pm"; #&Statistik::tpl($main_id,$u_id,$lang,"","",$sort); }elsif($node_meta->{ct_table} =~ /contenttranspos|contenttheftpos/){ require "Tpl/Calorin.pm"; &Calorin::tpl($node_meta,$users_dms,$mode,$return); } ##Modalbox things## if($return !~ /failure/){ if(($R::ct_trans !~ /close/) && ($ct_table =~ /contenttrans/ || $R::kind_of_trans =~ /Faktur|Verleih/) && ($R::ct_trans || $R::trans2edit || $R::ctpos_activ || $R::select_part || $R::set_main_id)){ &Modalbox::mobox($node_meta,$users_dms,$mode,$return); }elsif(($R::ct_trans !~ /close/) && ($ct_table =~ /content$|contentadr|contenttver|contentpos|users$/ && ($R::ct_trans || $R::rel_edit || $R::base_edit)) || ($R::node2edit && $R::node2edit =~ /edit/)){ &Modalbox3::mobox3($node_meta,$users_dms,$mode,$return) if($R::rel_edit !~ /delete|save/ && $R::ct_trans !~ /delete/ && $R::base_edit !~ /delete|save/ && !$R::service_id); } } if($return =~ /failure/){ require "Mod/Failure.pm"; &Failure::tpl("",$u_id,"","","","",$return); } } 1;