'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',
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
}
# $^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
) {
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
+*/
)
)
)
'bill', @date_type, '', '',
'last_bill', @date_type, '', '',
'susp', @date_type, '', '',
+ 'adjourn', @date_type, '', '',
'cancel', @date_type, '', '',
'expire', @date_type, '', '',
'manual_flag', 'char', 'NULL', 1, '', '',
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' ) {
=item last_bill - last bill date
+=item adjourn - date
+
=item susp - date
=item expire - date
=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.
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.
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";
+ }
}
}
|| $self->ut_numbern('bill')
|| $self->ut_numbern('susp')
|| $self->ut_numbern('cancel')
+ || $self->ut_numbern('adjourn')
+ || $self->ut_numbern('expire')
;
return $error if $error;
=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>.
&& $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 ) {
%
%
%#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'),
%);
<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>
%$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;
<% 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>
$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;
}
<%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
$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";
}
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{
my %past = ( 'cancel' => 'cancelled',
'expire' => 'expired',
'suspend' => 'suspended',
+ 'adjourn' => 'adjourned',
);
</%init>
<% header("Package $past{$method}") %>
'Setup',
'Last bill',
'Next bill',
+ 'Adjourn',
'Susp.',
'Expire',
'Cancel',
#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">'.
#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);
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;
)
%>
-% 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>
'setup' => 'Setup',
'last_bill' => 'Last bill',
'bill' => 'Next bill',
+ 'adjourn' => 'Adjourns',
'susp' => 'Suspended',
'expire' => 'Expires',
'cancel' => 'Cancelled',
#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' => {},
<% pkg_datestr($cust_pkg, 'bill', $conf) %>
</TR>
% }
+% if ( $cust_pkg->get('adjourn') ) {
+
+ <TR>
+ <TD WIDTH="<%$width%>" ALIGN="right">Adjourns </TD>
+ <% pkg_datestr($cust_pkg, 'adjourn', $conf) %>
+ </TR>
+% }
% if ( $cust_pkg->get('expire') ) {
<TR>
( <% pkg_suspend_link($cust_pkg) %> )
% }
+% if ( $curuser->access_right('Suspend customer package later') ) {
+
+ ( <% pkg_adjourn_link($cust_pkg) %> )
+% }
% if ( $curuser->access_right('Cancel customer package immediately') ) {
( <% pkg_cancel_link($cust_pkg) %> )
%sub pkg_change_link { pkg_link('misc/change_pkg', 'Change package', @_ ); }
%
%sub pkg_suspend_link { pkg_popup_link( 'misc/cancel_pkg.html?method=suspend',
-% 'Suspend',
+% 'Suspend now',
% 'Suspend',
% @_
% );
% @_
% );
% }
+%sub pkg_adjourn_link { pkg_popup_link( 'misc/cancel_pkg.html?method=adjourn',
+% 'Suspend later',
+% 'Adjourn',
+% @_
+% );
+% }
+%
%sub pkg_expire_link { pkg_popup_link( 'misc/cancel_pkg.html?method=expire',
% 'Cancel later',
% 'Expire', #"Cancel package $num later"