summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorivan <ivan>2009-01-03 01:52:59 +0000
committerivan <ivan>2009-01-03 01:52:59 +0000
commit0da7ecb92ccd671c47cb7fd4d04560cc80d4b520 (patch)
tree2c40a0ab1d7703806d5a85f1b248d219238eabd0 /FS
parent1d5f7cb129a7fade6ef9283977b2781ece183797 (diff)
indosoft CDR format, RT#4425
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Record.pm2
-rw-r--r--FS/FS/cdr.pm20
-rw-r--r--FS/FS/cdr/indosoft.pm71
3 files changed, 87 insertions, 6 deletions
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm
index 3327f18dc..16949fa95 100644
--- a/FS/FS/Record.pm
+++ b/FS/FS/Record.pm
@@ -1505,7 +1505,7 @@ sub batch_import {
my $job = $param->{job};
my $file = $param->{file};
my $format = $param->{'format'};
- my $params = $param->{params};
+ my $params = $param->{params} || {};
die "unknown format $format" unless exists $formats->{ $format };
diff --git a/FS/FS/cdr.pm b/FS/FS/cdr.pm
index 5bfd91da8..3c806f4c5 100644
--- a/FS/FS/cdr.pm
+++ b/FS/FS/cdr.pm
@@ -634,11 +634,12 @@ sub _cdr_min_parse {
sub _cdr_date_parser_maker {
my $field = shift;
+ my @fields = ref($field) ? @$field : ($field);
return sub {
- my( $cdr, $date ) = @_;
- #$cdr->$field( _cdr_date_parse($date) );
- eval { $cdr->$field( _cdr_date_parse($date) ); };
- die "error parsing date for $field from $date: $@\n" if $@;
+ my( $cdr, $datestring ) = @_;
+ my $unixdate = eval { _cdr_date_parse($datestring) };
+ die "error parsing date for @fields from $datestring: $@\n" if $@;
+ $cdr->$_($unixdate) foreach @fields;
};
}
@@ -674,13 +675,22 @@ Imports CDR records. Available options are:
=item file
+Filename
+
=item format
+=item params
+
+Hash reference of preset fields, typically cdrbatch
+
+=item empty_ok
+
+Set true to prevent throwing an error on empty imports
+
=back
=cut
-
my %import_options = (
'table' => 'cdr',
diff --git a/FS/FS/cdr/indosoft.pm b/FS/FS/cdr/indosoft.pm
new file mode 100644
index 000000000..cb25089e3
--- /dev/null
+++ b/FS/FS/cdr/indosoft.pm
@@ -0,0 +1,71 @@
+package FS::cdr::indosoft;
+
+use strict;
+use base qw( FS::cdr );
+use vars qw( %info );
+use FS::cdr qw( _cdr_date_parser_maker _cdr_min_parser_maker );
+
+%info = (
+ 'name' => 'Indosoft Conference Bridge',
+ 'weight' => 300,
+ 'header' => 1,
+ 'type' => 'csv',
+
+ #listref of what to do with each field from the CDR, in order
+ 'import_fields' => [
+
+ #cdr_id
+ 'uniqueid',
+
+ #connect_time
+ _cdr_date_parser_maker( ['startdate', 'answerdate' ] ),
+
+ #disconnect_time
+ _cdr_date_parser_maker('enddate'),
+
+ #account_id
+ 'accountcode',
+
+ #conference_id
+ 'userfield',
+
+ #client_id
+ 'charged_party',
+
+ #pin_used
+ 'dcontext',
+
+ #channel
+ 'channel',
+
+ #clid
+ #'src',
+ sub { my($cdr, $clid) = @_;
+ $cdr->clid( $clid ); #because they called it 'clid' explicitly
+ $cdr->src( $clid );
+ },
+
+ #dnis
+ 'dst',
+
+ #call_status
+ 'disposition',
+
+ #conf_billing_code
+ 'lastapp', #arbitrary
+
+ #participant_id
+ 'lastdata', #arbitrary
+
+ #codr_id
+ 'dstchannel', #arbitrary
+
+ #call_type
+ 'description',
+
+ ],
+
+);
+
+1;
+