1 package FS::rate_prefix;
5 use FS::Record qw( qsearch qsearchs dbh );
12 FS::rate_prefix - Object methods for rate_prefix records
18 $record = new FS::rate_prefix \%hash;
19 $record = new FS::rate_prefix { 'column' => 'value' };
21 $error = $record->insert;
23 $error = $new_record->replace($old_record);
25 $error = $record->delete;
27 $error = $record->check;
31 An FS::rate_prefix object represents an call rating prefix. FS::rate_prefix
32 inherits from FS::Record. The following fields are currently supported:
36 =item prefixnum - primary key
38 =item regionnum - call ration region (see L<FS::rate_region>)
54 Creates a new prefix. To add the prefix to the database, see L<"insert">.
56 Note that this stores the hash reference, not a distinct copy of the hash it
57 points to. You can ask the object for a copy with the I<hash> method.
61 # the new method can be inherited from FS::Record, if a table method is defined
63 sub table { 'rate_prefix'; }
67 Adds this record to the database. If there is an error, returns the error,
68 otherwise returns false.
72 # the insert method can be inherited from FS::Record
76 Delete this record from the database.
80 # the delete method can be inherited from FS::Record
82 =item replace OLD_RECORD
84 Replaces the OLD_RECORD with this one in the database. If there is an error,
85 returns the error, otherwise returns false.
89 # the replace method can be inherited from FS::Record
93 Checks all fields to make sure this is a valid prefix. If there is
94 an error, returns the error, otherwise returns false. Called by the insert
99 # the check method should currently be supplied - FS::Record contains some
100 # data checking routines
106 $self->ut_numbern('prefixnum')
107 || $self->ut_foreign_key('regionnum', 'rate_region', 'regionnum' )
108 || $self->ut_number('countrycode')
109 || $self->ut_numbern('npa')
110 || $self->ut_numbern('nxx')
112 return $error if $error;
119 Returns the rate region (see L<FS::rate_region>) for this prefix.
125 qsearchs('rate_region', { 'regionnum' => $self->regionnum } );
134 =item all_countrycodes
136 Returns a list of all countrycodes listed in rate_prefix
140 sub all_countrycodes {
143 "SELECT DISTINCT(countrycode) FROM rate_prefix ORDER BY countrycode";
144 my $sth = dbh->prepare($sql) or die dbh->errstr;
145 $sth->execute or die $sth->errstr;
146 map $_->[0], @{ $sth->fetchall_arrayref };
155 L<FS::rate_region>, L<FS::Record>, schema.html from the base documentation.