83c8d1758aff37d621f6ce7fa14aea9845323f82
[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   } else {
11     @agents = qsearch( {
12       'table'     => 'agent',
13       'hashref'   => { disabled=>'' },
14       'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
15     });
16   }
17
18 %>
19
20 <% if ( scalar(@agents) == 1 ) { %>
21
22   <INPUT TYPE="hidden" NAME="agentnum" VALUE="<%= $agents[0]->agentnum %>">
23
24 <% } else { %>
25
26   <TR>
27     <TD ALIGN="right"><%= $opt{'label'} || 'Agent: ' %></TD>
28     <TD>
29       <%= include( '/elements/select-agent.html', $agentnum,
30                      'agents' => \@agents,
31                  )
32       %>
33     </TD>
34   </TR>
35
36 <% } %>