4 use vars qw( @ISA @pw_set );
5 #use FS::Record qw( qsearch qsearchs );
8 @ISA = qw( FS::svc_Common );
11 @pw_set = ( 'a'..'k', 'm','n', 'p-z', 'A'..'N', 'P'..'Z' , '2'..'9' );
15 FS::svc_phone - Object methods for svc_phone records
21 $record = new FS::svc_phone \%hash;
22 $record = new FS::svc_phone { 'column' => 'value' };
24 $error = $record->insert;
26 $error = $new_record->replace($old_record);
28 $error = $record->delete;
30 $error = $record->check;
32 $error = $record->suspend;
34 $error = $record->unsuspend;
36 $error = $record->cancel;
40 An FS::svc_phone object represents a phone number. FS::svc_phone inherits
41 from FS::Record. The following fields are currently supported:
67 Creates a new phone number. To add the number to the database, see L<"insert">.
69 Note that this stores the hash reference, not a distinct copy of the hash it
70 points to. You can ask the object for a copy with the I<hash> method.
74 # the new method can be inherited from FS::Record, if a table method is defined
78 'name' => 'Phone number',
79 'sorts' => 'phonenum',
80 'display_weight' => 60,
81 'cancel_weight' => 80,
83 'countrycode' => { label => 'Country code',
85 disable_inventory => 1,
88 'phonenum' => 'Phone number',
89 'pin' => { label => 'Personal Identification Number',
91 disable_inventory => 1,
94 'sip_password' => 'SIP password',
99 sub table { 'svc_phone'; }
101 =item search_sql STRING
103 Class method which returns an SQL fragment to search for the given string.
108 my( $class, $string ) = @_;
109 $class->search_sql_field('phonenum', $string );
114 Returns the phone number.
120 $self->phonenum; #XXX format it better
125 Adds this record to the database. If there is an error, returns the error,
126 otherwise returns false.
130 # the insert method can be inherited from FS::Record
134 Delete this record from the database.
138 # the delete method can be inherited from FS::Record
140 =item replace OLD_RECORD
142 Replaces the OLD_RECORD with this one in the database. If there is an error,
143 returns the error, otherwise returns false.
147 # the replace method can be inherited from FS::Record
151 Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>).
155 Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>).
159 Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
163 Checks all fields to make sure this is a valid phone number. If there is
164 an error, returns the error, otherwise returns false. Called by the insert
169 # the check method should currently be supplied - FS::Record contains some
170 # data checking routines
175 my $phonenum = $self->phonenum;
176 $phonenum =~ s/\D//g;
177 $self->phonenum($phonenum);
180 $self->ut_numbern('svcnum')
181 || $self->ut_numbern('countrycode')
182 || $self->ut_number('phonenum')
183 || $self->ut_anything('sip_password')
184 || $self->ut_numbern('pin')
186 return $error if $error;
188 $self->countrycode(1) unless $self->countrycode;
190 unless ( length($self->sip_password) ) {
193 join('', map $pw_set[ int(rand $#pw_set) ], (0..16) )
203 Checks the supplied PIN against the PIN in the database. Returns true for a
204 sucessful authentication, false if no match.
209 my($self, $check_pin) = @_;
210 $check_pin eq $self->pin;
219 L<FS::svc_Common>, L<FS::Record>, L<FS::cust_svc>, L<FS::part_svc>,
220 L<FS::cust_pkg>, schema.html from the base documentation.