[freeside-commits] freeside/FS/FS part_pkg.pm,1.81,1.82

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


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

Modified Files:
	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.81
retrieving revision 1.82
diff -u -d -r1.81 -r1.82
--- part_pkg.pm	5 Dec 2008 17:19:55 -0000	1.81
+++ part_pkg.pm	22 Jan 2009 17:29:21 -0000	1.82
@@ -4,6 +4,7 @@
 use vars qw( @ISA %plans $DEBUG );
 use Carp qw(carp cluck confess);
 use Scalar::Util qw( blessed );
+use Time::Local qw( timelocal_nocheck );
 use Tie::IxHash;
 use FS::Conf;
 use FS::Record qw( qsearch qsearchs dbh dbdef );
@@ -728,6 +729,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