X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fsearch%2Fsqlradius_usage.html;h=494a275912ab0e09229618bb06408911c6c82ef1;hp=11ec307ceaea007062d4fbefac3ff55a9e91327c;hb=ae2ce7f3fc2a0fe00f05145ce64e8b6b8c034631;hpb=752e12c741bcb43a1b3eec64c213452adc56b843 diff --git a/httemplate/search/sqlradius_usage.html b/httemplate/search/sqlradius_usage.html index 11ec307ce..494a27591 100644 --- a/httemplate/search/sqlradius_usage.html +++ b/httemplate/search/sqlradius_usage.html @@ -64,20 +64,36 @@ my $curuser = $FS::CurrentUser::CurrentUser; die "access denied" unless $curuser->access_right('List services'); my $title = 'Data Usage Report - '; -my $agentnum; -my @include_agents; +my $agentnum = ''; +my @include_agents = (); -if ( $opt{'agentnum'} ) { +if ( $opt{'agentnum'} =~ /^(\d+)$/ ) { $agentnum = $opt{'agentnum'}; -} elsif ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { - $agentnum = $1; +} else { + + my @agentnums = grep /^(\d+)$/, $cgi->param('agentnum'); + + if ( ! @agentnums ) { + @include_agents = qsearch({ 'table' => 'agent', + 'hashref' => { 'disabled'=>'' }, + 'extra_sql' => ' AND '. $curuser->agentnums_sql, + }); + } elsif ( scalar(@agentnums) == 1 ) { + $agentnum = $agentnums[0]; + } else { + @include_agents = qsearch({ 'table' => 'agent', + 'hashref' => { 'disabled' => '', }, + 'extra_sql' => 'AND agentnum IN ('. + join(',',@agentnums). ') '. + ' AND '. $curuser->agentnums_sql, + }); + } + } if ( $agentnum ) { my $agent = FS::agent->by_key($agentnum); $title = $agent->agent." $title"; -} else { - @include_agents = qsearch('agent', {}); } # usage query params