X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Felements%2Ftr-select-agent.html;h=69cd95cb04fa474c06ddb33814f354f900987fa1;hb=a2649b652a3db877b105b4bea5b34727dbcb914f;hp=2227262b6cc389a0d53382a55ed3e8579be28da7;hpb=386ec52836abbe32ce2fbf575e851a75f6e112f8;p=freeside.git diff --git a/httemplate/elements/tr-select-agent.html b/httemplate/elements/tr-select-agent.html index 2227262b6..69cd95cb0 100644 --- a/httemplate/elements/tr-select-agent.html +++ b/httemplate/elements/tr-select-agent.html @@ -1,29 +1,37 @@ -<% - my( $agentnum, %opt ) = @_; +% if ( scalar(@agents) == 1 ) { - my @agents; - if ( $opt{'agents'} ) { - @agents = @{ $opt{'agents'} }; - } else { - @agents = qsearch( 'agent', { disabled=>'' } ); - } + -%> - -<% if ( scalar(@agents) == 1 ) { %> - - - -<% } else { %> +% } else { - <%= $opt{'label'} || 'Agent: ' %> + <% $opt{'label'} || 'Agent' %> - <%= include( '/elements/select-agent.html', $agentnum, - 'agents' => \@agents, + <% include( '/elements/select-agent.html', + 'curr_value' => $agentnum, + 'agents' => \@agents, + %opt, ) %> -<% } %> +% } + +<%init> + +my %opt = @_; +my $agentnum = $opt{'curr_value'} || $opt{'value'}; + +my @agents; +if ( $opt{'agents'} ) { + #@agents = @{ $opt{'agents'} }; + #here is the agent virtualization + my $agentnums_href = $FS::CurrentUser::CurrentUser->agentnums_href; + @agents = grep $agentnums_href->{$_->agentnum}, @{ $opt{'agents'} }; + delete $opt{'agents'}; +} else { + @agents = $FS::CurrentUser::CurrentUser->agents; +} + +