summaryrefslogtreecommitdiff
path: root/FS/FS/part_event/Action
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2016-03-23 11:46:41 -0700
committerMark Wells <mark@freeside.biz>2016-03-23 11:47:07 -0700
commite99c5d8493912f1b8e7d6a4806bf1964730c6795 (patch)
treeb039a211d903a9eb14202190cf65e8626c772cde /FS/FS/part_event/Action
parent1e70119f22c91c80c1a9aff7bd1d2b37fd5c7ff2 (diff)
add event action to send an invoice attached to a notice, #40152
Diffstat (limited to 'FS/FS/part_event/Action')
-rw-r--r--FS/FS/part_event/Action/cust_bill_send_with_notice.pm48
-rw-r--r--FS/FS/part_event/Action/letter.pm2
2 files changed, 49 insertions, 1 deletions
diff --git a/FS/FS/part_event/Action/cust_bill_send_with_notice.pm b/FS/FS/part_event/Action/cust_bill_send_with_notice.pm
new file mode 100644
index 0000000..10e86e3
--- /dev/null
+++ b/FS/FS/part_event/Action/cust_bill_send_with_notice.pm
@@ -0,0 +1,48 @@
+package FS::part_event::Action::cust_bill_send_with_notice;
+
+use strict;
+use base qw( FS::part_event::Action );
+use FS::msg_template;
+use MIME::Entity;
+
+sub description { 'Email a notice to the customer with invoice attached'; }
+
+sub eventtable_hashref {
+ { 'cust_bill' => 1 };
+}
+
+sub option_fields {
+ (
+ 'msgnum' => { label => 'Message template',
+ type => 'select-table',
+ table => 'msg_template',
+ hashref => { disabled => '' },
+ name_col => 'msgname',
+ disable_empty => 1,
+ },
+ 'modenum' => { label => 'Invoice mode',
+ type => 'select-invoice_mode',
+ },
+
+ );
+}
+
+sub default_weight { 56; }
+
+sub do_action {
+ my( $self, $cust_bill, %opt ) = @_;
+
+ $cust_bill->set('mode' => $self->option('modenum'));
+ my %args = ( 'time' => $opt{'time'} );
+ my $mimepart = MIME::Entity->build( $cust_bill->mimebuild_pdf(\%args) );
+ my $msgnum = $self->option('msgnum');
+ my $msg_template = FS::msg_template->by_key($msgnum)
+ or die "can't find message template #$msgnum to send with invoice";
+ $msg_template->send(
+ 'cust_main' => $cust_bill->cust_main,
+ 'object' => $cust_bill,
+ 'attach' => $mimepart
+ );
+}
+
+1;
diff --git a/FS/FS/part_event/Action/letter.pm b/FS/FS/part_event/Action/letter.pm
index 835dec2..123b990 100644
--- a/FS/FS/part_event/Action/letter.pm
+++ b/FS/FS/part_event/Action/letter.pm
@@ -26,7 +26,7 @@ sub option_fields {
);
}
-sub default_weight { 56; } #?
+sub default_weight { 58; }
sub do_action {
my( $self, $object ) = @_;