From fa3d83d0a1533448173639a22c33c71cc1d4ffbf Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Fri, 24 May 2019 19:54:27 -0600 Subject: [PATCH] Update xml_cdr.php --- app/xml_cdr/xml_cdr.php | 947 +++++++++++++++++++--------------------- 1 file changed, 441 insertions(+), 506 deletions(-) diff --git a/app/xml_cdr/xml_cdr.php b/app/xml_cdr/xml_cdr.php index 29d145cd66..7880d40241 100644 --- a/app/xml_cdr/xml_cdr.php +++ b/app/xml_cdr/xml_cdr.php @@ -182,184 +182,183 @@ echo "\n"; echo "\n"; - //basic search of call detail records - if (permission_exists('xml_cdr_search')) { +//basic search of call detail records + if (permission_exists('xml_cdr_search')) { - echo "
\n"; + 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"; - echo ""; - echo ""; - echo ""; - - // show hangup clause filter to super/admin - echo ""; - - echo ""; - echo "
\n"; - - echo "\n"; - echo " \n"; + echo " \n"; + if (permission_exists('hangup_cause')) { echo " \n"; echo " \n"; echo " \n"; - - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo " ".$text['label-direction']."\n"; + echo " ".$text['label-hangup_cause']."\n"; echo " \n"; - echo " \n"; echo " \n"; - echo " \n"; - echo " \n"; - echo " \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 " \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 "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + } + echo "
"; - echo $text['description_search']; - echo ""; - if (permission_exists('xml_cdr_all') && $_REQUEST['show'] == 'all') { - echo "\n"; } - echo "\n"; - echo "\n"; + if (permission_exists('caller_destination')) { + echo "
\n"; + echo " ".$text['label-caller_destination']."\n"; + echo " \n"; + echo " \n"; + echo "
\n"; - echo "
"; + echo ""; - echo "
"; - echo "

"; + echo ""; + 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 '&' @@ -374,74 +373,66 @@ 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 "".$text['label-recording']."\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 (file_exists($_SERVER["PROJECT_ROOT"]."/app/billing/app_config.php")){ - echo "".$text['label-price']."\n"; - $col_count++; - } - 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 "".$text['label-status']."\n"; - } - if (if_group("admin") || if_group("superadmin") || if_group("cdr")) { - echo ""; - if (permission_exists('xml_cdr_delete') && $result_count > 0) { - echo "".$v_link_label_delete.""; - } - echo "\n"; - $col_count++; - } - echo "\n"; - if (file_exists($_SERVER["PROJECT_ROOT"]."/app/billing/app_config.php")){ - require_once "app/billing/resources/functions/rating.php"; - require_once "resources/classes/database.php"; - $database = new database; +//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 "".$text['label-recording']."\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 "".$text['label-status']."\n"; + } + if (if_group("admin") || if_group("superadmin") || if_group("cdr")) { + echo ""; + if (permission_exists('xml_cdr_delete') && $result_count > 0) { + echo "".$v_link_label_delete.""; + } + echo "\n"; + $col_count++; + } + echo "\n"; - if ($result_count > 0) { +//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 = ( @@ -458,306 +449,250 @@ file_exists($theme_image_path."icon_cdr_local_failed.png") ) ? true : false; - 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']); + // 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); + //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); + //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 .= " "; - $content .= " "; - $content .= " "; - $content .= " "; - $xml_ids[] = 'checkbox_'.$row['xml_cdr_uuid']; - } - - //determine call result and appropriate icon - $content .= "\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'; + //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; } - $image_name .= ".png"; - $content .= "\n"; } - } - else { $content .= " "; } - $content .= "\n"; - //extension - if (permission_exists('xml_cdr_extension')) { - $content .= " "; - $content .= $row['extension'].' '; - $content .= " \n"; - } - //domain name - if ($_REQUEST['show'] == "all" && permission_exists('xml_cdr_all')) { - $content .= " "; - $content .= $row['domain_name'].' '; - $content .= " \n"; - } - //caller id name - $content .= " ".escape(substr($row['caller_id_name'], 0, 20))." \n"; - //source - $content .= " "; - $content .= " \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 .= " "; - $content .= " \n"; - //caller destination - if (permission_exists('caller_destination')) { - $content .= " "; - $content .= " \n"; - if (is_numeric($row['caller_destination'])) { - $content .= " ".format_phone(escape(substr($row['caller_destination'], 0, 20))).' '; + + //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 { - $content .= " ".escape(substr($row['caller_destination'], 0, 20)).' '; + $tr_link = null; + } + $content .= "\n"; + if (permission_exists('xml_cdr_delete')) { + $content .= " "; + $content .= " "; + $content .= " "; + $content .= " "; + $xml_ids[] = 'checkbox_'.$row['xml_cdr_uuid']; + } + + //determine call result and appropriate icon + $content .= "\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 .= "\n"; + //extension + if (permission_exists('xml_cdr_extension')) { + $content .= " "; + $content .= $row['extension'].' '; + $content .= " \n"; + } + //domain name + if ($_REQUEST['show'] == "all" && permission_exists('xml_cdr_all')) { + $content .= " "; + $content .= $row['domain_name'].' '; + $content .= " \n"; + } + //caller id name + $content .= " ".escape(substr($row['caller_id_name'], 0, 20))." \n"; + //source + $content .= " "; + $content .= " \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 .= " "; $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; - 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; + //caller destination + if (permission_exists('caller_destination')) { + $content .= " "; + $content .= " \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)).' '; + } + $content .= " "; + $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; + 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 .= " "; - $content .= " \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"; - } - } - else { - if ($remove_prefix == 'true') { - $content .= substr(format_phone(escape(substr($row['destination_number'], 0, 20))),strlen($prefix))."\n"; + $content .= " "; + $content .= " \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"; } - } - $content .= " \n"; - $content .= " \n"; - //recording - if (permission_exists('recording_play') || permission_exists('recording_download')) { - if ($record_path != '' && file_exists($record_path.'/'.$record_name)) { - $content .= " "; - if (permission_exists('recording_play')) { - $content .= ""; - $content .= "".$v_link_label_play.""; + } + else { + 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"; + } + } + $content .= " \n"; + $content .= " \n"; + //recording + if (permission_exists('recording_play') || permission_exists('recording_download')) { + if ($record_path != '' && file_exists($record_path.'/'.$record_name)) { + $content .= " "; + if (permission_exists('recording_play')) { + $content .= ""; + $content .= "".$v_link_label_play.""; + } + else { + //needs a translation + $content .= "Don't have recording_play permission "; + } + if (permission_exists('recording_download')) { + $content .= "".$v_link_label_download.""; + } + $content .= " \n"; } else { - //needs a translation - $content .= "Don't have recording_play permission "; + $content .= "  \n"; } - if (permission_exists('recording_download')) { - $content .= "".$v_link_label_download.""; + } + //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 .= " ".escape($row[$field_name])."\n"; + } + } + } + //start + $content .= " ".escape($tmp_start_epoch)."\n"; + //tta (time to answer) + $content .= " ".(($row['tta'] > 0) ? $row['tta']."s" : " ")."\n"; + //duration + $content .= " ".gmdate("G:i:s", $seconds)."\n"; + //pdd (post dial delay) + if (permission_exists("xml_cdr_pdd")) { + $content .= " ".number_format(escape($row['pdd_ms'])/1000,2)."s\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 .= " $value\n"; + } + //hangup cause/call result + if (permission_exists('hangup_cause')) { + $content .= " ".escape($hangup_cause)."\n"; + } + else { + $content .= " ".ucwords(escape($call_result))."\n"; + } + //control icons + if (permission_exists('xml_cdr_details')) { + $content .= " "; + if ($tr_link!=null) { + $content .= " $v_link_label_view"; + } + if (permission_exists('xml_cdr_delete')) { + $content .= "".$v_link_label_delete.""; } $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 .= " ".escape($row[$field_name])."\n"; - } - } - } - //start - $content .= " ".escape($tmp_start_epoch)."\n"; - //tta (time to answer) - $content .= " ".(($row['tta'] > 0) ? $row['tta']."s" : " ")."\n"; - //duration - $content .= " ".gmdate("G:i:s", $seconds)."\n"; - //billing - if (file_exists($_SERVER["PROJECT_ROOT"]."/app/billing/app_config.php")){ + $content .= "\n"; - $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); + //show the leg b only to those with the permission + if ($row['leg'] == 'a') { + echo $content; + } + elseif ($row['leg'] == 'b' && permission_exists('xml_cdr_b_leg')) { + echo $content; + } + unset($content); - $sell_price = strlen($row['call_sell'])?$row['call_sell']:0; - $lcr_direction = (strlen($row['direction'])?$row['direction']:"outbound"); - - $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) { - $content .= $e->getMessage(); - } - - $n = (($lcr_direction == "inbound")? - check_str(urldecode($array["caller_profile"]["caller_id_number"])): - check_str(urldecode($array["variables"]["lcr_query_digits"])) - ); - - $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 "
"; print $database->sql . ":";print "[".$database->result[0]['currency']."]"; print_r($array); print "
"; - - $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); - } - else { - $price = 0; - } - $content .= " ".number_format($price,6)." $billing_currency\n"; - unset ($sell_price, $price); - } - //pdd (post dial delay) - if (permission_exists("xml_cdr_pdd")) { - $content .= " ".number_format(escape($row['pdd_ms'])/1000,2)."s\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 .= " $value\n"; - } - //hangup cause/call result - if (permission_exists('hangup_cause')) { - $content .= " ".escape($hangup_cause)."\n"; - } - else { - $content .= " ".ucwords(escape($call_result))."\n"; - } - //control icons - if (permission_exists('xml_cdr_details')) { - $content .= " "; - if ($tr_link!=null) { - $content .= " $v_link_label_view"; //CJB - } - if (permission_exists('xml_cdr_delete')) { - $content .= "".$v_link_label_delete.""; - } - $content .= " \n"; - } - $content .= "\n"; - - //show the leg b only to those with the permission - if ($row['leg'] == 'a') { - echo $content; - } - elseif ($row['leg'] == 'b' && permission_exists('xml_cdr_b_leg')) { - echo $content; - } - unset($content); - - //toggle the color - $c = ($c) ? 0 : 1; - } //end foreach - unset($sql, $result, $row_count); - } //end if results + //toggle the color + $c = ($c) ? 0 : 1; + } //end foreach + unset($sql, $result, $row_count); + } //end foreach +//paging controls echo "\n"; echo ""; echo ""; @@ -765,7 +700,7 @@ echo $paging_controls; echo "

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