[freeside-commits] freeside/httemplate/edit cust_credit_bill.cgi,
1.11, 1.12 cust_bill_pay.cgi, 1.12, 1.13
Ivan,,,
ivan at wavetail.420.am
Sat Aug 26 05:57:44 PDT 2006
Update of /home/cvs/cvsroot/freeside/httemplate/edit
In directory wavetail:/tmp/cvs-serv4961
Modified Files:
cust_credit_bill.cgi 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.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- cust_bill_pay.cgi 26 Aug 2006 02:20:49 -0000 1.12
+++ cust_bill_pay.cgi 26 Aug 2006 12:57:42 -0000 1.13
@@ -81,7 +81,5 @@
}
grep { $_->owed != 0 }
qsearch('cust_bill', { 'custnum' => $cust_pay->custnum } );
-
-
</%init>
Index: cust_credit_bill.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/cust_credit_bill.cgi,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- cust_credit_bill.cgi 23 Aug 2006 22:25:37 -0000 1.11
+++ cust_credit_bill.cgi 26 Aug 2006 12:57:42 -0000 1.12
@@ -1,44 +1,11 @@
-%
-%
-%my($crednum, $amount, $invnum);
-%if ( $cgi->param('error') ) {
-% #$cust_credit_bill = new FS::cust_credit_bill ( {
-% # map { $_, scalar($cgi->param($_)) } fields('cust_credit_bill')
-% #} );
-% $crednum = $cgi->param('crednum');
-% $amount = $cgi->param('amount');
-% #$refund = $cgi->param('refund');
-% $invnum = $cgi->param('invnum');
-%} else {
-% my($query) = $cgi->keywords;
-% $query =~ /^(\d+)$/;
-% $crednum = $1;
-% $amount = '';
-% #$refund = 'yes';
-% $invnum = '';
-%}
-%
-%my $otaker = getotaker;
-%
-%my $p1 = popurl(1);
-%
-%
<% header("Apply Credit", '') %>
-% 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_credit_bill.cgi" METHOD=POST>
-%
-%my $cust_credit = qsearchs('cust_credit', { 'crednum' => $crednum } );
-%die "credit $crednum not found!" unless $cust_credit;
-%
-%my $credited = $cust_credit->credited;
-%
-
Credit #<B><% $crednum %></B>
<INPUT TYPE="hidden" NAME="crednum" VALUE="<% $crednum %>">
@@ -50,28 +17,18 @@
<BR>Unapplied amount: $<B><% $credited %></B>
<BR>Reason: <B><% $cust_credit->reason %></B>
-%
-%my @cust_bill = grep $_->owed != 0,
-% qsearch('cust_bill', { 'custnum' => $cust_credit->custnum } );
-%
-%
-
<SCRIPT>
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 < $cust_credit->credited
-% ? $cust_bill->owed
-% : $cust_credit->credited;
-%
- if ( cust_bill == $invnum ) {
- what.form.amount.value = "<% $changeto %>";
+ if ( cust_bill == <% $cust_bill->invnum %> ) {
+ what.form.amount.value = "<% min($cust_bill->owed, $credited) %>";
}
-% }
+% }
if ( cust_bill == "Refund" ) {
what.form.amount.value = "<% $credited %>";
@@ -81,13 +38,11 @@
<BR>Invoice #<SELECT NAME="invnum" SIZE=1 onChange="changed(this)">
<OPTION VALUE="">
-% 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 %>
+% 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>
@@ -97,6 +52,41 @@
<CENTER><INPUT TYPE="submit" VALUE="Apply"></CENTER>
</FORM>
-
</BODY>
</HTML>
+
+<%init>
+my($crednum, $amount, $invnum);
+if ( $cgi->param('error') ) {
+ #$cust_credit_bill = new FS::cust_credit_bill ( {
+ # map { $_, scalar($cgi->param($_)) } fields('cust_credit_bill')
+ #} );
+ $crednum = $cgi->param('crednum');
+ $amount = $cgi->param('amount');
+ #$refund = $cgi->param('refund');
+ $invnum = $cgi->param('invnum');
+} else {
+ my($query) = $cgi->keywords;
+ $query =~ /^(\d+)$/;
+ $crednum = $1;
+ $amount = '';
+ #$refund = 'yes';
+ $invnum = '';
+}
+
+my $otaker = getotaker;
+
+my $p1 = popurl(1);
+
+my $cust_credit = qsearchs('cust_credit', { 'crednum' => $crednum } );
+die "credit $crednum not found!" unless $cust_credit;
+
+my $credited = $cust_credit->credited;
+
+my @cust_bill = sort { $a->_date <=> $b->_date
+ or $a->invnum <=> $b->invnum
+ }
+ grep { $_->owed != 0 }
+ qsearch('cust_bill', { 'custnum' => $cust_credit->custnum } );
+</%init>
+
More information about the freeside-commits
mailing list