diff options
author | mark <mark> | 2010-09-22 23:04:32 +0000 |
---|---|---|
committer | mark <mark> | 2010-09-22 23:04:32 +0000 |
commit | 523edd344793bba1c53a622dcc618e74a962bcb6 (patch) | |
tree | e9cef77a51cd9dc0c282838828deda99b1ca692a /FS | |
parent | a5713014d58b2a6f4d5f795fbda6aa50126c2afb (diff) |
event action to send a notice to a fixed address, RT#8209
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/msg_template.pm | 8 | ||||
-rw-r--r-- | FS/FS/part_event/Action/notice.pm | 2 | ||||
-rw-r--r-- | FS/FS/part_event/Action/notice_to.pm | 55 |
3 files changed, 63 insertions, 2 deletions
diff --git a/FS/FS/msg_template.pm b/FS/FS/msg_template.pm index 50298d278..7321351d3 100644 --- a/FS/FS/msg_template.pm +++ b/FS/FS/msg_template.pm @@ -168,6 +168,11 @@ Customer object (required). Additional context object (currently, can be a cust_main, cust_pkg, cust_bill, svc_acct, cust_pay, or cust_pay_pending object). +=item to + +Destination address. The default is to use the customer's +invoicing_list addresses. + =back =cut @@ -247,7 +252,7 @@ sub prepare { # and email ### - my @to = $cust_main->invoicing_list_emailonly; + my @to = ($opt{'to'}) || $cust_main->invoicing_list_emailonly; warn "prepared msg_template with no email destination (custnum ". $cust_main->custnum.")\n" if !@to; @@ -311,6 +316,7 @@ sub substitutions { num_cancelled_pkgs num_ncancelled_pkgs num_pkgs classname categoryname balance + credit_limit invoicing_list_emailonly cust_status ucfirst_cust_status cust_statuscolor diff --git a/FS/FS/part_event/Action/notice.pm b/FS/FS/part_event/Action/notice.pm index 126965374..8e22c6844 100644 --- a/FS/FS/part_event/Action/notice.pm +++ b/FS/FS/part_event/Action/notice.pm @@ -5,7 +5,7 @@ use base qw( FS::part_event::Action ); use FS::Record qw( qsearchs ); use FS::msg_template; -sub description { 'Send a notice from a message template'; } +sub description { 'Email a notice to the customer\'s billing address'; } #sub eventtable_hashref { # { 'cust_main' => 1, diff --git a/FS/FS/part_event/Action/notice_to.pm b/FS/FS/part_event/Action/notice_to.pm new file mode 100644 index 000000000..194aeb84f --- /dev/null +++ b/FS/FS/part_event/Action/notice_to.pm @@ -0,0 +1,55 @@ +package FS::part_event::Action::notice_to; + +use strict; +use base qw( FS::part_event::Action ); +use FS::Record qw( qsearchs ); +use FS::msg_template; + +sub description { 'Email a notice to a specific address'; } + +#sub eventtable_hashref { +# { 'cust_main' => 1, +# 'cust_bill' => 1, +# 'cust_pkg' => 1, +# }; +#} + +sub option_fields { + ( + 'to' => { 'label' => 'Destination', + 'type' => 'text', + 'size' => 30, + }, + 'msgnum' => { 'label' => 'Template', + 'type' => 'select-table', + 'table' => 'msg_template', + 'name_col' => 'msgname', + 'disable_empty' => 1, + }, + ); +} + +sub default_weight { 56; } #? + +sub do_action { + my( $self, $object ) = @_; + + my $cust_main = $self->cust_main($object); + + my $msgnum = $self->option('msgnum'); + + my $msg_template = qsearchs('msg_template', { 'msgnum' => $msgnum } ) + or die "Template $msgnum not found"; + + my $to = $self->option('to') + or die "Can't send notice without a destination address"; + + $msg_template->send( + 'to' => $to, + 'cust_main' => $cust_main, + 'object' => $object, + ); + +} + +1; |