diff options
author | Mark Wells <mark@freeside.biz> | 2014-11-25 19:37:48 -0800 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2014-11-25 19:37:56 -0800 |
commit | be2bcc10c35d7762178b245cd38382047a7e270d (patch) | |
tree | b602a1ff99ffbbbd679a448725c344532349ba25 /httemplate/misc/cust_main-cancel.cgi | |
parent | d3011bbdd3401dd11cbaed058d495d29c2a6ebc0 (diff) |
option to credit unused time on suspension as part of suspend reason, #31702
Diffstat (limited to 'httemplate/misc/cust_main-cancel.cgi')
-rwxr-xr-x | httemplate/misc/cust_main-cancel.cgi | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/httemplate/misc/cust_main-cancel.cgi b/httemplate/misc/cust_main-cancel.cgi index 2ae9f1021..a78a8b3dc 100755 --- a/httemplate/misc/cust_main-cancel.cgi +++ b/httemplate/misc/cust_main-cancel.cgi @@ -22,51 +22,43 @@ 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') ) { $expire = parse_datetime($expire); if($expire) { #warn "setting expire dates on custnum#$custnum\n"; my @pkgs = $cust_main->ncancelled_pkgs; - @errors = grep {$_} map { $_->cancel( + my @errors = grep {$_} map { $_->cancel( 'reason' => $reasonnum, 'date' => $expire, ) } @pkgs; + $error = join(' / ', @errors); } else { - @errors = ("error parsing expire date: ".$cgi->param('expire')); + $error = ("error parsing expire date: ".$cgi->param('expire')); } } else { warn "cancelling $cust_main"; - @errors = $cust_main->cancel( + $error = $cust_main->cancel( 'ban' => $ban, 'reason' => $reasonnum, ); } -my $error = join(' / ', @errors) if scalar(@errors); if ( $error ) { $cgi->param('error', $error); |