[freeside-commits] freeside/FS/FS part_pkg.pm,1.56.2.8,1.56.2.9

Ivan,,, ivan at wavetail.420.am
Thu Jan 22 09:29:32 PST 2009


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

Modified Files:
      Tag: FREESIDE_1_7_BRANCH
	part_pkg.pm 
Log Message:
add self-service methods renew_info, order_renew and process_payment_order_renew to enable self-renewal through self-service.  RT#4623

Index: part_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg.pm,v
retrieving revision 1.56.2.8
retrieving revision 1.56.2.9
diff -u -d -r1.56.2.8 -r1.56.2.9
--- part_pkg.pm	11 Oct 2008 00:32:56 -0000	1.56.2.8
+++ part_pkg.pm	22 Jan 2009 17:29:29 -0000	1.56.2.9
@@ -3,6 +3,7 @@
 use strict;
 use vars qw( @ISA %plans $DEBUG );
 use Carp qw(carp cluck confess);
+use Time::Local qw( timelocal_nocheck );
 use Tie::IxHash;
 use FS::Conf;
 use FS::Record qw( qsearch qsearchs dbh dbdef );
@@ -666,6 +667,41 @@
   }
 }
 
+=item add_freq TIMESTAMP
+
+Adds the frequency of this package to the provided timestamp and returns
+the resulting timestamp, or -1 if the frequency of this package could not be
+parsed (shouldn't happen).
+
+=cut
+
+sub add_freq {
+  my( $self, $date ) = @_;
+  my $freq = $self->freq;
+
+  #change this bit to use Date::Manip? CAREFUL with timezones (see
+  # mailing list archive)
+  my ($sec,$min,$hour,$mday,$mon,$year) = (localtime($date) )[0,1,2,3,4,5];
+
+  if ( $self->freq =~ /^\d+$/ ) {
+    $mon += $self->freq;
+    until ( $mon < 12 ) { $mon -= 12; $year++; }
+  } elsif ( $self->freq =~ /^(\d+)w$/ ) {
+    my $weeks = $1;
+    $mday += $weeks * 7;
+  } elsif ( $self->freq =~ /^(\d+)d$/ ) {
+    my $days = $1;
+    $mday += $days;
+  } elsif ( $self->freq =~ /^(\d+)h$/ ) {
+    my $hours = $1;
+    $hour += $hours;
+  } else {
+    return -1;
+  }
+
+  timelocal_nocheck($sec,$min,$hour,$mday,$mon,$year);
+}
+
 =item plandata
 
 For backwards compatibility, returns the plandata field as well as all options



More information about the freeside-commits mailing list