. is used in some implementations of classic crypt
[freeside.git] / FS / FS / cdr.pm
index 439d5ae..79a687e 100644 (file)
@@ -129,6 +129,8 @@ following fields are currently supported:
 
 =item freesidestatus - NULL, done (or something)
 
+=item cdrbatch
+
 =back
 
 =head1 METHODS
@@ -244,14 +246,16 @@ sub check {
   my $error =
        $self->ut_numbern('acctid')
 
-    #Usage = 1, S&E = 7, OC&C = 8
-    || $self->ut_foreign_keyn('cdrtypenum',  'cdr_type',     'cdrtypenum' )
-
-    #the big list in appendix 2
-    || $self->ut_foreign_keyn('calltypenum', 'cdr_calltype', 'calltypenum' )
-
-    # Telstra =1, Optus = 2, RSL COM = 3
-    || $self->ut_foreign_keyn('carrierid', 'cdr_carrier', 'carrierid' )
+  #add a config option to turn these back on if someone needs 'em
+  #
+  #  #Usage = 1, S&E = 7, OC&C = 8
+  #  || $self->ut_foreign_keyn('cdrtypenum',  'cdr_type',     'cdrtypenum' )
+  #
+  #  #the big list in appendix 2
+  #  || $self->ut_foreign_keyn('calltypenum', 'cdr_calltype', 'calltypenum' )
+  #
+  #  # Telstra =1, Optus = 2, RSL COM = 3
+  #  || $self->ut_foreign_keyn('carrierid', 'cdr_carrier', 'carrierid' )
   ;
   return $error if $error;
 
@@ -617,6 +621,7 @@ sub batch_import {
 
   my $fh = $param->{filehandle};
   my $format = $param->{format};
+  my $cdrbatch = $param->{cdrbatch};
 
   return "Unknown format $format"
     unless exists( $cdr_info{$format} )
@@ -630,7 +635,11 @@ sub batch_import {
   if ( $type eq 'csv' ) {
     eval "use Text::CSV_XS;";
     die $@ if $@;
-    $parser = new Text::CSV_XS;
+    my %attr = ();
+    foreach ( grep exists($info->{$_}), qw( sep_char ) ) {
+      $attr{$_} = $info->{$_};
+    }
+    $parser = new Text::CSV_XS \%attr;
   } elsif ( $type eq 'fixedlength' ) {
     eval "use Parse::FixedLength;";
     die $@ if $@;
@@ -699,6 +708,8 @@ sub batch_import {
       }
       @{ $info->{'import_fields'} }
     ;
+    $cdr{cdrbatch} = $cdrbatch;
 
     my $cdr = new FS::cdr ( \%cdr );
 
@@ -732,7 +743,7 @@ sub batch_import {
   $dbh->commit or die $dbh->errstr if $oldAutoCommit;
 
   #might want to disable this if we skip records for any reason...
-  return "Empty file!" unless $imported;
+  return "Empty file!" unless $imported || $param->{empty_ok};
 
   '';