d85e1bd43fb3c4544b3a336e4abb4716eee2f565
[freeside.git] / FS / FS / part_event / Condition / has_pkgpart.pm
1 package FS::part_event::Condition::has_pkgpart;
2
3 use strict;
4
5 use base qw( FS::part_event::Condition );
6
7 sub description { 'Customer has uncancelled specific package(s)'; }
8
9 sub eventtable_hashref {
10     { 'cust_main' => 1,
11       'cust_bill' => 1,
12       'cust_pkg'  => 1,
13     };
14 }
15
16 sub option_fields {
17   ( 
18     'if_pkgpart' => { 'label'    => 'Only packages: ',
19                       'type'     => 'select-part_pkg',
20                       'multiple' => 1,
21                     },
22   );
23 }
24
25 sub condition {
26   my( $self, $object) = @_;
27
28   my $cust_main = $self->cust_main($object);
29
30   my $if_pkgpart = $self->option('if_pkgpart') || {};
31   grep $if_pkgpart->{ $_->pkgpart }, $cust_main->ncancelled_pkgs;
32
33 }
34
35 #XXX 
36 #sub condition_sql {
37 #
38 #}
39
40 1;