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-suspend.cgi | |
parent | d3011bbdd3401dd11cbaed058d495d29c2a6ebc0 (diff) |
option to credit unused time on suspension as part of suspend reason, #31702
Diffstat (limited to 'httemplate/misc/cust_main-suspend.cgi')
-rwxr-xr-x | httemplate/misc/cust_main-suspend.cgi | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/httemplate/misc/cust_main-suspend.cgi b/httemplate/misc/cust_main-suspend.cgi index 61851364e..7a501d61a 100755 --- a/httemplate/misc/cust_main-suspend.cgi +++ b/httemplate/misc/cust_main-suspend.cgi @@ -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); |