MySQL support, RT#28895
[freeside.git] / FS / FS / tower_sector.pm
index 80e7f51..4fbd89c 100644 (file)
@@ -1,9 +1,7 @@
 package FS::tower_sector;
 package FS::tower_sector;
+use base qw( FS::Record );
 
 use strict;
 
 use strict;
-use base qw( FS::Record );
-use FS::Record qw( qsearchs ); # qsearch );
-use FS::tower;
 
 =head1 NAME
 
 
 =head1 NAME
 
@@ -26,8 +24,8 @@ FS::tower_sector - Object methods for tower_sector records
 
 =head1 DESCRIPTION
 
 
 =head1 DESCRIPTION
 
-An FS::tower_sector object represents an example.  FS::tower_sector inherits from
-FS::Record.  The following fields are currently supported:
+An FS::tower_sector object represents an tower sector.  FS::tower_sector
+inherits from FS::Record.  The following fields are currently supported:
 
 =over 4
 
 
 =over 4
 
@@ -56,15 +54,13 @@ ip_addr
 
 =item new HASHREF
 
 
 =item new HASHREF
 
-Creates a new example.  To add the example to the database, see L<"insert">.
+Creates a new sector.  To add the sector to the database, see L<"insert">.
 
 Note that this stores the hash reference, not a distinct copy of the hash it
 points to.  You can ask the object for a copy with the I<hash> method.
 
 =cut
 
 
 Note that this stores the hash reference, not a distinct copy of the hash it
 points to.  You can ask the object for a copy with the I<hash> method.
 
 =cut
 
-# the new method can be inherited from FS::Record, if a table method is defined
-
 sub table { 'tower_sector'; }
 
 =item insert
 sub table { 'tower_sector'; }
 
 =item insert
@@ -72,38 +68,35 @@ sub table { 'tower_sector'; }
 Adds this record to the database.  If there is an error, returns the error,
 otherwise returns false.
 
 Adds this record to the database.  If there is an error, returns the error,
 otherwise returns false.
 
-=cut
-
-# the insert method can be inherited from FS::Record
-
 =item delete
 
 Delete this record from the database.
 
 =cut
 
 =item delete
 
 Delete this record from the database.
 
 =cut
 
-# the delete method can be inherited from FS::Record
+sub delete {
+  my $self = shift;
+
+  #not the most efficient, not not awful, and its not like deleting a sector
+  # with customers is a common operation
+  return "Can't delete a sector with customers" if $self->svc_broadband;
+
+  $self->SUPER::delete;
+}
 
 =item replace OLD_RECORD
 
 Replaces the OLD_RECORD with this one in the database.  If there is an error,
 returns the error, otherwise returns false.
 
 
 =item replace OLD_RECORD
 
 Replaces the OLD_RECORD with this one in the database.  If there is an error,
 returns the error, otherwise returns false.
 
-=cut
-
-# the replace method can be inherited from FS::Record
-
 =item check
 
 =item check
 
-Checks all fields to make sure this is a valid example.  If there is
+Checks all fields to make sure this is a valid sector.  If there is
 an error, returns the error, otherwise returns false.  Called by the insert
 and replace methods.
 
 =cut
 
 an error, returns the error, otherwise returns false.  Called by the insert
 and replace methods.
 
 =cut
 
-# the check method should currently be supplied - FS::Record contains some
-# data checking routines
-
 sub check {
   my $self = shift;
 
 sub check {
   my $self = shift;
 
@@ -112,6 +105,11 @@ sub check {
     || $self->ut_number('towernum', 'tower', 'towernum')
     || $self->ut_text('sectorname')
     || $self->ut_textn('ip_addr')
     || $self->ut_number('towernum', 'tower', 'towernum')
     || $self->ut_text('sectorname')
     || $self->ut_textn('ip_addr')
+    || $self->ut_floatn('height')
+    || $self->ut_numbern('freq_mhz')
+    || $self->ut_numbern('direction')
+    || $self->ut_numbern('width')
+    || $self->ut_floatn('sector_range')
   ;
   return $error if $error;
 
   ;
   return $error if $error;
 
@@ -122,13 +120,6 @@ sub check {
 
 Returns the tower for this sector, as an FS::tower object (see L<FS::tower>).
 
 
 Returns the tower for this sector, as an FS::tower object (see L<FS::tower>).
 
-=cut
-
-sub tower {
-  my $self = shift;
-  qsearchs('tower', { 'towernum'=>$self->towernum } );
-}
-
 =item description
 
 Returns a description for this sector including tower name.
 =item description
 
 Returns a description for this sector including tower name.
@@ -145,6 +136,10 @@ sub description {
   }
 }
 
   }
 }
 
+=item svc_broadband
+
+Returns the services on this tower sector.
+
 =back
 
 =head1 BUGS
 =back
 
 =head1 BUGS