add -i flag to set carrierid, RT#86028, RT#81941
[freeside.git] / FS / bin / freeside-cdr-sftp_and_import
index aa4bf64..bae8051 100755 (executable)
@@ -12,8 +12,8 @@ use FS::cdr;
 # parse command line
 ###
 
-use vars qw( $opt_m $opt_p $opt_r $opt_e $opt_d $opt_v $opt_P $opt_a $opt_c $opt_g $opt_s $opt_b );
-getopts('c:m:p:r:e:d:v:P:agsb');
+use vars qw( $opt_m $opt_p $opt_r $opt_e $opt_d $opt_v $opt_P $opt_a $opt_c $opt_i $opt_g $opt_s $opt_b );
+getopts('c:i:m:p:r:e:d:v:P:agsb');
 
 $opt_e ||= 'csv';
 #$opt_e = ".$opt_e" unless $opt_e =~ /^\./;
@@ -22,6 +22,7 @@ $opt_e =~ s/^\.//;
 $opt_p ||= '';
 
 die "invalid cdrtypenum" if $opt_c && $opt_c !~ /^\d+$/;
+die "invalid carrierid"  if $opt_i && $opt_i !~ /^\d+$/;
 
 my %options = ();
 
@@ -114,6 +115,7 @@ foreach my $filename ( @$ls ) {
     'empty_ok'        => 1,
   };
   $import_options->{'cdrtypenum'} = $opt_c if $opt_c;
+  $import_options->{'carrierid'}  = $opt_i if $opt_i;
   
   my $error = FS::cdr::batch_import($import_options);
 
@@ -205,7 +207,8 @@ freeside-cdr-sftp_and_import - Download CDR files from a remote server via SFTP
 
   freeside-cdr-sftp_and_import [ -m method ] [ -p prefix ] [ -e extension ] 
     [ -r remotefolder ] [ -d donefolder ] [ -v level ] [ -P port ]
-    [ -a ] [ -g ] [ -s ] [ -c cdrtypenum ] user format [sftpuser@]servername
+    [ -a ] [ -g ] [ -s ] [ -c cdrtypenum ] [ -i carrierid]
+    user format [sftpuser@]servername
 
 =head1 DESCRIPTION
 
@@ -233,6 +236,8 @@ or FTP and then import them into the database.
 
 -c: cdrtypenum to set, defaults to none
 
+-i: carrierid to set, defaults to none
+
 -g: File is gzipped
 
 -s: Warn and skip files which could not be imported rather than abort