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