X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Frate_prefix.pm;h=93349f04dc8f43f78a22b7221980c8641bb21b1a;hp=500462a15da5a5f9b242f70c356f3562632a3c8e;hb=80511cb4158b98db01deec317e5408675487bc6e;hpb=48ba2845d0119c56971d5b724661aa37e73b49dd diff --git a/FS/FS/rate_prefix.pm b/FS/FS/rate_prefix.pm index 500462a15..93349f04d 100644 --- a/FS/FS/rate_prefix.pm +++ b/FS/FS/rate_prefix.pm @@ -2,8 +2,9 @@ package FS::rate_prefix; use strict; use vars qw( @ISA ); -use FS::Record qw( qsearch qsearchs ); +use FS::Record qw( qsearch qsearchs dbh ); use FS::rate_region; +use FS::lata; @ISA = qw(FS::Record); @@ -108,6 +109,9 @@ sub check { || $self->ut_number('countrycode') || $self->ut_numbern('npa') || $self->ut_numbern('nxx') + || $self->ut_foreign_keyn('latanum', 'lata', 'latanum') + || $self->ut_textn('state') + || $self->ut_textn('ocn') ; return $error if $error; @@ -122,7 +126,28 @@ Returns the rate region (see L) for this prefix. sub rate_region { my $self = shift; - qsearch('rate_region', { 'regionnum' => $self->regionnum } ); + qsearchs('rate_region', { 'regionnum' => $self->regionnum } ); +} + +=back + +=head1 CLASS METHODS + +=over 4 + +=item all_countrycodes + +Returns a list of all countrycodes listed in rate_prefix + +=cut + +sub all_countrycodes { + #my $class = shift; + my $sql = + "SELECT DISTINCT(countrycode) FROM rate_prefix ORDER BY countrycode"; + my $sth = dbh->prepare($sql) or die dbh->errstr; + $sth->execute or die $sth->errstr; + map $_->[0], @{ $sth->fetchall_arrayref }; } =back