payments report for inventivemedia / hpnx
authorivan <ivan>
Fri, 11 Jul 2003 15:23:33 +0000 (15:23 +0000)
committerivan <ivan>
Fri, 11 Jul 2003 15:23:33 +0000 (15:23 +0000)
httemplate/index.html
httemplate/search/cust_pay.cgi
httemplate/search/cust_pkg.cgi
httemplate/search/report_cust_pay.html [new file with mode: 0644]

index e5bd118..7354b1c 100644 (file)
@@ -67,7 +67,8 @@
               <LI>120 day open invoices (<A HREF="search/cust_bill.cgi?OPEN120_invnum">by invoice number</A>) (<A HREF="search/cust_bill.cgi?OPEN120_date">by date</A>) (<A HREF="search/cust_bill.cgi?OPEN120_custnum">by customer number</A>)
               <LI>all invoices (<A HREF="search/cust_bill.cgi?invnum">by invoice number</A>) (<A HREF="search/cust_bill.cgi?date">by date</A>) (<A HREF="search/cust_bill.cgi?custnum">by customer number</A>)
             </UL>
-      Financial reports
+      <A HREF="search/report_cust_pay.html">Payments</A>
+      <BR><BR>Financial reports
             <UL>
               <LI> <A HREF="search/report_receivables.cgi">current receivables</A>
               <LI> <A HREF="search/report_tax.html">tax reports</A>
         <LI>120 day open invoices (<A HREF="search/cust_bill.cgi?OPEN120_invnum">by invoice number</A>) (<A HREF="search/cust_bill.cgi?OPEN120_date">by date</A>) (<A HREF="search/cust_bill.cgi?OPEN120_custnum">by customer number</A>)
         <LI>all invoices (<A HREF="search/cust_bill.cgi?invnum">by invoice number</A>) (<A HREF="search/cust_bill.cgi?date">by date</A>) (<A HREF="search/cust_bill.cgi?custnum">by customer number</A>)
       </UL>
-    Financial reports
+    <A HREF="search/report_cust_pay.html">Payments</A>
+    <BR><BR>Financial reports
             <UL>
               <LI> <A HREF="search/report_receivables.cgi">current receivables</A>
               <LI> <A HREF="search/report_tax.html">tax reports</A>
index b5bdf82..d601617 100755 (executable)
@@ -1,12 +1,46 @@
 <%
 
-$cgi->param('payinfo') =~ /^\s*(\d+)\s*$/ or die "illegal payinfo";
-my $payinfo = $1;
-$cgi->param('payby') =~ /^(\w+)$/ or die "illegal payby";
-my $payby = $1;
-my @cust_pay = qsearch('cust_pay', { 'payinfo' => $payinfo,
+my $sortby;
+my @cust_pay;
+if ( $cgi->param('magic') && $cgi->param('magic') eq '_date' ) {
+
+  my %search;
+  if ( $cgi->param('payby') ) {
+    $cgi->param('payby') =~ /^(CARD|CHEK|BILL)$/
+      or die "illegal payby ". $cgi->param('payby');
+    $search{'payby'} = $1;
+  }
+
+  #false laziness with cust_pkg.cgi
+  my $range = '';
+  if ( $cgi->param('beginning')
+       && $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/ ) {
+    my $beginning = str2time($1);
+    $range = " WHERE _date >= $beginning ";
+  }
+  if ( $cgi->param('ending')
+            && $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/ ) {
+    my $ending = str2time($1) + 86400;
+    $range .= ( $range ? ' AND ' : ' WHERE ' ). " _date <= $ending ";
+  }
+
+  @cust_pay = qsearch('cust_pay', \%search, '', " $range" );
+
+  $sortby = \*date_sort;
+
+} else {
+
+  $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    } );
-my $sortby = \*date_sort;
+  $sortby = \*date_sort;
+
+}
 
 if (0) {
 #if ( scalar(@cust_pay) == 1 ) {
@@ -16,7 +50,7 @@ if (0) {
 %>
 <!-- mason kludge -->
 <%
-  idiot("Check # not found.");
+  idiot("Payment not found.");
   #exit;
 } else {
   my $total = scalar(@cust_pay);
@@ -24,9 +58,9 @@ if (0) {
 %>
 <!-- mason kludge -->
 <%
-  print header("Check # Search Results", menubar(
+  print header("Payment Search Results", menubar(
           'Main Menu', popurl(2)
-        )), "$total matching check$s found<BR>", &table(), <<END;
+        )), "$total matching payment$s found<BR>", &table(), <<END;
       <TR>
         <TH></TH>
         <TH>Amount</TH>
@@ -40,23 +74,36 @@ END
   foreach my $cust_pay (
     sort $sortby grep(!$saw{$_->paynum}++, @cust_pay)
   ) {
-    my($paynum, $custnum, $payinfo, $amount, $date ) = (
+    my($paynum, $custnum, $payby, $payinfo, $amount, $date ) = (
       $cust_pay->paynum,
       $cust_pay->custnum,
+      $cust_pay->payby,
       $cust_pay->payinfo,
       sprintf("%.2f", $cust_pay->paid),
       $cust_pay->_date,
     );
-    my $pdate = time2str("%b %d %Y", $date);
+    my $pdate = time2str("%b&nbsp;%d&nbsp;%Y", $date);
 
     my $rowspan = 1;
 
     my $view = popurl(2). "view/cust_main.cgi?". $custnum. 
                "#". $payby. $payinfo;
 
+    my $payment_info;
+    if ( $payby eq 'CARD' ) {
+      $payment_info = 'Card&nbsp;#'. 'x'x(length($payinfo)-4).
+                      substr($payinfo,(length($payinfo)-4));
+    } elsif ( $payby eq 'CHEK' ) {
+      $payment_info = "E-check&nbsp;acct#$payinfo";
+    } elsif ( $payby eq 'BILL' ) {
+      $payment_info = "Check&nbsp;#$payinfo";
+    } else {
+      $payment_info = "$payby&nbsp;$payinfo";
+    }
+
     print <<END;
       <TR>
-        <TD ROWSPAN=$rowspan><A HREF="$view"><FONT SIZE=-1>$payinfo</FONT></A></TD>
+        <TD ROWSPAN=$rowspan><A HREF="$view"><FONT SIZE=-1>$payment_info</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
index 12179ea..603b565 100755 (executable)
@@ -19,6 +19,8 @@ my @cust_pkg;
 
 if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) {
   $sortby=\*bill_sort;
+
+  #false laziness with cust_pay.cgi
   my $range = '';
   if ( $cgi->param('beginning')
        && $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/ ) {
diff --git a/httemplate/search/report_cust_pay.html b/httemplate/search/report_cust_pay.html
new file mode 100644 (file)
index 0000000..93053e1
--- /dev/null
@@ -0,0 +1,24 @@
+<HTML>
+  <HEAD>
+    <TITLE>Payment report criteria</TITLE>
+  </HEAD>
+  <BODY>
+    <CENTER>
+      <H1>Payment report criteria</H1>
+    </CENTER>
+    <HR>
+    <FORM ACTION="cust_pay.cgi" METHOD="post">
+    <INPUT TYPE="hidden" NAME="magic" VALUE="_date">
+      Return <SELECT NAME="payby">
+        <OPTION VALUE="">all</OPTION>
+        <OPTION VALUE="CARD">credit card</OPTION>
+        <OPTION VALUE="CHEK">electronic check (ACH)</OPTION>
+        <OPTION VALUE="BILL">check/cash</OPTION>
+      </SELECT> payments for period<BR>
+      from <INPUT TYPE="text" NAME="beginning"> <i>m/d/y</i>
+      to <INPUT TYPE="text" NAME="ending"> <i>m/d/y</i>
+      <P><INPUT TYPE="submit" VALUE="Get Report">
+    </FORM>
+  <HR>
+  </BODY>
+</HTML>