Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / FS / FS / part_event / Action / cust_bill_email.pm
1 package FS::part_event::Action::cust_bill_email;
2
3 use strict;
4 use base qw( FS::part_event::Action );
5
6 sub description { 'Send invoice (email only)'; }
7
8 sub eventtable_hashref {
9   { 'cust_bill' => 1 };
10 }
11
12 sub option_fields {
13   (
14     'modenum' => {  label => 'Invoice mode',
15                     type  => 'select-invoice_mode',
16                  },
17   );
18 }
19
20 sub default_weight { 51; }
21
22 sub do_action {
23   my( $self, $cust_bill, $cust_event ) = @_;
24
25   my $cust_main = $cust_bill->cust_main;
26
27   $cust_bill->set('mode' => $self->option('modenum'));
28   if ( $cust_main->invoice_noemail ) {
29     # what about if the customer has no email dest?
30     $cust_event->set('no_action', 'Y');
31     return "customer has invoice_noemail flag";
32   } else {
33     $cust_bill->email;
34   }
35 }
36
37 1;