line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Asterisk::CDR; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
24172
|
use 5.008006; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
36
|
|
4
|
|
|
|
|
|
|
#use strict; # Doesn't like constants below. Anybody know why? |
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
4
|
use base Class::DBI; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
870
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use constant DEFAULT_TABLE => 'cdr'; |
12
|
|
|
|
|
|
|
use constant DEFAULT_COLUMNS => ('calldate', 'clid', 'src', 'dst', 'dcontext', 'channel', 'dstchannel', |
13
|
|
|
|
|
|
|
'lastapp', 'lastdata', 'duration', 'billsec', 'disposition', 'amaflags', |
14
|
|
|
|
|
|
|
'accountcode', 'uniqueid', 'userfield'); |
15
|
|
|
|
|
|
|
sub init_db { |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $class = shift; |
18
|
|
|
|
|
|
|
my $args = {@_}; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$class->connection($args->{dsn}, $args->{username}, $args->{password}); |
21
|
|
|
|
|
|
|
$class->table($args->{table} || DEFAULT_TABLE); |
22
|
|
|
|
|
|
|
my @cols = @{$args->{columns}} or DEFAULT_COLUMNS; |
23
|
|
|
|
|
|
|
$class->columns(All => @cols); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
__END__ |