1 package FS::part_event::Condition::has_pkgpart;
2 use base qw( FS::part_event::Condition );
6 sub description { 'Customer has uncancelled specific package(s)'; }
8 sub eventtable_hashref {
17 'if_pkgpart' => { 'label' => 'Only packages: ',
18 'type' => 'select-part_pkg',
25 my( $self, $object) = @_;
27 my $cust_main = $self->cust_main($object);
29 my $if_pkgpart = $self->option('if_pkgpart') || {};
30 grep $if_pkgpart->{ $_->pkgpart },
31 $cust_main->ncancelled_pkgs( 'skip_label_sort'=>1 );
36 my( $self, $table ) = @_;
38 'ARRAY'. $self->condition_sql_option_option_integer('if_pkgpart').
39 ' && '. #overlap (have elements in common)
40 'ARRAY( SELECT pkgpart FROM cust_pkg AS has_pkgpart_cust_pkg
41 WHERE has_pkgpart_cust_pkg.custnum = cust_main.custnum
42 AND ( has_pkgpart_cust_pkg.cancel IS NULL
43 OR has_pkgpart_cust_pkg.cancel = 0