summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2008-10-11 00:32:17 +0000
committerivan <ivan>2008-10-11 00:32:17 +0000
commit5d6b394a5c676e5b87819a205da545f17fde8616 (patch)
tree24dfb80b8b84329091831d8d81a9b534f8c13a1a
parentc8957643638264651261491fd3b25beeabdbedab (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 46e636b68..61b41685a 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -2460,6 +2460,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 b3359ca64..6d2c6018b 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -758,6 +758,9 @@ sub suspend {
}
unless ( $date ) {
+
+ my @labels = ();
+
foreach my $cust_svc (
qsearch( 'cust_svc', { 'pkgnum' => $self->pkgnum } )
) {
@@ -777,12 +780,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 ) {