add agent-specific A/R aging report, closes: bug#1229
authorivan <ivan>
Wed, 18 May 2005 16:55:23 +0000 (16:55 +0000)
committerivan <ivan>
Wed, 18 May 2005 16:55:23 +0000 (16:55 +0000)
httemplate/browse/agent.cgi
httemplate/search/report_receivables.cgi

index d8c74d1..f118552 100755 (executable)
@@ -97,6 +97,8 @@ foreach my $agent ( sort {
         <TD>
           <A HREF="<%= $p %>search/report_cust_pay.html?agentnum=<%= $agent->agentnum %>">Payments</A>
           <BR><A HREF="<%= $p %>search/report_cust_credit.html?agentnum=<%= $agent->agentnum %>">Credits</A>
         <TD>
           <A HREF="<%= $p %>search/report_cust_pay.html?agentnum=<%= $agent->agentnum %>">Payments</A>
           <BR><A HREF="<%= $p %>search/report_cust_credit.html?agentnum=<%= $agent->agentnum %>">Credits</A>
+          <BR><A HREF="<%= $p %>search/report_receivables.html?agentnum=<%= $agent->agentnum %>">A/R Aging</A>
+          <!--<BR><A HREF="<%= $p %>search/money_time.cgi?agentnum=<%= $agent->agentnum %>">Sales/Credits/Receipts</A>-->
 
         </TD>
 
 
         </TD>
 
index 4c835fb..77e1d4a 100755 (executable)
@@ -91,6 +91,12 @@ where 0 <
          )
 END
 
          )
 END
 
+  my $agentnum = '';
+  if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
+    $agentnum = $1;
+    $where .= " AND agentnum = '$agentnum' ";
+  }
+
   my $count_sql = "select count(*) from cust_main $where";
 
   my $sql_query = {
   my $count_sql = "select count(*) from cust_main $where";
 
   my $sql_query = {
@@ -100,6 +106,10 @@ END
     'extra_sql' => "$where order by coalesce(lower(company), ''), lower(last)",
   };
 
     'extra_sql' => "$where order by coalesce(lower(company), ''), lower(last)",
   };
 
+  if ( $agentnum ) {
+    $owed_cols =~
+      s/cust_bill\.custnum/cust_bill.custnum AND cust_main.agentnum = '$agentnum'/g;
+  }
   my $total_sql = "select $owed_cols";
   my $total_sth = dbh->prepare($total_sql) or die dbh->errstr;
   $total_sth->execute or die $total_sth->errstr;
   my $total_sql = "select $owed_cols";
   my $total_sth = dbh->prepare($total_sql) or die dbh->errstr;
   $total_sth->execute or die $total_sth->errstr;