import torrus 1.0.9
[freeside.git] / FS / FS / part_event / Action / cust_bill_send_if_newest.pm
1 package FS::part_event::Action::cust_bill_send_if_newest;
2
3 use strict;
4 use base qw( FS::part_event::Action );
5
6 sub description {
7   'Send invoice (email/print/fax) with alternate template, if it is still the newest invoice (useful for late notices - set to 31 days or later)';
8 }
9
10 # XXX is this handled better by something against customers??
11 #sub deprecated {
12 #  1;
13 #}
14
15 sub eventtable_hashref {
16   { 'cust_bill' => 1 };
17 }
18
19 sub option_fields {
20   (
21     'if_newest_templatename' => { label    => 'Template',
22                                   type     => 'select-invoice_template',
23                                 },
24   );
25 }
26
27 sub default_weight { 50; }
28
29 sub do_action {
30   my( $self, $cust_bill ) = @_;
31
32   #my $cust_main = $self->cust_main($cust_bill);
33   my $cust_main = $cust_bill->cust_main;
34
35   $cust_bill->send( $self->option('templatename') );
36 }
37
38 1;