summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2001-12-26 04:25:04 +0000
committerivan <ivan>2001-12-26 04:25:04 +0000
commitd0f483f47168e01eb6c28e8fc99a62050b245132 (patch)
treec2b554e22ebdab4b8821b5c8600601166393a02e
parentc6b853b4f0516450b3e27acd281f667eadaec9f4 (diff)
auto-apply payments and credits, post credit UI overhaul
-rw-r--r--FS/FS/CGI.pm64
-rwxr-xr-xhttemplate/edit/cust_credit.cgi40
-rwxr-xr-xhttemplate/edit/cust_pay.cgi66
-rwxr-xr-xhttemplate/edit/process/cust_credit.cgi7
-rwxr-xr-xhttemplate/edit/process/cust_pay.cgi7
5 files changed, 105 insertions, 79 deletions
diff --git a/FS/FS/CGI.pm b/FS/FS/CGI.pm
index f0fec434d..c66bfe3c2 100644
--- a/FS/FS/CGI.pm
+++ b/FS/FS/CGI.pm
@@ -9,7 +9,8 @@ use CGI::Carp qw(fatalsToBrowser);
use FS::UID;
@ISA = qw(Exporter);
-@EXPORT_OK = qw(header menubar idiot eidiot popurl table itable ntable);
+@EXPORT_OK = qw(header menubar idiot eidiot popurl table itable ntable
+ small_custview);
@header = ( '-Expires' => '-1',
'-Pragma' => 'no-cache',
@@ -206,6 +207,65 @@ sub ntable {
}
+=item small_custview CUSTNUM || CUST_MAIN_OBJECT, COUNTRYDEFAULT
+
+Sheesh. I should just switch to Mason.
+
+=cut
+
+sub small_custview {
+ use FS::Record qw(qsearchs);
+ use FS::cust_main;
+
+ my $arg = shift;
+ my $countrydefault = shift || 'US';
+
+ my $cust_main = ref($arg) ? $arg
+ : qsearchs('cust_main', { 'custnum' => $arg } )
+ or die "unknown custnum $arg";
+
+ my $html = 'Customer #<B>'. $cust_main->custnum. '</B>'.
+ ntable('#e8e8e8'). '<TR><TD>'. ntable("#cccccc",2).
+ '<TR><TD ALIGN="right" VALIGN="top">Billing</TD><TD BGCOLOR="#ffffff">'.
+ $cust_main->getfield('last'). ', '. $cust_main->first. '<BR>';
+
+ $html .= $cust_main->company. '<BR>' if $cust_main->company;
+ $html .= $cust_main->address1. '<BR>';
+ $html .= $cust_main->address2. '<BR>' if $cust_main->address2;
+ $html .= $cust_main->city. ', '. $cust_main->state. ' '. $cust_main->zip. '<BR>';
+ $html .= $cust_main->country. '<BR>'
+ if $cust_main->country && $cust_main->country ne $countrydefault;
+
+ $html .= '</TD></TR></TABLE></TD>';
+
+ if ( defined $cust_main->dbdef_table->column('ship_last') ) {
+
+ my $pre = $cust_main->ship_last ? 'ship_' : '';
+
+ $html .= '<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>';
+ $html .= $cust_main->get("${pre}company"). '<BR>'
+ if $cust_main->get("${pre}company");
+ $html .= $cust_main->get("${pre}address1"). '<BR>';
+ $html .= $cust_main->get("${pre}address2"). '<BR>'
+ if $cust_main->get("${pre}address2");
+ $html .= $cust_main->get("${pre}city"). ', '.
+ $cust_main->get("${pre}state"). ' '.
+ $cust_main->get("${pre}ship_zip"). '<BR>';
+ $html .= $cust_main->get("${pre}country"). '<BR>'
+ if $cust_main->get("${pre}country")
+ && $cust_main->get("${pre}country") ne $countrydefault;
+
+ $html .= '</TD></TR></TABLE></TD>';
+ }
+
+ $html .= '</TR></TABLE>';
+
+ $html;
+}
+
=back
=head1 BUGS
@@ -214,6 +274,8 @@ Not OO.
Not complete.
+small_custview sooooo doesn't belong here. i should just switch to Mason.
+
=head1 SEE ALSO
L<CGI>, L<CGI::Base>
diff --git a/httemplate/edit/cust_credit.cgi b/httemplate/edit/cust_credit.cgi
index 5d5f5b296..63732f86c 100755
--- a/httemplate/edit/cust_credit.cgi
+++ b/httemplate/edit/cust_credit.cgi
@@ -1,16 +1,18 @@
<%
-#<!-- $Id: cust_credit.cgi,v 1.5 2001-10-30 14:54:07 ivan Exp $ -->
+#<!-- $Id: cust_credit.cgi,v 1.6 2001-12-26 04:25:04 ivan Exp $ -->
use strict;
-use vars qw( $cgi $query $custnum $otaker $p1 $crednum $_date $amount $reason );
+use vars qw( $cgi $query $custnum $otaker $p1 $_date $amount $reason );
use Date::Format;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use FS::UID qw(cgisuidsetup getotaker);
-use FS::CGI qw(header popurl);
+use FS::CGI qw(header popurl small_custview);
use FS::Record qw(fields);
#use FS::cust_credit;
+my $conf = new FS::Conf;
+
$cgi = new CGI;
cgisuidsetup($cgi);
@@ -40,35 +42,31 @@ print header("Post Credit", '');
print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'),
"</FONT>"
if $cgi->param('error');
-print <<END;
+print <<END, small_custview($custnum, $conf->config('countrydefault'));
<FORM ACTION="${p1}process/cust_credit.cgi" METHOD=POST>
+ <INPUT TYPE="hidden" NAME="crednum" VALUE="">
+ <INPUT TYPE="hidden" NAME="paybatch" VALUE="">
+ <INPUT TYPE="hidden" NAME="_date" VALUE="$_date">
+ <INPUT TYPE="hidden" NAME="credited" VALUE="">
+ <INPUT TYPE="hidden" NAME="otaker" VALUE="$otaker">
END
-$crednum = "";
-print qq!Credit #<B>!, $crednum ? $crednum : " <I>(NEW)</I>", qq!</B><INPUT TYPE="hidden" NAME="crednum" VALUE="$crednum">!;
-
-print qq!<BR>Customer #<B>$custnum</B><INPUT TYPE="hidden" NAME="custnum" VALUE="$custnum">!;
-
-print qq!<INPUT TYPE="hidden" NAME="paybatch" VALUE="">!;
-
-print qq!<BR>Date: <B>!, time2str("%D",$_date), qq!</B><INPUT TYPE="hidden" NAME="_date" VALUE="">!;
+print '<BR><BR>Credit'. ntable("#cccccc", 2).
+ '<TR><TD ALIGN="right">Date</TD><TD BGCOLOR="#ffffff">'.
+ time2str("%D",$_date). '</TD></TR>';
-print qq!<BR>Amount \$<INPUT TYPE="text" NAME="amount" VALUE="$amount" SIZE=8 MAXLENGTH=8>!;
-print qq!<INPUT TYPE="hidden" NAME="credited" VALUE="">!;
+print qq!<TR><TD ALIGN="right">Amount</TD><TD BGCOLOR="#ffffff">\$<INPUT TYPE="text" NAME="amount" VALUE="$amount" SIZE=8 MAXLENGTH=8></TD></TR>!;
#print qq! <INPUT TYPE="checkbox" NAME="refund" VALUE="$refund">Also post refund!;
-print qq!<INPUT TYPE="hidden" NAME="otaker" VALUE="$otaker">!;
+print qq!<TR><TD ALIGN="right">Reason</TD><TD BGCOLOR="#ffffff"><INPUT TYPE="text" NAME="reason" VALUE="$reason"></TD></TR>!;
-print qq!<BR>Reason <INPUT TYPE="text" NAME="reason" VALUE="$reason">!;
+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>!;
print <<END;
+</TABLE>
<BR>
-<INPUT TYPE="submit" VALUE="Post">
-END
-
-print <<END;
-
+<INPUT TYPE="submit" VALUE="Post credit">
</FORM>
</BODY>
</HTML>
diff --git a/httemplate/edit/cust_pay.cgi b/httemplate/edit/cust_pay.cgi
index dfef3c542..7f70802c3 100755
--- a/httemplate/edit/cust_pay.cgi
+++ b/httemplate/edit/cust_pay.cgi
@@ -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>
diff --git a/httemplate/edit/process/cust_credit.cgi b/httemplate/edit/process/cust_credit.cgi
index b52d0bd46..2eb431bcc 100755
--- a/httemplate/edit/process/cust_credit.cgi
+++ b/httemplate/edit/process/cust_credit.cgi
@@ -1,5 +1,5 @@
<%
-#<!-- $Id: cust_credit.cgi,v 1.2 2001-08-21 02:31:56 ivan Exp $ -->
+#<!-- $Id: cust_credit.cgi,v 1.3 2001-12-26 04:25:04 ivan Exp $ -->
use strict;
use vars qw( $cgi $custnum $new $error );
@@ -31,6 +31,11 @@ if ( $error ) {
$cgi->param('error', $error);
print $cgi->redirect(popurl(2). "cust_credit.cgi?". $cgi->query_string );
} else {
+ if ( $cgi->param('apply') eq 'yes' ) {
+ my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum })
+ or die "unknown custnum $linknum";
+ $cust_main->apply_payments;
+ }
print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum");
}
diff --git a/httemplate/edit/process/cust_pay.cgi b/httemplate/edit/process/cust_pay.cgi
index 9be96505d..b2b3602db 100755
--- a/httemplate/edit/process/cust_pay.cgi
+++ b/httemplate/edit/process/cust_pay.cgi
@@ -1,5 +1,5 @@
<%
-#<!-- $Id: cust_pay.cgi,v 1.3 2001-09-03 22:07:39 ivan Exp $ -->
+#<!-- $Id: cust_pay.cgi,v 1.4 2001-12-26 04:25:04 ivan Exp $ -->
use strict;
use vars qw( $cgi $link $linknum $new $error );
@@ -38,6 +38,11 @@ if ($error) {
} elsif ( $link eq 'invnum' ) {
print $cgi->redirect(popurl(3). "view/cust_bill.cgi?$linknum");
} elsif ( $link eq 'custnum' ) {
+ if ( $cgi->param('apply') eq 'yes' ) {
+ my $cust_main = qsearchs('cust_main', { 'custnum' => $linknum })
+ or die "unknown custnum $linknum";
+ $cust_main->apply_payments;
+ }
print $cgi->redirect(popurl(3). "view/cust_main.cgi?$linknum");
}