From c3054513f27015595ce512dcb28748fb9ee11e27 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 19 Aug 2008 10:06:45 +0000 Subject: [PATCH] more consistent prefix display, and don't forget nxx' --- FS/FS/rate_region.pm | 5 +++-- httemplate/browse/rate_region.html | 7 ++++++- httemplate/edit/rate_region.cgi | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/FS/FS/rate_region.pm b/FS/FS/rate_region.pm index df3951f8b..0e6522302 100644 --- a/FS/FS/rate_region.pm +++ b/FS/FS/rate_region.pm @@ -287,12 +287,13 @@ 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 .= '-'. $rate_prefix->nxx if $rate_prefix->nxx; $out .= ', '; } $out =~ s/, $//; diff --git a/httemplate/browse/rate_region.html b/httemplate/browse/rate_region.html index e144625a5..df3d2f0b8 100644 --- a/httemplate/browse/rate_region.html +++ b/httemplate/browse/rate_region.html @@ -33,8 +33,13 @@ my $extra_sql = ''; if ( driver_name =~ /^Pg/ ) { my $fromwhere = 'FROM rate_prefix'. ' WHERE rate_prefix.regionnum = rate_region.regionnum'; + my $prefix_sql = " CASE WHEN nxx IS NULL OR nxx = '' ". + " THEN npa ". + " ELSE npa || '-' || nxx ". + " END"; + my $prefixes_sql = "SELECT $prefix_sql $fromwhere AND npa IS NOT NULL"; $select .= "( SELECT countrycode $fromwhere LIMIT 1 ) AS ccode, - ARRAY_TO_STRING( ARRAY(SELECT npa $fromwhere AND npa IS NOT NULL), ',' ) AS prefixes"; + ARRAY_TO_STRING( ARRAY($prefixes_sql), ',' ) AS prefixes"; } elsif ( driver_name =~ /^mysql/i ) { $join = 'LEFT JOIN rate_prefix USING ( regionnum )'; $select .= "GROUP_CONCAT( DISTINCT countrycode ) AS ccode, diff --git a/httemplate/edit/rate_region.cgi b/httemplate/edit/rate_region.cgi index c58fc8065..496e054b1 100644 --- a/httemplate/edit/rate_region.cgi +++ b/httemplate/edit/rate_region.cgi @@ -29,7 +29,7 @@
(comma-separated) - + -- 2.11.0