adding pkg_reason_type and pkg_not_reason_type conditions, RT#20084
[freeside.git] / FS / FS / part_event / Condition / pkg_not_reason_type.pm
1 package FS::part_event::Condition::pkg_not_reason_type;
2 use base qw( FS::part_event::Condition );
3
4 use strict;
5 use Tie::IxHash;
6 #use FS::Record qw( qsearch );
7
8 sub description {
9   'Package Not Reason Type';
10 }
11
12 sub eventtable_hashref {
13     { 'cust_main' => 0,
14       'cust_bill' => 0,
15       'cust_pkg'  => 1,
16       'svc_acct'  => 1,
17     };
18 }
19
20 tie my %actions, 'Tie::IxHash',
21   #'adjourn' =>
22   'susp'   => 'Suspension',
23   #'expire' =>
24   'cancel' => 'Cancellation'
25 ;
26
27 sub option_fields {
28   (
29     'action'  => { 'label'    => 'Package Action',
30                    'type'     => 'select',
31                    'options'  => [ keys %actions ],
32                    'labels'   => \%actions,
33                  },
34     'typenum' => { 'label'    => 'Not Reason Type',
35                    'type'     => 'select-reason_type',
36                    'multiple' => 1,
37                  },
38   );
39 }
40
41 sub condition {
42   my( $self, $object ) = @_;
43
44   my $cust_pkg = $self->cust_pkg($object);
45
46   my $reason = $cust_pkg->last_reason( $self->option('action') )
47     or return 0;
48
49   my $hashref = $self->option('typenum') || {};
50   ! $hashref->{ $reason->reason_type };
51 }
52
53 #sub condition_sql {
54 #  my( $self, $table ) = @_;
55 #
56 #}
57
58 1;