X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_event%2FCondition%2Fpkg_age.pm;h=6629e9d5487f6065ff45a82d3b532f838fbc6365;hb=c0a48dabc8d0d2a66dc6a596a66c9d40c7d37489;hp=8b3b4c971f82b2709ef75682319032b081f3a103;hpb=624b2d44625f69d71175c3348cae635d580c890b;p=freeside.git diff --git a/FS/FS/part_event/Condition/pkg_age.pm b/FS/FS/part_event/Condition/pkg_age.pm index 8b3b4c971..6629e9d54 100644 --- a/FS/FS/part_event/Condition/pkg_age.pm +++ b/FS/FS/part_event/Condition/pkg_age.pm @@ -1,58 +1,18 @@ package FS::part_event::Condition::pkg_age; +use base qw( FS::part_event::Condition::pkg_age_Common ); use strict; -use base qw( FS::part_event::Condition ); -use FS::Record qw( qsearch ); -sub description { - 'Package Age'; -} - -sub eventtable_hashref { - { 'cust_main' => 0, - 'cust_bill' => 0, - 'cust_pkg' => 1, - }; -} - -#something like this -sub option_fields { - ( - 'age' => { 'label' => 'Package date age', - 'type' => 'freq', - }, - 'field' => { 'label' => 'Compare date', - 'type' => 'select', - 'options' => - [qw( setup last_bill bill adjourn susp expire cancel )], - 'labels' => { - 'setup' => 'Setup date', - 'last_bill' => 'Last bill date', - 'bill' => 'Next bill date', - 'adjourn' => 'Adjournment date', - 'susp' => 'Suspension date', - 'expire' => 'Expiration date', - 'cancel' => 'Cancellation date', - }, - }, - ); -} - -sub condition { - my( $self, $cust_pkg, %opt ) = @_; +sub description { 'Package Age'; } - my $age = $self->option_age_from('age', $opt{'time'} ); +sub pkg_age_operator { '<='; } - my $pkg_date = $cust_pkg->get( $self->option('field') ); - - $pkg_date && $pkg_date <= $age; +sub pkg_age_label { 'Package date age older than'; } +sub pkg_age_compare { + my( $self, $pkg_date, $age ) = @_; + $pkg_date <= $age; } -#XXX write me for efficiency -#sub condition_sql { -# -#} - 1;