477 report as of a specific date, #24980
[freeside.git] / httemplate / search / 477.html
1 % if ( $type eq 'xml' ) {
2 <?xml version="1.0" encoding="ISO-8859-1"?>
3 <Form_477_submission xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://specialreports.fcc.gov/wcb/Form477/XMLSchema-instance/form_477_upload_Schema.xsd" >
4 % } else { #html
5 <& /elements/header.html, "FCC Form 477 Results - $state" &>
6 %# XXX when we stop supporting IE8, add this to freeside.css using :nth-child
7 %# selectors, and remove it from everywhere else
8 <STYLE TYPE="text/css">
9 .grid TH { background-color: #cccccc; padding: 0px 3px 2px; text-align: right }
10 .row0 TD { background-color: #eeeeee; padding: 0px 3px 2px; text-align: right }
11 .row1 TD { background-color: #ffffff; padding: 0px 3px 2px; text-align: right }
12 </STYLE>
13
14 <TABLE WIDTH="100%">
15   <TR>
16     <TD></TD>
17     <TD ALIGN="right" CLASS="noprint">
18       Download full results<BR>
19 %   $cgi->param('_type', 'xml');
20       as <A HREF="<% $cgi->self_url %>">XML file</A><BR>
21
22 %   $cgi->param('_type', 'html-print');
23       as <A HREF="<% $cgi->self_url %>">printable copy</A>
24
25     </TD>
26 %   $cgi->param('_type', $type );
27   </TR>
28 </TABLE>
29 % } #html
30 % foreach my $part ( @parts ) {
31 %   if ( $part{$part} ) {
32 %
33 %     if ( $part eq 'V' ) {
34 %       next unless ( $part{'IIA'} || $part{'IIB'} );
35 %     }
36 %
37 %     if ( $part eq 'VI_census' ) {
38 %       next unless $part{'IA'};
39 %     }
40 %
41 %     my @reports = ();
42 %     if ( $part eq 'IA' ) {
43 %       for ( my $tech = 0; $tech < scalar(@technology_option); $tech++ ) {
44 %         next unless $technology_option[$tech];
45 %         my $url = &{$url_mangler}($part);
46 %         if ( $type eq 'xml' ) {
47 <<% 'Part_IA_'. chr(65 + $tech) %>>
48 %         }
49 <& "477part${part}.html",
50     'tech_code' => $tech,
51     'url' => $url,
52     'type' => $type,
53     'date' => $date,
54 &>
55 %         if ( $type eq 'xml' ) {
56 </<% 'Part_IA_'. chr(65 + $tech) %>>
57 %         }
58 %       }
59 %     } else { # not part IA
60 %       if ( $type eq 'xml' ) {
61 <<% 'Part_'. $part %>>
62 %       }
63 %       my $url = &{$url_mangler}($part);
64 <& "477part${part}.html",
65     'url' => $url,
66     'date' => $date,
67 &>
68 %       if ( $type eq 'xml' ) {
69 </<% 'Part_'. $part %>>
70 %       }
71 %     }
72 %   }
73 % }
74 %
75 % if ( $type eq 'xml' ) {
76 </Form_477_submission>
77 % } else {
78 <& /elements/footer.html &>
79 % }
80 <%init>
81
82 my $curuser = $FS::CurrentUser::CurrentUser;
83
84 die "access denied"
85   unless $curuser->access_right('List packages');
86
87 my $date = $cgi->param('date') ? parse_datetime($cgi->param('date'))
88                                : time;
89
90 my $state = uc($cgi->param('state'));
91 $state =~ /^[A-Z]{2}$/ or die "illegal state: $state";
92
93 my %part = map { $_ => 1 } grep { /^\w+$/ } $cgi->param('part');
94 my $type = $cgi->param('_type') || 'html';
95 my $xlsname = '477report';
96 my @technology_option = &FS::Report::FCC_477::parse_technology_option($cgi,1);
97
98 # save upload and download mappings
99 my @download = $cgi->param('part1_column_option');
100 my @upload = $cgi->param('part1_row_option');
101 for(my $i=0; $i < scalar(@download); $i++) {
102     &FS::Report::FCC_477::save_fcc477map("part1_column_option_$i",$download[$i]);
103 }
104 for(my $i=0; $i < scalar(@upload); $i++) {
105     &FS::Report::FCC_477::save_fcc477map("part1_row_option_$i",$upload[$i]);
106 }
107
108 my @part2a_row_option = $cgi->param('part2a_row_option');
109 for(my $i=0; $i < scalar(@part2a_row_option); $i++) {
110     &FS::Report::FCC_477::save_fcc477map("part2a_row_option_$i",$part2a_row_option[$i]);
111 }
112
113 my @part2b_row_option = $cgi->param('part2b_row_option');
114 for(my $i=0; $i < scalar(@part2b_row_option); $i++) {
115     &FS::Report::FCC_477::save_fcc477map("part2b_row_option_$i",$part2b_row_option[$i]);
116 }
117
118 my $part5_report_option = $cgi->param('part5_report_option');
119 if ( $part5_report_option ) {
120   FS::Report::FCC_477::save_fcc477map('part5_report_option', $part5_report_option);
121 }
122
123 my $url_mangler = sub {
124   my $part = shift;
125   my $url = $cgi->url('-path_info' => 1, '-full' => 1);
126   $url =~ s/477\./477part$part./;
127   $url;
128 };
129 my @parts = qw( IA IIA IIB IV V VI_census );
130
131 </%init>