X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Frate_region.pm;h=e6114c825c726a1a043974128f7cfbd9ad5151ed;hb=f120002baa4ef8d96994c3a6e2129b7e39f003ca;hp=f4a0ab196afe93bb3ce7be4687406aef62909bb1;hpb=91ffcc0ecc1e1da51fa4b99a342691caa85a5992;p=freeside.git diff --git a/FS/FS/rate_region.pm b/FS/FS/rate_region.pm index f4a0ab196..e6114c825 100644 --- a/FS/FS/rate_region.pm +++ b/FS/FS/rate_region.pm @@ -36,7 +36,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 +236,7 @@ sub check { my $error = $self->ut_numbern('regionnum') || $self->ut_text('regionname') + || $self->ut_flag('exact_match') ; return $error if $error; @@ -302,6 +306,36 @@ sub prefixes_short { $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