X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2Fbin%2Ffreeside-cdr-a2billing-import;h=aa7fa4a61e22676a8129d8d3bab427e27af45379;hp=923f5fbb13ad43585d77a233757f803102f6e04b;hb=ac8410cdb67639afeb84c84e975fffadf3e6cce1;hpb=0c759132a02d9403f391c6a997cbe754a4dba407 diff --git a/FS/bin/freeside-cdr-a2billing-import b/FS/bin/freeside-cdr-a2billing-import index 923f5fbb1..aa7fa4a61 100755 --- a/FS/bin/freeside-cdr-a2billing-import +++ b/FS/bin/freeside-cdr-a2billing-import @@ -91,7 +91,7 @@ my %disposition = ( ); 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 @@ -101,6 +101,7 @@ my @cols = ( ); 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'") ; @@ -119,7 +120,13 @@ my $updates = 0; 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}, @@ -128,8 +135,10 @@ while ( $row = $sth->fetchrow_hashref ) { 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?