X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fcust_credit_bill.cgi;h=a0073494945a5cf272fba278d0fa90935d02d043;hb=cf16b23820da69e3c8d0156ae27e21c635bf1ec5;hp=df495a66821c6ba1de094f8ca8b9c1630fa1fdb0;hpb=6412f71a3557249225abf5eb2096ebad1729c585;p=freeside.git diff --git a/httemplate/edit/cust_credit_bill.cgi b/httemplate/edit/cust_credit_bill.cgi index df495a668..a00734949 100755 --- a/httemplate/edit/cust_credit_bill.cgi +++ b/httemplate/edit/cust_credit_bill.cgi @@ -1,11 +1,11 @@ <% -# +# use strict; -use vars qw( $cgi $query $custnum $invnum $otaker $p1 $crednum $_date $amount $reason $cust_credit ); -use Date::Format; +use vars qw( $cgi $query $custnum $invnum $otaker $p1 $crednum $amount $reason $cust_credit ); 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); @@ -32,43 +32,76 @@ if ( $cgi->param('error') ) { #$refund = 'yes'; $invnum = ''; } -$_date = time; $otaker = getotaker; $p1 = popurl(1); -print $cgi->header( '-expires' => 'now' ), header("Apply Credit", ''); +print header("Apply Credit", ''); print qq!Error: !, $cgi->param('error'), - "" + "

" if $cgi->param('error'); print < -
 END
 
 die unless $cust_credit = qsearchs('cust_credit', { 'crednum' => $crednum } );
 
-print qq!Credit #!, $crednum, qq!!;
+my $credited = $cust_credit->credited;
+
+print "Credit # $crednum".
+      qq!!.
+      '
Date: '. time2str("%D", $cust_credit->_date). ''. + '
Amount: $'. $cust_credit->amount. ''. + "
Unapplied amount: \$$credited". + '
Reason: '. $cust_credit->reason. '' + ; + +my @cust_bill = grep $_->owed != 0, + qsearch('cust_bill', { 'custnum' => $cust_credit->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 < $cust_credit->credited + ? $cust_bill->owed + : $cust_credit->credited; + print < +END -print qq!\nInvoice # !, + '