From: ivan Date: Wed, 23 Oct 2002 15:49:44 +0000 (+0000) Subject: add option to unapply payments X-Git-Tag: freeside_1_4_1beta6~13^2~64 X-Git-Url: http://git.freeside.biz/gitweb/?a=commitdiff_plain;h=9f96bd19b87cb0084dda17da070f3bb5dadd4823;p=freeside.git add option to unapply payments --- diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index cf874aa35..b3fffe327 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -317,6 +317,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 index 000000000..28643ef6e --- /dev/null +++ b/httemplate/misc/unapply-cust_pay.cgi @@ -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); + +%> diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi index a1a47ea74..7dbdc1356 100755 --- a/httemplate/view/cust_main.cgi +++ b/httemplate/view/cust_main.cgi @@ -470,6 +470,11 @@ function cust_pay_areyousure(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; +} END @@ -524,8 +529,12 @@ if ( $conf->config('payby-default') ne 'HIDE' ) { my $delete = $payment->closed !~ /^Y/i && $conf->exists('deletepayments') ? qq! (delete)! : ''; + my $unapply = + $payment->closed !~ /^Y/i && $conf->exists('unapplypayments') + ? qq! (unapply)! + : ''; 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)=