4 use base qw( FS::svc_External_Common );
5 use FS::Record qw( qsearchs ); # qsearch );
10 FS::svc_pbx - Object methods for svc_pbx records
16 $record = new FS::svc_pbx \%hash;
17 $record = new FS::svc_pbx { 'column' => 'value' };
19 $error = $record->insert;
21 $error = $new_record->replace($old_record);
23 $error = $record->delete;
25 $error = $record->check;
27 $error = $record->suspend;
29 $error = $record->unsuspend;
31 $error = $record->cancel;
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:
42 Primary key (assigned automatcially for new accounts)
46 (Unique?) number of external record
54 Maximum number of extensions
64 Creates a new PBX tenant. To add the PBX tenant to the database, see
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.
72 sub table { 'svc_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,
85 'max_extensions' => 'Maximum number of User Extensions',
86 # 'field' => 'Description',
87 # 'another_field' => {
88 # 'label' => 'Description',
89 # 'def_label' => 'Description for service definitions',
91 # 'disable_default' => 1, #disable switches
92 # 'disable_fixed' => 1, #
93 # 'disable_inventory' => 1, #
96 # 'label' => 'Description',
97 # 'def_label' => 'Description for service defs',
99 # 'select_table' => 'foreign_table',
100 # 'select_key' => 'key_field_in_table',
101 # 'select_label' => 'label_field_in_table',
108 =item search_sql STRING
110 Class method which returns an SQL fragment to search for the given string.
115 #or something more complicated if necessary
117 # my($class, $string) = @_;
118 # $class->search_sql_field('title', $string);
123 Returns the title field for this PBX tenant.
134 Adds this record to the database. If there is an error, returns the error,
135 otherwise returns false.
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.
146 $error = $self->SUPER::insert;
147 return $error if $error;
154 Delete this record from the database.
162 $error = $self->SUPER::delete;
163 return $error if $error;
169 =item replace OLD_RECORD
171 Replaces the OLD_RECORD with this one in the database. If there is an error,
172 returns the error, otherwise returns false.
177 my ( $new, $old ) = ( shift, shift );
180 $error = $new->SUPER::replace($old);
181 return $error if $error;
188 Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>).
192 Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>).
196 Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
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
209 my $x = $self->setfixed;
210 return $x unless ref($x);
217 #XXX this is a way-too simplistic implementation
218 # at the very least, title should be unique across exports that need that or
219 # controlled by a conf setting or something
220 sub _check_duplicate {
225 if ( qsearchs( 'svc_pbx', { 'title' => $self->title } ) ) {
226 return "Name in use";
238 L<FS::svc_Common>, L<FS::Record>, L<FS::cust_svc>, L<FS::part_svc>,
239 L<FS::cust_pkg>, schema.html from the base documentation.