import torrus 1.0.9
[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 #    { 'cust_main' => 1,
12 #      'cust_bill' => 1,
13 #      'cust_pkg'  => 1,
14 #    };
15 #}
16
17 sub option_fields {
18   (
19     'msgnum' => { 'label'    => 'Template',
20                   'type'     => 'select-table',
21                   'table'    => 'msg_template',
22                   'name_col' => 'msgname',
23                   'disable_empty' => 1,
24                 },
25   );
26 }
27
28 sub default_weight { 55; } #?
29
30 sub do_action {
31   my( $self, $object ) = @_;
32
33   my $cust_main = $self->cust_main($object);
34
35   my $msgnum = $self->option('msgnum');
36
37   my $msg_template = qsearchs('msg_template', { 'msgnum' => $msgnum } )
38       or die "Template $msgnum not found";
39
40   $msg_template->send(
41     'cust_main' => $cust_main,
42     'object'    => $object,
43   );
44
45 }
46
47 1;