5 use FS::UID qw(adminsuidsetup);
6 use FS::Record qw(qsearch);
17 'callback' => sub { time2str('%x', shift->_date); },
21 push @fields, qw( charged owed );
23 my $user = shift or die &usage;
26 my $agentnum = shift or die &usage;
28 my $csv = new Text::CSV_XS;
30 $csv->combine( map { ref($_) ? $_->{'header'} : $_ } @fields ) or die;
31 print $csv->string."\n";
33 my @cust_bill = qsearch({
34 'table' => 'cust_bill',
35 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
37 'extra_sql' => "WHERE cust_main.agentnum = $agentnum",
40 foreach my $cust_bill ( @cust_bill ) {
41 $csv->combine( map { ref($_) ? &{$_->{'callback'}}($cust_bill)
46 print $csv->string."\n";