summaryrefslogtreecommitdiff
path: root/FS/FS/cdr/simple.pm
diff options
context:
space:
mode:
authorivan <ivan>2008-07-17 23:55:38 +0000
committerivan <ivan>2008-07-17 23:55:38 +0000
commit8a8d007453fa916bcb62223a1da620728b8df269 (patch)
treeecc4859105fa4e7a4aafd7bd8a7388456d99a1df /FS/FS/cdr/simple.pm
parent3502f19e6371bee6d974f05b2d3f22f8ccd03891 (diff)
CDR updates; modularize CDR import formats; add formats for OpenSER, Genband/Tekelec, and "NT"
Diffstat (limited to 'FS/FS/cdr/simple.pm')
-rw-r--r--FS/FS/cdr/simple.pm49
1 files changed, 49 insertions, 0 deletions
diff --git a/FS/FS/cdr/simple.pm b/FS/FS/cdr/simple.pm
new file mode 100644
index 0000000..ab1e3ea
--- /dev/null
+++ b/FS/FS/cdr/simple.pm
@@ -0,0 +1,49 @@
+package FS::cdr::simple;
+
+use vars qw(@ISA %info);
+use FS::cdr;
+
+@ISA = qw(FS::cdr);
+
+%info = (
+ 'name' => 'Simple',
+ 'weight' => 20,
+ 'header' => 1,
+ 'import_fields' => [
+
+ # Date
+ sub { my($cdr, $date) = @_;
+ $date =~ /^(\d{1,2})\/(\d{1,2})\/(\d\d(\d\d)?)$/
+ or die "unparsable date: $date"; #maybe we shouldn't die...
+ #$cdr->startdate( timelocal(0, 0, 0 ,$2, $1-1, $3) );
+ ($tmp_mday, $tmp_mon, $tmp_year) = ( $2, $1-1, $3 );
+ },
+
+ # Time
+ sub { my($cdr, $time) = @_;
+ #my($sec, $min, $hour, $mday, $mon, $year)= localtime($cdr->startdate);
+ $time =~ /^(\d{1,2}):(\d{1,2}):(\d{1,2})$/
+ or die "unparsable time: $time"; #maybe we shouldn't die...
+ #$cdr->startdate( timelocal($3, $2, $1 ,$mday, $mon, $year) );
+ $cdr->startdate(
+ timelocal($3, $2, $1 ,$tmp_mday, $tmp_mon, $tmp_year)
+ );
+ },
+
+ # Source_Number
+ 'src',
+
+ # Terminating_Number
+ 'dst',
+
+ # Duration
+ sub { my($cdr, $min) = @_;
+ my $sec = sprintf('%.0f', $min * 60 );
+ $cdr->billsec( $sec );
+ $cdr->duration( $sec );
+ },
+
+ ],
+);
+
+1;