multiple state links in FCC report, RT#13922
[freeside.git] / httemplate / search / 477partVI_census.html
index 53b6db0..dbaaaab 100755 (executable)
                                      ],
                   'fields'        => [
                     sub { my $row = shift; 
-                          $state_hash{substr($row->censustract, 0, 2)}++;
-                          substr($row->censustract, 2, 3) || 'none'
+                          my $state = substr($row->censustract, 0, 2);
+                          $state_hash{$state}++;
+                          substr($row->censustract, 2, 3) || 'None'
                         },
                     sub { my $row = shift;
-                          substr($row->censustract, 5) || 'none'
+                          substr($row->censustract, 5) || 'None'
                         },
                     'upload',
                     'download',
                     'technology_code',
                     sub { $cgi->param('_type') eq 'xml' ? '0' : '' },#broken
-                    'quantity',
+                    sub { my $row = shift;
+                          my $state = substr($row->censustract, 0, 2);
+                          $state_pkgcount{$state} += $row->quantity;
+                          $row->quantity;
+                        },
                     sub { my $row = shift; sprintf "%.2f", $row->residential },
                   ],
                   'links'        => [
@@ -71,6 +76,7 @@ my $html_init = '<H2>Part VI</H2>';
 my %search_hash = ();
 my @sql_query = ();
 my %state_hash = ();
+my %state_pkgcount = ();
   
 for ( qw(agentnum magic) ) {
   $search_hash{$_} = $cgi->param($_) if $cgi->param($_);
@@ -149,9 +155,14 @@ my $html_foot = sub {
     '<BR><B>WARNING: multiple states found</B><BR>'.
     '<TABLE BORDER=0>'. #nicer formatting someday
     join('', map { '<TR>'.
-                     "<TD>$_</TD>".
-                     qq(<TD><A HREF="${link}state=$_">).
-                       $state_hash{$_}. '</A></TD>'.
+                     '<TD>'.
+                       ( &FS::Report::FCC_477::statenum2state($_) || 'None' ).
+                     '</TD>'.
+                     '<TD>'.
+                       qq(<A HREF="${link}censustract2=$_">).
+                       $state_pkgcount{$_}. ' packages</A> in '.
+                       $state_hash{$_}. ' census tracts'.
+                     '</TD>'.
                    '</TR>';
                  }
                  keys %state_hash