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:
69 Creates a new phone number. To add the number to the database, see L<"insert">.
71 Note that this stores the hash reference, not a distinct copy of the hash it
72 points to. You can ask the object for a copy with the I<hash> method.
76 # the new method can be inherited from FS::Record, if a table method is defined
80 'name' => 'Phone number',
81 'sorts' => 'phonenum',
82 'display_weight' => 60,
83 'cancel_weight' => 80,
85 'countrycode' => { label => 'Country code',
87 disable_inventory => 1,
90 'phonenum' => 'Phone number',
91 'pin' => { label => 'Personal Identification Number',
93 disable_inventory => 1,
96 'sip_password' => 'SIP password',
102 sub table { 'svc_phone'; }
104 =item search_sql STRING
106 Class method which returns an SQL fragment to search for the given string.
111 my( $class, $string ) = @_;
112 $class->search_sql_field('phonenum', $string );
117 Returns the phone number.
123 my $phonenum = $self->phonenum; #XXX format it better
124 my $label = $phonenum;
125 $label .= ' ('.$self->phone_name.')' if $self->phone_name;
131 Adds this record to the database. If there is an error, returns the error,
132 otherwise returns false.
136 # the insert method can be inherited from FS::Record
140 Delete this record from the database.
144 # the delete method can be inherited from FS::Record
146 =item replace OLD_RECORD
148 Replaces the OLD_RECORD with this one in the database. If there is an error,
149 returns the error, otherwise returns false.
153 # the replace method can be inherited from FS::Record
157 Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>).
161 Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>).
165 Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
169 Checks all fields to make sure this is a valid phone number. If there is
170 an error, returns the error, otherwise returns false. Called by the insert
175 # the check method should currently be supplied - FS::Record contains some
176 # data checking routines
181 my $phonenum = $self->phonenum;
182 $phonenum =~ s/\D//g;
183 $self->phonenum($phonenum);
186 $self->ut_numbern('svcnum')
187 || $self->ut_numbern('countrycode')
188 || $self->ut_number('phonenum')
189 || $self->ut_anything('sip_password')
190 || $self->ut_numbern('pin')
191 || $self->ut_textn('phone_name')
193 return $error if $error;
195 $self->countrycode(1) unless $self->countrycode;
197 unless ( length($self->sip_password) ) {
200 join('', map $pw_set[ int(rand $#pw_set) ], (0..16) )
210 Checks the supplied PIN against the PIN in the database. Returns true for a
211 sucessful authentication, false if no match.
216 my($self, $check_pin) = @_;
217 $check_pin eq $self->pin;
226 L<FS::svc_Common>, L<FS::Record>, L<FS::cust_svc>, L<FS::part_svc>,
227 L<FS::cust_pkg>, schema.html from the base documentation.