'View customers of all agents' doesn't mean create them, or upload inventory, RT...
[freeside.git] / httemplate / elements / tr-select-agent.html
1 <%doc>
2
3 Example:
4
5   include( '/elements/tr-select-agent.html',
6
7     #recommended to keep things "sticky" on errors
8     'curr_value'    => $curr_value,
9
10     ##
11     # optional
12     ##
13
14     'label'         => 'Agent for this thing',
15     'empty_label'   => 'Select agent', #override default 
16     'disable_empty' => 1,
17
18     #set to 'None' or something to override default of showing all agents
19     #for employees w/ 'View customers of all agents' right
20     viewall_right   => 'None',
21
22   );
23
24 </%doc>
25 % if ( scalar(@agents) == 1 ) { 
26
27   <INPUT TYPE="hidden" NAME="<% $opt{'field'} || 'agentnum' %>" VALUE="<% $agents[0]->agentnum %>">
28
29 %# YUCK.  empty row so we don't throw g_row in edit.html off :/
30   <TR>
31   </TR>
32 % } else { 
33
34   <TR>
35     <TD ALIGN="right"><% $opt{'label'} || 'Agent' %></TD>
36     <TD>
37       <% include( '/elements/select-agent.html',
38                      'curr_value' => $agentnum,
39                      'agents'     => \@agents,
40                      %opt,
41                  )
42       %>
43     </TD>
44   </TR>
45
46 % } 
47
48 <%init>
49
50 my %opt = @_;
51 my $agentnum = $opt{'curr_value'} || $opt{'value'};
52
53 my @agents =
54   $opt{'agents'}
55     ? @{ $opt{'agents'} }
56     : $FS::CurrentUser::CurrentUser->agents(
57         'viewall_right' => $opt{'viewall_right'},
58       );
59
60 </%init>