DID import enhancements, RT11219
authorlevinse <levinse>
Sun, 16 Jan 2011 05:44:15 +0000 (05:44 +0000)
committerlevinse <levinse>
Sun, 16 Jan 2011 05:44:15 +0000 (05:44 +0000)
FS/FS/part_export/internal_diddb.pm
FS/FS/phone_avail.pm
httemplate/misc/phone_avail-import.html

index a330cb0..a94e43e 100644 (file)
@@ -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,
index 677195d..0d59113 100644 (file)
@@ -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, @_ );
index 1f4d8ca..de280d0 100644 (file)
@@ -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') %>