3 my $tower = $opt{'object'};
4 my $towernum = $tower->towernum;
10 sectorname ip_addr height freq_mhz direction width tilt v_width db_high
15 if ( $cgi->param('error') ) {
16 foreach my $k ($cgi->param) {
17 if ($k =~ /^sectornum\d+$/) {
18 my $sectornum = $cgi->param($k);
19 my $sector = FS::tower_sector->new({
20 'sectornum' => $sectornum,
21 'towernum' => $towernum,
22 map { $_ => scalar($cgi->param($k.'_'.$_)) } @fields,
24 push @sectors, $sector if length($sector->sectorname);
27 } elsif ( $towernum ) {
28 @sectors = $tower->tower_sector;
29 } # else new mode, no sectors yet
31 my $id = $opt{id} || $opt{field} || 'sectornum';
34 <& tablebreak-tr-title.html, %opt &>
42 border-top-left-radius: 0.5em;
43 border-top-right-radius: 0.5em;
46 border-bottom-color: #fff;
54 display: inline-block;
57 .ui-tabs input, .ui-spinner {
58 border: 1px solid #666;
65 .ui-tabs input { /* but not spinner, messes it up */
69 .ui-tabs input:focus {
70 border-color: #7e0079;
71 background-color: #ffffdd;
73 .ui-spinner input { /* use the spinner's border and padding */
83 <div style="display: none">
84 <& .tab, id => $id . '_P' &>
85 <& .panel, id => $id . '_P' &>
89 <div id="<% $id %>_tabs">
91 % foreach my $sector (@sectors) {
92 <& .tab, sector => $sector, id => $id . $tabcounter &>
98 % foreach my $sector (@sectors) {
99 <& .panel, sector => $sector, id => $id . $tabcounter &>
107 var tabcounter = <% $tabcounter %>;
108 var id = <% $id |js_string %>;
110 var tabs = $( '#'+id+'_tabs' ).tabs();
112 function changedSectorName() {
113 var this_panel = $(this).parent();
114 var this_tab = tabs.find('#' + this_panel.prop('id') + '_tab');
115 // if this is the last panel, make a new one
116 if (this_panel.next().length == 0) {
117 addSector(this_panel);
119 // and update the current tab's text with the sector name
120 this_tab.find('a').text($(this).val());
123 var tab_proto = $('#'+id+'_P_tab');
124 var panel_proto = $('#'+id+'_P');
126 function addSector() {
127 var new_tab = tab_proto.clone();
128 var new_panel = panel_proto.clone();
129 // replace proto placeholder with the counter value, in all id and
130 // name properties in new_panel and its children
131 new_panel.add( new_panel.find('*') ).each(function() {
132 this.id = this.id.replace('_P', tabcounter);
134 this.name = this.name.replace('_P', tabcounter);
138 // and set the handler up on it
139 new_panel.find('.input-sectorname').on('change', changedSectorName);
141 // also update the tab itself
142 new_tab.find('a').prop('href', '#' + new_panel.prop('id'));
143 new_tab.prop('id', new_panel.prop('id') + '_tab');
145 tabs.append(new_panel);
146 tabs.children('ul:first').append(new_tab);
148 tabs.tabs('refresh');
151 $('.dbspinner').spinner({ step: 5 });
153 $('.input-sectorname').on('change', changedSectorName);
160 % my $sector = $opt{sector};
162 % my $title = $sector ? $sector->sectorname : mt('Add new');
163 <li id="<% $id %>_tab">
164 <a href="#<% $id %>"><% $title |h %></a>
169 % my $sector = $opt{sector} || FS::tower_sector->new({});
170 % my $id = $opt{id}; # sectornumX
172 % # no id on this one, the panel gets the "sectornumX" id
173 <input type="hidden" name="<% $id %>" value="<% $sector->sectornum |h %>">
175 <label><% emt('Sector name') %></label>
176 <input style="text-align: left"
177 class="input-sectorname"
178 id="<% $id %>_sectorname"
179 name="<% $id %>_sectorname"
180 value="<% $sector->sectorname |h %>">
182 <label><% emt('IP address') %></label>
183 <input style="text-align: left"
184 id="<% $id %>_ip_addr"
185 name="<% $id %>_ip_addr"
186 value="<% $sector->ip_addr |h %>">
189 <label for="<% $id %>_height"><% emt('Antenna height') %></label>
191 id="<% $id %>_height"
192 name="<% $id %>_height"
193 value="<% $sector->height |h %>">
194 <% emt('feet above ground') %>
197 <label for="<% $id %>_direction"><% emt('Azimuth') %></label>
199 id="<% $id %>_direction"
200 name="<% $id %>_direction"
201 value="<% $sector->direction |h %>">°
202 <label for="<% $id %>_downtilt"><% emt('Down tilt') %></label>
204 id="<% $id %>_downtilt"
205 name="<% $id %>_downtilt"
206 value="<% $sector->downtilt |h %>">°
210 <label for="<% $id %>_freq_mhz"><% emt('Frequency') %></label>
212 id="<% $id %>_freq_mhz"
213 name="<% $id %>_freq_mhz"
214 value="<% $sector->freq_mhz |h %>">
219 <label for="<% $id %>_width"><% emt('Horizontal beam') %></label>
222 name="<% $id %>_width"
223 value="<% $sector->width |h %>">°
224 <label for="<% $id %>_v_width"><% emt('Vertical beam') %></label>
226 id="<% $id %>_v_width"
227 name="<% $id %>_v_width"
228 value="<% $sector->v_width |h %>">°
231 <label><% emt('Signal margin') %></label>
232 <div style="display: inline-block; vertical-align: top">
233 <input class="dbspinner"
235 id="<% $id %>_db_high"
236 name="<% $id %>_db_high"
237 value="<% $sector->db_high |h %>">
238 <% emt('dB (high quality)') %>
241 <input class="dbspinner"
243 id="<% $id %>_db_low"
244 name="<% $id %>_db_low"
245 value="<% $sector->db_low |h %>">
246 <% emt('dB (low quality)') %>