1 <% include( 'elements/search.html',
2 'title' => 'Phone Number (DID) Search Results',
3 'name_singular' => 'phone number',
5 'table' => 'phone_avail',
10 FS::UI::Web::cust_sql_fields(),
12 'extra_sql' => $search,
13 'addl_from' => $addl_from,
15 'count_query' => $count_query,
23 FS::UI::Web::cust_header(),
29 '+'. $pn->countrycode. ' '.
30 $pn->npa. ' '. $pn->nxx. '-'. $pn->station;
32 sub { shift->get('name') },
37 \&FS::UI::Web::cust_fields,
39 'align' => 'rllllll'.FS::UI::Web::cust_aligns(),
46 '', #XXX #$export_link
48 ( map { $_ ne 'Cust. Status' ? $link_cust : '' }
49 FS::UI::Web::cust_header()
60 FS::UI::Web::cust_colors(),
70 FS::UI::Web::cust_styles(),
77 unless $FS::CurrentUser::CurrentUser->access_right('Import');
81 push @search, "availbatch = '$1'"
82 if ( $cgi->param('availbatch') =~ /^([\w\d \/\:\-\.]+)$/ );
84 push @search, "countrycode = '$1'"
85 if ( $cgi->param('countrycode') =~ /^(\d{1,3})$/ );
87 push @search, "phone_avail.state = '$1'"
88 if ( $cgi->param('state') =~ /^(\w{2})$/ );
90 # i know that the regexps match more than NPA/NXX, but this is good enough now
91 push @search, "npa = '$1'"
92 if ( $cgi->param('npa') =~ /^(\d{3})$/ );
93 push @search, "nxx = '$1'"
94 if ( $cgi->param('npa') =~ /^\d{3}$/ && $cgi->param('nxx') =~ /^(\d{3})$/ );
96 push @search, "name = '$1'"
97 if ( $cgi->param('ratecenter') =~ /^([\w \-\.]+)$/ );
99 push @search, "svcnum is null"
100 if ( $cgi->param('avail_status') eq 'AVAIL' );
101 push @search, "svcnum is not null"
102 if ( $cgi->param('avail_status') eq 'UNAVAIL' );
104 # #here is the agent virtualization
105 # push @search, $FS::CurrentUser::CurrentUser->agentnums_sql;
107 my $search = scalar(@search)
108 ? ' WHERE '. join(' AND ', @search)
112 my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '.
113 #' LEFT JOIN part_svc USING ( svcpart ) '.
114 ' LEFT JOIN cust_pkg USING ( pkgnum ) '.
115 ' LEFT JOIN cust_main USING ( custnum ) ';
117 my $count_query = "SELECT COUNT(*) FROM phone_avail $search"; #$addl_from?
119 my $link_cust = sub {
120 my $phone_avail = shift;
121 if ( $phone_avail->svcnum ) {
122 my $cust_svc = $phone_avail->cust_svc;
123 if ( $cust_svc->pkgnum ) {
124 #my $cust_main = $cust_svc->cust_pkg->cust_main;
125 return [ "${p}view/cust_main.cgi?", 'custnum' ];