5 use FS::UID qw(adminsuidsetup);
6 use FS::Record qw(qsearch);
18 { 'header' => 'Package',
19 'callback' => sub { shift->part_pkg->pkg_comment('nopkgpart'=>1) },
24 'callback' => sub { my $d = shift->get($field) or return '';
25 time2str('%x', $d); # %X", $d);
28 } qw( order_date start_date setup last_bill bill
30 expire cancel uncancel
35 my $user = shift or die &usage;
38 my $agentnum = shift or die &usage;
40 my $csv = new Text::CSV_XS;
42 $csv->combine( map { ref($_) ? $_->{'header'} : $_ } @fields ) or die;
43 print $csv->string."\n";
45 my @cust_pkg = qsearch({
46 'table' => 'cust_pkg',
47 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
49 'extra_sql' => "WHERE cust_main.agentnum = $agentnum",
52 foreach my $cust_pkg ( @cust_pkg ) {
53 $csv->combine( map { ref($_) ? &{$_->{'callback'}}($cust_pkg)
58 print $csv->string."\n";