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