Update xml_cdr.php

This commit is contained in:
FusionPBX 2019-05-24 19:54:27 -06:00 committed by GitHub
parent eb56801239
commit de8dfb3a9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 441 additions and 506 deletions

View File

@ -205,7 +205,6 @@
echo " </select>\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td class='vncell' valign='top' nowrap='nowrap'>\n";
echo " ".$text['label-status']."\n";
@ -374,6 +373,7 @@
echo "<th style='width: 30px; text-align: center; padding: 0px;'><input type='checkbox' id='chk_all' onchange=\"(this.checked) ? check('all') : check('none');\"></th>";
$col_count++;
}
//column headings
echo "<th>&nbsp;</th>\n";
if (permission_exists('xml_cdr_extension')) {
@ -407,10 +407,6 @@
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 "<th>".$text['label-price']."</th>\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++;
@ -435,13 +431,8 @@
}
echo "</tr>\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;
}
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,6 +449,7 @@
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']));
@ -579,7 +571,8 @@
$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) {
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);
@ -587,6 +580,7 @@
}
}
}
}
$content .= " <td valign='top' class='".$row_style[$c]." tr_link_void' nowrap='nowrap'>";
$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";
@ -599,6 +593,7 @@
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";
}
@ -650,67 +645,6 @@
$content .= " <td valign='top' class='".$row_style[$c]."' style='text-align: right;'>".(($row['tta'] > 0) ? $row['tta']."s" : "&nbsp;")."</td>\n";
//duration
$content .= " <td valign='top' class='".$row_style[$c]."' style='text-align: center;'>".gmdate("G:i:s", $seconds)."</td>\n";
//billing
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/billing/app_config.php")){
$database->table = "v_xml_cdr";
$accountcode = (strlen($row["accountcode"])?$row["accountcode"]:$_SESSION[domain_name]);
$database->sql = "SELECT currency FROM v_billings WHERE type_value='$accountcode'";
$database->result = $database->execute();
$billing_currency = (strlen($database->result[0]['currency'])?$database->result[0]['currency']:'USD');
$billing_currency = (strlen($database->result[0]['currency'])?$database->result[0]['currency']:
(strlen($_SESSION['billing']['currency']['text'])?$_SESSION['billing']['currency']['text']:'USD')
);
unset($database->sql);
unset($database->result);
$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 "<pre>"; print $database->sql . ":";print "[".$database->result[0]['currency']."]"; print_r($array); print "</pre>";
$lcr_currency = ((is_string($database->result[0]['currency']) && strlen($database->result[0]['currency']))?$database->result[0]['currency']:
(strlen($_SESSION['billing']['currency']['text'])?$_SESSION['billing']['currency']['text']:'USD')
); //billed currency
unset($database->sql);
unset($database->result);
if ($sell_price){
$price = currency_convert($sell_price, $billing_currency, $lcr_currency);
}
else {
$price = 0;
}
$content .= " <td valign='top' class='".$row_style[$c]."'>".number_format($price,6)." $billing_currency</td>\n";
unset ($sell_price, $price);
}
//pdd (post dial delay)
if (permission_exists("xml_cdr_pdd")) {
$content .= " <td valign='top' class='".$row_style[$c]."' style='text-align: right;'>".number_format(escape($row['pdd_ms'])/1000,2)."s</td>\n";
@ -734,7 +668,7 @@
if (permission_exists('xml_cdr_details')) {
$content .= " <td class='list_control_icons tr_link_void' nowrap='nowrap'>";
if ($tr_link!=null) {
$content .= " <a $tr_link title='".$text['button-view']."'>$v_link_label_view</a>"; //CJB
$content .= " <a $tr_link title='".$text['button-view']."'>$v_link_label_view</a>";
}
if (permission_exists('xml_cdr_delete')) {
$content .= "<a href='xml_cdr_delete.php?id[]=".escape($row['xml_cdr_uuid'])."&rec[]=".(($record_path != '') ? base64_encode($record_path.'/'.$record_name) : null)."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">".$v_link_label_delete."</a>";
@ -756,8 +690,9 @@
$c = ($c) ? 0 : 1;
} //end foreach
unset($sql, $result, $row_count);
} //end if results
} //end foreach
//paging controls
echo "<tr>\n";
echo "</table>";
echo "</form>";