summaryrefslogtreecommitdiff
path: root/FS/FS/part_event/Condition/hasnt_pkgpart.pm
blob: 421d0232c4c09064bd55e156958df2b8345ca59c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package FS::part_event::Condition::hasnt_pkgpart;

use strict;

use base qw( FS::part_event::Condition );

sub description { 'Customer does not have uncancelled package of specified definitions'; }

sub eventtable_hashref {
    { 'cust_main' => 1,
      'cust_bill' => 1,
      'cust_pkg'  => 1,
    };
}

sub option_fields {
  ( 
    'unless_pkgpart' => { 'label'    => 'Packages: ',
                          'type'     => 'select-part_pkg',
                          'multiple' => 1,
                        },
  );
}

sub condition {
  my( $self, $object ) = @_;

  my $cust_main = $self->cust_main($object);

  #XXX test
  my $unless_pkgpart = $self->option('unless_pkgpart') || {};
  ! grep $unless_pkgpart->{ $_->pkgpart }, $cust_main->ncancelled_pkgs;
}

#XXX
#sub condition_sql {
#
#}

1;