X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fpart_event%2FCondition%2Fhasnt_pkg_class_cancelled.pm;h=d54fb88fa5d5e46432cc06f41fdd6205dce773de;hp=353e6469fd23bdb0b838a9a96d9bb16b00d51318;hb=c76dee5b859e969a9a1610be53122981f5690687;hpb=b9f68ca7d2a521b037995d1512067ac19cf6db7b diff --git a/FS/FS/part_event/Condition/hasnt_pkg_class_cancelled.pm b/FS/FS/part_event/Condition/hasnt_pkg_class_cancelled.pm index 353e6469f..d54fb88fa 100644 --- a/FS/FS/part_event/Condition/hasnt_pkg_class_cancelled.pm +++ b/FS/FS/part_event/Condition/hasnt_pkg_class_cancelled.pm @@ -21,9 +21,16 @@ sub option_fields { 'type' => 'select-pkg_class', 'multiple' => 1, }, - 'age' => { 'label' => 'Cancellation in last', - 'type' => 'freq', - }, + 'age_newest' => { 'label' => 'Cancelled more than', + 'type' => 'freq', + 'post_text' => ' ago (blank for no limit)', + 'allow_blank' => 1, + }, + 'age' => { 'label' => 'Cancelled less than', + 'type' => 'freq', + 'post_text' => ' ago (blank for no limit)', + 'allow_blank' => 1, + }, ); } @@ -32,11 +39,12 @@ sub condition { my $cust_main = $self->cust_main($object); - my $age = $self->option_age_from('age', $opt{'time'} ); + my $oldest = length($self->option('age')) ? $self->option_age_from('age', $opt{'time'} ) : 0; + my $newest = $self->option_age_from('age_newest', $opt{'time'} ); + + my $pkgclass = $self->option('pkgclass') || {}; - #XXX test - my $hashref = $self->option('pkgclass') || {}; - ! grep { $hashref->{ $_->part_pkg->classnum } && $_->get('cancel') > $age } + ! grep { $pkgclass->{ $_->part_pkg->classnum } && ($_->get('cancel') > $oldest) && ($_->get('cancel') <= $newest) } $cust_main->cancelled_pkgs; }