[freeside-commits]
freeside/httemplate/edit cust_bill_pay.cgi, 1.11, 1.12
Ivan,,,
ivan at wavetail.420.am
Fri Aug 25 19:20:51 PDT 2006
Update of /home/cvs/cvsroot/freeside/httemplate/edit
In directory wavetail:/tmp/cvs-serv4711
Modified Files:
cust_bill_pay.cgi
Log Message:
fix javascript for auto-setting application amount
Index: cust_bill_pay.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/cust_bill_pay.cgi,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- cust_bill_pay.cgi 23 Aug 2006 22:25:37 -0000 1.11
+++ cust_bill_pay.cgi 26 Aug 2006 02:20:49 -0000 1.12
@@ -1,39 +1,11 @@
-%
-%
-%my($paynum, $amount, $invnum);
-%if ( $cgi->param('error') ) {
-% $paynum = $cgi->param('paynum');
-% $amount = $cgi->param('amount');
-% $invnum = $cgi->param('invnum');
-%} else {
-% my($query) = $cgi->keywords;
-% $query =~ /^(\d+)$/;
-% $paynum = $1;
-% $amount = '';
-% $invnum = '';
-%}
-%
-%my $otaker = getotaker;
-%
-%my $p1 = popurl(1);
-%
-%
<% header("Apply Payment", '') %>
-% if ( $cgi->param('error') ) {
+% if ( $cgi->param('error') ) {
<FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT>
<BR><BR>
% }
-
<FORM ACTION="<% $p1 %>process/cust_bill_pay.cgi" METHOD=POST>
-%
-%my $cust_pay = qsearchs('cust_pay', { 'paynum' => $paynum } );
-%die "payment $paynum not found!" unless $cust_pay;
-%
-%my $unapplied = $cust_pay->unapplied;
-%
-
Payment #<B><% $paynum %></B>
<INPUT TYPE="hidden" NAME="paynum" VALUE="<% $paynum %>">
@@ -43,28 +15,18 @@
<BR>Amount: $<B><% $cust_pay->paid %></B>
<BR>Unapplied amount: $<B><% $unapplied %></B>
-%
-%my @cust_bill = grep $_->owed != 0,
-% qsearch('cust_bill', { 'custnum' => $cust_pay->custnum } );
-%
-%
-
-<SCRIPT>
+<SCRIPT TYPE="text/javascript">
function changed(what) {
cust_bill = what.options[what.selectedIndex].value;
+
% foreach my $cust_bill ( @cust_bill ) {
-% my $invnum = $cust_bill->invnum;
-% my $changeto = $cust_bill->owed < $unapplied
-% ? $cust_bill->owed
-% : $unapplied;
-%
- if ( cust_bill == $invnum ) {
- what.form.amount.value = "<% $changeto %>";
- }
-% }
+ if ( cust_bill == <% $cust_bill->invnum %> ) {
+ what.form.amount.value = "<% min($cust_bill->owed, $unapplied) %>";
+ }
+% }
if ( cust_bill == "Refund" ) {
what.form.amount.value = "<% $unapplied %>";
@@ -74,13 +36,11 @@
<BR>Invoice #<SELECT NAME="invnum" SIZE=1 onChange="changed(this)">
<OPTION VALUE="">
-% foreach my $cust_bill ( @cust_bill ) {
-
+% foreach my $cust_bill ( @cust_bill ) {
<OPTION<% $cust_bill->invnum eq $invnum ? ' SELECTED' : '' %> VALUE="<% $cust_bill->invnum %>"><% $cust_bill->invnum %> - <% time2str("%D", $cust_bill->_date) %> - $<% $cust_bill->owed %>
% }
-
<OPTION VALUE="Refund">Refund
</SELECT>
@@ -90,6 +50,38 @@
<CENTER><INPUT TYPE="submit" VALUE="Apply"></CENTER>
</FORM>
-
</BODY>
</HTML>
+
+<%init>
+my($paynum, $amount, $invnum);
+if ( $cgi->param('error') ) {
+ $paynum = $cgi->param('paynum');
+ $amount = $cgi->param('amount');
+ $invnum = $cgi->param('invnum');
+} else {
+ my($query) = $cgi->keywords;
+ $query =~ /^(\d+)$/;
+ $paynum = $1;
+ $amount = '';
+ $invnum = '';
+}
+
+my $otaker = getotaker;
+
+my $p1 = popurl(1);
+
+my $cust_pay = qsearchs('cust_pay', { 'paynum' => $paynum } );
+die "payment $paynum not found!" unless $cust_pay;
+
+my $unapplied = $cust_pay->unapplied;
+
+my @cust_bill = sort { $a->_date <=> $b->_date
+ or $a->invnum <=> $b->invnum
+ }
+ grep { $_->owed != 0 }
+ qsearch('cust_bill', { 'custnum' => $cust_pay->custnum } );
+
+
+</%init>
+
More information about the freeside-commits
mailing list