package FS::rate_region;
+use base qw(FS::Record);
use strict;
-use vars qw( @ISA );
use FS::Record qw( qsearch qsearchs dbh );
use FS::rate_prefix;
use FS::rate_detail;
-@ISA = qw(FS::Record);
-
=head1 NAME
FS::rate_region - Object methods for rate_region records
=item regionnum - primary key
-=item regionname
+=item regionname - name of the region
+
+=item exact_match - 'Y' if "prefixes" in this region really represent
+complete phone numbers. Null if they represent prefixes (the usual case).
=back
my $error =
$self->ut_numbern('regionnum')
|| $self->ut_text('regionname')
+ || $self->ut_flag('exact_match')
;
return $error if $error;
$out;
}
+sub prefixes_short_sql {
+ my $self = shift;
+
+ my $countrycode = '';
+ my $out = '';
+
+ foreach my $prefix (sort split(',', $self->prefixes)) {
+ my($cc, $npa) = split(' ', $prefix);
+
+ if ( $countrycode ne $cc ) {
+ $out =~ s/, $//;
+ $countrycode = $cc;
+ $out.= " +$countrycode ";
+ }
+ if ( $countrycode eq '1' ) {
+ #$out .= '('. substr( $npa, 0, 3 ). ')';
+ $out .= substr( $npa, 0, 3 );
+ $out .= ' '. substr( $npa, 3 ) if length($npa) > 3;
+ } else {
+ $out .= $npa;
+ }
+#XXX have to implement this here too if we ever actually used the nxx field
+# $out .= '-'. $rate_prefix->nxx if $rate_prefix->nxx;
+ $out .= ', ';
+ }
+ $out =~ s/, $//;
+
+ $out;
+}
+
=back
=head1 BUGS