1 package FS::phone_avail;
5 use FS::Record qw( qsearch qsearchs );
11 FS::phone_avail - Phone number availability cache
17 $record = new FS::phone_avail \%hash;
18 $record = new FS::phone_avail { 'column' => 'value' };
20 $error = $record->insert;
22 $error = $new_record->replace($old_record);
24 $error = $record->delete;
26 $error = $record->check;
30 An FS::phone_avail object represents availability of phone service.
31 FS::phone_avail inherits from FS::Record. The following fields are currently
84 Creates a new record. To add the record to the database, see L<"insert">.
86 Note that this stores the hash reference, not a distinct copy of the hash it
87 points to. You can ask the object for a copy with the I<hash> method.
91 # the new method can be inherited from FS::Record, if a table method is defined
93 sub table { 'phone_avail'; }
97 Adds this record to the database. If there is an error, returns the error,
98 otherwise returns false.
102 # the insert method can be inherited from FS::Record
106 Delete this record from the database.
110 # the delete method can be inherited from FS::Record
112 =item replace OLD_RECORD
114 Replaces the OLD_RECORD with this one in the database. If there is an error,
115 returns the error, otherwise returns false.
119 # the replace method can be inherited from FS::Record
123 Checks all fields to make sure this is a valid record. If there is
124 an error, returns the error, otherwise returns false. Called by the insert
129 # the check method should currently be supplied - FS::Record contains some
130 # data checking routines
136 $self->ut_numbern('availnum')
137 || $self->ut_foreign_key('exportnum', 'part_export', 'exportnum' )
138 || $self->ut_number('countrycode')
139 || $self->ut_alphan('state')
140 || $self->ut_number('npa')
141 || $self->ut_numbern('nxx')
142 || $self->ut_numbern('station')
143 || $self->ut_foreign_keyn('svcnum', 'cust_svc', 'svcnum' )
144 || $self->ut_textn('availbatch')
146 return $error if $error;
151 sub process_batch_import {
155 my( $phone_avail, $value ) = @_;
157 $value =~ /^(\d{3})(\d{3})(\d+)$/ or die "unparsable number $value\n";
158 #( $hash->{npa}, $hash->{nxx}, $hash->{station} ) = ( $1, $2, $3 );
159 $phone_avail->npa($1);
160 $phone_avail->nxx($2);
161 $phone_avail->station($3);
164 my $opt = { 'table' => 'phone_avail',
165 'params' => [ 'availbatch', 'exportnum', 'countrycode' ],
166 'formats' => { 'default' => [ 'state', $numsub ] },
169 FS::Record::process_batch_import( $job, $opt, @_ );
177 Sparse documentation.
181 L<FS::Record>, schema.html from the base documentation.