From f7d5af6176a79d0afcd67ba8bdd5a64d6c6af330 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Fri, 11 Apr 2014 15:12:07 -0700 Subject: [PATCH] 477 report, XML adjustments, #28020 --- httemplate/search/477.html | 6 +++++- httemplate/search/477partIA.html | 1 - httemplate/search/477partIIA.html | 4 +--- httemplate/search/477partIIB.html | 7 +++++-- httemplate/search/477partV.html | 4 ++-- httemplate/search/477partVI_census.html | 3 +-- httemplate/search/elements/search-xml.html | 6 ++++-- 7 files changed, 18 insertions(+), 13 deletions(-) diff --git a/httemplate/search/477.html b/httemplate/search/477.html index 3e7888c40..ecf21cfb1 100755 --- a/httemplate/search/477.html +++ b/httemplate/search/477.html @@ -1,4 +1,7 @@ % if ( $type eq 'xml' ) { +% $filename = "fcc_477_$state" . '_' . time2str('%Y%m%d', $date) . '.xml'; +% http_header('Content-Type' => 'application/XML' ); # So saith RFC 4180 +% http_header('Content-Disposition' => 'attachment;filename="'.$filename.'"'); % } else { #html @@ -64,6 +67,7 @@ <& "477part${part}.html", 'url' => $url, 'date' => $date, + 'filename' => $filename, &> % if ( $type eq 'xml' ) { > @@ -92,7 +96,7 @@ $state =~ /^[A-Z]{2}$/ or die "illegal state: $state"; my %part = map { $_ => 1 } grep { /^\w+$/ } $cgi->param('part'); my $type = $cgi->param('_type') || 'html'; -my $xlsname = '477report'; +my $filename; my @technology_option = &FS::Report::FCC_477::parse_technology_option($cgi,1); # save upload and download mappings diff --git a/httemplate/search/477partIA.html b/httemplate/search/477partIA.html index aa7381139..97f8ac0aa 100755 --- a/httemplate/search/477partIA.html +++ b/httemplate/search/477partIA.html @@ -118,7 +118,6 @@ my $percentages = ($technology eq 'Terrestrial Mobile Wireless'); # So we count packages that were in active status as of the specified date, # not over any sort of range. $search_hash{'active'} = [ $opt{date}, $opt{date} ]; -warn Dumper \%search_hash; my $query = FS::cust_pkg->search(\%search_hash); my $count_query = $query->{'count_query'}; diff --git a/httemplate/search/477partIIA.html b/httemplate/search/477partIIA.html index 467b19c5f..7ccee6928 100755 --- a/httemplate/search/477partIIA.html +++ b/httemplate/search/477partIIA.html @@ -2,11 +2,9 @@ % my @cols = qw(a b c d); % for ( my $row = 0; $row < scalar(@rows); $row++ ) { % for my $col (0..3) { -% if ( exists($data[$col][$row]) and $data[$col][$row] > 0 ) { <% $cols[$col] %>>\ -<% $data[$col][$row] %>\ +<% $data[$col][$row] || 0 %>\ <% $cols[$col] %>> -% } % } #for $col % } #for $row % } else { # HTML mode diff --git a/httemplate/search/477partIIB.html b/httemplate/search/477partIIB.html index ce1ac03f0..bd56ecc60 100755 --- a/httemplate/search/477partIIB.html +++ b/httemplate/search/477partIIB.html @@ -118,11 +118,14 @@ foreach (@col_conds) { if ( $row == 0 ) { $col_data[$row] = $count; # the raw count } else { + # the rows that are percentages of the raw count if ( $col_data[0] == 0 ) { - $col_data[$row] = ''; # show nothing in this row, then + # 0 out of 0 is not 0%, but supposedly this works + $col_data[$row] = '0.000'; } else { - $col_data[$row] = sprintf('%.3f', 100 * $count / $col_data[0]) . '%'; + $col_data[$row] = sprintf('%.3f', 100 * $count / $col_data[0]); } + $col_data[$row] .= '%' unless $cgi->param('_type') eq 'xml'; } #if $row == 0 $row++; } diff --git a/httemplate/search/477partV.html b/httemplate/search/477partV.html index 5f7708140..2ffad2a27 100755 --- a/httemplate/search/477partV.html +++ b/httemplate/search/477partV.html @@ -1,5 +1,5 @@ % if ( $cgi->param('_type') =~ /^xml$/ ) { - + % } <& elements/search.html, 'html_init' => $html_init, @@ -18,7 +18,7 @@ &> % if ( $cgi->param('_type') =~ /^xml$/ ) { - + % } <%init> diff --git a/httemplate/search/477partVI_census.html b/httemplate/search/477partVI_census.html index b4f6ddc01..2f3cf419a 100755 --- a/httemplate/search/477partVI_census.html +++ b/httemplate/search/477partVI_census.html @@ -24,7 +24,7 @@ 'url' => $opt{url} || '', 'xml_row_element' => 'Datarow', 'really_disable_download' => 1, - + 'filename' => $opt{filename}, &> <%init> @@ -117,7 +117,6 @@ foreach my $row ( @row_option ) { ($report_option ? ( 'report_option' => $report_option ) : () ), } ); -warn Dumper($sql_query) if $rowcount==1 and $columncount==3; my $extracolumns = "$rowcount AS upload, $columncount AS download, $tech_code as technology_code"; my $percent = "CASE WHEN count(*) > 0 THEN 100-100*cast(count(cust_main.company) as numeric)/cast(count(*) as numeric) ELSE cast(0 as numeric) END AS residential"; $sql_query->{select} = "count(*) AS quantity, $extracolumns, cust_location.censustract, $percent"; diff --git a/httemplate/search/elements/search-xml.html b/httemplate/search/elements/search-xml.html index 50b191610..18bfe8d82 100644 --- a/httemplate/search/elements/search-xml.html +++ b/httemplate/search/elements/search-xml.html @@ -32,9 +32,11 @@ my $header = $args{'header'}; my $rows = $args{'rows'}; my %opt = %{ $args{'opt'} }; +my $filename = $opt{'filename'} || + ($opt{'name'} || PL($opt{'name_singular'}) . 'xml'); + http_header('Content-Type' => 'application/XML' ); # So saith RFC 4180 -http_header('Content-Disposition' => - 'attachment;filename="'.($opt{'name'} || PL($opt{'name_singular'}) ).'.xml"'); +http_header('Content-Disposition' => 'attachment;filename="'.$filename.'"'); unless ( $opt{'fields'} ) { foreach my $i ( 0 .. ( $#{ @$rows[0] } ) ) { -- 2.11.0