diff options
author | ivan <ivan> | 2001-09-03 22:07:39 +0000 |
---|---|---|
committer | ivan <ivan> | 2001-09-03 22:07:39 +0000 |
commit | fbcb45dfe5a1bce7981fe4527176b9fdf2ec54b7 (patch) | |
tree | f23551e188aaf6965bb61c13ccae3a48764aab02 /httemplate/edit/cust_credit_bill.cgi | |
parent | 33204e66fb11e9e551b95e8656d088506745e361 (diff) |
fix more bugs
Diffstat (limited to 'httemplate/edit/cust_credit_bill.cgi')
-rwxr-xr-x | httemplate/edit/cust_credit_bill.cgi | 66 |
1 files changed, 50 insertions, 16 deletions
diff --git a/httemplate/edit/cust_credit_bill.cgi b/httemplate/edit/cust_credit_bill.cgi index c4cd34eab..13bad1852 100755 --- a/httemplate/edit/cust_credit_bill.cgi +++ b/httemplate/edit/cust_credit_bill.cgi @@ -1,11 +1,12 @@ <% -#<!-- $Id: cust_credit_bill.cgi,v 1.2 2001-09-02 07:49:52 ivan Exp $ --> +#<!-- $Id: cust_credit_bill.cgi,v 1.3 2001-09-03 22:07:39 ivan Exp $ --> use strict; -use vars qw( $cgi $query $custnum $invnum $otaker $p1 $crednum $_date $amount $reason $cust_credit ); +use vars qw( $cgi $query $custnum $invnum $otaker $p1 $crednum $amount $reason $cust_credit ); use Date::Format; 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,7 +33,6 @@ if ( $cgi->param('error') ) { #$refund = 'yes'; $invnum = ''; } -$_date = time; $otaker = getotaker; @@ -44,31 +44,65 @@ print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'), if $cgi->param('error'); print <<END; <FORM ACTION="${p1}process/cust_credit_bill.cgi" METHOD=POST> - <PRE> END die unless $cust_credit = qsearchs('cust_credit', { 'crednum' => $crednum } ); -print qq!Credit #<B>!, $crednum, qq!</B><INPUT TYPE="hidden" NAME="crednum" VALUE="$crednum">!; +my $credited = $cust_credit->credited; + +print "Credit # <B>$crednum</B>". + qq!<INPUT TYPE="hidden" NAME="crednum" VALUE="$crednum">!. + '<BR>Date: <B>'. time2str("%D", $cust_credit->_date). '</B>'. + '<BR>Amount: $<B>'. $cust_credit->amount. '</B>'. + "<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 } ); + +print <<END; +<SCRIPT> +function changed(what) { + cust_bill = what.options[what.selectedIndex].value; +END -print qq!\nInvoice # <SELECT NAME="invnum" SIZE=1>!; -foreach $_ (grep $_->owed != 0, qsearch('cust_bill', { 'custnum' => $cust_credit->custnum } ) ) { - print "<OPTION", (($_->invnum eq $invnum) ? " SELECTED" : ""), - qq! VALUE="! .$_->invnum. qq!">!. $_->invnum. qq! (! . $_->owed . qq!)!; +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; + if ( cust_bill == $invnum ) { + what.form.amount.value = "$changeto"; + } +END } -print qq!<OPTION VALUE="Refund">Refund!; -print "</SELECT>"; -print qq!\nDate: <B>!, time2str("%D",$_date), qq!</B><INPUT TYPE="hidden" NAME="_date" VALUE="">!; +print <<END; + if ( cust_bill == "Refund" ) { + what.form.amount.value = "$credited"; + } +} +</SCRIPT> +END -print qq!\nAmount \$<INPUT TYPE="text" NAME="amount" VALUE="$amount" SIZE=8 MAXLENGTH=8>!; +print qq!<BR>Invoice #<SELECT NAME="invnum" SIZE=1 onChange="changed(this)">!, + '<OPTION VALUE="">'; +foreach my $cust_bill ( @cust_bill ) { + print '<OPTION'. ( $cust_bill->invnum eq $invnum ? ' SELECTED' : '' ). + ' VALUE="'. $cust_bill->invnum. '">'. $cust_bill->invnum. + ' - '. time2str("%D",$cust_bill->_date). + ' - $'. $cust_bill->owed; +} +print qq!<OPTION VALUE="Refund">Refund!; +print "</SELECT>"; -#print qq! <INPUT TYPE="checkbox" NAME="refund" VALUE="$refund">Also post refund!; +print qq!<BR>Amount \$<INPUT TYPE="text" NAME="amount" VALUE="$amount" SIZE=8 MAXLENGTH=8>!; print <<END; -</PRE> <BR> -<CENTER><INPUT TYPE="submit" VALUE="Post"></CENTER> +<INPUT TYPE="submit" VALUE="Apply"> END print <<END; |