sharee.bike/copri4/main/src/Tpl/MandantConf.pm

141 lines
4.9 KiB
Perl
Raw Normal View History

2021-12-30 12:05:56 +01:00
package MandantConf;
#
# SPDX-License-Identifier: AGPL-3.0-or-later
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
#
#
use strict;
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use CGI ':standard';
use Lib::Config;
use Mod::Buttons;
use Mod::Libenz;
use Mod::Libenzdb;
use Mod::DBtank;
sub new {
my $class = shift;
my $self = {};
bless($self,$class);
return $self;
}
#Template
sub tpl(){
my $node_meta = shift;
my $users_dms = shift;
my $u_group = 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 $but = new Buttons;
my %ib = $but->ibuttons();
my %varenv = $cf->envonline();
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="";
}
$path =~ s/\/user|\/manager|\/admin//;
my $lang = "de";
my $dbh = "";
my $rel = {};
my $ct = {};
if($node_meta->{ct_table} eq "contentuser"){
if(($node_meta->{node_name} eq "Firma") && ($users_dms->{u_id} eq $varenv{superu_id})){
$rel = $db->get_rel4tpl($node_meta->{main_id},$lang,"","201","","",">0");
$ct = $db->get_content1("contentuser",$rel->{content_id});
}elsif(($node_meta->{node_name} eq "System") && ($users_dms->{u_id} eq $varenv{superu_id})){
$rel = $db->get_rel4tpl($node_meta->{main_id},$lang,"","215","","",">0");
$ct = $db->get_content1("contentuser",$rel->{content_id});
}elsif($node_meta->{node_name} eq "Kontakt-Hotline" && $users_dms->{int08} >= 1){
$rel = $db->get_rel4tpl($node_meta->{main_id},$lang,"","197","","",">0");
$ct = $db->get_content1("contentuser",$rel->{content_id});
}else{
$return = "failure::Abbruch. Keine Zugriffsberechtigung";
}
}
my $tpl = $db->get_tpl($rel->{template_id});
my @tpl_order = split /,/,$tpl->{tpl_order};
my $u_name = $dbt->sys_username($dbh,$ct->{owner});
$ct->{mtime} = $lb->time4de($ct->{mtime},"1");
print "<div id='Content4list'>";
print $q->div({-class=>"copri_header",-style=>"background-color:#cccccc;"},"Pfad: $path");
print $q->div({-style=>'background-color:silver;height:10px;'},""),"\n";
print $q->start_form();
#Content
print $q->start_table({-border=>'0', -width=>'100%',-align=>'center', -cellpadding=>'3', -cellspacing=>'0'});
print $q->Tr();
if($R::config2edit){
print "<td class='ct_editline'>";
print $q->hidden(-name=>'owner',-override=>'1', -value=>"$users_dms->{u_id}");
print $q->hidden(-name=>'c_id',-override=>'1', -value=>"$ct->{c_id}");
print $q->hidden(-name=>'rel_id',-override=>'1', -value=>"$rel->{rel_id}");
2022-02-01 20:53:23 +01:00
print $q->hidden(-name=>'main_id',-override=>'1', -value=>"$rel->{main_id}");
2021-12-30 12:05:56 +01:00
print $but->singlesubmit7("rel_edit","save_user","$ib{save}");
print "</td>\n";
}else{
print "<td class='ct_editline'>";
print $q->a({-class=>"editnav",-href=>"$script$path?config2edit=1",-title=>'bearbeiten'}, $q->img({-src=>"$varenv{metahost}/glyphicons/glyphicons-151-edit.png"}));
print "</td>\n";
}
print $q->td({-style=>"background-color:white;padding-right:10px;border-bottom: 1px solid silver;text-align:right;font-size:12px;"}, "$u_name / $ct->{mtime}");
my $i=0;
foreach (@tpl_order){
$i++;
my ($key,$des,$size) = split /=/,$_;
2022-02-01 20:53:23 +01:00
$size = "60" if($key =~ /ct_name|txt|img/ && !$size);
2021-12-30 12:05:56 +01:00
$ct->{$key} = $q->unescapeHTML("$ct->{$key}");
$ct->{$key} = $lb->newline($ct->{$key});
2022-03-30 07:29:24 +02:00
$des .= " ($key)" if($users_dms->{u_id} eq $varenv{superu_id});
2021-12-30 12:05:56 +01:00
my $value = "";
if($R::config2edit){
if($size eq "area"){
2022-02-01 20:53:23 +01:00
$value = "<textarea class='etxtarea' name='$key' rows=2 cols=60>$ct->{$key}</textarea>";
2021-12-30 12:05:56 +01:00
}elsif($size =~ /\w\+\w/){
my ($a,$b) = split /\+/,$size;
my $a_checked;
my $b_checked;
$a_checked = "checked" if($ct->{$key} eq "$a" || !$ct->{$key});
$b_checked = "checked" if($ct->{$key} eq "$b");
$value = "$a <input type='radio' name='$key' value='$a' $a_checked> $b <input type='radio' name='$key' value='$b' $b_checked>";
2022-02-01 20:53:23 +01:00
}elsif($key =~ /txt/){
2021-12-30 12:05:56 +01:00
$value = "<input class='etxt' type='text' name='$key' value='$ct->{$key}' size=$size maxlength=200>";
}elsif($key =~ /int/){
$value = "<input class='etxt' type='text' name='$key' value='$ct->{$key}' size=6 maxlength=10>";
}elsif($key =~ /img/){
2022-02-01 20:53:23 +01:00
$value = "<input class='etxt' type='text' name='$key' value='$ct->{$key}' size=$size maxlength=200>";
2021-12-30 12:05:56 +01:00
}
}else{
$value = "$ct->{$key}";
}
print $q->Tr();
2022-03-30 07:29:24 +02:00
if($key =~ /ct_name/){
print $q->td({-class=>'tdescr2'}, ""),"\n";
2022-04-12 11:21:19 +02:00
print $q->td({-class=>'tdval2'},"$dbt->{operator}->{$varenv{dbname}}->{title} | $dbt->{operator}->{$varenv{dbname}}->{oprefix} | $dbt->{operator}->{$varenv{dbname}}->{database}->{dbname}"),"\n";
2021-12-30 12:05:56 +01:00
}else{
print $q->td({-class=>'tdescr2'},"$des"),"\n";
2022-03-30 07:29:24 +02:00
print $q->td({-class=>'tdval2'}, "$value"),"\n";
2021-12-30 12:05:56 +01:00
}
}
print $q->end_table;
print $q->end_form;
print "</div>";
return $return;
}
1;