1 package FS::rate_prefix;
2 use base qw(FS::Record);
5 use FS::Record qw( dbh ); #qw( qsearch qsearchs dbh );
10 FS::rate_prefix - Object methods for rate_prefix records
16 $record = new FS::rate_prefix \%hash;
17 $record = new FS::rate_prefix { 'column' => 'value' };
19 $error = $record->insert;
21 $error = $new_record->replace($old_record);
23 $error = $record->delete;
25 $error = $record->check;
29 An FS::rate_prefix object represents an call rating prefix. FS::rate_prefix
30 inherits from FS::Record. The following fields are currently supported:
34 =item prefixnum - primary key
36 =item regionnum - call ration region (see L<FS::rate_region>)
52 Creates a new prefix. To add the prefix to the database, see L<"insert">.
54 Note that this stores the hash reference, not a distinct copy of the hash it
55 points to. You can ask the object for a copy with the I<hash> method.
59 # the new method can be inherited from FS::Record, if a table method is defined
61 sub table { 'rate_prefix'; }
65 Adds this record to the database. If there is an error, returns the error,
66 otherwise returns false.
70 # the insert method can be inherited from FS::Record
74 Delete this record from the database.
78 # the delete method can be inherited from FS::Record
80 =item replace OLD_RECORD
82 Replaces the OLD_RECORD with this one in the database. If there is an error,
83 returns the error, otherwise returns false.
87 # the replace method can be inherited from FS::Record
91 Checks all fields to make sure this is a valid prefix. If there is
92 an error, returns the error, otherwise returns false. Called by the insert
97 # the check method should currently be supplied - FS::Record contains some
98 # data checking routines
104 $self->ut_numbern('prefixnum')
105 || $self->ut_foreign_key('regionnum', 'rate_region', 'regionnum' )
106 || $self->ut_number('countrycode')
107 || $self->ut_numbern('npa')
108 || $self->ut_numbern('nxx')
109 || $self->ut_foreign_keyn('latanum', 'lata', 'latanum')
110 || $self->ut_textn('state')
111 || $self->ut_textn('ocn')
113 return $error if $error;
120 Returns the rate region (see L<FS::rate_region>) for this prefix.
128 =item all_countrycodes
130 Returns a list of all countrycodes listed in rate_prefix
134 sub all_countrycodes {
137 "SELECT DISTINCT(countrycode) FROM rate_prefix ORDER BY countrycode";
138 my $sth = dbh->prepare($sql) or die dbh->errstr;
139 $sth->execute or die $sth->errstr;
140 map $_->[0], @{ $sth->fetchall_arrayref };
149 L<FS::rate_region>, L<FS::Record>, schema.html from the base documentation.