auto-apply payments and credits, post credit UI overhaul
[freeside.git] / httemplate / edit / cust_pay.cgi
index dfef3c5..7f70802 100755 (executable)
@@ -1,5 +1,5 @@
 <%
-#<!-- $Id: cust_pay.cgi,v 1.7 2001-12-26 02:33:30 ivan Exp $ -->
+#<!-- $Id: cust_pay.cgi,v 1.8 2001-12-26 04:25:04 ivan Exp $ -->
 
 use strict;
 use vars qw( $cgi $link $linknum $p1 $_date $payby $payinfo $paid );
@@ -8,12 +8,10 @@ use CGI;
 use CGI::Carp qw(fatalsToBrowser);
 use FS::Conf;
 use FS::UID qw(cgisuidsetup);
-use FS::CGI qw(header popurl ntable);
+use FS::CGI qw(header popurl ntable small_custview);
 
 my $conf = new FS::Conf;
 
-my $countrydefault = $conf->config('countrydefault') || 'US';
-
 $cgi = new CGI;
 cgisuidsetup($cgi);
 
@@ -43,10 +41,10 @@ if ( $cgi->param('error') ) {
 $_date = time;
 
 $p1 = popurl(1);
-print header("Enter payment", '');
+print header("Post payment", '');
 
 print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'),
-      "</FONT>"
+      "</FONT><BR><BR>"
   if $cgi->param('error');
 
 print <<END, ntable("#cccccc",2);
@@ -102,62 +100,24 @@ if ( $link eq 'invnum' ) {
   $custnum = $linknum;
 }
 
-print "<BR><BR>Customer #<B>$custnum</B>". ntable('#e8e8e8');
-my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
-  or die "unknown custnum $custnum";
-
-print '<TR><TD>'. ntable("#cccccc",2).
-      '<TR><TD ALIGN="right" VALIGN="top">Billing</TD><TD BGCOLOR="#ffffff">'.
-      $cust_main->getfield('last'). ', '. $cust_main->first. '<BR>';
-print $cust_main->company. '<BR>' if $cust_main->company;
-print $cust_main->address1. '<BR>';
-print $cust_main->address2. '<BR>' if $cust_main->address2;
-print $cust_main->city. ', '. $cust_main->state. '  '. $cust_main->zip. '<BR>';
-print $cust_main->country. '<BR>' if $cust_main->country
-                                     && $cust_main->country ne $countrydefault;
-
-print '</TD>'.
-      '</TR></TABLE></TD>';
-
-if ( defined $cust_main->dbdef_table->column('ship_last') ) {
-
-  my $pre = $cust_main->ship_last ? 'ship_' : '';
-
-  print '<TD>'. ntable("#cccccc",2).
-        '<TR><TD ALIGN="right" VALIGN="top">Service</TD><TD BGCOLOR="#ffffff">'.
-        $cust_main->get("${pre}last"). ', '.
-        $cust_main->get("${pre}first"). '<BR>';
-  print $cust_main->get("${pre}company"). '<BR>'
-    if $cust_main->get("${pre}company");
-  print $cust_main->get("${pre}address1"). '<BR>';
-  print $cust_main->get("${pre}address2"). '<BR>'
-    if $cust_main->get("${pre}address2");
-  print $cust_main->get("${pre}city"). ', '.
-        $cust_main->get("${pre}state"). '  '.
-        $cust_main->get("${pre}ship_zip"). '<BR>';
-  print $cust_main->get("${pre}country"). '<BR>'
-    if $cust_main->get("${pre}country")
-       && $cust_main->get("${pre}country") ne $countrydefault;
-
-  print '</TD>'.
-        '</TR></TABLE></TD>';
-}
-
-print '</TR></TABLE>';
+print small_custview($custnum, $conf->config('countrydefault'));
 
+print qq!<INPUT TYPE="hidden" NAME="_date" VALUE="$_date">!;
+print qq!<INPUT TYPE="hidden" NAME="payby" VALUE="$payby">!;
 
 print '<BR><BR>Payment'. ntable("#cccccc", 2).
       '<TR><TD ALIGN="right">Date</TD><TD BGCOLOR="#ffffff">'.
-      time2str("%D",$_date).  '</TD></TR>'.
-      qq!<INPUT TYPE="hidden" NAME="_date" VALUE="$_date">!;
+      time2str("%D",$_date).  '</TD></TR>';
 
 print qq!<TR><TD ALIGN="right">Amount</TD><TD BGCOLOR="#ffffff">\$<INPUT TYPE="text" NAME="paid" VALUE="$paid" SIZE=8 MAXLENGTH=8></TD></TR>!;
 
-print qq!<TR><TD ALIGN="right">Payby</TD><TD BGCOLOR="#ffffff">$payby</TD></TR><INPUT TYPE="hidden" NAME="payby" VALUE="$payby">!;
+print qq!<TR><TD ALIGN="right">Payby</TD><TD BGCOLOR="#ffffff">$payby</TD></TR>!;
 
 #payinfo (check # now as payby="BILL" hardcoded.. what to do later?)
 print qq!<TR><TD ALIGN="right">Check #</TD><TD BGCOLOR="#ffffff"><INPUT TYPE="text" NAME="payinfo" VALUE="$payinfo"></TD></TR>!;
 
+print qq!<TR><TD ALIGN="right">Auto-apply<BR>to invoices</TD><TD><SELECT NAME="apply"><OPTION VALUE="yes" SELECTED>yes<OPTION>no</SELECT></TD>!;
+
 #paybatch
 print qq!<INPUT TYPE="hidden" NAME="paybatch" VALUE="">!;
 
@@ -165,10 +125,6 @@ print <<END;
 </TABLE>
 <BR>
 <INPUT TYPE="submit" VALUE="Post payment">
-END
-
-print <<END;
-
     </FORM>
   </BODY>
 </HTML>