1 package FS::part_event::Condition::has_referral_pkgpart;
2 use base qw( FS::part_event::Condition );
4 use FS::part_event::Condition::has_referral_custnum;
5 #maybe i should be incorporated in has_referral_custnum
9 sub description { 'Customer has a referring customer with uncancelled specific package(s)'; }
13 'if_pkgpart' => { 'label' => 'Only packages: ',
14 'type' => 'select-part_pkg',
16 'toggle_disabled' => 1,
21 #lots of falze laziness w/has_pkgpart..
24 my($self, $object, %opt) = @_;
26 return 0 unless FS::part_event::Condition::has_referral_custnum::condition($self, $object, %opt);
28 my $cust_main = $self->cust_main($object);
30 my $if_pkgpart = $self->option('if_pkgpart') || {};
31 grep $if_pkgpart->{ $_->pkgpart },
32 $cust_main->referral_custnum_cust_main->ncancelled_pkgs( 'skip_label_sort'=> 1);
37 my( $self, $table ) = @_;
39 'ARRAY'. $self->condition_sql_option_option_integer('if_pkgpart').
40 ' && '. #overlap (have elements in common)
41 'ARRAY( SELECT pkgpart FROM cust_pkg AS has_referral_pkgpart_cust_pkg
42 WHERE has_referral_pkgpart_cust_pkg.custnum = cust_main.referral_custnum
43 AND ( has_referral_pkgpart_cust_pkg.cancel IS NULL
44 OR has_referral_pkgpart_cust_pkg.cancel = 0