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') },
36 return '' unless $pa->part_export;
37 $pa->part_export->exportname;
41 return '' unless $pa->cust_svc;
42 my($label,$value) = $pa->cust_svc->label;
43 $label . ": " . $value;
45 \&FS::UI::Web::cust_fields,
48 'align' => 'rllllllc'.FS::UI::Web::cust_aligns(),
55 '', #XXX #$export_link - to what exactly?
57 ( map { $_ ne 'Cust. Status' ? $link_cust : '' }
58 FS::UI::Web::cust_header()
70 FS::UI::Web::cust_colors(),
81 FS::UI::Web::cust_styles(),
89 unless ( $FS::CurrentUser::CurrentUser->access_right('List inventory')
90 || $FS::CurrentUser::CurrentUser->access_right('List services')
95 push @search, "availbatch = '$1'"
96 if ( $cgi->param('availbatch') =~ /^([\w\d \/\:\-\.]+)$/ );
98 push @search, "countrycode = '$1'"
99 if ( $cgi->param('countrycode') =~ /^(\d{1,3})$/ );
101 push @search, "phone_avail.state = '$1'"
102 if ( $cgi->param('state') =~ /^(\w{2})$/ );
104 # i know that the regexps match more than NPA/NXX, but this is good enough now
105 push @search, "npa = '$1'"
106 if ( $cgi->param('npa') =~ /^(\d{3})$/ );
107 push @search, "nxx = '$1'"
108 if ( $cgi->param('npa') =~ /^\d{3}$/ && $cgi->param('nxx') =~ /^(\d{3})$/ );
110 push @search, "name = '$1'"
111 if ( $cgi->param('ratecenter') =~ /^([\w \-\.]+)$/ );
113 push @search, "svcnum is null"
114 if ( $cgi->param('avail_status') eq 'AVAIL' );
115 push @search, "svcnum is not null"
116 if ( $cgi->param('avail_status') eq 'UNAVAIL' );
118 # #here is the agent virtualization
119 # push @search, $FS::CurrentUser::CurrentUser->agentnums_sql;
121 my $search = scalar(@search)
122 ? ' WHERE '. join(' AND ', @search)
126 my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '.
127 #' LEFT JOIN part_svc USING ( svcpart ) '.
128 ' LEFT JOIN cust_pkg USING ( pkgnum ) '.
129 ' LEFT JOIN cust_main USING ( custnum ) ';
131 my $count_query = "SELECT COUNT(*) FROM phone_avail $search"; #$addl_from?
134 $hashref->{'ordernum'} = $1 if $cgi->param('ordernum') =~ /^(\d+)$/;
136 my $link_cust = sub {
137 my $phone_avail = shift;
138 if ( $phone_avail->svcnum ) {
139 my $cust_svc = $phone_avail->cust_svc;
140 if ( $cust_svc->pkgnum ) {
141 #my $cust_main = $cust_svc->cust_pkg->cust_main;
142 return [ "${p}view/cust_main.cgi?", 'custnum' ];
149 my $phone_avail = shift;
150 my $cust_svc = $phone_avail->cust_svc;
152 return [ "${p}view/svc_phone.cgi?", 'svcnum'];