summaryrefslogtreecommitdiff
path: root/httemplate/misc/cust_main-suspend.cgi
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2014-12-04 10:37:16 -0800
committerIvan Kohler <ivan@freeside.biz>2014-12-04 10:37:16 -0800
commit8dd41f364aaba88969dfd0908feb22709025e7f6 (patch)
tree471cb3796019d873da648413d88ca70a657414ed /httemplate/misc/cust_main-suspend.cgi
parenta2df4ef9575be1ae2f1f5b9089f121316f796bac (diff)
parentbf50a8356a7344b4f75c7bc7f952019b98867f26 (diff)
Merge branch 'master' of git.freeside.biz:/home/git/freeside
Diffstat (limited to 'httemplate/misc/cust_main-suspend.cgi')
-rwxr-xr-xhttemplate/misc/cust_main-suspend.cgi37
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);