e6a27a34e6403e0f1ab4ff1304513445097a0042
[freeside.git] / FS / FS / part_event / Action / cust_bill_print.pm
1 package FS::part_event::Action::cust_bill_print;
2
3 use strict;
4 use base qw( FS::part_event::Action );
5
6 sub description { 'Send invoice (print 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     'skip_nopost' => { label => 'Skip customers without postal billing enabled',
18                        type  => 'checkbox',
19                        value => 'Y',
20                      },
21   );
22 }
23
24 sub default_weight { 51; }
25
26 sub do_action {
27   my( $self, $cust_bill, $cust_event ) = @_;
28
29   #my $cust_main = $self->cust_main($cust_bill);
30   my $cust_main = $cust_bill->cust_main;
31
32   $cust_bill->set('mode' => $self->option('modenum'));
33   if ( $self->option('skip_nopost')
34       && ! grep { $_ eq 'POST' } $cust_main->invoicing_list
35      ) {
36     # then skip customers
37     $cust_event->set('no_action', 'Y');
38     return "customer doesn't receive postal invoices"; # as statustext
39
40   } else {
41     $cust_bill->print;
42   }
43 }
44
45 1;