1 package FS::part_event::Action::notice_to_emailtovoice;
4 use base qw( FS::part_event::Action );
5 use FS::Record qw( qsearchs );
9 sub description { 'Email a email to voice notice'; }
11 sub eventtable_hashref {
17 'cust_pay_batch' => 1,
18 'cust_statement' => 1,
25 #my $conf = new FS::Conf;
26 #my $to_domain = $conf->config('email-to-voice_domain');
29 'to_name' => { 'label' => 'Address To',
31 'options' => [ 'mobile', 'fax', 'daytime' ],
32 'option_labels' => { 'mobile' => 'Mobile Phone #',
34 'daytime' => 'Day Time #',
36 'post_field_label' => ' <font color="red">Make sure you have setup your email-to-voice_domain config option in your Configuration settings.</font>',
39 'msgnum' => { 'label' => 'Template',
40 'type' => 'select-table',
41 'table' => 'msg_template',
42 'name_col' => 'msgname',
43 'hashref' => { disabled => '' },
50 sub default_weight { 56; } #?
53 my( $self, $object ) = @_;
55 my $conf = new FS::Conf;
56 my $to_domain = $conf->config('email-to-voice_domain')
57 or die "Can't send notice with out send-to-domain, being set in global config \n";
59 my $cust_main = $self->cust_main($object);
61 my $msgnum = $self->option('msgnum');
62 my $name = $self->option('to_name');
64 my $msg_template = qsearchs('msg_template', { 'msgnum' => $msgnum } )
65 or die "Template $msgnum not found";
67 my $to_name = $cust_main->$name
68 or die "Can't send notice with out " . $cust_main->$name . " number set";
70 ## remove - from phone number
73 #my $to = $to_name . '@' . $self->option('to_domain');
74 my $to = $to_name . '@' . $to_domain;
78 'cust_main' => $cust_main,