fix error on advanced broadband report when selecting a router, RT#14626
[freeside.git] / FS / FS / svc_acct.pm
index 9a2f009..37c55d6 100644 (file)
@@ -2227,20 +2227,19 @@ sub _op_overlimit {
 
   my $cust_pkg = $self->cust_svc->cust_pkg;
 
-  my $conf_overlimit =
+  my @conf_overlimit =
     $cust_pkg
       ? $conf->config('overlimit_groups', $cust_pkg->cust_main->agentnum )
       : $conf->config('overlimit_groups');
 
   foreach my $part_export ( $self->cust_svc->part_svc->part_export ) {
 
-    my $groups = $conf_overlimit || $part_export->option('overlimit_groups');
-    next unless $groups;
-
-    my $gref = &{ $self->_fieldhandlers->{'usergroup'} }( $self, $groups );
+    my @groups = scalar(@conf_overlimit) ? @conf_overlimit
+                                         : split(' ',$part_export->option('overlimit_groups'));
+    next unless scalar(@groups);
 
     my $other = new FS::svc_acct $self->hashref;
-    $other->usergroup( $gref );
+    $other->usergroup(\@groups);
 
     my($new,$old);
     if ($action eq 'suspend') {
@@ -2563,7 +2562,13 @@ sub radius_groups {
       unless ref($self->usergroup) eq 'ARRAY';
     #when provisioning records, export callback runs in svc_Common.pm before
     #radius_usergroup records can be inserted...
-    @{$self->usergroup};
+    my $groups = join(',',@{$self->usergroup});
+    my @groups;
+    return @groups unless length($groups);
+    @groups = qsearch({ 'table'         => 'radius_group',
+                           'extra_sql'     => "where groupnum in ($groups)",
+                        });
+    map { $_->groupname } @groups;
   } else {
      my $format = shift || '';
      my @groups = qsearch({ 'table'         => 'radius_usergroup',
@@ -2928,7 +2933,7 @@ sub search {
 
   #agentnum
   if ( $params->{'agentnum'} =~ /^(\d+)$/ and $1 ) {
-    push @where, "agentnum = $1";
+    push @where, "cust_main.agentnum = $1";
   }
 
   #custnum