start of FCC 477 report rewrite, #24047 and #28020
[freeside.git] / FS / FS / part_pkg_fcc_option.pm
1 package FS::part_pkg_fcc_option;
2
3 use strict;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
6 use Storable qw(dclone);
7 use Tie::IxHash;
8
9 sub table { 'part_pkg_fcc_option'; }
10
11 =head1 NAME
12
13 FS::part_pkg_fcc_option - Object methods for part_pkg_fcc_option records
14
15 =head1 SYNOPSIS
16
17   use FS::part_pkg_fcc_option;
18
19   $record = new FS::part_pkg_fcc_option \%hash;
20   $record = new FS::part_pkg_fcc_option { 'column' => 'value' };
21
22   $error = $record->insert;
23
24   $error = $new_record->replace($old_record);
25
26   $error = $record->delete;
27
28   $error = $record->check;
29
30 =head1 DESCRIPTION
31
32 An FS::part_pkg_fcc_option object represents an option that classifies a
33 package definition on the FCC Form 477 report.  FS::part_pkg_fcc_option 
34 inherits from FS::Record.  The following fields are currently supported:
35
36 =over 4
37
38 =item num
39
40 primary key
41
42 =item fccoptionname
43
44 A string identifying a report option, as an element of a static data
45 structure found within this module.  See the C<part> method.
46
47 =item pkgpart
48
49 L<FS::part_pkg> foreign key.
50
51 =item optionvalue
52
53 The value of the report option, as an integer.  Boolean options use 1 
54 and NULL.  Most other options have some kind of lookup table.
55
56 =back
57
58 =head1 METHODS
59
60 =over 4
61
62 =item check
63
64 Checks all fields to make sure this is a valid FCC option.  If there is
65 an error, returns the error, otherwise returns false.  Called by the insert
66 and replace methods.
67
68 =cut
69
70 sub check {
71   my $self = shift;
72
73   my $error = 
74     $self->ut_numbern('num')
75     || $self->ut_alpha('fccoptionname')
76     || $self->ut_number('pkgpart')
77     || $self->ut_foreign_key('pkgpart', 'part_pkg', 'pkgpart')
78     || $self->ut_textn('optionvalue')
79   ;
80   return $error if $error;
81
82   $self->SUPER::check;
83 }
84
85 =back
86
87 =head1 CLASS METHODS
88
89 =over 4
90
91 =item media_types
92
93 Returns a Tie::IxHash hashref of the media type strings (which are not 
94 part of the report definition, per se) to arrayrefs of the technology 
95 codes included in each one.
96
97 =item technology_labels
98
99 Returns a hashref relating each technology code to a label.  Unlike the 
100 media type strings, the technology codes are part of the formal report
101 definition.
102
103 =cut
104
105 tie our %media_types, 'Tie::IxHash', (
106   'Copper'          => [ 11, 12, 10, 20, 30 ],
107   'Cable Modem'     => [ 41, 42, 40 ],
108   'Fiber'           => [ 50 ],
109   'Satellite'       => [ 60 ],
110   'Fixed Wireless'  => [ 70 ],
111   'Mobile Wireless' => [ 80, 81, 82, 83, 84, 85, 86, 87, 88 ],
112   'Other'           => [ 90, 0 ],
113 );
114
115 our %technology_labels = (
116       10 => 'Other ADSL',
117       11 => 'ADSL2',
118       12 => 'VDSL',
119       20 => 'SDSL',
120       30 => 'Other Copper Wireline',
121       40 => 'Other Cable Modem',
122       41 => 'Cable - DOCSIS 1, 1.1, 2.0',
123       42 => 'Cable - DOCSIS 3.0',
124       50 => 'Fiber',
125       60 => 'Satellite',
126       70 => 'Terrestrial Fixed Wireless',
127       # mobile wireless
128       80 => 'Mobile - WCDMA/UMTS/HSPA',
129       81 => 'Mobile - HSPA+',
130       82 => 'Mobile - EVDO/EVDO Rev A',
131       83 => 'Mobile - LTE',
132       84 => 'Mobile - WiMAX',
133       85 => 'Mobile - CDMA',
134       86 => 'Mobile - GSM',
135       87 => 'Mobile - Analog',
136       88 => 'Other Mobile',
137
138       90 => 'Electric Power Line',
139       0  => 'Other'
140 );
141
142 sub media_types {
143   Storable::dclone(\%media_types);
144 }
145
146 sub technology_labels {
147   +{ %technology_labels };
148 }
149
150 =head1 BUGS
151
152 =head1 SEE ALSO
153
154 L<FS::Record>, schema.html from the base documentation.
155
156 =cut
157
158 1;
159