summaryrefslogtreecommitdiff
path: root/httemplate/search/477.html
blob: 68493377d7593f730de7f5e6d2ae433327777802 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<& /elements/header.html, $title &>
<STYLE TYPE="text/css">
table.fcc477part {
  border-collapse: collapse;
  border: 1px #777 solid;
  margin-bottom: 20px;
}
table.fcc477part td {
  padding: 0px 4px;
  border-left: 1px #777 solid;
  border-right: 1px #777 solid;
}
table.fcc477part tbody td {
  text-align: right;
}
table.fcc477part thead tr.head {
  text-align: center;
  vertical-align: top;
  font-weight: bold;
  border-top: 1px #777 solid;
  border-bottom: 1px #777 solid;
}
table.fcc477part thead tr.subhead {
  text-align: center;
  font-weight: bold;
  font-size: small;
  border-top: 1px #777 solid;
  border-bottom: 1px #777 solid;
}
.parttitle {
  font-weight: bold;
  font-size: large;
  float: left;
}
a.download {
  float: right;
}
</STYLE>
% foreach my $partnum (@partnums) {
%   $cgi->param('parts', $partnum);
%   $cgi->param('type', 'csv');
<table class="fcc477part">
  <caption>
    <span class="parttitle">Part <% $partnum %></span>
    <a class="download" href="<% $cgi->self_url %>">Download</a>
  </caption>
%   my $header = ".header$partnum";
%   my $data = $parts{$partnum};
  <thead>
    <& $header &>
  </thead>
%   #XXX column headings
%   foreach my $row (@$data) {
  <tr>
%     foreach my $item (@$row) {
    <td><% $item %></td>
%     }
  </tr>
%   }
</table>
% } # foreach $partnum
<& /elements/footer.html &>
<%init>
die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('List packages');

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);
}

my $agentnum;
if ($cgi->param('agentnum') =~ /^(\d+)$/ ) {
  $agentnum = $1;
}
my $date = parse_datetime($cgi->param('date')) || time;
my @partnums = grep /^\d+$/, $cgi->param('parts');
foreach my $partnum (@partnums) {
  my $method = "part$partnum";
  $parts{$partnum} ||= 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 $partnum = $partnums[0]; # ignore any beyond the first
  my $data = $parts{$partnum};
  my $csv = Text::CSV_XS->new({ eol => "\r\n" }); # i think

  my $filename = time2str('%Y-%m-%d', $date) . '-part' . $partnum . '.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;
}

</%init>
<%def .header6>
  <TR CLASS="head">
    <TD ROWSPAN=2>Census Tract</TD>
    <TD ROWSPAN=2>Technology</TD>
    <TD COLSPAN=2>Speed (Mbps)</TD>
    <TD COLSPAN=2>Subscriptions</TD>
  </TR>
  <TR CLASS="subhead">
    <TD>Down</TD>
    <TD>Up</TD>
    <TD>Total</TD>
    <TD>Consumer</TD>
  </TR>
</%def>
<%def .header7>
  <TR CLASS="head">
    <TD ROWSPAN=2>State</TD>
    <TD COLSPAN=2>Speed (Mbps)</TD>
    <TD COLSPAN=2>Subscriptions</TD>
  </TR>
  <TR CLASS="subhead">
    <TD>Down</TD>
    <TD>Up</TD>
    <TD>Total</TD>
    <TD>Consumer</TD>
  </TR>
</%def>
<%def .header8>
  <TR CLASS="head">
    <TD ROWSPAN=2>State</TD>
    <TD COLSPAN=2>Subscriptions</TD>
  </TR>
  <TR CLASS="subhead">
    <TD>Total</TD>
    <TD>Direct</TD>
  </TR>
</%def>
<%def .header9>
  <TR CLASS="head">
    <TD ROWSPAN=3>State</TD>
    <TD COLSPAN=2>Wholesale</TD>
    <TD COLSPAN=12>End User Lines</TD>
  </TR>
  <TR CLASS="subhead">
    <TD ROWSPAN=2>VGEs</TD>
    <TD ROWSPAN=2>UNE-Ls</TD>

    <TD ROWSPAN=2>Total</TD>
    <TD ROWSPAN=2>With Broadband</TD>
    <TD COLSPAN=2>Consumer</TD>
    <TD COLSPAN=2>Business</TD>

    <TD COLSPAN=3>Local Loop</TD>

    <TD COLSPAN=3>Special Media</TD>
  </TR>

  <TR CLASS="subhead">
    <TD> </TD>
    <TD>+LD</TD>
    <TD> </TD>
    <TD>+LD</TD>

    <TD>Owned</TD>
    <TD>UNE-L</TD>
    <TD>Resale</TD>

    <TD>Fiber</TD>
    <TD>Coaxial</TD>
    <TD>Wireless</TD>
  </TR>
</%def>
<%def .header10>
  <TR CLASS="head">
    <TD ROWSPAN=2>State</TD>
    <TD COLSPAN=2>VoIP OTT</TD>
    <TD COLSPAN=8>VoIP Non-OTT</TD>
  </TR>
  <TR CLASS="subhead">
    <TD ROWSPAN=2>Total</TD>
    <TD ROWSPAN=2>Consumer</TD>

    <TD ROWSPAN=2>Total</TD>
    <TD ROWSPAN=2>Consumer</TD>
    <TD ROWSPAN=2>Bundled</TD>
    <TD COLSPAN=5>Media Type</TD>
  </TR>
  <TR CLASS="subhead">
    <TD>Copper</TD>
    <TD>Fiber</TD>
    <TD>Coaxial</TD>
    <TD>Wireless</TD>
    <TD>Other</TD>
  </TR>
</%def>
<%def .header11>
  <TR CLASS="head">
    <TD ROWSPAN=2>Census Tract</TD>
    <TD ROWSPAN=2>VoIP?</TD>
    <TD COLSPAN=2>Lines/Subscriptions</TD>
  </TR>
  <TR CLASS="subhead">
    <TD>Total</TD>
    <TD>Consumer</TD>
  </TR>
</%def>