3 %my($crednum, $amount, $invnum);
4 %if ( $cgi->param('error') ) {
5 % #$cust_credit_bill = new FS::cust_credit_bill ( {
6 % # map { $_, scalar($cgi->param($_)) } fields('cust_credit_bill')
8 % $crednum = $cgi->param('crednum');
9 % $amount = $cgi->param('amount');
10 % #$refund = $cgi->param('refund');
11 % $invnum = $cgi->param('invnum');
13 % my($query) = $cgi->keywords;
14 % $query =~ /^(\d+)$/;
21 %my $otaker = getotaker;
26 <% header("Apply Credit", '') %>
27 % if ( $cgi->param('error') ) {
29 <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT>
34 <FORM ACTION="<% $p1 %>process/cust_credit_bill.cgi" METHOD=POST>
36 %my $cust_credit = qsearchs('cust_credit', { 'crednum' => $crednum } );
37 %die "credit $crednum not found!" unless $cust_credit;
39 %my $credited = $cust_credit->credited;
43 Credit #<B><% $crednum %></B>
44 <INPUT TYPE="hidden" NAME="crednum" VALUE="<% $crednum %>">
46 <BR>Date: <B><% time2str("%D", $cust_credit->_date) %></B>
48 <BR>Amount: $<B><% $cust_credit->amount %></B>
50 <BR>Unapplied amount: $<B><% $credited %></B>
52 <BR>Reason: <B><% $cust_credit->reason %></B>
54 %my @cust_bill = grep $_->owed != 0,
55 % qsearch('cust_bill', { 'custnum' => $cust_credit->custnum } );
61 function changed(what) {
62 cust_bill = what.options[what.selectedIndex].value;
63 % foreach my $cust_bill ( @cust_bill ) {
64 % my $invnum = $cust_bill->invnum;
65 % my $changeto = $cust_bill->owed < $cust_credit->credited
67 % : $cust_credit->credited;
70 if ( cust_bill == $invnum ) {
71 what.form.amount.value = "<% $changeto %>";
76 if ( cust_bill == "Refund" ) {
77 what.form.amount.value = "<% $credited %>";
82 <BR>Invoice #<SELECT NAME="invnum" SIZE=1 onChange="changed(this)">
84 % foreach my $cust_bill ( @cust_bill ) {
87 <OPTION<% $cust_bill->invnum eq $invnum ? ' SELECTED' : '' %> VALUE="<% $cust_bill->invnum %>"><% $cust_bill->invnum %> - <% time2str("%D",$cust_bill->_date) %> - $<% $cust_bill->owed %>
91 <OPTION VALUE="Refund">Refund
94 <BR>Amount $<INPUT TYPE="text" NAME="amount" VALUE="<% $amount %>" SIZE=8 MAXLENGTH=8>
97 <CENTER><INPUT TYPE="submit" VALUE="Apply"></CENTER>