warn about multiple states
authorjeff <jeff>
Wed, 1 Sep 2010 20:25:00 +0000 (20:25 +0000)
committerjeff <jeff>
Wed, 1 Sep 2010 20:25:00 +0000 (20:25 +0000)
httemplate/search/477partVI_census.html

index 5f3039d..1d625dc 100755 (executable)
@@ -1,5 +1,13 @@
 <% include( 'elements/search.html',
                   'html_init'     => $html_init,
+                  'html_foot'     => sub { if (scalar(keys %state_hash) > 1) {
+                                             '<BR><B>'.
+                                               'WARNING: multiple states found'.
+                                             '</B><BR>';
+                                           } else { 
+                                             '';
+                                           }
+                                         },
                   'name'          => 'regions',
                   'query'         => [ @sql_query ],
                   'count_query'   =>  $count_query,
                                        'percentage',
                                      ],
                   'fields'        => [
-                    sub { my $row = shift; substr($row->censustract, 2, 3) },
+                    sub { my $row = shift; 
+                          $state_hash{substr($row->censustract, 0, 2)} = 1;
+                          substr($row->censustract, 2, 3)
+                        },
                     sub { my $row = shift; substr($row->censustract, 5) },
                     'upload',
                     'download',
@@ -64,6 +75,7 @@ my $html_init = '<H2>Part VI</H2>';
 
 my %search_hash = ();
 my @sql_query = ();
+my %state_hash = ();
   
 for ( qw(agentnum magic classnum) ) {
   $search_hash{$_} = $cgi->param($_) if $cgi->param($_);