suspend event option to skip packages with a start_date, RT#83847
[freeside.git] / FS / FS / part_event / Action / svc_acct_notice.pm
1 package FS::part_event::Action::svc_acct_notice;
2
3 use strict;
4 use base qw( FS::part_event::Action );
5 use FS::Record qw( qsearchs );
6 use FS::svc_acct;
7 use FS::msg_template;
8
9 sub description { 'Email a notice to this account'; }
10
11 sub eventtable_hashref {
12   { 'svc_acct' => 1 }
13 };
14
15 sub option_fields {
16   (
17     'msgnum' => { 'label'    => 'Template',
18                   'type'     => 'select-table',
19                   'table'    => 'msg_template',
20                   'name_col' => 'msgname',
21                   'hashref'  => { disabled => '' },
22                   'disable_empty' => 1,
23                 },
24   );
25 }
26
27 sub default_weight { 56; } #?
28
29 sub do_action {
30   my( $self, $svc_acct ) = @_;
31
32   my $cust_main = $self->cust_main($svc_acct)
33       or die "No customer found for svcnum ".$svc_acct->svcnum;
34     # this will never be run for unlinked services, for several reasons
35
36   my $msgnum = $self->option('msgnum');
37
38   my $msg_template = qsearchs('msg_template', { 'msgnum' => $msgnum } )
39       or die "Template $msgnum not found";
40
41   my $email = $svc_acct->email
42       or die "No email associated with svcnum ".$svc_acct->svcnum;
43
44   $msg_template->send(
45     'cust_main' => $cust_main,
46     'object'    => $svc_acct,
47     'to'        => $email,
48   );
49
50 }
51
52 1;