summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2015-06-15 23:37:48 -0500
committerJonathan Prykop <jonathan@freeside.biz>2015-06-15 23:37:48 -0500
commit8f82d54c3b3bd30c8f8451ea24bcdab70ff37327 (patch)
tree20a6265c2cd7b6ec40d9aa0ddcde8ec22a1c8cde /httemplate
parentd2e0e83c3cb0caf1d1a958eee1717934e8b5176f (diff)
RT#30705 Change contract end date when changing packages
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/edit/process/change-cust_pkg.html61
-rwxr-xr-xhttemplate/misc/change_pkg.cgi13
-rw-r--r--httemplate/view/cust_main/packages/status.html4
3 files changed, 55 insertions, 23 deletions
diff --git a/httemplate/edit/process/change-cust_pkg.html b/httemplate/edit/process/change-cust_pkg.html
index 96175e1e4..c066ff5b0 100644
--- a/httemplate/edit/process/change-cust_pkg.html
+++ b/httemplate/edit/process/change-cust_pkg.html
@@ -41,34 +41,49 @@ if ( $cgi->param('locationnum') == -1 ) {
}
my $error;
-if ( $cgi->param('delay') ) {
- my $date = parse_datetime($cgi->param('start_date'));
- if (!$date) {
- $error = "Invalid change date '".$cgi->param('start_date')."'.";
- } elsif ( $date < time ) {
- $error = "Change date ".$cgi->param('start_date')." is in the past.";
+my $contract_end;
+my $now = time;
+if (defined($cgi->param('contract_end'))) {
+ $contract_end = parse_datetime($cgi->param('contract_end'));
+ if ($contract_end < $now) {
+ $error = "Contract end ".$cgi->param('contract_end')." is in the past.";
} else {
- # schedule the change
- $change{'start_date'} = $date;
- $error = $cust_pkg->change_later(\%change);
+ $change{'contract_end'} = $contract_end;
}
-} else {
- # special case: if there's a package change scheduled, and it matches
- # the parameters the user requested this time, then change to the existing
- # future package.
- if ( $cust_pkg->change_to_pkgnum ) {
- my $change_to = FS::cust_pkg->by_key($cust_pkg->change_to_pkgnum);
- if ( $change_to->pkgpart == $change{'pkgpart'} and
- $change_to->locationnum == $change{'locationnum'} ) {
-
- %change = ( 'cust_pkg' => $change_to );
+}
+unless ($error) {
+ if ( $cgi->param('delay') ) {
+ my $date = parse_datetime($cgi->param('start_date'));
+ if (!$date) {
+ $error = "Invalid change date '".$cgi->param('start_date')."'.";
+ } elsif ( $date < $now ) {
+ $error = "Change date ".$cgi->param('start_date')." is in the past.";
+ } else {
+ # schedule the change
+ $change{'start_date'} = $date;
+ $error = $cust_pkg->change_later(\%change);
+ }
+ } else {
+ # special case: if there's a package change scheduled, and it matches
+ # the parameters the user requested this time, then change to the existing
+ # future package.
+ if ( $cust_pkg->change_to_pkgnum ) {
+ my $change_to = FS::cust_pkg->by_key($cust_pkg->change_to_pkgnum);
+ if (
+ $change_to->pkgpart == $change{'pkgpart'} and
+ $change_to->locationnum == $change{'locationnum'} and
+ $change_to->quantity == $change{'quantity'} and
+ $change_to->contract_end == $change{'contract_end'}
+ ) {
+ %change = ( 'cust_pkg' => $change_to );
+ }
}
- }
- # do a package change right now
- my $pkg_or_error = $cust_pkg->change( \%change );
- $error = ref($pkg_or_error) ? '' : $pkg_or_error;
+ # do a package change right now
+ my $pkg_or_error = $cust_pkg->change( \%change );
+ $error = ref($pkg_or_error) ? '' : $pkg_or_error;
+ }
}
</%init>
diff --git a/httemplate/misc/change_pkg.cgi b/httemplate/misc/change_pkg.cgi
index 1b4a94e81..e74747e82 100755
--- a/httemplate/misc/change_pkg.cgi
+++ b/httemplate/misc/change_pkg.cgi
@@ -28,6 +28,14 @@
'curr_value' => $cust_pkg->quantity
&>
+% if ($use_contract_end) {
+ <& /elements/tr-input-date-field.html, {
+ 'name' => 'contract_end',
+ 'value' => ($cgi->param('contract_end') || $cust_pkg->get('contract_end')),
+ 'label' => '<B>Contract End</B>',
+ } &>
+% }
+
</TABLE>
<BR>
@@ -124,6 +132,8 @@ my $part_pkg = $cust_pkg->part_pkg;
my $title = "Change Package";
+my $use_contract_end = $cust_pkg->get('contract_end') ? 1 : 0;
+
# if there's already a package change ordered, preload it
if ( $cust_pkg->change_to_pkgnum ) {
my $change_to = FS::cust_pkg->by_key($cust_pkg->change_to_pkgnum);
@@ -131,6 +141,9 @@ if ( $cust_pkg->change_to_pkgnum ) {
foreach(qw( start_date pkgpart locationnum quantity )) {
$cgi->param($_, $change_to->get($_));
}
+ if ($use_contract_end) {
+ $cgi->param('contract_end', $change_to->get('contract_end'));
+ }
$title = "Edit Scheduled Package Change";
}
</%init>
diff --git a/httemplate/view/cust_main/packages/status.html b/httemplate/view/cust_main/packages/status.html
index 8057d8c3a..81156c927 100644
--- a/httemplate/view/cust_main/packages/status.html
+++ b/httemplate/view/cust_main/packages/status.html
@@ -417,6 +417,10 @@ sub pkg_status_row_expire {
} elsif ( $cust_pkg->change_to_pkg->locationnum != $cust_pkg->locationnum )
{
$title = mt('Will <b>change location</b> on');
+ } elsif (( $cust_pkg->change_to_pkg->quantity != $cust_pkg->quantity ) ||
+ ( $cust_pkg->change_to_pkg->contract_end != $cust_pkg->contract_end ))
+ {
+ $title = mt('Will change on');
} else {
# FS::cust_pkg->change_later should have prevented this, but
# just so that we can display _something_