fix customer cancellation, sort of a side effect of #2872, fixes #3480, #3481
[freeside.git] / httemplate / misc / cancel_cust.html
1 <% include('/elements/header-popup.html', 'Cancel customer' ) %>
2
3 <% include('/elements/error.html') %>
4
5 <FORM NAME="cust_cancel_popup" ACTION="<% popurl(1) %>cust_main-cancel.cgi" METHOD=POST>
6 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
7
8
9  <P ALIGN="center"><B>Permanently delete all services and cancel this customer?</B>
10
11  <% $ban %>
12  
13 <BR><BR>
14
15 <% ntable("#cccccc", 2) %>
16
17 <% include('/elements/tr-select-reason.html',
18              'field'          => 'reasonnum',
19              'reason_class'   => 'C',
20              'cgi'            => $cgi,
21              'control_button' => "document.getElementById('confirm_cancel_cust_button')",
22           )
23 %>
24
25 </TABLE>
26
27 <BR>
28 <P ALIGN="CENTER">
29 <INPUT TYPE="submit" NAME="submit" ID="confirm_cancel_cust_button" VALUE="Cancel customer" DISABLED> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<INPUT TYPE="BUTTON" VALUE="Don't cancel" onClick="parent.cClick();"> 
30
31 </FORM>
32 </BODY>
33 </HTML>
34
35 <%init>
36
37 $cgi->param('custnum') =~ /^(\d+)$/ or die 'illegal custnum';
38 my $custnum = $1;
39
40 my $curuser = $FS::CurrentUser::CurrentUser;
41
42 die "access denied" unless $curuser->access_right('Cancel customer');
43
44 my $cust_main = qsearchs( {
45   'table'     => 'cust_main',
46   'hashref'   => { 'custnum' => $custnum },
47   'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
48 } );
49 die "No customer # $custnum" unless $cust_main;
50
51 my $ban = '';
52 if ( $cust_main->payby =~ /^(CARD|DCRD|CHEK|DCHK)$/ ) {
53   $ban = '<BR><P ALIGN="center">'.
54          '<INPUT TYPE="checkbox" NAME="ban" VALUE="1"> Ban this customer\'s ';
55   if ( $cust_main->payby =~ /^(CARD|DCRD)$/ ) {
56     $ban .= 'credit card';
57   } elsif (  $cust_main->payby =~ /^(CHEK|DCHK)$/ ) {
58     $ban .= 'ACH account';
59   }
60 }
61
62 </%init>
63