X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=httemplate%2Felements%2Fselect-tower_sector.html;h=76ff252237785e83312b8bda937428c252ccc555;hb=d4114381c5d95e8acd0d0fc2bbc2b3528bde2ecf;hp=1973ef9c6bb01b6f2a6e0a43874658d8f6d032c9;hpb=fb4ab1073f0d15d660c6cdc4e07afebf68ef3924;p=freeside.git
diff --git a/httemplate/elements/select-tower_sector.html b/httemplate/elements/select-tower_sector.html
index 1973ef9c6..76ff25223 100644
--- a/httemplate/elements/select-tower_sector.html
+++ b/httemplate/elements/select-tower_sector.html
@@ -2,6 +2,8 @@
<& /elements/select-table.html,
table => 'tower_sector',
name_col => 'description',
+ addl_from => 'JOIN tower USING (towernum)',
+ extra_sql => q(WHERE disabled = '' OR disabled IS NULL),
order_by => 'ORDER BY towernum,sectorname',
empty_label => ' ',
@_
@@ -11,8 +13,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 +35,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';
%init>