X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fcust_bill_pay.cgi;h=498d477cde581f07b0a249efb1a9f15e2f2f246b;hb=eb4ff7f73c5d4bdf74a3472448b5a195598ff4cd;hp=46ca51e82b649124117bc362d11f7724ac51cf4a;hpb=355fe2160a24311e5d1faab56376c9a0781c6479;p=freeside.git diff --git a/httemplate/edit/cust_bill_pay.cgi b/httemplate/edit/cust_bill_pay.cgi index 46ca51e82..498d477cd 100755 --- a/httemplate/edit/cust_bill_pay.cgi +++ b/httemplate/edit/cust_bill_pay.cgi @@ -1,109 +1,85 @@ -<% -# +<% header("Apply Payment", '') %> -use strict; -use vars qw( $cgi $query $custnum $paynum $amount $invnum $p1 $otaker $cust_pay ); -use CGI; -use CGI::Carp qw(fatalsToBrowser); -use Date::Format; -use FS::UID qw(cgisuidsetup getotaker); -use FS::CGI qw(header popurl); -use FS::Record qw(qsearch fields); -use FS::cust_pay; -use FS::cust_bill; +% if ( $cgi->param('error') ) { + Error: <% $cgi->param('error') %> +

+% } +
-$cgi = new CGI; -cgisuidsetup($cgi); +Payment #<% $paynum %> + +
Date: <% time2str("%D", $cust_pay->_date) %> + +
Amount: $<% $cust_pay->paid %> + +
Unapplied amount: $<% $unapplied %> + + + +
Invoice # + +
Amount $ + +
+
+ +
+ + + +<%init> +my($paynum, $amount, $invnum); if ( $cgi->param('error') ) { $paynum = $cgi->param('paynum'); $amount = $cgi->param('amount'); $invnum = $cgi->param('invnum'); } else { - ($query) = $cgi->keywords; + my($query) = $cgi->keywords; $query =~ /^(\d+)$/; $paynum = $1; $amount = ''; $invnum = ''; } -$otaker = getotaker; - -$p1 = popurl(1); +my $otaker = getotaker; -print header("Apply Payment", ''); -print qq!Error: !, $cgi->param('error'), - "

" - if $cgi->param('error'); -print < -END +my $p1 = popurl(1); -die unless $cust_pay = qsearchs('cust_pay', { 'paynum' => $paynum } ); +my $cust_pay = qsearchs('cust_pay', { 'paynum' => $paynum } ); +die "payment $paynum not found!" unless $cust_pay; my $unapplied = $cust_pay->unapplied; -print "Payment # $paynum". - qq!!. - '
Date: '. time2str("%D", $cust_pay->_date). ''. - '
Amount: $'. $cust_pay->paid. ''. - "
Unapplied amount: \$$unapplied". - ; - -my @cust_bill = grep $_->owed != 0, +my @cust_bill = sort { $a->_date <=> $b->_date + or $a->invnum <=> $b->invnum + } + grep { $_->owed != 0 } qsearch('cust_bill', { 'custnum' => $cust_pay->custnum } ); + -print < -function changed(what) { - cust_bill = what.options[what.selectedIndex].value; -END - -foreach my $cust_bill ( @cust_bill ) { - my $invnum = $cust_bill->invnum; - my $changeto = $cust_bill->owed < $unapplied - ? $cust_bill->owed - : $unapplied - print < -#END -print "\n"; - -print qq!
Invoice #"; - -print qq!
Amount \$!; - -print < - -END - -print < - - -END - -%>