X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fsearch%2Fcust_main-zip.html;h=e87b21474319ad4ef70ae18373d4a87ce1d0ced2;hp=333a1e0b1c674cf2914cc270251dbdae206de2f0;hb=c3da5cf1caa244937d280e0f406927103beef148;hpb=d453a487d95258e1f11f134fc5864f7e6458a6ef diff --git a/httemplate/search/cust_main-zip.html b/httemplate/search/cust_main-zip.html index 333a1e0b1..e87b21474 100644 --- a/httemplate/search/cust_main-zip.html +++ b/httemplate/search/cust_main-zip.html @@ -1,4 +1,17 @@ -<% +<% include( 'elements/search.html', + 'title' => 'Zip code Search Results', + 'name' => 'zip codes', + 'query' => $sql_query, + 'count_query' => $count_sql, + 'header' => [ 'Zip code', 'Customers', ], + #'fields' => [ 'zip', 'num_cust', ], + 'links' => [ '', sub { 'somewhere'; } ], + ) +%> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('List zip codes'); # XXX link to customers @@ -19,6 +32,17 @@ if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { $agentnum = $1; push @where, "cust_main.agentnum = $agentnum"; } + +# select svcdb + +if ( $cgi->param('svcdb') =~ /^(\w+)$/ ) { + my $svcdb = $1; + push @where, "EXISTS( SELECT 1 FROM $svcdb LEFT JOIN cust_svc USING ( svcnum ) + LEFT JOIN cust_pkg USING ( pkgnum ) + WHERE cust_pkg.custnum = cust_main.custnum + )"; +} + my $where = scalar(@where) ? 'WHERE '. join(' AND ', @where) : ''; # bill zip vs ship zip @@ -83,13 +107,4 @@ my $count_sql = "select count(distinct $czip) from cust_main $where"; # XXX should link... -%><%= include( 'elements/search.html', - 'title' => 'Zip code Search Results', - 'name' => 'zip codes', - 'query' => $sql_query, - 'count_query' => $count_sql, - 'header' => [ 'Zip code', 'Customers', ], - #'fields' => [ 'zip', 'num_cust', ], - 'links' => [ '', sub { 'somewhere'; } ], - ) -%> +