my @recur_discounts = ();
my $sdate;
if ( ! $cust_pkg->start_date
- and ( ! $cust_pkg->susp || $cust_pkg->option('suspend_bill',1)
- || ( $part_pkg->option('suspend_bill', 1) )
- && ! $cust_pkg->option('no_suspend_bill',1)
- )
+ and
+ ( ! $cust_pkg->susp
+ || ( $cust_pkg->susp != $cust_pkg->order_date
+ && ( $cust_pkg->option('suspend_bill',1)
+ || ( $part_pkg->option('suspend_bill', 1)
+ && ! $cust_pkg->option('no_suspend_bill',1)
+ )
+ )
+ )
+ )
and
( $part_pkg->freq ne '0' && ( $cust_pkg->bill || 0 ) <= $cmp_time )
|| ( $part_pkg->plan eq 'voip_cdr'
local $SIG{TSTP} = 'IGNORE';
local $SIG{PIPE} = 'IGNORE';
+ $self->susp( $self->order_date ) if $self->susp eq 'now';
+
my $oldAutoCommit = $FS::UID::AutoCommit;
local $FS::UID::AutoCommit = 0;
my $dbh = dbh;
&& ! $self->option('suspend_bill',1)
&& ( ! $self->part_pkg->option('suspend_bill',1)
|| $self->option('no_suspend_bill',1)
- );
+ )
+ && $hash{'order_date'} != $hash{'susp'}
+ ;
$hash{'susp'} = '';
$hash{'adjourn'} = '' if $hash{'adjourn'} and $hash{'adjourn'} < time;
=over 4
+=item on hold
+
=item not yet billed
=item one-time charge
my $freq = length($self->freq) ? $self->freq : $self->part_pkg->freq;
return 'cancelled' if $self->get('cancel');
+ return 'on hold' if $self->susp && ! $self->setup;
return 'suspended' if $self->susp;
return 'not yet billed' unless $self->setup;
return 'one-time charge' if $freq =~ /^(0|$)/;
=cut
tie my %statuscolor, 'Tie::IxHash',
+ 'on hold' => '7E0079', #purple!
'not yet billed' => '009999', #teal? cyan?
'one-time charge' => '000000',
'active' => '00CC00',
AND ( cust_pkg.susp IS NULL OR cust_pkg.susp = 0 )
"; }
+=item on_hold_sql
+
+Returns an SQL expression identifying on-hold packages.
+
+=cut
+
+sub on_hold_sql {
+ #$_[0]->recurring_sql(). ' AND '.
+ "
+ ( cust_pkg.cancel IS NULL OR cust_pkg.cancel = 0 )
+ AND cust_pkg.susp IS NOT NULL AND cust_pkg.susp != 0
+ AND ( cust_pkg.setup IS NULL OR cust_pkg.setup = 0 )
+ ";
+}
+
=item susp_sql
=item suspended_sql
"
( cust_pkg.cancel IS NULL OR cust_pkg.cancel = 0 )
AND cust_pkg.susp IS NOT NULL AND cust_pkg.susp != 0
+ AND cust_pkg.setup IS NOT NULL AND cust_pkg.setup != 0
";
}
sub status_sql {
"CASE
WHEN cust_pkg.cancel IS NOT NULL THEN 'cancelled'
+ WHEN ( cust_pkg.susp IS NOT NULL AND cust_pkg.setup IS NULL ) THEN 'on hold'
WHEN cust_pkg.susp IS NOT NULL THEN 'suspended'
WHEN cust_pkg.setup IS NULL THEN 'not yet billed'
WHEN ".onetime_sql()." THEN 'one-time charge'
=item magic
-active, inactive, suspended, cancel (or cancelled)
+on hold, active, inactive (or one-time charge), suspended, cancel (or cancelled)
=item status
-active, inactive, suspended, one-time charge, inactive, cancel (or cancelled)
+on hold, active, inactive (or one-time charge), suspended, cancel (or cancelled)
=item custom
push @where, FS::cust_pkg->inactive_sql();
+ } elsif ( $params->{'magic'} =~ /^on[ _]hold$/
+ || $params->{'status'} =~ /^on[ _]hold$/ ) {
+
+ push @where, FS::cust_pkg->on_hold_sql();
+
+
} elsif ( $params->{'magic'} eq 'suspended'
|| $params->{'status'} eq 'suspended' ) {
( $count_cust_pkg
AND ( cancel IS NULL OR cancel = 0 )
AND susp IS NOT NULL AND susp != 0
+ AND setup IS NOT NULL AND setup != 0
) AS num_suspended,
( $count_cust_pkg
+ AND ( cancel IS NULL OR cancel = 0 )
+ AND susp IS NOT NULL AND susp != 0
+ AND ( setup IS NULL OR setup = 0 )
+ ) AS num_on_hold,
+
+ ( $count_cust_pkg
AND cancel IS NOT NULL AND cancel != 0
) AS num_cancelled
#if ( $cgi->param('active') ) {
push @header, 'Customer<BR>packages';
my %col = (
+ 'on hold' => '7E0079', #purple!
'not yet billed' => '009999', #teal? cyan?
'active' => '00CC00',
'suspended' => 'FF9900',
my $label = $_;
if ( $magic eq 'active' && $part_pkg->freq == 0 ) {
$magic = 'inactive';
- #$label = 'one-time charge',
- $label = 'charge',
+ #$label = 'one-time charge';
+ $label = 'charge';
}
$label= 'not yet billed' if $magic eq 'not_yet_billed';
+ $label= 'on hold' if $magic eq 'on_hold';
[
{
),
},
],
- } (qw( not_yet_billed active suspended cancelled ))
+ } (qw( on_hold not_yet_billed active suspended cancelled ))
),
($acl_config ?
[ {},
my %hash = (
'pkgpart' => $pkgpart,
'quantity' => $quantity,
- 'start_date' => ( scalar($cgi->param('start_date'))
- ? parse_datetime($cgi->param('start_date'))
- : ''
- ),
'salesnum' => $salesnum,
'refnum' => $refnum,
'contactnum' => $contactnum,
);
$hash{'custnum'} = $cust_main->custnum if $cust_main;
+if ( $cgi->param('start') eq 'on_hold' ) {
+ $hash{'susp'} = 'now';
+} elsif ( $cgi->param('start') eq 'on_date' ) {
+ $hash{'start_date'} = scalar($cgi->param('start_date'))
+ ? parse_datetime($cgi->param('start_date'))
+ : '';
+}
+
if ( $quotationnum ) {
$quotation_pkg = new FS::quotation_pkg \%hash;
var opt = form.pkgpart.options[form.pkgpart.selectedIndex];
var date_button = document.getElementById('start_date_button');
- var date_button_disabled = document.getElementById('start_date_button_disabled');
+ var date_button_disabled = document.getElementById('start_date_disabled');
var date_text = document.getElementById('start_date_text');
+ var radio_now = document.getElementById('start_now');
+ //var radio_on_hold = document.getElementById('start_on_hold');
+ var radio_on_date = document.getElementById('start_on_date');
form.submitButton.disabled = false;
if ( discountnum ) {
date_text.disabled = false;
date_button.style.display = '';
date_button_disabled.style.display = 'none';
+ if ( radio_on_date ) {
+ radio_on_date.disabled = false;
+ if ( form.start_date_text.value.length > 0 && radio_now.checked ) {
+ radio_now.checked = false;
+ radio_on_date.checked = true;
+ }
+ }
} else {
date_text.style.backgroundColor = '#dddddd';
date_text.disabled = true;
date_button.style.display = 'none';
date_button_disabled.style.display = '';
+ if ( radio_on_date ) {
+ if ( radio_on_date.checked ) {
+ radio_on_date.checked = false;
+ radio_now.checked = true;
+ }
+ radio_on_date.disabled = true;
+ }
}
} else {
'name' => 'start_date',
'value' => ($cgi->param('start_date') || $cust_main->next_bill_date),
} &>
- <IMG SRC="<%$fsurl%>images/calendar-disabled.png" \
- ID="start_date_button_disabled" STYLE="display:none">
</TD>
</TR>
</TABLE>
% }
<TR>
- <TH ALIGN="right"><% mt('Start date') |h %> </TD>
+ <TH ALIGN="right"><% mt('Start') |h %> </TD>
<TD COLSPAN=6>
+ <INPUT TYPE="radio" NAME="start" ID="start_now" VALUE="" <% $cgi->param('start') eq '' ? 'CHECKED' : ''%>>Now
+  
+ <INPUT TYPE="radio" NAME="start" ID="start_on_hold" VALUE="on_hold" <% $cgi->param('start') eq 'on_hold' ? 'CHECKED' : ''%>>On hold
+  
+ <INPUT TYPE="radio" NAME="start" ID="start_on_date" VALUE="on_date" <% $cgi->param('start') eq 'date' ? 'CHECKED' : ''%>>On date
+
<& /elements/input-date-field.html,{
'name' => 'start_date',
'format' => $date_format,
'value' => '',
'noinit' => 1,
} &>
- <IMG SRC = "<%$fsurl%>images/calendar-disabled.png"
- ID = "start_date_button_disabled"
- STYLE = "display:none">
- <FONT SIZE=-1>(<% mt('leave blank to start immediately') |h %>)</FONT>
</TD>
</TR>
#false laziness w/cust_pkg.cgi
my %disable = (
'all' => {},
- 'not yet billed' => { 'setup'=>1, 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, },
+ 'on hold' => { 'setup'=>1, 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'expire'=>1, 'cancel'=>1, 'dundate'=> 1, },
+ 'not yet billed' => { 'setup'=>1, 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, 'dundate'=>1, },
'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, 'contract_end'=>1, 'dundate'=>1, },
'active' => { 'susp'=>1, 'cancel'=>1 },
'suspended' => { 'cancel'=>1, 'dundate'=>1, },
%
% } else {
%
-% if ( $cust_pkg->get('susp') ) { #status: suspended
-% my $cpr = $cust_pkg->last_cust_pkg_reason('susp');
+% if ( $cust_pkg->get('susp') ) { #suspended or on hold
+%
+% if ( $cust_pkg->order_date eq $cust_pkg->get('susp') ) { #status: on hold
+
+ <% pkg_status_row( $cust_pkg, emt('On Hold'), '', 'color'=>'7E0079', %opt ) %>
- <% pkg_status_row( $cust_pkg, emt('Suspended'), 'susp', 'color'=>'FF9900', %opt ) %>
+% } else { #status: suspended
- <% pkg_reason_row( $cust_pkg, $cpr, 'color' => 'FF9900', %opt ) %>
+ <% pkg_status_row( $cust_pkg, emt('Suspended'), 'susp', 'color'=>'FF9900', %opt ) %>
+% my $cpr = $cust_pkg->last_cust_pkg_reason('susp');
+ <% pkg_reason_row( $cust_pkg, $cpr, 'color' => 'FF9900', %opt ) %>
+
+% }
<% pkg_status_row_noauto( $cust_pkg, %opt ) %>
<% pkg_status_row_discount( $cust_pkg, %opt ) %>
-% unless ( $cust_pkg->get('setup') ) {
- <% pkg_status_row_colspan( $cust_pkg, emt('Never billed'), '', %opt ) %>
-% } else {
- <% pkg_status_row($cust_pkg, emt('Setup'), 'setup', %opt ) %>
+% unless ( $cust_pkg->order_date eq $cust_pkg->get('susp') ) { #on hold
+% unless ( $cust_pkg->get('setup') ) {
+ <% pkg_status_row_colspan( $cust_pkg, emt('Never billed'), '', %opt ) %>
+% } else {
+ <% pkg_status_row($cust_pkg, emt('Setup'), 'setup', %opt ) %>
+% }
% }
<% pkg_status_row_if($cust_pkg, emt('Un-cancelled'), 'uncancel', %opt ) %>
% }
% }
% if ( $curuser->access_right('Unsuspend customer package') ) {
- ( <% pkg_unsuspend_link($cust_pkg) %> )
- ( <% pkg_resume_link($cust_pkg) %> )
+% if ( $cust_pkg->order_date eq $cust_pkg->get('susp') ) { #on hold
+ ( <% pkg_link('misc/unsusp_pkg', emt('Start bililng now'), $cust_pkg) %> )
+% } else {
+ ( <% pkg_unsuspend_link($cust_pkg) %> )
+ ( <% pkg_resume_link($cust_pkg) %> )
+% }
% }
% if ( !$cust_pkg->change_to_pkgnum and
% $curuser->access_right('Cancel customer package immediately')