broadband_nas export, #15284
[freeside.git] / FS / FS / svc_broadband.pm
index 35de8b3..a85fc5c 100755 (executable)
@@ -2,6 +2,8 @@ package FS::svc_broadband;
 
 use strict;
 use vars qw(@ISA $conf);
+
+use base qw(FS::svc_Radius_Mixin FS::svc_Tower_Mixin FS::svc_Common);
 use NetAddr::IP;
 use FS::Record qw( qsearchs qsearch dbh );
 use FS::svc_Common;
@@ -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_Common );
-
 $FS::UID::callback{'FS::svc_broadband'} = sub { 
   $conf = new FS::Conf;
 };
@@ -346,10 +346,6 @@ sub check {
 
   return $x unless ref($x);
 
-  my $nw_coords = $conf->exists('svc_broadband-require-nw-coordinates');
-  my $lat_lower = $nw_coords ? 1 : -90;
-  my $lon_upper = $nw_coords ? -1 : 180;
-
   # remove delimiters
   my $mac_addr = uc($self->get('mac_addr'));
   $mac_addr =~ s/[-: ]//g;
@@ -365,8 +361,8 @@ sub check {
     || $self->ut_ipn('ip_addr')
     || $self->ut_hexn('mac_addr')
     || $self->ut_hexn('auth_key')
-    || $self->ut_coordn('latitude', $lat_lower, 90)
-    || $self->ut_coordn('longitude', -180, $lon_upper)
+    || $self->ut_coordn('latitude')
+    || $self->ut_coordn('longitude')
     || $self->ut_sfloatn('altitude')
     || $self->ut_textn('vlan_profile')
     || $self->ut_textn('plan_id')
@@ -399,6 +395,17 @@ 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 );
+    } elsif ( $l->latitude && $l->longitude ) {
+      $self->latitude(  $l->latitude  );
+      $self->longitude( $l->longitude );
+    }
+  }
+
   $error = $self->_check_ip_addr;
   return $error if $error;
 
@@ -481,16 +488,6 @@ sub NetAddr {
   new NetAddr::IP ($self->ip_addr);
 }
 
-=item tower_sector
-
-=cut
-
-sub tower_sector {
-  my $self = shift;
-  return '' unless $self->sectornum;
-  qsearchs('tower_sector', { sectornum => $self->sectornum });
-}
-
 =item addr_block
 
 Returns the FS::addr_block record (i.e. the address block) for this broadband service.