Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / FS / FS / part_event / Condition / hasnt_pkgpart.pm
1 package FS::part_event::Condition::hasnt_pkgpart;
2
3 use strict;
4
5 use base qw( FS::part_event::Condition );
6
7 sub description { 'Customer does not have uncancelled package of specified definitions'; }
8
9 sub eventtable_hashref {
10     { 'cust_main' => 1,
11       'cust_bill' => 1,
12       'cust_pkg'  => 1,
13     };
14 }
15
16 sub option_fields {
17   ( 
18     'unless_pkgpart' => { 'label'    => 'Packages: ',
19                           'type'     => 'select-part_pkg',
20                           'multiple' => 1,
21                         },
22   );
23 }
24
25 sub condition {
26   my( $self, $object ) = @_;
27
28   my $cust_main = $self->cust_main($object);
29
30   #XXX test
31   my $unless_pkgpart = $self->option('unless_pkgpart') || {};
32   ! grep $unless_pkgpart->{ $_->pkgpart }, $cust_main->ncancelled_pkgs;
33 }
34
35 #XXX
36 #sub condition_sql {
37 #
38 #}
39
40 1;