2ffad2a27dbf241037ac66b725abf8f431d4685c
[freeside.git] / httemplate / search / 477partV.html
1 % if ( $cgi->param('_type') =~ /^xml$/ ) {
2 <zip_codes>
3 % }
4 <& elements/search.html,
5                   'html_init'         => $html_init,
6                   'name'              => 'zip code',
7                   'query'             => $sql_query,
8                   'count_query'       => $count_query,
9                   'nohtmlheader'      => 1,
10                   'disable_total'     => 1,
11                   'header'            => [ 'zip code' ],
12                   'xml_elements'      => [ 'zip codes' ],
13                   'no_field_elements' => 1,
14                   'fields'            => [ 'zip' ],
15                   'url'               => $opt{url} || '',
16                   'really_disable_download'  => 1,
17
18               
19 &>
20 % if ( $cgi->param('_type') =~ /^xml$/ ) {
21 </zip_codes>
22 % }
23 <%init>
24
25 my $curuser = $FS::CurrentUser::CurrentUser;
26
27 die "access denied"
28   unless $curuser->access_right('List packages');
29
30 my %opt = @_;
31 my $html_init = '<H2>Part V</H2>';
32 my %search_hash = ();
33 my @sql_query = ();
34 my @count_query = ();
35   
36 for ( qw(agentnum state) ) {
37   $search_hash{$_} = $cgi->param($_) if $cgi->param($_);
38 }
39 $search_hash{'country'} = 'US';
40 $search_hash{'classnum'} = [ $cgi->param('classnum') ];
41 $search_hash{report_option} = $cgi->param('part5_report_option')
42   if $cgi->param('part5_report_option');
43 $search_hash{'active'}   = [ $opt{date}, $opt{date} ];
44
45 my $sql_query = FS::cust_pkg->search( { %search_hash,
46                                         'fcc_line'    => 1,
47                                         'select_zip5' => 1,
48                                       }
49                                     );
50 my $count_query = delete($sql_query->{'count_query'});
51 $count_query =~ s/COUNT\(\*\)/count(DISTINCT substr(zip,1,5))/;
52 $count_query =~ s/ORDER BY [.\w]+//;
53
54 </%init>