autogenerate coverage maps on tower edit
[freeside.git] / FS / FS / tower.pm
index a05160c..18b43fe 100644 (file)
@@ -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