diff options
author | ivan <ivan> | 2010-10-25 00:28:41 +0000 |
---|---|---|
committer | ivan <ivan> | 2010-10-25 00:28:41 +0000 |
commit | 140b381af1008dad929b4d3b87aa1e54747d534f (patch) | |
tree | 215b8d02498696e13021809f62a4714117a0f5d2 /httemplate/view | |
parent | f8f2e2063d597045cbbe16b2f7f8b973f1dde77d (diff) |
svc_pbx and whole-customer links to CDRs, RT#10315
Diffstat (limited to 'httemplate/view')
-rwxr-xr-x | httemplate/view/cust_main/packages.html | 4 | ||||
-rw-r--r-- | httemplate/view/svc_pbx.cgi | 72 |
2 files changed, 75 insertions, 1 deletions
diff --git a/httemplate/view/cust_main/packages.html b/httemplate/view/cust_main/packages.html index 811ac3c98..f0f156bf8 100755 --- a/httemplate/view/cust_main/packages.html +++ b/httemplate/view/cust_main/packages.html @@ -57,7 +57,9 @@ Current packages <TD ALIGN="right"> <A HREF="<%$p%>search/report_cust_pkg.html?custnum=<% $cust_main->custnum %>">Package reports</A><BR> Service reports: - <A HREF="<%$p%>search/report_svc_acct.html?custnum=<% $cust_main->custnum %>">accounts</A> + <A HREF="<%$p%>search/report_svc_acct.html?custnum=<% $cust_main->custnum %>">accounts</A><BR> + Usage reports: + <A HREF="<%$p%>search/report_cdr.html?custnum=<% $cust_main->custnum %>">CDRs</A> </TD> </TR> diff --git a/httemplate/view/svc_pbx.cgi b/httemplate/view/svc_pbx.cgi new file mode 100644 index 000000000..79cafed4d --- /dev/null +++ b/httemplate/view/svc_pbx.cgi @@ -0,0 +1,72 @@ +<% include('elements/svc_Common.html', + 'table' => 'svc_pbx', + 'edit_url' => $p."edit/svc_Common.html?svcdb=svc_pbx;svcnum=", + 'labels' => \%labels, + 'html_foot' => $html_foot, + ) +%> +<%init> + +my $fields = FS::svc_pbx->table_info->{'fields'}; +my %labels = map { $_ => ( ref($fields->{$_}) + ? $fields->{$_}{'label'} + : $fields->{$_} + ); + } + keys %$fields; + +my $html_foot = sub { + my $svc_pbx = shift; + + ## + # CDR links + ## + + tie my %what, 'Tie::IxHash', + 'pending' => 'NULL', + 'billed' => 'done', + ; + + #matching as per package def cdr_svc_method + my $cust_pkg = $svc_pbx->cust_svc->cust_pkg; + return '' unless $cust_pkg; + + my @voip_pkgs = + grep { $_->plan eq 'voip_cdr' } $cust_pkg->part_pkg->self_and_bill_linked; + if ( scalar(@voip_pkgs) > 1 ) { + warn "multiple voip_cdr packages bundled\n"; + return ''; + } elsif ( !@voip_pkgs ) { + warn "no voip_cdr packages\n"; + } + my $voip_pkg = @voip_pkgs[0]; + + my $cdr_svc_method = $voip_pkg->option('cdr_svc_method') + || 'svc_phone.phonenum'; + return '' unless $cdr_svc_method =~ /^svc_pbx\.(\w+)$/; + my $field = $1; + + my $search; + if ( $field eq 'title' ) { + $search = 'charged_party='. uri_escape($svc_pbx->title); + } elsif ( $field eq 'svcnum' ) { + $search = 'svcnum='. $svc_pbx->svcnum; + } else { + warn "unknown cdr_svc_method svc_pbx.$field"; + return ''; + } + + my @links = map { + qq(<A HREF="${p}search/cdr.html?cdrbatchnum=__ALL__;$search;freesidestatus=$what{$_}">). + "View $_ CDRs</A>"; + } keys(%what); + + ### + # concatenate & return + ### + + join(' | ', @links ). '<BR>'; + +}; + +</%init> |