summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2008-10-11 00:32:21 +0000
committerivan <ivan>2008-10-11 00:32:21 +0000
commitc093d1dbd7e925a1252bd393d68e6cffec60a0e5 (patch)
treebc4b7e0d0afcb08dd0c01f733a0ae7a6cebcd3ca
parent458ee7e44e909197be3754141ee1d3c4a84533cc (diff)
enable suspension notices to an administrator, RT#4083
-rw-r--r--FS/FS/Conf.pm7
-rw-r--r--FS/FS/cust_pkg.pm36
2 files changed, 42 insertions, 1 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 3991c03e0..6251b0366 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -2387,6 +2387,13 @@ worry that config_items is freeside-specific and icky.
'type' => 'text',
},
+ {
+ 'key' => 'suspend_email_admin',
+ 'section' => '',
+ 'description' => 'Destination admin email address to enable suspension notices',
+ 'type' => 'text',
+ },
+
);
1;
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index bc6e46b61..184826452 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -672,6 +672,9 @@ sub suspend {
}
unless ( $date ) {
+
+ my @labels = ();
+
foreach my $cust_svc (
qsearch( 'cust_svc', { 'pkgnum' => $self->pkgnum } )
) {
@@ -691,12 +694,43 @@ sub suspend {
$dbh->rollback if $oldAutoCommit;
return $error;
}
+ my( $label, $value ) = $cust_svc->label;
+ push @labels, "$label: $value";
}
}
+
+ my $conf = new FS::Conf;
+ if ( $conf->config('suspend_email_admin') ) {
+
+ my $error = send_email(
+ 'from' => $conf->config('invoice_from'), #??? well as good as any
+ 'to' => $conf->config('suspend_email_admin'),
+ 'subject' => 'FREESIDE NOTIFICATION: Customer package suspended',
+ 'body' => [
+ "This is an automatic message from your Freeside installation\n",
+ "informing you that the following customer package has been suspended:\n",
+ "\n",
+ 'Customer: #'. $self->custnum. ' '. $self->cust_main->name. "\n",
+ 'Package : #'. $self->pkgnum. " (". $self->part_pkg->pkg_comment. ")\n",
+ ( map { "Service : $_\n" } @labels ),
+ ],
+ );
+
+ if ( $error ) {
+ warn "WARNING: can't send suspension admin email (suspending anyway): ".
+ "$error\n";
+ }
+
+ }
+
}
my %hash = $self->hash;
- $date ? ($hash{'adjourn'} = $date) : ($hash{'susp'} = time);
+ if ( $date ) {
+ $hash{'adjourn'} = $date;
+ } else {
+ $hash{'susp'} = time;
+ }
my $new = new FS::cust_pkg ( \%hash );
$error = $new->replace( $self, options => { $self->options } );
if ( $error ) {