5 use FS::UID qw(adminsuidsetup);
6 use FS::Record qw(qsearch);
10 { 'header' => 'pkgnum',
11 'callback' => sub { shift->cust_svc->pkgnum; },
13 { 'header' => 'svcpart',
14 'callback' => sub { shift->cust_svc->svcpart; },
16 { 'header' => 'Service',
17 'callback' => sub { shift->cust_svc->part_svc->svc; },
27 my $user = shift or die &usage;
30 my $agentnum = shift or die &usage;
32 my $csv = new Text::CSV_XS;
34 $csv->combine( map { ref($_) ? $_->{'header'} : $_ } @fields ) or die;
35 print $csv->string."\n";
37 my @svc_phone = qsearch({
38 'table' => 'svc_phone',
39 'addl_from' => 'LEFT JOIN cust_svc USING (svcnum)
40 LEFT JOIN cust_pkg USING (pkgnum)
41 LEFT JOIN cust_main USING ( custnum )',
43 'extra_sql' => "WHERE cust_main.agentnum = $agentnum",
46 foreach my $svc_phone ( @svc_phone ) {
47 $csv->combine( map { ref($_) ? &{$_->{'callback'}}($svc_phone)
52 print $csv->string."\n";