<%shared> # kind of a hack... my ($export) = FS::tower_sector->part_export; my $antenna_types; # will be an ordered hash if ($export and $export->can('get_antenna_types')) { $antenna_types = $export->get_antenna_types; } <%init> my %opt = @_; my $tower = $opt{'object'}; my $towernum = $tower->towernum; my $cgi = $opt{'cgi'}; my $tabcounter = 0; my @fields = qw( sectorname ip_addr height freq_mhz direction width downtilt v_width db_high db_low sector_range power line_loss antenna_gain hardware_typenum up_rate_limit down_rate_limit ); my @sectors; if ( $cgi->param('error') ) { foreach my $k ($cgi->param) { if ($k =~ /^sectornum\d+$/) { my $sectornum = $cgi->param($k); my $sector = FS::tower_sector->new({ 'sectornum' => $sectornum, 'towernum' => $towernum, map { $_ => scalar($cgi->param($k.'_'.$_)) } @fields, }); push @sectors, $sector if length($sector->sectorname); } } } elsif ( $towernum ) { @sectors = $tower->tower_sector; } # else new mode, no sectors yet my $id = $opt{id} || $opt{field} || 'sectornum'; <& tablebreak-tr-title.html, value => 'Sectors' &> %# prototypes
<& .tab, id => $id . '_P' &> <& .panel, id => $id . '_P' &>
%# main container
% $tabcounter = 0; % foreach my $sector (@sectors) { <& .panel, sector => $sector, id => $id . $tabcounter &> % $tabcounter++; % }
<%def .tab> % my %opt = @_; % my $sector = $opt{sector}; % my $id = $opt{id}; % my $title = $sector ? $sector->sectorname : mt('Add new');
  • <% $title |h %>
  • <%def .panel> % my %opt = @_; % my $sector = $opt{sector} || FS::tower_sector->new({}); % my $id = $opt{id}; # sectornumX
    % # no id on this one, the panel gets the "sectornumX" id

    <% emt('feet above ground') %>

    ° °

    <% emt('MHz') %>

    <% emt('dBm') %>
    <% emt('dB antenna gain') %>
    <% emt('dB line loss') %> % if ( $antenna_types ) {

    <& /elements/select.html, field => $id.'_hardware_typenum', options => [ '', keys %$antenna_types ], labels => $antenna_types, curr_value => $sector->hardware_typenum, &>

    % } % # this next section might not be necessary if you enter an antenna type

    ° °

    <% emt('dB (high quality)') %>
    <% emt('dB (low quality)') %>