X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Ftower.pm;h=18b43fe7dc451c9fb870b55703d2c086cc224145;hb=2a56c671635687bf2648eb3a7cf4bce228101af3;hp=5497c7217ec5aa72337b0de6c4dc774d584bc09f;hpb=822d38841a1620b8b8e8c5ac4102ad64de9ae17f;p=freeside.git diff --git a/FS/FS/tower.pm b/FS/FS/tower.pm index 5497c7217..18b43fe7d 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 @@ -75,6 +75,27 @@ Delete this record from the database. Replaces the OLD_RECORD with this one in the database. If there is an error, returns the error, otherwise returns false. +=cut + +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 Checks all fields to make sure this is a valid tower. If there is @@ -143,7 +164,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