summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Davis <jeremyd@freeside.biz>2014-11-04 09:42:53 -0500
committerJeremy Davis <jeremyd@freeside.biz>2014-11-04 09:42:53 -0500
commitc7560e90bea5f1450cf66254468d427b854c83c4 (patch)
tree019d59dd0a37de81e1be8561d35d3ae79c0626cc
parent3503b600f300515c448d19a3e332e5c24d2bdfbe (diff)
Ticket #29048 3cx cdr format
-rw-r--r--FS/FS/cdr/cx3.pm53
1 files changed, 53 insertions, 0 deletions
diff --git a/FS/FS/cdr/cx3.pm b/FS/FS/cdr/cx3.pm
new file mode 100644
index 000000000..bc511d966
--- /dev/null
+++ b/FS/FS/cdr/cx3.pm
@@ -0,0 +1,53 @@
+package FS::cdr::cx3;
+
+use strict;
+use vars qw( @ISA %info);
+use FS::cdr;
+use Date::Parse;
+
+@ISA = qw(FS::cdr);
+
+%info = (
+ 'name' => '3CX',
+ 'weight' => 120,
+ 'header' => 1,
+ 'import_fields' => [
+
+
+sub {
+ my ($cdr, $data, $conf, $param) = @_;
+ $param->{skiprow} = 1 if $data ne 'CallDetail 0'; # skip non-detail records
+ }, # record type
+ 'uniqueid', # unique id
+ skip(1), # unknown
+ 'src', # source
+ 'dst', # destination
+sub { my ($cdr, $calldate, $param) = @_;
+
+ if ($calldate =~ /^(\d{4})-(\d{2})-(\d{2})\s*(\d{2}):(\d{2}):(\d{2})$/){
+
+ $cdr->set('calldate', $calldate);
+ my $tmp_date = "$2/$3/$1 $4:$5:$6";
+
+ $tmp_date = str2time($tmp_date);
+ $cdr->set('startdate', $tmp_date);
+ }
+ }, #date
+sub { my ($cdr, $duration) = @_;
+
+ my ($hour,$min,$sec) = split(/:/,$duration);
+ $sec += $min * 60;
+ $sec += $hour * 60 * 60;
+ $sec = sprintf ("%.0f", $sec);
+ $cdr->set('billsec', $sec);
+
+}, #duration
+ skip(1), # unknown
+ 'disposition', # call status
+
+ ],
+);
+
+sub skip { map {''} (1..$_[0]) }
+
+1;