include agent and restore cust-level status in small_custview
[freeside.git] / FS / FS / cdr / kannel.pm
1 package FS::cdr::kannel;
2
3 use strict;
4 use vars qw( @ISA %info );
5 use FS::cdr qw( _cdr_date_parser_maker );
6
7 @ISA = qw(FS::cdr);
8
9 %info = (
10   'name'          => 'Kannel',
11   'weight'        => 25,
12   'header'        => 1,
13   'type'          => 'csv',
14   'row_callback'  => sub { my $row = shift;
15                         return ' ' if $row =~ /.*Log (begins|ends)$/;
16                         die "invalid row format for '$row'" unless
17                             $row =~ /^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) ([A-Za-z ]+) (\[SMSC:\w+\] \[SVC:\w*\] \[ACT:\w*\] \[BINF:\w*\] \[FID:\w*\]) \[from:(.*?)\] \[to:(.*?)\] (\[flags:.*?\]) \[msg:(\d+):.*?\] (\[udh:.*?\])$/;
18                         $row = "$1,$2,$3,$4,$5,$6,$7,$8";
19                         $row;
20                      },
21   'import_fields' => [
22         _cdr_date_parser_maker('startdate'),
23         'disposition',
24         'userfield', # [SMSC: ... FID...], five fields
25
26         sub {
27             my($cdr, $src) = @_;
28             $src =~ s/[^\+\d]//g; 
29             $src =~ /^(\+|)(\d+)$/ 
30                 or die "unparsable number: $src"; #maybe we shouldn't die...
31             $cdr->src("$1$2");
32         },
33         
34         sub {
35             my($cdr, $dst) = @_;
36             $dst =~ s/[^\+\d]//g; 
37             $dst =~ /^(\+|)(\d+)$/ 
38                 or die "unparsable number: $dst"; #maybe we shouldn't die...
39             $cdr->dst("$1$2");
40         },
41
42         sub { my($cdr, $flags) = @_;
43             $cdr->userfield($cdr->userfield." $flags");
44         },
45
46         # setting billsec to the msg length as we need billsec set non-zero
47         'billsec', 
48
49         sub { my($cdr, $udh) = @_;
50             $cdr->userfield($cdr->userfield." $udh");
51         },
52   ],
53 );
54
55 sub skip { map {''} (1..$_[0]) }
56
57 1;