X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Frate_region.pm;h=0a501a7857a47c01fc674d741df34cf46a823d6c;hp=65dfd2a25c4a08642a723c6f1b9b963690d04428;hb=20f03d52cc6c930f610c0b4466eeeeda54fdbb40;hpb=9509e5bfb7f9331303153cac24d7bfecbe2ea9f1 diff --git a/FS/FS/rate_region.pm b/FS/FS/rate_region.pm index 65dfd2a25..0a501a785 100644 --- a/FS/FS/rate_region.pm +++ b/FS/FS/rate_region.pm @@ -1,13 +1,11 @@ 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 @@ -36,7 +34,10 @@ inherits from FS::Record. The following fields are currently supported: =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 @@ -233,6 +234,7 @@ sub check { my $error = $self->ut_numbern('regionnum') || $self->ut_text('regionname') + || $self->ut_flag('exact_match') ; return $error if $error; @@ -248,6 +250,7 @@ Returns all prefixes (see L) for this region. sub rate_prefix { my $self = shift; + map { $_ } #return $self->num_rate_prefix unless wantarray; sort { $a->countrycode cmp $b->countrycode or $a->npa cmp $b->npa or $a->nxx cmp $b->nxx @@ -264,7 +267,7 @@ destionation. sub dest_detail { my $self = shift; - qsearch( 'rate_detail', { 'dest_regionnum' => $self->regionnum, } ); + qsearch( 'rate_detail', { 'dest_regionnum' => $self->regionnum } ); } =item prefixes_short @@ -287,11 +290,43 @@ sub prefixes_short { } my $npa = $rate_prefix->npa; if ( $countrycode eq '1' ) { - $out .= '('. substr( $npa, 0, 3 ). ')'; + #$out .= '('. substr( $npa, 0, 3 ). ')'; + $out .= substr( $npa, 0, 3 ); $out .= ' '. substr( $npa, 3 ) if length($npa) > 3; } else { $out .= $rate_prefix->npa; } + $out .= '-'. $rate_prefix->nxx if $rate_prefix->nxx; + $out .= ', '; + } + $out =~ s/, $//; + + $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/, $//;