search services by tower/sector, #15950
[freeside.git] / FS / FS / svc_broadband.pm
index 1d1fa76..18514af 100755 (executable)
@@ -2,7 +2,9 @@ package FS::svc_broadband;
 
 use strict;
 use vars qw(@ISA $conf);
-use NetAddr::IP;
+
+use base qw(FS::svc_Radius_Mixin FS::svc_Tower_Mixin FS::svc_Common);
+{ no warnings 'redefine'; use NetAddr::IP; }
 use FS::Record qw( qsearchs qsearch dbh );
 use FS::svc_Common;
 use FS::cust_svc;
@@ -10,8 +12,6 @@ use FS::addr_block;
 use FS::part_svc_router;
 use FS::tower_sector;
 
-@ISA = qw( FS::svc_Radius_Mixin FS::svc_Tower_Mixin FS::svc_Common );
-
 $FS::UID::callback{'FS::svc_broadband'} = sub { 
   $conf = new FS::Conf;
 };
@@ -158,6 +158,10 @@ Parameters:
 
 =item routernum - arrayref
 
+=item sectornum - arrayref
+
+=item towernum - arrayref
+
 =item order_by
 
 =back
@@ -214,6 +218,13 @@ sub search {
       push @where, "addr_block.routernum = $1";
     }
   }
+
+  #sector and tower, as above
+  my @where_sector = $class->tower_sector_sql($params);
+  if ( @where_sector ) {
+    push @where, @where_sector;
+    push @from, 'LEFT JOIN tower_sector USING ( sectornum )';
+  }
  
   #svcnum
   if ( $params->{'svcnum'} =~ /^(\d+)$/ ) {
@@ -398,11 +409,11 @@ sub check {
   if ( $cust_pkg && ! $self->latitude && ! $self->longitude ) {
     my $l = $cust_pkg->cust_location_or_main;
     if ( $l->ship_latitude && $l->ship_longitude ) {
-      $self->latitude  = $l->ship_latitude;
-      $self->longitude = $l->ship_longitude;
+      $self->latitude(  $l->ship_latitude  );
+      $self->longitude( $l->ship_longitude );
     } elsif ( $l->latitude && $l->longitude ) {
-      $self->latitude  = $l->latitude;
-      $self->longitude = $l->longitude;
+      $self->latitude(  $l->latitude  );
+      $self->longitude( $l->longitude );
     }
   }