5 use FS::Record qw( qsearchs );
9 my( $custnum ) = shift; #@_;
11 my $cust_main = qsearchs( 'cust_main' => { 'custnum' => $custnum } )
12 or return { 'status' => 'E',
13 'error' => "$custnum not found" };
15 my @cust_pkg = $cust_main->cust_pkg;
17 my @cust_svc = map $_->cust_svc, @cust_pkg;
24 grep { my($n,$l,$t) = $_->label; $t eq 'svc_pbx' }
27 #i tried sofa king hard to explain to them why passing a custnum instead
28 #of a conference id was a bad idea, but i can't make them understand...
29 if ( ! @cust_svc_pbx ) {
30 return { 'status' => 'E',
31 'error' => "customer $custnum has no conference service" };
32 } elsif ( scalar(@cust_svc_pbx) > 1 ) {
33 return { 'status' => 'E',
34 'error' => "customer $custnum has more than one conference service; there should be a way to specify which one you want",
35 }; #maybe list them... and work with a pkgnum
38 my $cust_svc_pbx = $cust_svc_pbx[0];
40 my $svc_pbx = $cust_svc_pbx->svc_X;
43 # find "outbound service" y/n
46 my $conf = new FS::Conf;
47 my %outbound_pkgs = map { $_=>1 } $conf->config('mc-outbound_packages');
48 my $outbound_service =
49 scalar( grep $outbound_pkgs{ $_->pkgpart }, @cust_pkg )
53 # find "good till" date/time stamp
57 sort { $a->bill <=> $b->bill }
58 grep { !$_->get('cancel') && $_->part_pkg->freq ne '0' }
60 my $good_till =time2str('%c', $active_cust_pkg[0]->bill || time );
67 'status' => substr($cust_main->ucfirst_status,0,1), #what they asked for..
68 'name' => $cust_main->name,
69 'email' => $cust_main->invoicing_list_emailonly_scalar,
70 'max_lines' => $svc_pbx->max_extensions,
71 'max_simultaneous' => $svc_pbx->max_simultaneous,
72 'outbound_service' => $outbound_service,
73 'good_till' => $good_till,
74 'products' => [ map $_->pkgpart, grep !$_->get('cancel'), @cust_pkg ],