suspend event option to skip packages with a start_date, RT#83847
[freeside.git] / FS / FS / part_event / Action / suspend.pm
1 package FS::part_event::Action::suspend;
2
3 use strict;
4 use base qw( FS::part_event::Action );
5
6 sub description { 'Suspend all of this customer\'s packages'; }
7
8 sub option_fields {
9   ( 
10     'reasonnum'    => {
11       'label'        => 'Reason',
12       'type'         => 'select-reason',
13       'reason_class' => 'S',
14     },
15     'suspend_bill' => {
16       'label'        => 'Continue recurring billing while suspended',
17       'type'         => 'checkbox',
18       'value'        => 'Y',
19     },
20     'skip_future_startdate' => {
21       'label'        => "Don't suspend packages with a future start date",
22       'type'         => 'checkbox',
23       'value'        => 'Y',
24     },
25   );
26 }
27
28 sub default_weight { 10; }
29
30 sub do_action {
31   my( $self, $cust_object ) = @_;
32
33   my $cust_main = $self->cust_main($cust_object);
34
35   my @err = $cust_main->suspend(
36     'skip_future_startdate' => $self->option('skip_future_startdate'),
37     'reason'                => $self->option('reasonnum'),
38     'options'               => { 'suspend_bill' => $self->option('suspend_bill')
39                                },
40   );
41
42   die join(' / ', @err) if scalar(@err);
43
44   '';
45
46 }
47
48 1;