summaryrefslogtreecommitdiff
path: root/FS/FS/cust_pkg.pm
diff options
context:
space:
mode:
authorivan <ivan>2011-08-10 23:43:43 +0000
committerivan <ivan>2011-08-10 23:43:43 +0000
commit5ee66912dd45edf27a7f679b249dda595a8ab7b0 (patch)
tree74611eb39ee2bdf43cd6a50f77e835a5b2d7c9ab /FS/FS/cust_pkg.pm
parent39222a44aa136114b0f88c549cc9decafc79e780 (diff)
delay setup checkbox, RT#13783
Diffstat (limited to 'FS/FS/cust_pkg.pm')
-rw-r--r--FS/FS/cust_pkg.pm18
1 files changed, 14 insertions, 4 deletions
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index 81800559c..21c05f3ee 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -8,7 +8,7 @@ use Carp qw(cluck);
use Scalar::Util qw( blessed );
use List::Util qw(max);
use Tie::IxHash;
-use Time::Local qw( timelocal_nocheck );
+use Time::Local qw( timelocal timelocal_nocheck );
use MIME::Entity;
use FS::UID qw( getotaker dbh );
use FS::Misc qw( send_email );
@@ -266,7 +266,9 @@ sub insert {
my $error = $self->check_pkgpart;
return $error if $error;
- if ( $self->part_pkg->option('start_1st', 1) && !$self->start_date ) {
+ my $part_pkg = $self->part_pkg;
+
+ if ( $part_pkg->option('start_1st', 1) && !$self->start_date ) {
my ($sec,$min,$hour,$mday,$mon,$year) = (localtime(time) )[0,1,2,3,4,5];
$mon += 1 unless $mday == 1;
until ( $mon < 12 ) { $mon -= 12; $year++; }
@@ -274,13 +276,21 @@ sub insert {
}
foreach my $action ( qw(expire adjourn contract_end) ) {
- my $months = $self->part_pkg->option("${action}_months",1);
+ my $months = $part_pkg->option("${action}_months",1);
if($months and !$self->$action) {
my $start = $self->start_date || $self->setup || time;
- $self->$action( $self->part_pkg->add_freq($start, $months) );
+ $self->$action( $part_pkg->add_freq($start, $months) );
}
}
+ my $free_days = $part_pkg->option('free_days');
+ if ( $free_days && $part_pkg->option('delay_setup') ) { #&& !$self->start_date
+ my ($mday,$mon,$year) = (localtime(time) )[3,4,5];
+ #my $start_date = ($self->start_date || timelocal(0,0,0,$mday,$mon,$year)) + 86400 * $free_days;
+ my $start_date = timelocal(0,0,0,$mday,$mon,$year) + 86400 * $free_days;
+ $self->start_date($start_date);
+ }
+
$self->order_date(time);
local $SIG{HUP} = 'IGNORE';