5 #use FS::Record qw( qsearch qsearchs );
8 @ISA = qw( FS::svc_Common );
12 FS::svc_phone - Object methods for svc_phone records
18 $record = new FS::svc_phone \%hash;
19 $record = new FS::svc_phone { 'column' => 'value' };
21 $error = $record->insert;
23 $error = $new_record->replace($old_record);
25 $error = $record->delete;
27 $error = $record->check;
29 $error = $record->suspend;
31 $error = $record->unsuspend;
33 $error = $record->cancel;
37 An FS::svc_phone object represents a phone number. FS::svc_phone inherits
38 from FS::Record. The following fields are currently supported:
42 =item svcnum - primary key
58 Creates a new phone number. To add the number to the database, see L<"insert">.
60 Note that this stores the hash reference, not a distinct copy of the hash it
61 points to. You can ask the object for a copy with the I<hash> method.
65 # the new method can be inherited from FS::Record, if a table method is defined
69 'name' => 'Phone number',
70 'sorts' => 'phonenum',
71 'display_weight' => 60,
72 'cancel_weight' => 80,
74 'countrycode' => { label => 'Country code',
76 disable_inventory => 1,
79 'phonenum' => 'Phone number',
80 'pin' => { label => 'Personal Identification Number',
82 disable_inventory => 1,
89 sub table { 'svc_phone'; }
91 =item search_sql STRING
93 Class method which returns an SQL fragment to search for the given string.
98 my( $class, $string ) = @_;
99 $class->search_sql_field('phonenum', $string );
104 Returns the phone number.
110 $self->phonenum; #XXX format it better
115 Adds this record to the database. If there is an error, returns the error,
116 otherwise returns false.
120 # the insert method can be inherited from FS::Record
124 Delete this record from the database.
128 # the delete method can be inherited from FS::Record
130 =item replace OLD_RECORD
132 Replaces the OLD_RECORD with this one in the database. If there is an error,
133 returns the error, otherwise returns false.
137 # the replace method can be inherited from FS::Record
141 Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>).
145 Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>).
149 Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
153 Checks all fields to make sure this is a valid phone number. If there is
154 an error, returns the error, otherwise returns false. Called by the insert
159 # the check method should currently be supplied - FS::Record contains some
160 # data checking routines
165 my $phonenum = $self->phonenum;
166 $phonenum =~ s/\D//g;
167 $self->phonenum($phonenum);
170 $self->ut_numbern('svcnum')
171 || $self->ut_numbern('countrycode')
172 || $self->ut_number('phonenum')
173 || $self->ut_anythingn('sip_password')
174 || $self->ut_numbern('pin')
176 return $error if $error;
178 $self->countrycode(1) unless $self->countrycode;
185 Checks the supplied PIN against the PIN in the database. Returns true for a
186 sucessful authentication, false if no match.
191 my($self, $check_pin) = @_;
192 $check_pin eq $self->pin;
201 L<FS::svc_Common>, L<FS::Record>, L<FS::cust_svc>, L<FS::part_svc>,
202 L<FS::cust_pkg>, schema.html from the base documentation.