X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2F477.html;h=26bd9f33ba98181086b0248de430739db8f46d18;hb=0f359d5480aa1621d73ee802f420e8951abc620d;hp=d586406af7120469cd0a3c527b81db992960b9c4;hpb=0fb307c305e4bc2c9c27dc25a3308beae3a4d33c;p=freeside.git diff --git a/httemplate/search/477.html b/httemplate/search/477.html old mode 100755 new mode 100644 index d586406af..26bd9f33b --- a/httemplate/search/477.html +++ b/httemplate/search/477.html @@ -1,93 +1,221 @@ -% unless ( $type eq 'xml' ) { -<% include( '/elements/header.html', 'FCC Form 477 Results') %> -%}else{ - - -%} -% if ( $type eq 'html' || $type eq 'html-print' ) { - - -%}elsif ( $type eq 'xml' ) { -%} -% unless ( $type eq 'html-print' || $type eq 'xml' ) { - - -% $cgi->param('_type', $type ); -% } -% if ( $type eq 'html' || $type eq 'html-print' ) { - -
- - Download full results
-% $cgi->param('_type', 'xml'); - as XML file
- -% $cgi->param('_type', 'html-print'); - as printable copy - -
-%}elsif ( $type eq 'xml' ) { -%} -% 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) %>> -% } -<% include( "477part${part}_summary.html", 'tech_code' => $tech, 'url' => $url ) %> -<% include( "477part${part}_detail.html", 'tech_code' => $tech, 'url' => $url ) %> -% if ( $type eq 'xml' ) { -> -% } -% } -% } else { -% if ( $type eq 'xml' ) { -<<% 'Part_'. $part %>> -% } -% my $url = &{$url_mangler}($part); -<% include( "477part${part}.html", 'url' => $url ) %> -% if ( $type eq 'xml' ) { -> -% } +<& /elements/header.html, $title &> + +% foreach my $partname (@partnames) { +% $cgi->param('parts', $partname); +% $cgi->param('type', 'csv'); + + +% my $header = ".header_$partname"; +% my $data = $parts{$partname}; + + <& $header &> + +% foreach my $row (@$data) { + +% foreach my $item (@$row) { + % } + % } -% } -% -% if ( $type eq 'html' || $type eq 'html-print' ) { -<% include( '/elements/footer.html') %> -%}elsif ( $type eq 'xml' ) { - -%} +
+ <% $parttitle{$partname} %> + Download +
<% $item %>
+% } # foreach $partname +<& /elements/footer.html &> <%init> +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('List packages'); -my $curuser = $FS::CurrentUser::CurrentUser; +my %parts; +# load from cache if possible +my $session; +if ( $cgi->param('session') =~ /^(\d+)$/ ) { + $session = $1; + %parts = %{ $m->cache->get($session) }; +} else { + $session = sprintf('%010d%06d', time, int(rand(1000000))); + $cgi->param('session', $session); +} -die "access denied" - unless $curuser->access_right('List packages'); - -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); -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 $agentnum; +if ($cgi->param('agentnum') =~ /^(\d+)$/ ) { + $agentnum = $1; +} +my $date = parse_datetime($cgi->param('date')) || time; +my @partnames = grep /^\w+$/, $cgi->param('parts'); +foreach my $partname (@partnames) { + my $method = "report_$partname"; + $parts{$partname} ||= FS::Report::FCC_477->$method( + date => $date, + agentnum => $agentnum + ); +} +$m->cache->set($session, \%parts, '1h'); + +my $title = 'FCC Form 477 Data - ' . time2str('%b %o, %Y', $date); + +if ( $cgi->param('type') eq 'csv' ) { + my $partname = $partnames[0]; # ignore any beyond the first + my $data = $parts{$partname}; + my $csv = Text::CSV_XS->new({ eol => "\r\n" }); # i think + + my $filename = time2str('%Y-%m-%d', $date) . '-'. $partname . '.csv'; + http_header('Content-Type' => 'text/csv'); + http_header('Content-Disposition' => qq(attachment;filename="$filename")); + + $m->clear_buffer; + + foreach my $row (@$data) { + $csv->combine(@$row); + $m->print($csv->string); + } + $m->abort; +} +<%def .header_fixed_broadband> + + Census Tract + Technology + Speed (Mbps) + Subscriptions + + + Down + Up + Total + Consumer + + +<%def .header_fixed_voice> + + Census Tract + VoIP? + Lines/Subscriptions + + + Total + Consumer + + +<%def .header_local_phone> + + State + Wholesale + End User Lines + + + VGEs + UNE-Ls + + Total + With Broadband + Consumer + Business + + Local Loop + + Special Media + + + + + +LD + + +LD + + Owned + UNE-L + Resale + + Fiber + Coaxial + Wireless + + +<%def .header_voip> + + State + VoIP OTT + VoIP Non-OTT + + + Total + Consumer + + Total + Consumer + Bundled + Media Type + + + Copper + Fiber + Coaxial + Wireless + Other + + +<%def .header_mobile_broadband> +%# unimplemented + + State + Speed (Mbps) + Subscriptions + + + Down + Up + Total + Consumer + + +<%def .header_mobile_voice> +%# unimplemented + + State + Subscriptions + + + Total + Direct + + +