Update xml_cdr_inc.php

This commit is contained in:
FusionPBX 2019-01-30 08:36:37 -07:00 committed by GitHub
parent 5c6178b5a4
commit 29bf914dcb
1 changed files with 36 additions and 35 deletions

View File

@ -356,67 +356,68 @@
$offset = $rows_per_page * $page; $offset = $rows_per_page * $page;
//get the results from the db //get the results from the db
$sql = "select "; $sql = "select \n";
$sql .= "domain_uuid, "; $sql .= "c.domain_uuid, \n";
$sql .= "start_stamp, "; $sql .= "e.extension, \n";
$sql .= "end_stamp, "; $sql .= "c.start_stamp, \n";
$sql .= "start_epoch, "; $sql .= "c.end_stamp, \n";
$sql .= "hangup_cause, "; $sql .= "c.start_epoch, \n";
$sql .= "duration, "; $sql .= "c.hangup_cause, \n";
$sql .= "billmsec, "; $sql .= "c.duration, \n";
$sql .= "record_path, "; $sql .= "c.billmsec, \n";
$sql .= "record_name, "; $sql .= "c.record_path, \n";
$sql .= "xml_cdr_uuid, "; $sql .= "c.record_name, \n";
$sql .= "bridge_uuid, "; $sql .= "c.xml_cdr_uuid, \n";
$sql .= "direction, "; $sql .= "c.bridge_uuid, \n";
$sql .= "billsec, "; $sql .= "c.direction, \n";
$sql .= "caller_id_name, "; $sql .= "c.billsec, \n";
$sql .= "caller_id_number, "; $sql .= "c.caller_id_name, \n";
$sql .= "caller_destination, "; $sql .= "c.caller_id_number, \n";
$sql .= "source_number, "; $sql .= "c.caller_destination, \n";
$sql .= "destination_number, "; $sql .= "c.source_number, \n";
$sql .= "leg, "; $sql .= "c.destination_number, \n";
$sql .= "(xml IS NOT NULL OR json IS NOT NULL) AS raw_data_exists, "; $sql .= "c.leg, \n";
$sql .= "(c.xml IS NOT NULL OR c.json IS NOT NULL) AS raw_data_exists, \n";
if (is_array($_SESSION['cdr']['field'])) { if (is_array($_SESSION['cdr']['field'])) {
foreach ($_SESSION['cdr']['field'] as $field) { foreach ($_SESSION['cdr']['field'] as $field) {
$array = explode(",", $field); $array = explode(",", $field);
$field_name = end($array); $field_name = end($array);
$sql .= $field_name.", "; $sql .= $field_name.", \n";
} }
} }
if (is_array($_SESSION['cdr']['export'])) { if (is_array($_SESSION['cdr']['export'])) {
foreach ($_SESSION['cdr']['export'] as $field) { foreach ($_SESSION['cdr']['export'] as $field) {
$sql .= $field.", "; $sql .= $field.", \n";
} }
} }
$sql .= "accountcode, "; $sql .= "c.accountcode, \n";
$sql .= "answer_stamp, "; $sql .= "c.answer_stamp, \n";
$sql .= "sip_hangup_disposition, "; $sql .= "c.sip_hangup_disposition, \n";
if (permission_exists("xml_cdr_pdd")) { if (permission_exists("xml_cdr_pdd")) {
$sql .= "pdd_ms, "; $sql .= "c.pdd_ms, \n";
} }
if (permission_exists("xml_cdr_mos")) { if (permission_exists("xml_cdr_mos")) {
$sql .= "rtp_audio_in_mos, "; $sql .= "c.rtp_audio_in_mos, \n";
} }
$sql .= "(answer_epoch - start_epoch) as tta "; $sql .= "(c.answer_epoch - c.start_epoch) as tta ";
if ($_REQUEST['show'] == "all" && permission_exists('xml_cdr_all')) { if ($_REQUEST['show'] == "all" && permission_exists('xml_cdr_all')) {
$sql .= ", domain_name "; $sql .= ", c.domain_name \n";
} }
$sql .= "from v_xml_cdr "; $sql .= "from v_xml_cdr as c, v_extensions as e \n";
if ($_REQUEST['show'] == "all" && permission_exists('xml_cdr_all')) { if ($_REQUEST['show'] == "all" && permission_exists('xml_cdr_all')) {
if ($sql_where) { $sql .= "where "; } if ($sql_where) { $sql .= "where "; }
} else { } else {
$sql .= "where domain_uuid = '".$domain_uuid."' "; $sql .= "where c.domain_uuid = '".$domain_uuid."' \n";
} }
$sql .= "and c.extension_uuid = e.extension_uuid \n";
$sql .= $sql_where; $sql .= $sql_where;
if (strlen($order_by)> 0) { $sql .= " order by ".$order_by." ".$order." "; } if (strlen($order_by)> 0) { $sql .= " order by ".$order_by." ".$order." "; }
if ($_REQUEST['export_format'] != "csv" && $_REQUEST['export_format'] != "pdf") { if ($_REQUEST['export_format'] != "csv" && $_REQUEST['export_format'] != "pdf") {
if ($rows_per_page == 0) { if ($rows_per_page == 0) {
$sql .= " limit ".$_SESSION['cdr']['limit']['numeric']." offset 0 "; $sql .= " limit ".$_SESSION['cdr']['limit']['numeric']." offset 0 \n";
} }
else { else {
$sql .= " limit ".$rows_per_page." offset ".$offset." "; $sql .= " limit ".$rows_per_page." offset ".$offset." \n";
} }
} }
$sql= str_replace(" ", " ", $sql); $sql= str_replace(" ", " ", $sql);