1 <% header("Apply Credit", '') %>
3 % if ( $cgi->param('error') ) {
4 <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT>
8 <FORM ACTION="<% $p1 %>process/cust_credit_bill.cgi" METHOD=POST>
10 Credit #<B><% $crednum %></B>
11 <INPUT TYPE="hidden" NAME="crednum" VALUE="<% $crednum %>">
13 <BR>Date: <B><% time2str("%D", $cust_credit->_date) %></B>
15 <BR>Amount: $<B><% $cust_credit->amount %></B>
17 <BR>Unapplied amount: $<B><% $credited %></B>
19 <BR>Reason: <B><% $cust_credit->reason %></B>
22 function changed(what) {
23 cust_bill = what.options[what.selectedIndex].value;
25 % foreach my $cust_bill ( @cust_bill ) {
27 if ( cust_bill == <% $cust_bill->invnum %> ) {
28 what.form.amount.value = "<% min($cust_bill->owed, $credited) %>";
33 if ( cust_bill == "Refund" ) {
34 what.form.amount.value = "<% $credited %>";
39 <BR>Invoice #<SELECT NAME="invnum" SIZE=1 onChange="changed(this)">
42 % foreach my $cust_bill ( @cust_bill ) {
43 <OPTION<% $cust_bill->invnum eq $invnum ? ' SELECTED' : '' %> VALUE="<% $cust_bill->invnum %>"><% $cust_bill->invnum %> - <% time2str("%D",$cust_bill->_date) %> - $<% $cust_bill->owed %>
46 <OPTION VALUE="Refund">Refund
49 <BR>Amount $<INPUT TYPE="text" NAME="amount" VALUE="<% $amount %>" SIZE=8 MAXLENGTH=8>
52 <CENTER><INPUT TYPE="submit" VALUE="Apply"></CENTER>
59 my($crednum, $amount, $invnum);
60 if ( $cgi->param('error') ) {
61 #$cust_credit_bill = new FS::cust_credit_bill ( {
62 # map { $_, scalar($cgi->param($_)) } fields('cust_credit_bill')
64 $crednum = $cgi->param('crednum');
65 $amount = $cgi->param('amount');
66 #$refund = $cgi->param('refund');
67 $invnum = $cgi->param('invnum');
69 my($query) = $cgi->keywords;
77 my $otaker = getotaker;
81 my $cust_credit = qsearchs('cust_credit', { 'crednum' => $crednum } );
82 die "credit $crednum not found!" unless $cust_credit;
84 my $credited = $cust_credit->credited;
86 my @cust_bill = sort { $a->_date <=> $b->_date
87 or $a->invnum <=> $b->invnum
89 grep { $_->owed != 0 }
90 qsearch('cust_bill', { 'custnum' => $cust_credit->custnum } );