1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
package FS::part_event::Action::notice_to_emailtovoice;
use strict;
use base qw( FS::part_event::Action );
use FS::Record qw( qsearchs );
use FS::msg_template;
use FS::Conf;
sub description { 'Email a email to voice notice'; }
sub eventtable_hashref {
{
'cust_main' => 1,
'cust_bill' => 1,
'cust_pkg' => 1,
'cust_pay' => 1,
'cust_pay_batch' => 1,
'cust_statement' => 1,
'svc_acct' => 1,
};
}
sub option_fields {
#my $conf = new FS::Conf;
#my $to_domain = $conf->config('send-to-domain');
(
'to_name' => { 'label' => 'Address To',
'type' => 'select',
'options' => [ 'mobile', 'fax', 'daytime' ],
'option_labels' => { 'mobile' => 'Mobile Phone #',
'fax' => 'Fax #',
'daytime' => 'Day Time #',
},
'post_field_label' => "@" , #. $to_domain ,
},
'msgnum' => { 'label' => 'Template',
'type' => 'select-table',
'table' => 'msg_template',
'name_col' => 'msgname',
'hashref' => { disabled => '' },
'disable_empty' => 1,
},
);
}
sub default_weight { 56; } #?
sub do_action {
my( $self, $object ) = @_;
my $conf = new FS::Conf;
my $to_domain = $conf->config('send-to-domain')
or die "Can't send notice with out send-to-domain, being set in global config \n";
my $cust_main = $self->cust_main($object);
my $msgnum = $self->option('msgnum');
my $name = $self->option('to_name');
my $msg_template = qsearchs('msg_template', { 'msgnum' => $msgnum } )
or die "Template $msgnum not found";
my $to_name = $cust_main->$name
or die "Can't send notice with out " . $cust_main->$name . " number set";
## remove - from phone number
$to_name =~ s/-//g;
#my $to = $to_name . '@' . $self->option('to_domain');
my $to = $to_name . '@' . $to_domain;
$msg_template->send(
'to' => $to,
'cust_main' => $cust_main,
'object' => $object,
);
}
1;
|