4 use base qw( FS::svc_Common );
12 FS::svc_fiber - Object methods for svc_fiber records
18 $record = new FS::table_name \%hash;
19 $record = new FS::table_name { 'column' => 'value' };
21 $error = $record->insert;
23 $error = $new_record->replace($old_record);
25 $error = $record->delete;
27 $error = $record->check;
29 $error = $record->suspend;
31 $error = $record->unsuspend;
33 $error = $record->cancel;
37 An FS::svc_fiber object represents a fiber-to-the-premises service.
38 FS::svc_fiber inherits from FS::svc_Common. The following fields are
43 =item svcnum - Primary key
45 =item oltnum - The Optical Line Terminal this service connects to (see
48 =item shelf - The shelf number on the OLT.
50 =item card - The card number on the OLT shelf.
52 =item olt_port - The port number on that card.
54 =item vlan - The VLAN number.
56 =item signal - Measured signal strength in dB.
58 =item speed_up - Measured uplink speed in Mbps.
60 =item speed_down - Measured downlink speed in Mbps.
70 Creates a new fiber service record. To add it to the database, see L<"insert">.
74 sub table { 'svc_fiber'; }
79 'name_plural' => 'Fiber', # really the name of the ACL
80 'longname_plural' => 'Fiber services',
81 'sorts' => [ 'oltnum', ],
82 'display_weight' => 74,
83 'cancel_weight' => 74,
88 'select_table' => 'fiber_olt',
89 'select_key' => 'oltnum',
90 'select_label' => 'oltname',
91 'disable_inventory' => 1,
96 'disable_inventory' => 1,
97 'disable_select' => 1,
102 'disable_inventory' => 1,
103 'disable_select' => 1,
106 'label' => 'GPON port',
108 'disable_inventory' => 1,
109 'disable_select' => 1,
114 'disable_select' => 1,
117 'label' => 'Device type',
118 'type' => 'select-hardware',
119 'disable_select' => 1,
120 'disable_default' => 1,
121 'disable_inventory' => 1,
124 'label' => 'Serial number',
125 'disable_select' => 1,
128 'label' => 'GE port',
130 'disable_inventory' => 1,
131 'disable_select' => 1,
136 'disable_inventory' => 1,
137 'disable_select' => 1,
140 'label' => 'Signal strength (dB)',
142 'disable_inventory' => 1,
143 'disable_select' => 1,
146 'label' => 'Download speed (Mbps)',
148 'disable_inventory' => 1,
149 'disable_select' => 1,
152 'label' => 'Upload speed (Mbps)',
154 'disable_inventory' => 1,
155 'disable_select' => 1,
158 'label' => 'ONT install location',
160 'disable_inventory' => 1,
161 'disable_select' => 1,
167 =item search_sql STRING
169 Class method which returns an SQL fragment to search for the given string.
170 For svc_fiber, STRING can be a full or partial ONT serial number.
174 #or something more complicated if necessary
176 my($class, $string) = @_;
177 $string = dbh->quote('%' . $string . '%');
178 "LOWER(svc_fiber.ont_serial) LIKE LOWER($string)";
183 Returns a description of this fiber service containing the OLT name and
184 port location, and the ONT serial number.
190 $self->ont_serial . ' @ ' . $self->fiber_olt->oltname . ' ' .
191 join('-', $self->shelf, $self->card, $self->olt_port);
194 # nothing special for insert, delete, or replace
198 Adds this record to the database. If there is an error, returns the error,
199 otherwise returns false.
201 The additional fields pkgnum and svcpart (see L<FS::cust_svc>) should be
202 defined. An FS::cust_svc record will be created and inserted.
206 Delete this record from the database.
208 =item replace OLD_RECORD
210 Replaces the OLD_RECORD with this one in the database. If there is an error,
211 returns the error, otherwise returns false.
215 Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>).
219 Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>).
223 Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
227 Checks all fields to make sure this is a valid example. If there is
228 an error, returns the error, otherwise returns false. Called by the insert
236 my $x = $self->setfixed;
237 return $x unless ref($x);
241 $self->ut_number('oltnum')
242 || $self->ut_numbern('shelf')
243 || $self->ut_numbern('card')
244 || $self->ut_numbern('olt_port')
245 || $self->ut_number('ont_id')
246 || $self->ut_number('ont_typenum')
247 || $self->ut_alphan('ont_serial')
248 || $self->ut_alphan('ont_port')
249 || $self->ut_numbern('vlan')
250 || $self->ut_snumbern('signal')
251 || $self->ut_numbern('speed_up')
252 || $self->ut_numbern('speed_down')
253 || $self->ut_textn('ont_install')
255 return $error if $error;
260 =item ont_description
262 Returns the description of the ONT hardware, if there is one.
266 sub ont_description {
268 $self->ont_typenum ? $self->hardware_type->description : '';
273 Returns a qsearch hash expression to search for parameters specified in
276 Parameters are those in L<FS::svc_Common/search>, plus:
278 ont_typenum - the ONT L<FS::hardware_type> key
280 oltnum - the OLT L<FS::fiber_olt> key
282 shelf, card, olt_port - the OLT port location fields
284 vlan - the VLAN number
286 ont_serial - the ONT serial number
291 my ($class, $params, $from, $where) = @_;
293 # make this simple: all of these are numeric fields, except that 0 means null
294 foreach my $field (qw(ont_typenum oltnum shelf olt_port card vlan)) {
295 if ( $params->{$field} =~ /^(\d+)$/ ) {
296 push @$where, "COALESCE($field,0) = $1";
299 if ( length($params->{ont_serial}) ) {
300 my $string = dbh->quote('%'.$params->{ont_serial}.'%');
301 push @$where, "LOWER(ont_serial) LIKE LOWER($string)";
306 #stub still needed under 4.x+
310 $self->ont_typenum ? FS::hardware_type->by_key($self->ont_typenum) : '';
317 L<FS::svc_Common>, L<FS::Record>, L<FS::cust_svc>, L<FS::part_svc>,
318 L<FS::cust_pkg>, schema.html from the base documentation.