blob: 4808e9083886b0bc3a40ee684db38c6ac8687a86 (
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
41
42
43
44
45
46
|
package FS::part_event::Condition::cust_paydate_within;
use strict;
use base qw( FS::part_event::Condition );
use FS::Record qw( str2time_sql str2time_sql_closing );
use Time::Local 'timelocal';
sub description {
'Credit card expires within upcoming interval';
}
# Run the event when the customer's credit card expiration
# date is less than X days in the future.
# Combine this with a "once_every" condition so that the event
# won't repeat every day until the expiration date.
sub eventtable_hashref {
{ 'cust_main' => 1,
'cust_bill' => 0,
'cust_pkg' => 0,
};
}
sub option_fields {
(
'within' => { 'label' => 'Expiration date within',
'type' => 'freq',
},
);
}
sub condition {
my( $self, $cust_main, %opt ) = @_;
my $expire_time = $cust_main->paydate_epoch or return 0;
$opt{'time'} >= $self->option_age_from('within', $expire_time);
}
sub condition_sql {
my ($self, $table, %opt) = @_;
my $expire_time = FS::cust_main->paydate_epoch_sql or return 'true';
$opt{'time'} . ' >= ' .
$self->condition_sql_option_age_from('within', $expire_time);
}
1;
|