X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Felements%2Fselect-tower_sector.html;h=59b0163595c58199bbcd93925af44977121799d3;hb=6776904eea418b12bec7f1aa0296e9384981d07a;hp=456ef410c6740a53d8eea64231232c7c945eadbb;hpb=f5aa3dd9639ac3d8655ae7452ceda5dc174db410;p=freeside.git diff --git a/httemplate/elements/select-tower_sector.html b/httemplate/elements/select-tower_sector.html index 456ef410c..59b016359 100644 --- a/httemplate/elements/select-tower_sector.html +++ b/httemplate/elements/select-tower_sector.html @@ -12,7 +12,7 @@ table => 'tower', name_col => 'towername', id => 'towernum', - field => 'dummy_towernum', + field => 'towernum', onchange => 'change_towernum(this.value);', element_etc => 'STYLE="vertical-align:top"', &> @@ -34,17 +34,34 @@ function change_towernum(towernum) { 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';