2012-06-04 16:58:40 +02:00
< ? php
/*
FusionPBX
Version : MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 ( the " License " ); you may not use this file except in compliance with
the License . You may obtain a copy of the License at
http :// www . mozilla . org / MPL /
Software distributed under the License is distributed on an " AS IS " basis ,
WITHOUT WARRANTY OF ANY KIND , either express or implied . See the License
for the specific language governing rights and limitations under the
License .
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane < markjcrane @ fusionpbx . com >
2017-12-09 20:27:27 +01:00
Portions created by the Initial Developer are Copyright ( C ) 2008 - 2017
2012-06-04 16:58:40 +02:00
the Initial Developer . All Rights Reserved .
Contributor ( s ) :
Mark J Crane < markjcrane @ fusionpbx . com >
2014-06-22 20:24:32 +02:00
Luis Daniel Lucio Quiroz < dlucio @ okay . com . mx >
2012-06-04 16:58:40 +02:00
*/
2016-07-27 04:51:50 +02:00
//includes
require_once " root.php " ;
require_once " resources/require.php " ;
require_once " resources/check_auth.php " ;
//check permisions
if ( permission_exists ( 'xml_cdr_view' )) {
//access granted
}
else {
echo " access denied " ;
exit ;
}
2012-06-04 16:58:40 +02:00
2012-10-24 09:35:01 +02:00
//add multi-lingual support
2015-01-18 11:04:43 +01:00
$language = new text ;
$text = $language -> get ();
2012-10-06 20:02:17 +02:00
2012-06-04 16:58:40 +02:00
//additional includes
2013-07-06 08:29:50 +02:00
require_once " resources/header.php " ;
require_once " resources/paging.php " ;
2012-07-11 04:23:05 +02:00
2012-06-04 16:58:40 +02:00
//xml cdr include
2016-03-29 07:02:11 +02:00
$rows_per_page = ( $_SESSION [ 'domain' ][ 'paging' ][ 'numeric' ] != '' ) ? $_SESSION [ 'domain' ][ 'paging' ][ 'numeric' ] : 50 ;
2012-06-04 16:58:40 +02:00
require_once " xml_cdr_inc.php " ;
2012-08-29 23:31:31 +02:00
//javascript function: send_cmd
echo " <script type= \" text/javascript \" > \n " ;
echo " function send_cmd(url) { \n " ;
2014-09-09 11:15:32 +02:00
echo " if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari \n " ;
2012-08-29 23:31:31 +02:00
echo " xmlhttp=new XMLHttpRequest(); \n " ;
echo " } \n " ;
echo " else { // code for IE6, IE5 \n " ;
echo " xmlhttp=new ActiveXObject( \" Microsoft.XMLHTTP \" ); \n " ;
echo " } \n " ;
echo " xmlhttp.open( \" GET \" ,url,true); \n " ;
echo " xmlhttp.send(null); \n " ;
echo " document.getElementById('cmd_reponse').innerHTML=xmlhttp.responseText; \n " ;
echo " } \n " ;
echo " </script> \n " ;
2014-12-06 11:30:44 +01:00
//javascript to toggle export select box
echo " <script language='javascript' type='text/javascript'> " ;
echo " var fade_speed = 400; " ;
echo " function toggle_select(select_id) { " ;
echo " $ ('#'+select_id).fadeToggle(fade_speed, function() { " ;
echo " document.getElementById(select_id).selectedIndex = 0; " ;
echo " }); " ;
echo " } " ;
echo " </script> " ;
2012-06-04 16:58:40 +02:00
//page title and description
echo " <table width='100%' border='0' cellpadding='0' cellspacing='0'> \n " ;
echo " <tr> \n " ;
2015-04-03 23:07:24 +02:00
echo " <td align='left' nowrap='nowrap' style='vertical-align: top;'><b> " . $text [ 'title' ] . " </b><br><br><br></td> \n " ;
2014-06-16 20:12:21 +02:00
echo " <td align='right' width='100%' style='vertical-align: top;'> \n " ;
2015-02-20 00:28:40 +01:00
echo " <form id='frm_export' method='post' action='xml_cdr_export.php'> \n " ;
2016-03-11 00:29:47 +01:00
echo " <input type='hidden' name='cdr_id' value=' " . $cdr_id . " '> \n " ;
echo " <input type='hidden' name='direction' value=' " . $direction . " '> \n " ;
echo " <input type='hidden' name='caller_id_name' value=' " . $caller_id_name . " '> \n " ;
echo " <input type='hidden' name='start_stamp_begin' value=' " . $start_stamp_begin . " '> \n " ;
echo " <input type='hidden' name='start_stamp_end' value=' " . $start_stamp_end . " '> \n " ;
echo " <input type='hidden' name='hangup_cause' value=' " . $hangup_cause . " '> \n " ;
echo " <input type='hidden' name='call_result' value=' " . $call_result . " '> \n " ;
echo " <input type='hidden' name='caller_extension_uuid' value=' " . $caller_extension_uuid . " '> \n " ;
echo " <input type='hidden' name='caller_id_number' value=' " . $caller_id_number . " '> \n " ;
2017-05-29 23:15:31 +02:00
echo " <input type='hidden' name='caller_destination' value=' " . $caller_destination . " '> \n " ;
2016-03-11 00:29:47 +01:00
echo " <input type='hidden' name='destination_number' value=' " . $destination_number . " '> \n " ;
echo " <input type='hidden' name='context' value=' " . $context . " '> \n " ;
echo " <input type='hidden' name='answer_stamp_begin' value=' " . $answer_stamp_begin . " '> \n " ;
echo " <input type='hidden' name='answer_stamp_end' value=' " . $answer_stamp_end . " '> \n " ;
echo " <input type='hidden' name='end_stamp_begin' value=' " . $end_stamp_begin . " '> \n " ;
echo " <input type='hidden' name='end_stamp_end' value=' " . $end_stamp_end . " '> \n " ;
echo " <input type='hidden' name='start_epoch' value=' " . $start_epoch . " '> \n " ;
echo " <input type='hidden' name='stop_epoch' value=' " . $stop_epoch . " '> \n " ;
echo " <input type='hidden' name='duration' value=' " . $duration . " '> \n " ;
echo " <input type='hidden' name='billsec' value=' " . $billsec . " '> \n " ;
echo " <input type='hidden' name='uuid' value=' " . $uuid . " '> \n " ;
echo " <input type='hidden' name='bleg_uuid' value=' " . $bleg_uuid . " '> \n " ;
echo " <input type='hidden' name='accountcode' value=' " . $accountcode . " '> \n " ;
echo " <input type='hidden' name='read_codec' value=' " . $read_codec . " '> \n " ;
echo " <input type='hidden' name='write_codec' value=' " . $write_codec . " '> \n " ;
echo " <input type='hidden' name='remote_media_ip' value=' " . $remote_media_ip . " '> \n " ;
echo " <input type='hidden' name='network_addr' value=' " . $network_addr . " '> \n " ;
echo " <input type='hidden' name='bridge_uuid' value=' " . $bridge_uuid . " '> \n " ;
2017-06-03 06:31:20 +02:00
echo " <input type='hidden' name='leg' value=' " . $leg . " '> \n " ;
2016-12-23 05:19:35 +01:00
if ( is_array ( $_SESSION [ 'cdr' ][ 'field' ])) {
foreach ( $_SESSION [ 'cdr' ][ 'field' ] as $field ) {
2017-01-05 06:25:17 +01:00
$array = explode ( " , " , $field );
$field_name = $array [ count ( $array ) - 1 ];
if ( isset ( $_REQUEST [ $field_name ])) {
2016-12-23 05:19:35 +01:00
echo " <input type='hidden' name=' $field_name ' value=' " . $$field_name . " '> \n " ;
}
2016-12-22 00:58:21 +01:00
}
}
2015-02-20 00:28:40 +01:00
if ( isset ( $order_by )) {
2016-03-11 00:29:47 +01:00
echo " <input type='hidden' name='order_by' value=' " . $order_by . " '> \n " ;
echo " <input type='hidden' name='order' value=' " . $order . " '> \n " ;
2015-02-20 00:28:40 +01:00
}
2017-12-09 20:27:27 +01:00
if ( permission_exists ( 'xml_cdr_all' ) && $_REQUEST [ 'show' ] == 'all' ) {
echo " <input type='hidden' name='show' value='all'> \n " ;
2016-02-24 02:09:00 +01:00
}
2014-12-06 11:30:44 +01:00
echo " <table cellpadding='0' cellspacing='0' border='0'> \n " ;
echo " <tr> \n " ;
echo " <td style='vertical-align: top;'> \n " ;
2015-03-06 18:15:09 +01:00
if ( permission_exists ( 'xml_cdr_all' )) {
2017-12-09 20:27:27 +01:00
if ( $_REQUEST [ 'show' ] != 'alll' ) {
echo " <input type='button' class='btn' value=' " . $text [ 'button-show_all' ] . " ' onclick= \" window.location='xml_cdr.php?show=all'; \" > \n " ;
2015-03-31 05:16:20 +02:00
}
2015-03-06 18:15:09 +01:00
}
2014-12-06 11:30:44 +01:00
if ( permission_exists ( 'xml_cdr_search_advanced' )) {
2017-12-09 20:27:27 +01:00
if ( $_REQUEST [ 'show' ] == 'all' ) {
$query_string = " show=all " ;
2016-02-24 01:53:21 +01:00
}
echo " <input type='button' class='btn' value=' " . $text [ 'button-advanced_search' ] . " ' onclick= \" window.location='xml_cdr_search.php? $query_string '; \" > \n " ;
2014-12-06 11:30:44 +01:00
}
2016-03-11 00:29:47 +01:00
if ( $_GET [ 'call_result' ] != 'missed' ) {
echo " <input type='button' class='btn' value=' " . $text [ 'button-missed' ] . " ' onclick= \" document.location.href='xml_cdr.php?call_result=missed'; \" > \n " ;
2015-04-01 11:06:02 +02:00
}
2014-12-06 11:30:44 +01:00
echo " <input type='button' class='btn' value=' " . $text [ 'button-statistics' ] . " ' onclick= \" document.location.href='xml_cdr_statistics.php'; \" > \n " ;
2018-04-23 21:24:30 +02:00
if ( permission_exists ( 'xml_cdr_archive' )) {
if ( $_REQUEST [ 'show' ] == 'all' ) {
$query_string = " show=all " ;
}
echo " <input type='button' class='btn' value=' " . $text [ 'button-archive' ] . " ' onclick= \" window.location='xml_cdr_archive.php? $query_string '; \" > \n " ;
}
2014-12-06 11:30:44 +01:00
echo " <input type='button' class='btn' value=' " . $text [ 'button-export' ] . " ' onclick= \" toggle_select('export_format'); \" > \n " ;
2017-04-25 09:01:40 +02:00
echo " <input type='button' class='btn' value=' " . $text [ 'button-refresh' ] . " ' onclick= \" document.location.href='xml_cdr.php'; \" /> \n " ;
2014-12-06 11:30:44 +01:00
echo " </td> " ;
echo " <td style='vertical-align: top;'> " ;
echo " <select class='formfld' style='display: none; width: auto; margin-left: 3px;' name='export_format' id='export_format' onchange= \" display_message(' " . $text [ 'message-preparing_download' ] . " '); toggle_select('export_format'); document.getElementById('frm_export').submit(); \" > \n " ;
echo " <option value=''>...</option> \n " ;
echo " <option value='csv'>CSV</option> \n " ;
echo " <option value='pdf'>PDF</option> \n " ;
echo " </select> \n " ;
echo " </td> \n " ;
2018-05-01 11:02:36 +02:00
echo " <td style='vertical-align: top; padding-left: 15px;'> " . $paging_controls_mini . " </td> \n " ;
2014-12-06 11:30:44 +01:00
echo " </tr> \n " ;
echo " </table> \n " ;
2012-06-04 16:58:40 +02:00
echo " </form> \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
echo " <tr> \n " ;
echo " <td align='left' colspan='2'> \n " ;
2016-03-11 00:29:47 +01:00
echo $text [ 'description' ] . " \n " ;
echo $text [ 'description2' ] . " \n " ;
echo $text [ 'description-3' ] . " \n " ;
echo $text [ 'description-4' ] . " \n " ;
2012-06-04 16:58:40 +02:00
2016-03-11 00:29:47 +01:00
echo " <br /><br /> \n " ;
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
echo " </table> \n " ;
2014-06-17 00:08:30 +02:00
//basic search of call detail records
if ( permission_exists ( 'xml_cdr_search' )) {
2014-06-16 20:12:21 +02:00
2015-02-20 00:28:40 +01:00
echo " <form method='get' action=''> \n " ;
2014-06-16 20:12:21 +02:00
echo " <table width='100%' border='0' cellpadding='0' cellspacing='0'> \n " ;
2012-06-04 16:58:40 +02:00
echo " <tr> \n " ;
2016-03-11 00:29:47 +01:00
echo " <td width=' " . (( if_group ( " admin " ) || if_group ( " superadmin " ) || if_group ( " cdr " )) ? '19%' : '30%' ) . " ' style='vertical-align: top;'> \n " ;
2014-06-16 20:12:21 +02:00
2015-02-15 08:59:02 +01:00
echo " <table width='100%' border='0' cellpadding='0' cellspacing='0'> \n " ;
2012-06-04 16:58:40 +02:00
echo " <tr> \n " ;
2016-03-11 00:29:47 +01:00
echo " <td class='vncell' valign='top' nowrap='nowrap'> \n " ;
2014-06-16 20:12:21 +02:00
echo " " . $text [ 'label-direction' ] . " \n " ;
echo " </td> \n " ;
2016-03-11 00:29:47 +01:00
echo " <td class='vtable' align='left'> \n " ;
2014-06-16 20:12:21 +02:00
echo " <select name='direction' class='formfld'> \n " ;
echo " <option value=''></option> \n " ;
2016-03-11 00:29:47 +01:00
echo " <option value='inbound' " . (( $direction == " inbound " ) ? " selected='selected' " : null ) . " > " . $text [ 'label-inbound' ] . " </option> \n " ;
echo " <option value='outbound' " . (( $direction == " outbound " ) ? " selected='selected' " : null ) . " > " . $text [ 'label-outbound' ] . " </option> \n " ;
echo " <option value='local' " . (( $direction == " local " ) ? " selected='selected' " : null ) . " > " . $text [ 'label-local' ] . " </option> \n " ;
2012-06-04 16:58:40 +02:00
echo " </select> \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
echo " <tr> \n " ;
2016-03-11 00:29:47 +01:00
echo " <td class='vncell' valign='top' nowrap='nowrap'> \n " ;
2014-06-16 20:12:21 +02:00
echo " " . $text [ 'label-status' ] . " \n " ;
echo " </td> \n " ;
2016-03-11 00:29:47 +01:00
echo " <td class='vtable' align='left'> \n " ;
echo " <select name='call_result' class='formfld'> \n " ;
2014-06-17 00:08:30 +02:00
echo " <option value=''></option> \n " ;
2016-03-11 00:29:47 +01:00
echo " <option value='answered' " . (( $call_result == 'answered' ) ? 'selected' : null ) . " > " . $text [ 'label-answered' ] . " </option> \n " ;
echo " <option value='missed' " . (( $call_result == 'missed' ) ? 'selected' : null ) . " > " . $text [ 'label-missed' ] . " </option> \n " ;
echo " <option value='voicemail' " . (( $call_result == 'voicemail' ) ? 'selected' : null ) . " > " . $text [ 'label-voicemail' ] . " </option> \n " ;
echo " <option value='cancelled' " . (( $call_result == 'cancelled' ) ? 'selected' : null ) . " > " . $text [ 'label-cancelled' ] . " </option> \n " ;
echo " <option value='failed' " . (( $call_result == 'failed' ) ? 'selected' : null ) . " > " . $text [ 'label-failed' ] . " </option> \n " ;
2014-06-16 20:12:21 +02:00
echo " </select> \n " ;
echo " </td> \n " ;
2012-06-04 16:58:40 +02:00
echo " </tr> \n " ;
echo " </table> \n " ;
2014-06-16 20:12:21 +02:00
echo " </td> " ;
2016-03-11 00:29:47 +01:00
echo " <td width=' " . (( if_group ( " admin " ) || if_group ( " superadmin " ) || if_group ( " cdr " )) ? '24%' : '30%' ) . " ' style='vertical-align: top;'> \n " ;
2012-06-04 16:58:40 +02:00
2015-02-15 08:59:02 +01:00
echo " <table width='100%' border='0' cellpadding='0' cellspacing='0'> \n " ;
2012-06-04 16:58:40 +02:00
echo " <tr> \n " ;
2016-03-11 00:29:47 +01:00
echo " <td class='vncell' valign='top' nowrap='nowrap'> \n " ;
2018-05-04 16:31:45 +02:00
echo " " . $text [ 'label-caller_id_number' ] . " \n " ;
2014-06-16 20:12:21 +02:00
echo " </td> \n " ;
2016-03-11 00:29:47 +01:00
echo " <td class='vtable' align='left' style='white-space: nowrap;'> \n " ;
2014-08-03 06:03:44 +02:00
echo " <input type='text' class='formfld' style=' " . $style [ 'caller_id_number' ] . " ' name='caller_id_number' id='caller_id_number' value=' " . $caller_id_number . " '> \n " ;
2014-06-16 20:12:21 +02:00
echo " </td> \n " ;
2012-06-04 16:58:40 +02:00
echo " </tr> \n " ;
echo " <tr> \n " ;
2016-03-11 00:29:47 +01:00
echo " <td class='vncell' valign='top' nowrap='nowrap'> \n " ;
2014-06-16 20:12:21 +02:00
echo " " . $text [ 'label-destination' ] . " \n " ;
echo " </td> \n " ;
2016-03-11 00:29:47 +01:00
echo " <td class='vtable' align='left' style='white-space: nowrap;'> \n " ;
2014-08-03 06:03:44 +02:00
echo " <input type='text' class='formfld' name='destination_number' id='destination_number' value=' " . $destination_number . " '> \n " ;
2014-06-16 20:12:21 +02:00
echo " </td> \n " ;
2012-06-04 16:58:40 +02:00
echo " </tr> \n " ;
echo " </table> \n " ;
2014-06-16 20:12:21 +02:00
echo " </td> " ;
2016-03-11 00:29:47 +01:00
echo " <td width=' " . (( if_group ( " admin " ) || if_group ( " superadmin " ) || if_group ( " cdr " )) ? '30%' : '40%' ) . " ' style='vertical-align: top;'> \n " ;
2012-06-04 16:58:40 +02:00
2015-02-15 08:59:02 +01:00
echo " <table width='100%' border='0' cellpadding='0' cellspacing='0'> \n " ;
2012-06-04 16:58:40 +02:00
echo " <tr> \n " ;
2016-03-11 00:29:47 +01:00
echo " <td class='vncell' valign='top' nowrap='nowrap'> \n " ;
2014-08-02 12:57:02 +02:00
echo " " . $text [ 'label-start_range' ] . " \n " ;
2014-06-16 20:12:21 +02:00
echo " </td> \n " ;
2016-04-13 21:23:07 +02:00
echo " <td class='vtable' align='left' style='position: relative; min-width: 250px;'> \n " ;
echo " <input type='text' class='formfld datetimepicker' style='min-width: 115px; width: 115px;' name='start_stamp_begin' placeholder=' " . $text [ 'label-from' ] . " ' value=' $start_stamp_begin '> \n " ;
echo " <input type='text' class='formfld datetimepicker' style='min-width: 115px; width: 115px;' name='start_stamp_end' placeholder=' " . $text [ 'label-to' ] . " ' value=' $start_stamp_end '> \n " ;
2014-06-16 20:12:21 +02:00
echo " </td> \n " ;
2012-06-04 16:58:40 +02:00
echo " </tr> \n " ;
echo " <tr> \n " ;
2016-03-11 00:29:47 +01:00
echo " <td class='vncell' valign='top' nowrap='nowrap'> \n " ;
2014-08-02 12:57:02 +02:00
echo " " . $text [ 'label-cid-name' ] . " \n " ;
2014-06-16 20:12:21 +02:00
echo " </td> \n " ;
2016-03-11 00:29:47 +01:00
echo " <td class='vtable' align='left'> \n " ;
2014-08-02 12:57:02 +02:00
echo " <input type='text' class='formfld' name='caller_id_name' value=' $caller_id_name '> \n " ;
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
2014-06-16 20:12:21 +02:00
echo " </table> \n " ;
2012-06-04 16:58:40 +02:00
echo " </td> " ;
2016-03-11 00:29:47 +01:00
// show hangup clause filter to super/admin
2018-03-13 17:30:45 +01:00
echo " <td width='27%' style='vertical-align: top;'> \n " ;
2016-03-11 00:29:47 +01:00
2018-03-13 17:30:45 +01:00
echo " <table width='100%' border='0' cellpadding='0' cellspacing='0'> \n " ;
echo " <tr> \n " ;
if ( permission_exists ( 'hangup_cause' )) {
2016-03-11 00:29:47 +01:00
echo " <td class='vncell' valign='top' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-hangup_cause' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
echo " <select name='hangup_cause' class='formfld'> \n " ;
echo " <option value=''></option> \n " ;
$cdr_status_options = array (
'NORMAL_CLEARING' ,
'ORIGINATOR_CANCEL' ,
'BLIND_TRANSFER' ,
'LOSE_RACE' ,
'NO_ANSWER' ,
'NORMAL_UNSPECIFIED' ,
'NO_USER_RESPONSE' ,
'NO_ROUTE_DESTINATION' ,
'SUBSCRIBER_ABSENT' ,
'NORMAL_TEMPORARY_FAILURE' ,
'ATTENDED_TRANSFER' ,
'PICKED_OFF' ,
'USER_BUSY' ,
'CALL_REJECTED' ,
'INVALID_NUMBER_FORMAT' ,
'NETWORK_OUT_OF_ORDER' ,
'DESTINATION_OUT_OF_ORDER' ,
'RECOVERY_ON_TIMER_EXPIRE' ,
'MANAGER_REQUEST' ,
'MEDIA_TIMEOUT' ,
'UNALLOCATED_NUMBER' ,
'NONE' ,
'EXCHANGE_ROUTING_ERROR' ,
'ALLOTTED_TIMEOUT' ,
'CHAN_NOT_IMPLEMENTED' ,
'INCOMPATIBLE_DESTINATION' ,
'USER_NOT_REGISTERED' ,
'SYSTEM_SHUTDOWN' ,
'MANDATORY_IE_MISSING'
);
sort ( $cdr_status_options );
foreach ( $cdr_status_options as $cdr_status ) {
$selected = ( $hangup_cause == $cdr_status ) ? " selected='selected' " : null ;
$cdr_status_label = ucwords ( strtolower ( str_replace ( " _ " , " " , $cdr_status )));
echo " <option value=' " . $cdr_status . " ' " . $selected . " > " . $cdr_status_label . " </option> \n " ;
}
echo " </select> \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
2018-03-13 17:30:45 +01:00
}
if ( permission_exists ( 'caller_destination' )) {
2017-05-29 19:23:36 +02:00
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' nowrap='nowrap'> \n " ;
2017-06-14 00:34:18 +02:00
echo " " . $text [ 'label-caller_destination' ] . " \n " ;
2017-05-29 19:23:36 +02:00
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2017-05-29 23:15:31 +02:00
echo " <input type='text' class='formfld' name='caller_destination' value=' $caller_destination '> \n " ;
2017-05-29 19:23:36 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
2018-03-13 17:30:45 +01:00
}
echo " </table> \n " ;
2016-03-11 00:29:47 +01:00
2018-03-13 17:30:45 +01:00
echo " </td> " ;
2016-03-11 00:29:47 +01:00
2012-06-04 16:58:40 +02:00
echo " </tr> " ;
2016-03-11 00:29:47 +01:00
echo " </table> " ;
echo " <table width='100%' border='0' cellpadding='0' cellspacing='0'> \n " ;
2014-06-16 20:12:21 +02:00
echo " <tr> " ;
2016-03-11 00:29:47 +01:00
echo " <td style='padding-top: 8px;' align='left'> " ;
2014-06-24 02:37:17 +02:00
echo $text [ 'description_search' ];
echo " </td> " ;
2016-03-11 00:29:47 +01:00
echo " <td style='padding-top: 8px;' align='right' nowrap> " ;
2017-12-09 20:27:27 +01:00
if ( permission_exists ( 'xml_cdr_all' ) && $_REQUEST [ 'show' ] == 'all' ) {
echo " <input type='hidden' name='show' value='all'> \n " ;
2016-02-24 03:19:03 +01:00
}
echo " <input type='button' class='btn' value=' " . $text [ 'button-reset' ] . " ' onclick= \" document.location.href='xml_cdr.php'; \" > \n " ;
echo " <input type='submit' class='btn' name='submit' value=' " . $text [ 'button-search' ] . " '> \n " ;
2014-06-16 20:12:21 +02:00
echo " </td> " ;
2012-06-04 16:58:40 +02:00
echo " </tr> " ;
echo " </table> " ;
2014-06-16 20:12:21 +02:00
2012-06-04 16:58:40 +02:00
echo " </form> " ;
2014-06-16 20:12:21 +02:00
echo " <br /><br /> " ;
2012-06-04 16:58:40 +02:00
}
2015-02-20 00:28:40 +01:00
//mod paging parameters for inclusion in column sort heading links
$param = substr ( $param , 1 ); //remove leading '&'
$param = substr ( $param , 0 , strrpos ( $param , '&order_by=' )); //remove trailing order by
2012-06-04 16:58:40 +02:00
//show the results
2015-04-14 00:26:50 +02:00
$col_count = 8 ;
2015-02-20 00:28:40 +01:00
echo " <form name='frm' method='post' action='xml_cdr_delete.php'> \n " ;
2015-04-14 00:26:50 +02:00
echo " <table class='tr_hover' width='100%' cellpadding='0' cellspacing='0' border='0'> \n " ;
2012-06-04 16:58:40 +02:00
echo " <tr> \n " ;
2015-04-03 23:07:24 +02:00
if ( permission_exists ( 'xml_cdr_delete' ) && $result_count > 0 ) {
2016-03-17 01:48:42 +01:00
echo " <th style='width: 30px; text-align: center; padding: 0px;'><input type='checkbox' id='chk_all' onchange= \" (this.checked) ? check('all') : check('none'); \" ></th> " ;
2015-04-14 00:26:50 +02:00
$col_count ++ ;
2015-02-20 00:28:40 +01:00
}
2016-03-11 00:29:47 +01:00
//column headings
echo " <th> </th> \n " ;
2017-12-09 20:27:27 +01:00
if ( $_REQUEST [ 'show' ] == " all " && permission_exists ( 'xml_cdr_all' )) {
2016-03-11 00:29:47 +01:00
echo th_order_by ( 'domain_name' , $text [ 'label-domain' ], $order_by , $order , null , null , $param );
$col_count ++ ;
2015-02-20 00:28:40 +01:00
}
2018-05-04 16:31:45 +02:00
echo th_order_by ( 'caller_id_name' , $text [ 'label-caller_id_name' ], $order_by , $order , null , null , $param );
echo th_order_by ( 'caller_id_number' , $text [ 'label-caller_id_number' ], $order_by , $order , null , null , $param );
2018-03-13 17:45:09 +01:00
if ( permission_exists ( 'caller_destination' )) {
echo th_order_by ( 'caller_destination' , $text [ 'label-caller_destination' ], $order_by , $order , null , null , $param );
}
2016-03-11 00:29:47 +01:00
echo th_order_by ( 'destination_number' , $text [ 'label-destination' ], $order_by , $order , null , null , $param );
if ( permission_exists ( 'recording_play' ) || permission_exists ( 'recording_download' )) {
echo " <th> " . $text [ 'label-recording' ] . " </th> \n " ;
$col_count ++ ;
}
2016-12-22 00:58:21 +01:00
if ( is_array ( $_SESSION [ 'cdr' ][ 'field' ])) {
foreach ( $_SESSION [ 'cdr' ][ 'field' ] as $field ) {
2016-12-23 01:03:05 +01:00
$array = explode ( " , " , $field );
$field_name = $array [ count ( $array ) - 1 ];
$field_label = ucwords ( str_replace ( " _ " , " " , $field_name ));
$field_label = str_replace ( " Sip " , " SIP " , $field_label );
if ( $field_name != " destination_number " ) {
echo th_order_by ( $field_name , $field_label , $order_by , $order , null , " style='text-align: right;' " , $param );
}
2016-12-22 00:58:21 +01:00
}
}
2016-03-11 00:29:47 +01:00
echo th_order_by ( 'start_stamp' , $text [ 'label-start' ], $order_by , $order , null , " style='text-align: center;' " , $param );
2017-05-13 22:14:03 +02:00
echo th_order_by ( 'tta' , $text [ 'label-tta' ], $order_by , $order , null , " style='text-align: right;' " , $param , $text [ 'description-tta' ]);
2016-03-11 00:29:47 +01:00
echo th_order_by ( 'duration' , $text [ 'label-duration' ], $order_by , $order , null , " style='text-align: center;' " , $param );
if ( file_exists ( $_SERVER [ " PROJECT_ROOT " ] . " /app/billing/app_config.php " )){
echo " <th> " . $text [ 'label-price' ] . " </th> \n " ;
$col_count ++ ;
}
if ( permission_exists ( 'xml_cdr_pdd' )) {
2017-05-13 22:14:03 +02:00
echo th_order_by ( 'pdd_ms' , $text [ 'label-pdd' ], $order_by , $order , null , " style='text-align: right;' " , $param , $text [ 'description-pdd' ]);
2016-03-11 00:29:47 +01:00
$col_count ++ ;
}
if ( permission_exists ( 'xml_cdr_mos' )) {
2017-05-13 22:14:03 +02:00
echo th_order_by ( 'rtp_audio_in_mos' , $text [ 'label-mos' ], $order_by , $order , null , " style='text-align: center;' " , $param , $text [ 'description-mos' ]);
2016-03-11 00:29:47 +01:00
$col_count ++ ;
}
2018-03-13 17:45:09 +01:00
if ( permission_exists ( 'hangup_cause' )) {
2016-03-11 00:29:47 +01:00
echo th_order_by ( 'hangup_cause' , $text [ 'label-hangup_cause' ], $order_by , $order , null , null , $param );
}
else {
echo " <th> " . $text [ 'label-status' ] . " </th> \n " ;
}
if ( if_group ( " admin " ) || if_group ( " superadmin " ) || if_group ( " cdr " )) {
echo " <td class='list_control_icon'> " ;
if ( permission_exists ( 'xml_cdr_delete' ) && $result_count > 0 ) {
echo " <a href='javascript:void(0);' onclick= \" if (confirm(' " . $text [ 'confirm-delete' ] . " ')) { document.forms.frm.submit(); } \" alt=' " . $text [ 'button-delete' ] . " '> " . $v_link_label_delete . " </a> " ;
}
echo " </td> \n " ;
$col_count ++ ;
}
echo " </tr> \n " ;
2016-01-17 08:01:13 +01:00
if ( file_exists ( $_SERVER [ " PROJECT_ROOT " ] . " /app/billing/app_config.php " )){
2014-07-18 01:46:04 +02:00
require_once " app/billing/resources/functions/rating.php " ;
2014-06-26 01:58:47 +02:00
require_once " resources/classes/database.php " ;
$database = new database ;
}
2014-10-12 17:29:31 +02:00
2012-06-04 16:58:40 +02:00
if ( $result_count > 0 ) {
2016-03-11 00:29:47 +01:00
//determine if theme images exist
$theme_image_path = $_SERVER [ " DOCUMENT_ROOT " ] . " /themes/ " . $_SESSION [ 'domain' ][ 'template' ][ 'name' ] . " /images/ " ;
$theme_cdr_images_exist = (
file_exists ( $theme_image_path . " icon_cdr_inbound_answered.png " ) &&
file_exists ( $theme_image_path . " icon_cdr_inbound_voicemail.png " ) &&
file_exists ( $theme_image_path . " icon_cdr_inbound_cancelled.png " ) &&
file_exists ( $theme_image_path . " icon_cdr_inbound_failed.png " ) &&
file_exists ( $theme_image_path . " icon_cdr_outbound_answered.png " ) &&
file_exists ( $theme_image_path . " icon_cdr_outbound_cancelled.png " ) &&
file_exists ( $theme_image_path . " icon_cdr_outbound_failed.png " ) &&
file_exists ( $theme_image_path . " icon_cdr_local_answered.png " ) &&
file_exists ( $theme_image_path . " icon_cdr_local_voicemail.png " ) &&
file_exists ( $theme_image_path . " icon_cdr_local_cancelled.png " ) &&
file_exists ( $theme_image_path . " icon_cdr_local_failed.png " )
) ? true : false ;
2015-03-14 01:03:16 +01:00
foreach ( $result as $index => $row ) {
2017-10-15 21:51:44 +02:00
//get the date and time
$tmp_year = date ( " Y " , strtotime ( $row [ 'start_stamp' ]));
$tmp_month = date ( " M " , strtotime ( $row [ 'start_stamp' ]));
$tmp_day = date ( " d " , strtotime ( $row [ 'start_stamp' ]));
$tmp_start_epoch = ( $_SESSION [ 'domain' ][ 'time_format' ][ 'text' ] == '12h' ) ? date ( " j M Y g:i:sa " , $row [ 'start_epoch' ]) : date ( " j M Y H:i:s " , $row [ 'start_epoch' ]);
//get the hangup cause
$hangup_cause = $row [ 'hangup_cause' ];
$hangup_cause = str_replace ( " _ " , " " , $hangup_cause );
$hangup_cause = strtolower ( $hangup_cause );
$hangup_cause = ucwords ( $hangup_cause );
2012-06-04 16:58:40 +02:00
2015-02-20 00:28:40 +01:00
//if call cancelled, show the ring time, not the bill time.
2016-03-11 00:29:47 +01:00
$seconds = ( $row [ 'hangup_cause' ] == " ORIGINATOR_CANCEL " ) ? $row [ 'duration' ] : round (( $row [ 'billmsec' ] / 1000 ), 0 , PHP_ROUND_HALF_UP );
//determine recording properties
if ( permission_exists ( 'recording_play' ) || permission_exists ( 'recording_download' )) {
2017-10-15 21:51:44 +02:00
$record_path = $row [ 'record_path' ];
$record_name = $row [ 'record_name' ];
//$record_name = strtolower(pathinfo($tmp_name, PATHINFO_BASENAME));
$record_extension = pathinfo ( $record_name , PATHINFO_EXTENSION );
switch ( $record_extension ) {
case " wav " : $record_type = " audio/wav " ; break ;
case " mp3 " : $record_type = " audio/mpeg " ; break ;
case " ogg " : $record_type = " audio/ogg " ; break ;
2016-03-11 00:29:47 +01:00
}
2015-04-03 23:07:24 +02:00
}
2016-03-11 00:29:47 +01:00
//recording playback
2017-10-15 21:51:44 +02:00
if ( permission_exists ( 'recording_play' ) && $record_path != '' ) {
echo " <tr id='recording_progress_bar_ " . $row [ 'uuid' ] . " ' style='display: none;'><td class=' " . $row_style [ $c ] . " playback_progress_bar_background' style='padding: 0; border: none;' colspan=' " . $col_count . " '><span class='playback_progress_bar' id='recording_progress_ " . $row [ 'uuid' ] . " '></span></td></tr> \n " ;
2015-04-03 23:07:24 +02:00
}
2016-03-11 00:29:47 +01:00
2017-09-14 19:51:31 +02:00
if ( $row [ 'raw_data_exists' ] && permission_exists ( 'xml_cdr_details' )) {
2017-12-09 20:27:27 +01:00
$tr_link = " href='xml_cdr_details.php?uuid= " . $row [ 'uuid' ] . (( $_REQUEST [ 'show' ]) ? " &show=all " : null ) . " ' " ;
2015-04-03 23:07:24 +02:00
}
2016-03-11 00:29:47 +01:00
else {
$tr_link = null ;
2015-04-03 23:07:24 +02:00
}
2016-03-11 00:29:47 +01:00
echo " <tr " . $tr_link . " > \n " ;
if ( permission_exists ( 'xml_cdr_delete' )) {
echo " <td valign='top' class=' " . $row_style [ $c ] . " tr_link_void' style='text-align: center; vertical-align: middle; padding: 0px;'> " ;
2017-10-15 21:51:44 +02:00
echo " <input type='checkbox' name='id[ " . $index . " ]' id='checkbox_ " . $row [ 'uuid' ] . " ' value=' " . $row [ 'uuid' ] . " ' onclick= \" if (this.checked) { document.getElementById('recording_ " . $row [ 'uuid' ] . " ').value=' " . base64_encode ( $record_path . '/' . $record_name ) . " ' } else { document.getElementById('recording_ " . $row [ 'uuid' ] . " ').value=''; document.getElementById('chk_all').checked = false; } \" > " ;
2016-03-11 00:29:47 +01:00
echo " <input type='hidden' name='rec[ " . $index . " ]' id='recording_ " . $row [ 'uuid' ] . " '> " ;
echo " </td> " ;
$xml_ids [] = 'checkbox_' . $row [ 'uuid' ];
2015-04-03 23:07:24 +02:00
}
2016-03-11 00:29:47 +01:00
//determine call result and appropriate icon
echo " <td valign='top' class=' " . $row_style [ $c ] . " '> \n " ;
if ( $theme_cdr_images_exist ) {
if ( $row [ 'direction' ] == 'inbound' || $row [ 'direction' ] == 'local' ) {
if ( $row [ 'answer_stamp' ] != '' && $row [ 'bridge_uuid' ] != '' ) { $call_result = 'answered' ; }
else if ( $row [ 'answer_stamp' ] != '' && $row [ 'bridge_uuid' ] == '' ) { $call_result = 'voicemail' ; }
else if ( $row [ 'answer_stamp' ] == '' && $row [ 'bridge_uuid' ] == '' && $row [ 'sip_hangup_disposition' ] != 'send_refuse' ) { $call_result = 'cancelled' ; }
else { $call_result = 'failed' ; }
}
else if ( $row [ 'direction' ] == 'outbound' ) {
if ( $row [ 'answer_stamp' ] != '' && $row [ 'bridge_uuid' ] != '' ) { $call_result = 'answered' ; }
else if ( $row [ 'answer_stamp' ] == '' && $row [ 'bridge_uuid' ] != '' ) { $call_result = 'cancelled' ; }
else { $call_result = 'failed' ; }
}
2016-07-10 00:29:42 +02:00
if ( strlen ( $row [ 'direction' ]) > 0 ) {
2017-06-03 06:31:20 +02:00
$image_name = " icon_cdr_ " . $row [ 'direction' ] . " _ " . $call_result ;
if ( $row [ 'leg' ] == 'b' ){
$image_name .= '_b' ;
}
$image_name .= " .png " ;
echo " <img src=' " . PROJECT_PATH . " /themes/ " . $_SESSION [ 'domain' ][ 'template' ][ 'name' ] . " /images/ $image_name ' width='16' style='border: none; cursor: help;' title=' " . $text [ 'label-' . $row [ 'direction' ]] . " : " . $text [ 'label-' . $call_result ] . ( $row [ 'leg' ] == 'b' ? '(b)' : '' ) . " '> \n " ;
2016-07-10 00:29:42 +02:00
}
2015-04-03 23:07:24 +02:00
}
2016-03-11 00:29:47 +01:00
else { echo " " ; }
echo " </td> \n " ;
//domain name
2017-12-09 20:27:27 +01:00
if ( $_REQUEST [ 'show' ] == " all " && permission_exists ( 'xml_cdr_all' )) {
2016-03-11 00:29:47 +01:00
echo " <td valign='top' class=' " . $row_style [ $c ] . " '> " ;
echo $row [ 'domain_name' ] . ' ' ;
echo " </td> \n " ;
2015-04-03 23:07:24 +02:00
}
2016-03-11 00:29:47 +01:00
//caller id name
echo " <td valign='top' class=' " . $row_style [ $c ] . " '> " . $row [ 'caller_id_name' ] . " </td> \n " ;
//source
echo " <td valign='top' class=' " . $row_style [ $c ] . " tr_link_void' nowrap='nowrap'> " ;
echo " <a href= \" javascript:void(0) \" onclick= \" send_cmd(' " . PROJECT_PATH . " /app/click_to_call/click_to_call.php?src_cid_name= " . urlencode ( $row [ 'caller_id_name' ]) . " &src_cid_number= " . urlencode ( $row [ 'caller_id_number' ]) . " &dest_cid_name= " . urlencode ( $_SESSION [ 'user' ][ 'extension' ][ 0 ][ 'outbound_caller_id_name' ]) . " &dest_cid_number= " . urlencode ( $_SESSION [ 'user' ][ 'extension' ][ 0 ][ 'outbound_caller_id_number' ]) . " &src= " . urlencode ( $_SESSION [ 'user' ][ 'extension' ][ 0 ][ 'user' ]) . " &dest= " . urlencode ( $row [ 'caller_id_number' ]) . " &rec=false&ringback=us-ring&auto_answer=true'); \" > \n " ;
if ( is_numeric ( $row [ 'caller_id_number' ])) {
echo " " . format_phone ( $row [ 'caller_id_number' ]) . ' ' ;
2015-04-03 23:07:24 +02:00
}
2016-03-11 00:29:47 +01:00
else {
echo " " . $row [ 'caller_id_number' ] . ' ' ;
2015-04-03 23:07:24 +02:00
}
2016-03-11 00:29:47 +01:00
echo " </a> " ;
echo " </td> \n " ;
2017-05-29 19:23:36 +02:00
//caller destination
2018-03-13 17:45:09 +01:00
if ( permission_exists ( 'caller_destination' )) {
echo " <td valign='top' class=' " . $row_style [ $c ] . " tr_link_void' nowrap='nowrap'> " ;
echo " <a href= \" javascript:void(0) \" onclick= \" send_cmd(' " . PROJECT_PATH . " /app/click_to_call/click_to_call.php?src_cid_name= " . urlencode ( $row [ 'caller_id_name' ]) . " &src_cid_number= " . urlencode ( $row [ 'caller_id_number' ]) . " &dest_cid_name= " . urlencode ( $_SESSION [ 'user' ][ 'extension' ][ 0 ][ 'outbound_caller_id_name' ]) . " &dest_cid_number= " . urlencode ( $_SESSION [ 'user' ][ 'extension' ][ 0 ][ 'outbound_caller_id_number' ]) . " &src= " . urlencode ( $_SESSION [ 'user' ][ 'extension' ][ 0 ][ 'user' ]) . " &dest= " . urlencode ( $row [ 'caller_destination' ]) . " &rec=false&ringback=us-ring&auto_answer=true'); \" > \n " ;
if ( is_numeric ( $row [ 'caller_destination' ])) {
echo " " . format_phone ( $row [ 'caller_destination' ]) . ' ' ;
}
else {
echo " " . $row [ 'caller_destination' ] . ' ' ;
}
echo " </a> " ;
echo " </td> \n " ;
2017-05-29 19:23:36 +02:00
}
2016-03-11 00:29:47 +01:00
//destination
echo " <td valign='top' class=' " . $row_style [ $c ] . " tr_link_void' nowrap='nowrap'> " ;
echo " <a href= \" javascript:void(0) \" onclick= \" send_cmd(' " . PROJECT_PATH . " /app/click_to_call/click_to_call.php?src_cid_name= " . urlencode ( $row [ 'destination_number' ]) . " &src_cid_number= " . urlencode ( $row [ 'destination_number' ]) . " &dest_cid_name= " . urlencode ( $_SESSION [ 'user' ][ 'extension' ][ 0 ][ 'outbound_caller_id_name' ]) . " &dest_cid_number= " . urlencode ( $_SESSION [ 'user' ][ 'extension' ][ 0 ][ 'outbound_caller_id_number' ]) . " &src= " . urlencode ( $_SESSION [ 'user' ][ 'extension' ][ 0 ][ 'user' ]) . " &dest= " . urlencode ( $row [ 'destination_number' ]) . " &rec=false&ringback=us-ring&auto_answer=true'); \" > \n " ;
if ( is_numeric ( $row [ 'destination_number' ])) {
echo format_phone ( $row [ 'destination_number' ]) . " \n " ;
2015-04-03 23:07:24 +02:00
}
else {
2016-03-11 00:29:47 +01:00
echo " " . $row [ 'destination_number' ] . " \n " ;
2014-06-21 12:38:02 +02:00
}
2016-03-11 00:29:47 +01:00
echo " </a> \n " ;
2014-06-21 12:38:02 +02:00
echo " </td> \n " ;
2016-03-11 00:29:47 +01:00
//recording
if ( permission_exists ( 'recording_play' ) || permission_exists ( 'recording_download' )) {
2017-10-15 23:46:25 +02:00
if ( $record_path != '' && file_exists ( $record_path . '/' . $record_name )) {
2016-03-29 06:29:15 +02:00
echo " <td valign='top' align='center' class=' " . $row_style [ $c ] . " row_style_slim tr_link_void' nowrap='nowrap'> " ;
2016-03-11 00:29:47 +01:00
if ( permission_exists ( 'recording_play' )) {
2017-10-15 21:51:44 +02:00
echo " <audio id='recording_audio_ " . $row [ 'uuid' ] . " ' style='display: none;' preload='none' ontimeupdate= \" update_progress(' " . $row [ 'uuid' ] . " ') \" onended= \" recording_reset(' " . $row [ 'uuid' ] . " '); \" src= \" download.php?id= " . $row [ 'uuid' ] . " &t=record \" type=' " . $record_type . " '></audio> " ;
2016-03-11 00:29:47 +01:00
echo " <span id='recording_button_ " . $row [ 'uuid' ] . " ' onclick= \" recording_play(' " . $row [ 'uuid' ] . " ') \" title=' " . $text [ 'label-play' ] . " / " . $text [ 'label-pause' ] . " '> " . $v_link_label_play . " </span> " ;
}
2017-10-15 21:51:44 +02:00
else {
echo " don't have recording_play permission " ;
}
2016-03-11 00:29:47 +01:00
if ( permission_exists ( 'recording_download' )) {
2017-10-15 21:51:44 +02:00
echo " <a href= \" download.php?id= " . $row [ 'uuid' ] . " &t=bin \" title=' " . $text [ 'label-download' ] . " '> " . $v_link_label_download . " </a> " ;
2016-03-11 00:29:47 +01:00
}
echo " </td> \n " ;
2015-04-03 23:07:24 +02:00
}
2016-03-11 00:29:47 +01:00
else {
echo " <td valign='top' align='center' class=' " . $row_style [ $c ] . " '> </td> \n " ;
2015-04-03 23:07:24 +02:00
}
}
2016-12-22 00:58:21 +01:00
//dynamic cdr fields
if ( is_array ( $_SESSION [ 'cdr' ][ 'field' ])) {
foreach ( $_SESSION [ 'cdr' ][ 'field' ] as $field ) {
2016-12-23 01:03:05 +01:00
$array = explode ( " , " , $field );
$field_name = $array [ count ( $array ) - 1 ];
if ( $field_name != " destination_number " ) {
echo " <td valign='top' class=' " . $row_style [ $c ] . " ' style='text-align: center;' nowrap='nowrap'> " . $row [ $field_name ] . " </td> \n " ;
}
2016-12-22 00:58:21 +01:00
}
}
2016-03-11 00:29:47 +01:00
//start
echo " <td valign='top' class=' " . $row_style [ $c ] . " ' style='text-align: center;' nowrap='nowrap'> " . $tmp_start_epoch . " </td> \n " ;
//tta (time to answer)
echo " <td valign='top' class=' " . $row_style [ $c ] . " ' style='text-align: right;'> " . (( $row [ 'tta' ] > 0 ) ? $row [ 'tta' ] . " s " : " " ) . " </td> \n " ;
//duration
echo " <td valign='top' class=' " . $row_style [ $c ] . " ' style='text-align: center;'> " . gmdate ( " G:i:s " , $seconds ) . " </td> \n " ;
//billing
if ( file_exists ( $_SERVER [ " PROJECT_ROOT " ] . " /app/billing/app_config.php " )){
$database -> table = " v_xml_cdr " ;
$accountcode = ( strlen ( $row [ " accountcode " ]) ? $row [ " accountcode " ] : $_SESSION [ domain_name ]);
$database -> sql = " SELECT currency FROM v_billings WHERE type_value=' $accountcode ' " ;
$database -> result = $database -> execute ();
$billing_currency = ( strlen ( $database -> result [ 0 ][ 'currency' ]) ? $database -> result [ 0 ][ 'currency' ] : 'USD' );
$billing_currency = ( strlen ( $database -> result [ 0 ][ 'currency' ]) ? $database -> result [ 0 ][ 'currency' ] :
( strlen ( $_SESSION [ 'billing' ][ 'currency' ][ 'text' ]) ? $_SESSION [ 'billing' ][ 'currency' ][ 'text' ] : 'USD' )
);
unset ( $database -> sql );
unset ( $database -> result );
2014-06-22 20:24:32 +02:00
2016-03-11 00:29:47 +01:00
$sell_price = strlen ( $row [ 'call_sell' ]) ? $row [ 'call_sell' ] : 0 ;
$lcr_direction = ( strlen ( $row [ 'direction' ]) ? $row [ 'direction' ] : " outbound " );
2014-06-26 01:58:47 +02:00
2016-03-11 00:29:47 +01:00
$xml_string = trim ( $row [ " xml " ]);
$json_string = trim ( $row [ " json " ]);
if ( strlen ( $xml_string ) > 0 ) {
$format = " xml " ;
}
if ( strlen ( $json_string ) > 0 ) {
$format = " json " ;
}
try {
if ( $format == 'json' ) {
$array = json_decode ( $json_string , true );
}
if ( $format == 'xml' ) {
$array = json_decode ( json_encode (( array ) simplexml_load_string ( $xml_string )), true );
}
}
catch ( Exception $e ) {
echo $e -> getMessage ();
}
2014-06-26 01:58:47 +02:00
2016-03-11 00:29:47 +01:00
$n = (( $lcr_direction == " inbound " ) ?
check_str ( urldecode ( $array [ " caller_profile " ][ " caller_id_number " ])) :
check_str ( urldecode ( $array [ " variables " ][ " lcr_query_digits " ]))
);
2014-11-25 23:22:28 +01:00
2016-03-11 00:29:47 +01:00
$database -> table = " v_lcr " ;
$database -> sql = " SELECT currency FROM v_lcr WHERE v_lcr.carrier_uuid IS NULL AND v_lcr.enabled='true' AND v_lcr.lcr_direction=' $lcr_direction ' AND v_lcr.digits IN ( " . number_series ( $n ) . " ) ORDER BY digits DESC, rate ASC, date_start DESC LIMIT 1 " ;
$database -> result = $database -> execute ();
// print "<pre>"; print $database->sql . ":";print "[".$database->result[0]['currency']."]"; print_r($array); print "</pre>";
$lcr_currency = (( is_string ( $database -> result [ 0 ][ 'currency' ]) && strlen ( $database -> result [ 0 ][ 'currency' ])) ? $database -> result [ 0 ][ 'currency' ] :
( strlen ( $_SESSION [ 'billing' ][ 'currency' ][ 'text' ]) ? $_SESSION [ 'billing' ][ 'currency' ][ 'text' ] : 'USD' )
); //billed currency
unset ( $database -> sql );
unset ( $database -> result );
if ( $sell_price ){
$price = currency_convert ( $sell_price , $billing_currency , $lcr_currency );
2014-11-25 23:22:28 +01:00
}
2016-03-11 00:29:47 +01:00
else {
$price = 0 ;
2014-11-25 23:22:28 +01:00
}
2016-03-11 00:29:47 +01:00
echo " <td valign='top' class=' " . $row_style [ $c ] . " '> " . number_format ( $price , 6 ) . " $billing_currency </td> \n " ;
unset ( $sell_price , $price );
2014-11-25 23:22:28 +01:00
}
2016-03-11 00:29:47 +01:00
//pdd (post dial delay)
if ( permission_exists ( " xml_cdr_pdd " )) {
echo " <td valign='top' class=' " . $row_style [ $c ] . " ' style='text-align: right;'> " . number_format ( $row [ 'pdd_ms' ] / 1000 , 2 ) . " s</td> \n " ;
2014-11-25 23:22:28 +01:00
}
2016-03-11 00:29:47 +01:00
//mos (mean opinion score)
if ( permission_exists ( " xml_cdr_mos " )) {
2017-05-10 22:09:30 +02:00
if ( strlen ( $row [ 'rtp_audio_in_mos' ]) > 0 ){
$title = " title=' " . $text [ 'label-mos_score-' . round ( $row [ 'rtp_audio_in_mos' ])] . " ' " ;
$value = $row [ 'rtp_audio_in_mos' ];
}
echo " <td valign='top' class=' " . $row_style [ $c ] . " ' $title style='text-align: center;'> $value </td> \n " ;
2016-03-11 00:29:47 +01:00
}
//hangup cause/call result
2018-03-13 17:45:09 +01:00
if ( permission_exists ( 'hangup_cause' )) {
2016-03-11 00:29:47 +01:00
echo " <td valign='top' class=' " . $row_style [ $c ] . " ' nowrap='nowrap'><a " . $tr_link . " > " . $hangup_cause . " </a></td> \n " ;
2014-12-06 16:04:38 +01:00
}
2015-05-01 20:52:01 +02:00
else {
2016-03-11 00:29:47 +01:00
echo " <td valign='top' class=' " . $row_style [ $c ] . " ' nowrap='nowrap'> " . ucwords ( $call_result ) . " </td> \n " ;
2015-05-01 20:52:01 +02:00
}
2016-03-11 00:29:47 +01:00
//control icons
2017-09-14 19:51:31 +02:00
if ( permission_exists ( 'xml_cdr_details' )) {
2016-03-11 00:29:47 +01:00
echo " <td class='list_control_icons tr_link_void' nowrap='nowrap'> " ;
2016-09-03 20:03:35 +02:00
if ( $tr_link != null ) {
echo " <a $tr_link title=' " . $text [ 'button-view' ] . " '> $v_link_label_view </a> " ; //CJB
}
2016-03-11 00:29:47 +01:00
if ( permission_exists ( 'xml_cdr_delete' )) {
2017-10-15 21:51:44 +02:00
echo " <a href='xml_cdr_delete.php?id[]= " . $row [ 'uuid' ] . " &rec[]= " . (( $record_path != '' ) ? base64_encode ( $record_path . '/' . $record_name ) : null ) . " ' alt=' " . $text [ 'button-delete' ] . " ' onclick= \" return confirm(' " . $text [ 'confirm-delete' ] . " ') \" > " . $v_link_label_delete . " </a> " ;
2016-03-11 00:29:47 +01:00
}
echo " </td> \n " ;
2015-02-20 00:28:40 +01:00
}
2012-06-04 16:58:40 +02:00
echo " </tr> \n " ;
2015-04-14 00:26:50 +02:00
$c = ( $c ) ? 0 : 1 ;
2012-06-04 16:58:40 +02:00
} //end foreach
unset ( $sql , $result , $row_count );
} //end if results
echo " <tr> \n " ;
echo " </table> " ;
2015-02-20 00:28:40 +01:00
echo " </form> " ;
2012-06-04 16:58:40 +02:00
echo " <br><br> " ;
2018-05-01 11:02:36 +02:00
echo $paging_controls ;
2012-06-04 16:58:40 +02:00
echo " <br><br> " ;
2015-02-20 00:28:40 +01:00
// check or uncheck all checkboxes
if ( sizeof ( $xml_ids ) > 0 ) {
echo " <script> \n " ;
echo " function check(what) { \n " ;
foreach ( $xml_ids as $xml_id ) {
echo " document.getElementById(' " . $xml_id . " ').checked = (what == 'all') ? true : false; \n " ;
}
echo " } \n " ;
echo " </script> \n " ;
}
//store last search/sort query parameters in session
$_SESSION [ 'xml_cdr' ][ 'last_query' ] = $_SERVER [ " QUERY_STRING " ];
2012-06-04 16:58:40 +02:00
//show the footer
2013-07-06 08:29:50 +02:00
require_once " resources/footer.php " ;
2014-08-03 13:14:56 +02:00
2016-12-22 00:58:21 +01:00
?>