don't redirect to a GET with sensitive data, RT#26099
[freeside.git] / httemplate / search / report_477.html
1 <% include('/elements/header.html', 'FCC Form 477 Report' ) %>
2
3 <FORM ACTION="477.html" METHOD="GET">
4 <INPUT TYPE="hidden" NAME="magic" VALUE="active">
5
6   <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
7
8     <TR>
9       <TH CLASS="background" COLSPAN=2 ALIGN="left">
10         <FONT SIZE="+1">Search options</FONT>
11       </TH>
12     </TR>
13
14     <% include( '/elements/tr-select-agent.html',
15                    'curr_value'    => scalar( $cgi->param('agentnum') ),
16                    'disable_empty' => 0,
17                )
18     %>
19
20     <& /elements/tr-td-label.html, 'label' => 'State' &>
21     <TD>
22       <SELECT NAME="state">
23 %   foreach (@states) {
24         <OPTION VALUE="<% $_ %>"><% $_ %></OPTION>
25 %   }
26       </SELECT>
27     </TD></TR>
28
29     <% include( '/elements/tr-select-pkg_class.html',
30                    'multiple'       => 1,
31                    'empty_label' => '(empty class)',
32                )
33     %>
34
35     <SCRIPT type="text/javascript">
36       function partchange(what) {
37         var id = 'part' + what.value;
38         var element = document.getElementById(id);
39         if (what.checked) {
40           element.style.display = '';
41         } else {
42           element.style.display = 'none';
43         }
44       }
45       function toggleV() {
46         document.getElementById('enableV').disabled =
47           ! (document.getElementById('enableIIA').checked ||
48              document.getElementById('enableIIB').checked);
49       }
50       function toggleVI() {
51         document.getElementById('enableVI').disabled =
52           ! document.getElementById('enableIA').checked;
53       }
54     </SCRIPT>
55
56     <% include( '/elements/tr-checkbox.html',
57                    'label' => 'Enable part IA?',
58                    'field' => 'part',
59                    'id'    => 'enableIA',
60                    'value' => 'IA',
61                    'onchange' => 'partchange(this); toggleVI();',
62                )
63     %>
64
65     <TR id='partIA' style="display:none"><TD>Part IA</TD><TD><TABLE>
66       <TR><TD>Download speeds</TD><TD>
67         <TABLE>
68 %       my $i = 0;
69 %       foreach my $speed ( @FS::Report::FCC_477::download ) {
70           <TR>
71             <TH><% $speed %></TH>
72             <TD>
73             <% include( '/elements/select-table.html',
74                            'table'        => 'part_pkg_report_option',
75                            'name_col'     => 'name',
76                            'hashref'      => { 'disabled' => '' },
77                            'element_name' => 'part1_column_option',
78                            'disable_empty' => 1,
79                            'curr_value'   =>
80                                 FS::Report::FCC_477::restore_fcc477map("part1_column_option_$i"),
81                        )
82             %>
83             </TD>
84           </TR>
85 %       $i++
86 %       }
87         </TABLE></TD>
88       <TD>Upload speeds</TD><TD>
89         <TABLE>
90 %       $i = 0;
91 %       foreach my $speed ( @FS::Report::FCC_477::upload ) {
92           <TR>
93             <TH><% $speed %></TH>
94             <TD>
95             <% include( '/elements/select-table.html',
96                            'table'        => 'part_pkg_report_option',
97                            'name_col'     => 'name',
98                            'hashref'      => { 'disabled' => '' },
99                            'element_name' => 'part1_row_option',
100                            'disable_empty' => 1,
101                            'curr_value'   =>
102                                 FS::Report::FCC_477::restore_fcc477map("part1_row_option_$i"),
103                        )
104             %>
105             </TD>
106           </TR>
107 %       $i++
108 %       }
109         </TABLE></TD></TR>
110       <TR><TD>Technologies</TD><TD>
111         <TABLE>
112 %       $i = 0;
113 %       foreach my $tech ( @FS::Report::FCC_477::technology ) {
114           <TR>
115             <TH><% $tech %></TH>
116             <TD>
117             <% include( '/elements/select-table.html',
118                            'table'        => 'part_pkg_report_option',
119                            'name_col'     => 'name',
120                            'hashref'      => { 'disabled' => '' },
121                            'element_name' => "part1_technology_option_$i",
122                            'empty_label'  => '(omit)',
123                            'curr_value'   =>
124                                 FS::Report::FCC_477::restore_fcc477map("part1_technology_option_$i"),
125                        )
126             %>
127             </TD>
128           </TR>
129 %       $i++
130 %       }
131         </TABLE></TD></TR>
132     </TABLE></TD></TR>
133
134     <% include( '/elements/tr-checkbox.html',
135                    'label' => 'Enable part IIA?',
136                    'field' => 'part',
137                    'id'    => 'enableIIA',
138                    'value' => 'IIA',
139                    'onchange' => 'partchange(this); toggleV();',
140                )
141     %>
142
143     <TR id='partIIA' style="display:none"><TD>Part IIA</TD><TD><TABLE>
144 %   $i = 0;
145 %   foreach my $option ( @FS::Report::FCC_477::part2aoption ) {
146     <TR>
147       <TH><% $option %></TH>
148       <TD>
149       <% include( '/elements/select-table.html',
150                      'table'        => 'part_pkg_report_option',
151                      'name_col'     => 'name',
152                      'hashref'      => { 'disabled' => '' },
153                      'element_name' => 'part2a_row_option',
154                      'curr_value'   =>
155                            FS::Report::FCC_477::restore_fcc477map("part2a_row_option_$i"),
156                  )
157       %>
158       </TD>
159     </TR>
160 %    $i++
161 %   }
162   </TABLE></TD></TR>
163
164     <% include( '/elements/tr-checkbox.html',
165                    'label' => 'Enable part IIB?',
166                    'field' => 'part',
167                    'id'    => 'enableIIB',
168                    'value' => 'IIB',
169                    'onchange' => 'partchange(this); toggleV();',
170                )
171     %>
172
173     <TR id='partIIB' style="display:none"><TD>Part IIB</TD><TD><TABLE>
174 %   $i = 0;
175 %   foreach my $option ( @FS::Report::FCC_477::part2boption ) {
176     <TR>
177       <TH><% $option %></TH>
178       <TD>
179       <% include( '/elements/select-table.html',
180                      'table'        => 'part_pkg_report_option',
181                      'name_col'     => 'name',
182                      'hashref'      => { 'disabled' => '' },
183                      'element_name' => 'part2b_row_option',
184                       'curr_value'   =>
185                             FS::Report::FCC_477::restore_fcc477map("part2b_row_option_$i"),
186                  )
187       %>
188       </TD>
189     </TR>
190 %    $i++
191 %   }
192   </TABLE></TD></TR>
193
194     <% include( '/elements/tr-checkbox.html',
195                    'label' => 'Enable part IV?',
196                    'field' => 'part',
197                    'id'    => 'enableIV', #unused
198                    'value' => 'IV',
199                    'onchange' => 'partchange(this)',
200                )
201     %>
202
203     <TR id='partIV' style="display:none"><TD>Part IV</TD><TD><TABLE>
204     <% include( '/elements/tr-textarea.html',
205                    'label'        => 'Explanatory notes',
206                    'id'           => 'partIV',
207                    'field'         => 'notes',
208                    'rows'         => 15,
209                    'cols'         => 80,
210                )
211     %>
212   </TABLE></TD></TR>
213
214     <% include( '/elements/tr-checkbox.html',
215                    'label' => 'Enable part V?',
216                    'field' => 'part',
217                    'value' => 'V',
218                    'id'    => 'enableV',
219                    'onchange' => 'partchange(this)',
220                    'postfix'  => 
221                     '&nbsp;<FONT SIZE="-1">(requires Part IIA or IIB)</FONT>',
222                )
223     %>
224     <TR id='partV' style="display:none">
225         <TD>Part V</TD>
226         <TD>
227             <% include( '/elements/select-table.html',
228                      'table'        => 'part_pkg_report_option',
229                      'name_col'     => 'name',
230                      'hashref'      => { 'disabled' => '' },
231                      'element_name' => 'part5_report_option',
232                      'curr_value'   =>
233                             FS::Report::FCC_477::restore_fcc477map("part5_report_option"),
234                  )
235             %>
236         </TD>
237     </TR>
238
239
240     <% include( '/elements/tr-checkbox.html',
241                    'label' => 'Enable part VI?',
242                    'field' => 'part',
243                    'id'    => 'enableVI',
244                    'value' => 'VI_census',
245                    'postfix'  =>
246                     '&nbsp;<FONT SIZE="-1">(requires part IA)</FONT>',
247                )
248     %>
249   <SCRIPT TYPE="text/javascript">
250   toggleV();
251   toggleVI();
252   </SCRIPT>
253   </TABLE>
254
255 <BR>
256 <INPUT TYPE="submit" VALUE="Get Report">
257
258 </FORM>
259
260 <% include('/elements/footer.html') %>
261 <%init>
262
263 die "access denied"
264   unless $FS::CurrentUser::CurrentUser->access_right('List packages');
265
266 my @states = (
267   qsearch({
268     'table'   => 'cust_main',
269     'select'  => 'DISTINCT(state)',
270     'hashref' => { 'country' => 'US' }, # 477 report isn't relevant elsewhere
271   }),
272   qsearch({
273     'table'   => 'cust_main',
274     'select'  => 'DISTINCT(ship_state) AS state',
275     'hashref' => { 'country' => 'US' },
276   }),
277   qsearch({
278     'table'   => 'cust_location',
279     'select'  => 'DISTINCT(state)',
280     'hashref' => { 'country' => 'US' },
281   }),
282 );
283
284 {
285   my %seen = map {$_->get('state') => 1} @states;
286   @states = grep $_, sort keys(%seen);
287 }
288
289 </%init>