option to credit unused time on suspension as part of suspend reason, #31702
[freeside.git] / httemplate / misc / process / elements / reason
diff --git a/httemplate/misc/process/elements/reason b/httemplate/misc/process/elements/reason
new file mode 100644 (file)
index 0000000..ae92a75
--- /dev/null
@@ -0,0 +1,17 @@
+<%init>
+#untaint reasonnum, and set up new reason if appropriate
+my $reasonnum = $cgi->param('reasonnum');
+$reasonnum =~ /^(-?\d+)$/ or die "Illegal reasonnum";
+$reasonnum = $1;
+
+my $error;
+if ($reasonnum == -1) {
+  my $new_reason = FS::reason->new({
+    map { $_ => scalar( $cgi->param("reasonnum_new_$_") ) }
+    qw( reason_type reason unsuspend_pkgpart unsuspend_hold unused_credit )
+  }); # not sanitizing them here, but check() will do it
+  $error = $new_reason->insert;
+  $reasonnum = $new_reason->reasonnum;
+}
+return ($reasonnum, $error);
+</%init>