From c96f38c9a16df1fe84172e53cf58acd551b1937d Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Mon, 20 Feb 2012 14:14:18 -0800 Subject: [PATCH] add rows #s to fcc 477 census report --- httemplate/search/477partVI_census.html | 129 ++++++++++++++++---------------- 1 file changed, 66 insertions(+), 63 deletions(-) diff --git a/httemplate/search/477partVI_census.html b/httemplate/search/477partVI_census.html index 3883a1c0f..be3a9c057 100755 --- a/httemplate/search/477partVI_census.html +++ b/httemplate/search/477partVI_census.html @@ -1,64 +1,27 @@ <% include( 'elements/search.html', - 'html_init' => $html_init, - 'html_foot' => $html_foot, - 'name' => 'regions', - 'query' => [ @sql_query ], - 'count_query' => $count_query, - 'order_by' => 'ORDER BY censustract', - 'avoid_quote' => 1, - 'no_csv_header' => 1, - 'nohtmlheader' => 1, - 'header' => [ - 'County code', - 'Census tract code', - 'Upload rate', - 'Download rate', - 'Technology code', - 'Technology code other', - 'Quantity', - 'Percentage residential', - ], - 'xml_elements' => [ - 'county_fips', - 'census_tract', - 'upload_rate_code', - 'download_rate_code', - 'technology_code', - 'technology_code_other', - 'value', - 'percentage', - ], - 'fields' => [ - sub { my $row = shift; - 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'; - }, - 'upload', - 'download', - 'technology_code', - sub { $cgi->param('_type') eq 'xml' ? '0' : '' },#broken - 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' => [ - [ $link, $link_suffix ], - [ $link, $link_suffix ], - [ $link, $link_suffix ], - [ $link, $link_suffix ], - [ $link, $link_suffix ], - [ $link, $link_suffix ], - [ $link, $link_suffix ], - [ $link, $link_suffix ], - ], - 'url' => $opt{url} || '', + 'html_init' => '

Part VI

', + 'html_foot' => $html_foot, + 'name' => 'regions', + 'query' => [ @sql_query ], + 'count_query' => $count_query, + 'order_by' => 'ORDER BY censustract', + 'avoid_quote' => 1, + 'no_csv_header' => 1, + 'nohtmlheader' => 1, + 'header' => \@header, + 'xml_elements' => [ + 'county_fips', + 'census_tract', + 'upload_rate_code', + 'download_rate_code', + 'technology_code', + 'technology_code_other', + 'value', + 'percentage', + ], + 'fields' => \@fields, + 'links' => \@links, + 'url' => $opt{url} || '', 'xml_row_element' => 'Datarow', ) %> @@ -71,12 +34,52 @@ die "access denied" my %opt = @_; -my $html_init = '

Part VI

'; +my %state_hash = (); +my %state_pkgcount = (); + +my @header = (); +my @fields = (); +my @links = (); +my $num = ($cgi->param('offset') =~ /^(\d+)$/) ? $1 : 0; +unless ( $cgi->param('_type') eq 'xml' ) { + push @header, '#'; + push @fields, sub { ++$num }; + push @links, ''; +} +push @header, + 'County code', + 'Census tract code', + 'Upload rate', + 'Download rate', + 'Technology code', + 'Technology code other', + 'Quantity', + 'Percentage residential', +; +push @fields, + sub { my $row = shift; + 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'; + }, + 'upload', + 'download', + 'technology_code', + sub { $cgi->param('_type') eq 'xml' ? '0' : '' },#broken + 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 }, +; +push @links, ( [ $link, $link_suffix ] x 8 ); my %search_hash = (); my @sql_query = (); -my %state_hash = (); -my %state_pkgcount = (); for ( qw(agentnum magic) ) { $search_hash{$_} = $cgi->param($_) if $cgi->param($_); -- 2.11.0