X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=inline;f=httemplate%2Fsearch%2F477.html;h=3e7888c4070354d8171e9f748ff76f58dee13bf6;hb=f2718f0968799015e034fe705d198b91c932e9cd;hp=45c92ffe7d494aa934a17afcc16ec8332dd19e3d;hpb=0b407666b53dea109661f25d51860a7e7e06981f;p=freeside.git diff --git a/httemplate/search/477.html b/httemplate/search/477.html index 45c92ffe7..3e7888c40 100755 --- a/httemplate/search/477.html +++ b/httemplate/search/477.html @@ -1,29 +1,82 @@ -<% include( 'elements/search.html', - 'title' => 'FCC Form 477 Results', - 'html_init' => $html_init, - 'name' => 'regions', - 'query' => $sql_query, - 'count_query' => $count_query, - 'header' => [ - 'State code', - 'County code', - 'Census tract code', - 'Quantity', - ], - 'fields' => [ - sub { my $row = shift; substr($row->censustract, 0, 2) }, - sub { my $row = shift; substr($row->censustract, 2, 3) }, - sub { my $row = shift; substr($row->censustract, 5) }, - 'quantity', - ], - 'links' => [ - [ $link, 'censustract' ], - [ $link, 'censustract' ], - [ $link, 'censustract' ], - [ $link, 'censustract' ], - ], - ) -%> +% if ( $type eq 'xml' ) { + + +% } else { #html +<& /elements/header.html, "FCC Form 477 Results - $state" &> +%# XXX when we stop supporting IE8, add this to freeside.css using :nth-child +%# selectors, and remove it from everywhere else + + + + + + +% $cgi->param('_type', $type ); + +
+ Download full results
+% $cgi->param('_type', 'xml'); + as XML file
+ +% $cgi->param('_type', 'html-print'); + as printable copy + +
+% } #html +% foreach my $part ( @parts ) { +% if ( $part{$part} ) { +% +% if ( $part eq 'V' ) { +% next unless ( $part{'IIA'} || $part{'IIB'} ); +% } +% +% if ( $part eq 'VI_census' ) { +% next unless $part{'IA'}; +% } +% +% my @reports = (); +% if ( $part eq 'IA' ) { +% for ( my $tech = 0; $tech < scalar(@technology_option); $tech++ ) { +% next unless $technology_option[$tech]; +% my $url = &{$url_mangler}($part); +% if ( $type eq 'xml' ) { +<<% 'Part_IA_'. chr(65 + $tech) %>> +% } +<& "477part${part}.html", + 'tech_code' => $tech, + 'url' => $url, + 'type' => $type, + 'date' => $date, +&> +% if ( $type eq 'xml' ) { +> +% } +% } +% } else { # not part IA +% if ( $type eq 'xml' ) { +<<% 'Part_'. $part %>> +% } +% my $url = &{$url_mangler}($part); +<& "477part${part}.html", + 'url' => $url, + 'date' => $date, +&> +% if ( $type eq 'xml' ) { +> +% } +% } +% } +% } +% +% if ( $type eq 'xml' ) { +
+% } else { +<& /elements/footer.html &> +% } <%init> my $curuser = $FS::CurrentUser::CurrentUser; @@ -31,40 +84,48 @@ my $curuser = $FS::CurrentUser::CurrentUser; die "access denied" unless $curuser->access_right('List packages'); -my %search_hash = (); - -$search_hash{'query'} = $cgi->keywords; - -for ( qw(agentnum magic status classnum) ) { - $search_hash{$_} = $cgi->param($_) if $cgi->param($_); -} +my $date = $cgi->param('date') ? parse_datetime($cgi->param('date')) + : time; +my $state = uc($cgi->param('state')); +$state =~ /^[A-Z]{2}$/ or die "illegal state: $state"; -my @report_option = $cgi->param('report_option') - if $cgi->param('report_option'); -$search_hash{report_option} = join(',', @report_option) if @report_option; +my %part = map { $_ => 1 } grep { /^\w+$/ } $cgi->param('part'); +my $type = $cgi->param('_type') || 'html'; +my $xlsname = '477report'; +my @technology_option = &FS::Report::FCC_477::parse_technology_option($cgi,1); -my $where = join(' OR ', map { "num = $_" } grep { /^\d+$/ } @report_option ); -my @report_option_name = $where ? - ( map { $_->name } - qsearch({ 'table' => 'part_pkg_report_option', - 'hashref' => {}, - 'extra_sql' => "WHERE $where", - }) - ) : - ( 'all packages' ); +# save upload and download mappings +my @download = $cgi->param('part1_column_option'); +my @upload = $cgi->param('part1_row_option'); +for(my $i=0; $i < scalar(@download); $i++) { + &FS::Report::FCC_477::save_fcc477map("part1_column_option_$i",$download[$i]); +} +for(my $i=0; $i < scalar(@upload); $i++) { + &FS::Report::FCC_477::save_fcc477map("part1_row_option_$i",$upload[$i]); +} -my $html_init = "For
". join(' and
', @report_option_name). "
"; +my @part2a_row_option = $cgi->param('part2a_row_option'); +for(my $i=0; $i < scalar(@part2a_row_option); $i++) { + &FS::Report::FCC_477::save_fcc477map("part2a_row_option_$i",$part2a_row_option[$i]); +} -my $sql_query = FS::cust_pkg->search_sql(\%search_hash); +my @part2b_row_option = $cgi->param('part2b_row_option'); +for(my $i=0; $i < scalar(@part2b_row_option); $i++) { + &FS::Report::FCC_477::save_fcc477map("part2b_row_option_$i",$part2b_row_option[$i]); +} -$sql_query->{select} = 'count(*) as quantity, censustract'; -$sql_query->{extra_sql} =~ /^(.*)(ORDER BY bill)(.*)$/s or die "couldn't parse extra_sql"; -$sql_query->{extra_sql} = "$1 GROUP BY censustract $3"; +my $part5_report_option = $cgi->param('part5_report_option'); +if ( $part5_report_option ) { + FS::Report::FCC_477::save_fcc477map('part5_report_option', $part5_report_option); +} -my $count_query = delete($sql_query->{'count_query'}); -$count_query = 'SELECT count(*) FROM (SELECT count(*) FROM cust_pkg '. - $sql_query->{addl_from}. ' '. $sql_query->{extra_sql}. ') AS foo'; +my $url_mangler = sub { + my $part = shift; + my $url = $cgi->url('-path_info' => 1, '-full' => 1); + $url =~ s/477\./477part$part./; + $url; +}; +my @parts = qw( IA IIA IIB IV V VI_census ); -my $link = 'cust_pkg.cgi?'. $cgi->query_string. ';censustract=';