X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fmisc%2Fcust_main-cancel.cgi;h=009a7d41bd65415802bc24692fbc9e0af3d8d206;hb=2ab068f449eb97a10e18d20e9dab5ab9faa017e7;hp=519e6c2b2ea6e9540a8836b417ccf8a67257d40d;hpb=369cc8545df88dd4e717ccd8f6aa8719bc4308b3;p=freeside.git diff --git a/httemplate/misc/cust_main-cancel.cgi b/httemplate/misc/cust_main-cancel.cgi index 519e6c2b2..009a7d41b 100755 --- a/httemplate/misc/cust_main-cancel.cgi +++ b/httemplate/misc/cust_main-cancel.cgi @@ -1,4 +1,13 @@ -<% +<% header("Customer cancelled") %> + + + +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Cancel customer'); my $custnum; my $ban = ''; @@ -11,12 +20,38 @@ if ( $cgi->param('custnum') =~ /^(\d+)$/ ) { $custnum = $1; } -my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); +#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' ) ), + }; +} -my @errors = $cust_main->cancel( 'ban' => $ban ); -eidiot(join(' / ', @errors)) if scalar(@errors); +#eslaf -#print $cgi->redirect($p. "view/cust_main.cgi?". $cust_main->custnum); -print $cgi->redirect($p); +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 ); +} -%> +