1 <% include( 'elements/search.html',
2 'html_init' => $html_init,
5 'count_query' => $count_query,
6 'really_disable_download' => 1,
7 'disable_download' => 1,
10 'header' => [ '', @column_option_name ],
11 'xml_elements' => [ @xml_elements ],
12 'fields' => [ @fields ],
17 my $curuser = $FS::CurrentUser::CurrentUser;
20 unless $curuser->access_right('List packages');
25 for ( qw(agentnum magic classnum) ) {
26 $search_hash{$_} = $cgi->param($_) if $cgi->param($_);
29 my @column_option = grep { /^\d+/ } $cgi->param('part1_column_option')
30 if $cgi->param('part1_column_option');
32 my @row_option = grep { /^\d+/ } $cgi->param('part1_row_option')
33 if $cgi->param('part1_row_option');
35 my @technology_option = &FS::Report::FCC_477::parse_technology_option($cgi);
37 my @column_option_name = scalar(@column_option)
38 ? ( map { my $part_pkg_report_option =
39 qsearchs({ 'table' => 'part_pkg_report_option',
40 'hashref' => { num => $_ },
42 $part_pkg_report_option ? $part_pkg_report_option->name
43 : 'no such report option';
48 my $where = join(' OR ', map { "num = $_" } @row_option );
49 my %row_option_name = $where ?
50 ( map { $_->num => $_->name }
51 qsearch({ 'table' => 'part_pkg_report_option',
53 'extra_sql' => "WHERE $where",
58 my $tech_code = $opt{tech_code};
59 my $technology = $FS::Report::FCC_477::technology[$tech_code] || 'unknown';
60 my $html_init = "<H2>Part IA $technology breakdown by speeds</H2>";
61 my $xml_prefix = 'PartIA_'. chr(65 + $tech_code);
63 my $query = 'SELECT '. join(' UNION ALL SELECT ',@row_option);
64 my $count_query = 'SELECT '. scalar(@row_option);
67 my ($rowref, $column) = (shift, shift);
68 my $row = $rowref->[0];
70 if ($column eq 'name') {
71 return $row_option_name{$row} || 'no such report option';
72 } elsif ( $column =~ /^(\d+)$/ ) {
73 my @report_option = ( $row || '',
74 $column_option[$1 - 2] || '',
75 $technology_option[$tech_code] || '',
78 my ( $count, $residential ) = FS::cust_pkg->fcc_477_count(
79 { %search_hash, 'report_option' => join(',', @report_option) }
82 my $percentage = sprintf('%.2f', $count ? 100 * $residential / $count : 0);
84 $return .= "<BR>$percentage% residential"
85 unless $cgi->param('_type') eq 'xml';
88 return '<FONT SIZE="+1" COLOR="#ff0000">Bad call to column_value</FONT>';
93 sub { &{$value}(shift, 'name');},
94 sub { &{$value}(shift, 2);},
95 sub { &{$value}(shift, 3);},
96 sub { &{$value}(shift, 4);},
97 sub { &{$value}(shift, 5);},
98 sub { &{$value}(shift, 6);},
99 sub { &{$value}(shift, 7);},
100 sub { &{$value}(shift, 8);},
101 sub { &{$value}(shift, 9);},
103 shift @fields if $cgi->param('_type') eq 'xml';
105 my $xml_element = sub {
106 my ($rowref, $column) = (shift, shift);
107 my $row = $rowref->[0];
110 $xml_prefix. $column. $row;
115 sub { &{$xml_element}(shift, 'f') },
116 sub { &{$xml_element}(shift, 'g') },
117 sub { &{$xml_element}(shift, 'h') },
118 sub { &{$xml_element}(shift, 'i') },
119 sub { &{$xml_element}(shift, 'j') },
120 sub { &{$xml_element}(shift, 'k') },
121 sub { &{$xml_element}(shift, 'l') },
122 sub { &{$xml_element}(shift, 'm') },