add option to unapply payments
authorivan <ivan>
Wed, 23 Oct 2002 15:49:36 +0000 (15:49 +0000)
committerivan <ivan>
Wed, 23 Oct 2002 15:49:36 +0000 (15:49 +0000)
FS/FS/Conf.pm
httemplate/misc/unapply-cust_pay.cgi [new file with mode: 0755]

index 8befed4..3f6d652 100644 (file)
@@ -324,6 +324,13 @@ httemplate/docs/config.html
     'type'        => [qw( checkbox text )],
   },
 
+  {
+    'key'         => 'unapplypayments',
+    'section'     => 'UI',
+    'description' => 'Enable "unapplication" of unclosed payments.',
+    'type'        => 'checkbox',
+  },
+
   {
     'key'         => 'dirhash',
     'section'     => 'shell',
diff --git a/httemplate/misc/unapply-cust_pay.cgi b/httemplate/misc/unapply-cust_pay.cgi
new file mode 100755 (executable)
index 0000000..28643ef
--- /dev/null
@@ -0,0 +1,18 @@
+<%
+
+#untaint paynum
+my($query) = $cgi->keywords;
+$query =~ /^(\d+)$/ || die "Illegal paynum";
+my $paynum = $1;
+
+my $cust_pay = qsearchs('cust_pay', { 'paynum' => $paynum } );
+my $custnum = $cust_pay->custnum;
+
+foreach my $cust_bill_pay ( $cust_pay->cust_bill_pay ) {
+  my $error = $cust_bill_pay->delete;
+  eidiot($error) if $error;
+}
+
+print $cgi->redirect($p. "view/cust_main.cgi?". $custnum);
+
+%>