summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlevinse <levinse>2011-01-16 05:44:15 +0000
committerlevinse <levinse>2011-01-16 05:44:15 +0000
commitae83e38c6767b3a7762a1c64159978ce76054e9b (patch)
treee7512788dcd2634a97393267f5442d26b7fdca66
parentfbab214cf73e03f9d8524fb385360cfe2cfb0b41 (diff)
DID import enhancements, RT11219
-rw-r--r--FS/FS/part_export/internal_diddb.pm30
-rw-r--r--FS/FS/phone_avail.pm2
-rw-r--r--httemplate/misc/phone_avail-import.html3
3 files changed, 30 insertions, 5 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, @_ );
diff --git a/httemplate/misc/phone_avail-import.html b/httemplate/misc/phone_avail-import.html
index 1f4d8ca..de280d0 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.
<BR><BR>
-<b>Default</b> format has the following field order: <i>state, number<i></i>
+<b>Default</b> format has the following field order: <i>state, number, name</i>
<BR><BR>
Field information:
<ul>
<li><i>state</i>: Two-letter state code, i.e. "CA"
<li><i>number</i>: Phone number
+ <li><i>name</i>: optional, rate center
</ul>
<% include('/elements/footer.html') %>