X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fmisc%2Fcust_main-suspend.cgi;h=e81e2b4906710c0fe3b063c80b01f0b0726405f0;hb=0929e7aec153632691a64ae8755c082090fd1de5;hp=61851364ec8d2d841bc40c817bda55bf214e7d11;hpb=f3c4966ed1f6ec3db7accd6dcdd3a5a3821d72a7;p=freeside.git diff --git a/httemplate/misc/cust_main-suspend.cgi b/httemplate/misc/cust_main-suspend.cgi index 61851364e..e81e2b490 100755 --- a/httemplate/misc/cust_main-suspend.cgi +++ b/httemplate/misc/cust_main-suspend.cgi @@ -1,6 +1,6 @@ <& /elements/header-popup.html, mt("Customer suspended") &> @@ -22,50 +22,39 @@ if ( $cgi->param('custnum') =~ /^(\d+)$/ ) { $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' ) ), - }; +#untaint reasonnum / create new reason +my ($reasonnum, $error) = $m->comp('process/elements/reason'); +if (!$reasonnum) { + $error ||= 'Reason required'; } -#eslaf - my $cust_main = qsearchs( { 'table' => 'cust_main', 'hashref' => { 'custnum' => $custnum }, 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql, } ); -my @errors; -if($cgi->param('now_or_later')) { +if ( $error ) { + # do nothing +} elsif ( $cgi->param('now_or_later') ) { $adjourn = parse_datetime($adjourn); if($adjourn) { #warn "setting adjourn dates on custnum#$custnum\n"; my @pkgs = $cust_main->unsuspended_pkgs; - @errors = grep {$_} map { $_->suspend( + my @errors = grep {$_} map { $_->suspend( 'reason' => $reasonnum, 'date' => $adjourn, ) } @pkgs; + $error = join(' / ', @errors); + } else { + $error = ("error parsing adjourn date: ".$cgi->param('adjourn')); } - else { - @errors = ("error parsing adjourn date: ".$cgi->param('adjourn')); - } -} -else { +} else { warn "suspending $cust_main"; - @errors = $cust_main->suspend( + $error = $cust_main->suspend( 'reason' => $reasonnum, ); } -my $error = join(' / ', @errors) if scalar(@errors); if ( $error ) { $cgi->param('error', $error);