remember 477 report part 5 selection, #13057
[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 <TABLE WIDTH="100%">
7   <TR>
8     <TD></TD>
9     <TD ALIGN="right" CLASS="noprint">
10       Download full results<BR>
11 %   $cgi->param('_type', 'xml');
12       as <A HREF="<% $cgi->self_url %>">XML file</A><BR>
13
14 %   $cgi->param('_type', 'html-print');
15       as <A HREF="<% $cgi->self_url %>">printable copy</A>
16
17     </TD>
18 %   $cgi->param('_type', $type );
19   </TR>
20 </TABLE>
21 % } #html
22 % foreach my $part ( @parts ) {
23 %   if ( $part{$part} ) {
24 %
25 %     if ( $part eq 'V' ) {
26 %       next unless ( $part{'IIA'} || $part{'IIB'} );
27 %     }
28 %
29 %     if ( $part eq 'VI_census' ) {
30 %       next unless $part{'IA'};
31 %     }
32 %
33 %     my @reports = ();
34 %     if ( $part eq 'IA' ) {
35 %       for ( my $tech = 0; $tech < scalar(@technology_option); $tech++ ) {
36 %         next unless $technology_option[$tech];
37 %         my $url = &{$url_mangler}($part);
38 %         if ( $type eq 'xml' ) {
39 <<% 'Part_IA_'. chr(65 + $tech) %>>
40 %         }
41 <& "477part${part}_summary.html", 'tech_code' => $tech, 'url' => $url &>
42 <& "477part${part}_detail.html", 'tech_code' => $tech, 'url' => $url &>
43 %         if ( $type eq 'xml' ) {
44 </<% 'Part_IA_'. chr(65 + $tech) %>>
45 %         }
46 %       }
47 %     } else {
48 %       if ( $type eq 'xml' ) {
49 <<% 'Part_'. $part %>>
50 %       }
51 %       my $url = &{$url_mangler}($part);
52 <& "477part${part}.html", 'url' => $url &>
53 %       if ( $type eq 'xml' ) {
54 </<% 'Part_'. $part %>>
55 %       }
56 %     }
57 %   }
58 % }
59 %
60 % if ( $type eq 'xml' ) {
61 </Form_477_submission>
62 % } else {
63 <& /elements/footer.html &>
64 % }
65 <%init>
66
67 my $curuser = $FS::CurrentUser::CurrentUser;
68
69 die "access denied"
70   unless $curuser->access_right('List packages');
71
72 my $state = uc($cgi->param('state'));
73 $state =~ /^[A-Z]{2}$/ or die "illegal state: $state";
74
75 my %part = map { $_ => 1 } grep { /^\w+$/ } $cgi->param('part');
76 my $type = $cgi->param('_type') || 'html';
77 my $xlsname = '477report';
78 my @technology_option = &FS::Report::FCC_477::parse_technology_option($cgi,1);
79
80 # save upload and download mappings
81 my @download = $cgi->param('part1_column_option');
82 my @upload = $cgi->param('part1_row_option');
83 for(my $i=0; $i < scalar(@download); $i++) {
84     &FS::Report::FCC_477::save_fcc477map("part1_column_option_$i",$download[$i]);
85 }
86 for(my $i=0; $i < scalar(@upload); $i++) {
87     &FS::Report::FCC_477::save_fcc477map("part1_row_option_$i",$upload[$i]);
88 }
89
90 my @part2a_row_option = $cgi->param('part2a_row_option');
91 for(my $i=0; $i < scalar(@part2a_row_option); $i++) {
92     &FS::Report::FCC_477::save_fcc477map("part2a_row_option_$i",$part2a_row_option[$i]);
93 }
94
95 my @part2b_row_option = $cgi->param('part2b_row_option');
96 for(my $i=0; $i < scalar(@part2b_row_option); $i++) {
97     &FS::Report::FCC_477::save_fcc477map("part2b_row_option_$i",$part2b_row_option[$i]);
98 }
99
100 my $part5_report_option = $cgi->param('part5_report_option');
101 if ( $part5_report_option ) {
102   FS::Report::FCC_477::save_fcc477map('part5_report_option', $part5_report_option);
103 }
104
105 my $url_mangler = sub {
106   my $part = shift;
107   my $url = $cgi->url('-path_info' => 1, '-full' => 1);
108   $url =~ s/477\./477part$part./;
109   $url;
110 };
111 my @parts = qw( IA IIA IIB IV V VI_census );
112
113 </%init>