state->areacode caching,
[freeside.git] / FS / FS / phone_avail.pm
1 package FS::phone_avail;
2
3 use strict;
4 use vars qw( @ISA );
5 use FS::Record qw( qsearch qsearchs );
6
7 @ISA = qw(FS::Record);
8
9 =head1 NAME
10
11 FS::phone_avail - Phone number availability cache
12
13 =head1 SYNOPSIS
14
15   use FS::phone_avail;
16
17   $record = new FS::phone_avail \%hash;
18   $record = new FS::phone_avail { 'column' => 'value' };
19
20   $error = $record->insert;
21
22   $error = $new_record->replace($old_record);
23
24   $error = $record->delete;
25
26   $error = $record->check;
27
28 =head1 DESCRIPTION
29
30 An FS::phone_avail object represents availability of phone service.
31 FS::phone_avail inherits from FS::Record.  The following fields are currently
32 supported:
33
34 =over 4
35
36 =item availnum
37
38 primary key
39
40 =item exportnum
41
42 exportnum
43
44 =item countrycode
45
46 countrycode
47
48 =item state
49
50 state
51
52 =item npa
53
54 npa
55
56 =item nxx
57
58 nxx
59
60 =back
61
62 =head1 METHODS
63
64 =over 4
65
66 =item new HASHREF
67
68 Creates a new record.  To add the record to the database, see L<"insert">.
69
70 Note that this stores the hash reference, not a distinct copy of the hash it
71 points to.  You can ask the object for a copy with the I<hash> method.
72
73 =cut
74
75 # the new method can be inherited from FS::Record, if a table method is defined
76
77 sub table { 'phone_avail'; }
78
79 =item insert
80
81 Adds this record to the database.  If there is an error, returns the error,
82 otherwise returns false.
83
84 =cut
85
86 # the insert method can be inherited from FS::Record
87
88 =item delete
89
90 Delete this record from the database.
91
92 =cut
93
94 # the delete method can be inherited from FS::Record
95
96 =item replace OLD_RECORD
97
98 Replaces the OLD_RECORD with this one in the database.  If there is an error,
99 returns the error, otherwise returns false.
100
101 =cut
102
103 # the replace method can be inherited from FS::Record
104
105 =item check
106
107 Checks all fields to make sure this is a valid record.  If there is
108 an error, returns the error, otherwise returns false.  Called by the insert
109 and replace methods.
110
111 =cut
112
113 # the check method should currently be supplied - FS::Record contains some
114 # data checking routines
115
116 sub check {
117   my $self = shift;
118
119   my $error = 
120     $self->ut_numbern('availnum')
121     || $self->ut_foreign_key('exportnum', 'part_export', 'exportnum' )
122     || $self->ut_number('countrycode')
123     || $self->ut_alphan('state')
124     || $self->ut_number('npa')
125     || $self->ut_numbern('nxx')
126   ;
127   return $error if $error;
128
129   $self->SUPER::check;
130 }
131
132 =back
133
134 =head1 BUGS
135
136 Sparse documentation.
137
138 =head1 SEE ALSO
139
140 L<FS::Record>, schema.html from the base documentation.
141
142 =cut
143
144 1;
145