undo voodoo, find real problem
[freeside.git] / httemplate / elements / tr-select-agent.html
1 % if ( scalar(@agents) == 1 ) { 
2
3   <INPUT TYPE="hidden" NAME="<% $opt{'field'} || 'agentnum' %>" VALUE="<% $agents[0]->agentnum %>">
4
5 %# YUCK.  empty row so we don't throw g_row in edit.html off :/
6   <TR>
7   </TR>
8 % } else { 
9
10   <TR>
11     <TD ALIGN="right"><% $opt{'label'} || 'Agent' %></TD>
12     <TD>
13       <% include( '/elements/select-agent.html',
14                      'curr_value' => $agentnum,
15                      'agents'     => \@agents,
16                      %opt,
17                  )
18       %>
19     </TD>
20   </TR>
21
22 % } 
23
24 <%init>
25
26 my %opt = @_;
27 my $agentnum = $opt{'curr_value'} || $opt{'value'};
28
29 my @agents;
30 if ( $opt{'agents'} ) {
31   #@agents = @{ $opt{'agents'} };
32   #here is the agent virtualization
33   my $agentnums_href = $FS::CurrentUser::CurrentUser->agentnums_href;
34   @agents = grep $agentnums_href->{$_->agentnum}, @{ $opt{'agents'} };
35   delete $opt{'agents'};
36 } else {
37   @agents = $FS::CurrentUser::CurrentUser->agents;
38 }
39
40 </%init>