1 % if ( $opt{'type'} eq 'xml' ) {
2 %# container element <Part_IA_$tech> is in 477.html
4 % foreach ( @summary_row ) {
5 % my $el = $xml_prefix . $col . '1'; # PartIA_Aa1, PartIA_Ab1, etc.
6 <<% $el %>><% $_ %><<% "/$el" %>>
9 % foreach my $col_data ( @data ) {
11 % foreach my $cell ( @$col_data ) {
12 % my $el = $xml_prefix . $col . $row; # PartIA_Af1, PartIA_Af2...
13 <<% $el %>><% $cell->[0] %><<% "/$el" %>>
14 % if ( $percentages ) {
15 % $el = $xml_percent . $col . $row; # Part_p_IA_Af1, ...
16 <<% $el %>><% $cell->[1] %><<% "/$el" %>>
21 % } # foreach $col_data
24 <H2><% $title %> totals</H2>
25 <& /elements/table-grid.html &>
27 % foreach ( 'Total Connections',
29 % '% billed to end users',
31 % '% residential > 200 kbps') {
32 <TH WIDTH="20%"><% $_ |h %></TH>
36 % foreach ( @summary_row ) {
41 <H2><% $title %> breakdown by speed</H2>
42 <TABLE CLASS="grid" CELLSPACING=0>
45 % for (my $col = 0; $col < scalar(@download_option); $col++) {
47 <% $FS::Report::FCC_477::download[$col] |h %>
51 % for (my $row = 0; $row < scalar(@upload_option); $row++) {
52 <TR CLASS="row<% $row % 2%>">
53 <TD STYLE="text-align: left; font-weight: bold">
54 % if ( $asymmetric ) {
55 <% $FS::Report::FCC_477::upload[$row] |h %>
58 % for (my $col = 0; $col < scalar(@download_option); $col++) {
60 <% $data[$col][$row][0] %>
61 % if ( $percentages ) {
62 <BR><% $data[$col][$row][1] %>
72 my $curuser = $FS::CurrentUser::CurrentUser;
75 unless $curuser->access_right('List packages');
80 for ( qw(agentnum state) ) {
81 $search_hash{$_} = $cgi->param($_) if $cgi->param($_);
83 $search_hash{'status'} = 'active';
84 $search_hash{'country'} = 'US';
85 $search_hash{'classnum'} = [ $cgi->param('classnum') ];
87 # arrays of report_option_ numbers, running parallel to
88 # the download and upload speed arrays
89 my @download_option = $cgi->param('part1_column_option');
90 my @upload_option = $cgi->param('part1_row_option');
92 my @technology_option = &FS::Report::FCC_477::parse_technology_option($cgi);
95 my $total_residential = 0;
97 my $tech_code = $opt{tech_code};
98 my $technology = $FS::Report::FCC_477::technology[$tech_code] || 'unknown';
99 my $title = "Part IA $technology";
100 my $xml_prefix = 'PartIA_'. chr(65 + $tech_code);
101 my $xml_percent = 'Part_p_IA_'. chr(65 + $tech_code); # yes, seriously
103 # whether to show the results as a matrix (upload speeds in rows) or a single
106 if ( $technology eq 'Symmetric xDSL' or $technology eq 'Other Wireline' ) {
108 @upload_option = ( undef );
110 # whether to show residential percentages in each cell of the matrix
111 my $percentages = ($technology eq 'Terrestrial Mobile Wireless');
113 my $query = FS::cust_pkg->search(\%search_hash);
114 my $count_query = $query->{'count_query'};
116 my $is_residential = " AND COALESCE(cust_main.company, '') = ''";
117 my $has_option = sub {
118 my $optionnum = shift;
119 $optionnum =~ /^\d+$/ ?
121 SELECT 1 FROM part_pkg_option
122 WHERE part_pkg_option.pkgpart = part_pkg.pkgpart
123 AND optionname = 'report_option_$optionnum'
124 AND optionvalue = '1'
128 # limit to those that have technology option $tech_code
129 $count_query .= $has_option->($technology_option[$tech_code]);
132 for ( my $row = 0; $row < scalar @upload_option; $row++ ) {
133 for ( my $col = 0; $col < scalar @download_option; $col++ ) {
135 my $this_count_query = $count_query .
136 $has_option->($upload_option[$row]) .
137 $has_option->($download_option[$col]);
139 my $count = FS::Record->scalar_sql($this_count_query);
140 my $residential = FS::Record->scalar_sql($this_count_query . $is_residential);
142 my $percent = sprintf('%.2f', $count ? 100 * $residential / $count : 0);
143 $data[$col][$row] = [ $count, $percent ];
145 $total_count += $count;
146 $total_residential += $residential;
147 $above_200 += $residential if $row > 0 or !$asymmetric;
151 my $total_percentage =
152 sprintf("%.2f", $total_count ? 100*$total_residential/$total_count : 0);
154 my $above_200_percentage =
155 sprintf("%.2f", $total_count ? 100*$above_200/$total_count : 0);
159 100.00, # own local loop--consistent with previous practice, but probably wrong
160 100.00, # billed to end user--also wrong
161 $total_percentage, # residential percentage
162 $above_200_percentage,