1 % if ( ! $opt{'multiple'} ) {
2 <& /elements/select-table.html,
3 table => 'tower_sector',
4 name_col => 'description',
5 addl_from => 'JOIN tower USING (towernum)',
6 extra_sql => q(WHERE disabled = '' OR disabled IS NULL),
7 order_by => 'ORDER BY towernum,sectorname',
12 % else { # currently only multiple sectors, not towers
13 <& /elements/select-table.html,
15 name_col => 'towername',
16 hashref => { 'disabled' => '', },
19 onchange => 'change_towernum(this.value);',
20 element_etc => 'STYLE="vertical-align:top"',
22 <SELECT NAME="sectornum" ID="sectornum" MULTIPLE SIZE="6"></SELECT>
23 <SCRIPT TYPE="text/javascript">
24 var sectors_of = <% encode_json(\%sectors_of) %>;
25 var select_sectornum = document.getElementById('sectornum');
26 function change_towernum(towernum) {
27 select_sectornum.options.length = 0;
28 for (var sectornum in sectors_of[towernum]) {
29 var o = document.createElement('OPTION');
31 o.text = sectors_of[towernum][sectornum];
33 select_sectornum.add(o, null);
40 <INPUT TYPE="checkbox" VALUE="none" NAME="sectornum" CHECKED> <% $empty_label %>
47 if ( $opt{'multiple'} ) {
48 foreach my $sector ( qsearch('tower_sector',{}) ) {
49 $sectors_of{$sector->towernum} ||= {};
50 $sectors_of{$sector->towernum}->{$sector->sectornum} = $sector->sectorname;
51 $sectors_of{''}->{$sector->sectornum} = $sector->description;
52 $default_of{$sector->towernum} = $sector->sectornum
53 if $sector->sectorname eq '_default';
56 foreach my $towernum (keys %sectors_of) {
57 # hide default sectors for towers that have real sectors defined
58 my $sectornum = $default_of{$towernum};
59 if ( keys %{ $sectors_of{$towernum} } > 1 ) {
60 delete $sectors_of{$towernum}->{$sectornum};
61 delete $sectors_of{''}->{$sectornum};
64 # show default sectorname as '(all)'
65 $sectors_of{$towernum}->{$sectornum} = '(all)'
69 my $empty_label = $opt{'empty_label'} || 'Include services with no sector';