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')
94 push @search, "availbatch = '$1'"
95 if ( $cgi->param('availbatch') =~ /^([\w\d \/\:\-\.]+)$/ );
97 push @search, "countrycode = '$1'"
98 if ( $cgi->param('countrycode') =~ /^(\d{1,3})$/ );
100 push @search, "phone_avail.state = '$1'"
101 if ( $cgi->param('state') =~ /^(\w{2})$/ );
103 # i know that the regexps match more than NPA/NXX, but this is good enough now
104 push @search, "npa = '$1'"
105 if ( $cgi->param('npa') =~ /^(\d{3})$/ );
106 push @search, "nxx = '$1'"
107 if ( $cgi->param('npa') =~ /^\d{3}$/ && $cgi->param('nxx') =~ /^(\d{3})$/ );
109 push @search, "name = '$1'"
110 if ( $cgi->param('ratecenter') =~ /^([\w \-\.]+)$/ );
112 push @search, "svcnum is null"
113 if ( $cgi->param('avail_status') eq 'AVAIL' );
114 push @search, "svcnum is not null"
115 if ( $cgi->param('avail_status') eq 'UNAVAIL' );
117 # #here is the agent virtualization
118 # push @search, $FS::CurrentUser::CurrentUser->agentnums_sql;
120 my $search = scalar(@search)
121 ? ' WHERE '. join(' AND ', @search)
125 my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '.
126 #' LEFT JOIN part_svc USING ( svcpart ) '.
127 ' LEFT JOIN cust_pkg USING ( pkgnum ) '.
128 ' LEFT JOIN cust_main USING ( custnum ) ';
130 my $count_query = "SELECT COUNT(*) FROM phone_avail $search"; #$addl_from?
133 $hashref->{'ordernum'} = $1 if $cgi->param('ordernum') =~ /^(\d+)$/;
135 my $link_cust = sub {
136 my $phone_avail = shift;
137 if ( $phone_avail->svcnum ) {
138 my $cust_svc = $phone_avail->cust_svc;
139 if ( $cust_svc->pkgnum ) {
140 #my $cust_main = $cust_svc->cust_pkg->cust_main;
141 return [ "${p}view/cust_main.cgi?", 'custnum' ];
148 my $phone_avail = shift;
149 my $cust_svc = $phone_avail->cust_svc;
151 return [ "${p}view/svc_phone.cgi?", 'svcnum'];