RT# 76309 - Updated 3 email notices to use more billing event types
[freeside.git] / FS / FS / part_event / Action / notice.pm
1 package FS::part_event::Action::notice;
2
3 use strict;
4 use base qw( FS::part_event::Action );
5 use FS::Record qw( qsearchs );
6 use FS::msg_template;
7
8 sub description { 'Email a notice to the customer\'s billing address'; }
9
10 sub eventtable_hashref {
11     {
12       'cust_main'      => 1,
13       'cust_bill'      => 1,
14       'cust_pkg'       => 1,
15       'cust_pay'       => 1,
16       'cust_pay_batch' => 1,
17       'cust_statement' => 1,
18       'svc_acct'       => 1,
19     };
20 }
21
22 sub option_fields {
23   (
24     'msgnum' => { 'label'    => 'Template',
25                   'type'     => 'select-table',
26                   'table'    => 'msg_template',
27                   'hashref'  => { disabled => '' },
28                   'name_col' => 'msgname',
29                   'disable_empty' => 1,
30                 },
31   );
32 }
33
34 sub default_weight { 55; } #?
35
36 sub do_action {
37   my( $self, $object ) = @_;
38
39   my $cust_main = $self->cust_main($object);
40
41   my $msgnum = $self->option('msgnum');
42
43   my $msg_template = qsearchs('msg_template', { 'msgnum' => $msgnum } )
44       or die "Template $msgnum not found";
45
46   $msg_template->send(
47     'cust_main' => $cust_main,
48     'object'    => $object,
49   );
50
51 }
52
53 1;