From: levinse Date: Sun, 16 Jan 2011 05:44:15 +0000 (+0000) Subject: DID import enhancements, RT11219 X-Git-Tag: freeside_2_3_0~751 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=ae83e38c6767b3a7762a1c64159978ce76054e9b DID import enhancements, RT11219 --- diff --git a/FS/FS/part_export/internal_diddb.pm b/FS/FS/part_export/internal_diddb.pm index a330cb0a6..a94e43e28 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 677195d92..0d591138c 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, @_ ); diff --git a/httemplate/misc/phone_avail-import.html b/httemplate/misc/phone_avail-import.html index 1f4d8caae..de280d0f9 100644 --- a/httemplate/misc/phone_avail-import.html +++ b/httemplate/misc/phone_avail-import.html @@ -64,13 +64,14 @@ Import a file containing phone numbers (DIDs). Uploaded files can be CSV (comma-separated value) files or Excel spreadsheets. The file should have a .CSV or .XLS extension.

-Default format has the following field order: state, number +Default format has the following field order: state, number, name

Field information: <% include('/elements/footer.html') %>