event refactor, landing on HEAD!
[freeside.git] / FS / FS / part_event / Action / suspend_unless_pkgpart.pm
1 package FS::part_event::Action::suspend_unless_pkgpart;
2
3 use strict;
4 use base qw( FS::part_event::Action );
5
6 sub description {
7   'Suspend packages except';
8 }
9
10 sub option_fields {
11   ( 
12     'unless_pkgpart' => { 'label'    => 'Suspend packages except:',
13                           'type'     => 'select-part_pkg',
14                           'multiple' => 1,
15                         },
16     'reasonnum' => { 'label'        => 'Reason',
17                      'type'         => 'select-reason',
18                      'reason_class' => 'S',
19                    },
20   );
21 };
22
23 sub default_weight {
24   10;
25 }
26
27 sub do_action {
28   my( $self, $cust_object ) = @_;
29
30   my $cust_main = $self->cust_main($cust_object);
31
32   my @err = $cust_main->suspend_unless_pkgpart( {
33     'pkgparts' => [ split(/\s*,\s*/, $self->option('unless_pkgpart') ) ],
34     'reason'   => $self->option('reasonnum'),
35   } );
36
37   die join(' / ', @err) if scalar(@err);
38
39   '';
40 }
41
42 1;