ACL for hardware class config, RT#85057
[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::olt_site;
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 sitenum - the L<FS::olt_site> where this OLT is installed
42
43 =item disabled - set to 'Y' to make this OLT unavailable for new connections
44
45 =back
46
47 =head1 METHODS
48
49 =over 4
50
51 =item new HASHREF
52
53 Creates a new fiber_olt record.  To add it to the database, see L<"insert">.
54
55 =cut
56
57 # the new method can be inherited from FS::Record, if a table method is defined
58
59 sub table { 'fiber_olt'; }
60
61 =item insert
62
63 Adds this record to the database.  If there is an error, returns the error,
64 otherwise returns false.
65
66 =item delete
67
68 Delete this record from the database.
69
70 =item replace OLD_RECORD
71
72 Replaces the OLD_RECORD with this one in the database.  If there is an error,
73 returns the error, otherwise returns false.
74
75 =item check
76
77 Checks all fields to make sure this is a valid example.  If there is
78 an error, returns the error, otherwise returns false.  Called by the insert
79 and replace methods.
80
81 =cut
82
83 # the check method should currently be supplied - FS::Record contains some
84 # data checking routines
85
86 sub check {
87   my $self = shift;
88
89   my $error = 
90     $self->ut_numbern('oltnum')
91     || $self->ut_text('oltname')
92     || $self->ut_text('serial')
93     || $self->ut_foreign_keyn('sitenum', 'olt_site', 'sitenum')
94     || $self->ut_flag('disabled')
95   ;
96   return $error if $error;
97
98   $self->SUPER::check;
99 }
100
101 =item site_description
102
103 Returns the OLT's site description.
104
105 =cut
106
107 sub site_description {
108   my $self = shift;
109   return '' if !$self->sitenum;
110   my $olt_site = FS::olt_site->by_key($self->sitenum);
111   return $olt_site->description;
112 }
113
114 =item description
115
116 Returns the OLT's site name and unit name.
117
118 =cut
119
120 sub description {
121   my $self = shift;
122   my $desc = $self->oltname;
123   $desc = $self->site_description . '/' . $desc if $self->sitenum;
124   return $desc;
125 }
126
127 =back
128
129 =head1 SEE ALSO
130
131 L<FS::svc_fiber>, L<FS::olt_site>, L<FS::Record>
132
133 =cut
134
135 1;
136