[freeside-commits] freeside/httemplate/misc cancel_cust.html, 1.6, 1.7 cust_main-cancel.cgi, 1.7, 1.8
Mark Wells
mark at wavetail.420.am
Fri Sep 3 19:19:05 PDT 2010
Update of /home/cvs/cvsroot/freeside/httemplate/misc
In directory wavetail.420.am:/tmp/cvs-serv9155/misc
Modified Files:
cancel_cust.html cust_main-cancel.cgi
Log Message:
set expire date for customer packages, RT#9697
Index: cancel_cust.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/misc/cancel_cust.html,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -d -r1.6 -r1.7
--- cancel_cust.html 7 May 2008 21:36:35 -0000 1.6
+++ cancel_cust.html 4 Sep 2010 02:19:03 -0000 1.7
@@ -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>
+<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 %>
-<BR><BR>
-
-<% ntable("#cccccc", 2) %>
-
+<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 @@
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)$/ ) {
Index: cust_main-cancel.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/misc/cust_main-cancel.cgi,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -w -d -r1.7 -r1.8
--- cust_main-cancel.cgi 13 Jan 2008 21:14:18 -0000 1.7
+++ cust_main-cancel.cgi 4 Sep 2010 02:19:03 -0000 1.8
@@ -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 @@
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 @@
'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
} );
+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";
-my @errors = $cust_main->cancel(
+ @errors = $cust_main->cancel(
'ban' => $ban,
'reason' => $reasonnum,
);
+}
my $error = join(' / ', @errors) if scalar(@errors);
if ( $error ) {
More information about the freeside-commits
mailing list