X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fmisc%2Fcust_main-cancel.cgi;h=009a7d41bd65415802bc24692fbc9e0af3d8d206;hb=37591b61f8ad6fc5c5acb2fd8f520d2dbe4f1539;hp=257c3384f5d8e1895112cee2455a09880afd5470;hpb=5fc8c5edf574ab024d4646914b6432d458e2ffbd;p=freeside.git diff --git a/httemplate/misc/cust_main-cancel.cgi b/httemplate/misc/cust_main-cancel.cgi index 257c3384f..009a7d41b 100755 --- a/httemplate/misc/cust_main-cancel.cgi +++ b/httemplate/misc/cust_main-cancel.cgi @@ -1,16 +1,57 @@ -<% +<% header("Customer cancelled") %> + + + +<%init> -#untaint custnum -my($query) = $cgi->keywords; -$query =~ /^(\d+)$/ || die "Illegal custnum"; -my $custnum = $1; +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Cancel customer'); -my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); +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 @errors = $cust_main->cancel; -eidiot(join(' / ', @errors)) if scalar(@errors); +#false laziness w/process/cancel_pkg.html -#print $cgi->redirect($p. "view/cust_main.cgi?". $cust_main->custnum); -print $cgi->redirect($p); +#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 ); +} + +