From c0e8da2f1e89729efa1032241e4239765a296514 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 19 Jun 2006 02:33:52 +0000 Subject: agent virtualization, take one (stuff from "inactive" changeset snuck into cust_main.pm and the package reporting changeset in search/cust_pkg.cgi here too) --- httemplate/elements/select-agent.html | 2 ++ httemplate/elements/select-table.html | 7 ++++++- httemplate/elements/tr-select-agent.html | 11 +++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) (limited to 'httemplate/elements') 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, + }); } %> -- cgit v1.2.1