From 0d577b3490ea577dda0fefb25ccb5800ee508a9e Mon Sep 17 00:00:00 2001 From: Andreas Granig Date: Thu, 3 Jul 2014 14:44:09 +0200 Subject: [PATCH] MT#7935 Show callid, cost and link to callmap. In call history of a subscriber, link to callmap, and show the call-id and source customer cost in case of admin/reseller. --- lib/NGCP/Panel/Controller/Callflow.pm | 15 +++++++++------ lib/NGCP/Panel/Controller/Subscriber.pm | 10 ++++++++-- lib/NGCP/Panel/Utils/GD/Simple.pm | 2 +- ngcp_panel.conf | 2 ++ share/templates/callflow/callmap.tt | 5 ++++- share/templates/subscriber/master.tt | 6 ++++++ 6 files changed, 30 insertions(+), 10 deletions(-) diff --git a/lib/NGCP/Panel/Controller/Callflow.pm b/lib/NGCP/Panel/Controller/Callflow.pm index 32a550be16..a16079da93 100644 --- a/lib/NGCP/Panel/Controller/Callflow.pm +++ b/lib/NGCP/Panel/Controller/Callflow.pm @@ -5,6 +5,7 @@ BEGIN { extends 'Catalyst::Controller'; } use NGCP::Panel::Utils::Callflow; use NGCP::Panel::Utils::Navigation; +use NGCP::Panel::Utils::Message; use HTML::Entities; @@ -111,6 +112,7 @@ sub get_png :Chained('callflow_base') :PathPart('png') :Args(0) { sub get_callmap :Chained('callflow_base') :PathPart('callmap') :Args(0) { my ($self, $c) = @_; my $cid = $c->stash->{callid}; + $c->stash->{template} = 'callflow/callmap.tt'; my $calls_rs = $c->model('DB')->resultset('messages')->search({ 'me.call_id' => { -in => [ $cid, $cid.'_b2b-1', $cid.'_pbx-1' ] }, @@ -119,12 +121,13 @@ sub get_callmap :Chained('callflow_base') :PathPart('callmap') :Args(0) { }); my $calls = [ $calls_rs->all ]; - my $map = NGCP::Panel::Utils::Callflow::generate_callmap($c, $calls); - - $c->stash( - canvas => $map, - template => 'callflow/callmap.tt', - ); + unless(@{ $calls }) { + $c->log->error("No packets for call-id $cid found"); + $c->stash(messages => [{type => 'error', text => $c->loc('No packets for this Call-ID found.')}]) + } else { + my $map = NGCP::Panel::Utils::Callflow::generate_callmap($c, $calls); + $c->stash->{canvas} = $map; + } } sub get_packet :Chained('callflow_base') :PathPart('packet') :Args() { diff --git a/lib/NGCP/Panel/Controller/Subscriber.pm b/lib/NGCP/Panel/Controller/Subscriber.pm index 2aa5fcb327..cc96959a01 100644 --- a/lib/NGCP/Panel/Controller/Subscriber.pm +++ b/lib/NGCP/Panel/Controller/Subscriber.pm @@ -1858,13 +1858,19 @@ sub load_preference_list :Private { sub master :Chained('base') :PathPart('details') :CaptureArgs(0) { my ($self, $c) = @_; - $c->stash->{calls_dt_columns} = NGCP::Panel::Utils::Datatables::set_columns($c, [ + my $call_cols = [ { name => "source_user", search => 1, title => $c->loc('Caller') }, { name => "destination_user", search => 1, title => $c->loc('Callee') }, { name => "call_status", search => 1, title => $c->loc('Status') }, { name => "start_time", search_from_epoch => 1, search_to_epoch => 1, title => $c->loc('Start Time') }, { name => "duration", search => 1, title => $c->loc('Duration') }, - ]); + ]; + push @{ $call_cols }, ( + { name => "call_id", search => 1, title => $c->loc('Call-ID') }, + { name => "source_customer_cost", search => 1, title => $c->loc('Source Cust Cost (cents)') }, + ) if($c->user->roles eq "admin" || $c->user->roles eq "reseller"); + $c->stash->{calls_dt_columns} = NGCP::Panel::Utils::Datatables::set_columns($c, $call_cols); + $c->stash->{vm_dt_columns} = NGCP::Panel::Utils::Datatables::set_columns($c, [ { name => "id", search => 1, title => $c->loc('#') }, { name => "callerid", search => 1, title => $c->loc('Caller') }, diff --git a/lib/NGCP/Panel/Utils/GD/Simple.pm b/lib/NGCP/Panel/Utils/GD/Simple.pm index 277ddf4e32..af84f6b942 100644 --- a/lib/NGCP/Panel/Utils/GD/Simple.pm +++ b/lib/NGCP/Panel/Utils/GD/Simple.pm @@ -178,7 +178,7 @@ sub AUTOLOAD { my($pack,$func_name) = $AUTOLOAD=~/(.+)::([^:]+)$/; return if $func_name eq 'DESTROY'; - if (ref $self && exists $self->{gd}) { + if (ref $self && defined $self->{gd}) { $self->{gd}->$func_name(@_); } else { my @result = $IMAGECLASS->$func_name(@_); diff --git a/ngcp_panel.conf b/ngcp_panel.conf index 1ab551d65a..231b5f6cdc 100644 --- a/ngcp_panel.conf +++ b/ngcp_panel.conf @@ -19,6 +19,7 @@ log4perl.appender.Default.layout.ConversionPattern=%d{ISO8601} [%p] [%F +%L] %m{ + callflow 1 multidomain 1 faxserver 1 @@ -93,6 +94,7 @@ log4perl.appender.Default.layout.ConversionPattern=%d{ISO8601} [%p] [%F +%L] %m{ proxy 127.0.0.1:5062 sbc 127.0.0.1:5080 app 127.0.0.1:5070 + pbx 127.0.0.1:5085 diff --git a/share/templates/callflow/callmap.tt b/share/templates/callflow/callmap.tt index b8d2a9d563..db4a07bf2f 100644 --- a/share/templates/callflow/callmap.tt +++ b/share/templates/callflow/callmap.tt @@ -13,7 +13,9 @@
[% c.loc('Back') %] + [% IF canvas -%] [% c.loc('Download PCAP') %] + [% END -%]
[% back_created = 1 -%] @@ -25,7 +27,7 @@
- +[% IF canvas -%] @@ -33,5 +35,6 @@ [% END -%] +[% END -%] [% # vim: set tabstop=4 syntax=html expandtab: -%] diff --git a/share/templates/subscriber/master.tt b/share/templates/subscriber/master.tt index da477ba50a..964b749471 100644 --- a/share/templates/subscriber/master.tt +++ b/share/templates/subscriber/master.tt @@ -178,6 +178,12 @@ helper.form_object = form; helper.ajax_uri = c.uri_for_action('/subscriber/ajax_calls', [c.req.captures.0]); + IF (c.user.roles == "admin" || c.user.roles == "reseller") && c.config.features.callflow; + helper.dt_buttons = [ + { name = c.loc('Call Flow'), uri = "/callflow/'+encodeURIComponent(full.call_id)+'/callmap", class = 'btn-small btn-primary', icon = 'icon-random' }, + ]; + END; + PROCESS 'helpers/datatables.tt'; %]