svc_fiber, #35260
[freeside.git] / FS / FS / fiber_olt.pm
1 package FS::fiber_olt;
2 use base qw( FS::Record );
3
4 use strict;
5 use FS::Record qw( qsearch qsearchs );
6 use FS::svc_fiber;
7
8 =head1 NAME
9
10 FS::fiber_olt - Object methods for fiber_olt records
11
12 =head1 SYNOPSIS
13
14   use FS::fiber_olt;
15
16   $record = new FS::fiber_olt \%hash;
17   $record = new FS::fiber_olt { 'column' => 'value' };
18
19   $error = $record->insert;
20
21   $error = $new_record->replace($old_record);
22
23   $error = $record->delete;
24
25   $error = $record->check;
26
27 =head1 DESCRIPTION
28
29 An FS::fiber_olt object represents an Optical Line Terminal that fiber
30 connections (L<FS::svc_fiber>) connect to.  FS::fiber_olt inherits from
31 FS::Record.  The following fields are currently supported:
32
33 =over 4
34
35 =item oltnum - primary key
36
37 =item oltname - name of this device
38
39 =item serial - serial number
40
41 =item disabled - set to 'Y' to make this OLT unavailable for new connections
42
43 =back
44
45 =head1 METHODS
46
47 =over 4
48
49 =item new HASHREF
50
51 Creates a new fiber_olt record.  To add it to the database, see L<"insert">.
52
53 =cut
54
55 # the new method can be inherited from FS::Record, if a table method is defined
56
57 sub table { 'fiber_olt'; }
58
59 =item insert
60
61 Adds this record to the database.  If there is an error, returns the error,
62 otherwise returns false.
63
64 =item delete
65
66 Delete this record from the database.
67
68 =item replace OLD_RECORD
69
70 Replaces the OLD_RECORD with this one in the database.  If there is an error,
71 returns the error, otherwise returns false.
72
73 =item check
74
75 Checks all fields to make sure this is a valid example.  If there is
76 an error, returns the error, otherwise returns false.  Called by the insert
77 and replace methods.
78
79 =cut
80
81 # the check method should currently be supplied - FS::Record contains some
82 # data checking routines
83
84 sub check {
85   my $self = shift;
86
87   my $error = 
88     $self->ut_numbern('oltnum')
89     || $self->ut_text('oltname')
90     || $self->ut_text('serial')
91     || $self->ut_flag('disabled')
92   ;
93   return $error if $error;
94
95   $self->SUPER::check;
96 }
97
98 # 3.x stub
99
100 sub svc_fiber {
101   my $self = shift;
102   qsearch('svc_fiber', { 'oltnum' => $self->get('oltnum') });
103 }
104
105 =back
106
107 =head1 SEE ALSO
108
109 L<FS::svc_fiber>, L<FS::Record>
110
111 =cut
112
113 1;
114