ae92a75289ae1ecaeb795781ff44bc2f2ae106ba
[freeside.git] / httemplate / misc / process / elements / reason
1 <%init>
2 #untaint reasonnum, and set up new reason if appropriate
3 my $reasonnum = $cgi->param('reasonnum');
4 $reasonnum =~ /^(-?\d+)$/ or die "Illegal reasonnum";
5 $reasonnum = $1;
6
7 my $error;
8 if ($reasonnum == -1) {
9   my $new_reason = FS::reason->new({
10     map { $_ => scalar( $cgi->param("reasonnum_new_$_") ) }
11     qw( reason_type reason unsuspend_pkgpart unsuspend_hold unused_credit )
12   }); # not sanitizing them here, but check() will do it
13   $error = $new_reason->insert;
14   $reasonnum = $new_reason->reasonnum;
15 }
16 return ($reasonnum, $error);
17 </%init>