X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Ftower.pm;h=8a93d8f23253249203d235b32e00457fb3060cd6;hp=227e3eb6608fa7ff4b3a7bb0d02ca0c022268b03;hb=ffa18709ee8a4d05e18d2d406cf73afe79e52524;hpb=c81adbf7bbaa537b650f39bb76ce0b7b8c069450 diff --git a/FS/FS/tower.pm b/FS/FS/tower.pm index 227e3eb66..8a93d8f23 100644 --- a/FS/FS/tower.pm +++ b/FS/FS/tower.pm @@ -1,10 +1,10 @@ package FS::tower; +use base qw( FS::o2m_Common FS::Record ); use strict; -use base qw( FS::o2m_Common FS::Record ); +use List::Util qw( max ); use FS::Record qw( qsearch qsearchs ); use FS::tower_sector; -use List::Util qw( max ); =head1 NAME @@ -44,6 +44,14 @@ Tower name Disabled flag, empty or 'Y' +=item up_rate_limit + +Up Rate limit for towner + +=item down_rate_limit + +Down Rate limit for tower + =back =head1 METHODS @@ -59,8 +67,6 @@ points to. You can ask the object for a copy with the I method. =cut -# the new method can be inherited from FS::Record, if a table method is defined - sub table { 'tower'; } =item insert @@ -68,14 +74,10 @@ sub table { 'tower'; } Adds this record to the database. If there is an error, returns the error, otherwise returns false. -=cut - =item delete Delete this record from the database. -=cut - =item replace OLD_RECORD Replaces the OLD_RECORD with this one in the database. If there is an error, @@ -83,7 +85,24 @@ returns the error, otherwise returns false. =cut -# the replace method can be inherited from FS::Record +sub replace { + my $self = shift; + my $old = shift || $self->replace_old; + # editing the tower location needs to regenerate coverage on its sectors + my $regen_coverage = 0; + foreach (qw(latitude longitude height)) { + $regen_coverage = 1 if $self->get($_) != $old->get($_); + } + + my $error = $self->SUPER::replace($old); + return $error if $error; + + if ($regen_coverage) { + foreach my $sector ($self->tower_sector) { + $sector->queue_generate_coverage; + } + } +} =item check @@ -93,9 +112,6 @@ and replace methods. =cut -# the check method should currently be supplied - FS::Record contains some -# data checking routines - sub check { my $self = shift; @@ -103,6 +119,15 @@ sub check { $self->ut_numbern('towernum') || $self->ut_text('towername') || $self->ut_enum('disabled', [ '', 'Y' ]) + || $self->ut_coordn('latitude') + || $self->ut_coordn('longitude') + || $self->ut_enum('coord_auto', [ '', 'Y' ]) + || $self->ut_floatn('altitude') + || $self->ut_floatn('height') + || $self->ut_floatn('veg_height') + || $self->ut_alphan('color') + || $self->ut_numbern('up_rate_limit') + || $self->ut_numbern('down_rate_limit') ; return $error if $error; @@ -149,7 +174,7 @@ default sector. sub process_o2m { my $self = shift; my %opt = @_; - my $params = $opt{params}; + my $params = +{ %{$opt{params}} }; # Adjust to make sure our default sector is in the list. my $default_sector = $self->default_sector