summaryrefslogtreecommitdiff
path: root/httemplate/search/477.html
diff options
context:
space:
mode:
authorjeff <jeff>2009-07-16 01:57:07 +0000
committerjeff <jeff>2009-07-16 01:57:07 +0000
commit0b407666b53dea109661f25d51860a7e7e06981f (patch)
tree046c7ff544278881423cb18120951a34898a7056 /httemplate/search/477.html
parenta06bd793c13d7d616d698f517be88b1812e8cea9 (diff)
duh! more 477 files
Diffstat (limited to 'httemplate/search/477.html')
-rwxr-xr-xhttemplate/search/477.html70
1 files changed, 70 insertions, 0 deletions
diff --git a/httemplate/search/477.html b/httemplate/search/477.html
new file mode 100755
index 0000000..45c92ff
--- /dev/null
+++ b/httemplate/search/477.html
@@ -0,0 +1,70 @@
+<% include( 'elements/search.html',
+ 'title' => 'FCC Form 477 Results',
+ 'html_init' => $html_init,
+ 'name' => 'regions',
+ 'query' => $sql_query,
+ 'count_query' => $count_query,
+ 'header' => [
+ 'State code',
+ 'County code',
+ 'Census tract code',
+ 'Quantity',
+ ],
+ 'fields' => [
+ sub { my $row = shift; substr($row->censustract, 0, 2) },
+ sub { my $row = shift; substr($row->censustract, 2, 3) },
+ sub { my $row = shift; substr($row->censustract, 5) },
+ 'quantity',
+ ],
+ 'links' => [
+ [ $link, 'censustract' ],
+ [ $link, 'censustract' ],
+ [ $link, 'censustract' ],
+ [ $link, 'censustract' ],
+ ],
+ )
+%>
+<%init>
+
+my $curuser = $FS::CurrentUser::CurrentUser;
+
+die "access denied"
+ unless $curuser->access_right('List packages');
+
+my %search_hash = ();
+
+$search_hash{'query'} = $cgi->keywords;
+
+for ( qw(agentnum magic status classnum) ) {
+ $search_hash{$_} = $cgi->param($_) if $cgi->param($_);
+}
+
+
+my @report_option = $cgi->param('report_option')
+ if $cgi->param('report_option');
+$search_hash{report_option} = join(',', @report_option) if @report_option;
+
+my $where = join(' OR ', map { "num = $_" } grep { /^\d+$/ } @report_option );
+my @report_option_name = $where ?
+ ( map { $_->name }
+ qsearch({ 'table' => 'part_pkg_report_option',
+ 'hashref' => {},
+ 'extra_sql' => "WHERE $where",
+ })
+ ) :
+ ( 'all packages' );
+
+my $html_init = "For <BR>". join(' and <BR>', @report_option_name). "<BR>";
+
+my $sql_query = FS::cust_pkg->search_sql(\%search_hash);
+
+$sql_query->{select} = 'count(*) as quantity, censustract';
+$sql_query->{extra_sql} =~ /^(.*)(ORDER BY bill)(.*)$/s or die "couldn't parse extra_sql";
+$sql_query->{extra_sql} = "$1 GROUP BY censustract $3";
+
+my $count_query = delete($sql_query->{'count_query'});
+$count_query = 'SELECT count(*) FROM (SELECT count(*) FROM cust_pkg '.
+ $sql_query->{addl_from}. ' '. $sql_query->{extra_sql}. ') AS foo';
+
+my $link = 'cust_pkg.cgi?'. $cgi->query_string. ';censustract=';
+</%init>