X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2F477partIA_detail.html;h=2eca1072be6c8beb237b02341ba4dc0cb33b633f;hb=d8299144d2175f1695adafe29e9549bd9b158e2f;hp=546d56c7f02760308eaaae746334dc3608ded8ef;hpb=4ef5b3b917b7802a136551ad567dc9d649700f53;p=freeside.git diff --git a/httemplate/search/477partIA_detail.html b/httemplate/search/477partIA_detail.html index 546d56c7f..2eca1072b 100755 --- a/httemplate/search/477partIA_detail.html +++ b/httemplate/search/477partIA_detail.html @@ -9,6 +9,7 @@ 'disable_total' => 1, 'header' => [ '', @column_option_name ], 'xml_elements' => [ @xml_elements ], + 'xml_omit_empty' => 1, 'fields' => [ @fields ], ) %> @@ -22,10 +23,12 @@ die "access denied" my %opt = @_; my %search_hash = (); -for ( qw(agentnum magic classnum) ) { +for ( qw(agentnum magic) ) { $search_hash{$_} = $cgi->param($_) if $cgi->param($_); } +$search_hash{'classnum'} = [ $cgi->param('classnum') ]; + my @column_option = grep { /^\d+/ } $cgi->param('part1_column_option') if $cgi->param('part1_column_option'); @@ -60,9 +63,19 @@ my $technology = $FS::Report::FCC_477::technology[$tech_code] || 'unknown'; my $html_init = "

Part IA $technology breakdown by speeds

"; my $xml_prefix = 'PartIA_'. chr(65 + $tech_code); +if ($cgi->param('_type') eq 'xml') { + #rotate data pi/2 + my @temp = @column_option; + @column_option = @row_option; + @row_option = @temp; +} + my $query = 'SELECT '. join(' UNION ALL SELECT ',@row_option); my $count_query = 'SELECT '. scalar(@row_option); +my $xml_element = 'OOPS, I was never set'; +my $rowchar = 101; # 'e' -- rows are columns! (pi/2) + my $value = sub { my ($rowref, $column) = (shift, shift); my $row = $rowref->[0]; @@ -71,7 +84,7 @@ my $value = sub { return $row_option_name{$row} || 'no such report option'; } elsif ( $column =~ /^(\d+)$/ ) { my @report_option = ( $row || '', - $column_option[$1 - 2] || '', + $column_option[$column] || '', $technology_option[$tech_code] || '', ); @@ -81,45 +94,35 @@ my $value = sub { my $percentage = sprintf('%.2f', $count ? 100 * $residential / $count : 0); my $return = $count; - $return .= "
$percentage% residential" - unless $cgi->param('_type') eq 'xml'; + + if ($cgi->param('_type') eq 'xml') { + $rowchar++ if $column == 0; + $xml_element = $xml_prefix. chr($rowchar). ($column+1); + $return = '' if $count == 0 and $cgi->param('_type') eq 'xml'; + } else { + $return .= "
$percentage% residential"; + } + return $return; } else { return 'Bad call to column_value'; } }; -my @fields = ( - sub { &{$value}(shift, 'name');}, - sub { &{$value}(shift, 2);}, - sub { &{$value}(shift, 3);}, - sub { &{$value}(shift, 4);}, - sub { &{$value}(shift, 5);}, - sub { &{$value}(shift, 6);}, - sub { &{$value}(shift, 7);}, - sub { &{$value}(shift, 8);}, - sub { &{$value}(shift, 9);}, - ); +my @fields = map { my $ci = $_; sub { &{$value}(shift, $ci); } } + ( 'name', (0 .. $#column_option) ); shift @fields if $cgi->param('_type') eq 'xml'; -my $xml_element = sub { - my ($rowref, $column) = (shift, shift); - my $row = $rowref->[0]; - - $row++; - $xml_prefix. $column. $row; - -}; - -my @xml_elements = ( - sub { &{$xml_element}(shift, 'f') }, - sub { &{$xml_element}(shift, 'g') }, - sub { &{$xml_element}(shift, 'h') }, - sub { &{$xml_element}(shift, 'i') }, - sub { &{$xml_element}(shift, 'j') }, - sub { &{$xml_element}(shift, 'k') }, - sub { &{$xml_element}(shift, 'l') }, - sub { &{$xml_element}(shift, 'm') }, +my @xml_elements = ( # -- columns are rows! (pi/2) + sub { return $xml_element; }, + sub { return $xml_element; }, + sub { return $xml_element; }, + sub { return $xml_element; }, + sub { return $xml_element; }, + sub { return $xml_element; }, + sub { return $xml_element; }, + sub { return $xml_element; }, + sub { return $xml_element; }, );