diff options
Diffstat (limited to 'httemplate/misc')
| -rw-r--r-- | httemplate/misc/cancel_cust.html | 42 | ||||
| -rwxr-xr-x | httemplate/misc/cust_main-cancel.cgi | 31 | 
2 files changed, 60 insertions, 13 deletions
| 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') %> +  <FORM NAME="cust_cancel_popup" ACTION="<% popurl(1) %>cust_main-cancel.cgi" METHOD=POST>  <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">   <P ALIGN="center"><B>Permanently delete all services and cancel this customer?</B> - <% $ban %> -  -<BR><BR> - -<% ntable("#cccccc", 2) %> +<TABLE BORDER="0" CELLSPACING="2" +STYLE="margin-left:auto; margin-right:auto"> +<TR> +  <TD ALIGN="right"> +    <INPUT TYPE="radio" NAME="now_or_later" VALUE="0" onclick="toggle(false)" CHECKED /> +  </TD> +  <TD ALIGN="left">Cancel now</TD> +</TR> +<TR> +  <TD ALIGN="right"> +    <INPUT TYPE="radio" NAME="now_or_later" VALUE="1" onclick="toggle(true)" /> +  </TD> +  <TD ALIGN="left">Cancel on date:  +  <% include('/elements/input-date-field.html', { +              'name'    => 'expire', +              'value'   => time, +    } ) %> +  </TD> +</TR> +</TABLE> +<SCRIPT type="text/javascript"> +function toggle(val) { +  document.getElementById("expire_text").disabled = !val; +  document.getElementById("ban").disabled = val; +  document.getElementById("expire_button").style.visibility =  +    val ? 'visible' : 'hidden'; +} +toggle(false); +</SCRIPT>  +<% $ban %> +<TABLE BGCOLOR="#cccccc", BORDER="0" CELLSPACING="2" +STYLE="margin-left:auto; margin-right:auto">  <% 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 = '<BR><P ALIGN="center">'. -         '<INPUT TYPE="checkbox" NAME="ban" VALUE="1"> Ban this customer\'s '; +  $ban = '<P ALIGN="center">'. +         '<INPUT TYPE="checkbox" NAME="ban" ID="ban" VALUE="1"> 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") %>    <SCRIPT TYPE="text/javascript">      window.top.location.reload();    </SCRIPT> @@ -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 ) { | 
