X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcdr%2Fenswitch.pm;h=a19b16641f8232ae5e04dc09519f022093236674;hb=89a387874554b561f87d7ad5958f915f4feb95d6;hp=64518af6d354c007e2301f7de9c41fcea65994bd;hpb=b49c1bd5510a5f10b05bffacc6cc8b6a1b2153e8;p=freeside.git diff --git a/FS/FS/cdr/enswitch.pm b/FS/FS/cdr/enswitch.pm index 64518af6d..a19b16641 100644 --- a/FS/FS/cdr/enswitch.pm +++ b/FS/FS/cdr/enswitch.pm @@ -1,11 +1,10 @@ package FS::cdr::enswitch; +use base qw( FS::cdr ); use strict; -use vars qw( @ISA %info $tmp_mon $tmp_mday $tmp_year ); -use Time::Local; -use FS::cdr qw(_cdr_min_parser_maker); - -@ISA = qw(FS::cdr); +use vars qw( %info $tmp_mon $tmp_mday $tmp_year ); +use FS::Record qw( qsearchs ); +use FS::cdr_type; %info = ( 'name' => 'Enswitch', @@ -23,11 +22,14 @@ use FS::cdr qw(_cdr_min_parser_maker); 'clid', #Calling name skip(1), #Called type 'dst', #Called number - skip(23), #Destination customer, Destination type + skip(5), #Destination customer, Destination type #Destination number #Destination group ID, Destination group name, - #Inbound calling type, Inbound calling number, - #Inbound called type, Inbound called number, + \&in_calling_type, #Inbound calling type, + \&in_calling_num, #Inbound calling number, + '', #Inbound called type, + \&in_called_num, #Inbound called number, + skip(14), #Inbound destination type, Inbound destination number, #Outbound calling type, Outbound calling number, #Outbound called type, Outbound called number, @@ -46,4 +48,33 @@ use FS::cdr qw(_cdr_min_parser_maker); sub skip { map {''} (1..$_[0]) } +#create CDR types with names matching in_calling_type valuesj - 'none' +# (without the quotes) for blank +our %cdr_type = (); +sub in_calling_type { + my ($record, $data) = @_; + + $data ||= 'none'; + + my $cdr_type = exists($cdr_type{$data}) + ? $cdr_type{$data} + : qsearchs('cdr_type', { 'cdrtypename' => $data } ); + + $cdr_type{$data} = $cdr_type; + + $record->set('in_calling_type', $data); #for below + $record->set('cdrtypenum', $cdr_type->cdrtypenum) if $cdr_type; + +} + +sub in_calling_num { + my ($record, $data) = @_; + $record->src($data) if ( ($record->in_calling_type || '') eq 'external' ); +} + +sub in_called_num { + my ($record, $data) = @_; + $record->dst($data) if ( ($record->in_calling_type || '') eq 'external' ); +} + 1;