diff options
author | levinse <levinse> | 2011-01-16 05:44:15 +0000 |
---|---|---|
committer | levinse <levinse> | 2011-01-16 05:44:15 +0000 |
commit | ae83e38c6767b3a7762a1c64159978ce76054e9b (patch) | |
tree | e7512788dcd2634a97393267f5442d26b7fdca66 /FS/FS | |
parent | fbab214cf73e03f9d8524fb385360cfe2cfb0b41 (diff) |
DID import enhancements, RT11219
Diffstat (limited to 'FS/FS')
-rw-r--r-- | FS/FS/part_export/internal_diddb.pm | 30 | ||||
-rw-r--r-- | FS/FS/phone_avail.pm | 2 |
2 files changed, 28 insertions, 4 deletions
diff --git a/FS/FS/part_export/internal_diddb.pm b/FS/FS/part_export/internal_diddb.pm index a330cb0..a94e43e 100644 --- a/FS/FS/part_export/internal_diddb.pm +++ b/FS/FS/part_export/internal_diddb.pm @@ -30,7 +30,20 @@ sub get_dids { 'svcnum' => '', ); - if ( $opt{'areacode'} && $opt{'exchange'} ) { #return numbers + if ( $opt{'ratecenter'} && $opt{'state'} ) { + my $rc = $opt{ratecenter}; + $rc =~ s/, [A-Z][A-Z]$//g; + $hash{name} = $rc; + $hash{state} = $opt{state}; + + return [ map { $_->npa. '-'. $_->nxx. '-'. $_->station } + qsearch({ 'table' => 'phone_avail', + 'hashref' => \%hash, + 'order_by' => 'ORDER BY station', + }) + ]; + } + elsif ( $opt{'areacode'} && $opt{'exchange'} ) { #return numbers $hash{npa} = $opt{areacode}; $hash{nxx} = $opt{exchange}; @@ -42,11 +55,22 @@ sub get_dids { }) ]; - } elsif ( $opt{'areacode'} ) { #return city (npa-nxx-XXXX) + } elsif ( $opt{'areacode'} ) { $hash{npa} = $opt{areacode}; - return [ map { '('. $_->npa. '-'. $_->nxx. '-XXXX)' } + my @rc = qsearch({ 'select' => 'DISTINCT name, state', + 'table' => 'phone_avail', + 'hashref' => \%hash, + }); + + if(scalar(@rc)) { + my $first_phone_avail = $rc[0]; + return [ map { $_->get('name').", ".$_->state } @rc ] + if $first_phone_avail->get('name'); + } + + return [ map { '('. $_->npa. '-'. $_->nxx. '-XXXX)' } qsearch({ 'select' => 'DISTINCT npa, nxx', 'table' => 'phone_avail', 'hashref' => \%hash, diff --git a/FS/FS/phone_avail.pm b/FS/FS/phone_avail.pm index 677195d..0d59113 100644 --- a/FS/FS/phone_avail.pm +++ b/FS/FS/phone_avail.pm @@ -188,7 +188,7 @@ sub process_batch_import { my $opt = { 'table' => 'phone_avail', 'params' => [ 'availbatch', 'exportnum', 'countrycode' ], - 'formats' => { 'default' => [ 'state', $numsub ] }, + 'formats' => { 'default' => [ 'state', $numsub, 'name' ], }, }; FS::Record::process_batch_import( $job, $opt, @_ ); |