1 <& /elements/header.html, 'Broadband Search Results' &>
3 <& elements/gmap.html, features => \@features &>
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 my $tower = $towers{$towernum};
80 if ( $tower->latitude and $tower->longitude ) {
85 coordinates => [ \@coord, $tower_coord{$towernum} ],
89 strokeColor => ($tower->color || 'green'),
95 # also extend tower's ROI to include this point
96 # (this is experimental; might get better results using the centroid of
97 # all connected services or something)
98 my $bounds = $tower_bounds{$towernum} ||= {
99 east => $tower->longitude,
100 west => $tower->longitude,
101 north => $tower->latitude,
102 south => $tower->latitude,
104 if ($coord[0] > $bounds->{east}) {
105 $bounds->{east} = $coord[0];
106 } elsif ($coord[0] < $bounds->{west}) {
107 $bounds->{west} = $coord[0];
109 if ($coord[1] > $bounds->{north}) {
110 $bounds->{north} = $coord[1]
111 } elsif ($coord[1] < $bounds->{south}) {
112 $bounds->{south} = $coord[1]
115 } # if tower has coords
116 } # foreach $svc_broadband
118 foreach my $tower (values(%towers)) {
119 my $towernum = $tower->towernum;
120 my $bounds = $tower_bounds{$towernum};
121 # add some padding for easier reading
122 my $dx = 0.1 * ($bounds->{east} - $bounds->{west});
123 my $dy = 0.1 * ($bounds->{north} - $bounds->{south});
124 $bounds->{east} += $dx;
125 $bounds->{west} -= $dx;
126 $bounds->{north} += $dy;
127 $bounds->{south} -= $dy;
130 id => 'tower/'.$towernum,
133 coordinates => $tower_coord{$towernum},
139 url => $fsurl.'images/jcartier-antenna-square-21x51.png',
140 anchor => { x => 10, y => 4 }
143 content => include('.tower', $tower),
144 bounds => $tower_bounds{$towernum},
150 <%def .svc_broadband>
152 % my @label = $svc->cust_svc->label;
154 <a target="_blank" href="<% $fsurl %>view/svc_broadband.cgi?<% $svc->svcnum %>">
155 <% $label[0] |h %> #<% $svc->svcnum %> | <% $label[1] %>
158 % my $cust_main = $svc->cust_main;
159 <a target="_blank" href="<% $fsurl %>view/cust_main.cgi?<% $cust_main->custnum %>">
160 <& /elements/small_custview.html, {
161 cust_main => $svc->cust_main,
162 #url => $fsurl.'view/cust_main.cgi',
168 % my $can_edit = $FS::CurrentUser::CurrentUser->access_right('Configuration');
171 <a target="_blank" href="<% $fsurl %>edit/tower.html?<% $tower->towernum %>">
173 Tower #<% $tower->towernum %> | <% $tower->towername %>