Service-Config refactoring

This commit is contained in:
ragu 2022-05-09 12:45:01 +02:00
parent 0f89b9e836
commit 0163c06893
15 changed files with 149 additions and 107 deletions

View file

@ -51,6 +51,7 @@ sub tpl(){
#print $dbt->{operator}->{$varenv{dbname}}->{oprefix};
my $rel_id = $1 if($R::rel_id && $R::rel_id =~ /(\d+)/);
my $c_id = $1 if($R::c_id && $R::c_id =~ /(\d+)/);
my $u_id = $1 if($R::u_id && $R::u_id =~ /(\d+)/);
$u_id = $1 if($R::c_idadr && $R::c_idadr =~ /(\d+)/ && $R::base_edit eq "new_dmsusers");
my ($edit,$copy_key,$save_key,$relate_key,$move_key,$delete_key,$package_key);
@ -108,6 +109,22 @@ sub tpl(){
$save_key = "save_dmsusers";
$tpl = $db->get_tpl($node_meta->{tpl_id});
#print Dumper($node_meta->{tpl_id}) . "\n u_id:" . $u_id;
#
}elsif($node_meta->{ct_table} eq "contentuser" && $node_meta->{tpl_id} == 199){
my $ref = {
table => "$node_meta->{ct_table}",
fetch => "one",
template_id => "$node_meta->{tpl_id}",
c_id => "$c_id",
};
$ctrel = $dbt->fetch_record($dbh,$ref);
print $q->hidden(-name=>'c_id',-override=>'1', -value=>"$ctrel->{c_id}");
print $q->hidden(-name=>'rel_id',-override=>'1', -value=>"$ctrel->{rel_id}");
$bg_color = $varenv{background_color2};
$edit = "rel_edit";
$save_key = "save_ctuser";
$tpl = $db->get_tpl($node_meta->{tpl_id});
}else{
print $q->div("Es konnten keine Daten gefunden werden"),"\n";
return "failure::Error, no table selected";
@ -192,7 +209,7 @@ sub tpl(){
my $cttrans = $db->collect_ct4rel4nd("contenttrans","","$lang","","","","ct.int10","$ctrel->{c_id}","209,218","","rel_id","");
foreach my $id (sort { $cttrans->{$b}->{c_id} <=> $cttrans->{$a}->{c_id} } keys (%$cttrans)){
my $toppx = $top . "px";
print $q->div({-style=>"position:absolute;top:$toppx;right:20px;"}, " TXID $cttrans->{$id}->{txt16} ",$q->span({-style=>"background-color:$varenv{term_active_color}"},$q->a({-class=>"linknav",-href=>"/$dbt->{shareedms_conf}->{parent_node}/Faktura/$cttrans->{$id}->{node_name}?ct_trans=open\&c_id4trans=$cttrans->{$id}->{c_id}\&tpl_id4trans=$cttrans->{$id}->{template_id}\&kind_of_trans=$users_dms->{kind_of_trans}&owner=$users_dms->{u_id}",-title=>"Faktura Terminal öffnen"},"[ $cttrans->{$id}->{node_name} #$cttrans->{$id}->{ct_name} ]"))),"\n";
print $q->div({-style=>"position:absolute;top:$toppx;right:20px;"}, " TXID $cttrans->{$id}->{txt16} ",$q->span({-style=>"background-color:#f7ae37"},$q->a({-class=>"linknav",-href=>"/$dbt->{shareedms_conf}->{parent_node}/Faktura/$cttrans->{$id}->{node_name}?ct_trans=open\&c_id4trans=$cttrans->{$id}->{c_id}\&tpl_id4trans=$cttrans->{$id}->{template_id}\&kind_of_trans=$users_dms->{kind_of_trans}&owner=$users_dms->{u_id}",-title=>"Faktura Terminal öffnen"},"[ $cttrans->{$id}->{node_name} #$cttrans->{$id}->{ct_name} ]"))),"\n";
$top += 22;
}
}elsif($node_meta->{tpl_id} == 205){
@ -201,7 +218,7 @@ sub tpl(){
my $year = strftime "%Y", localtime;
my ($nyear,$nmonth,$nday) = Add_Delta_YMD($year,$month,$day, 0,0,-28);
my $toppx = $top . "px";
print $q->div({-style=>"position:absolute;top:$toppx;right:20px;"}, $q->span({-style=>"background-color:$varenv{calendar_active_color}"},$q->a({-class=>"linknav",-href=>"/$dbt->{shareedms_conf}->{parent_node}/Mietjournal/?detail_search=1&barcode=$ctrel->{barcode}&start_date_time=$nday.$nmonth.$nyear",-title=>"Mietjournal der letzten 4 Wochen"},"[ Mietjournal zu Rad $dbt->{operator}->{$varenv{dbname}}->{oprefix}$ctrel->{barcode} ]"))),"\n";
print $q->div({-style=>"position:absolute;top:$toppx;right:20px;"}, $q->span({-style=>"background-color:#86cbd7"},$q->a({-class=>"linknav",-href=>"/$dbt->{shareedms_conf}->{parent_node}/Mietjournal/?detail_search=1&barcode=$ctrel->{barcode}&start_date_time=$nday.$nmonth.$nyear",-title=>"Mietjournal der letzten 4 Wochen"},"[ Mietjournal zu Rad $dbt->{operator}->{$varenv{dbname}}->{oprefix}$ctrel->{barcode} ]"))),"\n";
$top += 22;
#}else{
#print $q->div({-style=>"position:absolute;top:$top;right:20px;"},"no valid users path definition: $tpath"),"\n";

View file

@ -27,14 +27,12 @@ sub tpl(){
my $return = shift || "";
my $q = new CGI;
my $cf = new Config;
my $dbt = new DBtank;
my $apif = new APIfunc;
my $api_file = "/var/www/copri4/shareeconf/apikeys.cfg";
my $aconf = Config::General->new($api_file);
my %apikeyconf = $aconf->getall;
#print $apikeyconf{googlemap}->{google_key};
my $api_return = { authcookie => '' };
my $coo = $q->cookie(-name=>'domcookie') || $R::sessionid;
@ -43,18 +41,22 @@ sub tpl(){
my $initMap = $dbt->{website}->{$varenv->{syshost}}->{initMap};
my $map_zoom = $dbt->{website}->{$varenv->{syshost}}->{map_zoom} || "10";
my $project = "all";
my $uri_request = $dbt->{primary}->{sharee_primary}->{primaryDMS};
if($dbt->{website}->{$varenv->{syshost}}->{merchant_id}){
$api_return->{authcookie} = $dbt->{website}->{$varenv->{syshost}}->{merchant_id} if(!$api_return->{authcookie});
$project = $dbt->{website}->{$varenv->{syshost}}->{project} if($dbt->{website}->{$varenv->{syshost}}->{project});
$uri_request = $dbt->{website}->{$varenv->{syshost}}->{operatorWeb};
}elsif($dbt->{operator}->{$varenv->{dbname}}->{merchant_id}){
$api_return->{authcookie} = $dbt->{operator}->{$varenv->{dbname}}->{merchant_id} if(!$api_return->{authcookie});
$initMap = $dbt->{operator}->{$varenv->{dbname}}->{initMap} if($dbt->{operator}->{$varenv->{dbname}}->{initMap});
$map_zoom = $dbt->{operator}->{$varenv->{dbname}}->{map_zoom} if($dbt->{operator}->{$varenv->{dbname}}->{map_zoom});
$project = $dbt->{operator}->{$varenv->{dbname}}->{project} if($dbt->{operator}->{$varenv->{dbname}}->{project});
$uri_request = $dbt->{operator}->{$varenv->{dbname}}->{operatorDMS};
}elsif($dbt->{primary}->{$varenv->{dbname}}->{merchant_id}){
$api_return->{authcookie} = $dbt->{primary}->{$varenv->{dbname}}->{merchant_id} if(!$api_return->{authcookie});
$initMap = $dbt->{primary}->{$varenv->{dbname}}->{initMap} if($dbt->{primary}->{$varenv->{dbname}}->{initMap});
$uri_request = $dbt->{primary}->{$varenv->{dbname}}->{primaryDMS};
}
my $icon_green = "Open_Green.png";
@ -71,12 +73,17 @@ sub tpl(){
$users_sharee->{c_id} = "0" if(!$users_sharee->{c_id});
$initMap =~ s/\s//g;
my ($lat,$lng) = split(/,/,$initMap);
my $kmlfile = "";
my $filesize = 0;
my $preserve_view = "false";
require "Mod/KMLout.pm";
my $kmlfile = Mod::KMLout::kmlGenerator($api_return,$varenv,$users_sharee);
$kmlfile = Mod::KMLout::kmlGenerator($api_return,$varenv,$users_sharee);
my $filesize = -s "$varenv->{metahost}/xml/$kmlfile";
my $preserve_view = "false";
$preserve_view = "true" if($filesize < 200);#it's like empty without publixc stations
#
#used by empty station card like without public stations
#setting to true to keeps lat,lng and zoom
$preserve_view = "true" if($filesize < 200);
print "<div style='background-color:#cccccc;width:100%;margin-top:1em;'>\n";
@ -96,13 +103,11 @@ print<<EOF
var ctaLayer = new google.maps.KmlLayer({
position: map.getCenter(),
preserveViewport: $preserve_view,
//url: '$dbt->{primary}->{sharee_primary}->{primaryApp}/KMLout?kml=' + (new Date()).getTime() + '$users_sharee->{c_id}',
//url: '$varenv->{metahost}/xml/KMLout-3',
//url: '$varenv->{wwwhost}/?kml=' + (new Date()).getTime(),
//url: '$uri_request/KMLout?authcookie=$api_return->{authcookie}&dynamo=' + (new Date()).getTime(),
url: '$varenv->{metahost}/xml/$kmlfile',
map: map
});
console.log('$varenv->{metahost}/xml/$kmlfile');
console.log(ctaLayer);
};
@ -119,7 +124,7 @@ print "</div>\n";
#print $q->div({-class=>"content2_legende", -style=>'font-weight:bold;'}, "&bull; Ist ein Lastenrad an einer Mietradstation verfügbar?"),"\n";
print $q->div({-class=>"content2_legende"}, $q->img({-style=>'height:30px;', -src=>"$varenv->{metahost}/img/$icon_green"}), "Lastenrad verfügbar"),"\n";
print $q->div({-class=>"content2_legende"}, $q->img({-style=>'height:30px;', -src=>"$varenv->{metahost}/img/$icon_red"}), "Lastenrad nicht verfügbar"),"\n";
print $q->div({-class=>"content2_legende"}, "&nbsp;"),"\n";
#print $q->div({-class=>"content2_legende"}, "&nbsp;"),"\n";
print "$initMap|$varenv->{dbname}|$api_return->{authcookie}|$users_sharee->{c_id}|$kmlfile" if($users_dms->{u_id} == $dbt->{copri_conf}->{superu_id});

View file

@ -207,7 +207,7 @@ sub tpl(){
print "<div id='Content4list'>\n";
my $v_journal = $R::v_journal || "";
if($node_meta->{main_id} == $dbt->{shareeconf_dms}->{invoicejournal}){
if($node_meta->{main_id} == $dbt->{shareedms_conf}->{invoicejournal}){
$v_journal = $node_meta->{node_name};
}

View file

@ -68,7 +68,7 @@ sub tpl(){
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");
$ct->{change} = $lb->time4de($ct->{mtime},"1");
print "<div id='Content4list'>";
print $q->div({-class=>"copri_header",-style=>"background-color:#cccccc;"},"Pfad: $path");
@ -91,7 +91,7 @@ sub tpl(){
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}");
print $q->td({-style=>"background-color:white;padding-right:10px;border-bottom: 1px solid silver;text-align:right;font-size:12px;"}, "$u_name / $ct->{change}");
my $i=0;
foreach (@tpl_order){

View file

@ -19,8 +19,6 @@ use Mod::Libenz;
use Mod::Libenzdb;
use Mod::DBtank;
use Mod::APIfunc;
use Date::Calc qw(:all);
use Storable;
use Data::Dumper;
@ -48,38 +46,25 @@ sub tpl(){
my $db = new Libenzdb;
my $dbt = new DBtank;
my $apif = new APIfunc;
my $but = new Buttons;
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="";
}
my $path = $q->path_info();
my $lang = "de";
my $dbh = "";
my $parent_node4rel = $db->get_node4rel($node_meta->{parent_id},"","","null");
my %ib = $but->ibuttons();
my $tpl_order = $node_meta->{tpl_order};
if(1==2 && $node_meta->{tpl_id} >= 400 && $node_meta->{tpl_id} < 500){
if(1==2 && $node_meta->{tpl_id} > 400 && $node_meta->{tpl_id} < 500){
$tpl_order =~ s/barcode=Rad/barcode=Rad,txt10=Station-log,txt09=Wartungsprotokoll=area/;
$tpl_order =~ s/int04=Station/int04=Station,txt09=Wartungsprotokoll=area/ if($node_meta->{tpl_id} == 403);
$tpl_order =~ s/int04=Station/int04=Station,txt09=Wartungsprotokoll=area/ if($node_meta->{tpl_id} == 499);
}
my @tpl_order = split /,/,$tpl_order;
my $message = "";
#$message = "Fehler: bitte Unter \"Servicetechnik\" die Datenklasse konfigurieren!" if(scalar(@tpl_order) < 1);
#$message = "Fehler: " if(scalar(@tpl_order) < 1);
my $s_owner_id = "";
#my $s_u_name = "";
my @viewsel = split /\//,$1 if($path =~ /^\/(.*)/);
my $depth = scalar(@viewsel);
my $view_base = $viewsel[1] || "nothing";#like Waren
my $node_mandant = $db->get_node("$view_base","$lang");
#TODO, build service path by pos.template_id or pos.barcode alis bike_id
#my $pref = { table => "content",
# table_pos => "contentpos",
@ -122,7 +107,9 @@ sub tpl(){
$offset += $limit;
}
my $date; my $start_chck=0;my $end_chck=0;
my $date = "";
my $start_chck=0;
my $end_chck=0;
my $last_year;
if($R::s_start_mtime){
($date,$start_chck) = $lb->checkdate($R::s_start_mtime) if($R::s_start_mtime !~ "%");
@ -144,17 +131,22 @@ sub tpl(){
my $scol = "mtime";
my $table = "content";
$searchref->{table_pos} = "contentpos";
if($node_meta->{tpl_id} > 600 && $node_meta->{tpl_id} < 700){
if($node_meta->{tpl_id} == 199){
$table = "contentuser";
$searchref->{table_pos} = "";
$searchref->{template_id_pos} = "";
$main_ids = $node_meta->{main_id};
$tpl_ids = $node_meta->{tpl_id};
}
elsif($node_meta->{tpl_id} > 600 && $node_meta->{tpl_id} < 700){
$table = "contentadr";
$searchref->{table_pos} = "contentadrpos";
$searchref->{template_id_pos} = "$node_meta->{tpl_id}";
}
if($node_meta->{tpl_id} == 198){
my $mandant_id = 100002;
elsif($node_meta->{tpl_id} == 198){
$table = "contentadr";
$searchref->{table_pos} = "users";
#$searchref->{template_id_pos} = "$node_meta->{tpl_id}";
$main_ids = 200011;
$tpl_ids = 202;
print<<EOF
<style>
@ -168,7 +160,7 @@ print<<EOF
<script>
\$(function() {
\$('#json_selectadr').autocomplete({
source: '/ajax_json?mandant_id=$mandant_id&table=contentadr',
source: '/ajax_json?mandant_id=$dbt->{shareedms_conf}->{parent_id}&table=contentadr',
minLength: 2,
select: function(event, ui) {
\$('#vorname_name').val(ui.item.vorname_name);
@ -187,7 +179,9 @@ EOF
#print Dumper($node_meta);
my $hashfile = "$varenv{logdir}/$users_dms->{u_id}-$searchref->{table_pos}-searchhash";
my $ct4rel = {};
if(!$start_chck && !$end_chck && $parent_node4rel ne "Servicetechnik" && $main_ids && $tpl_ids){
#print Dumper($node_meta);
#print "if(!$start_chck && !$end_chck && $main_ids && $tpl_ids){";
if(!$start_chck && !$end_chck && $main_ids && $tpl_ids){
#$rows = $db->count_content($searchref->{table_pos},"$main_ids","$tpl_ids");
#collect search keys
@ -214,19 +208,17 @@ EOF
my $todo = "";
my $ck4ex = "";
#only if permission read
if(($node_meta->{ct_table} eq "users" && $users_dms->{int07} >= 1) || ($node_meta->{ct_table} eq "contentadrpos" && $users_dms->{int02} >= 1) || ($node_meta->{ct_table} eq "contentpos" && $users_dms->{int01} >= 1)){
$ct4rel = $db->search_content3($searchref,$table,$node_mandant->{parent_id},$node_meta,$users_dms->{u_id},$lang,"$main_ids","$tpl_ids","","",$time,"",$scol,$users_dms->{sort_updown},$offset,$limit,$export,$todo,$ck4ex,"");
if(($node_meta->{ct_table} eq "users" && $users_dms->{int07} >= 1) || ($node_meta->{ct_table} eq "contentadrpos" && $users_dms->{int02} >= 1) || ($node_meta->{ct_table} eq "contentpos" && $users_dms->{int01} >= 1) || ($node_meta->{ct_table} eq "contentuser" && $users_dms->{int08} >= 1)){
$ct4rel = $db->search_content3($searchref,$table,$dbt->{shareedms_conf}->{parent_id},$node_meta,$users_dms->{u_id},$lang,"$main_ids","$tpl_ids","","",$time,"",$scol,$users_dms->{sort_updown},$offset,$limit,$export,$todo,$ck4ex,"");
}else{
$return = "failure::Abbruch. Keine Zugriffsberechtigung";
}
}
print "<div id='Content4list'>\n";
if($varenv{syshost} ne "azn"){
my $header_style = "";
$header_style = "border:2px solid #9f1f0e;" if($message);
print $q->div({-class=>"copri_header",-style=>"background-color:$node_meta->{bg_color};"},"$path",$q->span({-style=>"$header_style"},"$message"));
}
my $header_style = "";
$header_style = "border:2px solid #9f1f0e;" if($message);
print $q->div({-class=>"copri_header",-style=>"background-color:$node_meta->{bg_color};"},"$path",$q->span({-style=>"$header_style"},"$message"));
print $q->div({-style=>'background-color:silver;height:10px;'},""),"\n";
print $q->start_form(-name=>'searchform'),"\n";
@ -240,7 +232,7 @@ EOF
print $q->start_table({ -style=>'clear:both;', -border=>'0', -width=>'100%',-align=>'center', -cellpadding=>'0', -cellspacing=>'0'}),"\n";
#new_edit and search (disabled for DMS-Account)
if($node_meta->{tpl_id} != 198){
if($node_meta->{tpl_id} != 198 && $node_meta->{tpl_id} != 199){
my $edit="rel_edit";
my $new_key="service_done";
@ -305,7 +297,7 @@ EOF
print $q->textfield(-style=>'border:1px solid grey;height:25px;width:80%;',-id=>"json_selectadr",-name=>"json_selectadr", -placeholder=>'Neuer DMS-Account', -value=>""),"\n";
print "</th>\n";
}else{
}elsif($node_meta->{tpl_id} != 199){
print $q->th({-style=>""},"&nbsp;"),"\n";
print $q->th({-style=>""},"&nbsp;"),"\n";
}
@ -353,7 +345,7 @@ EOF
#Tablecontent (parameter)
print $q->Tr(),"\n";
if($node_meta->{tpl_id} != 198){
if($node_meta->{tpl_id} != 198 && $node_meta->{tpl_id} != 199){
print $q->td({-class=>'tdtxt',-style=>"$set_style"},""),"\n";
print $q->td({-class=>'tdint',-style=>"$set_style"},""),"\n";
}
@ -386,8 +378,10 @@ EOF
#$u_name = $ct_users->{$ct4rel->{$id}->{$key}}->{txt01} || $ct4rel->{$id}->{$key};
print $q->td({-class=>"$tdclass",-style=>"$tdstyle $set_style"},"$u_name"),"\n";
}elsif($key eq "ct_name" && $node_meta->{ct_table} eq "contentuser"){
print $q->td({-class=>"$tdclass",-style=>"$tdstyle $set_style"},$q->a({-class=>"linknav3",-href=>"?node2edit=editpart\&c_id=$ct4rel->{$id}->{c_id}",-title=>"edit"},"$ct4rel->{$id}->{$key}")),"\n";
}elsif($key eq "barcode" && $node_meta->{ct_table} eq "contentadrpos"){
print $q->td({-class=>"$tdclass",-style=>"$tdstyle $set_style"},$q->a({-class=>"linknav3",-href=>"$varenv{wwwhost}/Waren/?detail_search=1\&s_barcode=$ct4rel->{$id}->{barcode}",-title=>"zum Rad "},"$ct4rel->{$id}->{barcode}")),"\n";
print $q->td({-class=>"$tdclass",-style=>"$tdstyle $set_style"},$q->a({-class=>"linknav3",-href=>"$varenv{wwwhost}/DMS/Waren/?detail_search=1\&s_barcode=$ct4rel->{$id}->{barcode}",-title=>"zum Rad "},"$ct4rel->{$id}->{barcode}")),"\n";
}elsif($key eq "u_id" && $node_meta->{ct_table} eq "users"){
my $adref = {