summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--httemplate/index.html1
-rwxr-xr-xhttemplate/search/cust_pay.cgi112
-rwxr-xr-xhttemplate/search/cust_pay.html18
-rwxr-xr-xhttemplate/view/cust_main.cgi32
4 files changed, 156 insertions, 7 deletions
diff --git a/httemplate/index.html b/httemplate/index.html
index dcf513703..d1abd0d61 100644
--- a/httemplate/index.html
+++ b/httemplate/index.html
@@ -28,6 +28,7 @@
<!-- <LI><A HREF="search/svc_acct_sm.html">mail aliases (by domain, and optionally username)</A>-->
<!-- <LI><A HREF="search/svc_forward.html">mail forwards (by ?)</A>-->
<LI><A HREF="search/cust_bill.html">invoices (by invoice number)</A>
+ <LI><A HREF="search/cust_pay.html">checks (by check number)</A>
</ul>
<li><A NAME="browse">Browse</A>
<ul>
diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi
new file mode 100755
index 000000000..68a17e7dc
--- /dev/null
+++ b/httemplate/search/cust_pay.cgi
@@ -0,0 +1,112 @@
+<%
+#<!-- $Id: cust_pay.cgi,v 1.1 2001-12-26 09:18:18 ivan Exp $ -->
+
+use strict;
+use vars qw( $cgi $sortby @cust_pay );
+use CGI;
+use CGI::Carp qw(fatalsToBrowser);
+use Date::Format;
+use FS::UID qw(cgisuidsetup);
+use FS::CGI qw(popurl header menubar idiot table );
+use FS::Record qw(qsearch );
+use FS::cust_pay;
+use FS::cust_main;
+
+$cgi = new CGI;
+cgisuidsetup($cgi);
+
+$cgi->param('payinfo') =~ /^\s*(\d+)\s*$/ or die "illegal payinfo";
+my $payinfo = $1;
+$cgi->param('payby') =~ /^(\w+)$/ or die "illegal payby";
+my $payby = $1;
+@cust_pay = qsearch('cust_pay', { 'payinfo' => $payinfo,
+ 'payby' => $payby } );
+$sortby = \*date_sort;
+
+if (0) {
+#if ( scalar(@cust_pay) == 1 ) {
+# my $invnum = $cust_bill[0]->invnum;
+# print $cgi->redirect(popurl(2). "view/cust_bill.cgi?$invnum"); #redirect
+} elsif ( scalar(@cust_pay) == 0 ) {
+ idiot("Check # not found.");
+ #exit;
+} else {
+ my $total = scalar(@cust_pay);
+ my $s = $total > 1 ? 's' : '';
+ print header("Check # Search Results", menubar(
+ 'Main Menu', popurl(2)
+ )), "$total matching check$s found<BR>", &table(), <<END;
+ <TR>
+ <TH></TH>
+ <TH>Amount</TH>
+ <TH>Date</TH>
+ <TH>Contact name</TH>
+ <TH>Company</TH>
+ </TR>
+END
+
+ my(%saw, $cust_pay);
+ foreach my $cust_pay (
+ sort $sortby grep(!$saw{$_->paynum}++, @cust_pay)
+ ) {
+ my($paynum, $custnum, $payinfo, $amount, $date ) = (
+ $cust_pay->paynum,
+ $cust_pay->custnum,
+ $cust_pay->payinfo,
+ sprintf("%.2f", $cust_pay->paid),
+ $cust_pay->_date,
+ );
+ my $pdate = time2str("%b %d %Y", $date);
+
+ my $rowspan = 1;
+
+ my $view = popurl(2). "view/cust_main.cgi?". $custnum.
+ "#". $payby. $payinfo;
+
+ print <<END;
+ <TR>
+ <TD ROWSPAN=$rowspan><A HREF="$view"><FONT SIZE=-1>$payinfo</FONT></A></TD>
+ <TD ROWSPAN=$rowspan ALIGN="right"><A HREF="$view"><FONT SIZE=-1>\$$amount</FONT></A></TD>
+ <TD ROWSPAN=$rowspan><A HREF="$view"><FONT SIZE=-1>$pdate</FONT></A></TD>
+END
+ my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
+ if ( $cust_main ) {
+ #my $cview = popurl(2). "view/cust_main.cgi?". $cust_main->custnum;
+ my ( $name, $company ) = (
+ $cust_main->last. ', '. $cust_main->first,
+ $cust_main->company,
+ );
+ print <<END;
+ <TD ROWSPAN=$rowspan><A HREF="$view"><FONT SIZE=-1>$name</FONT></A></TD>
+ <TD ROWSPAN=$rowspan><A HREF="$view"><FONT SIZE=-1>$company</FONT></A></TD>
+END
+ } else {
+ print <<END
+ <TD ROWSPAN=$rowspan COLSPAN=2>WARNING: couldn't find cust_main.custnum $custnum (cust_pay.paynum $paynum)</TD>
+END
+ }
+
+ print "</TR>";
+ }
+ print <<END;
+ </TABLE>
+ </BODY>
+</HTML>
+END
+
+}
+
+#
+
+#sub invnum_sort {
+# $a->invnum <=> $b->invnum;
+#}
+#
+#sub custnum_sort {
+# $a->custnum <=> $b->custnum || $a->invnum <=> $b->invnum;
+#}
+
+sub date_sort {
+ $a->_date <=> $b->_date || $a->invnum <=> $b->invnum;
+}
+%>
diff --git a/httemplate/search/cust_pay.html b/httemplate/search/cust_pay.html
new file mode 100755
index 000000000..3848d66f7
--- /dev/null
+++ b/httemplate/search/cust_pay.html
@@ -0,0 +1,18 @@
+<HTML>
+ <HEAD>
+ <TITLE>Check # Search</TITLE>
+ </HEAD>
+ <BODY BGCOLOR="#e8e8e8">
+ <FONT SIZE=7>
+ Check # Search
+ </FONT>
+ <BR><BR>
+ <FORM ACTION="cust_pay.cgi" METHOD="post">
+ Search for <B>check #</B>:
+ <INPUT TYPE="text" NAME="payinfo">
+ <INPUT TYPE="hidden" NAME="payby" VALUE="BILL">
+ <BR><BR><INPUT TYPE="submit" VALUE="Search">
+ </FORM>
+ </BODY>
+</HTML>
+
diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi
index b17c9277a..eea2403c4 100755
--- a/httemplate/view/cust_main.cgi
+++ b/httemplate/view/cust_main.cgi
@@ -1,5 +1,5 @@
<%
-#<!-- $Id: cust_main.cgi,v 1.15 2001-12-21 21:40:24 ivan Exp $ -->
+#<!-- $Id: cust_main.cgi,v 1.16 2001-12-26 09:18:18 ivan Exp $ -->
use strict;
use vars qw ( $cgi $query $custnum $cust_main $hashref $agent $referral
@@ -361,6 +361,8 @@ print qq!<BR><BR><A NAME="history">Payment History!.
@history = (); #needed for mod_perl :)
+my %target = ();
+
@bills = qsearch('cust_bill',{'custnum'=>$custnum});
foreach $bill (@bills) {
my($bref)=$bill->hashref;
@@ -386,9 +388,13 @@ foreach $bill (@bills) {
$payment->payinfo,
$cust_bill_pay->amount,
);
- $payinfo = substr($payinfo,0,4). 'x'x(length($payinfo)-4) if $payby eq 'CARD';
+ $payinfo = substr($payinfo,0,4). 'x'x(length($payinfo)-4)
+ if $payby eq 'CARD';
+ my $target = "$payby$payinfo";
+ $payby =~ s/^BILL$/Check #/ if $payinfo;
+ $payby =~ s/^(CARD|COMP)$/$1 /;
push @history,
- "$date\tPayment, Invoice #$invnum ($payby $payinfo)\t\t$paid\t\t";
+ "$date\tPayment, Invoice #$invnum ($payby$payinfo)\t\t$paid\t\t\t$target";
}
my(@cust_credit_bill)=
@@ -438,12 +444,20 @@ foreach my $refund (@refunds) {
my @unapplied_payments =
grep { $_->unapplied > 0 } qsearch('cust_pay', { 'custnum' => $custnum } );
foreach my $payment (@unapplied_payments) {
+ my $payby = $payment->payby;
+ my $payinfo = $payment->payinfo;
+ #false laziness w/above
+ $payinfo = substr($payinfo,0,4). 'x'x(length($payinfo)-4)
+ if $payby eq 'CARD';
+ my $target = "$payby$payinfo";
+ $payby =~ s/^BILL$/Check #/ if $payinfo;
+ $payby =~ s/^(CARD|COMP)$/$1 /;
push @history,
$payment->_date. "\t".
'<A HREF="'. popurl(2). 'edit/cust_bill_pay.cgi?'. $payment->paynum. '">'.
'<b><font size="+1" color="#ff0000">Unapplied payment #' .
- $payment->paynum . "</font></b></A>".
- "\t\t" . $payment->unapplied . "\t\t";
+ $payment->paynum . " ($payby$payinfo)</font></b></A>".
+ "\t\t" . $payment->unapplied . "\t\t\t$target";
}
#formatting
@@ -463,7 +477,7 @@ END
$balance = 0;
foreach $item (sort keyfield_numerically @history) {
- my($date,$desc,$charge,$payment,$credit,$refund)=split(/\t/,$item);
+ my($date,$desc,$charge,$payment,$credit,$refund,$target)=split(/\t/,$item);
$charge ||= 0;
$payment ||= 0;
$credit ||= 0;
@@ -473,7 +487,11 @@ foreach $item (sort keyfield_numerically @history) {
$balance = sprintf("%.2f", $balance);
$balance =~ s/^\-0\.00$/0.00/; #yay ieee fp
- print "<TR><TD><FONT SIZE=-1>",time2str("%D",$date),"</FONT></TD>",
+ print "<TR><TD><FONT SIZE=-1>";
+ print qq!<A NAME="$target">! unless $target{$target}++;
+ print time2str("%D",$date);
+ print '</A>' if $target{$target} == 1;
+ print "</FONT></TD>",
"<TD><FONT SIZE=-1>$desc</FONT></TD>",
"<TD><FONT SIZE=-1>",
( $charge ? "\$".sprintf("%.2f",$charge) : '' ),