From a1871d3d13c1dafa93b956762c0d23728d261da7 Mon Sep 17 00:00:00 2001 From: jeff Date: Sat, 28 Jun 2008 19:25:24 +0000 Subject: agent virtualize address blocks and routers --- httemplate/elements/select-table.html | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'httemplate/elements/select-table.html') diff --git a/httemplate/elements/select-table.html b/httemplate/elements/select-table.html index 7339f362c..d24c9abe4 100644 --- a/httemplate/elements/select-table.html +++ b/httemplate/elements/select-table.html @@ -92,14 +92,25 @@ my $name_col = $opt{'name_col'}; my $value = $opt{'curr_value'} || $opt{'value'}; $value = [ split(/\s*,\s*/, $value) ] if $opt{'multiple'} && $value =~ /,/; +my $extra_sql = $opt{'extra_sql'} || ''; +my $hashref = $opt{'hashref'} || {}; + +if ( $opt{'agent_virt'} ) { + $extra_sql .= + ( $extra_sql =~ /WHERE/i || scalar(keys %$hashref ) ? ' AND ' : ' WHERE ' ). + $FS::CurrentUser::CurrentUser->agentnums_sql( + 'null_right' => $opt{'agent_null_right'} + ); +} + my @records = (); if ( $opt{'records'} ) { @records = @{ $opt{'records'} }; } else { @records = qsearch( { 'table' => $opt{'table'}, - 'hashref' => ( $opt{'hashref'} || {} ), - 'extra_sql' => ( $opt{'extra_sql'} || '' ), + 'hashref' => $hashref, + 'extra_sql' => $extra_sql, 'order_by' => ( $opt{'order_by'} || "ORDER BY $name_col" ), }); } @@ -113,7 +124,7 @@ unless ( ! $value $opt{hashref}->{$key} = $value; my $record = qsearchs( { 'table' => $opt{table}, - 'hashref' => $opt{hashref}, + 'hashref' => $hashref, 'extra_sql' => ( $opt{extra_sql} || '' ), }); push @records, $record if $record; -- cgit v1.2.1