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,
113 'label' => 'ODN circuit',
114 'type' => 'input-fiber_circuit',
115 'disable_inventory' => 1,
116 'disable_select' => 1,
121 'disable_select' => 1,
124 'label' => 'Device type',
125 'type' => 'select-hardware',
126 'disable_select' => 1,
127 'disable_default' => 1,
128 'disable_inventory' => 1,
131 'label' => 'Serial number',
132 'disable_select' => 1,
135 'label' => 'GE port',
137 'disable_inventory' => 1,
138 'disable_select' => 1,
143 'disable_inventory' => 1,
144 'disable_select' => 1,
147 'label' => 'Signal strength (dB)',
149 'disable_inventory' => 1,
150 'disable_select' => 1,
153 'label' => 'Download speed (Mbps)',
155 'disable_inventory' => 1,
156 'disable_select' => 1,
159 'label' => 'Upload speed (Mbps)',
161 'disable_inventory' => 1,
162 'disable_select' => 1,
165 'label' => 'ONT install location',
167 'disable_inventory' => 1,
168 'disable_select' => 1,
174 =item search_sql STRING
176 Class method which returns an SQL fragment to search for the given string.
177 For svc_fiber, STRING can be a full or partial ONT serial number.
181 #or something more complicated if necessary
183 my($class, $string) = @_;
184 $string = dbh->quote('%' . $string . '%');
185 "LOWER(svc_fiber.ont_serial) LIKE LOWER($string)";
190 Returns a description of this fiber service containing the ONT serial number
191 and the OLT name and port location.
197 $self->ont_serial . ' @ ' . $self->fiber_olt->description . ' ' .
198 join('-', $self->shelf, $self->card, $self->olt_port);
201 # nothing special for insert, delete, or replace
205 Adds this record to the database. If there is an error, returns the error,
206 otherwise returns false.
208 The additional fields pkgnum and svcpart (see L<FS::cust_svc>) should be
209 defined. An FS::cust_svc record will be created and inserted.
213 Delete this record from the database.
215 =item replace OLD_RECORD
217 Replaces the OLD_RECORD with this one in the database. If there is an error,
218 returns the error, otherwise returns false.
222 Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>).
226 Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>).
230 Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
234 Checks all fields to make sure this is a valid example. If there is
235 an error, returns the error, otherwise returns false. Called by the insert
243 my $x = $self->setfixed;
244 return $x unless ref($x);
248 $self->ut_number('oltnum')
249 || $self->ut_numbern('shelf')
250 || $self->ut_numbern('card')
251 || $self->ut_numbern('olt_port')
252 || $self->ut_number('ont_id')
253 || $self->ut_number('ont_typenum')
254 || $self->ut_alphan('ont_serial')
255 || $self->ut_alphan('ont_port')
256 || $self->ut_numbern('vlan')
257 || $self->ut_sfloatn('signal')
258 || $self->ut_numbern('speed_up')
259 || $self->ut_numbern('speed_down')
260 || $self->ut_textn('ont_install')
262 return $error if $error;
264 $self->set('signal', sprintf('%.2f', $self->get('signal')));
269 =item ont_description
271 Returns the description of the ONT hardware, if there is one.
275 sub ont_description {
277 $self->ont_typenum ? $self->hardware_type->description : '';
282 Returns a qsearch hash expression to search for parameters specified in
285 Parameters are those in L<FS::svc_Common/search>, plus:
287 ont_typenum - the ONT L<FS::hardware_type> key
289 oltnum - the OLT L<FS::fiber_olt> key
291 shelf, card, olt_port - the OLT port location fields
293 vlan - the VLAN number
295 ont_serial - the ONT serial number
300 my ($class, $params, $from, $where) = @_;
302 # make this simple: all of these are numeric fields, except that 0 means null
303 foreach my $field (qw(ont_typenum oltnum shelf olt_port card vlan)) {
304 if ( $params->{$field} =~ /^(\d+)$/ ) {
305 push @$where, "COALESCE($field,0) = $1";
308 if ( length($params->{ont_serial}) ) {
309 my $string = dbh->quote('%'.$params->{ont_serial}.'%');
310 push @$where, "LOWER(ont_serial) LIKE LOWER($string)";
319 $self->get('oltnum') ? FS::fiber_olt->by_key($self->get('oltnum')) : '';
322 #stub still needed under 4.x+
326 $self->ont_typenum ? FS::hardware_type->by_key($self->ont_typenum) : '';
333 L<FS::svc_Common>, L<FS::Record>, L<FS::cust_svc>, L<FS::part_svc>,
334 L<FS::cust_pkg>, schema.html from the base documentation.