diff options
| author | Mark Wells <mark@freeside.biz> | 2013-07-15 18:25:13 -0700 |
|---|---|---|
| committer | Mark Wells <mark@freeside.biz> | 2013-07-15 18:25:13 -0700 |
| commit | ebcfdd04f1fe69028836d231238845801aa69505 (patch) | |
| tree | 8c2bbc29c554709d3e0576d3626630f58ca89d82 /httemplate/edit | |
| parent | 8e84773c2e9107185f0a0cf629cf357d7b8979f5 (diff) | |
future package change, #20687
Diffstat (limited to 'httemplate/edit')
| -rwxr-xr-x | httemplate/edit/REAL_cust_pkg.cgi | 14 | ||||
| -rw-r--r-- | httemplate/edit/process/change-cust_pkg.html | 31 |
2 files changed, 43 insertions, 2 deletions
diff --git a/httemplate/edit/REAL_cust_pkg.cgi b/httemplate/edit/REAL_cust_pkg.cgi index 99e911ae5..ac8aa40cb 100755 --- a/httemplate/edit/REAL_cust_pkg.cgi +++ b/httemplate/edit/REAL_cust_pkg.cgi @@ -95,7 +95,21 @@ function confirm_changes() { <& .row_display, cust_pkg=>$cust_pkg, column=>'susp', label=>'Suspension' &> <& .row_display, cust_pkg=>$cust_pkg, column=>'resume', label=>'Resumption', note=> '(will <b>unsuspend</b> this package when the date is reached' &> +% if ( $cust_pkg->change_to_pkgnum ) { +% my $change_to_pkg = FS::cust_pkg->by_key($cust_pkg->change_to_pkgnum); +% my $desc; +% if ( $change_to_pkg->pkgpart != $cust_pkg->pkgpart ) { +% $desc = '<b>change package</b> to '.$change_to_pkg->part_pkg->pkg; +% } +% if ( $change_to_pkg->locationnum != $cust_pkg->locationnum ) { +% $desc .= ' and ' if $desc; +% $desc .= '<b>change location</b> to "'. +% $change_to_pkg->cust_location->line . '"'; +% } + <& .row_display, cust_pkg=>$cust_pkg, column=>'expire', label=>'Change package', note=>"(will $desc when the date is reached)" &> +% } else { <& .row_display, cust_pkg=>$cust_pkg, column=>'expire', label=>'Expiration', note=>'(will <b>cancel</b> this package when the date is reached)' &> +% } <& .row_display, cust_pkg=>$cust_pkg, column=>'cancel', label=>'Cancellation' &> diff --git a/httemplate/edit/process/change-cust_pkg.html b/httemplate/edit/process/change-cust_pkg.html index c893f13a2..9d06d8e1a 100644 --- a/httemplate/edit/process/change-cust_pkg.html +++ b/httemplate/edit/process/change-cust_pkg.html @@ -40,8 +40,35 @@ if ( $cgi->param('locationnum') == -1 ) { $change{'cust_location'} = $cust_location; } -my $pkg_or_error = $cust_pkg->change( \%change ); +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."; + } 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'} ) { -my $error = ref($pkg_or_error) ? '' : $pkg_or_error; + %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; +} </%init> |
