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 circuit ID
191 and the ONT serial number.
197 $self->ont_serial . ' @ ' . $self->circuit_id;
200 # nothing special for insert, delete, or replace
204 Adds this record to the database. If there is an error, returns the error,
205 otherwise returns false.
207 The additional fields pkgnum and svcpart (see L<FS::cust_svc>) should be
208 defined. An FS::cust_svc record will be created and inserted.
212 Delete this record from the database.
214 =item replace OLD_RECORD
216 Replaces the OLD_RECORD with this one in the database. If there is an error,
217 returns the error, otherwise returns false.
221 Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>).
225 Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>).
229 Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
233 Checks all fields to make sure this is a valid example. If there is
234 an error, returns the error, otherwise returns false. Called by the insert
242 my $x = $self->setfixed;
243 return $x unless ref($x);
247 $self->ut_number('oltnum')
248 || $self->ut_numbern('shelf')
249 || $self->ut_numbern('card')
250 || $self->ut_numbern('olt_port')
251 || $self->ut_number('ont_id')
252 || $self->ut_number('ont_typenum')
253 || $self->ut_alphan('ont_serial')
254 || $self->ut_alphan('ont_port')
255 || $self->ut_numbern('vlan')
256 || $self->ut_sfloatn('signal')
257 || $self->ut_numbern('speed_up')
258 || $self->ut_numbern('speed_down')
259 || $self->ut_textn('ont_install')
261 return $error if $error;
263 $self->set('signal', sprintf('%.2f', $self->get('signal')));
268 =item ont_description
270 Returns the description of the ONT hardware, if there is one.
274 sub ont_description {
276 $self->ont_typenum ? $self->hardware_type->description : '';
281 Returns a qsearch hash expression to search for parameters specified in
284 Parameters are those in L<FS::svc_Common/search>, plus:
286 ont_typenum - the ONT L<FS::hardware_type> key
288 oltnum - the OLT L<FS::fiber_olt> key
290 shelf, card, olt_port - the OLT port location fields
292 vlan - the VLAN number
294 ont_serial - the ONT serial number
299 my ($class, $params, $from, $where) = @_;
301 # make this simple: all of these are numeric fields, except that 0 means null
302 foreach my $field (qw(ont_typenum oltnum shelf olt_port card vlan)) {
303 if ( $params->{$field} =~ /^(\d+)$/ ) {
304 push @$where, "COALESCE($field,0) = $1";
307 if ( length($params->{ont_serial}) ) {
308 my $string = dbh->quote('%'.$params->{ont_serial}.'%');
309 push @$where, "LOWER(ont_serial) LIKE LOWER($string)";
314 #stub still needed under 4.x+
318 $self->ont_typenum ? FS::hardware_type->by_key($self->ont_typenum) : '';
325 L<FS::svc_Common>, L<FS::Record>, L<FS::cust_svc>, L<FS::part_svc>,
326 L<FS::cust_pkg>, schema.html from the base documentation.