1 <% include( 'elements/search.html',
2 'title' => 'Phone Number (DID) Search Results',
3 'name_singular' => 'phone number',
5 'table' => 'phone_avail',
7 'select' => 'distinct npa||nxx as npanxx'
9 'count_query' => 'SELECT COUNT(distinct npa||nxx) FROM phone_avail',
10 'header' => [ 'NPANXX',
18 my $npanxx = shift->npanxx;
19 my @dids = qsearch('phone_avail',
21 'npa' => substr($npanxx,0,3),
22 'nxx' => substr($npanxx,3,3),
28 my $npanxx = shift->npanxx;
29 my @dids = provisioned_dids($npanxx);
33 my $npanxx = shift->npanxx;
34 my @dids = provisioned_dids($npanxx);
36 foreach my $did ( @dids ) {
37 next unless $did->cust_svc;
38 my $svc_phone = $did->cust_svc->svc_x;
39 next unless $svc_phone;
40 my @cdrs = $svc_phone->get_cdrs;
41 $count++ if scalar(@cdrs);
70 unless ( $FS::CurrentUser::CurrentUser->access_right('List inventory')
71 && $FS::CurrentUser::CurrentUser->access_right('List services')
74 # XXX: agent virtualize
76 sub provisioned_dids {
78 qsearch({ 'table' => 'phone_avail',
80 'npa' => substr($npanxx,0,3),
81 'nxx' => substr($npanxx,3,3),
83 'extra_sql' => ' and svcnum is not null ',