summaryrefslogtreecommitdiff
path: root/httemplate/search/477partV.html
blob: 2fd5119d1ebf0ae517db0067f17a689f8f2e0586 (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
<% include( 'elements/search.html',
                  'html_init'         => $html_init,
                  'name'              => 'zip code',
                  'query'             => $sql_query,
                  'count_query'       => $count_query,
                  'nohtmlheader'      => 1,
                  'disable_total'     => 1,
                  'header'            => [ 'zip code' ],
                  'xml_elements'      => [ 'zip codes' ],
                  'no_field_elements' => 1,
                  'fields'            => [ 'zip' ],
                  'url'               => $opt{url} || '',
                  'really_disable_download'  => 1,

              )
%>
<%init>

my $curuser = $FS::CurrentUser::CurrentUser;

die "access denied"
  unless $curuser->access_right('List packages');

my %opt = @_;
my $html_init = '<H2>Part V</H2>';
my %search_hash = ();
my @sql_query = ();
my @count_query = ();
  
for ( qw(agentnum magic state) ) {
  $search_hash{$_} = $cgi->param($_) if $cgi->param($_);
}
$search_hash{'country'} = 'US';
$search_hash{'classnum'} = [ $cgi->param('classnum') ];
$search_hash{report_option} = $cgi->param('partv_report_option')
  if $cgi->param('partv_report_option');

my $sql_query = FS::cust_pkg->search( { %search_hash,
                                        'fcc_line'    => 1,
                                        'select_zip5' => 1,
                                      }
                                    );
my $count_query = delete($sql_query->{'count_query'});
$count_query =~ s/COUNT\(\*\)/count(DISTINCT substr(zip,1,5))/;
$count_query =~ s/ORDER BY [.\w]+//;

</%init>