This commit was generated by cvs2svn to compensate for changes in r11022,
[freeside.git] / FS / FS / part_event / Condition / has_pkg_class.pm
1 package FS::part_event::Condition::has_pkg_class;
2
3 use strict;
4
5 use base qw( FS::part_event::Condition );
6 use FS::Record qw( qsearch );
7 use FS::pkg_class;
8
9 sub description {
10   'Customer has uncancelled package with class';
11 }
12
13 sub eventtable_hashref {
14     { 'cust_main' => 1,
15       'cust_bill' => 1,
16       'cust_pkg'  => 1,
17     };
18 }
19
20 #something like this
21 sub option_fields {
22   (
23     'pkgclass'  => { 'label'    => 'Package Class',
24                      'type'     => 'select-pkg_class',
25                      'multiple' => 1,
26                    },
27   );
28 }
29
30 sub condition {
31   my( $self, $object ) = @_;
32
33   my $cust_main = $self->cust_main($object);
34
35   #XXX test
36   my $hashref = $self->option('pkgclass') || {};
37   grep $hashref->{ $_->part_pkg->classnum }, $cust_main->ncancelled_pkgs;
38 }
39
40 1;