X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fsearch%2Freport_cdr.html;h=e3418a7d44fd3a70bb0254eb8727c023e2cc915b;hp=1c191506fa8a150aa8e9974fe979ac74d518fa25;hb=5b73387992a96f7b80e40b5ecb2fedabd8a78d6b;hpb=12eecccdb5cc0b5e5f4f0122cade7e01f96d1de5 diff --git a/httemplate/search/report_cdr.html b/httemplate/search/report_cdr.html index 1c191506f..e3418a7d4 100644 --- a/httemplate/search/report_cdr.html +++ b/httemplate/search/report_cdr.html @@ -1,19 +1,63 @@ <% include('/elements/header.html', 'Call Detail Record Search' ) %> + +
+ + + + + +% #if ( ) { # disable for everyone not using termination billing... +% foreach my $termpart ( 1..1 ) { #qsearch('part_termination + + + + + + +% } +% #} + + <% include('/elements/tr-select-table.html', + field => 'cdrtypenum', + label => 'CDR Type', + table => 'cdr_type', + name_col => 'cdrtypename', + disable_empty => 1, + pre_options => [ '', 'all', + 'none', 'none' ] ) + %> + <% include ( '/elements/tr-input-beginning_ending.html' ) %> @@ -30,6 +74,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + <% include( '/elements/tr-input-lessthan_greaterthan.html', 'label' => 'Duration (sec)', 'field' => 'duration', @@ -42,15 +122,151 @@ ) %> + + + + + + + + + + + + + + + + <% include( '/elements/tr-select-cdrbatch.html' ) %> + + + + + + + + + + + + + + + + + + + +
+ Search options +
Status:
Termination Status: + +
Destination Context: + +
Charged Party #: + +
Charged Party or Source #: + +
Last Application: + +
Freeside service #: + +
Top destinations
Top sources
longest calls
Acct ID (one per-line):
 
Display options
+ <% include('/elements/checkboxes.html', + 'names_list' => $names_list, + 'element_name_prefix' => 'show_', + 'checked_callback' => sub { $show_default{$_[1]} }, + # my($cgi, $name) = @_; + ) + %> +

+
+ <% include('/elements/footer.html') %> <%init> die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('List rating data'); +my @fields = fields('cdr'); +my $labels = FS::cdr->table_info->{'fields'}; + +#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? + 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 '1'; + $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 + +} +