This commit was generated by cvs2svn to compensate for changes in r11022,
[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 #    { 'cust_main' => 1,
12 #      'cust_bill' => 1,
13 #      'cust_pkg'  => 1,
14 #    };
15 #}
16
17 sub option_fields {
18   (
19     'to'     => { 'label'    => 'Destination',
20                   'type'     => 'text',
21                   'size'     => 30,
22                 },
23     'msgnum' => { 'label'    => 'Template',
24                   'type'     => 'select-table',
25                   'table'    => 'msg_template',
26                   'name_col' => 'msgname',
27                   'disable_empty' => 1,
28                 },
29   );
30 }
31
32 sub default_weight { 56; } #?
33
34 sub do_action {
35   my( $self, $object ) = @_;
36
37   my $cust_main = $self->cust_main($object);
38
39   my $msgnum = $self->option('msgnum');
40
41   my $msg_template = qsearchs('msg_template', { 'msgnum' => $msgnum } )
42       or die "Template $msgnum not found";
43
44   my $to = $self->option('to') 
45       or die "Can't send notice without a destination address";
46   
47   $msg_template->send(
48     'to'        => $to,
49     'cust_main' => $cust_main,
50     'object'    => $object,
51   );
52
53 }
54
55 1;