+#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' );
+}
+