summaryrefslogtreecommitdiff
path: root/FS/FS/part_event/Condition/has_pkg_class.pm
blob: 59a3675c31407fa16e93f3c0d7089e2aaab6c736 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package FS::part_event::Condition::has_pkg_class;

use strict;

use base qw( FS::part_event::Condition );
use FS::Record qw( qsearch );
use FS::pkg_class;

sub description {
  'Customer has uncancelled package with class';
}

sub eventtable_hashref {
    { 'cust_main' => 1,
      'cust_bill' => 1,
      'cust_pkg'  => 1,
    };
}

#something like this
sub option_fields {
  (
    'pkgclass'  => { 'label'    => 'Package Class',
                     'type'     => 'select-pkg_class',
                     'multiple' => 1,
                   },
  );
}

sub condition {
  my( $self, $object ) = @_;

  my $cust_main = $self->cust_main($object);

  #XXX test
  my $hashref = $self->option('pkgclass') || {};
  grep $hashref->{ $_->part_pkg->classnum }, $cust_main->ncancelled_pkgs;
}

1;