RT#27886: Referral customers and billing events
[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 use FS::part_event::Condition::has_referral_custnum;
5 #maybe i should be incorporated in has_referral_custnum
6
7 use strict;
8
9 sub description { 'Customer has a referring customer with uncancelled specific package(s)'; }
10
11 sub option_fields {
12   ( 
13     'if_pkgpart' => { 'label'    => 'Only packages: ',
14                       'type'     => 'select-part_pkg',
15                       'multiple' => 1,
16                     },
17   );
18 }
19
20 sub condition {
21   my($self, $object, %opt) = @_;
22
23   return 0 unless FS::part_event::Condition::has_referral_custnum::condition($self, $object, %opt);
24
25   my $cust_main = $self->cust_main($object);
26
27   my $if_pkgpart = $self->option('if_pkgpart') || {};
28   grep $if_pkgpart->{ $_->pkgpart },
29     $cust_main->referral_custnum_cust_main->ncancelled_pkgs;
30                                             #maybe billing_pkgs
31 }
32
33 #XXX 
34 #sub condition_sql {
35 #
36 #}
37
38 1;
39