CDR updates; modularize CDR import formats; add formats for OpenSER, Genband/Tekelec...
[freeside.git] / FS / FS / cdr / simple.pm
1 package FS::cdr::simple;
2
3 use vars qw(@ISA %info);
4 use FS::cdr;
5
6 @ISA = qw(FS::cdr);
7
8 %info = (
9   'name'          => 'Simple',
10   'weight'        => 20,
11   'header'        => 1,
12   'import_fields' => [
13
14     # Date
15     sub { my($cdr, $date) = @_;
16           $date =~ /^(\d{1,2})\/(\d{1,2})\/(\d\d(\d\d)?)$/
17             or die "unparsable date: $date"; #maybe we shouldn't die...
18           #$cdr->startdate( timelocal(0, 0, 0 ,$2, $1-1, $3) );
19           ($tmp_mday, $tmp_mon, $tmp_year) = ( $2, $1-1, $3 );
20         },
21
22     # Time
23     sub { my($cdr, $time) = @_;
24           #my($sec, $min, $hour, $mday, $mon, $year)= localtime($cdr->startdate);
25           $time =~ /^(\d{1,2}):(\d{1,2}):(\d{1,2})$/
26             or die "unparsable time: $time"; #maybe we shouldn't die...
27           #$cdr->startdate( timelocal($3, $2, $1 ,$mday, $mon, $year) );
28           $cdr->startdate(
29             timelocal($3, $2, $1 ,$tmp_mday, $tmp_mon, $tmp_year)
30           );
31         },
32
33     # Source_Number
34     'src',
35
36     # Terminating_Number
37     'dst',
38
39     # Duration
40     sub { my($cdr, $min) = @_;
41           my $sec = sprintf('%.0f', $min * 60 );
42           $cdr->billsec(  $sec );
43           $cdr->duration( $sec );
44         },
45
46   ],
47 );
48
49 1;