summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Misc.pm5
-rw-r--r--FS/FS/Schema.pm3
-rw-r--r--FS/FS/cust_bill.pm2
-rw-r--r--FS/FS/cust_msg.pm17
-rw-r--r--FS/FS/cust_pay.pm6
-rw-r--r--FS/FS/cust_pkg.pm6
-rw-r--r--FS/FS/part_export/send_email.pm1
7 files changed, 29 insertions, 11 deletions
diff --git a/FS/FS/Misc.pm b/FS/FS/Misc.pm
index 9c18961ea..c598507cc 100644
--- a/FS/FS/Misc.pm
+++ b/FS/FS/Misc.pm
@@ -267,7 +267,7 @@ sub send_email {
}
# Logging
- if ( $conf->exists('log_sent_mail') and $options{'custnum'} ) {
+ if ( $conf->exists('log_sent_mail') ) {
my $cust_msg = FS::cust_msg->new({
'env_from' => $options{'from'},
'env_to' => join(', ', @to),
@@ -278,6 +278,7 @@ sub send_email {
'custnum' => $options{'custnum'},
'msgnum' => $options{'msgnum'},
'status' => ($error ? 'failed' : 'sent'),
+ 'msgtype' => $options{'msgtype'},
});
$cust_msg->insert; # ignore errors
}
@@ -337,7 +338,7 @@ sub generate_email {
my $me = '[FS::Misc::generate_email]';
- my @fields = qw(from to bcc subject custnum msgnum);
+ my @fields = qw(from to bcc subject custnum msgnum msgtype);
my %return;
@return{@fields} = @args{@fields};
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index b8321618e..fbeeb0d4b 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -4220,7 +4220,7 @@ sub tables_hashref {
'cust_msg' => {
'columns' => [
'custmsgnum', 'serial', '', '', '', '',
- 'custnum', 'int', '', '', '', '',
+ 'custnum', 'int', 'NULL', '', '', '',
'msgnum', 'int', 'NULL', '', '', '',
'_date', @date_type, '', '',
'env_from', 'varchar', 'NULL', 255, '', '',
@@ -4229,6 +4229,7 @@ sub tables_hashref {
'body', 'blob', 'NULL', '', '', '',
'error', 'varchar', 'NULL', 255, '', '',
'status', 'varchar', '',$char_d, '', '',
+ 'msgtype', 'varchar', 'NULL', 16, '', '',
],
'primary_key' => 'custmsgnum',
'unique' => [ ],
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index 4f4d438de..44e7b4682 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -1083,6 +1083,8 @@ sub generate_email {
my %return = (
'from' => $args{'from'},
'subject' => ($args{'subject'} || $self->email_subject),
+ 'custnum' => $self->custnum,
+ 'msgtype' => 'invoice',
);
$args{'unsquelch_cdr'} = $conf->exists('voip-cdr_email');
diff --git a/FS/FS/cust_msg.pm b/FS/FS/cust_msg.pm
index c9cf68663..8d57a54ac 100644
--- a/FS/FS/cust_msg.pm
+++ b/FS/FS/cust_msg.pm
@@ -22,9 +22,9 @@ FS::cust_msg - Object methods for cust_msg records
=head1 DESCRIPTION
-An FS::cust_msg object represents a template-generated message sent to
-a customer (see L<FS::msg_template>). FS::cust_msg inherits from
-FS::Record. The following fields are currently supported:
+An FS::cust_msg object represents an email message generated by Freeside
+and sent to a customer (see L<FS::msg_template>). FS::cust_msg inherits
+from FS::Record. The following fields are currently supported:
=over 4
@@ -34,6 +34,8 @@ FS::Record. The following fields are currently supported:
=item msgnum - template number
+=item msgtype - the message type
+
=item _date - the time the message was sent
=item env_from - envelope From address
@@ -125,8 +127,8 @@ sub check {
my $error =
$self->ut_numbern('custmsgnum')
- || $self->ut_number('custnum')
- || $self->ut_foreign_key('custnum', 'cust_main', 'custnum')
+ || $self->ut_numbern('custnum')
+ || $self->ut_foreign_keyn('custnum', 'cust_main', 'custnum')
|| $self->ut_numbern('msgnum')
|| $self->ut_foreign_keyn('msgnum', 'msg_template', 'msgnum')
|| $self->ut_numbern('_date')
@@ -136,6 +138,11 @@ sub check {
|| $self->ut_anything('body')
|| $self->ut_enum('status', \@statuses)
|| $self->ut_textn('error')
+ || $self->ut_enum('msgtype', [ '',
+ 'invoice',
+ 'receipt',
+ 'admin',
+ ])
;
return $error if $error;
diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm
index 046b7c7b5..12bf12b47 100644
--- a/FS/FS/cust_pay.pm
+++ b/FS/FS/cust_pay.pm
@@ -645,11 +645,12 @@ sub send_receipt {
'custnum' => $cust_main->custnum,
};
$error = $queue->insert(
- FS::msg_template->by_key($msgnum)->prepare(
+ FS::msg_template->by_key($msgnum)->prepare(
'cust_main' => $cust_main,
'object' => $self,
'from_config' => 'payment_receipt_from',
- )
+ ),
+ 'msgtype' => 'receipt', # override msg_template's default
);
} elsif ( $conf->exists('payment_receipt_email') ) {
@@ -692,6 +693,7 @@ sub send_receipt {
'job' => 'FS::Misc::process_send_generated_email',
'paynum' => $self->paynum,
'custnum' => $cust_main->custnum,
+ 'msgtype' => 'receipt',
};
$error = $queue->insert(
'from' => $conf->config('invoice_from', $cust_main->agentnum),
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index 5779d5c10..c2c5bbb34 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -935,6 +935,8 @@ sub cancel {
'to' => \@invoicing_list,
'subject' => ( $conf->config('cancelsubject') || 'Cancellation Notice' ),
'body' => [ map "$_\n", $conf->config('cancelmessage') ],
+ 'custnum' => $self->custnum,
+ 'msgtype' => '', #admin?
);
}
#should this do something on errors?
@@ -1376,6 +1378,8 @@ sub suspend {
'Package : #'. $self->pkgnum. " (". $self->part_pkg->pkg_comment. ")\n",
( map { "Service : $_\n" } @labels ),
],
+ 'custnum' => $self->custnum,
+ 'msgtype' => 'admin'
);
if ( $error ) {
@@ -1629,6 +1633,8 @@ sub unsuspend {
: ''
),
],
+ 'custnum' => $self->custnum,
+ 'msgtype' => 'admin',
);
if ( $error ) {
diff --git a/FS/FS/part_export/send_email.pm b/FS/FS/part_export/send_email.pm
index 1fcb828b7..41f04093e 100644
--- a/FS/FS/part_export/send_email.pm
+++ b/FS/FS/part_export/send_email.pm
@@ -6,7 +6,6 @@ use FS::part_export;
use FS::Record qw(qsearch qsearchs);
use FS::Conf;
use FS::msg_template;
-use FS::Misc qw(send_email);
@ISA = qw(FS::part_export);