summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjeff <jeff>2007-06-26 15:37:19 +0000
committerjeff <jeff>2007-06-26 15:37:19 +0000
commitc8f56207c0c8ee26b62824064e59d5952c20f70b (patch)
treefb0ebf505a870db499ae7517a1beae6c72febe23
parentbd8582f48b90a63c17a568e4a395a82fe4f9277e (diff)
suspend later just like expire (#1487)
-rw-r--r--FS/FS/AccessRight.pm1
-rw-r--r--FS/FS/Cron/bill.pm7
-rw-r--r--FS/FS/Cron/notify.pm5
-rw-r--r--FS/FS/Schema.pm1
-rw-r--r--FS/FS/cust_main.pm2
-rw-r--r--FS/FS/cust_pkg.pm28
-rwxr-xr-xhttemplate/edit/REAL_cust_pkg.cgi11
-rwxr-xr-xhttemplate/edit/process/REAL_cust_pkg.cgi1
-rwxr-xr-xhttemplate/misc/cancel_pkg.html9
-rwxr-xr-xhttemplate/misc/process/cancel_pkg.html9
-rwxr-xr-xhttemplate/search/cust_pkg.cgi7
-rwxr-xr-xhttemplate/search/report_cust_pkg.html7
-rwxr-xr-xhttemplate/view/cust_main/packages.html20
13 files changed, 80 insertions, 28 deletions
diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm
index f67614aac..7a8bfc2c4 100644
--- a/FS/FS/AccessRight.pm
+++ b/FS/FS/AccessRight.pm
@@ -106,6 +106,7 @@ assigned to users and/or groups.
'Edit customer package dates',
'Customize customer package',
'Suspend customer package',
+ 'Suspend customer package later',
'Unsuspend customer package',
'Cancel customer package immediately',
'Cancel customer package later',
diff --git a/FS/FS/Cron/bill.pm b/FS/FS/Cron/bill.pm
index 9926fea9e..b6925d095 100644
--- a/FS/FS/Cron/bill.pm
+++ b/FS/FS/Cron/bill.pm
@@ -34,6 +34,7 @@ sub bill {
and ( setup is null or setup = 0
or bill is null or bill <= $time
or ( expire is not null and expire <= $^T )
+ or ( adjourn is not null and adjourn <= $^T )
)
)
END
@@ -91,8 +92,10 @@ END
}
# $^T not $time because -d is for pre-printing invoices
foreach my $cust_pkg (
- grep { $_->part_pkg->is_prepaid
- && $_->bill && $_->bill < $^T && ! $_->susp
+ grep { ( $_->part_pkg->is_prepaid && $_->bill && $_->bill < $^T
+ || $_->adjourn && $_->adjourn <= $^T
+ )
+ && ! $_->susp
}
$cust_main->ncancelled_pkgs
) {
diff --git a/FS/FS/Cron/notify.pm b/FS/FS/Cron/notify.pm
index 371065094..622f15f6b 100644
--- a/FS/FS/Cron/notify.pm
+++ b/FS/FS/Cron/notify.pm
@@ -42,6 +42,11 @@ sub notify_flat_delay {
or cust_pkg.expire > $time
+ cast(part_pkg_option.optionvalue as integer)
* 86400
+/* and ( cust_pkg.adjourn is null
+ or cust_pkg.adjourn > $time
+-- Should notify suspended ones + cast(part_pkg_option.optionvalue as integer)
+ * 86400
+*/
)
)
)
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 7f5149bd4..5ff549d9d 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -651,6 +651,7 @@ sub tables_hashref {
'bill', @date_type, '', '',
'last_bill', @date_type, '', '',
'susp', @date_type, '', '',
+ 'adjourn', @date_type, '', '',
'cancel', @date_type, '', '',
'expire', @date_type, '', '',
'manual_flag', 'char', 'NULL', 1, '', '',
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 641b8cd30..51aa4d5d4 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -4725,7 +4725,7 @@ sub batch_import {
my %svc_acct = ();
foreach my $field ( @fields ) {
- if ( $field =~ /^cust_pkg\.(pkgpart|setup|bill|susp|expire|cancel)$/ ) {
+ if ( $field =~ /^cust_pkg\.(pkgpart|setup|bill|susp|adjourn|expire|cancel)$/ ) {
#$cust_pkg{$1} = str2time( shift @$columns );
if ( $1 eq 'pkgpart' ) {
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index 055b87b61..45a5380aa 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -111,6 +111,8 @@ inherits from FS::Record. The following fields are currently supported:
=item last_bill - last bill date
+=item adjourn - date
+
=item susp - date
=item expire - date
@@ -124,7 +126,7 @@ unsuspension of this package when using the B<unsuspendauto> config file.
=back
-Note: setup, bill, susp, expire and cancel are specified as UNIX timestamps;
+Note: setup, bill, adjourn, susp, expire and cancel are specified as UNIX timestamps;
see L<perlfunc/"time">. Also see L<Time::Local> and L<Date::Parse> for
conversion functions.
@@ -264,7 +266,7 @@ the customer ever purchased the item. Instead, see the cancel method.
Replaces the OLD_RECORD with this one in the database. If there is an error,
returns the error, otherwise returns false.
-Currently, custnum, setup, bill, susp, expire, and cancel may be changed.
+Currently, custnum, setup, bill, adjourn, susp, expire, and cancel may be changed.
Changing pkgpart may have disasterous effects. See the order subroutine.
@@ -310,13 +312,15 @@ sub replace {
local $FS::UID::AutoCommit = 0;
my $dbh = dbh;
- if ($options{'reason'} && $new->expire && $old->expire ne $new->expire) {
- my $error = $new->insert_reason( 'reason' => $options{'reason'},
- 'date' => $new->expire,
- );
- if ( $error ) {
- dbh->rollback if $oldAutoCommit;
- return "Error inserting cust_pkg_reason: $error";
+ foreach my $method ( qw(adjourn expire) ) { # How many reasons?
+ if ($options{'reason'} && $new->$method && $old->$method ne $new->$method) {
+ my $error = $new->insert_reason( 'reason' => $options{'reason'},
+ 'date' => $new->$method,
+ );
+ if ( $error ) {
+ dbh->rollback if $oldAutoCommit;
+ return "Error inserting cust_pkg_reason: $error";
+ }
}
}
@@ -377,6 +381,8 @@ sub check {
|| $self->ut_numbern('bill')
|| $self->ut_numbern('susp')
|| $self->ut_numbern('cancel')
+ || $self->ut_numbern('adjourn')
+ || $self->ut_numbern('expire')
;
return $error if $error;
@@ -601,7 +607,8 @@ sub suspend {
=item unsuspend [ OPTION => VALUE ... ]
Unsuspends all services (see L<FS::cust_svc> and L<FS::part_svc>) in this
-package, then unsuspends the package itself (clears the susp field).
+package, then unsuspends the package itself (clears the susp field and the
+adjourn field if it is in the past).
Available options are: I<adjust_next_bill>.
@@ -666,6 +673,7 @@ sub unsuspend {
&& $inactive > 0 && ( $hash{'bill'} || $hash{'setup'} );
$hash{'susp'} = '';
+ $hash{'adjourn'} = '' if $hash{'adjourn'} < time;
my $new = new FS::cust_pkg ( \%hash );
$error = $new->replace( $self, options => { $self->options } );
if ( $error ) {
diff --git a/httemplate/edit/REAL_cust_pkg.cgi b/httemplate/edit/REAL_cust_pkg.cgi
index 69bbb9b22..7a9e030e9 100755
--- a/httemplate/edit/REAL_cust_pkg.cgi
+++ b/httemplate/edit/REAL_cust_pkg.cgi
@@ -50,8 +50,9 @@
%
%
%#print info
-%my($susp,$cancel,$expire)=(
+%my($susp,$adjourn,$cancel,$expire)=(
% $cust_pkg->getfield('susp'),
+% $cust_pkg->getfield('adjourn'),
% $cust_pkg->getfield('cancel'),
% $cust_pkg->getfield('expire'),
%);
@@ -134,6 +135,14 @@
<IMG SRC="../images/calendar.png" ID="bill_button" STYLE="cursor: pointer" TITLE="Select date">
</TD>
</TR>
+ <TR>
+ <TD ALIGN="right">Adjournment date</TD>
+ <TD>
+ <INPUT TYPE="text" NAME="adjourn" SIZE=32 ID="adjourn_text" VALUE="<% ( $adjourn ? time2str($format, $adjourn) : "" ) %>">
+ <IMG SRC="../images/calendar.png" ID="adjourn_button" STYLE="cursor: pointer" TITLE="Select date">
+ <BR><FONT SIZE=-1>(will <b>suspend</b> this package when the date is reached)</FONT>
+ </TD>
+ </TR>
% if ( $susp ) {
<TR>
diff --git a/httemplate/edit/process/REAL_cust_pkg.cgi b/httemplate/edit/process/REAL_cust_pkg.cgi
index 26e234fb0..9255672c0 100755
--- a/httemplate/edit/process/REAL_cust_pkg.cgi
+++ b/httemplate/edit/process/REAL_cust_pkg.cgi
@@ -7,6 +7,7 @@
%$hash{'bill'} = $cgi->param('bill') ? str2time($cgi->param('bill')) : '';
%$hash{'last_bill'} =
% $cgi->param('last_bill') ? str2time($cgi->param('last_bill')) : '';
+%$hash{'adjourn'} = $cgi->param('adjourn') ? str2time($cgi->param('adjourn')) : '';
%$hash{'expire'} = $cgi->param('expire') ? str2time($cgi->param('expire')) : '';
%
%my $new;
diff --git a/httemplate/misc/cancel_pkg.html b/httemplate/misc/cancel_pkg.html
index e61000618..b085d2281 100755
--- a/httemplate/misc/cancel_pkg.html
+++ b/httemplate/misc/cancel_pkg.html
@@ -23,9 +23,9 @@
<% ucfirst($method) . " $pkgnum: " .$part_pkg->pkg. ' - ' .$part_pkg->comment %>
<% ntable("#cccccc", 2) %>
-% if ($method eq 'expire') {
+% if ($method eq 'expire' || $method eq 'adjourn') {
<TR>
- <TD>Cancel package on </TD>
+ <TD><% $submit =~ /^(\w*)\s/ %> package on </TD>
<TD><INPUT TYPE="text" NAME="date" ID="expire_date" VALUE="<% $date %>">
<IMG SRC="<% $p %>images/calendar.png" ID="expire_button" STYLE="cursor:pointer" TITLE="Select date">
<BR><I>m/d/y</I>
@@ -77,7 +77,10 @@ if ($method eq 'cancel') {
$submit = "Cancel Later";
}elsif ($method eq 'suspend') {
$class = 'S';
- $submit = "Suspend";
+ $submit = "Suspend Now";
+}elsif ($method eq 'adjourn') {
+ $class = 'S';
+ $submit = "Suspend Later";
}else{
die "illegal query ". $cgi->keywords;
}
diff --git a/httemplate/misc/process/cancel_pkg.html b/httemplate/misc/process/cancel_pkg.html
index cd533be10..50b111093 100755
--- a/httemplate/misc/process/cancel_pkg.html
+++ b/httemplate/misc/process/cancel_pkg.html
@@ -1,7 +1,7 @@
<%init>
#untaint method
my $method = $cgi->param('method');
-$method =~ /^(cancel|expire|suspend)$/ || die "Illegal method";
+$method =~ /^(cancel|expire|suspend|adjourn)$/ || die "Illegal method";
$method = $1;
#untaint pkgnum
@@ -15,7 +15,7 @@ $reasonnum =~ /^(-?\d+)$/ || die "Illegal reasonnum";
$reasonnum = $1;
my $date = time;
-if ($method eq 'expire'){
+if ($method eq 'expire' || $method eq 'adjourn'){
#untaint date
$date = $cgi->param('date');
str2time($cgi->param('date')) =~ /^(\d+)$/ || die "Illegal date";
@@ -47,9 +47,9 @@ if ($reasonnum == -1) {
}
unless ($error) {
- if ($method eq 'expire'){
+ if ($method eq 'expire' || $method eq 'adjourn'){
my %hash = $cust_pkg->hash;
- $hash{'expire'}=$date;
+ $hash{$method}=$date;
my $new = new FS::cust_pkg (\%hash);
$error = $new->replace($cust_pkg, 'reason' => $reasonnum);
}else{
@@ -68,6 +68,7 @@ $dbh->commit or die $dbh->errstr if $oldAutoCommit;
my %past = ( 'cancel' => 'cancelled',
'expire' => 'expired',
'suspend' => 'suspended',
+ 'adjourn' => 'adjourned',
);
</%init>
<% header("Package $past{$method}") %>
diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi
index 4fd5e9d45..941a2e76c 100755
--- a/httemplate/search/cust_pkg.cgi
+++ b/httemplate/search/cust_pkg.cgi
@@ -12,6 +12,7 @@
'Setup',
'Last bill',
'Next bill',
+ 'Adjourn',
'Susp.',
'Expire',
'Cancel',
@@ -43,7 +44,7 @@
#sub { time2str('%b %d %Y', shift->expire); },
#sub { time2str('%b %d %Y', shift->get('cancel')); },
( map { time_or_blank($_) }
- qw( setup last_bill bill susp expire cancel ) ),
+ qw( setup last_bill bill adjourn susp expire cancel ) ),
\&FS::UI::Web::cust_fields,
#sub { '<table border=0 cellspacing=0 cellpadding=0 STYLE="border:none">'.
@@ -210,14 +211,14 @@ my $orderby = '';
#false laziness w/report_cust_pkg.html
my %disable = (
'all' => {},
- 'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, },
+ 'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, },
'active' => { 'susp'=>1, 'cancel'=>1 },
'suspended' => { 'cancel' => 1 },
'cancelled' => {},
'' => {},
);
-foreach my $field (qw( setup last_bill bill susp expire cancel )) {
+foreach my $field (qw( setup last_bill bill adjourn susp expire cancel )) {
my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, $field);
diff --git a/httemplate/search/report_cust_pkg.html b/httemplate/search/report_cust_pkg.html
index 1412816c9..57180c18e 100755
--- a/httemplate/search/report_cust_pkg.html
+++ b/httemplate/search/report_cust_pkg.html
@@ -26,7 +26,7 @@
if ( what.options[what.selectedIndex].value == '<% $status %>' ) {
-% foreach my $field (qw( setup last_bill bill susp expire cancel )) {
+% foreach my $field (qw( setup last_bill bill adjourn susp expire cancel )) {
% if ( $disable{$status}->{$field} ) {
what.form.<% $field %>_beginning_text.disabled = true;
@@ -68,7 +68,7 @@
)
%>
-% foreach my $field (qw( setup last_bill bill susp expire cancel )) {
+% foreach my $field (qw( setup last_bill bill adjourn susp expire cancel )) {
<TR>
<TD ALIGN="right" VALIGN="center"><% $label{$field} %></TD>
@@ -116,6 +116,7 @@ my %label = (
'setup' => 'Setup',
'last_bill' => 'Last bill',
'bill' => 'Next bill',
+ 'adjourn' => 'Adjourns',
'susp' => 'Suspended',
'expire' => 'Expires',
'cancel' => 'Cancelled',
@@ -124,7 +125,7 @@ my %label = (
#false laziness w/cust_pkg.cgi
my %disable = (
'all' => {},
- 'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, },
+ 'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, },
'active' => { 'susp'=>1, 'cancel'=>1 },
'suspended' => { 'cancel' => 1 },
'cancelled' => {},
diff --git a/httemplate/view/cust_main/packages.html b/httemplate/view/cust_main/packages.html
index 98acb8685..5890726ae 100755
--- a/httemplate/view/cust_main/packages.html
+++ b/httemplate/view/cust_main/packages.html
@@ -299,6 +299,13 @@ Current packages
<% pkg_datestr($cust_pkg, 'bill', $conf) %>
</TR>
% }
+% if ( $cust_pkg->get('adjourn') ) {
+
+ <TR>
+ <TD WIDTH="<%$width%>" ALIGN="right">Adjourns&nbsp;</TD>
+ <% pkg_datestr($cust_pkg, 'adjourn', $conf) %>
+ </TR>
+% }
% if ( $cust_pkg->get('expire') ) {
<TR>
@@ -315,6 +322,10 @@ Current packages
(&nbsp;<% pkg_suspend_link($cust_pkg) %>&nbsp;)
% }
+% if ( $curuser->access_right('Suspend customer package later') ) {
+
+ (&nbsp;<% pkg_adjourn_link($cust_pkg) %>&nbsp;)
+% }
% if ( $curuser->access_right('Cancel customer package immediately') ) {
(&nbsp;<% pkg_cancel_link($cust_pkg) %>&nbsp;)
@@ -489,7 +500,7 @@ Current packages
%sub pkg_change_link { pkg_link('misc/change_pkg', 'Change&nbsp;package', @_ ); }
%
%sub pkg_suspend_link { pkg_popup_link( 'misc/cancel_pkg.html?method=suspend',
-% 'Suspend',
+% 'Suspend&nbsp;now',
% 'Suspend',
% @_
% );
@@ -505,6 +516,13 @@ Current packages
% @_
% );
% }
+%sub pkg_adjourn_link { pkg_popup_link( 'misc/cancel_pkg.html?method=adjourn',
+% 'Suspend&nbsp;later',
+% 'Adjourn',
+% @_
+% );
+% }
+%
%sub pkg_expire_link { pkg_popup_link( 'misc/cancel_pkg.html?method=expire',
% 'Cancel&nbsp;later',
% 'Expire', #"Cancel package $num later"