use strict;
use vars qw( @ISA @upload @download @technology @part2aoption @part2boption );
use FS::Report;
+use FS::Record qw( dbh );
@ISA = qw( FS::Report );
'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' => [ ['batchnum'], ['invnum'], ['custnum'] ],
},
+ 'fcc477map' => {
+ 'columns' => [
+ 'formkey', 'varchar', '', '', '', '',
+ 'formvalue', 'text', 'NULL', '', '', '',
+ ],
+ 'primary_key' => 'formkey',
+ 'unique' => [],
+ 'index' => [],
+ },
+
'cust_pkg' => {
'columns' => [
'pkgnum', 'serial', '', '', '', '',
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);
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');
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');
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');
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');
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';
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');
%>
<% include( '/elements/tr-select-pkg_class.html',
- 'pre_options' => [ '0' => 'all' ],
+ 'multiple' => 1,
'empty_label' => '(empty class)',
)
%>
<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>