From: jeff Date: Wed, 19 Dec 2007 22:31:38 +0000 (+0000) Subject: backport reason selection for whole customer cancel (RT#2872) X-Git-Tag: freeside_1_7_3rc1~188 X-Git-Url: http://git.freeside.biz/gitweb/?a=commitdiff_plain;h=7b657e6cca6770039c52ca6bc43cd9a7b24072c8;p=freeside.git backport reason selection for whole customer cancel (RT#2872) --- diff --git a/httemplate/misc/cancel_cust.html b/httemplate/misc/cancel_cust.html new file mode 100644 index 000000000..022fc108f --- /dev/null +++ b/httemplate/misc/cancel_cust.html @@ -0,0 +1,70 @@ +<% include('/elements/header-popup.html', 'Cancel customer' ) %> + +% if ( $cgi->param('error') ) { + Error: <% $cgi->param('error') %> +

+% } + +
+ + + +

Permanently delete all services and cancel this customer? + + <% $ban %> + +

+ +<% ntable("#cccccc", 2) %> + +<% include('/elements/tr-select-reason.html', 'reasonnum', 'C', '', '', '', 'document.cust_cancel_popup.submit', + ) +%> + + + +
+

+          + +

+ + + +<%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 = '

'. + ' Ban this customer\'s '; + if ( $cust_main->payby =~ /^(CARD|DCRD)$/ ) { + $ban .= 'credit card'; + } elsif ( $cust_main->payby =~ /^(CHEK|DCHK)$/ ) { + $ban .= 'ACH account'; + } +} + + + diff --git a/httemplate/misc/cust_main-cancel.cgi b/httemplate/misc/cust_main-cancel.cgi index 13d7d1ff1..7f6f69701 100755 --- a/httemplate/misc/cust_main-cancel.cgi +++ b/httemplate/misc/cust_main-cancel.cgi @@ -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") %> + + + +<%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 ); +} + + diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi index 850b48b27..382bf68f6 100755 --- a/httemplate/view/cust_main.cgi +++ b/httemplate/view/cust_main.cgi @@ -37,9 +37,9 @@ var confirm_cancel = '

Cancel this customer | + <% cust_cancel_link($cust_main) %> | + % } % if ( $conf->exists('deletecustomers') % && $curuser->access_right('Delete customer') @@ -169,3 +169,33 @@ my $cust_main = qsearchs({ die "Customer not found!" unless $cust_main; +<%once> + + +sub cust_cancel_link { cust_popup_link( 'misc/cancel_cust.html', + 'Cancel this customer', + 'Confirm Cancellation', + '#ff0000', + @_, + ); +} + +#false laziness w/view/cust_main/packages.html + +sub cust_popup_link { + my($action, $label, $actionlabel, $color, $cust_main) = @_; + $action .= '?'. $cust_main->custnum; + popup_link($action, $label, $actionlabel, $color); +} + +sub popup_link { + my($action, $label, $actionlabel, $color) = @_; + $color ||= '#333399'; + qq!$label!; + +# CLOSETEXT, '', +#WIDTH, 576, HEIGHT, 128, TEXTSIZE, 3, +#BGCOLOR, '#ff0000', CGCOLOR, '#ff0000' +} + +