summaryrefslogtreecommitdiff
path: root/FS/FS/part_event/Condition/has_referral_custnum.pm
diff options
context:
space:
mode:
Diffstat (limited to 'FS/FS/part_event/Condition/has_referral_custnum.pm')
-rw-r--r--FS/FS/part_event/Condition/has_referral_custnum.pm48
1 files changed, 48 insertions, 0 deletions
diff --git a/FS/FS/part_event/Condition/has_referral_custnum.pm b/FS/FS/part_event/Condition/has_referral_custnum.pm
new file mode 100644
index 0000000..61a8155
--- /dev/null
+++ b/FS/FS/part_event/Condition/has_referral_custnum.pm
@@ -0,0 +1,48 @@
+package FS::part_event::Condition::has_referral_custnum;
+
+use strict;
+use FS::cust_main;
+
+use base qw( FS::part_event::Condition );
+
+sub description { 'Customer has a referring customer'; }
+
+sub option_fields {
+ (
+ 'active' => { 'label' => 'Referring customer is active',
+ 'type' => 'checkbox',
+ 'value' => 'Y',
+ },
+ );
+}
+
+sub condition {
+ my($self, $object) = @_;
+
+ my $cust_main = $self->cust_main($object);
+
+ if ( $self->option('active') ) {
+
+ return 0 unless $cust_main->referral_custnum;
+
+ #check for no cust_main for referral_custnum? (deleted?)
+
+ $cust_main->referral_custnum_cust_main->status eq 'active';
+
+ } else {
+
+ $cust_main->referral_custnum; # ? 1 : 0;
+
+ }
+
+}
+
+sub condition_sql {
+ #my( $class, $table ) = @_;
+
+ "cust_main.referral_custnum IS NOT NULL";
+
+ #XXX a bit harder to check active status here
+}
+
+1;