virtualize referrals on customer addition
[freeside.git] / httemplate / elements / tr-select-agent.html
1 <%
2   my( $agentnum, %opt ) = @_;
3
4   my @agents;
5   if ( $opt{'agents'} ) {
6     #@agents = @{ $opt{'agents'} };
7     #here is the agent virtualization
8     my $agentnums_href = $FS::CurrentUser::CurrentUser->agentnums_href;
9     @agents = grep $agentnums_href->{$_->agentnum}, @{ $opt{'agents'} };
10     delete $opt{'agents'};
11   } else {
12     @agents = $FS::CurrentUser::CurrentUser->agents;
13   }
14
15 %>
16
17 <% if ( scalar(@agents) == 1 ) { %>
18
19   <INPUT TYPE="hidden" NAME="agentnum" VALUE="<%= $agents[0]->agentnum %>">
20
21 <% } else { %>
22
23   <TR>
24     <TD ALIGN="right"><%= $opt{'label'} || 'Agent' %></TD>
25     <TD>
26       <%= include( '/elements/select-agent.html', $agentnum,
27                      'agents' => \@agents,
28                      %opt,
29                  )
30       %>
31     </TD>
32   </TR>
33
34 <% } %>