X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fcust_credit_bill.cgi;h=a0073494945a5cf272fba278d0fa90935d02d043;hb=355fe2160a24311e5d1faab56376c9a0781c6479;hp=c4cd34eab89be8e7ec9499f3d78fe6b27145ac72;hpb=dbfb0ae501d5acba37f9348476d94b99a4c92450;p=freeside.git diff --git a/httemplate/edit/cust_credit_bill.cgi b/httemplate/edit/cust_credit_bill.cgi index c4cd34eab..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 # !, + '