\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 "