);
my @cols = (
- 'cc_call.id as id', 'cc_card.username as username',
+ "$table.id as id", 'cc_card.username as username',
qw( sessionid
starttime stoptime sessiontime real_sessiontime
terminatecauseid
);
my $sql = 'SELECT '.join(',', @cols). " FROM $table".
+ " LEFT JOIN cc_card ON ( $table.card_id = cc_card.id ) ".
' WHERE freesidestatus IS NULL' .
($start && " AND starttime >= '$start'") .
($end && " AND starttime < '$end'") ;
my $row;
while ( $row = $sth->fetchrow_hashref ) {
- $row->{calledstation} =~ s/^1//;
+ my $dst = $row->{calledstation};
+ my $dst_ip_addr = '';
+ if ($dst =~ m[^SIP/(\d+)@(.*)$] ) {
+ $dst = $1;
+ $dst_ip_addr = $2;
+ }
+ $dst =~ s/^1//;
$row->{src} =~ s/^1//;
my $cdr = FS::cdr->new ({
uniqueid => $row->{sessionid},
enddate => time2str($row->{stoptime}),
duration => $row->{sessiontime},
billsec => $row->{real_sessiontime},
- dst => $row->{calledstation},
+ dst => $dst,
src => $row->{src},
+ dst_ip_addr => $dst_ip_addr,
+ dstchannel => $row->{calledstation},
charged_party => $row->{username},
upstream_rateplanid => $row->{id_tariffplan},
upstream_rateid => $row->{id_ratecard}, # I think?