1 <& elements/svc_Common.html,
2 'title' => 'Broadband Search Results',
3 'name' => 'broadband services',
4 'html_init' => $html_init,
6 'count_query' => $sql_query->{'count_query'},
7 'redirect' => [ popurl(2). "view/svc_broadband.cgi?", 'svcnum' ],
13 'Upload Speed (Kbps)',
14 'Download Speed (Kbps)',
17 FS::UI::Web::cust_header($cgi->param('cust_fields')),
19 'fields' => [ 'svcnum',
22 my $router = shift->router;
23 $router ? $router->routername : '';
31 $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
32 return '' unless $cust_pkg_cache{$_[0]->svcnum};
33 $cust_pkg_cache{$_[0]->svcnum}->ucfirst_status
35 \&FS::UI::Web::cust_fields,
40 (map '', @tower_fields),
46 ( map { $_ ne 'Cust. Status' ? $link_cust : '' }
47 FS::UI::Web::cust_header($cgi->param('cust_fields'))
50 'align' => 'rll'.('r' x @tower_fields).
51 'rrr'. # ip_addr, speed_up, speed_down
54 FS::UI::Web::cust_aligns(),
59 (map '', @tower_fields),
65 $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
66 return '' unless $cust_pkg_cache{$_[0]->svcnum};
67 my $c = FS::cust_pkg::statuscolors;
68 $c->{$cust_pkg_cache{$_[0]->svcnum}->status };
70 FS::UI::Web::cust_colors(),
76 (map '', @tower_fields),
82 FS::UI::Web::cust_styles(),
88 die "access denied" unless
89 $FS::CurrentUser::CurrentUser->access_right('List services');
93 my $conf = new FS::Conf;
95 $m->comp('/elements/handle_uri_query');
98 if ( $cgi->param('magic') eq 'unlinked' ) {
99 %search_hash = ( 'unlinked' => 1 );
101 foreach (qw( custnum agentnum svcpart cust_fields )) {
102 $search_hash{$_} = $cgi->param($_) if $cgi->param($_);
104 foreach (qw(pkgpart routernum towernum sectornum)) {
105 $search_hash{$_} = [ $cgi->param($_) ] if $cgi->param($_);
107 if ( defined($cgi->param('cancelled')) ) {
108 $search_hash{'cancelled'} = $cgi->param('cancelled') ? 1 : 0;
112 if ( $cgi->param('sortby') =~ /^(\w+)$/ ) {
113 $search_hash{'order_by'} = "ORDER BY $1";
116 my $sql_query = FS::svc_broadband->search(\%search_hash);
120 if ( FS::tower_sector->count > 0 ) {
121 push @tower_header, 'Tower/Sector';
122 push @tower_fields, sub { $_[0]->tower_sector ?
123 $_[0]->tower_sector->description : '' };
126 my %routerbyblock = ();
127 foreach my $router (qsearch('router', {})) {
128 foreach ($router->addr_block) {
129 $routerbyblock{$_->blocknum} = $router;
133 my $link = [ $p.'view/svc_broadband.cgi?', 'svcnum' ];
135 #XXX get the router link working
136 #my $link_router = sub {
137 # my $routernum = $routerbyblock{shift->blocknum}->routernum;
138 # [ $p.'view/router.cgi?'.$routernum, 'routernum' ];
141 my $link_cust = [ $p.'view/cust_main.cgi?', 'custnum' ];
143 my $html_init = include('/elements/email-link.html',
144 'search_hash' => \%search_hash,
145 'table' => 'svc_broadband'
148 my $query = $m->scomp('/elements/create_uri_query');
150 $html_init .= ' | ' .
152 $fsurl . 'search/svc_broadband-map.html?' . $query .
153 '">' . emt('View a map of these services') . '</a>';
155 my (@header_pkg,@fields_pkg,@blank_pkg);
157 #false laziness with search/svc_acct.cgi
158 $cgi->param('cust_pkg_fields') =~ /^([\w\,]*)$/ or die "bad cust_pkg_fields";
159 my @pkg_fields = split(',', $1);
160 foreach my $pkg_field ( @pkg_fields ) {
161 ( my $header = ucfirst($pkg_field) ) =~ s/_/ /; #:/
162 push @header_pkg, $header;
164 #not the most efficient to do it every field, but this is of niche use. so far
165 push @fields_pkg, sub { my $svc_x = shift;
166 my $cust_pkg = $svc_x->cust_svc->cust_pkg or return '';
168 if ($pkg_field eq 'package') {
169 $value = $cust_pkg->part_pkg->pkg;
170 #$value = $cust_pkg->pkg_label;
173 $value = $cust_pkg->get($pkg_field);#closures help alot
174 $value ? time2str('%b %d %Y', $value ) : '';