Portions created by the Initial Developer are Copyright (C) 2008-2019 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane Luis Daniel Lucio Quiroz */ //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; } //add multi-lingual support $language = new text; $text = $language->get(); //additional includes require_once "resources/header.php"; require_once "resources/paging.php"; //xml cdr include $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; require_once "xml_cdr_inc.php"; //javascript function: send_cmd echo "\n"; //javascript to toggle export select box echo ""; //page title and description echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
".$text['title']."


\n"; echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; if (is_array($_SESSION['cdr']['field'])) { foreach ($_SESSION['cdr']['field'] as $field) { $array = explode(",", $field); $field_name = $array[count($array) - 1]; if (isset($_REQUEST[$field_name])) { echo " \n"; } } } if (isset($order_by)) { echo " \n"; echo " \n"; } if (permission_exists('xml_cdr_all') && $_REQUEST['show'] == 'all') { echo " \n"; } echo " \n"; echo " \n"; echo " "; echo " \n"; echo " \n"; echo "
\n"; if (permission_exists('xml_cdr_all')) { if ($_REQUEST['show'] != 'alll') { echo " \n"; } } if (permission_exists('xml_cdr_search_advanced')) { if ($_REQUEST['show'] == 'all') { $query_string = "show=all"; } echo " \n"; } if ($_GET['call_result'] != 'missed') { echo " \n"; } echo " \n"; if (permission_exists('xml_cdr_archive')) { if ($_REQUEST['show'] == 'all') { $query_string = "show=all"; } echo " \n"; } echo " \n"; echo " \n"; echo " \n"; echo " ".$paging_controls_mini."
\n"; echo "
\n"; echo "
\n"; echo $text['description']." \n"; echo $text['description2']." \n"; echo $text['description-3']." \n"; echo $text['description-4']." \n"; echo "

\n"; echo "
\n"; //basic search of call detail records if (permission_exists('xml_cdr_search')) { echo "
\n"; echo "\n"; echo "\n"; echo ""; echo ""; echo ""; // show hangup clause filter to super/admin echo ""; echo ""; echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " ".$text['label-direction']."\n"; echo " \n"; echo " \n"; echo "
\n"; echo " ".$text['label-status']."\n"; echo " \n"; echo " \n"; echo "
\n"; echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " ".$text['label-caller_id_number']."\n"; echo " \n"; echo " \n"; echo "
\n"; echo " ".$text['label-destination']."\n"; echo " \n"; echo " \n"; echo "
\n"; echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " ".$text['label-start_range']."\n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " ".$text['label-caller_id_name']."\n"; echo " \n"; echo " \n"; echo "
\n"; echo "
\n"; echo "\n"; echo " \n"; if (permission_exists('hangup_cause')) { echo " \n"; echo " \n"; echo " \n"; } if (permission_exists('caller_destination')) { echo " \n"; echo " \n"; echo " \n"; echo " \n"; } echo "
\n"; echo " ".$text['label-hangup_cause']."\n"; echo " \n"; echo " \n"; echo "
\n"; echo " ".$text['label-caller_destination']."\n"; echo " \n"; echo " \n"; echo "
\n"; echo "
"; echo "\n"; echo ""; echo ""; echo ""; echo ""; echo "
"; echo $text['description_search']; echo ""; if (permission_exists('xml_cdr_all') && $_REQUEST['show'] == 'all') { echo "\n"; } echo "\n"; echo "\n"; echo "
"; echo "
"; echo "

"; } //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 //show the results $col_count = 8; echo "
\n"; echo "\n"; echo "\n"; if (permission_exists('xml_cdr_delete') && $result_count > 0) { echo ""; $col_count++; } //column headings echo "\n"; if (permission_exists('xml_cdr_extension')) { echo th_order_by('extension', $text['label-extension'], $order_by, $order, null, null, $param); } if ($_REQUEST['show'] == "all" && permission_exists('xml_cdr_all')) { echo th_order_by('domain_name', $text['label-domain'], $order_by, $order, null, null, $param); $col_count++; } 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); if (permission_exists('caller_destination')) { echo th_order_by('caller_destination', $text['label-caller_destination'], $order_by, $order, null, null, $param); } 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 "\n"; $col_count++; } if (is_array($_SESSION['cdr']['field'])) { foreach ($_SESSION['cdr']['field'] as $field) { $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); } } } echo th_order_by('start_stamp', $text['label-start'], $order_by, $order, null, "style='text-align: center;'", $param); echo th_order_by('tta', $text['label-tta'], $order_by, $order, null, "style='text-align: right;'", $param, $text['description-tta']); echo th_order_by('duration', $text['label-duration'], $order_by, $order, null, "style='text-align: center;'", $param); if (permission_exists('xml_cdr_pdd')) { echo th_order_by('pdd_ms', $text['label-pdd'], $order_by, $order, null, "style='text-align: right;'", $param, $text['description-pdd']); $col_count++; } if (permission_exists('xml_cdr_mos')) { echo th_order_by('rtp_audio_in_mos', $text['label-mos'], $order_by, $order, null, "style='text-align: center;'", $param, $text['description-mos']); $col_count++; } if (permission_exists('hangup_cause')) { echo th_order_by('hangup_cause', $text['label-hangup_cause'], $order_by, $order, null, null, $param); } else { echo "\n"; } if (if_group("admin") || if_group("superadmin") || if_group("cdr")) { echo "\n"; $col_count++; } echo "\n"; //show results if (is_array($result)) { //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; //loop through the results foreach ($result as $index => $row) { //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); //if call cancelled, show the ring time, not the bill time. $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')) { $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; } } //set an empty content variable $content = ''; //recording playback if (permission_exists('recording_play') && $record_path != '') { $content .= "\n"; } if ($row['raw_data_exists'] && permission_exists('xml_cdr_details')) { $tr_link = "href='xml_cdr_details.php?id=".escape($row['xml_cdr_uuid']).(($_REQUEST['show']) ? "&show=all" : null)."'"; } else { $tr_link = null; } $content .= "\n"; if (permission_exists('xml_cdr_delete')) { $content .= " "; $xml_ids[] = 'checkbox_'.$row['xml_cdr_uuid']; } //determine call result and appropriate icon $content .= "\n"; //extension if (permission_exists('xml_cdr_extension')) { $content .= " \n"; } //domain name if ($_REQUEST['show'] == "all" && permission_exists('xml_cdr_all')) { $content .= " \n"; } //caller id name $content .= " \n"; //source $content .= " \n"; //caller destination if (permission_exists('caller_destination')) { $content .= " \n"; } //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; } } } } $content .= " \n"; //recording if (permission_exists('recording_play') || permission_exists('recording_download')) { if ($record_path != '' && file_exists($record_path.'/'.$record_name)) { $content .= " \n"; } else { $content .= " \n"; } } //dynamic cdr 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") { $content .= " \n"; } } } //start $content .= " \n"; //tta (time to answer) $content .= " \n"; //duration $content .= " \n"; //pdd (post dial delay) if (permission_exists("xml_cdr_pdd")) { $content .= " \n"; } //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']; } $content .= " \n"; } //hangup cause/call result if (permission_exists('hangup_cause')) { $content .= " \n"; } else { $content .= " \n"; } //control icons if (permission_exists('xml_cdr_details')) { $content .= " \n"; } $content .= "\n"; //show the leg b only to those with the permission if ($row['leg'] == 'a') { echo $content; } else if ($row['leg'] == 'b' && permission_exists('xml_cdr_b_leg')) { echo $content; } unset($content); //toggle the color $c = $c ? 0 : 1; } //foreach } //if unset($sql, $result, $row_count); //paging controls echo "\n"; echo "
 ".$text['label-recording']."".$text['label-status'].""; if (permission_exists('xml_cdr_delete') && $result_count > 0) { echo "".$v_link_label_delete.""; } echo "
\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'; } } if (strlen($row['direction']) > 0) { $image_name = "icon_cdr_" . $row['direction'] . "_" . $call_result; if($row['leg'] == 'b') { $image_name .= '_b'; } $image_name .= ".png"; $content .= "\n"; } } else { $content .= " "; } $content .= ""; $content .= $row['extension'].' '; $content .= " "; $content .= $row['domain_name'].' '; $content .= " ".escape(substr($row['caller_id_name'], 0, 20))."  ".escape($row[$field_name])."".escape($tmp_start_epoch)."".(($row['tta'] > 0) ? $row['tta']."s" : " ")."".gmdate("G:i:s", $seconds)."".number_format(escape($row['pdd_ms'])/1000,2)."s$value".escape($hangup_cause)."".ucwords(escape($call_result))."
"; echo "
"; echo "

"; echo $paging_controls; echo "

"; // check or uncheck all checkboxes if (sizeof($xml_ids) > 0) { echo "\n"; } //store last search/sort query parameters in session $_SESSION['xml_cdr']['last_query'] = $_SERVER["QUERY_STRING"]; //show the footer require_once "resources/footer.php"; ?>