RT# 76309 Fix typo
[freeside.git] / FS / FS / part_event / Action / notice_to.pm
1 package FS::part_event::Action::notice_to;
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 a specific 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     'to'     => { 'label'      => 'Destination',
25                   'type'       => 'text',
26                   'size'       => 30,
27                   'validation' => 'ut_email',
28                 },
29     'msgnum' => { 'label'    => 'Template',
30                   'type'     => 'select-table',
31                   'table'    => 'msg_template',
32                   'name_col' => 'msgname',
33                   'hashref'  => { disabled => '' },
34                   'disable_empty' => 1,
35                 },
36   );
37 }
38
39 sub default_weight { 56; } #?
40
41 sub do_action {
42   my( $self, $object ) = @_;
43
44   my $cust_main = $self->cust_main($object);
45
46   my $msgnum = $self->option('msgnum');
47
48   my $msg_template = qsearchs('msg_template', { 'msgnum' => $msgnum } )
49       or die "Template $msgnum not found";
50
51   my $to = $self->option('to') 
52       or die "Can't send notice without a destination address";
53   
54   $msg_template->send(
55     'to'        => $to,
56     'cust_main' => $cust_main,
57     'object'    => $object,
58   );
59
60 }
61
62 1;