summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/access_user.pm6
-rw-r--r--httemplate/edit/cust_main/top_misc.html1
-rw-r--r--httemplate/elements/tr-select-agent.html33
-rw-r--r--httemplate/misc/inventory_item-import.html5
4 files changed, 38 insertions, 7 deletions
diff --git a/FS/FS/access_user.pm b/FS/FS/access_user.pm
index 25aa8af..8c8ba8b 100644
--- a/FS/FS/access_user.pm
+++ b/FS/FS/access_user.pm
@@ -413,10 +413,10 @@ sub agentnum {
$sth->fetchrow_arrayref->[0];
}
-=item agents
+=item agents [ HASHREF | OPTION => VALUE ... ]
Returns the list of agents this user can view (via group membership), as
-FS::agent objects.
+FS::agent objects. Accepts the same options as the agentnums_sql method.
=cut
@@ -425,7 +425,7 @@ sub agents {
qsearch({
'table' => 'agent',
'hashref' => { disabled=>'' },
- 'extra_sql' => ' AND '. $self->agentnums_sql,
+ 'extra_sql' => ' AND '. $self->agentnums_sql(@_),
});
}
diff --git a/httemplate/edit/cust_main/top_misc.html b/httemplate/edit/cust_main/top_misc.html
index 916bac0..441a363 100644
--- a/httemplate/edit/cust_main/top_misc.html
+++ b/httemplate/edit/cust_main/top_misc.html
@@ -13,6 +13,7 @@
'label' => "<B>${r}Agent</B>",
'empty_label' => 'Select agent',
'disable_empty' => ( $cust_main->agentnum ? 1 : 0 ),
+ 'viewall_right' => 'None', #override default 'View customers of all agents'
)
%>
diff --git a/httemplate/elements/tr-select-agent.html b/httemplate/elements/tr-select-agent.html
index fcfa9f3..9f2f76a 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',
+
+ );
+
+</%doc>
% if ( scalar(@agents) == 1 ) {
<INPUT TYPE="hidden" NAME="<% $opt{'field'} || 'agentnum' %>" VALUE="<% $agents[0]->agentnum %>">
@@ -26,8 +50,11 @@
my %opt = @_;
my $agentnum = $opt{'curr_value'} || $opt{'value'};
-my @agents = $opt{'agents'}
- ? @{ $opt{'agents'} }
- : $FS::CurrentUser::CurrentUser->agents;
+my @agents =
+ $opt{'agents'}
+ ? @{ $opt{'agents'} }
+ : $FS::CurrentUser::CurrentUser->agents(
+ 'viewall_right' => $opt{'viewall_right'},
+ );
</%init>
diff --git a/httemplate/misc/inventory_item-import.html b/httemplate/misc/inventory_item-import.html
index 990c14f..d264baf 100644
--- a/httemplate/misc/inventory_item-import.html
+++ b/httemplate/misc/inventory_item-import.html
@@ -24,7 +24,10 @@ Import a file containing <% PL($inventory_class->classname) %>, one per line.
%# <INPUT TYPE="hidden" NAME="itembatch" VALUE="<% $itembatch %>">
- <% include('/elements/tr-select-agent.html') %>
+ <% include('/elements/tr-select-agent.html',
+ 'viewall_right' => 'None',
+ )
+ %>
<% include( '/elements/file-upload.html',
'field' => 'file',