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' ],
15 FS::UI::Web::cust_header($cgi->param('cust_fields')),
17 'fields' => [ 'svcnum',
20 my $router = shift->router;
21 $router ? $router->routername : '';
27 $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
28 return '' unless $cust_pkg_cache{$_[0]->svcnum};
29 $cust_pkg_cache{$_[0]->svcnum}->ucfirst_status
31 \&FS::UI::Web::cust_fields,
36 (map '', @tower_fields),
40 ( map { $_ ne 'Cust. Status' ? $link_cust : '' }
41 FS::UI::Web::cust_header($cgi->param('cust_fields'))
44 'align' => 'rll'.('r' x @tower_fields).
48 FS::UI::Web::cust_aligns(),
53 (map '', @tower_fields),
57 $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
58 return '' unless $cust_pkg_cache{$_[0]->svcnum};
59 my $c = FS::cust_pkg::statuscolors;
60 $c->{$cust_pkg_cache{$_[0]->svcnum}->status };
62 FS::UI::Web::cust_colors(),
68 (map '', @tower_fields),
72 FS::UI::Web::cust_styles(),
78 die "access denied" unless
79 $FS::CurrentUser::CurrentUser->access_right('List services');
83 my $conf = new FS::Conf;
86 if ( $cgi->param('magic') eq 'unlinked' ) {
87 %search_hash = ( 'unlinked' => 1 );
89 foreach (qw( custnum agentnum svcpart cust_fields )) {
90 $search_hash{$_} = $cgi->param($_) if $cgi->param($_);
92 foreach (qw(pkgpart routernum towernum sectornum)) {
93 $search_hash{$_} = [ $cgi->param($_) ] if $cgi->param($_);
95 if ( defined($cgi->param('cancelled')) ) {
96 $search_hash{'cancelled'} = $cgi->param('cancelled') ? 1 : 0;
100 if ( $cgi->param('sortby') =~ /^(\w+)$/ ) {
101 $search_hash{'order_by'} = "ORDER BY $1";
104 my $sql_query = FS::svc_broadband->search(\%search_hash);
108 if ( FS::tower_sector->count > 0 ) {
109 push @tower_header, 'Tower/Sector';
110 push @tower_fields, sub { $_[0]->tower_sector ?
111 $_[0]->tower_sector->description : '' };
114 my %routerbyblock = ();
115 foreach my $router (qsearch('router', {})) {
116 foreach ($router->addr_block) {
117 $routerbyblock{$_->blocknum} = $router;
121 my $link = [ $p.'view/svc_broadband.cgi?', 'svcnum' ];
123 #XXX get the router link working
124 #my $link_router = sub {
125 # my $routernum = $routerbyblock{shift->blocknum}->routernum;
126 # [ $p.'view/router.cgi?'.$routernum, 'routernum' ];
129 my $link_cust = [ $p.'view/cust_main.cgi?', 'custnum' ];
131 my $html_init = include('/elements/email-link.html',
132 'search_hash' => \%search_hash,
133 'table' => 'svc_broadband'
135 $html_init .= ' | ' .
137 $fsurl . 'search/svc_broadband-map.html?' . $cgi->query_string .
138 '">' . emt('View a map of these services') . '</a>';
140 my (@header_pkg,@fields_pkg,@blank_pkg);
142 #false laziness with search/svc_acct.cgi
143 $cgi->param('cust_pkg_fields') =~ /^([\w\,]*)$/ or die "bad cust_pkg_fields";
144 my @pkg_fields = split(',', $1);
145 foreach my $pkg_field ( @pkg_fields ) {
146 ( my $header = ucfirst($pkg_field) ) =~ s/_/ /; #:/
147 push @header_pkg, $header;
149 #not the most efficient to do it every field, but this is of niche use. so far
150 push @fields_pkg, sub { my $svc_x = shift;
151 my $cust_pkg = $svc_x->cust_svc->cust_pkg or return '';
153 if ($pkg_field eq 'package') {
154 $value = $cust_pkg->part_pkg->pkg;
155 #$value = $cust_pkg->pkg_label;
158 $value = $cust_pkg->get($pkg_field);#closures help alot
159 $value ? time2str('%b %d %Y', $value ) : '';