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:
64 Creates a new phone number. To add the number to the database, see L<"insert">.
66 Note that this stores the hash reference, not a distinct copy of the hash it
67 points to. You can ask the object for a copy with the I<hash> method.
71 # the new method can be inherited from FS::Record, if a table method is defined
75 'name' => 'Phone number',
76 'sorts' => 'phonenum',
77 'display_weight' => 60,
78 'cancel_weight' => 80,
80 'countrycode' => { label => 'Country code',
82 disable_inventory => 1,
85 'phonenum' => 'Phone number',
86 'pin' => { label => 'Personal Identification Number',
88 disable_inventory => 1,
91 'sip_password' => 'SIP password',
96 sub table { 'svc_phone'; }
98 =item search_sql STRING
100 Class method which returns an SQL fragment to search for the given string.
105 my( $class, $string ) = @_;
106 $class->search_sql_field('phonenum', $string );
111 Returns the phone number.
117 $self->phonenum; #XXX format it better
122 Adds this record to the database. If there is an error, returns the error,
123 otherwise returns false.
127 # the insert method can be inherited from FS::Record
131 Delete this record from the database.
135 # the delete method can be inherited from FS::Record
137 =item replace OLD_RECORD
139 Replaces the OLD_RECORD with this one in the database. If there is an error,
140 returns the error, otherwise returns false.
144 # the replace method can be inherited from FS::Record
148 Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>).
152 Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>).
156 Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
160 Checks all fields to make sure this is a valid phone number. If there is
161 an error, returns the error, otherwise returns false. Called by the insert
166 # the check method should currently be supplied - FS::Record contains some
167 # data checking routines
172 my $phonenum = $self->phonenum;
173 $phonenum =~ s/\D//g;
174 $self->phonenum($phonenum);
177 $self->ut_numbern('svcnum')
178 || $self->ut_numbern('countrycode')
179 || $self->ut_number('phonenum')
180 || $self->ut_anything('sip_password')
181 || $self->ut_numbern('pin')
183 return $error if $error;
185 $self->countrycode(1) unless $self->countrycode;
192 Checks the supplied PIN against the PIN in the database. Returns true for a
193 sucessful authentication, false if no match.
198 my($self, $check_pin) = @_;
199 $check_pin eq $self->pin;
208 L<FS::svc_Common>, L<FS::Record>, L<FS::cust_svc>, L<FS::part_svc>,
209 L<FS::cust_pkg>, schema.html from the base documentation.