1 package FS::part_event::Condition::has_referral_custnum;
6 use base qw( FS::part_event::Condition );
8 sub description { 'Customer has a referring customer'; }
12 'active' => { 'label' => 'Referring customer is active',
20 my($self, $object) = @_;
22 my $cust_main = $self->cust_main($object);
24 if ( $self->option('active') ) {
26 return 0 unless $cust_main->referral_custnum;
28 #check for no cust_main for referral_custnum? (deleted?)
30 $cust_main->referral_custnum_cust_main->status eq 'active';
34 $cust_main->referral_custnum; # ? 1 : 0;
41 my( $class, $table ) = @_;
43 my $sql = FS::cust_main->active_sql;
44 $sql =~ s/cust_main.custnum/cust_main.referral_custnum/;
45 $sql = 'cust_main.referral_custnum IS NOT NULL AND ('.
46 $class->condition_sql_option('active') . ' IS NULL OR '.$sql.')';