2012-06-04 14:58:40 +00: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>
2019-03-13 20:15:19 -06:00
Portions created by the Initial Developer are Copyright (C) 2008-2019
2012-06-04 14:58:40 +00:00
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
2014-06-22 18:24:32 +00:00
Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
2012-06-04 14:58:40 +00:00
*/
2016-07-26 20:51:50 -06:00
//includes
require_once "root.php" ;
require_once "resources/require.php" ;
require_once "resources/check_auth.php" ;
2019-10-22 01:43:55 -06:00
require_once "resources/paging.php" ;
2016-07-26 20:51:50 -06:00
//check permisions
if ( permission_exists ( 'xml_cdr_view' )) {
//access granted
}
else {
echo "access denied" ;
exit ;
}
2012-06-04 14:58:40 +00:00
2012-10-24 07:35:01 +00:00
//add multi-lingual support
2015-01-18 10:04:43 +00:00
$language = new text ;
$text = $language -> get ();
2012-10-06 18:02:17 +00:00
2019-10-22 01:43:55 -06:00
//get posted data
if ( is_array ( $_POST [ 'xml_cdrs' ])) {
$action = $_POST [ 'action' ];
$xml_cdrs = $_POST [ 'xml_cdrs' ];
}
//delete the cdr
if ( permission_exists ( 'xml_cdr_delete' )) {
if ( $action == 'delete' && is_array ( $xml_cdrs ) && @ sizeof ( $xml_cdrs ) != 0 ) {
//delete
$obj = new xml_cdr ;
$obj -> delete ( $xml_cdrs );
//redirect
header ( 'Location: xml_cdr.php' );
exit ;
}
}
//create token
$object = new token ;
$token = $object -> create ( $_SERVER [ 'PHP_SELF' ]);
2012-06-04 14:58:40 +00:00
//additional includes
2013-07-06 06:29:50 +00:00
require_once "resources/header.php" ;
2012-07-11 02:23:05 +00:00
2012-06-04 14:58:40 +00:00
//xml cdr include
2016-03-28 23:02:11 -06:00
$rows_per_page = ( $_SESSION [ 'domain' ][ 'paging' ][ 'numeric' ] != '' ) ? $_SESSION [ 'domain' ][ 'paging' ][ 'numeric' ] : 50 ;
2012-06-04 14:58:40 +00:00
require_once "xml_cdr_inc.php" ;
2012-08-29 21:31:31 +00:00
//javascript function: send_cmd
echo "<script type= \" text/javascript \" > \n " ;
echo "function send_cmd(url) { \n " ;
2014-09-09 09:15:32 +00:00
echo " if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari \n " ;
2012-08-29 21:31:31 +00: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 10:30:44 +00: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;" ;
2019-10-22 01:43:55 -06:00
echo " document.getElementById(select_id).focus();" ;
2014-12-06 10:30:44 +00:00
echo " });" ;
echo " }" ;
echo "</script>" ;
2012-06-04 14:58:40 +00:00
//page title and description
2019-10-22 01:43:55 -06:00
echo "<div class='action_bar' id='action_bar'> \n " ;
2019-10-24 16:28:09 -06:00
echo " <div class='heading'><b>" . $text [ 'title-call_detail_records' ] . "</b></div> \n " ;
2019-10-24 16:31:14 -06:00
echo " <div class='actions'> \n " ;
2019-10-24 16:28:09 -06:00
echo " <form id='frm_export' class='inline' method='post' action='xml_cdr_export.php'> \n " ;
echo " <input type='hidden' name='cdr_id' value='" . escape ( $cdr_id ) . "'> \n " ;
echo " <input type='hidden' name='direction' value='" . escape ( $direction ) . "'> \n " ;
echo " <input type='hidden' name='caller_id_name' value='" . escape ( $caller_id_name ) . "'> \n " ;
echo " <input type='hidden' name='start_stamp_begin' value='" . escape ( $start_stamp_begin ) . "'> \n " ;
echo " <input type='hidden' name='start_stamp_end' value='" . escape ( $start_stamp_end ) . "'> \n " ;
echo " <input type='hidden' name='hangup_cause' value='" . escape ( $hangup_cause ) . "'> \n " ;
echo " <input type='hidden' name='call_result' value='" . escape ( $call_result ) . "'> \n " ;
echo " <input type='hidden' name='caller_extension_uuid' value='" . escape ( $caller_extension_uuid ) . "'> \n " ;
echo " <input type='hidden' name='caller_id_number' value='" . escape ( $caller_id_number ) . "'> \n " ;
echo " <input type='hidden' name='caller_destination' value='" . escape ( $caller_destination ) . "'> \n " ;
echo " <input type='hidden' name='destination_number' value='" . escape ( $destination_number ) . "'> \n " ;
echo " <input type='hidden' name='context' value='" . escape ( $context ) . "'> \n " ;
echo " <input type='hidden' name='answer_stamp_begin' value='" . escape ( $answer_stamp_begin ) . "'> \n " ;
echo " <input type='hidden' name='answer_stamp_end' value='" . escape ( $answer_stamp_end ) . "'> \n " ;
echo " <input type='hidden' name='end_stamp_begin' value='" . escape ( $end_stamp_begin ) . "'> \n " ;
echo " <input type='hidden' name='end_stamp_end' value='" . escape ( $end_stamp_end ) . "'> \n " ;
echo " <input type='hidden' name='start_epoch' value='" . escape ( $start_epoch ) . "'> \n " ;
echo " <input type='hidden' name='stop_epoch' value='" . escape ( $stop_epoch ) . "'> \n " ;
echo " <input type='hidden' name='duration' value='" . escape ( $duration ) . "'> \n " ;
echo " <input type='hidden' name='billsec' value='" . escape ( $billsec ) . "'> \n " ;
echo " <input type='hidden' name='xml_cdr_uuid' value='" . escape ( $xml_cdr_uuid ) . "'> \n " ;
echo " <input type='hidden' name='bleg_uuid' value='" . escape ( $bleg_uuid ) . "'> \n " ;
echo " <input type='hidden' name='accountcode' value='" . escape ( $accountcode ) . "'> \n " ;
echo " <input type='hidden' name='read_codec' value='" . escape ( $read_codec ) . "'> \n " ;
echo " <input type='hidden' name='write_codec' value='" . escape ( $write_codec ) . "'> \n " ;
echo " <input type='hidden' name='remote_media_ip' value='" . escape ( $remote_media_ip ) . "'> \n " ;
echo " <input type='hidden' name='network_addr' value='" . escape ( $network_addr ) . "'> \n " ;
echo " <input type='hidden' name='bridge_uuid' value='" . escape ( $bridge_uuid ) . "'> \n " ;
echo " <input type='hidden' name='leg' value='" . escape ( $leg ) . "'> \n " ;
2016-12-22 21:19:35 -07:00
if ( is_array ( $_SESSION [ 'cdr' ][ 'field' ])) {
foreach ( $_SESSION [ 'cdr' ][ 'field' ] as $field ) {
2017-01-04 22:25:17 -07:00
$array = explode ( "," , $field );
$field_name = $array [ count ( $array ) - 1 ];
if ( isset ( $_REQUEST [ $field_name ])) {
2019-10-24 16:28:09 -06:00
echo "<input type='hidden' name='" . escape ( $field_name ) . "' value='" . escape ( $$field_name ) . "'> \n " ;
2016-12-22 21:19:35 -07:00
}
2016-12-21 16:58:21 -07:00
}
}
2015-02-19 23:28:40 +00:00
if ( isset ( $order_by )) {
2018-06-09 13:21:23 -06:00
echo " <input type='hidden' name='order_by' value='" . escape ( $order_by ) . "'> \n " ;
echo " <input type='hidden' name='order' value='" . escape ( $order ) . "'> \n " ;
2015-02-19 23:28:40 +00:00
}
2019-10-22 09:53:36 -06:00
if ( permission_exists ( 'xml_cdr_delete' )) {
2019-10-22 01:43:55 -06:00
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-delete' ], 'icon' => $_SESSION [ 'theme' ][ 'button_icon_delete' ], 'onclick' => "if (confirm('" . $text [ 'confirm-delete' ] . "')) { list_action_set('delete'); list_form_submit('form_list'); } else { this.blur(); return false; }" ]);
2016-02-23 18:09:00 -07:00
}
2015-03-06 17:15:09 +00:00
if ( permission_exists ( 'xml_cdr_all' )) {
2019-10-24 16:28:09 -06:00
if ( ! $_REQUEST [ 'show' ] == 'all' ) {
2019-10-22 01:43:55 -06:00
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-show_all' ], 'icon' => $_SESSION [ 'theme' ][ 'button_icon_all' ], 'link' => '?show=all' ]);
2015-03-31 03:16:20 +00:00
}
2015-03-06 17:15:09 +00:00
}
2016-03-10 16:29:47 -07:00
if ( $_GET [ 'call_result' ] != 'missed' ) {
2019-10-22 01:43:55 -06:00
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-missed' ], 'icon' => 'phone-slash' , 'link' => '?call_result=missed' ]);
2015-04-01 09:06:02 +00:00
}
2019-10-22 01:43:55 -06:00
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-statistics' ], 'icon' => 'chart-area' , 'link' => 'xml_cdr_statistics.php' ]);
2018-04-23 15:24:30 -04:00
if ( permission_exists ( 'xml_cdr_archive' )) {
2019-10-22 01:43:55 -06:00
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-archive' ], 'icon' => 'archive' , 'link' => 'xml_cdr_archive.php' . ( $_REQUEST [ 'show' ] == 'all' ? '?show=all' : null )]);
}
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-export' ], 'icon' => 'file-export' , 'onclick' => "toggle_select('export_format'); this.blur();" ]);
2019-10-24 16:28:09 -06:00
echo "<select class='formfld' style='display: none; width: auto;' name='export_format' id='export_format' onchange= \" display_message('" . $text [ 'message-preparing_download' ] . "'); toggle_select('export_format'); document.getElementById('frm_export').submit(); \" >" ;
echo " <option value='' disabled='disabled' selected='selected'>" . $text [ 'label-format' ] . "</option>" ;
echo " <option value='csv'>CSV</option>" ;
echo " <option value='pdf'>PDF</option>" ;
echo " </select>" ;
2019-10-22 01:43:55 -06:00
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-refresh' ], 'icon' => 'sync-alt' , 'link' => 'xml_cdr.php' ]);
if ( $paging_controls_mini != '' ) {
2019-10-24 16:28:09 -06:00
echo "<span style='margin-left: 15px;'>" . $paging_controls_mini . "</span>" ;
2018-04-23 15:24:30 -04:00
}
2019-10-24 16:28:09 -06:00
echo " </form> \n " ;
echo " </div> \n " ;
echo " <div style='clear: both;'></div> \n " ;
2019-10-22 01:43:55 -06:00
echo "</div> \n " ;
2012-06-04 14:58:40 +00:00
2016-03-10 16:29:47 -07:00
echo $text [ 'description' ] . " \n " ;
echo $text [ 'description2' ] . " \n " ;
echo $text [ 'description-3' ] . " \n " ;
echo $text [ 'description-4' ] . " \n " ;
echo "<br /><br /> \n " ;
2012-06-04 14:58:40 +00:00
2019-05-24 19:54:27 -06:00
//basic search of call detail records
if ( permission_exists ( 'xml_cdr_search' )) {
echo "<form method='get' action=''> \n " ;
2019-10-24 16:28:09 -06:00
if ( permission_exists ( 'xml_cdr_all' ) && $_REQUEST [ 'show' ] == 'all' ) {
echo "<input type='hidden' name='show' value='all'> \n " ;
}
2019-05-24 19:54:27 -06:00
2019-10-02 14:01:27 -06:00
echo "<div class='form_grid'> \n " ;
if ( permission_exists ( 'xml_cdr_search_direction' )) {
echo " <div class='form_set'> \n " ;
echo " <div class='label'> \n " ;
echo " " . $text [ 'label-direction' ] . " \n " ;
echo " </div> \n " ;
echo " <div class='field'> \n " ;
echo " <select name='direction' class='formfld'> \n " ;
2019-09-28 19:13:01 -06:00
echo " <option value=''></option> \n " ;
2019-10-02 14:01:27 -06: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 " ;
2019-09-28 19:13:01 -06:00
echo " </select> \n " ;
2019-10-02 14:01:27 -06:00
if ( permission_exists ( 'xml_cdr_b_leg' )){
echo " <select name='leg' class='formfld'> \n " ;
echo " <option value=''></option> \n " ;
echo " <option value='a'>a-leg</option> \n " ;
echo " <option value='b'>b-leg</option> \n " ;
echo " </select> \n " ;
}
echo " </div> \n " ;
echo " </div> \n " ;
2019-09-28 19:13:01 -06:00
}
2019-10-02 14:01:27 -06:00
if ( permission_exists ( 'xml_cdr_search_status' )) {
echo " <div class='form_set'> \n " ;
echo " <div class='label'> \n " ;
echo " " . $text [ 'label-status' ] . " \n " ;
echo " </div> \n " ;
echo " <div class='field'> \n " ;
echo " <select name='call_result' class='formfld'> \n " ;
echo " <option value=''></option> \n " ;
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 " ;
echo " </select> \n " ;
echo " </div> \n " ;
echo " </div> \n " ;
}
if ( permission_exists ( 'xml_cdr_search_extension' )) {
2019-09-28 19:13:01 -06:00
$sql = "select extension_uuid, extension, number_alias from v_extensions " ;
$sql .= "where domain_uuid = :domain_uuid " ;
$sql .= "order by extension asc, number_alias asc " ;
$parameters [ 'domain_uuid' ] = $_SESSION [ 'domain_uuid' ];
$database = new database ;
$result_e = $database -> select ( $sql , $parameters , 'all' );
2019-10-02 14:01:27 -06:00
echo " <div class='form_set'> \n " ;
echo " <div class='label'> \n " ;
echo " " . $text [ 'label-extension' ] . " \n " ;
echo " </div> \n " ;
echo " <div class='field'> \n " ;
echo " <select class='formfld' name='extension_uuid' id='extension_uuid'> \n " ;
echo " <option value=''></option>" ;
2019-09-28 19:13:01 -06:00
if ( is_array ( $result_e ) && @ sizeof ( $result_e ) != 0 ) {
foreach ( $result_e as & $row ) {
$selected = ( $row [ 'extension_uuid' ] == $extension_uuid ) ? "selected" : null ;
2019-10-02 14:01:27 -06:00
echo " <option value='" . escape ( $row [ 'extension_uuid' ]) . "' " . escape ( $selected ) . ">" . (( is_numeric ( $row [ 'extension' ])) ? escape ( $row [ 'extension' ]) : escape ( $row [ 'number_alias' ]) . " (" . escape ( $row [ 'extension' ]) . ")" ) . "</option>" ;
2019-09-28 19:13:01 -06:00
}
}
2019-10-02 14:01:27 -06:00
echo " </select> \n " ;
echo " </div> \n " ;
echo " </div> \n " ;
2019-09-28 19:13:01 -06:00
unset ( $sql , $parameters , $result_e , $row , $selected );
}
2019-10-02 14:01:27 -06:00
if ( permission_exists ( 'xml_cdr_search_caller_id' )) {
echo " <div class='form_set'> \n " ;
echo " <div class='label'> \n " ;
echo " " . $text [ 'label-caller_id' ] . " \n " ;
echo " </div> \n " ;
2019-10-22 01:43:55 -06:00
echo " <div class='field no-wrap'> \n " ;
2019-10-02 14:01:27 -06:00
echo " <input type='text' class='formfld' name='caller_id_name' style='min-width: 115px; width: 115px;' placeholder= \" " . $text [ 'label-name' ] . " \" value='" . escape ( $caller_id_name ) . "'> \n " ;
echo " <input type='text' class='formfld' name='caller_id_number' style='min-width: 115px; width: 115px;' placeholder= \" " . $text [ 'label-number' ] . " \" value='" . escape ( $caller_id_number ) . "'> \n " ;
echo " </div> \n " ;
echo " </div> \n " ;
2019-09-28 19:13:01 -06:00
}
2019-10-02 14:01:27 -06:00
if ( permission_exists ( 'xml_cdr_search_start_range' )) {
echo " <div class='form_set'> \n " ;
echo " <div class='label'> \n " ;
echo " " . $text [ 'label-start_range' ] . " \n " ;
echo " </div> \n " ;
2019-10-22 01:43:55 -06:00
echo " <div class='field no-wrap'> \n " ;
2019-10-02 14:01:27 -06:00
echo " <input type='text' class='formfld datetimepicker' data-toggle='datetimepicker' data-target='#start_stamp_begin' onblur= \" $(this).datetimepicker('hide'); \" style='min-width: 115px; width: 115px;' name='start_stamp_begin' id='start_stamp_begin' placeholder='" . $text [ 'label-from' ] . "' value='" . escape ( $start_stamp_begin ) . "'> \n " ;
echo " <input type='text' class='formfld datetimepicker' data-toggle='datetimepicker' data-target='#start_stamp_end' onblur= \" $(this).datetimepicker('hide'); \" style='min-width: 115px; width: 115px;' name='start_stamp_end' id='start_stamp_end' placeholder='" . $text [ 'label-to' ] . "' value='" . escape ( $start_stamp_end ) . "'> \n " ;
echo " </div> \n " ;
echo " </div> \n " ;
}
if ( permission_exists ( 'xml_cdr_search_duration' )) {
echo " <div class='form_set'> \n " ;
echo " <div class='label'> \n " ;
echo " " . $text [ 'label-duration' ] . " (" . $text [ 'label-seconds' ] . ") \n " ;
echo " </div> \n " ;
2019-10-22 01:43:55 -06:00
echo " <div class='field no-wrap'> \n " ;
2019-10-02 14:01:27 -06:00
echo " <input type='text' class='formfld' style='min-width: 75px; width: 75px;' name='duration_min' value='" . escape ( $duration_min ) . "' placeholder= \" " . $text [ 'label-minimum' ] . " \" > \n " ;
echo " <input type='text' class='formfld' style='min-width: 75px; width: 75px;' name='duration_max' value='" . escape ( $duration_max ) . "' placeholder= \" " . $text [ 'label-maximum' ] . " \" > \n " ;
echo " </div> \n " ;
echo " </div> \n " ;
}
if ( permission_exists ( 'xml_cdr_search_caller_destination' )) {
echo " <div class='form_set'> \n " ;
echo " <div class='label'> \n " ;
2019-09-26 08:27:13 -06:00
echo " " . $text [ 'label-caller_destination' ] . " \n " ;
2019-10-02 14:01:27 -06:00
echo " </div> \n " ;
echo " <div class='field'> \n " ;
2019-09-26 08:27:13 -06:00
echo " <input type='text' class='formfld' name='caller_destination' value='" . escape ( $caller_destination ) . "'> \n " ;
2019-10-02 14:01:27 -06:00
echo " </div> \n " ;
echo " </div> \n " ;
2019-09-26 08:27:13 -06:00
}
2019-10-02 14:01:27 -06:00
if ( permission_exists ( 'xml_cdr_search_destination' )) {
echo " <div class='form_set'> \n " ;
echo " <div class='label'> \n " ;
echo " " . $text [ 'label-destination' ] . " \n " ;
echo " </div> \n " ;
echo " <div class='field'> \n " ;
echo " <input type='text' class='formfld' name='destination_number' id='destination_number' value='" . escape ( $destination_number ) . "'> \n " ;
echo " </div> \n " ;
echo " </div> \n " ;
}
if ( permission_exists ( 'xml_cdr_search_tta' )) {
echo " <div class='form_set'> \n " ;
echo " <div class='label'> \n " ;
echo " " . $text [ 'label-tta' ] . " (" . $text [ 'label-seconds' ] . ") \n " ;
echo " </div> \n " ;
2019-10-22 01:43:55 -06:00
echo " <div class='field no-wrap'> \n " ;
2019-10-02 14:01:27 -06:00
echo " <input type='text' class='formfld' style='min-width: 75px; width: 75px;' name='tta_min' id='tta_min' value='" . escape ( $tta ) . "' placeholder= \" " . $text [ 'label-minimum' ] . " \" > \n " ;
echo " <input type='text' class='formfld' style='min-width: 75px; width: 75px;' name='tta_max' id='tta_max' value='" . escape ( $tta ) . "' placeholder= \" " . $text [ 'label-maximum' ] . " \" > \n " ;
echo " </div> \n " ;
echo " </div> \n " ;
2019-09-28 19:13:01 -06:00
}
2014-06-16 18:12:21 +00:00
2019-10-02 14:01:27 -06:00
if ( permission_exists ( 'xml_cdr_search_hangup_cause' )) {
echo " <div class='form_set'> \n " ;
echo " <div class='label'> \n " ;
2019-09-26 08:27:13 -06:00
echo " " . $text [ 'label-hangup_cause' ] . " \n " ;
2019-10-02 14:01:27 -06:00
echo " </div> \n " ;
echo " <div class='field'> \n " ;
2019-09-26 08:27:13 -06:00
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='" . escape ( $cdr_status ) . "' " . escape ( $selected ) . ">" . escape ( $cdr_status_label ) . "</option> \n " ;
2019-05-24 19:54:27 -06:00
}
2019-09-26 08:27:13 -06:00
echo " </select> \n " ;
2019-10-02 14:01:27 -06:00
echo " </div> \n " ;
echo " </div> \n " ;
2019-09-26 08:27:13 -06:00
}
2019-10-02 14:01:27 -06:00
if ( permission_exists ( 'xml_cdr_search_recording' )) {
echo " <div class='form_set'> \n " ;
echo " <div class='label'> \n " ;
echo " " . $text [ 'label-recording' ] . " \n " ;
echo " </div> \n " ;
echo " <div class='field'> \n " ;
echo " <select name='recording' class='formfld'> \n " ;
echo " <option value=''></option> \n " ;
echo " <option value='true' " . ( $recording == 'true' ? "selected='selected'" : null ) . ">" . $text [ 'label-true' ] . "</option> \n " ;
echo " <option value='false' " . ( $recording == 'false' ? "selected='selected'" : null ) . ">" . $text [ 'label-false' ] . "</option> \n " ;
echo " </select> \n " ;
echo " </div> \n " ;
echo " </div> \n " ;
2019-09-26 08:27:13 -06:00
}
2019-10-02 14:01:27 -06:00
if ( permission_exists ( 'xml_cdr_search_order' )) {
echo " <div class='form_set'> \n " ;
echo " <div class='label'> \n " ;
echo " " . $text [ 'label-order' ] . " \n " ;
echo " </div> \n " ;
2019-10-22 01:43:55 -06:00
echo " <div class='field no-wrap'> \n " ;
2019-10-02 14:01:27 -06:00
echo " <select name='order_by' class='formfld'> \n " ;
if ( permission_exists ( 'xml_cdr_extension' )) {
echo " <option value='extension' " . ( $order_by == 'extension' ? "selected='selected'" : null ) . ">" . $text [ 'label-extension' ] . "</option> \n " ;
}
if ( permission_exists ( 'xml_cdr_all' )) {
echo " <option value='domain_name' " . ( $order_by == 'domain_name' ? "selected='selected'" : null ) . ">" . $text [ 'label-domain' ] . "</option> \n " ;
}
2019-10-02 15:41:49 -06:00
if ( permission_exists ( 'xml_cdr_caller_id_name' )) {
echo " <option value='caller_id_name' " . ( $order_by == 'caller_id_name' ? "selected='selected'" : null ) . ">" . $text [ 'label-caller_id_name' ] . "</option> \n " ;
}
if ( permission_exists ( 'xml_cdr_caller_id_number' )) {
echo " <option value='caller_id_number' " . ( $order_by == 'caller_id_number' ? "selected='selected'" : null ) . ">" . $text [ 'label-caller_id_number' ] . "</option> \n " ;
}
2019-10-02 14:01:27 -06:00
if ( permission_exists ( 'xml_cdr_caller_destination' )) {
echo " <option value='caller_destination' " . ( $order_by == 'caller_destination' ? "selected='selected'" : null ) . ">" . $text [ 'label-caller_destination' ] . "</option> \n " ;
}
2019-10-02 15:41:49 -06:00
if ( permission_exists ( 'xml_cdr_destination' )) {
echo " <option value='destination_number' " . ( $order_by == 'destination_number' ? "selected='selected'" : null ) . ">" . $text [ 'label-destination' ] . "</option> \n " ;
}
if ( permission_exists ( 'xml_cdr_start' )) {
echo " <option value='start_stamp' " . ( $order_by == 'start_stamp' || $order_by == '' ? "selected='selected'" : null ) . ">" . $text [ 'label-start' ] . "</option> \n " ;
}
if ( permission_exists ( 'xml_cdr_tta' )) {
echo " <option value='tta' " . ( $order_by == 'tta' ? "selected='selected'" : null ) . ">" . $text [ 'label-tta' ] . "</option> \n " ;
}
if ( permission_exists ( 'xml_cdr_duration' )) {
echo " <option value='duration' " . ( $order_by == 'duration' ? "selected='selected'" : null ) . ">" . $text [ 'label-duration' ] . "</option> \n " ;
}
2019-10-02 14:01:27 -06:00
if ( permission_exists ( 'xml_cdr_pdd' )) {
echo " <option value='pdd_ms' " . ( $order_by == 'pdd_ms' ? "selected='selected'" : null ) . ">" . $text [ 'label-pdd' ] . "</option> \n " ;
}
if ( permission_exists ( 'xml_cdr_mos' )) {
echo " <option value='rtp_audio_in_mos' " . ( $order_by == 'rtp_audio_in_mos' ? "selected='selected'" : null ) . ">" . $text [ 'label-mos' ] . "</option> \n " ;
}
if ( permission_exists ( 'xml_cdr_hangup_cause' )) {
echo " <option value='hangup_cause' " . ( $order_by == 'desc' ? "selected='selected'" : null ) . ">" . $text [ 'label-hangup_cause' ] . "</option> \n " ;
}
2019-10-02 15:41:49 -06:00
if ( permission_exists ( 'xml_cdr_custom_fields' )) {
if ( is_array ( $_SESSION [ 'cdr' ][ 'field' ])) {
echo " <option value='' disabled='disabled'></option> \n " ;
echo " <optgroup label= \" " . $text [ 'label-custom_cdr_fields' ] . " \" > \n " ;
foreach ( $_SESSION [ 'cdr' ][ 'field' ] as $field ) {
$array = explode ( "," , $field );
$field_name = end ( $array );
$field_label = ucwords ( str_replace ( "_" , " " , $field_name ));
$field_label = str_replace ( "Sip" , "SIP" , $field_label );
if ( $field_name != "destination_number" ) {
echo " <option value='" . $field_name . "' " . ( $order_by == $field_name ? "selected='selected'" : null ) . ">" . $field_label . "</option> \n " ;
}
2019-10-02 14:01:27 -06:00
}
2019-10-02 15:41:49 -06:00
echo " </optgroup> \n " ;
2019-09-26 08:27:13 -06:00
}
2019-05-24 19:54:27 -06:00
}
2019-10-02 14:01:27 -06:00
echo " </select> \n " ;
echo " <select name='order' class='formfld'> \n " ;
echo " <option value='desc' " . ( $order == 'desc' ? "selected='selected'" : null ) . ">" . $text [ 'label-descending' ] . "</option> \n " ;
echo " <option value='asc' " . ( $order == 'asc' ? "selected='selected'" : null ) . ">" . $text [ 'label-ascending' ] . "</option> \n " ;
echo " </select> \n " ;
echo " </div> \n " ;
echo " </div> \n " ;
2019-09-28 19:13:01 -06:00
}
2019-09-26 08:27:13 -06:00
2019-10-02 14:01:27 -06:00
echo "</div> \n " ;
2016-03-10 16:29:47 -07:00
2019-10-22 01:43:55 -06:00
button :: $collapse = false ;
2019-10-02 14:01:27 -06:00
echo "<div style='float: right; padding-top: 8px; margin-left: 20px; white-space: nowrap;'>" ;
2019-05-24 19:54:27 -06:00
if ( permission_exists ( 'xml_cdr_all' ) && $_REQUEST [ 'show' ] == 'all' ) {
echo "<input type='hidden' name='show' value='all'> \n " ;
}
2019-10-02 15:41:49 -06:00
if ( permission_exists ( 'xml_cdr_search_advanced' )) {
2019-10-22 01:43:55 -06:00
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-advanced_search' ], 'icon' => 'bolt' , 'link' => "xml_cdr_search.php" . ( $_REQUEST [ 'show' ] == 'all' ? '?show=all' : null ), 'style' => 'margin-right: 15px;' ]);
2019-10-02 15:41:49 -06:00
}
2019-10-22 01:43:55 -06:00
echo button :: create ([ 'label' => $text [ 'button-reset' ], 'icon' => $_SESSION [ 'theme' ][ 'button_icon_reset' ], 'type' => 'button' , 'link' => 'xml_cdr.php' ]);
echo button :: create ([ 'label' => $text [ 'button-search' ], 'icon' => $_SESSION [ 'theme' ][ 'button_icon_search' ], 'type' => 'submit' , 'name' => 'submit' ]);
2019-10-02 14:01:27 -06:00
echo "</div> \n " ;
echo "<div style='font-size: 85%; padding-top: 8px;'>" . $text [ 'description_search' ] . "</div> \n " ;
2014-06-16 18:12:21 +00:00
2019-05-24 19:54:27 -06:00
echo "</form>" ;
echo "<br /><br />" ;
}
2012-06-04 14:58:40 +00:00
2015-02-19 23:28:40 +00: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 14:58:40 +00:00
//show the results
2019-10-02 15:41:49 -06:00
$col_count = 0 ;
2019-10-22 01:43:55 -06:00
echo "<form id='form_list' method='post'> \n " ;
echo "<input type='hidden' id='action' name='action' value=''> \n " ;
echo "<table class='list'> \n " ;
echo "<tr class='list-header'> \n " ;
2019-10-23 21:19:37 -06:00
if ( permission_exists ( 'xml_cdr_delete' )) {
2019-10-22 01:43:55 -06:00
echo " <th class='checkbox'> \n " ;
2019-10-23 21:19:37 -06:00
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' " . ( $result ?: "style='visibility: hidden;'" ) . "> \n " ;
2019-10-22 01:43:55 -06:00
echo " </th> \n " ;
2015-04-13 22:26:50 +00:00
$col_count ++ ;
2015-02-19 23:28:40 +00:00
}
2019-05-24 19:54:27 -06:00
//column headings
2019-10-02 15:41:49 -06:00
if ( permission_exists ( 'xml_cdr_direction' )) {
echo "<th> </th> \n " ;
$col_count ++ ;
}
2019-05-24 19:54:27 -06:00
if ( permission_exists ( 'xml_cdr_extension' )) {
2019-09-26 08:27:13 -06:00
echo "<th>" . $text [ 'label-extension' ] . "</th> \n " ;
2019-10-02 15:41:49 -06:00
$col_count ++ ;
2019-05-24 19:54:27 -06:00
}
2019-10-02 15:41:49 -06:00
if ( permission_exists ( 'xml_cdr_all' ) && $_REQUEST [ 'show' ] == "all" ) {
2019-09-26 08:27:13 -06:00
echo "<th>" . $text [ 'label-domain' ] . "</th> \n " ;
2019-05-24 19:54:27 -06:00
$col_count ++ ;
}
2019-10-02 15:41:49 -06:00
if ( permission_exists ( 'xml_cdr_caller_id_name' )) {
2019-10-22 01:43:55 -06:00
echo "<th class='hide-md-dn'>" . $text [ 'label-caller_id_name' ] . "</th> \n " ;
2019-10-02 15:41:49 -06:00
$col_count ++ ;
}
if ( permission_exists ( 'xml_cdr_caller_id_number' )) {
echo "<th>" . $text [ 'label-caller_id_number' ] . "</th> \n " ;
$col_count ++ ;
}
2019-10-02 14:01:27 -06:00
if ( permission_exists ( 'xml_cdr_caller_destination' )) {
2019-10-22 01:43:55 -06:00
echo "<th class='hide-md-dn'>" . $text [ 'label-caller_destination' ] . "</th> \n " ;
2019-10-02 15:41:49 -06:00
$col_count ++ ;
2019-05-24 19:54:27 -06:00
}
2019-10-02 15:41:49 -06:00
if ( permission_exists ( 'xml_cdr_destination' )) {
echo "<th>" . $text [ 'label-destination' ] . "</th> \n " ;
$col_count ++ ;
}
if ( permission_exists ( 'xml_cdr_recording' ) && ( permission_exists ( 'recording_play' ) || permission_exists ( 'recording_download' ))) {
2019-10-22 01:43:55 -06:00
echo "<th class='center'>" . $text [ 'label-recording' ] . "</th> \n " ;
2019-05-24 19:54:27 -06:00
$col_count ++ ;
}
2019-10-02 15:41:49 -06:00
if ( permission_exists ( 'xml_cdr_custom_fields' )) {
if ( is_array ( $_SESSION [ 'cdr' ][ 'field' ]) && @ sizeof ( $_SESSION [ 'cdr' ][ 'field' ])) {
foreach ( $_SESSION [ 'cdr' ][ 'field' ] as $field ) {
$array = explode ( "," , $field );
$field_name = end ( $array );
$field_label = ucwords ( str_replace ( "_" , " " , $field_name ));
$field_label = str_replace ( "Sip" , "SIP" , $field_label );
if ( $field_name != "destination_number" ) {
2019-10-22 01:43:55 -06:00
echo "<th class='right'>" . $field_label . "</th> \n " ;
2019-10-02 15:41:49 -06:00
$col_count ++ ;
}
2016-12-21 16:58:21 -07:00
}
}
2019-05-24 19:54:27 -06:00
}
2019-10-02 15:41:49 -06:00
if ( permission_exists ( 'xml_cdr_start' )) {
2019-10-22 01:43:55 -06:00
echo "<th class='center'>" . $text [ 'label-start' ] . "</th> \n " ;
2019-10-02 15:41:49 -06:00
$col_count ++ ;
}
if ( permission_exists ( 'xml_cdr_tta' )) {
2019-10-22 01:43:55 -06:00
echo "<th class='right hide-md-dn' title= \" " . $text [ 'description-tta' ] . " \" >" . $text [ 'label-tta' ] . "</th> \n " ;
2019-10-02 15:41:49 -06:00
$col_count ++ ;
}
if ( permission_exists ( 'xml_cdr_duration' )) {
2019-10-22 01:43:55 -06:00
echo "<th class='center hide-sm-dn'>" . $text [ 'label-duration' ] . "</th> \n " ;
2019-10-02 15:41:49 -06:00
$col_count ++ ;
}
2019-05-24 19:54:27 -06:00
if ( permission_exists ( 'xml_cdr_pdd' )) {
2019-10-22 01:43:55 -06:00
echo "<th class='right hide-md-dn' title= \" " . $text [ 'description-pdd' ] . " \" >" . $text [ 'label-pdd' ] . "</th> \n " ;
2019-05-24 19:54:27 -06:00
$col_count ++ ;
}
if ( permission_exists ( 'xml_cdr_mos' )) {
2019-10-22 01:43:55 -06:00
echo "<th class='center hide-md-dn' title= \" " . $text [ 'description-mos' ] . " \" >" . $text [ 'label-mos' ] . "</th> \n " ;
2019-05-24 19:54:27 -06:00
$col_count ++ ;
}
2019-10-02 14:01:27 -06:00
if ( permission_exists ( 'xml_cdr_hangup_cause' )) {
2019-10-22 01:43:55 -06:00
echo "<th class='hide-sm-dn'>" . $text [ 'label-hangup_cause' ] . "</th> \n " ;
2019-10-02 15:41:49 -06:00
$col_count ++ ;
2019-05-24 19:54:27 -06:00
}
else {
echo "<th>" . $text [ 'label-status' ] . "</th> \n " ;
2019-10-02 15:41:49 -06:00
$col_count ++ ;
2019-05-24 19:54:27 -06:00
}
2019-10-02 15:41:49 -06:00
if ( permission_exists ( 'xml_cdr_details' )) {
2019-10-22 01:43:55 -06:00
echo "<td class='action-button'> </td> \n " ;
2014-06-25 23:58:47 +00:00
}
2019-05-24 19:54:27 -06:00
echo "</tr> \n " ;
2014-10-12 15:29:31 +00:00
2019-05-24 19:54:27 -06:00
//show results
if ( is_array ( $result )) {
2019-10-22 01:43:55 -06:00
2016-03-10 16:29:47 -07: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 ;
2019-09-03 08:29:44 -06:00
//loop through the results
2019-10-22 01:43:55 -06:00
$x = 0 ;
2019-09-03 08:29:44 -06:00
foreach ( $result as $index => $row ) {
2019-05-24 19:54:27 -06: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' ]));
2019-10-22 01:43:55 -06:00
$tmp_start_epoch = ( $_SESSION [ 'domain' ][ 'time_format' ][ 'text' ] == '12h' ) ? escape ( date ( "j M Y" , $row [ 'start_epoch' ])) . " <span class='hide-md-dn'>" . escape ( date ( "g:i:sa" , $row [ 'start_epoch' ])) . "</span>" : escape ( date ( "j M Y" , $row [ 'start_epoch' ])) . " <span class='hide-md-dn'>" . escape ( date ( "H:i:s" , $row [ 'start_epoch' ])) . "</span>" ;
2019-05-24 19:54:27 -06:00
//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 );
//if call cancelled, show the ring time, not the bill time.
2019-09-03 08:29:44 -06:00
$seconds = $row [ 'hangup_cause' ] == "ORIGINATOR_CANCEL" ? $row [ 'duration' ] : round (( $row [ 'billmsec' ] / 1000 ), 0 , PHP_ROUND_HALF_UP );
2019-05-24 19:54:27 -06:00
//determine recording properties
if ( permission_exists ( 'recording_play' ) || permission_exists ( 'recording_download' )) {
$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-10 16:29:47 -07:00
}
2019-05-24 19:54:27 -06:00
//set an empty content variable
$content = '' ;
2019-03-13 20:15:19 -06:00
2019-05-24 19:54:27 -06:00
//recording playback
if ( permission_exists ( 'recording_play' ) && $record_path != '' ) {
2019-10-22 01:57:20 -06:00
$content .= "<tr class='list-row' id='recording_progress_bar_" . $row [ 'xml_cdr_uuid' ] . "' style='display: none;'><td class='playback_progress_bar_background' style='padding: 0; border-bottom: none; overflow: hidden;' colspan='" . $col_count . "'><span class='playback_progress_bar' id='recording_progress_" . $row [ 'xml_cdr_uuid' ] . "'></span></td></tr> \n " ;
2019-10-22 01:43:55 -06:00
$content .= "<tr class='list-row' style='display: none;'><td></td></tr> \n " ; // dummy table row to maintain alternating background color
2019-05-24 19:54:27 -06:00
}
2019-10-04 13:16:21 -06:00
if ( permission_exists ( 'xml_cdr_details' )) {
2019-10-22 01:43:55 -06:00
$list_row_url = "xml_cdr_details.php?id=" . urlencode ( $row [ 'xml_cdr_uuid' ]) . ( $_REQUEST [ 'show' ] ? "&show=all" : null );
2016-03-10 16:29:47 -07:00
}
2019-10-22 01:43:55 -06:00
$content .= "<tr class='list-row' href='" . $list_row_url . "'> \n " ;
2019-05-24 19:54:27 -06:00
if ( permission_exists ( 'xml_cdr_delete' )) {
2019-10-22 01:43:55 -06:00
$content .= " <td class='checkbox'> \n " ;
$content .= " <input type='checkbox' name='xml_cdrs[ $x ][checked]' id='checkbox_" . $x . "' value='true' onclick= \" if (!this.checked) { document.getElementById('checkbox_all').checked = false; } \" > \n " ;
$content .= " <input type='hidden' name='xml_cdrs[ $x ][uuid]' value='" . escape ( $row [ 'xml_cdr_uuid' ]) . "' /> \n " ;
$content .= " </td> \n " ;
2019-05-24 19:54:27 -06:00
}
//determine call result and appropriate icon
2019-10-02 15:41:49 -06:00
if ( permission_exists ( 'xml_cdr_direction' )) {
2019-10-22 01:43:55 -06:00
$content .= "<td> \n " ;
2019-10-02 15:41:49 -06:00
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' ; }
}
if ( strlen ( $row [ 'direction' ]) > 0 ) {
$image_name = "icon_cdr_" . $row [ 'direction' ] . "_" . $call_result ;
if ( $row [ 'leg' ] == 'b' ) {
$image_name .= '_b' ;
}
$image_name .= ".png" ;
$content .= "<img src='" . PROJECT_PATH . "/themes/" . $_SESSION [ 'domain' ][ 'template' ][ 'name' ] . "/images/" . escape ( $image_name ) . "' width='16' style='border: none; cursor: help;' title='" . $text [ 'label-' . $row [ 'direction' ]] . ": " . $text [ 'label-' . $call_result ] . ( $row [ 'leg' ] == 'b' ? '(b)' : '' ) . "'> \n " ;
2019-05-24 19:54:27 -06:00
}
2017-06-03 07:31:20 +03:00
}
2019-10-02 15:41:49 -06:00
else { $content .= " " ; }
$content .= "</td> \n " ;
2016-07-09 16:29:42 -06:00
}
2019-05-24 19:54:27 -06:00
//extension
if ( permission_exists ( 'xml_cdr_extension' )) {
2019-10-22 01:43:55 -06:00
$content .= " <td>" ;
2019-05-24 19:54:27 -06:00
$content .= $row [ 'extension' ] . ' ' ;
$content .= " </td> \n " ;
}
//domain name
2019-10-02 15:41:49 -06:00
if ( permission_exists ( 'xml_cdr_all' ) && $_REQUEST [ 'show' ] == "all" ) {
2019-10-22 01:43:55 -06:00
$content .= " <td>" ;
2019-05-24 19:54:27 -06:00
$content .= $row [ 'domain_name' ] . ' ' ;
$content .= " </td> \n " ;
}
//caller id name
2019-10-02 15:41:49 -06:00
if ( permission_exists ( 'xml_cdr_caller_id_name' )) {
2019-10-22 01:43:55 -06:00
$content .= " <td class='overflow hide-md-dn'>" . escape ( $row [ 'caller_id_name' ]) . " </td> \n " ;
2018-03-13 10:45:09 -06:00
}
2019-10-02 15:41:49 -06:00
//source
if ( permission_exists ( 'xml_cdr_caller_id_number' )) {
2019-10-22 01:43:55 -06:00
$content .= " <td class='no-link no-wrap'>" ;
2019-10-02 15:41:49 -06:00
$content .= " <a href= \" javascript:void(0) \" onclick= \" send_cmd('" . PROJECT_PATH . "/app/click_to_call/click_to_call.php?src_cid_name=" . urlencode ( escape ( $row [ 'caller_id_name' ])) . "&src_cid_number=" . urlencode ( escape ( $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 ( escape ( $row [ 'caller_id_number' ])) . "&rec=false&ringback=us-ring&auto_answer=true'); \" > \n " ;
if ( is_numeric ( $row [ 'caller_id_number' ])) {
$content .= " " . format_phone ( substr ( $row [ 'caller_id_number' ], 0 , 20 )) . ' ' ;
}
else {
$content .= " " . escape ( substr ( $row [ 'caller_id_number' ], 0 , 20 )) . ' ' ;
}
$content .= " </a>" ;
$content .= " </td> \n " ;
2018-03-13 10:45:09 -06:00
}
2019-05-24 19:54:27 -06:00
//caller destination
2019-10-02 14:01:27 -06:00
if ( permission_exists ( 'xml_cdr_caller_destination' )) {
2019-10-22 01:43:55 -06:00
$content .= " <td class='no-link no-wrap hide-md-dn'>" ;
2019-05-24 19:54:27 -06:00
$content .= " <a href= \" javascript:void(0) \" onclick= \" send_cmd('" . PROJECT_PATH . "/app/click_to_call/click_to_call.php?src_cid_name=" . urlencode ( escape ( $row [ 'caller_id_name' ])) . "&src_cid_number=" . urlencode ( escape ( $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 ( escape ( $row [ 'caller_destination' ])) . "&rec=false&ringback=us-ring&auto_answer=true'); \" > \n " ;
if ( is_numeric ( $row [ 'caller_destination' ])) {
$content .= " " . format_phone ( escape ( substr ( $row [ 'caller_destination' ], 0 , 20 ))) . ' ' ;
}
else {
$content .= " " . escape ( substr ( $row [ 'caller_destination' ], 0 , 20 )) . ' ' ;
2019-05-24 13:51:43 -06:00
}
2019-05-24 19:54:27 -06:00
$content .= " </a>" ;
$content .= " </td> \n " ;
2019-05-24 13:58:31 -04:00
}
2019-05-24 19:54:27 -06:00
//destination
2019-10-02 15:41:49 -06:00
if ( permission_exists ( 'xml_cdr_destination' )) {
if ( $_SESSION [ 'cdr' ][ 'remove_prefix' ][ 'boolean' ] == 'true' ) {
//get outbound prefix variable from json table if exists
$json_string = trim ( $row [ "json" ]);
$array = json_decode ( $json_string , true );
$remove_prefix = false ;
$prefix = false ;
if ( is_array ( $array [ "app_log" ][ "application" ])) {
foreach ( $array [ "app_log" ][ "application" ] as $application ) {
$app_data = urldecode ( $application [ "@attributes" ][ "app_data" ]);
if ( substr ( $app_data , 0 , 7 ) == "prefix=" ) {
$prefix = substr ( $app_data , 7 );
$remove_prefix = true ;
}
2019-05-24 19:54:27 -06:00
}
}
2019-05-24 13:51:43 -06:00
}
2019-10-22 01:43:55 -06:00
$content .= " <td class='no-link no-wrap'>" ;
2019-10-02 15:41:49 -06:00
$content .= " <a href= \" javascript:void(0) \" onclick= \" send_cmd('" . PROJECT_PATH . "/app/click_to_call/click_to_call.php?src_cid_name=" . urlencode ( escape ( $row [ 'destination_number' ])) . "&src_cid_number=" . urlencode ( escape ( $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 ( escape ( $row [ 'destination_number' ])) . "&rec=false&ringback=us-ring&auto_answer=true'); \" > \n " ;
if ( is_numeric ( $row [ 'destination_number' ])) {
if ( $prefix ) {
//confirms call was made with a prefix
$is_prefixed = substr ( format_phone ( escape ( substr ( $row [ 'destination_number' ], 0 , 20 ))), 0 , strlen ( $prefix ));
//remove the prefix
if ( $prefix == $is_prefixed ) {
$content .= substr ( format_phone ( escape ( substr ( $row [ 'destination_number' ], 0 , 20 ))), strlen ( $prefix )) . " \n " ;
}
else {
$content .= format_phone ( escape ( substr ( $row [ 'destination_number' ], 0 , 20 ))) . " \n " ;
}
2019-05-24 19:54:27 -06:00
}
2019-06-05 14:18:56 -04:00
else {
$content .= format_phone ( escape ( substr ( $row [ 'destination_number' ], 0 , 20 ))) . " \n " ;
}
2019-05-24 13:58:31 -04:00
}
else {
2019-10-02 15:41:49 -06:00
if ( $remove_prefix == 'true' ) {
$content .= substr ( format_phone ( escape ( substr ( $row [ 'destination_number' ], 0 , 20 ))), strlen ( $prefix )) . " \n " ;
}
else {
$content .= format_phone ( escape ( substr ( $row [ 'destination_number' ], 0 , 20 ))) . " \n " ;
}
2019-05-24 13:51:43 -06:00
}
2019-10-02 15:41:49 -06:00
$content .= " </a> \n " ;
$content .= " </td> \n " ;
2019-05-24 19:54:27 -06:00
}
//recording
2019-10-02 15:41:49 -06:00
if ( permission_exists ( 'xml_cdr_recording' ) && ( permission_exists ( 'recording_play' ) || permission_exists ( 'recording_download' ))) {
2019-05-24 19:54:27 -06:00
if ( $record_path != '' && file_exists ( $record_path . '/' . $record_name )) {
2019-10-22 01:43:55 -06:00
$content .= " <td class='button center no-link no-wrap'>" ;
2019-05-24 19:54:27 -06:00
if ( permission_exists ( 'recording_play' )) {
$content .= "<audio id='recording_audio_" . escape ( $row [ 'xml_cdr_uuid' ]) . "' style='display: none;' preload='none' ontimeupdate= \" update_progress('" . escape ( $row [ 'xml_cdr_uuid' ]) . "') \" onended= \" recording_reset('" . escape ( $row [ 'xml_cdr_uuid' ]) . "'); \" src= \" download.php?id=" . escape ( $row [ 'xml_cdr_uuid' ]) . "&t=record \" type='" . escape ( $record_type ) . "'></audio>" ;
2019-10-22 01:43:55 -06:00
$content .= button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-label' ], 'icon' => $_SESSION [ 'theme' ][ 'button_icon_play' ], 'id' => 'recording_button_' . escape ( $row [ 'xml_cdr_uuid' ]), 'onclick' => "recording_play('" . escape ( $row [ 'xml_cdr_uuid' ]) . "')" , 'title' => $text [ 'label-play' ] . ' / ' . $text [ 'label-pause' ]]);
2019-05-24 19:54:27 -06:00
}
if ( permission_exists ( 'recording_download' )) {
2019-10-22 01:43:55 -06:00
$content .= button :: create ([ 'type' => 'button' , 'title' => $text [ 'button-download' ], 'icon' => $_SESSION [ 'theme' ][ 'button_icon_download' ], 'link' => "download.php?id=" . urlencode ( $row [ 'xml_cdr_uuid' ]) . "&t=bin" ]);
2019-05-24 19:54:27 -06:00
}
2019-10-22 01:43:55 -06:00
$content .= "</td> \n " ;
2016-03-10 16:29:47 -07:00
}
2017-10-15 13:51:44 -06:00
else {
2019-10-22 01:43:55 -06:00
$content .= " <td> </td> \n " ;
2017-10-15 13:51:44 -06:00
}
2019-05-24 19:54:27 -06:00
}
2019-10-02 15:41:49 -06:00
//custom cdr fields
if ( permission_exists ( 'xml_cdr_custom_fields' )) {
if ( is_array ( $_SESSION [ 'cdr' ][ 'field' ])) {
foreach ( $_SESSION [ 'cdr' ][ 'field' ] as $field ) {
$array = explode ( "," , $field );
$field_name = $array [ count ( $array ) - 1 ];
if ( $field_name != "destination_number" ) {
2019-10-22 01:43:55 -06:00
$content .= " <td class='center no-wrap'>" . escape ( $row [ $field_name ]) . "</td> \n " ;
2019-10-02 15:41:49 -06:00
}
2019-05-24 19:54:27 -06:00
}
2016-03-10 16:29:47 -07:00
}
2015-04-03 21:07:24 +00:00
}
2019-05-24 19:54:27 -06:00
//start
2019-10-02 15:41:49 -06:00
if ( permission_exists ( 'xml_cdr_start' )) {
2019-10-22 01:43:55 -06:00
$content .= " <td class='center no-wrap'>" . $tmp_start_epoch . "</td> \n " ;
2019-10-02 15:41:49 -06:00
}
2019-05-24 19:54:27 -06:00
//tta (time to answer)
2019-10-02 15:41:49 -06:00
if ( permission_exists ( 'xml_cdr_tta' )) {
2019-10-22 01:43:55 -06:00
$content .= " <td class='right hide-md-dn'>" . (( $row [ 'tta' ] > 0 ) ? $row [ 'tta' ] . "s" : " " ) . "</td> \n " ;
2019-10-02 15:41:49 -06:00
}
2019-05-24 19:54:27 -06:00
//duration
2019-10-02 15:41:49 -06:00
if ( permission_exists ( 'xml_cdr_duration' )) {
2019-10-22 01:43:55 -06:00
$content .= " <td class='center hide-sm-dn'>" . gmdate ( "G:i:s" , $seconds ) . "</td> \n " ;
2019-10-02 15:41:49 -06:00
}
2019-05-24 19:54:27 -06:00
//pdd (post dial delay)
if ( permission_exists ( "xml_cdr_pdd" )) {
2019-10-22 01:43:55 -06:00
$content .= " <td class='right hide-md-dn'>" . number_format ( escape ( $row [ 'pdd_ms' ]) / 1000 , 2 ) . "s</td> \n " ;
2015-04-03 21:07:24 +00:00
}
2019-05-24 19:54:27 -06:00
//mos (mean opinion score)
if ( permission_exists ( "xml_cdr_mos" )) {
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' ];
2016-12-22 17:03:05 -07:00
}
2019-10-22 01:43:55 -06:00
$content .= " <td class='center hide-md-dn' " . $title . ">" . $value . "</td> \n " ;
2016-12-21 16:58:21 -07:00
}
2019-05-24 19:54:27 -06:00
//hangup cause/call result
2019-10-02 14:01:27 -06:00
if ( permission_exists ( 'xml_cdr_hangup_cause' )) {
2019-10-22 01:43:55 -06:00
$content .= " <td class='no-wrap hide-sm-dn'><a href='" . $list_row_url . "'>" . escape ( $hangup_cause ) . "</a></td> \n " ;
2016-03-10 16:29:47 -07:00
}
2019-05-24 19:54:27 -06:00
else {
2019-10-22 01:43:55 -06:00
$content .= " <td class='no-wrap hide-sm-dn'>" . ucwords ( escape ( $call_result )) . "</td> \n " ;
2016-03-10 16:29:47 -07:00
}
2019-10-22 01:43:55 -06:00
//action icon
2019-10-22 10:06:24 -06:00
//if (permission_exists('xml_cdr_details')) {
// $content .= " <td class='action-button'>";
// $content .= button::create(['type'=>'button','title'=>$text['button-view'],'icon'=>$_SESSION['theme']['button_icon_view'],'link'=>$list_row_url]);
// $content .= " </td>\n";
//}
2019-05-24 19:54:27 -06:00
$content .= "</tr> \n " ;
2014-11-25 22:22:28 +00:00
2019-05-24 19:54:27 -06:00
//show the leg b only to those with the permission
if ( $row [ 'leg' ] == 'a' ) {
echo $content ;
2016-09-03 14:03:35 -04:00
}
2019-09-03 08:29:44 -06:00
else if ( $row [ 'leg' ] == 'b' && permission_exists ( 'xml_cdr_b_leg' )) {
2019-05-24 19:54:27 -06:00
echo $content ;
2016-03-10 16:29:47 -07:00
}
2019-05-24 19:54:27 -06:00
unset ( $content );
2019-03-13 20:15:19 -06:00
2019-10-22 01:43:55 -06:00
$x ++ ;
}
}
2019-09-03 08:29:44 -06:00
unset ( $sql , $result , $row_count );
2012-06-04 14:58:40 +00:00
2019-10-22 01:43:55 -06:00
echo "</table> \n " ;
echo "<br /> \n " ;
echo "<div align='center'>" . $paging_controls . "</div> \n " ;
echo "<input type='hidden' name='" . $token [ 'name' ] . "' value='" . $token [ 'hash' ] . "'> \n " ;
echo "</form> \n " ;
2015-02-19 23:28:40 +00:00
2019-05-24 19:54:27 -06:00
//store last search/sort query parameters in session
2015-02-19 23:28:40 +00:00
$_SESSION [ 'xml_cdr' ][ 'last_query' ] = $_SERVER [ "QUERY_STRING" ];
2012-06-04 14:58:40 +00:00
//show the footer
2013-07-06 06:29:50 +00:00
require_once "resources/footer.php" ;
2014-08-03 11:14:56 +00:00
2019-10-22 09:53:36 -06:00
?>