fix label method and doc work
[freeside.git] / FS / FS / svc_pbx.pm
1 package FS::svc_pbx;
2
3 use strict;
4 use base qw( FS::svc_External_Common );
5 #use FS::Record qw( qsearch qsearchs );
6 use FS::cust_svc;
7
8 =head1 NAME
9
10 FS::svc_pbx - Object methods for svc_pbx records
11
12 =head1 SYNOPSIS
13
14   use FS::svc_pbx;
15
16   $record = new FS::svc_pbx \%hash;
17   $record = new FS::svc_pbx { '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   $error = $record->suspend;
28
29   $error = $record->unsuspend;
30
31   $error = $record->cancel;
32
33 =head1 DESCRIPTION
34
35 An FS::svc_pbx object represents a PBX tenant.  FS::svc_pbx inherits from
36 FS::svc_Common.  The following fields are currently supported:
37
38 =over 4
39
40 =item svcnum
41
42 Primary key (assigned automatcially for new accounts)
43
44 =item id
45
46 (Unique?) number of external record
47
48 =item title
49
50 PBX name
51
52 =item max_extensions
53
54 Maximum number of extensions
55
56 =back
57
58 =head1 METHODS
59
60 =over 4
61
62 =item new HASHREF
63
64 Creates a new PBX tenant.  To add the PBX tenant to the database, see
65 L<"insert">.
66
67 Note that this stores the hash reference, not a distinct copy of the hash it
68 points to.  You can ask the object for a copy with the I<hash> method.
69
70 =cut
71
72 sub table { 'svc_pbx'; }
73
74 sub table_info {
75   {
76     'name' => 'PBX',
77     'name_plural' => 'PBXs', #optional,
78     'longname_plural' => 'PBXs', #optional
79     'sorts' => 'svcnum', # optional sort field (or arrayref of sort fields, main first)
80     'display_weight' => 70,
81     'cancel_weight'  => 90,
82     'fields' => {
83       'id'    => 'Thirdlane ID',
84       'title' => 'Name',
85       'max_extensions' => 'Maximum number of User Extensions',
86 #      'field'         => 'Description',
87 #      'another_field' => { 
88 #                           'label'     => 'Description',
89 #                          'def_label' => 'Description for service definitions',
90 #                          'type'      => 'text',
91 #                          'disable_default'   => 1, #disable switches
92 #                          'disable_fixed'     => 1, #
93 #                          'disable_inventory' => 1, #
94 #                        },
95 #      'foreign_key'   => { 
96 #                           'label'        => 'Description',
97 #                          'def_label'    => 'Description for service defs',
98 #                          'type'         => 'select',
99 #                          'select_table' => 'foreign_table',
100 #                          'select_key'   => 'key_field_in_table',
101 #                          'select_label' => 'label_field_in_table',
102 #                        },
103
104     },
105   };
106 }
107
108 =item search_sql STRING
109
110 Class method which returns an SQL fragment to search for the given string.
111
112 =cut
113
114 #XXX
115 #or something more complicated if necessary
116 #sub search_sql {
117 #  my($class, $string) = @_;
118 #  $class->search_sql_field('title', $string);
119 #}
120
121 =item label
122
123 Returns the title field for this PBX tenant.
124
125 =cut
126
127 sub label {
128   my $self = shift;
129   $self->title;
130 }
131
132 =item insert
133
134 Adds this record to the database.  If there is an error, returns the error,
135 otherwise returns false.
136
137 The additional fields pkgnum and svcpart (see L<FS::cust_svc>) should be 
138 defined.  An FS::cust_svc record will be created and inserted.
139
140 =cut
141
142 sub insert {
143   my $self = shift;
144   my $error;
145
146   $error = $self->SUPER::insert;
147   return $error if $error;
148
149   '';
150 }
151
152 =item delete
153
154 Delete this record from the database.
155
156 =cut
157
158 sub delete {
159   my $self = shift;
160   my $error;
161
162   $error = $self->SUPER::delete;
163   return $error if $error;
164
165   '';
166 }
167
168
169 =item replace OLD_RECORD
170
171 Replaces the OLD_RECORD with this one in the database.  If there is an error,
172 returns the error, otherwise returns false.
173
174 =cut
175
176 sub replace {
177   my ( $new, $old ) = ( shift, shift );
178   my $error;
179
180   $error = $new->SUPER::replace($old);
181   return $error if $error;
182
183   '';
184 }
185
186 =item suspend
187
188 Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>).
189
190 =item unsuspend
191
192 Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>).
193
194 =item cancel
195
196 Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
197
198 =item check
199
200 Checks all fields to make sure this is a valid PBX tenant.  If there is
201 an error, returns the error, otherwise returns false.  Called by the insert
202 and repalce methods.
203
204 =cut
205
206 sub check {
207   my $self = shift;
208
209   my $x = $self->setfixed;
210   return $x unless ref($x);
211   my $part_svc = $x;
212
213
214   $self->SUPER::check;
215 }
216
217 =back
218
219 =head1 BUGS
220
221 =head1 SEE ALSO
222
223 L<FS::svc_Common>, L<FS::Record>, L<FS::cust_svc>, L<FS::part_svc>,
224 L<FS::cust_pkg>, schema.html from the base documentation.
225
226 =cut
227
228 1;
229