diff options
Diffstat (limited to 'httemplate/elements')
-rw-r--r-- | httemplate/elements/select-agent.html | 2 | ||||
-rw-r--r-- | httemplate/elements/select-table.html | 7 | ||||
-rw-r--r-- | httemplate/elements/tr-select-agent.html | 11 |
3 files changed, 17 insertions, 3 deletions
diff --git a/httemplate/elements/select-agent.html b/httemplate/elements/select-agent.html index aa480a54b..78ec25f82 100644 --- a/httemplate/elements/select-agent.html +++ b/httemplate/elements/select-agent.html @@ -11,6 +11,8 @@ 'value' => $agentnum, 'empty_label' => 'all', 'hashref' => { 'disabled' => '' }, + 'extra_sql' => ' AND '. + $FS::CurrentUser::CurrentUser->agentnums_sql, %select_opt, ) %> diff --git a/httemplate/elements/select-table.html b/httemplate/elements/select-table.html index 96f0177fb..6c8089b31 100644 --- a/httemplate/elements/select-table.html +++ b/httemplate/elements/select-table.html @@ -10,6 +10,7 @@ ##opt # 'empty_label' => '', #better specify it though, the default might change # 'hashref' => {}, + # 'extra_sql' => '', # 'records' => \@records, #instead of hashref # 'pre_options' => [ 'value' => 'option' ], #before normal options @@ -25,7 +26,11 @@ if ( $opt{'records'} ) { @records = @{ $opt{'records'} }; } else { - @records = qsearch( $opt{'table'}, ( $opt{'hashref'} || {} ) ); + @records = qsearch( { + 'table' => $opt{'table'}, + 'hashref' => ( $opt{'hashref'} || {} ), + 'extra_sql' => ( $opt{'extra_sql'} || '' ), + }); } my @pre_options = $opt{'pre_options'} ? @{ $opt{'pre_options'} } : (); diff --git a/httemplate/elements/tr-select-agent.html b/httemplate/elements/tr-select-agent.html index 2227262b6..83c8d1758 100644 --- a/httemplate/elements/tr-select-agent.html +++ b/httemplate/elements/tr-select-agent.html @@ -3,9 +3,16 @@ my @agents; if ( $opt{'agents'} ) { - @agents = @{ $opt{'agents'} }; + #@agents = @{ $opt{'agents'} }; + #here is the agent virtualization + my $agentnums_href = $FS::CurrentUser::CurrentUser->agentnums_href; + @agents = grep $agentnums_href->{$_->agentnum}, @{ $opt{'agents'} }; } else { - @agents = qsearch( 'agent', { disabled=>'' } ); + @agents = qsearch( { + 'table' => 'agent', + 'hashref' => { disabled=>'' }, + 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql, + }); } %> |