60ba7ccd5eb66f9ae0777cf968e71b024b0fbf6d
[freeside.git] / FS / FS / part_event / Condition / has_referral_pkgpart.pm
1 package FS::part_event::Condition::has_referral_pkgpart;
2 use base qw( FS::part_event::Condition );
3
4 #maybe i should be incorporated in has_referral_custnum
5
6 use strict;
7
8 sub description { 'Customer has a referring customer with uncancelled specific package(s)'; }
9
10 sub option_fields {
11   ( 
12     'if_pkgpart' => { 'label'    => 'Only packages: ',
13                       'type'     => 'select-part_pkg',
14                       'multiple' => 1,
15                     },
16   );
17 }
18
19 sub condition {
20   my($self, $object, %opt) = @_;
21
22   my $cust_main = $self->cust_main($object);
23
24   return 0 unless $cust_main->referral_custnum;
25   
26   my $if_pkgpart = $self->option('if_pkgpart') || {};
27   grep $if_pkgpart->{ $_->pkgpart },
28     $cust_main->referral_custnum_cust_main->ncancelled_pkgs;
29                                             #maybe billing_pkgs
30 }
31
32 #XXX 
33 #sub condition_sql {
34 #
35 #}
36
37 1;
38