allow services with a tower but no sector to appear in search results, #33056
authorMark Wells <mark@freeside.biz>
Tue, 1 Sep 2015 05:16:37 +0000 (22:16 -0700)
committerMark Wells <mark@freeside.biz>
Tue, 1 Sep 2015 05:17:07 +0000 (22:17 -0700)
FS/FS/svc_Tower_Mixin.pm
httemplate/elements/select-tower_sector.html

index 2555b9e..d677679 100644 (file)
@@ -27,7 +27,13 @@ sub tower_sector_sql {
       my $in = join(',', map { /^(\d+)$/ ? $1 : () } @$value);
       my @orwhere;
       push @orwhere, "tower_sector.$field IN ($in)" if $in;
-      push @orwhere, "tower_sector.$field IS NULL" if grep /^none$/, @$value;
+      if ( grep /^none$/, @$value ) {
+        # then allow this field to be null
+        push @orwhere, "tower_sector.$field IS NULL";
+        # and if this field is the sector, also allow the default sector
+        # on the tower
+        push @orwhere, "sectorname = '_default'" if $field eq 'sectornum';
+      }
       push @where, '( '.join(' OR ', @orwhere).' )';
     }
     elsif ( $value =~ /^(\d+)$/ ) {
index a16d3bf..59b0163 100644 (file)
@@ -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"',
 &>
@@ -63,5 +63,5 @@ foreach my $towernum (keys %sectors_of) {
   }
 }
 
-my $empty_label = $opt{'empty_label'} || 'Include services with no tower/sector';
+my $empty_label = $opt{'empty_label'} || 'Include services with no sector';
 </%init>