X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcdr.pm;h=36721a81adf8fa426880f7cd8ef0371677bc9551;hb=b7b5088f7e2f5dd21c8c53d98461609d1c89d6e3;hp=3157b6b60942a399823da25c99c37f32749067e6;hpb=43fe059594a5f7b21413ea6805eb41d4ed89fa6a;p=freeside.git diff --git a/FS/FS/cdr.pm b/FS/FS/cdr.pm index 3157b6b60..36721a81a 100644 --- a/FS/FS/cdr.pm +++ b/FS/FS/cdr.pm @@ -560,11 +560,11 @@ sub export_formats { my $duration_sub = sub { my($cdr, %opt) = @_; my $sec = $opt{seconds} || $cdr->billsec; - if ( length($opt{granularity}) && + if ( defined $opt{granularity} && $opt{granularity} == 0 ) { #per call return '1 call'; } - elsif ( $opt{granularity} == 60 ) {#full minutes + elsif ( defined $opt{granularity} && $opt{granularity} == 60 ) {#full minutes my $min = int($sec/60); $min++ if $sec%60; return $min.'m'; @@ -620,7 +620,10 @@ sub export_formats { $duration_sub, #PRICE - sub { my($cdr, %opt) = @_; $opt{money_char}. $opt{charge}; }, + sub { my($cdr, %opt) = @_; + $opt{charge} = '0.00' unless defined $opt{charge}; + $opt{money_char}.$opt{charge}; + }, ], ); @@ -660,6 +663,8 @@ sub downstream_csv { } @{ $formats{$format} }; + return @columns if defined $opt{'keeparray'}; + my $status = $csv->combine(@columns); die "FS::CDR: error combining ". $csv->error_input(). "into downstream CSV" unless $status; @@ -906,7 +911,7 @@ my %import_options = ( }, #drop the || 'csv' to allow auto xls for csv types? - 'format_types' => { map { $_ => ( lc($cdr_info{$_}->{'type'}) || 'csv' ); } + 'format_types' => { map { $_ => lc($cdr_info{$_}->{'type'} || 'csv'); } keys %cdr_info }, @@ -943,6 +948,14 @@ sub batch_import { my $iopt = _import_options; $opt->{$_} = $iopt->{$_} foreach keys %$iopt; + if ( defined $opt->{'cdrtypenum'} ) { + $opt->{'preinsert_callback'} = sub { + my($record,$param) = (shift,shift); + $record->cdrtypenum($opt->{'cdrtypenum'}); + ''; + }; + } + FS::Record::batch_import( $opt ); }