X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Felements%2Ftr-select-agent.html;h=515a11d48c27e9f188ab930d8ba064852b34f3b5;hb=bb119c4cc86e906f698a205437790bd8f96bb3d0;hp=44df3fc7d35ea9448dea98eceb5fbc4e0758de8d;hpb=c0fd57a78daf5ed54cb5f0944b227350f12f0704;p=freeside.git diff --git a/httemplate/elements/tr-select-agent.html b/httemplate/elements/tr-select-agent.html index 44df3fc7d..515a11d48 100644 --- a/httemplate/elements/tr-select-agent.html +++ b/httemplate/elements/tr-select-agent.html @@ -1,3 +1,27 @@ +<%doc> + +Example: + + include( '/elements/tr-select-agent.html', + + #recommended to keep things "sticky" on errors + 'curr_value' => $curr_value, + + ## + # optional + ## + + 'label' => 'Agent for this thing', + 'empty_label' => 'Select agent', #override default + 'disable_empty' => 1, + + #set to 'None' or something to override default of showing all agents + #for employees w/ 'View customers of all agents' right + viewall_right => 'None', + + ); + + % if ( scalar(@agents) == 1 ) { @@ -9,7 +33,7 @@ <% $opt{'label'} || 'Agent' %> - + > <% include( '/elements/select-agent.html', 'curr_value' => $agentnum, 'agents' => \@agents, @@ -26,15 +50,13 @@ 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; -} +my @agents = + $opt{'agents'} + ? @{ $opt{'agents'} } + : $FS::CurrentUser::CurrentUser->agents( + 'viewall_right' => $opt{'viewall_right'}, + ); + +my $colspan = $opt{'colspan'} ? 'COLSPAN="'.$opt{'colspan'}.'"' : '';