453cf8dd824c436bb65a6a59253ad6878a7dbb52
[freeside.git] / FS / FS / Report / FCC_477.pm
1 package FS::Report::FCC_477;
2
3 use strict;
4 use vars qw( @ISA @upload @download @technology @part2aoption @part2boption );
5 use FS::Report;
6 use FS::Record qw( dbh );
7
8 @ISA = qw( FS::Report );
9
10 =head1 NAME
11
12 FS::Report::FCC_477 - Routines for FCC Form 477 reports
13
14 =head1 SYNOPSIS
15
16 =head1 BUGS
17
18 Documentation.
19
20 =head1 SEE ALSO
21
22 =cut
23
24 @upload = qw(
25  <200kpbs
26  200-768kpbs
27  768kbps-1.5mbps
28  1.5-3mpbs
29  3-6mbps
30  6-10mbps
31  10-25mbps
32  25-100mbps
33  >100bmps
34 );
35
36 @download = qw(
37  200-768kpbs
38  768kbps-1.5mbps
39  1.5-3mpbs
40  3-6mbps
41  6-10mbps
42  10-25mbps
43  25-100mbps
44  >100bmps
45 );
46
47 @technology = (
48   'Asymetric xDSL',
49   'Symetric xDSL',
50   'Other Wireline',
51   'Cable Modem',
52   'Optical Carrier',
53   'Satellite',
54   'Terrestrial Fixed Wireless',
55   'Terrestrial Mobile Wireless',
56   'Electric Power Line',
57   'Other Technology',
58 );
59
60 @part2aoption = (
61  'LD carrier',
62  'owned loops',
63  'unswitched UNE loops',
64  'UNE-P',
65  'UNE-P replacement',
66  'FTTP',
67  'coax',
68  'wireless',
69 );
70
71 @part2boption = (
72  'nomadic',
73  'copper',
74  'FTTP',
75  'coax',
76  'wireless',
77  'other broadband',
78 );
79
80 sub restore_fcc477map {
81     my $key = shift;
82     FS::Record::scalar_sql('',"select formvalue from fcc477map where formkey = ?",$key);
83 }
84
85 sub save_fcc477map {
86     my $key = shift;
87     my $value = shift;
88
89     # lame, particularly lack of transactions
90
91     my $sql = "delete from fcc477map where formkey = ?";
92     my $sth = dbh->prepare($sql) or die dbh->errstr;
93     $sth->execute($key) or die "Error removing FCC 477 form defaults: " . $sth->errstr;
94
95     $sql = "insert into fcc477map (formkey,formvalue) values (?,?)";
96     $sth = dbh->prepare($sql) or die dbh->errstr;
97     $sth->execute($key,$value) or die "Error setting FCC 477 form defaults: " . $sth->errstr;
98
99     '';
100 }
101
102 sub parse_technology_option {
103   my $cgi = shift;
104   my $save = shift;
105   my @result = ();
106   my $i = 0;
107   for (my $i = 0; $i < scalar(@technology); $i++) {
108     my $value = $cgi->param("part1_technology_option_$i"); #lame
109     save_fcc477map("part1_technology_option_$i",$value) 
110         if $save && $value =~ /^\d+$/;
111     push @result, $value =~ /^\d+$/ ? $value : 0;
112   }
113   return (@result);
114 }
115
116 1;