[freeside-commits] freeside/httemplate/misc cancel_cust.html, NONE, 1.1.2.2 cust_main-cancel.cgi, 1.4.2.1, 1.4.2.2

Jeff Finucane,420,, jeff at wavetail.420.am
Wed Dec 19 14:31:40 PST 2007


Update of /home/cvs/cvsroot/freeside/httemplate/misc
In directory wavetail:/tmp/cvs-serv27949/misc

Modified Files:
      Tag: FREESIDE_1_7_BRANCH
	cust_main-cancel.cgi 
Added Files:
      Tag: FREESIDE_1_7_BRANCH
	cancel_cust.html 
Log Message:
backport reason selection for whole customer cancel (RT#2872)

--- NEW FILE: cancel_cust.html ---
<% include('/elements/header-popup.html', 'Cancel customer' ) %>

% if ( $cgi->param('error') ) { 
  <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT>
  <BR><BR>
% } 

<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', 'reasonnum', 'C', '', '', '', 'document.cust_cancel_popup.submit',
          )
%>

</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();"> 

</FORM>
</BODY>
</HTML>

<%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;
  }
}

$curuser = $FS::CurrentUser::CurrentUser;

$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>


Index: cust_main-cancel.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/misc/cust_main-cancel.cgi,v
retrieving revision 1.4.2.1
retrieving revision 1.4.2.2
diff -u -d -r1.4.2.1 -r1.4.2.2
--- cust_main-cancel.cgi	8 Oct 2007 19:04:48 -0000	1.4.2.1
+++ cust_main-cancel.cgi	19 Dec 2007 22:31:38 -0000	1.4.2.2
@@ -1,23 +1,54 @@
-%
-%
-%my $custnum;
-%my $ban = '';
-%if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
-%  $custnum = $1;
-%  $ban = $cgi->param('ban');
-%} else {
-%  my($query) = $cgi->keywords;
-%  $query =~ /^(\d+)$/ || die "Illegal custnum";
-%  $custnum = $1;
-%}
-%
-%my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
-%
-%my @errors = $cust_main->cancel( 'ban' => $ban );
-%errorpage(join(' / ', @errors)) if scalar(@errors);
-%
-%#print $cgi->redirect($p. "view/cust_main.cgi?". $cust_main->custnum);
-%print $cgi->redirect($p);
-%
-%
+<% header("Customer cancelled") %>
+  <SCRIPT TYPE="text/javascript">
+    window.top.location.reload();
+  </SCRIPT>
+  </BODY>
+</HTML>
+<%init>
 
+my $custnum;
+my $ban = '';
+if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
+  $custnum = $1;
+  $ban = $cgi->param('ban');
+} else {
+  my($query) = $cgi->keywords;
+  $query =~ /^(\d+)$/ || die "Illegal custnum";
+  $custnum = $1;
+}
+
+#false laziness w/process/cancel_pkg.html
+
+#untaint reasonnum
+my $reasonnum = $cgi->param('reasonnum');
+$reasonnum =~ /^(-?\d+)$/ || die "Illegal reasonnum";
+$reasonnum = $1;
+
+if ($reasonnum == -1) {
+  $reasonnum = {
+    'typenum' => scalar( $cgi->param('newreasonnumT') ),
+    'reason'  => scalar( $cgi->param('newreasonnum' ) ),
+  };
+}
+
+#eslaf
+
+my $cust_main = qsearchs( {
+  'table'     => 'cust_main',
+  'hashref'   => { 'custnum' => $custnum },
+  'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
+} );
+
+warn "cancelling $cust_main";
+my @errors = $cust_main->cancel(
+  'ban'    => $ban,
+  'reason' => $reasonnum,
+);
+my $error = join(' / ', @errors) if scalar(@errors);
+
+if ( $error ) {
+  $cgi->param('error', $error);
+  print $cgi->redirect(popurl(1). "cancel_cust.html?". $cgi->query_string );
+}
+
+</%init>



More information about the freeside-commits mailing list