X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fbrowse%2Ftower.html;h=16e44c6c0c15ec8859ddb7d86d78d72111779768;hb=8bd159590e349d9d49855333bb770be3c2ba64c1;hp=660e92469fc8711fd8b169caafb18b0afe8b23e2;hpb=e6f7e02b32ebaa471230819d36a88f88b98bed6a;p=freeside.git diff --git a/httemplate/browse/tower.html b/httemplate/browse/tower.html index 660e92469..16e44c6c0 100644 --- a/httemplate/browse/tower.html +++ b/httemplate/browse/tower.html @@ -1,43 +1,114 @@ -<% include( 'elements/browse.html', - 'title' => 'Towers', - 'name' => 'towers', - 'menubar' => [ 'Add a new tower' => - $p.'edit/tower.html', - ], - 'query' => { 'table' => 'tower', }, - 'count_query' => 'SELECT COUNT(*) FROM tower', - 'disableable' => 1, - 'disabled_statuspos' => 1, - 'header' => [ 'Name', 'Sectors', ], - 'fields' => [ 'towername', - $sector_sub, - ], - 'links' => [ $link, - '', - ], - ) -%> +<& elements/browse.html, + 'title' => 'Towers', + 'name' => 'towers', + 'menubar' => [ 'Add a new tower' => + $p.'edit/tower.html', + 'Sector coverage maps' => + $p.'search/sector.html', + 'Download CSV for towercoverage.com' => + $p.'misc/tower-export.html?format=tc' + ], + 'query' => { 'table' => 'tower', }, + 'count_query' => 'SELECT COUNT(*) FROM tower', + 'disableable' => 1, + 'disabled_statuspos' => 1, + 'header' => [ 'Name', 'Location', 'Sectors', ], + 'fields' => [ $tower_sub, + $coord_sub, + $sector_sub, + ], + 'links' => [ ], + 'cell_style' => [ $tagdesc_style ], +&> <%init> die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); -my $link = [ "${p}edit/tower.html?", 'towernum' ]; +#false laziness w/ browse/part_tag.html +my $tagdesc_style = sub { 'background-color:#'.shift->color }; -my $sector_sub = sub { +my $num_svc_links = sub { + my ($query_string, $sectors) = @_; + return if !$sectors; + my $num_svc_broadband = FS::svc_broadband->count("sectornum IN($sectors)"); + my $num_svc_acct = FS::svc_acct->count("sectornum IN($sectors)"); + + { + 'data' => $num_svc_broadband ? + ''.$num_svc_broadband.''. + ' broadband' + : '', + 'link' => $p.'search/svc_broadband.cgi?'.$query_string, + 'size' => '-1', + 'align'=> 'right', + 'colspan'=> 2, + }, + + { + 'data' => $num_svc_acct ? + ''.$num_svc_acct.''. + ' login' + : '', + 'link' => $p.'search/svc_acct.cgi?magic=advanced;'.$query_string, + 'size' => '-1', + 'align'=> 'right', + 'colspan'=> 2, + }, +}; + +my $coord_sub = sub { my $tower = shift; - - [ map { - [ - { 'data' => $_->sectorname, - 'link' => ( $_->ip_addr ? 'http://'. $_->ip_addr : '' ), - }, - ], + my $coords = $m->scomp("/elements/coord-links.html", $tower->latitude, $tower->longitude, $tower->towername); + + [ + [ + { 'data' => "Latitude: ". $tower->latitude. + "
Longitude: ". $tower->longitude. + "
Altitude: ". $tower->altitude. + "
Height: ". $tower->height. + "
Veg. height: ". $tower->veg_height, + }, + { 'data' => $coords, 'link' => "Coordinates", }, + ], + ] +}; + +my $tower_sub = sub { + my $tower = shift; + my $sectors = join(',', + map { $_->sectornum } $tower->tower_sector, $tower->default_sector + ); + [ #rows + [ + { 'data' => $tower->towername. ' ', }, + { 'data' => ' (edit) ', size => '-1', + 'link' => $p.'edit/tower.html?' . $tower->towernum }, + ], + # turn these into rows + map { [ $_ ] } + &{$num_svc_links}( 'towernum='.$tower->towernum, $sectors ) + ] #rows +}; - } - $tower->tower_sector - ]; +my $sector_sub = sub { + my $tower = shift; + + [ #rows + map { + my $sector = $_; + my $sectornum = $sector->sectornum; + [ + { + 'data' => $sector->sectorname. ' ', + 'link' => ( $sector->ip_addr ? 'http://'. $sector->ip_addr : '' ), + }, + + &{$num_svc_links}( 'sectornum='.$sectornum, $sectornum ) + ] + } $tower->tower_sector + ] #rows };