summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2013-02-22 08:27:20 -0800
committerMark Wells <mark@freeside.biz>2013-02-22 08:27:20 -0800
commitc3b8e954dbf5ddd04930809edfb77fa106fccaee (patch)
treeca2081dd206d5e53aa259d9eaea27c7efd37e5fd
parent4d3d1f29b5cb6d01e3474d0037fc4c6c866e8311 (diff)
exact-match rate regions, #20851
-rw-r--r--FS/FS/Schema.pm1
-rw-r--r--FS/FS/rate.pm29
-rw-r--r--FS/FS/rate_region.pm6
-rw-r--r--httemplate/browse/rate_region.html8
-rw-r--r--httemplate/edit/rate_region.cgi8
5 files changed, 41 insertions, 11 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 6c7453d..774dcd2 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -3056,6 +3056,7 @@ sub tables_hashref {
'columns' => [
'regionnum', 'serial', '', '', '', '',
'regionname', 'varchar', '', $char_d, '', '',
+ 'exact_match', 'char', 'NULL', 1, '', '',
],
'primary_key' => 'regionnum',
'unique' => [],
diff --git a/FS/FS/rate.pm b/FS/FS/rate.pm
index a2511cf..49ac938 100644
--- a/FS/FS/rate.pm
+++ b/FS/FS/rate.pm
@@ -308,17 +308,28 @@ sub dest_detail {
#find a rate prefix, first look at most specific, then fewer digits,
# finally trying the country code only
my $rate_prefix = '';
- for my $len ( reverse(1..10) ) {
- $rate_prefix = qsearchs('rate_prefix', {
+ $rate_prefix = qsearchs({
+ 'table' => 'rate_prefix',
+ 'addl_from' => ' JOIN rate_region USING (regionnum)',
+ 'hashref' => {
+ 'countrycode' => $countrycode,
+ 'npa' => $phonenum,
+ },
+ 'extra_sql' => ' AND exact_match = \'Y\''
+ });
+ if (!$rate_prefix) {
+ for my $len ( reverse(1..10) ) {
+ $rate_prefix = qsearchs('rate_prefix', {
+ 'countrycode' => $countrycode,
+ #'npa' => { op=> 'LIKE', value=> substr($number, 0, $len) }
+ 'npa' => substr($phonenum, 0, $len),
+ } ) and last;
+ }
+ $rate_prefix ||= qsearchs('rate_prefix', {
'countrycode' => $countrycode,
- #'npa' => { op=> 'LIKE', value=> substr($number, 0, $len) }
- 'npa' => substr($phonenum, 0, $len),
- } ) and last;
+ 'npa' => '',
+ });
}
- $rate_prefix ||= qsearchs('rate_prefix', {
- 'countrycode' => $countrycode,
- 'npa' => '',
- });
return '' unless $rate_prefix;
diff --git a/FS/FS/rate_region.pm b/FS/FS/rate_region.pm
index f4a0ab1..d42fdb4 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;
diff --git a/httemplate/browse/rate_region.html b/httemplate/browse/rate_region.html
index b958894..b0ce467 100644
--- a/httemplate/browse/rate_region.html
+++ b/httemplate/browse/rate_region.html
@@ -62,8 +62,14 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+my $sub_prefixes = sub {
+ my $region = shift;
+ $region->prefixes .
+ ($region->exact_match ? ' <I>(exact match only)</I>' : '');
+};
+
my @header = ( '#', 'Region', 'Country code', 'Prefixes' );
-my @fields = ( 'regionnum', 'regionname', 'ccode', 'prefixes' );
+my @fields = ( 'regionnum', 'regionname', 'ccode', $sub_prefixes );
my @links = ( ($link) x 4 );
my @align = ( 'right', 'left', 'right', 'left' );
my @xls_format = ( ({ locked=>1, bg_color=>22 }) x 4 );
diff --git a/httemplate/edit/rate_region.cgi b/httemplate/edit/rate_region.cgi
index 367bbaf..a1c1bcb 100644
--- a/httemplate/edit/rate_region.cgi
+++ b/httemplate/edit/rate_region.cgi
@@ -33,6 +33,14 @@
</TD>
</TR>
+ <& /elements/tr-checkbox.html,
+ label => 'Exact match',
+ field => 'exact_match',
+ cell_style => 'font-weight: bold',
+ value => 'Y',
+ curr_value => $rate_region->exact_match
+ &>
+
</TABLE>
<BR>