3 my ($export) = FS::tower_sector->part_export;
4 my $antenna_types; # will be an ordered hash
5 if ($export and $export->can('get_antenna_types')) {
6 $antenna_types = $export->get_antenna_types;
11 my $tower = $opt{'object'};
12 my $towernum = $tower->towernum;
13 my $cgi = $opt{'cgi'};
18 sectorname ip_addr height freq_mhz direction width downtilt v_width
19 db_high db_low sector_range
20 power line_loss antenna_gain hardware_typenum up_rate_limit down_rate_limit
24 if ( $cgi->param('error') ) {
25 foreach my $k ($cgi->param) {
26 if ($k =~ /^sectornum\d+$/) {
27 my $sectornum = $cgi->param($k);
28 my $sector = FS::tower_sector->new({
29 'sectornum' => $sectornum,
30 'towernum' => $towernum,
31 map { $_ => scalar($cgi->param($k.'_'.$_)) } @fields,
33 push @sectors, $sector if length($sector->sectorname);
36 } elsif ( $towernum ) {
37 @sectors = $tower->tower_sector;
38 } # else new mode, no sectors yet
40 my $id = $opt{id} || $opt{field} || 'sectornum';
43 <& tablebreak-tr-title.html, value => 'Sectors' &>
51 border-top-left-radius: 0.5em;
52 border-top-right-radius: 0.5em;
55 border-bottom-color: #fff;
63 display: inline-block;
66 .ui-tabs input, .ui-spinner {
67 border: 1px solid #666;
74 .ui-tabs input { /* but not spinner, messes it up */
78 .ui-tabs input:focus {
79 border-color: #7e0079;
80 background-color: #ffffdd;
82 .ui-spinner input { /* use the spinner's border and padding */
97 <div style="display: none">
98 <& .tab, id => $id . '_P' &>
99 <& .panel, id => $id . '_P' &>
103 <div id="<% $id %>_tabs">
105 % foreach my $sector (@sectors) {
106 <& .tab, sector => $sector, id => $id . $tabcounter &>
112 % foreach my $sector (@sectors) {
113 <& .panel, sector => $sector, id => $id . $tabcounter &>
121 var tabcounter = <% $tabcounter %>;
122 var id = <% $id |js_string %>;
124 var tabs = $( '#'+id+'_tabs' ).tabs();
126 function changedSectorName() {
127 var this_panel = $(this).closest('div');
128 var this_tab = tabs.find('#' + this_panel.prop('id') + '_tab');
129 // if this is the last panel, make a new one
130 if (this_panel.next().length == 0) {
133 // and update the current tab's text with the sector name
134 this_tab.find('a').text($(this).val());
137 var tab_proto = $('#'+id+'_P_tab');
138 var panel_proto = $('#'+id+'_P');
140 function addSector() {
141 var new_tab = tab_proto.clone();
142 var new_panel = panel_proto.clone();
143 // replace proto placeholder with the counter value, in all id and
144 // name properties in new_panel and its children
145 new_panel.add( new_panel.find('*') ).each(function() {
146 this.id = this.id.replace('_P', tabcounter);
148 this.name = this.name.replace('_P', tabcounter);
152 // and set the handler up on it
153 new_panel.find('.input-sectorname').on('change', changedSectorName);
155 // also update the tab itself
156 new_tab.find('a').prop('href', '#' + new_panel.prop('id'));
157 new_tab.prop('id', new_panel.prop('id') + '_tab');
159 tabs.append(new_panel);
160 tabs.children('ul:first').append(new_tab);
162 tabs.tabs('refresh');
165 $('.dbspinner').spinner({ step: 5 });
167 $('.input-sectorname').on('change', changedSectorName);
174 % my $sector = $opt{sector};
176 % my $title = $sector ? $sector->sectorname : mt('Add new');
177 <li id="<% $id %>_tab">
178 <a href="#<% $id %>"><% $title |h %></a>
183 % my $sector = $opt{sector} || FS::tower_sector->new({});
184 % my $id = $opt{id}; # sectornumX
186 % # no id on this one, the panel gets the "sectornumX" id
187 <input type="hidden" name="<% $id %>" value="<% $sector->sectornum |h %>">
189 <label><% emt('Sector name') %></label>
190 <input style="text-align: left"
191 class="input-sectorname"
192 id="<% $id %>_sectorname"
193 name="<% $id %>_sectorname"
194 value="<% $sector->sectorname |h %>">
196 <label><% emt('IP address') %></label>
197 <input style="text-align: left"
198 id="<% $id %>_ip_addr"
199 name="<% $id %>_ip_addr"
200 value="<% $sector->ip_addr |h %>">
203 <label for="<% $id %>_height"><% emt('Antenna height') %></label>
205 id="<% $id %>_height"
206 name="<% $id %>_height"
207 value="<% $sector->height |h %>">
208 <% emt('feet above ground') %>
211 <label for="<% $id %>_direction"><% emt('Azimuth') %></label>
213 id="<% $id %>_direction"
214 name="<% $id %>_direction"
215 value="<% $sector->direction |h %>">°
216 <label for="<% $id %>_downtilt"><% emt('Down tilt') %></label>
218 id="<% $id %>_downtilt"
219 name="<% $id %>_downtilt"
220 value="<% $sector->downtilt |h %>">°
224 <label for="<% $id %>_freq_mhz"><% emt('Frequency') %></label>
226 id="<% $id %>_freq_mhz"
227 name="<% $id %>_freq_mhz"
228 value="<% $sector->freq_mhz |h %>">
233 <label for="<% $id %>_power"><% emt('Transmit power') %></label>
236 name="<% $id %>_power"
237 value="<% $sector->power |h %>">
239 <label for="<% $id %>_antenna_gain">+ </label>
241 id="<% $id %>_antenna_gain"
242 name="<% $id %>_antenna_gain"
243 value="<% $sector->antenna_gain |h %>">
244 <% emt('dB antenna gain') %><br>
245 <label for="<% $id %>_line_loss">– </label>
247 id="<% $id %>_line_loss"
248 name="<% $id %>_line_loss"
249 value="<% $sector->line_loss |h %>">
250 <% emt('dB line loss') %>
252 % if ( $antenna_types ) {
254 <label for="<% $id %>_hardware_typenum"><% emt('Antenna type') %></label>
255 <& /elements/select.html,
256 field => $id.'_hardware_typenum',
257 options => [ '', keys %$antenna_types ],
258 labels => $antenna_types,
259 curr_value => $sector->hardware_typenum,
263 % # this next section might not be necessary if you enter an antenna type
265 <label for="<% $id %>_width"><% emt('Horizontal beam') %></label>
268 name="<% $id %>_width"
269 value="<% $sector->width |h %>">°
270 <label for="<% $id %>_v_width"><% emt('Vertical beam') %></label>
272 id="<% $id %>_v_width"
273 name="<% $id %>_v_width"
274 value="<% $sector->v_width |h %>">°
277 <label><% emt('Signal margin') %></label>
278 <div style="display: inline-block; vertical-align: top">
279 <input class="dbspinner"
281 id="<% $id %>_db_high"
282 name="<% $id %>_db_high"
283 value="<% $sector->db_high |h %>">
284 <% emt('dB (high quality)') %>
287 <input class="dbspinner"
289 id="<% $id %>_db_low"
290 name="<% $id %>_db_low"
291 value="<% $sector->db_low |h %>">
292 <% emt('dB (low quality)') %>
295 <label><% emt('Up Rate (Kbps)') %></label>
296 <input style="text-align: left"
297 id="<% $id %>_up_rate_limit"
298 name="<% $id %>_up_rate_limit"
299 value="<% $sector->up_rate_limit |h %>">
302 <label><% emt('Down Rate (Kbps)') %></label>
303 <input style="text-align: left"
304 id="<% $id %>_down_rate_limit"
305 name="<% $id %>_down_rate_limit"
306 value="<% $sector->down_rate_limit |h %>">