enable package class condition for invoices, #14499
[freeside.git] / FS / FS / tower.pm
1 package FS::tower;
2
3 use strict;
4 use base qw( FS::o2m_Common FS::Record );
5 use FS::Record qw( qsearch ); #qsearchs );
6 use FS::tower_sector;
7
8 =head1 NAME
9
10 FS::tower - Object methods for tower records
11
12 =head1 SYNOPSIS
13
14   use FS::tower;
15
16   $record = new FS::tower \%hash;
17   $record = new FS::tower { '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::tower object represents a tower.  FS::tower inherits from
30 FS::Record.  The following fields are currently supported:
31
32 =over 4
33
34 =item towernum
35
36 primary key
37
38 =item towername
39
40 Tower name
41
42 =item disabled
43
44 Disabled flag, empty or 'Y'
45
46 =back
47
48 =head1 METHODS
49
50 =over 4
51
52 =item new HASHREF
53
54 Creates a new tower.  To add the tower to the database, see L<"insert">.
55
56 Note that this stores the hash reference, not a distinct copy of the hash it
57 points to.  You can ask the object for a copy with the I<hash> method.
58
59 =cut
60
61 # the new method can be inherited from FS::Record, if a table method is defined
62
63 sub table { 'tower'; }
64
65 =item insert
66
67 Adds this record to the database.  If there is an error, returns the error,
68 otherwise returns false.
69
70 =cut
71
72 # the insert method can be inherited from FS::Record
73
74 =item delete
75
76 Delete this record from the database.
77
78 =cut
79
80 # the delete method can be inherited from FS::Record
81
82 =item replace OLD_RECORD
83
84 Replaces the OLD_RECORD with this one in the database.  If there is an error,
85 returns the error, otherwise returns false.
86
87 =cut
88
89 # the replace method can be inherited from FS::Record
90
91 =item check
92
93 Checks all fields to make sure this is a valid tower.  If there is
94 an error, returns the error, otherwise returns false.  Called by the insert
95 and replace methods.
96
97 =cut
98
99 # the check method should currently be supplied - FS::Record contains some
100 # data checking routines
101
102 sub check {
103   my $self = shift;
104
105   my $error = 
106     $self->ut_numbern('towernum')
107     || $self->ut_text('towername')
108     || $self->ut_enum('disabled', [ '', 'Y' ])
109   ;
110   return $error if $error;
111
112   $self->SUPER::check;
113 }
114
115 =item tower_sector
116
117 Returns the sectors of this tower, as FS::tower_sector objects (see
118 L<FS::tower_sector>).
119
120 =cut
121
122 sub tower_sector {
123   my $self = shift;
124   qsearch({
125     'table'    => 'tower_sector',
126     'hashref'  => { 'towernum' => $self->towernum },
127     'order_by' => 'ORDER BY sectorname',
128   });
129 }
130
131 =back
132
133 =head1 BUGS
134
135 =head1 SEE ALSO
136
137 L<FS::tower_sector>, L<FS::svc_broadband>, L<FS::Record>
138
139 =cut
140
141 1;
142