From 1d15c6930650f2cceb13f7ae9da4acea5213643f Mon Sep 17 00:00:00 2001 From: levinse Date: Mon, 25 Apr 2011 04:00:03 +0000 Subject: [PATCH] FCC form 477 report improvements, RT12089 --- FS/FS/Report/FCC_477.pm | 26 ++++++++++++++++++++++++++ FS/FS/Schema.pm | 10 ++++++++++ httemplate/search/477.html | 13 ++++++++++++- httemplate/search/477partIA_detail.html | 4 +++- httemplate/search/477partIA_summary.html | 3 ++- httemplate/search/477partIIA.html | 3 ++- httemplate/search/477partIIB.html | 3 ++- httemplate/search/477partV.html | 3 ++- httemplate/search/477partVI_census.html | 3 ++- httemplate/search/report_477.html | 14 ++++++++++++-- 10 files changed, 73 insertions(+), 9 deletions(-) diff --git a/FS/FS/Report/FCC_477.pm b/FS/FS/Report/FCC_477.pm index 518b9f0e1..453cf8dd8 100644 --- a/FS/FS/Report/FCC_477.pm +++ b/FS/FS/Report/FCC_477.pm @@ -3,6 +3,7 @@ package FS::Report::FCC_477; use strict; use vars qw( @ISA @upload @download @technology @part2aoption @part2boption ); use FS::Report; +use FS::Record qw( dbh ); @ISA = qw( FS::Report ); @@ -76,12 +77,37 @@ Documentation. 'other broadband', ); +sub restore_fcc477map { + my $key = shift; + FS::Record::scalar_sql('',"select formvalue from fcc477map where formkey = ?",$key); +} + +sub save_fcc477map { + my $key = shift; + my $value = shift; + + # lame, particularly lack of transactions + + my $sql = "delete from fcc477map where formkey = ?"; + my $sth = dbh->prepare($sql) or die dbh->errstr; + $sth->execute($key) or die "Error removing FCC 477 form defaults: " . $sth->errstr; + + $sql = "insert into fcc477map (formkey,formvalue) values (?,?)"; + $sth = dbh->prepare($sql) or die dbh->errstr; + $sth->execute($key,$value) or die "Error setting FCC 477 form defaults: " . $sth->errstr; + + ''; +} + sub parse_technology_option { my $cgi = shift; + my $save = shift; my @result = (); my $i = 0; for (my $i = 0; $i < scalar(@technology); $i++) { my $value = $cgi->param("part1_technology_option_$i"); #lame + save_fcc477map("part1_technology_option_$i",$value) + if $save && $value =~ /^\d+$/; push @result, $value =~ /^\d+$/ ? $value : 0; } return (@result); diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 0b6ea0d2b..deb3995d2 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -1406,6 +1406,16 @@ sub tables_hashref { 'index' => [ ['batchnum'], ['invnum'], ['custnum'] ], }, + 'fcc477map' => { + 'columns' => [ + 'formkey', 'varchar', '', '', '', '', + 'formvalue', 'text', 'NULL', '', '', '', + ], + 'primary_key' => 'formkey', + 'unique' => [], + 'index' => [], + }, + 'cust_pkg' => { 'columns' => [ 'pkgnum', 'serial', '', '', '', '', diff --git a/httemplate/search/477.html b/httemplate/search/477.html index d586406af..a3880a52e 100755 --- a/httemplate/search/477.html +++ b/httemplate/search/477.html @@ -81,7 +81,18 @@ die "access denied" my %part = map { $_ => 1 } grep { /^\w+$/ } $cgi->param('part'); my $type = $cgi->param('_type') || 'html'; my $xlsname = '477report'; -my @technology_option = &FS::Report::FCC_477::parse_technology_option($cgi); +my @technology_option = &FS::Report::FCC_477::parse_technology_option($cgi,1); + +# save upload and download mappings +my @download = $cgi->param('part1_column_option'); +my @upload = $cgi->param('part1_row_option'); +for(my $i=0; $i < scalar(@download); $i++) { + &FS::Report::FCC_477::save_fcc477map("part1_column_option_$i",$download[$i]); +} +for(my $i=0; $i < scalar(@upload); $i++) { + &FS::Report::FCC_477::save_fcc477map("part1_row_option_$i",$upload[$i]); +} + my $url_mangler = sub { my $part = shift; my $url = $cgi->url('-path_info' => 1, '-full' => 1); diff --git a/httemplate/search/477partIA_detail.html b/httemplate/search/477partIA_detail.html index 6fea39109..2eca1072b 100755 --- a/httemplate/search/477partIA_detail.html +++ b/httemplate/search/477partIA_detail.html @@ -23,10 +23,12 @@ die "access denied" my %opt = @_; my %search_hash = (); -for ( qw(agentnum magic classnum) ) { +for ( qw(agentnum magic) ) { $search_hash{$_} = $cgi->param($_) if $cgi->param($_); } +$search_hash{'classnum'} = [ $cgi->param('classnum') ]; + my @column_option = grep { /^\d+/ } $cgi->param('part1_column_option') if $cgi->param('part1_column_option'); diff --git a/httemplate/search/477partIA_summary.html b/httemplate/search/477partIA_summary.html index eb1c11607..ecacaefad 100755 --- a/httemplate/search/477partIA_summary.html +++ b/httemplate/search/477partIA_summary.html @@ -40,9 +40,10 @@ die "access denied" my %opt = @_; my %search_hash = (); -for ( qw(agentnum magic classnum) ) { +for ( qw(agentnum magic) ) { $search_hash{$_} = $cgi->param($_) if $cgi->param($_); } +$search_hash{'classnum'} = [ $cgi->param('classnum') ]; my @column_option = grep { /^\d+$/ } $cgi->param('part1_column_option') if $cgi->param('part1_column_option'); diff --git a/httemplate/search/477partIIA.html b/httemplate/search/477partIIA.html index 64f773a21..80ad39368 100755 --- a/httemplate/search/477partIIA.html +++ b/httemplate/search/477partIIA.html @@ -22,9 +22,10 @@ die "access denied" my $html_init = '

Part IIA

'; my %search_hash = (); -for ( qw(agentnum magic classnum) ) { +for ( qw(agentnum magic) ) { $search_hash{$_} = $cgi->param($_) if $cgi->param($_); } +$search_hash{'classnum'} = [ $cgi->param('classnum') ]; my @row_option = grep { /^\d+$/ } $cgi->param('part2a_row_option') if $cgi->param('part2a_row_option'); diff --git a/httemplate/search/477partIIB.html b/httemplate/search/477partIIB.html index 278dfdc8b..ffc6e12f5 100755 --- a/httemplate/search/477partIIB.html +++ b/httemplate/search/477partIIB.html @@ -22,9 +22,10 @@ die "access denied" my $html_init = '

Part IIB

'; my %search_hash = (); -for ( qw(agentnum magic classnum) ) { +for ( qw(agentnum magic) ) { $search_hash{$_} = $cgi->param($_) if $cgi->param($_); } +$search_hash{'classnum'} = [ $cgi->param('classnum') ]; my @row_option = grep { /^\d+$/ } $cgi->param('part2b_row_option') if $cgi->param('part2b_row_option'); diff --git a/httemplate/search/477partV.html b/httemplate/search/477partV.html index 885294d28..e0f5e043a 100755 --- a/httemplate/search/477partV.html +++ b/httemplate/search/477partV.html @@ -26,9 +26,10 @@ my %search_hash = (); my @sql_query = (); my @count_query = (); -for ( qw(agentnum magic classnum) ) { +for ( qw(agentnum magic) ) { $search_hash{$_} = $cgi->param($_) if $cgi->param($_); } +$search_hash{'classnum'} = [ $cgi->param('classnum') ]; my $sql_query = FS::cust_pkg->search( { %search_hash, 'fcc_line' > 1 }); $sql_query->{select} = 'DISTINCT zip'; diff --git a/httemplate/search/477partVI_census.html b/httemplate/search/477partVI_census.html index 1d625dcb0..9134bacca 100755 --- a/httemplate/search/477partVI_census.html +++ b/httemplate/search/477partVI_census.html @@ -77,9 +77,10 @@ my %search_hash = (); my @sql_query = (); my %state_hash = (); -for ( qw(agentnum magic classnum) ) { +for ( qw(agentnum magic) ) { $search_hash{$_} = $cgi->param($_) if $cgi->param($_); } +$search_hash{'classnum'} = [ $cgi->param('classnum') ]; my @column_option = grep { /^\d+$/ } $cgi->param('part1_column_option') if $cgi->param('part1_column_option'); diff --git a/httemplate/search/report_477.html b/httemplate/search/report_477.html index 7ac497a11..d34fb8f96 100755 --- a/httemplate/search/report_477.html +++ b/httemplate/search/report_477.html @@ -18,7 +18,7 @@ %> <% include( '/elements/tr-select-pkg_class.html', - 'pre_options' => [ '0' => 'all' ], + 'multiple' => 1, 'empty_label' => '(empty class)', ) %> @@ -46,6 +46,7 @@ Part IA
Download speeds +% my $i = 0; % foreach my $speed ( @FS::Report::FCC_477::download ) { @@ -56,14 +57,18 @@ 'hashref' => { 'disabled' => '' }, 'element_name' => 'part1_column_option', 'disable_empty' => 1, + 'curr_value' => + FS::Report::FCC_477::restore_fcc477map("part1_column_option_$i"), ) %> +% $i++ % }
<% $speed %>
Upload speeds +% $i = 0; % foreach my $speed ( @FS::Report::FCC_477::upload ) { @@ -74,15 +79,18 @@ 'hashref' => { 'disabled' => '' }, 'element_name' => 'part1_row_option', 'disable_empty' => 1, + 'curr_value' => + FS::Report::FCC_477::restore_fcc477map("part1_row_option_$i"), ) %> +% $i++ % }
<% $speed %>
Technologies -% my $i = 0; +% $i = 0; % foreach my $tech ( @FS::Report::FCC_477::technology ) { @@ -93,6 +101,8 @@ 'hashref' => { 'disabled' => '' }, 'element_name' => "part1_technology_option_$i", 'empty_label' => '(omit)', + 'curr_value' => + FS::Report::FCC_477::restore_fcc477map("part1_technology_option_$i"), ) %> -- 2.11.0
<% $tech %>