diff options
author | ivan <ivan> | 2009-01-22 17:29:22 +0000 |
---|---|---|
committer | ivan <ivan> | 2009-01-22 17:29:22 +0000 |
commit | 2b8e51c711674efa5878354cd17e2875a5ee19b2 (patch) | |
tree | 40a332d8f38ac08a350970cef232ba66e020fdad /FS/FS/part_pkg.pm | |
parent | 455556cc709f205cb63d42cfe941bb874f36c2f5 (diff) |
add self-service methods renew_info, order_renew and process_payment_order_renew to enable self-renewal through self-service. RT#4623
Diffstat (limited to 'FS/FS/part_pkg.pm')
-rw-r--r-- | FS/FS/part_pkg.pm | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm index f521d65e2..38fc03e42 100644 --- a/FS/FS/part_pkg.pm +++ b/FS/FS/part_pkg.pm @@ -4,6 +4,7 @@ use strict; 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 @@ sub freq_pretty { } } +=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 |