RT# 79284 Updated discounts UI for Change Package screen
[freeside.git] / httemplate / misc / cancel_cust.html
index a757aa6..8536702 100644 (file)
@@ -1,36 +1,63 @@
-<% include('/elements/header-popup.html', 'Cancel customer' ) %>
+<& /elements/header-popup.html, mt('Cancel customer')  &>
 
-% if ( $cgi->param('error') ) { 
-  <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT>
-  <BR><BR>
-% } 
+<& /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) %>
-
-<% include('/elements/tr-select-reason.html',
+ <P ALIGN="center"><B><% mt('Permanently delete all services and cancel this customer?') |h %></B>
+
+<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"><% mt('Cancel now') |h %></TD>
+</TR>
+<TR>
+  <TD ALIGN="right">
+    <INPUT TYPE="radio" NAME="now_or_later" VALUE="1" onclick="toggle(true)" />
+  </TD>
+  <TD ALIGN="left"><% mt('Cancel on date: ') |h %> 
+  <& /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> 
+% if ( $cust_main->payby =~ /^(CARD|DCRD|CHEK|DCHK)$/ ) {
+% my $ban = "Ban this customer's ";
+% $ban .= 'credit card' if $cust_main->payby =~ /^(CARD|DCRD)$/;
+% $ban .= 'ACH account' if $cust_main->payby =~ /^(CHEK|DCHK)$/;
+    <P ALIGN="center">
+         <INPUT TYPE="checkbox" NAME="ban" ID="ban" VALUE="1"><% mt($ban) |h %> 
+% }
+
+<TABLE BGCOLOR="#cccccc" BORDER="0" CELLSPACING="2" STYLE="margin-left:auto; margin-right:auto">
+<& /elements/tr-select-reason.html,
              'field'          => 'reasonnum',
              'reason_class'   => 'C',
-             #XXX these need to be sticky on errors too...
-             #'curr_value'     => '',
-             'control_button' => 'document.cust_cancel_popup.submit',
-          )
-%>
+             'cgi'            => $cgi,
+             'control_button' => 'confirm_cancel_cust_button',
+&>
 
 </TABLE>
 
 <BR>
 <P ALIGN="CENTER">
-<INPUT TYPE="submit" NAME="submit" VALUE="Cancel customer" disabled='true'> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<INPUT TYPE="BUTTON" VALUE="Don't cancel" onClick="parent.cClick();"> 
+<INPUT TYPE="submit" NAME="submit" ID="confirm_cancel_cust_button" VALUE="<% mt('Cancel customer') |h %>" DISABLED> 
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+<INPUT TYPE="BUTTON" VALUE="<% mt("Don't cancel") |h %>" onClick="parent.cClick();"> 
 
 </FORM>
 </BODY>
 
 <%init>
 
-my($custnum, $reasonnum, $submit, $cust_main, $curuser, $class); 
-if ( $cgi->param('error') ) {
-  $custnum        = $cgi->param('custnum');
-  $reasonnum     = $cgi->param('reasonnum');
-} else {
-  my( $query ) = $cgi->keywords;
-  if ( $query =~ /^(\d+)$/ ) {
-    $custnum  = $1;
-  } else {
-    die "illegal query ". $cgi->keywords;
-  }
-}
+$cgi->param('custnum') =~ /^(\d+)$/ or die 'illegal custnum';
+my $custnum = $1;
+
+my $curuser = $FS::CurrentUser::CurrentUser;
 
-$curuser = $FS::CurrentUser::CurrentUser;
+die "access denied" unless $curuser->access_right('Cancel customer');
 
-$cust_main = qsearchs( {
+my $cust_main = qsearchs( {
   'table'     => 'cust_main',
   'hashref'   => { 'custnum' => $custnum },
   'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
 } );
 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 ';
-  if ( $cust_main->payby =~ /^(CARD|DCRD)$/ ) {
-    $ban .= 'credit card';
-  } elsif (  $cust_main->payby =~ /^(CHEK|DCHK)$/ ) {
-    $ban .= 'ACH account';
-  }
-}
-
 </%init>