1 package FS::part_event::Condition::hasnt_pkgpart;
5 use base qw( FS::part_event::Condition );
7 sub description { 'Customer does not have uncancelled package of specified definitions'; }
9 sub eventtable_hashref {
18 'unless_pkgpart' => { 'label' => 'Packages: ',
19 'type' => 'select-part_pkg',
25 #false laziness w/has_pkgpart.pm
28 my( $self, $object ) = @_;
30 my $cust_main = $self->cust_main($object);
32 my $unless_pkgpart = $self->option('unless_pkgpart') || {};
33 ! grep $unless_pkgpart->{ $_->pkgpart }, $cust_main->ncancelled_pkgs;
37 my( $self, $table ) = @_;
40 'ARRAY'. $self->condition_sql_option_option_integer('unless_pkgpart').
41 ' && '. #overlap (have elements in common)
42 'ARRAY( SELECT pkgpart FROM cust_pkg AS has_pkgpart_cust_pkg
43 WHERE has_pkgpart_cust_pkg.custnum = cust_main.custnum
44 AND ( has_pkgpart_cust_pkg.cancel IS NULL
45 OR has_pkgpart_cust_pkg.cancel = 0