X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fnena2.pm;h=fa3597b7aa017d7be3e5d74ae0b00279be3f2bd0;hb=eb649eb7b8851a07a36955a26685d061b46e4593;hp=ad67ba2a07a2f25c583323c12152fff026e93907;hpb=8577c7ca4210f58be1d0188bd0d45d44f899ec40;p=freeside.git

diff --git a/FS/FS/part_export/nena2.pm b/FS/FS/part_export/nena2.pm
index ad67ba2a0..fa3597b7a 100644
--- a/FS/FS/part_export/nena2.pm
+++ b/FS/FS/part_export/nena2.pm
@@ -15,11 +15,17 @@ my %upload_targets;
 
 tie %options, 'Tie::IxHash', (
   'company_name'    => {  label => 'Company name for header record',
-                          type  => 'text'
+                          type  => 'text',
                        },
   'company_id'      => {  label => 'NENA company ID',
                           type  => 'text',
                        },
+  'customer_code'   => {  label => 'Customer code',
+                          type  => 'text',
+                       },
+  'area_code'       => {  label => 'Default area code for 7 digit numbers',
+                          type  => 'text',
+                       },
   'prefix'          => {  label => 'File name prefix',
                           type  => 'text',
                        },
@@ -215,12 +221,18 @@ sub data {
   my $cust_location = FS::cust_location->by_key($locationnum);
 
   # initialize with empty strings
-  my %hash = map { $_ => '' } $item_format->names;
+  my %hash = map { $_ => '' } @{ $item_format->names };
 
   $hash{function_code} = $function_code{$action};
-
-  # phone number 
-  $svc->phonenum =~ /^(\d{3})(\d*)$/;
+  
+  # Add default area code if phonenum is 7 digits
+  my $phonenum = $svc->phonenum;
+  if ($self->option('area_code') =~ /^\d{3}$/ && $phonenum =~ /^\d{7}$/ ){
+  $phonenum = $self->option('area_code'). $svc->phonenum;
+  }
+ 
+  # phone number
+  $phonenum =~ /^(\d{3})(\d*)$/;
   $hash{npa} = $1;
   $hash{calling_number} = $2;
 
@@ -277,13 +289,11 @@ sub data {
   # so we can't comply.  NENA 3 fixed this...
 
   $hash{company_id} = $self->option('company_id');
+  $hash{customer_code} = $self->option('customer_code') || '';
   $hash{source_id} = $initial_load_hack ? 'C' : ' ';
 
-  @hash{'zip', 'zip_'} = split('-', $cust_location->zip);
-  
-  # $hash{customer_code} is supposed to "uniquely identify a customer" but 
-  # they give us 3 alphanumeric characters.  Not sure how that works.
-
+  @hash{'zip_code', 'zip_4'} = split('-', $cust_location->zip);
+ 
   $hash{x_coordinate} = $cust_location->longitude;
   $hash{y_coordinate} = $cust_location->latitude;
   # $hash{z_coordinate} = $cust_location->altitude; # not implemented, sadly