+ my $row = $total_sth->fetchrow_hashref();
+
+ my $conf = new FS::Conf;
+ my $money_char = $conf->config('money_char') || '$';
+
+%><%= include( 'elements/search.html',
+ 'title' => 'Accounts Receivable Aging Summary',
+ 'name' => 'customers',
+ 'query' => $sql_query,
+ 'count_query' => $count_sql,
+ 'header' => [
+ '#',
+ 'Customer',
+ 'Status (me)',
+ 'Status (cust_main)',
+ '0-30',
+ '30-60',
+ '60-90',
+ '90+',
+ 'Total',
+ ],
+ 'footer' => [
+ '',
+ 'Total',
+ '',
+ '',
+ sprintf( $money_char.'%.2f',
+ $row->{'owed_0_30'} ),
+ sprintf( $money_char.'%.2f',
+ $row->{'owed_30_60'} ),
+ sprintf( $money_char.'%.2f',
+ $row->{'owed_60_90'} ),
+ sprintf( $money_char.'%.2f',
+ $row->{'owed_90_pl'} ),
+ sprintf( '<b>'. $money_char.'%.2f'. '</b>',
+ $row->{'owed_total'} ),
+ ],
+ 'align' => 'rlccrrrrr',
+ 'size' => [ '', '', '-1', '-1', '', '', '', '', '', ],
+ 'style' => [ '', '', 'b', 'b', '', '', '', '', 'b', ],
+ 'color' => [
+ '',
+ '',
+ sub {
+ my $row = shift;
+ my $status = 'Cancelled';
+ my $statuscol = 'FF0000';
+ if ( $row->uncancelled_pkgs ) {
+ $status = 'Suspended';
+ $statuscol = 'FF9900';
+ if ( $row->active_pkgs ) {
+ $status = 'Active';
+ $statuscol = '00CC00';
+ }
+ }
+ $statuscol;
+ },
+ sub { shift->statuscolor; },
+ '',
+ '',
+ '',
+ '',
+ '',
+ ],
+ 'fields' => [
+ 'custnum',
+ 'name',
+ sub {
+ my $row = shift;
+ my $status = 'Cancelled';
+ my $statuscol = 'FF0000';
+ if ( $row->uncancelled_pkgs ) {
+ $status = 'Suspended';
+ $statuscol = 'FF9900';
+ if ( $row->active_pkgs ) {
+ $status = 'Active';
+ $statuscol = '00CC00';
+ }
+ }
+ $status;
+ },
+ sub { ucfirst(shift->status) },
+ sub { sprintf( $money_char.'%.2f',
+ shift->get('owed_0_30') ) },
+ sub { sprintf( $money_char.'%.2f',
+ shift->get('owed_30_60') ) },
+ sub { sprintf( $money_char.'%.2f',
+ shift->get('owed_60_90') ) },
+ sub { sprintf( $money_char.'%.2f',
+ shift->get('owed_90_pl') ) },
+ sub { sprintf( $money_char.'%.2f',
+ shift->get('owed_total') ) },
+ ],
+ )