agent-virtualize credit card surcharge percentage, RT#72961
[freeside.git] / FS / FS / pbx_extension.pm
1 package FS::pbx_extension;
2 use base qw( FS::Record );
3
4 use strict;
5 #use FS::Record qw( qsearch qsearchs );
6
7 =head1 NAME
8
9 FS::pbx_extension - Object methods for pbx_extension records
10
11 =head1 SYNOPSIS
12
13   use FS::pbx_extension;
14
15   $record = new FS::pbx_extension \%hash;
16   $record = new FS::pbx_extension { 'column' => 'value' };
17
18   $error = $record->insert;
19
20   $error = $new_record->replace($old_record);
21
22   $error = $record->delete;
23
24   $error = $record->check;
25
26 =head1 DESCRIPTION
27
28 An FS::pbx_extension object represents an PBX extension.  FS::pbx_extension
29 inherits from FS::Record.  The following fields are currently supported:
30
31 =over 4
32
33 =item extensionnum
34
35 primary key
36
37 =item svcnum
38
39 svcnum
40
41 =item extension
42
43 extension
44
45 =item pin
46
47 pin
48
49 =item sip_password
50
51 sip_password
52
53 =item phone_name
54
55 phone_name
56
57
58 =back
59
60 =head1 METHODS
61
62 =over 4
63
64 =item new HASHREF
65
66 Creates a new extension.  To add the extension to the database, see L<"insert">.
67
68 Note that this stores the hash reference, not a distinct copy of the hash it
69 points to.  You can ask the object for a copy with the I<hash> method.
70
71 =cut
72
73 sub table { 'pbx_extension'; }
74
75 =item insert
76
77 Adds this record to the database.  If there is an error, returns the error,
78 otherwise returns false.
79
80 =item delete
81
82 Delete this record from the database.
83
84 =item replace OLD_RECORD
85
86 Replaces the OLD_RECORD with this one in the database.  If there is an error,
87 returns the error, otherwise returns false.
88
89 =item check
90
91 Checks all fields to make sure this is a valid extension.  If there is
92 an error, returns the error, otherwise returns false.  Called by the insert
93 and replace methods.
94
95 =cut
96
97 sub check {
98   my $self = shift;
99
100   my $error = 
101     $self->ut_numbern('extensionnum')
102     || $self->ut_foreign_key('svcnum', 'svc_pbx', 'svcnum')
103     || $self->ut_number('extension')
104     || $self->ut_numbern('pin')
105     || $self->ut_textn('sip_password')
106     || $self->ut_textn('phone_name')
107   ;
108   return $error if $error;
109
110   $self->SUPER::check;
111 }
112
113 =back
114
115 =head1 BUGS
116
117 =head1 SEE ALSO
118
119 L<FS::svc_pbx>, L<FS::Record>
120
121 =cut
122
123 1;
124