X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fconfig%2Fconfig-view.cgi;h=534de02314a1fa7a30fd2b98fc770ae56fb3c22e;hp=41ecfd2686cfce2c42ab3a228259c59d7ee5a7dc;hb=8cda5aa78a9ae58afe4b9f3684165658eb73c163;hpb=c1b01fc753bb1cbd9fedf7e17ac307d5e3d3cf00 diff --git a/httemplate/config/config-view.cgi b/httemplate/config/config-view.cgi index 41ecfd268..534de0231 100644 --- a/httemplate/config/config-view.cgi +++ b/httemplate/config/config-view.cgi @@ -3,6 +3,21 @@ Click on a configuration value to change it.

+% unless ( $page_agent ) { +% +% if ( $cgi->param('showagent') ) { +% $cgi->param('showagent', 0); + ( hide agent overrides ) +% $cgi->param('showagent', 1); +% } else { +% $cgi->param('showagent', 1); + ( show agent overrides ) +% $cgi->param('showagent', 0); +% } +% +% } +

+ <% include('/elements/init_overlib.html') %> % if ($FS::UID::use_confcompat) { @@ -42,6 +57,26 @@ Click on a configuration value to change it. % #$width = % #$height = % } +% +% my @agents = (); +% if ( $page_agent ) { +% @agents = ( $page_agent ); +% } else { +% @agents = ( +% '', +% grep { defined( _config_agentonly($conf, $i->key, $_->agentnum) ) } +% @all_agents +% ); +% } +% +% foreach my $agent ( @agents ) { +% my $agentnum = $agent ? $agent->agentnum : ''; +% +% my $label = $i->key; +% $label = '['. $agent->agent. "] $label" +% if $agent && $cgi->param('showagent'); +% +% #indentation :/ <% include('/elements/popup_link.html', @@ -50,8 +85,9 @@ Click on a configuration value to change it. 'width' => $width, 'height' => $height, 'actionlabel' => 'Enter configuration value', - 'label' => ''. $i->key. '', - 'aname' => $i->key, + 'label' => "$label", + 'aname' => $i->key, #agentnum + # if $cgi->param('showagent')? ) %>: <% $i->description %> @@ -102,21 +138,19 @@ Click on a configuration value to change it. % || $type eq 'selectmultiple' ) { - -
-<% encode_entities(join("\n",
+              
+
<% encode_entities(join("\n",
      map { length($_) > 88 ? substr($_,0,88).'...' : $_ }
          $conf->config($i->key, $agentnum)
    ) )
-%>
-
+%>
% } elsif ( $type eq 'checkbox' ) { - YES' : 'ff0000">NO' %> + YES' : 'ff0000">NO' %> % } elsif ( $type eq 'select' && $i->select_hash ) { @@ -129,7 +163,7 @@ Click on a configuration value to change it. % } - + <% $conf->exists($i->key, $agentnum) ? $hash{ $conf->config($i->key, $agentnum) } : '' %> @@ -137,7 +171,7 @@ Click on a configuration value to change it. % } elsif ( $type eq 'text' || $type eq 'select' ) { - + <% $conf->exists($i->key, $agentnum) ? $conf->config($i->key, $agentnum) : '' %> @@ -145,7 +179,7 @@ Click on a configuration value to change it. % } elsif ( $type eq 'select-sub' ) { - + <% $conf->config($i->key, $agentnum) %>: <% &{ $i->option_sub }( $conf->config($i->key, $agentnum) ) %> @@ -162,35 +196,50 @@ Click on a configuration value to change it. -% } + +% } # foreach my $agentnum + +% } # foreach my $i

-% } +% } # foreach my $nav_section +<%once> + +#should probably be a Conf method. what else would need to use it? +sub _config_agentonly { + my($self,$name,$agentnum)=@_; + my $hashref = { 'name' => $name }; + $hashref->{agentnum} = $agentnum; + local $FS::Record::conf = undef; # XXX evil hack prevents recursion + FS::Record::qsearchs('conf', $hashref); +} + + <%init> die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); -my $agentnum = ''; +my $page_agent = ''; my $title; my @menubar = (); if ($cgi->param('agentnum') =~ /^(\d+)$/) { - $agentnum = $1; - my $agent = qsearchs('agent', { 'agentnum' => $agentnum } ); - die "Agent $agentnum not found!" unless $agent; + my $page_agentnum = $1; + $page_agent = qsearchs('agent', { 'agentnum' => $page_agentnum } ); + die "Agent $page_agentnum not found!" unless $page_agent; push @menubar, 'View all agents' => $p.'browse/agent.cgi'; - $title = 'Agent Configuration for '. $agent->agent; + $title = 'Agent Configuration for '. $page_agent->agent; } else { $title = 'Global Configuration'; } my $conf = new FS::Conf; -my @config_items = grep { $agentnum ? $_->per_agent : 1 } +my @config_items = grep { $page_agent ? $_->per_agent : 1 } grep { $_->key != ~/^invoice_(html|latex|template)/ } $conf->config_items; @@ -204,4 +253,10 @@ foreach my $section (@sections) { @sections = grep scalar( @{ $section_items{$_} } ), @sections; +my @all_agents = (); +if ( $cgi->param('showagent') ) { + @all_agents = qsearch('agent', { 'disabled' => '' } ); +} +warn 'all agents: '. join('-', @all_agents); +