fix 477 package links, RT#13922
authorivan <ivan>
Thu, 18 Aug 2011 23:29:29 +0000 (23:29 +0000)
committerivan <ivan>
Thu, 18 Aug 2011 23:29:29 +0000 (23:29 +0000)
FS/FS/cust_pkg.pm
httemplate/search/477partVI_census.html

index 44c103f..20e3d44 100644 (file)
@@ -2987,6 +2987,7 @@ sub search {
       } elsif ( @c_where ) {
         push @where, ' ( '. join(' OR ', @c_where). ' ) ';
       }
+      warn $where[-1];
 
     }
     
@@ -2998,11 +2999,13 @@ sub search {
   ###
 
   my @report_option = ();
-  if ( exists($params->{'report_option'})
-       && $params->{'report_option'} =~ /^([,\d]*)$/
-     )
-  {
-    @report_option = split(',', $1);
+  if ( exists($params->{'report_option'}) ) {
+    if ( ref($params->{'report_option'}) eq 'ARRAY' ) {
+      @report_option = @{ $params->{'report_option'} };
+    } elsif ( $params->{'report_option'} =~ /^([,\d]*)$/ ) {
+      @report_option = split(',', $1);
+    }
+
   }
 
   if (@report_option) {
@@ -3015,7 +3018,26 @@ sub search {
          } @report_option;
   }
 
-  #eslaf
+  my @report_option_any = ();
+  if ( exists($params->{'report_option_any'}) ) {
+    if ( ref($params->{'report_option_any'}) eq 'ARRAY' ) {
+      @report_option_any = @{ $params->{'report_option_any'} };
+    } elsif ( $params->{'report_option_any'} =~ /^([,\d]*)$/ ) {
+      @report_option_any = split(',', $1);
+    }
+
+  }
+
+  if (@report_option_any) {
+    # this will result in the empty set for the dangling comma case as it should
+    push @where, ' ( '. join(' OR ',
+      map{ "0 < ( SELECT count(*) FROM part_pkg_option
+                    WHERE part_pkg_option.pkgpart = part_pkg.pkgpart
+                    AND optionname = 'report_option_$_'
+                    AND optionvalue = '1' )"
+         } @report_option_any
+    ). ' ) ';
+  }
 
   ###
   # parse custom
index 9256b86..b604353 100755 (executable)
@@ -147,7 +147,7 @@ my $link_suffix = sub { my $row = shift;
                         my @ro = grep $_,
                           @row_option[$row->upload - 1],
                           @column_option[$row->download - 2],
-                          @technology_option[$row->technology_code],
+                          @technology_option[$row->technology_code - 1],
                         ;
                         $result .= 'report_option='. join(',',@ro) if @ro;
                         $result;
@@ -155,6 +155,10 @@ my $link_suffix = sub { my $row = shift;
 
 my $html_foot = sub {
   if (scalar(keys %state_hash) > 1) {
+
+    my $roa = join(',', grep $_, @technology_option);
+    $roa = ";report_option_any=$roa" if $roa;
+    
     '<BR><B>WARNING: multiple states found</B><BR>'.
     '<TABLE BORDER=0>'. #nicer formatting someday
     join('', map { '<TR>'.
@@ -162,7 +166,7 @@ my $html_foot = sub {
                        ( &FS::Report::FCC_477::statenum2state($_) || 'None' ).
                      '</TD>'.
                      '<TD>'.
-                       qq(<A HREF="${link}censustract2=$_">).
+                       qq(<A HREF="${link}censustract2=$_$roa">).
                        $state_pkgcount{$_}. ' packages</A> in '.
                        $state_hash{$_}. ' census tracts'.
                      '</TD>'.