diff options
-rwxr-xr-x | httemplate/edit/cust_bill_pay.cgi | 109 | ||||
-rwxr-xr-x | httemplate/edit/cust_credit_bill.cgi | 3 | ||||
-rwxr-xr-x | httemplate/edit/process/cust_bill_pay.cgi | 46 | ||||
-rwxr-xr-x | httemplate/edit/process/cust_credit_bill.cgi | 6 |
4 files changed, 160 insertions, 4 deletions
diff --git a/httemplate/edit/cust_bill_pay.cgi b/httemplate/edit/cust_bill_pay.cgi new file mode 100755 index 000000000..a4ed94462 --- /dev/null +++ b/httemplate/edit/cust_bill_pay.cgi @@ -0,0 +1,109 @@ +<% +#<!-- $Id: cust_bill_pay.cgi,v 1.1 2001-12-18 19:30:31 ivan Exp $ --> + +use strict; +use vars qw( $cgi $query $custnum $paynum $amount $invnum $p1 $otaker ); # $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); +use FS::cust_pay; +use FS::cust_bill; + + +$cgi = new CGI; +cgisuidsetup($cgi); + +if ( $cgi->param('error') ) { + $paynum = $cgi->param('paynum'); + $amount = $cgi->param('amount'); + $invnum = $cgi->param('invnum'); +} else { + ($query) = $cgi->keywords; + $query =~ /^(\d+)$/; + $paynum = $1; + $amount = ''; + $invnum = ''; +} + +$otaker = getotaker; + +$p1 = popurl(1); + +print header("Apply Payment", ''); +print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'), + "</FONT><BR><BR>" + if $cgi->param('error'); +print <<END; + <FORM ACTION="${p1}process/cust_bill_pay.cgi" METHOD=POST> +END + +die unless $cust_pay = qsearchs('cust_pay', { 'paynum' => $paynum } ); + +my $unapplied = $cust_pay->unapplied; + +print "Payment # <B>$paynum</B>". + qq!<INPUT TYPE="hidden" NAME="paynum" VALUE="$paynum">!. + '<BR>Date: <B>'. time2str("%D", $cust_pay->_date). '</B>'. + '<BR>Amount: $<B>'. $cust_pay->paid. '</B>'. + "<BR>Unapplied amount: \$<B>$unapplied</B>". + ; + +my @cust_bill = grep $_->owed != 0, + qsearch('cust_bill', { 'custnum' => $cust_pay->custnum } ); + +print <<END; +<SCRIPT> +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 < $unapplied + ? $cust_bill->owed + : $unapplied + print <<END; + if ( cust_bill == $invnum ) { + what.form.amount.value = "$changeto"; + } +END +} + +#print <<END; +# if ( cust_bill == "Refund" ) { +# what.form.amount.value = "$credited"; +# } +#} +#</SCRIPT> +#END +print "</SCRIPT>\n"; + +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!<BR>Amount \$<INPUT TYPE="text" NAME="amount" VALUE="$amount" SIZE=8 MAXLENGTH=8>!; + +print <<END; +<BR> +<INPUT TYPE="submit" VALUE="Apply"> +END + +print <<END; + + </FORM> + </BODY> +</HTML> +END + +%> diff --git a/httemplate/edit/cust_credit_bill.cgi b/httemplate/edit/cust_credit_bill.cgi index 2b41cc216..a00734949 100755 --- a/httemplate/edit/cust_credit_bill.cgi +++ b/httemplate/edit/cust_credit_bill.cgi @@ -1,9 +1,8 @@ <% -#<!-- $Id: cust_credit_bill.cgi,v 1.5 2001-10-30 14:54:07 ivan Exp $ --> +#<!-- $Id: cust_credit_bill.cgi,v 1.6 2001-12-18 19:30:31 ivan Exp $ --> use strict; 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; diff --git a/httemplate/edit/process/cust_bill_pay.cgi b/httemplate/edit/process/cust_bill_pay.cgi new file mode 100755 index 000000000..f0d403331 --- /dev/null +++ b/httemplate/edit/process/cust_bill_pay.cgi @@ -0,0 +1,46 @@ +<% +#<!-- $Id: cust_bill_pay.cgi,v 1.1 2001-12-18 19:30:31 ivan Exp $ --> + +use strict; +use vars qw( $cgi $custnum $paynum $new $error ); +use CGI; +use CGI::Carp qw(fatalsToBrowser); +use FS::UID qw(cgisuidsetup getotaker); +use FS::CGI qw(popurl); +use FS::Record qw(qsearchs fields); +use FS::cust_pay; +use FS::cust_bill_pay; +use FS::cust_main; + +$cgi = new CGI; +cgisuidsetup($cgi); + +$cgi->param('paynum') =~ /^(\d*)$/ or die "Illegal paynum!"; +$paynum = $1; + +my $cust_pay = qsearchs('cust_pay', { 'paynum' => $paynum } ) + or die "No such paynum"; + +my $cust_main = qsearchs('cust_main', { 'custnum' => $cust_pay->custnum } ) + or die "Bogus credit: not attached to customer"; + +my $custnum = $cust_main->custnum; + +$new = new FS::cust_bill_pay ( { + map { + $_, scalar($cgi->param($_)); + #} qw(custnum _date amount invnum) + } fields('cust_bill_pay') +} ); + +$error=$new->insert; + +if ( $error ) { + $cgi->param('error', $error); + print $cgi->redirect(popurl(2). "cust_bill_pay.cgi?". $cgi->query_string ); +} else { + print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum"); +} + + +%> diff --git a/httemplate/edit/process/cust_credit_bill.cgi b/httemplate/edit/process/cust_credit_bill.cgi index f838dff10..e84894b04 100755 --- a/httemplate/edit/process/cust_credit_bill.cgi +++ b/httemplate/edit/process/cust_credit_bill.cgi @@ -1,5 +1,5 @@ <% -#<!-- $Id: cust_credit_bill.cgi,v 1.1 2001-09-01 21:52:20 jeff Exp $ --> +#<!-- $Id: cust_credit_bill.cgi,v 1.2 2001-12-18 19:30:31 ivan Exp $ --> use strict; use vars qw( $cgi $custnum $crednum $new $error ); @@ -10,6 +10,8 @@ use FS::CGI qw(popurl); use FS::Record qw(qsearchs fields); use FS::cust_credit; use FS::cust_credit_bill; +use FS::cust_refund; +use FS::cust_main; $cgi = new CGI; cgisuidsetup($cgi); @@ -34,7 +36,7 @@ if ($cgi->param('invnum') =~ /^Refund$/) { 'payinfo' => 'Cash', 'crednum' => $crednum, } ); -}else{ +} else { $new = new FS::cust_credit_bill ( { map { $_, scalar($cgi->param($_)); |