1 <& /elements/header.html, 'Broadband Search Results' &>
3 <& elements/gmap.html, features => \@features, overlays => \@overlays &>
5 <& /elements/footer.html &>
8 die "access denied" unless
9 $FS::CurrentUser::CurrentUser->access_right('List services');
11 my $conf = new FS::Conf;
13 my @features; # geoJSON structure
15 # accept all the search logic from svc_broadband.cgi...
17 if ( $cgi->param('magic') eq 'unlinked' ) {
18 %search_hash = ( 'unlinked' => 1 );
20 foreach (qw( custnum agentnum svcpart cust_fields )) {
21 $search_hash{$_} = $cgi->param($_) if $cgi->param($_);
23 foreach (qw(pkgpart routernum towernum sectornum)) {
24 $search_hash{$_} = [ $cgi->param($_) ] if $cgi->param($_);
28 if ( $cgi->param('sortby') =~ /^(\w+)$/ ) {
29 $search_hash{'order_by'} = "ORDER BY $1";
32 my $sql_query = FS::svc_broadband->search(\%search_hash);
34 my %routerbyblock = ();
36 my @rows = qsearch($sql_query);
41 foreach my $svc_broadband (@rows) {
42 # don't try to show it if coords aren't set
43 next if !$svc_broadband->latitude || !$svc_broadband->longitude;
44 # coerce coordinates to numbers
46 $svc_broadband->longitude + 0,
47 $svc_broadband->latitude + 0,
49 push @coord, $svc_broadband->altitude + 0
50 if length($svc_broadband->altitude); # it's optional
54 id => 'svc_broadband/'.$svc_broadband->svcnum,
57 coordinates => \@coord,
60 content => include('.svc_broadband', $svc_broadband),
63 # look up tower location and draw connecting line
64 next if !$svc_broadband->sectornum;
65 my $sector = $sectors{$svc_broadband->sectornum} ||= $svc_broadband->tower_sector;
66 my $towernum = $sector->towernum;
67 my $tower = $towers{$towernum};
70 $tower = $towers{$towernum} = $sector->tower;
71 $tower_coord{$towernum} =
72 [ $tower->longitude + 0,
74 ($tower->altitude || 0) + 0,
79 if ( $tower->latitude and $tower->longitude ) {
84 coordinates => [ \@coord, $tower_coord{$towernum} ],
88 strokeColor => ($tower->color || 'green'),
94 # also extend tower's ROI to include this point
95 # (this is experimental; might get better results using the centroid of
96 # all connected services or something)
97 my $bounds = $tower_bounds{$towernum} ||= {
98 east => $tower->longitude,
99 west => $tower->longitude,
100 north => $tower->latitude,
101 south => $tower->latitude,
103 if ($coord[0] > $bounds->{east}) {
104 $bounds->{east} = $coord[0];
105 } elsif ($coord[0] < $bounds->{west}) {
106 $bounds->{west} = $coord[0];
108 if ($coord[1] > $bounds->{north}) {
109 $bounds->{north} = $coord[1]
110 } elsif ($coord[1] < $bounds->{south}) {
111 $bounds->{south} = $coord[1]
114 } # if tower has coords
115 } # foreach $svc_broadband
117 foreach my $tower (values(%towers)) {
118 my $towernum = $tower->towernum;
119 my $bounds = $tower_bounds{$towernum};
120 # add some padding for easier reading
121 my $dx = 0.1 * ($bounds->{east} - $bounds->{west});
122 my $dy = 0.1 * ($bounds->{north} - $bounds->{south});
123 $bounds->{east} += $dx;
124 $bounds->{west} -= $dx;
125 $bounds->{north} += $dy;
126 $bounds->{south} -= $dy;
129 id => 'tower/'.$towernum,
132 coordinates => $tower_coord{$towernum},
138 url => $fsurl.'images/jcartier-antenna-square-21x51.png',
139 anchor => { x => 10, y => 4 }
142 content => include('.tower', $tower),
143 bounds => $tower_bounds{$towernum},
149 foreach my $sector (values %sectors) {
150 if ( length($sector->image) > 0 ) {
152 url => $fsurl.'view/sector_map-png.cgi?' . $sector->sectornum
154 foreach (qw(south north west east)) {
155 $o->{$_} = $sector->get($_) + 0;
162 <%def .svc_broadband>
164 % my @label = $svc->cust_svc->label;
166 <a target="_blank" href="<% $fsurl %>view/svc_broadband.cgi?<% $svc->svcnum %>">
167 <% $label[0] |h %> #<% $svc->svcnum %> | <% $label[1] %>
170 % my $cust_main = $svc->cust_main;
171 <a target="_blank" href="<% $fsurl %>view/cust_main.cgi?<% $cust_main->custnum %>">
172 <& /elements/small_custview.html, {
173 cust_main => $svc->cust_main,
174 #url => $fsurl.'view/cust_main.cgi',
180 % my $can_edit = $FS::CurrentUser::CurrentUser->access_right('Configuration');
183 <a target="_blank" href="<% $fsurl %>edit/tower.html?<% $tower->towernum %>">
185 Tower #<% $tower->towernum %> | <% $tower->towername %>