% include('/elements/header.html', 'Call Detail Record Search' ) %>
<% include('/elements/footer.html') %> <%init> die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('List rating data'); my @fields = fields('cdr'); push @fields, 'ratename'; push @fields, map "cdr_termination.$_", qw( rated_price rated_seconds rated_minutes rated_granularity status svcnum ); my $labels = FS::cdr->table_info->{'fields'}; $labels->{ratename} = 'Rate plan'; $labels->{'cdr_termination.rated_price'} = 'Termination rated price'; $labels->{'cdr_termination.rated_seconds'} = 'Termination rated seconds'; $labels->{'cdr_termination.rated_minutes'} = 'Termination rated minutes'; $labels->{'cdr_termination.rated_granularity'} = 'Termination rated granularity'; $labels->{'cdr_termination.status'} = 'Termination status'; $labels->{'cdr_termination.svcnum'} = 'Termination service'; my $conf = new FS::Conf; my $default_phone_countrycode = $conf->config('default_phone_countrycode') || '1'; #XXX config my @show_default = qw( calldate clid src dst dcontext charged_party startdate answerdate enddate duration billsec disposition amaflags accountcode userfield rated_price upstream_price carrierid svcnum freesidestatus freesiderewritestatus ); my %show_default = map { $_=>1 } @show_default; my $names_list = [ map { [ $_ => { 'label' => 'Show '. ( $labels->{$_} || $_ ) } ] } @fields ]; my @charged_party = (); my @charged_party_or_src = (); my @svcnum = (); if ( $cgi->param('custnum') =~ /^(\d+)$/ ) { my $custnum = $1; my $cust_main = qsearchs( { 'table' => 'cust_main', 'hashref' => { 'custnum' => $custnum }, 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql, }); die "Customer not found!" unless $cust_main; #historical packages? It would help, it was still usage, it happened foreach my $cust_pkg ( $cust_main->ncancelled_pkgs ) { my @voip_pkgs = grep { $_->plan eq 'voip_cdr' } $cust_pkg->part_pkg->self_and_bill_linked; if ( scalar(@voip_pkgs) > 1 ) { die "multiple voip_cdr packages bundled\n"; } elsif ( !@voip_pkgs ) { next; } my $voip_pkg = @voip_pkgs[0]; my $cdr_svc_method = $voip_pkg->option('cdr_svc_method') || 'svc_phone.phonenum'; my @cust_svc = $cust_pkg->cust_svc; #historical? if ( $cdr_svc_method eq 'svc_phone.phonenum' ) { my @svc_phone = map $_->svc_x, grep { $_->part_svc->svcdb eq 'svc_phone' } @cust_svc; my @numbers = map { my $number = $_->phonenum; $number = $_->countrycode. $number unless $_->countrycode eq $default_phone_countrycode; $number; } @svc_phone; if ( $voip_pkg->option('disable_src') ) { push @charged_party, @numbers; } else { push @charged_party_or_src, @numbers; } } elsif ( $cdr_svc_method eq 'svc_pbx.title' ) { my @svc_pbx = map $_->svc_x, grep { $_->part_svc->svcdb eq 'svc_pbx' } @cust_svc; push @charged_party, map $_->title, @svc_pbx; } elsif ( $cdr_svc_method eq 'svc_pbx.svcnum' ) { my @cust_svc_pbx = grep { $_->part_svc->svcdb eq 'svc_pbx' } @cust_svc; push @svcnum, map $_->svcnum, @cust_svc_pbx; } } die "No CDR packages for customer $custnum\n" unless @charged_party || @charged_party_or_src || @svcnum; #die "Multiple matching metods for customer $custnum\n" # if #there's more than one } %init>