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

index cf874aa..b3fffe3 100644 (file)
@@ -318,6 +318,13 @@ httemplate/docs/config.html
   },
 
   {
   },
 
   {
+    'key'         => 'unapplypayments',
+    'section'     => 'UI',
+    'description' => 'Enable "unapplication" of unclosed payments.',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'dirhash',
     'section'     => 'shell',
     'description' => 'Optional numeric value to control directory hashing.  If positive, hashes directories for the specified number of levels from the front of the username.  If negative, hashes directories for the specified number of levels from the end of the username.  Some examples: <ul><li>1: user -> <a href="#home">/home</a>/u/user<li>2: user -> <a href="#home">/home</a>/u/s/user<li>-1: user -> <a href="#home">/home</a>/r/user<li>-2: user -> <a href="#home">home</a>/r/e/user</ul>',
     'key'         => 'dirhash',
     'section'     => 'shell',
     'description' => 'Optional numeric value to control directory hashing.  If positive, hashes directories for the specified number of levels from the front of the username.  If negative, hashes directories for the specified number of levels from the end of the username.  Some examples: <ul><li>1: user -> <a href="#home">/home</a>/u/user<li>2: user -> <a href="#home">/home</a>/u/s/user<li>-1: user -> <a href="#home">/home</a>/r/user<li>-2: user -> <a href="#home">home</a>/r/e/user</ul>',
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);
+
+%>
index a1a47ea..7dbdc13 100755 (executable)
@@ -470,6 +470,11 @@ function cust_pay_areyousure(href) {
  == true)
         window.location.href = href;
 }
  == true)
         window.location.href = href;
 }
+function cust_pay_unapply_areyousure(href) {
+    if (confirm("Are you sure you want to unapply this payment?")
+ == true)
+        window.location.href = href;
+}
 </SCRIPT>
 END
 
 </SCRIPT>
 END
 
@@ -524,8 +529,12 @@ if ( $conf->config('payby-default') ne 'HIDE' ) {
       my $delete = $payment->closed !~ /^Y/i && $conf->exists('deletepayments')
                      ? qq! (<A HREF="javascript:cust_pay_areyousure('${p}misc/delete-cust_pay.cgi?!. $payment->paynum. qq!')">delete</A>)!
                      : '';
       my $delete = $payment->closed !~ /^Y/i && $conf->exists('deletepayments')
                      ? qq! (<A HREF="javascript:cust_pay_areyousure('${p}misc/delete-cust_pay.cgi?!. $payment->paynum. qq!')">delete</A>)!
                      : '';
+      my $unapply =
+        $payment->closed !~ /^Y/i && $conf->exists('unapplypayments')
+          ? qq! (<A HREF="javascript:cust_pay_unapply_areyousure('${p}misc/unapply-cust_pay.cgi?!. $payment->paynum. qq!')">unapply</A>)!
+          : '';
       push @history,
       push @history,
-        "$date\tPayment, Invoice #$invnum ($payby$payinfo)$delete\t\t$paid\t\t\t$target";
+        "$date\tPayment, Invoice #$invnum ($payby$payinfo)$delete$unapply\t\t$paid\t\t\t$target";
     }
   
     my(@cust_credit_bill)=
     }
   
     my(@cust_credit_bill)=