10 ( select sum(amount) from cust_bill_pay
11 where cust_bill.invnum = cust_bill_pay.invnum )
15 ( select sum(amount) from cust_bill_pay
16 where cust_bill.invnum = cust_bill_pay.invnum )
22 where cust_bill._date > extract(epoch from now())-2592000
23 and cust_main.custnum = cust_bill.custnum
31 ( select sum(amount) from cust_bill_pay
32 where cust_bill.invnum = cust_bill_pay.invnum )
36 ( select sum(amount) from cust_bill_pay
37 where cust_bill.invnum = cust_bill_pay.invnum )
43 where cust_bill._date > extract(epoch from now())-5184000
44 and cust_bill._date <= extract(epoch from now())-2592000
45 and cust_main.custnum = cust_bill.custnum
53 ( select sum(amount) from cust_bill_pay
54 where cust_bill.invnum = cust_bill_pay.invnum )
58 ( select sum(amount) from cust_bill_pay
59 where cust_bill.invnum = cust_bill_pay.invnum )
65 where cust_bill._date > extract(epoch from now())-7776000
66 and cust_bill._date <= extract(epoch from now())-5184000
67 and cust_main.custnum = cust_bill.custnum
75 ( select sum(amount) from cust_bill_pay
76 where cust_bill.invnum = cust_bill_pay.invnum )
80 ( select sum(amount) from cust_bill_pay
81 where cust_bill.invnum = cust_bill_pay.invnum )
87 where cust_bill._date <= extract(epoch from now())-7776000
88 and cust_main.custnum = cust_bill.custnum
96 ( select sum(amount) from cust_bill_pay
97 where cust_bill.invnum = cust_bill_pay.invnum )
101 ( select sum(amount) from cust_bill_pay
102 where cust_bill.invnum = cust_bill_pay.invnum )
108 where cust_main.custnum = cust_bill.custnum
117 ( select sum( charged
119 ( select sum(amount) from cust_bill_pay
120 where cust_bill.invnum = cust_bill_pay.invnum )
124 ( select sum(amount) from cust_bill_pay
125 where cust_bill.invnum = cust_bill_pay.invnum )
131 where cust_main.custnum = cust_bill.custnum
136 order by company, last
143 #the grep (and the sort ) should be pushed down to SQL
144 #my @cust_main = sort { $a->company cmp $b->company
145 # || $a->last cmp $b->last }
146 # grep { $_->balance }
147 # qsearch('cust_main', {} );
149 my $totals_table = table(). '<TR><TH>Total</TH>'.
150 '<TD><i>0-30</i></TD>'.
151 '<TD><i>30-60</i></TD>'.
152 '<TD><i>60-90</i></TD>'.
153 '<TD><i>90+</i></TD>'.
154 '<TD><i>total</i></TD>'.
158 my $sth = dbh->prepare($sql) or die dbh->errstr;
159 $sth->execute or die $sth->errstr;
162 <%= header('Accounts Receivable Aging Summary', menubar( 'Main Menu'=>$p, ) ) %>
173 <% while ( my $row = $sth->fetchrow_hashref() ) { %>
175 <TD><A HREF="<% $p %>view/cust_main.cgi?<%= $row->{'custnum'} %>">
176 <%= $row->{'company'} ? $row->{'company'}. ' (' : '' %>
177 <%= $row->{'last'}. ', '. $row->{'first'} %>
178 <%= $row->{'company'} ? ')' : '' %></A>
180 <TD ALIGN="right">$<%= sprintf("%.2f", $row->{'owed_0_30'} ) %></TD>
181 <TD ALIGN="right">$<%= sprintf("%.2f", $row->{'owed_30_60'} ) %></TD>
182 <TD ALIGN="right">$<%= sprintf("%.2f", $row->{'owed_60_90'} ) %></TD>
183 <TD ALIGN="right">$<%= sprintf("%.2f", $row->{'owed_90_plus'} ) %></TD>
184 <TD ALIGN="right"><B>$<%= sprintf("%.2f", $row->{'owed_total'} ) %></B></TD>