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
52 my $svcnum = $svc_broadband->svcnum;
53 my $color = $svc_broadband->addr_status_color;
57 id => 'svc_broadband/'.$svcnum,
60 coordinates => \@coord,
63 #content => include('.svc_broadband', $svc_broadband),
64 url => $fsurl . 'view/svc_broadband-popup.html?' . $svcnum,
72 # look up tower location and draw connecting line
73 next if !$svc_broadband->sectornum;
74 my $sector = $sectors{$svc_broadband->sectornum} ||= $svc_broadband->tower_sector;
75 my $towernum = $sector->towernum;
76 my $tower = $towers{$towernum};
79 $tower = $towers{$towernum} = $sector->tower;
80 $tower_coord{$towernum} =
81 [ $tower->longitude + 0,
83 ($tower->altitude || 0) + 0,
88 if ( $tower->latitude and $tower->longitude ) {
93 coordinates => [ \@coord, $tower_coord{$towernum} ],
97 strokeColor => $color,
103 # also extend tower's ROI to include this point
104 # (this is experimental; might get better results using the centroid of
105 # all connected services or something)
106 my $bounds = $tower_bounds{$towernum} ||= {
107 east => $tower->longitude,
108 west => $tower->longitude,
109 north => $tower->latitude,
110 south => $tower->latitude,
112 if ($coord[0] > $bounds->{east}) {
113 $bounds->{east} = $coord[0];
114 } elsif ($coord[0] < $bounds->{west}) {
115 $bounds->{west} = $coord[0];
117 if ($coord[1] > $bounds->{north}) {
118 $bounds->{north} = $coord[1]
119 } elsif ($coord[1] < $bounds->{south}) {
120 $bounds->{south} = $coord[1]
123 } # if tower has coords
124 } # foreach $svc_broadband
126 foreach my $tower (values(%towers)) {
127 my $towernum = $tower->towernum;
128 my $bounds = $tower_bounds{$towernum};
129 # add some padding for easier reading
130 my $dx = 0.1 * ($bounds->{east} - $bounds->{west});
131 my $dy = 0.1 * ($bounds->{north} - $bounds->{south});
132 $bounds->{east} += $dx;
133 $bounds->{west} -= $dx;
134 $bounds->{north} += $dy;
135 $bounds->{south} -= $dy;
138 id => 'tower/'.$towernum,
141 coordinates => $tower_coord{$towernum},
147 url => $fsurl.'images/antenna-square-21x51.png',
148 anchor => { x => 10, y => 4 }
151 content => include('.tower', $tower),
152 bounds => $tower_bounds{$towernum},
158 foreach my $sector (values %sectors) {
159 if ( length($sector->image) > 0 ) {
161 url => $fsurl.'view/sector_map-png.cgi?' . $sector->sectornum
163 foreach (qw(south north west east)) {
164 $o->{$_} = $sector->get($_) + 0;
173 % my $can_edit = $FS::CurrentUser::CurrentUser->access_right('Configuration');
176 <a target="_blank" href="<% $fsurl %>edit/tower.html?<% $tower->towernum %>">
178 Tower #<% $tower->towernum %> | <% $tower->towername %>