X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Felements%2Fselect-tower_sector.html;h=458bcddcfb50750ea1b4d84c610b963137dd463a;hp=1973ef9c6bb01b6f2a6e0a43874658d8f6d032c9;hb=58d388d4354f18477e9863ad95c78e73772d1768;hpb=fb4ab1073f0d15d660c6cdc4e07afebf68ef3924 diff --git a/httemplate/elements/select-tower_sector.html b/httemplate/elements/select-tower_sector.html index 1973ef9c6..458bcddcf 100644 --- a/httemplate/elements/select-tower_sector.html +++ b/httemplate/elements/select-tower_sector.html @@ -11,8 +11,9 @@ <& /elements/select-table.html, table => 'tower', name_col => 'towername', + hashref => { 'disabled' => '', }, id => 'towernum', - field => 'dummy_towernum' + field => 'towernum', onchange => 'change_towernum(this.value);', element_etc => 'STYLE="vertical-align:top"', &> @@ -32,19 +33,36 @@ function change_towernum(towernum) { return; } change_towernum(''); -% }
- No sector + <% $empty_label %> +% } <%init> my %opt = @_; my %sectors_of; +my %default_of; if ( $opt{'multiple'} ) { foreach my $sector ( qsearch('tower_sector',{}) ) { $sectors_of{$sector->towernum} ||= {}; $sectors_of{$sector->towernum}->{$sector->sectornum} = $sector->sectorname; $sectors_of{''}->{$sector->sectornum} = $sector->description; + $default_of{$sector->towernum} = $sector->sectornum + if $sector->sectorname eq '_default'; + } +} +foreach my $towernum (keys %sectors_of) { + # hide default sectors for towers that have real sectors defined + my $sectornum = $default_of{$towernum}; + if ( keys %{ $sectors_of{$towernum} } > 1 ) { + delete $sectors_of{$towernum}->{$sectornum}; + delete $sectors_of{''}->{$sectornum}; + } + else { + # show default sectorname as '(all)' + $sectors_of{$towernum}->{$sectornum} = '(all)' } } + +my $empty_label = $opt{'empty_label'} || 'Include services with no sector';