FCC form 477 report improvements, RT12089
authorlevinse <levinse>
Mon, 25 Apr 2011 04:00:03 +0000 (04:00 +0000)
committerlevinse <levinse>
Mon, 25 Apr 2011 04:00:03 +0000 (04:00 +0000)
FS/FS/Report/FCC_477.pm
FS/FS/Schema.pm
httemplate/search/477.html
httemplate/search/477partIA_detail.html
httemplate/search/477partIA_summary.html
httemplate/search/477partIIA.html
httemplate/search/477partIIB.html
httemplate/search/477partV.html
httemplate/search/477partVI_census.html
httemplate/search/report_477.html

index 518b9f0..453cf8d 100644 (file)
@@ -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);
index 0b6ea0d..deb3995 100644 (file)
@@ -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',     '', '', '', '', 
index d586406..a3880a5 100755 (executable)
@@ -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);
index 6fea391..2eca107 100755 (executable)
@@ -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');
 
index eb1c116..ecacaef 100755 (executable)
@@ -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');
index 64f773a..80ad393 100755 (executable)
@@ -22,9 +22,10 @@ die "access denied"
 my $html_init = '<H2>Part IIA</H2>';
 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');
index 278dfdc..ffc6e12 100755 (executable)
@@ -22,9 +22,10 @@ die "access denied"
 my $html_init = '<H2>Part IIB</H2>';
 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');
index 885294d..e0f5e04 100755 (executable)
@@ -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';
index 1d625dc..9134bac 100755 (executable)
@@ -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');
index 7ac497a..d34fb8f 100755 (executable)
@@ -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 @@
     <TR id='partIA' style="display:none"><TD>Part IA</TD><TD><TABLE>
       <TR><TD>Download speeds</TD><TD>
         <TABLE>
+%       my $i = 0;
 %       foreach my $speed ( @FS::Report::FCC_477::download ) {
           <TR>
             <TH><% $speed %></TH>
                            'hashref'      => { 'disabled' => '' },
                            'element_name' => 'part1_column_option',
                            'disable_empty' => 1,
+                           'curr_value'   =>
+                                FS::Report::FCC_477::restore_fcc477map("part1_column_option_$i"),
                        )
             %>
             </TD>
           </TR>
+%       $i++
 %       }
         </TABLE></TD>
       <TD>Upload speeds</TD><TD>
         <TABLE>
+%       $i = 0;
 %       foreach my $speed ( @FS::Report::FCC_477::upload ) {
           <TR>
             <TH><% $speed %></TH>
                            'hashref'      => { 'disabled' => '' },
                            'element_name' => 'part1_row_option',
                            'disable_empty' => 1,
+                           'curr_value'   =>
+                                FS::Report::FCC_477::restore_fcc477map("part1_row_option_$i"),
                        )
             %>
             </TD>
           </TR>
+%       $i++
 %       }
         </TABLE></TD></TR>
       <TR><TD>Technologies</TD><TD>
         <TABLE>
-%       my $i = 0;
+%       $i = 0;
 %       foreach my $tech ( @FS::Report::FCC_477::technology ) {
           <TR>
             <TH><% $tech %></TH>
                            'hashref'      => { 'disabled' => '' },
                            'element_name' => "part1_technology_option_$i",
                            'empty_label'  => '(omit)',
+                           'curr_value'   =>
+                                FS::Report::FCC_477::restore_fcc477map("part1_technology_option_$i"),
                        )
             %>
             </TD>