From 75a2e8dbba40070ced5503457696baf5d538b953 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 23 Jul 2010 00:11:51 +0000 Subject: [PATCH] 'View customers of all agents' doesn't mean create them, or upload inventory, RT#7010 --- FS/FS/access_user.pm | 6 +++--- httemplate/edit/cust_main/top_misc.html | 1 + httemplate/elements/tr-select-agent.html | 33 +++++++++++++++++++++++++++--- httemplate/misc/inventory_item-import.html | 5 ++++- 4 files changed, 38 insertions(+), 7 deletions(-) diff --git a/FS/FS/access_user.pm b/FS/FS/access_user.pm index 25aa8af01..8c8ba8b9f 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 916bac001..441a36334 100644 --- a/httemplate/edit/cust_main/top_misc.html +++ b/httemplate/edit/cust_main/top_misc.html @@ -13,6 +13,7 @@ 'label' => "${r}Agent", '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 fcfa9f300..9f2f76a6c 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', + + ); + + % if ( scalar(@agents) == 1 ) { @@ -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'}, + ); diff --git a/httemplate/misc/inventory_item-import.html b/httemplate/misc/inventory_item-import.html index 990c14ffc..d264bafc5 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. %# - <% include('/elements/tr-select-agent.html') %> + <% include('/elements/tr-select-agent.html', + 'viewall_right' => 'None', + ) + %> <% include( '/elements/file-upload.html', 'field' => 'file', -- 2.11.0