From 48e3f879908a13cb87786e32e158ff8a8bf18fbb Mon Sep 17 00:00:00 2001 From: mark Date: Sat, 4 Sep 2010 02:19:03 +0000 Subject: set expire date for customer packages, RT#9697 --- httemplate/misc/cancel_cust.html | 42 ++++++++++++++++++++++++++++++------ httemplate/misc/cust_main-cancel.cgi | 31 ++++++++++++++++++++------ 2 files changed, 60 insertions(+), 13 deletions(-) (limited to 'httemplate/misc') diff --git a/httemplate/misc/cancel_cust.html b/httemplate/misc/cancel_cust.html index 12c37ebe2..b7ecccd7e 100644 --- a/httemplate/misc/cancel_cust.html +++ b/httemplate/misc/cancel_cust.html @@ -2,18 +2,46 @@ <% include('/elements/error.html') %> +

Permanently delete all services and cancel this customer? - <% $ban %> - -

- -<% ntable("#cccccc", 2) %> + + + + + + + + + +
+ + Cancel now
+ + Cancel on date:  + <% include('/elements/input-date-field.html', { + 'name' => 'expire', + 'value' => time, + } ) %> +
+ +<% $ban %> + <% include('/elements/tr-select-reason.html', 'field' => 'reasonnum', 'reason_class' => 'C', @@ -50,8 +78,8 @@ die "No customer # $custnum" unless $cust_main; my $ban = ''; if ( $cust_main->payby =~ /^(CARD|DCRD|CHEK|DCHK)$/ ) { - $ban = '

'. - ' Ban this customer\'s '; + $ban = '

'. + ' Ban this customer\'s '; if ( $cust_main->payby =~ /^(CARD|DCRD)$/ ) { $ban .= 'credit card'; } elsif ( $cust_main->payby =~ /^(CHEK|DCHK)$/ ) { diff --git a/httemplate/misc/cust_main-cancel.cgi b/httemplate/misc/cust_main-cancel.cgi index 009a7d41b..44be20c8a 100755 --- a/httemplate/misc/cust_main-cancel.cgi +++ b/httemplate/misc/cust_main-cancel.cgi @@ -1,4 +1,4 @@ -<% header("Customer cancelled") %> +<% include('/elements/header.html', "Customer cancelled") %> @@ -11,9 +11,11 @@ die "access denied" my $custnum; my $ban = ''; +my $expire = ''; if ( $cgi->param('custnum') =~ /^(\d+)$/ ) { $custnum = $1; $ban = $cgi->param('ban'); + $expire = $cgi->param('expire'); } else { my($query) = $cgi->keywords; $query =~ /^(\d+)$/ || die "Illegal custnum"; @@ -42,11 +44,28 @@ my $cust_main = qsearchs( { 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql, } ); -warn "cancelling $cust_main"; -my @errors = $cust_main->cancel( - 'ban' => $ban, - 'reason' => $reasonnum, -); +my @errors; +if($cgi->param('now_or_later')) { + $expire = parse_datetime($expire); + if($expire) { + #warn "setting expire dates on custnum#$custnum\n"; + my @pkgs = $cust_main->ncancelled_pkgs; + @errors = grep {$_} map { $_->cancel( + 'reason' => $reasonnum, + 'date' => $expire, + ) } @pkgs; + } + else { + @errors = ("error parsing expire date: ".$cgi->param('expire')); + } +} +else { + warn "cancelling $cust_main"; + @errors = $cust_main->cancel( + 'ban' => $ban, + 'reason' => $reasonnum, + ); +} my $error = join(' / ', @errors) if scalar(@errors); if ( $error ) { -- cgit v1.2.1