new 477 report: deployment info, combined browse-edit UI, #24047
[freeside.git] / httemplate / search / 477.html
1 <& /elements/header.html, $title &>
2 <STYLE TYPE="text/css">
3 table.fcc477part {
4   border-collapse: collapse;
5   border: 1px #777 solid;
6   margin-bottom: 20px;
7 }
8 table.fcc477part td {
9   padding: 0px 4px;
10   border-left: 1px #777 solid;
11   border-right: 1px #777 solid;
12 }
13 table.fcc477part tbody td {
14   text-align: right;
15 }
16 table.fcc477part thead tr.head {
17   text-align: center;
18   vertical-align: top;
19   font-weight: bold;
20   border-top: 1px #777 solid;
21   border-bottom: 1px #777 solid;
22 }
23 table.fcc477part thead tr.subhead {
24   text-align: center;
25   font-weight: bold;
26   font-size: small;
27   border-top: 1px #777 solid;
28   border-bottom: 1px #777 solid;
29 }
30 .parttitle {
31   font-weight: bold;
32   font-size: large;
33   float: left;
34 }
35 a.download {
36   float: right;
37 }
38 </STYLE>
39 % foreach my $partname (@partnames) {
40 %   $cgi->param('parts', $partname);
41 %   $cgi->param('type', 'csv');
42 <table class="fcc477part">
43   <caption>
44     <span class="parttitle"><% $parttitle{$partname} %></span>
45     <a class="download" href="<% $cgi->self_url %>">Download</a>
46   </caption>
47 %   my $header = ".header_$partname";
48 %   my $data = $parts{$partname};
49   <thead>
50     <& $header &>
51   </thead>
52 %   foreach my $row (@$data) {
53   <tr>
54 %     foreach my $item (@$row) {
55     <td><% $item %></td>
56 %     }
57   </tr>
58 %   }
59 </table>
60 % } # foreach $partname
61 <& /elements/footer.html &>
62 <%init>
63 die "access denied"
64   unless $FS::CurrentUser::CurrentUser->access_right('List packages');
65
66 my %parts;
67 # load from cache if possible
68 my $session;
69 if ( $cgi->param('session') =~ /^(\d+)$/ ) {
70   $session = $1;
71   %parts = %{ $m->cache->get($session) };
72 } else {
73   $session = sprintf('%010d%06d', time, int(rand(1000000)));
74   $cgi->param('session', $session);
75 }
76
77 my $agentnum;
78 if ($cgi->param('agentnum') =~ /^(\d+)$/ ) {
79   $agentnum = $1;
80 }
81 my $date = parse_datetime($cgi->param('date')) || time;
82 my @partnames = grep /^\w+$/, $cgi->param('parts');
83 foreach my $partname (@partnames) {
84   my $method = "report_$partname";
85   $parts{$partname} ||= FS::Report::FCC_477->$method(
86     date      => $date,
87     agentnum  => $agentnum
88   );
89 }
90 $m->cache->set($session, \%parts, '1h');
91
92 my $title = 'FCC Form 477 Data - ' . time2str('%b %o, %Y', $date);
93
94 if ( $cgi->param('type') eq 'csv' ) {
95   my $partname = $partnames[0]; # ignore any beyond the first
96   my $data = $parts{$partname};
97   my $csv = Text::CSV_XS->new({ eol => "\r\n" }); # i think
98
99   my $filename = time2str('%Y-%m-%d', $date) . '-'. $partname . '.csv';
100   http_header('Content-Type' => 'text/csv');
101   http_header('Content-Disposition' => qq(attachment;filename="$filename"));
102
103   $m->clear_buffer;
104
105   foreach my $row (@$data) {
106     $csv->combine(@$row);
107     $m->print($csv->string);
108   }
109   $m->abort;
110 }
111
112 </%init>
113 <%def .header_fixed_broadband>
114   <TR CLASS="head">
115     <TD ROWSPAN=2>Census Tract</TD>
116     <TD ROWSPAN=2>Technology</TD>
117     <TD COLSPAN=2>Speed (Mbps)</TD>
118     <TD COLSPAN=2>Subscriptions</TD>
119   </TR>
120   <TR CLASS="subhead">
121     <TD>Down</TD>
122     <TD>Up</TD>
123     <TD>Total</TD>
124     <TD>Consumer</TD>
125   </TR>
126 </%def>
127 <%def .header_fixed_voice>
128   <TR CLASS="head">
129     <TD ROWSPAN=2>Census Tract</TD>
130     <TD ROWSPAN=2>VoIP?</TD>
131     <TD COLSPAN=2>Lines/Subscriptions</TD>
132   </TR>
133   <TR CLASS="subhead">
134     <TD>Total</TD>
135     <TD>Consumer</TD>
136   </TR>
137 </%def>
138 <%def .header_local_phone>
139   <TR CLASS="head">
140     <TD ROWSPAN=3>State</TD>
141     <TD COLSPAN=2>Wholesale</TD>
142     <TD COLSPAN=12>End User Lines</TD>
143   </TR>
144   <TR CLASS="subhead">
145     <TD ROWSPAN=2>VGEs</TD>
146     <TD ROWSPAN=2>UNE-Ls</TD>
147
148     <TD ROWSPAN=2>Total</TD>
149     <TD ROWSPAN=2>With Broadband</TD>
150     <TD COLSPAN=2>Consumer</TD>
151     <TD COLSPAN=2>Business</TD>
152
153     <TD COLSPAN=3>Local Loop</TD>
154
155     <TD COLSPAN=3>Special Media</TD>
156   </TR>
157
158   <TR CLASS="subhead">
159     <TD> </TD>
160     <TD>+LD</TD>
161     <TD> </TD>
162     <TD>+LD</TD>
163
164     <TD>Owned</TD>
165     <TD>UNE-L</TD>
166     <TD>Resale</TD>
167
168     <TD>Fiber</TD>
169     <TD>Coaxial</TD>
170     <TD>Wireless</TD>
171   </TR>
172 </%def>
173 <%def .header_voip>
174   <TR CLASS="head">
175     <TD ROWSPAN=2>State</TD>
176     <TD COLSPAN=2>VoIP OTT</TD>
177     <TD COLSPAN=8>VoIP Non-OTT</TD>
178   </TR>
179   <TR CLASS="subhead">
180     <TD ROWSPAN=2>Total</TD>
181     <TD ROWSPAN=2>Consumer</TD>
182
183     <TD ROWSPAN=2>Total</TD>
184     <TD ROWSPAN=2>Consumer</TD>
185     <TD ROWSPAN=2>Bundled</TD>
186     <TD COLSPAN=5>Media Type</TD>
187   </TR>
188   <TR CLASS="subhead">
189     <TD>Copper</TD>
190     <TD>Fiber</TD>
191     <TD>Coaxial</TD>
192     <TD>Wireless</TD>
193     <TD>Other</TD>
194   </TR>
195 </%def>
196 <%def .header_mobile_broadband>
197 %# unimplemented
198   <TR CLASS="head">
199     <TD ROWSPAN=2>State</TD>
200     <TD COLSPAN=2>Speed (Mbps)</TD>
201     <TD COLSPAN=2>Subscriptions</TD>
202   </TR>
203   <TR CLASS="subhead">
204     <TD>Down</TD>
205     <TD>Up</TD>
206     <TD>Total</TD>
207     <TD>Consumer</TD>
208   </TR>
209 </%def>
210 <%def .header_mobile_voice>
211 %# unimplemented
212   <TR CLASS="head">
213     <TD ROWSPAN=2>State</TD>
214     <TD COLSPAN=2>Subscriptions</TD>
215   </TR>
216   <TR CLASS="subhead">
217     <TD>Total</TD>
218     <TD>Direct</TD>
219   </TR>
220 </%def>
221