[freeside-commits] freeside/FS/FS cust_pkg.pm,1.204.2.2,1.204.2.3

Ivan,,, ivan at wavetail.420.am
Wed Aug 10 16:43:48 PDT 2011


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv7763/FS/FS

Modified Files:
      Tag: FREESIDE_2_3_BRANCH
	cust_pkg.pm 
Log Message:
delay setup checkbox, RT#13783

Index: cust_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_pkg.pm,v
retrieving revision 1.204.2.2
retrieving revision 1.204.2.3
diff -u -w -d -r1.204.2.2 -r1.204.2.3
--- cust_pkg.pm	5 Aug 2011 19:26:57 -0000	1.204.2.2
+++ cust_pkg.pm	10 Aug 2011 23:43:46 -0000	1.204.2.3
@@ -8,7 +8,7 @@
 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 @@
   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,11 +276,19 @@
   }
 
   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);



More information about the freeside-commits mailing list