From: mark Date: Wed, 22 Sep 2010 23:04:32 +0000 (+0000) Subject: event action to send a notice to a fixed address, RT#8209 X-Git-Tag: freeside_2_1_1^2~26 X-Git-Url: http://git.freeside.biz/gitweb/?a=commitdiff_plain;h=523edd344793bba1c53a622dcc618e74a962bcb6;p=freeside.git event action to send a notice to a fixed address, RT#8209 --- 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; diff --git a/httemplate/edit/msg_template.html b/httemplate/edit/msg_template.html index a60f2d0c1..4546db98b 100644 --- a/httemplate/edit/msg_template.html +++ b/httemplate/edit/msg_template.html @@ -48,6 +48,7 @@ my %substitutions = ( '$classname' => 'Customer class', '$categoryname' => 'Customer category', '$balance' => 'Current balance', + '$credit_limit' => 'Credit limit', '$invoicing_list_emailonly' => 'Billing email address', '$cust_status' => 'Status', '$ucfirst_cust_status' => 'Status, capitalized',