Add show all code donated by Chris Black

This commit is contained in:
Mark Crane 2015-03-06 17:15:09 +00:00
parent 0f40019abd
commit 669fb08d4e
9 changed files with 142 additions and 52 deletions

View File

@ -57,6 +57,9 @@
$apps[$x]['permissions'][$y]['name'] = "xml_cdr_mos"; $apps[$x]['permissions'][$y]['name'] = "xml_cdr_mos";
$apps[$x]['permissions'][$y]['groups'][] = "admin"; $apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "xml_cdr_all";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
//schema details //schema details
$y = 0; //table array index $y = 0; //table array index

View File

@ -608,4 +608,13 @@
$text['message-delete']['pt-pt'] = "Remoção Efectuada"; $text['message-delete']['pt-pt'] = "Remoção Efectuada";
$text['message-delete']['fr-fr'] = "Supprimé"; $text['message-delete']['fr-fr'] = "Supprimé";
$text['button-show_all']['en-us'] = "Show All";
$text['button-show_all']['es-cl'] = "Mostrar Todos";
$text['button-show_all']['pt-pt'] = "Mostrar Todos";
$text['button-show_all']['fr-fr'] = "Montrer Tout";
$text['label-domain-name']['en-us'] = "Domain Name";
$text['label-domain-name']['es-cl'] = "Nombre de Dominio";
$text['label-domain-name']['pt-pt'] = "Nome de Domínio";
$text['label-domain-name']['fr-fr'] = "Nom de Domaine";
?> ?>

View File

@ -38,6 +38,7 @@
else { else {
include "root.php"; include "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
require_once "resources/pdo.php";
} }
//set debug //set debug

View File

@ -125,6 +125,9 @@ else {
echo " <table cellpadding='0' cellspacing='0' border='0'>\n"; echo " <table cellpadding='0' cellspacing='0' border='0'>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td style='vertical-align: top;'>\n"; echo " <td style='vertical-align: top;'>\n";
if (permission_exists('xml_cdr_all')) {
echo " <input type='button' class='btn' value='".$text['button-show_all']."' onclick=\"window.location='xml_cdr.php?showall=true';\">\n";
}
if (permission_exists('xml_cdr_search_advanced')) { if (permission_exists('xml_cdr_search_advanced')) {
echo " <input type='button' class='btn' value='".$text['button-advanced_search']."' onclick=\"window.location='xml_cdr_search.php';\">\n"; echo " <input type='button' class='btn' value='".$text['button-advanced_search']."' onclick=\"window.location='xml_cdr_search.php';\">\n";
} }
@ -371,6 +374,12 @@ else {
echo "<th style='width: 30px; text-align: center; padding: 0px;'><input type='checkbox' onchange=\"(this.checked) ? check('all') : check('none');\"></th>"; echo "<th style='width: 30px; text-align: center; padding: 0px;'><input type='checkbox' onchange=\"(this.checked) ? check('all') : check('none');\"></th>";
} }
echo "<th>&nbsp;</th>\n"; echo "<th>&nbsp;</th>\n";
if ($_GET['showall'] && permission_exists('xml_cdr_all')) {
echo th_order_by('domain_name', $text['label-domain-name'], $order_by, $order, null, null, $param);
//echo " <th class='vncell' valign='top' nowrap='nowrap' width='30%'>\n";
//echo " ".$text['label-domain-name']."\n";
//echo " </th>\n";
}
echo th_order_by('caller_id_name', $text['label-cid-name'], $order_by, $order, null, null, $param); echo th_order_by('caller_id_name', $text['label-cid-name'], $order_by, $order, null, null, $param);
echo th_order_by('caller_id_number', $text['label-source'], $order_by, $order, null, null, $param); echo th_order_by('caller_id_number', $text['label-source'], $order_by, $order, null, null, $param);
echo th_order_by('destination_number', $text['label-destination'], $order_by, $order, null, null, $param); echo th_order_by('destination_number', $text['label-destination'], $order_by, $order, null, null, $param);
@ -473,7 +482,14 @@ else {
unset($recording_file_path); unset($recording_file_path);
} }
$tr_link = (if_group("admin") || if_group("superadmin") || if_group("cdr")) ? "href='xml_cdr_details.php?uuid=".$row['uuid']."'" : null; //$tr_link = (if_group("admin") || if_group("superadmin") || if_group("cdr")) ? "href='xml_cdr_details.php?uuid=".$row['uuid']."'" : null;
if ((if_group("admin") || if_group("superadmin") || if_group("cdr")) && $_GET['showall']) {
$tr_link .= "href='xml_cdr_details.php?uuid=".$row['uuid']."&showall=true'";
} elseif (if_group("admin") || if_group("superadmin") || if_group("cdr")) {
$tr_link .= "href='xml_cdr_details.php?uuid=".$row['uuid']."'";
} else {
$tr_link = null;
}
echo "<tr ".$tr_link.">\n"; echo "<tr ".$tr_link.">\n";
if (permission_exists('xml_cdr_delete')) { if (permission_exists('xml_cdr_delete')) {
echo " <td valign='top' class='".$row_style[$c]." tr_link_void' style='text-align: center; vertical-align: middle; padding: 0px;'>"; echo " <td valign='top' class='".$row_style[$c]." tr_link_void' style='text-align: center; vertical-align: middle; padding: 0px;'>";
@ -518,7 +534,11 @@ else {
else { else {
echo " <td class='".$row_style[$c]."'>&nbsp;</td>"; echo " <td class='".$row_style[$c]."'>&nbsp;</td>";
} }
if ($_GET['showall'] && permission_exists('xml_cdr_all')) {
echo " <td valign='top' class='".$row_style[$c]."'>";
echo $row['domain_name'].'&nbsp;';
echo " </td>\n";
}
echo " <td valign='top' class='".$row_style[$c]."'>"; echo " <td valign='top' class='".$row_style[$c]."'>";
echo $row['caller_id_name'].'&nbsp;'; echo $row['caller_id_name'].'&nbsp;';
echo " </td>\n"; echo " </td>\n";
@ -627,7 +647,7 @@ else {
} }
echo " <td valign='top' class='".$row_style[$c]."' nowrap='nowrap'>"; echo " <td valign='top' class='".$row_style[$c]."' nowrap='nowrap'>";
if (if_group("admin") || if_group("superadmin") || if_group("cdr")) { if (if_group("admin") || if_group("superadmin") || if_group("cdr")) {
echo "<a href='xml_cdr_details.php?uuid=".$row['uuid']."'>".$hangup_cause."</a>"; echo "<a $tr_link>".$hangup_cause."</a>";
} }
else { else {
echo $hangup_cause; echo $hangup_cause;
@ -635,7 +655,7 @@ else {
echo " </td>\n"; echo " </td>\n";
if (if_group("admin") || if_group("superadmin") || if_group("cdr")) { if (if_group("admin") || if_group("superadmin") || if_group("cdr")) {
echo " <td class='list_control_icons tr_link_void'>"; echo " <td class='list_control_icons tr_link_void'>";
echo " <a href='xml_cdr_details.php?uuid=".$row['uuid']."' title='".$text['button-view']."'>$v_link_label_view</a>"; echo " <a $tr_link title='".$text['button-view']."'>$v_link_label_view</a>"; //CJB
if (permission_exists('xml_cdr_delete')) { if (permission_exists('xml_cdr_delete')) {
echo "<a href='xml_cdr_delete.php?id[]=".$row['uuid']."&rec[]=".(($recording_file_path != '') ? base64_encode($recording_file_path) : null)."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">".$v_link_label_delete."</a>"; echo "<a href='xml_cdr_delete.php?id[]=".$row['uuid']."&rec[]=".(($recording_file_path != '') ? base64_encode($recording_file_path) : null)."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">".$v_link_label_delete."</a>";
} }

View File

@ -46,8 +46,11 @@ else {
//get the cdr string from the database //get the cdr string from the database
$sql = "select * from v_xml_cdr "; $sql = "select * from v_xml_cdr ";
$sql .= "where domain_uuid = '$domain_uuid' "; if ($_GET['showall'] && permission_exists('xml_cdr_all')) {
$sql .= "and uuid = '$uuid' "; if ($sql_where) { $sql .= "where uuid = '$uuid' "; }
} else {
$sql .= "where uuid = '$uuid' and domain_uuid = '$domain_uuid' ";
}
$row = $db->query($sql)->fetch(); $row = $db->query($sql)->fetch();
$start_stamp = trim($row["start_stamp"]); $start_stamp = trim($row["start_stamp"]);
$xml_string = trim($row["xml"]); $xml_string = trim($row["xml"]);

View File

@ -61,8 +61,11 @@ require_once "resources/require.php";
$sql .= "v_extensions "; $sql .= "v_extensions ";
$sql .= "where "; $sql .= "where ";
$sql .= "enabled = 'true' "; $sql .= "enabled = 'true' ";
if ($_GET['showall'] && permission_exists('xml_cdr_all')) {
$sql .= " ";
} else {
$sql .= "and domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql .= "and domain_uuid = '".$_SESSION['domain_uuid']."' ";
}
if (!(if_group("admin") || if_group("superadmin"))) { if (!(if_group("admin") || if_group("superadmin"))) {
if (count($_SESSION['user']['extension']) > 0) { if (count($_SESSION['user']['extension']) > 0) {
$sql .= "and ("; $sql .= "and (";
@ -109,8 +112,13 @@ require_once "resources/require.php";
$sql .= "hangup_cause "; $sql .= "hangup_cause ";
$sql .= "from v_xml_cdr "; $sql .= "from v_xml_cdr ";
$sql .= "where "; $sql .= "where ";
$sql .= "domain_uuid = '".$_SESSION['domain_uuid']."' "; if ($_GET['showall'] && permission_exists('xml_cdr_all')) {
$sql .= "and ( "; $sql .= " ";
} else {
$sql .= " domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= " and ";
}
$sql .= "( ";
$sql .= " caller_id_number in ('".$ext_list."') or "; $sql .= " caller_id_number in ('".$ext_list."') or ";
$sql .= " destination_number in ('".$ext_list."') "; $sql .= " destination_number in ('".$ext_list."') ";
$sql .= ") "; $sql .= ") ";
@ -260,6 +268,9 @@ require_once "resources/require.php";
echo " </tr>"; echo " </tr>";
echo " <tr>"; echo " <tr>";
echo " <td colspan='4' style='padding-top: 8px;' align='right'>"; echo " <td colspan='4' style='padding-top: 8px;' align='right'>";
if (permission_exists('xml_cdr_all')) {
echo " <input type='button' class='btn' value='".$text['button-show_all']."' onclick=\"window.location='xml_cdr_extension_summary.php?showall=true';\">\n";
}
echo " <input type='button' class='btn' value='".$text['button-reset']."' onclick=\"document.location.href='xml_cdr_extension_summary.php';\">\n"; echo " <input type='button' class='btn' value='".$text['button-reset']."' onclick=\"document.location.href='xml_cdr_extension_summary.php';\">\n";
echo " <input type='submit' class='btn' name='submit' value='".$text['button-update']."'>\n"; echo " <input type='submit' class='btn' name='submit' value='".$text['button-update']."'>\n";
echo " </td>"; echo " </td>";

View File

@ -200,6 +200,9 @@ else {
$param .= "&remote_media_ip=".$remote_media_ip; $param .= "&remote_media_ip=".$remote_media_ip;
$param .= "&network_addr=".$network_addr; $param .= "&network_addr=".$network_addr;
$param .= "&bridge_uuid=".$bridge_uuid; $param .= "&bridge_uuid=".$bridge_uuid;
if ($_GET['showall'] && permission_exists('xml_cdr_all')) {
$param .= "&showall=" . $_GET['showall'];
}
if (isset($order_by)) { if (isset($order_by)) {
$param .= "&order_by=".$order_by."&order=".$order; $param .= "&order_by=".$order_by."&order=".$order;
} }
@ -277,7 +280,16 @@ else {
$sql .= "rtp_audio_in_mos, "; $sql .= "rtp_audio_in_mos, ";
} }
$sql .= "(answer_epoch - start_epoch) as tta "; $sql .= "(answer_epoch - start_epoch) as tta ";
$sql .= "from v_xml_cdr where domain_uuid = '".$domain_uuid."' ".$sql_where; if ($_GET['showall'] && permission_exists('xml_cdr_all')) {
$sql .= ", domain_name ";
}
$sql .= "from v_xml_cdr ";
if ($_GET['showall'] && permission_exists('xml_cdr_all')) {
if ($sql_where) { $sql .= "where "; }
} else {
$sql .= "where domain_uuid = '".$domain_uuid."' ";
}
$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 ($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 ";

View File

@ -47,6 +47,9 @@ else {
echo "<tr>\n"; echo "<tr>\n";
echo " <td width='30%' align='left' valign='top' nowrap='nowrap'><b>".$text['label-call-statistics']."</b></td>\n"; echo " <td width='30%' align='left' valign='top' nowrap='nowrap'><b>".$text['label-call-statistics']."</b></td>\n";
echo " <td width='70%' align='right' valign='top'>\n"; echo " <td width='70%' align='right' valign='top'>\n";
if (permission_exists('xml_cdr_all')) {
echo " <input type='button' class='btn' value='".$text['button-show_all']."' onclick=\"window.location='xml_cdr_statistics.php?showall=true';\">\n";
}
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='xml_cdr.php'\" value='".$text['button-back']."'>\n"; echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='xml_cdr.php'\" value='".$text['button-back']."'>\n";
echo " <input type='button' class='btn' value='".$text['button-extension_summary']."' onclick=\"document.location.href='xml_cdr_extension_summary.php';\">\n"; echo " <input type='button' class='btn' value='".$text['button-extension_summary']."' onclick=\"document.location.href='xml_cdr_extension_summary.php';\">\n";
echo " <input type='button' class='btn' value='".$text['button-download_csv']."' onclick=\"document.location.href='xml_cdr_statistics_csv.php';\">\n"; echo " <input type='button' class='btn' value='".$text['button-download_csv']."' onclick=\"document.location.href='xml_cdr_statistics_csv.php';\">\n";

View File

@ -57,8 +57,12 @@ else {
} }
else { else {
//superadmin or admin //superadmin or admin
if ($_GET['showall'] && permission_exists('xml_cdr_all')) {
$sql_where = "";
} else {
$sql_where = "where domain_uuid = '$domain_uuid' "; $sql_where = "where domain_uuid = '$domain_uuid' ";
} }
}
//create the sql query to get the xml cdr records //create the sql query to get the xml cdr records
if (strlen($order_by) == 0) { $order_by = "start_epoch"; } if (strlen($order_by) == 0) { $order_by = "start_epoch"; }
@ -74,11 +78,15 @@ else {
function get_call_volume_between($start, $end, $where) { function get_call_volume_between($start, $end, $where) {
global $db; global $db;
if (strlen($where) == 0) { if (strlen($where) == 0) {
if ($_GET['showall'] && permission_exists('xml_cdr_all')) {
$where = "where ";
} else {
$where = "where domain_uuid = '".$_SESSION['domain_uuid']."' "; $where = "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
} }
}
$sql = " select count(*) as count from v_xml_cdr "; $sql = " select count(*) as count from v_xml_cdr ";
$sql .= $where; $sql .= $where;
$sql .= "and start_epoch BETWEEN ".$start." AND ".$end." "; $sql .= " start_epoch BETWEEN ".$start." AND ".$end." ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
@ -98,11 +106,15 @@ else {
function get_call_seconds_between($start, $end, $where) { function get_call_seconds_between($start, $end, $where) {
global $db; global $db;
if (strlen($where) == 0) { if (strlen($where) == 0) {
if ($_GET['showall'] && permission_exists('xml_cdr_all')) {
$where .= "where ";
} else {
$where = "where domain_uuid = '".$_SESSION['domain_uuid']."' "; $where = "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
} }
}
$sql = " select sum(billsec) as seconds from v_xml_cdr "; $sql = " select sum(billsec) as seconds from v_xml_cdr ";
$sql .= $where; $sql .= $where;
$sql .= "and start_epoch BETWEEN ".$start." AND ".$end." "; $sql .= "start_epoch BETWEEN ".$start." AND ".$end." ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
@ -145,8 +157,12 @@ else {
$stats[$i]['avg_min'] = ($stats[$i]['volume'] - $stats[$i]['missed']) / 60; $stats[$i]['avg_min'] = ($stats[$i]['volume'] - $stats[$i]['missed']) / 60;
//answer / seizure ratio //answer / seizure ratio
$where = "where domain_uuid = '".$_SESSION['domain_uuid']."' "; if ($_GET['showall'] && permission_exists('xml_cdr_all')) {
$where .= "and billsec = '0' "; $where .= "where ";
} else {
$where = "where domain_uuid = '".$_SESSION['domain_uuid']."' and ";
}
$where .= "billsec = '0' ";
$where .= "and direction = 'inbound' "; $where .= "and direction = 'inbound' ";
$stats[$i]['missed'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $where); $stats[$i]['missed'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $where);
$stats[$i]['asr'] = (($stats[$i]['volume'] - $stats[$i]['missed']) / ($stats[$i]['volume']) * 100); $stats[$i]['asr'] = (($stats[$i]['volume'] - $stats[$i]['missed']) / ($stats[$i]['volume']) * 100);
@ -169,8 +185,12 @@ else {
$stats[$i]['minutes'] = $stats[$i]['seconds'] / 60; $stats[$i]['minutes'] = $stats[$i]['seconds'] / 60;
$stats[$i]['avg_sec'] = $stats[$i]['seconds'] / $stats[$i]['volume']; $stats[$i]['avg_sec'] = $stats[$i]['seconds'] / $stats[$i]['volume'];
$stats[$i]['avg_min'] = ($stats[$i]['volume'] - $stats[$i]['missed']) / (60*24); $stats[$i]['avg_min'] = ($stats[$i]['volume'] - $stats[$i]['missed']) / (60*24);
$where = "where domain_uuid = '".$_SESSION['domain_uuid']."' "; if ($_GET['showall'] && permission_exists('xml_cdr_all')) {
$where .= "and billsec = '0' "; $where .= "where ";
} else {
$where = "where domain_uuid = '".$_SESSION['domain_uuid']."' and ";
}
$where .= "billsec = '0' ";
$where .= "and direction = 'inbound' "; $where .= "and direction = 'inbound' ";
$stats[$i]['missed'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $where); $stats[$i]['missed'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $where);
$stats[$i]['asr'] = (($stats[$i]['volume'] - $stats[$i]['missed']) / ($stats[$i]['volume']) * 100); $stats[$i]['asr'] = (($stats[$i]['volume'] - $stats[$i]['missed']) / ($stats[$i]['volume']) * 100);
@ -190,8 +210,12 @@ else {
$stats[$i]['minutes'] = $stats[$i]['seconds'] / 60; $stats[$i]['minutes'] = $stats[$i]['seconds'] / 60;
$stats[$i]['avg_sec'] = $stats[$i]['seconds'] / $stats[$i]['volume']; $stats[$i]['avg_sec'] = $stats[$i]['seconds'] / $stats[$i]['volume'];
$stats[$i]['avg_min'] = ($stats[$i]['volume'] - $stats[$i]['missed']) / (60*24*7); $stats[$i]['avg_min'] = ($stats[$i]['volume'] - $stats[$i]['missed']) / (60*24*7);
$where = "where domain_uuid = '".$_SESSION['domain_uuid']."' "; if ($_GET['showall'] && permission_exists('xml_cdr_all')) {
$where .= "and billsec = '0' "; $where .= "where ";
} else {
$where = "where domain_uuid = '".$_SESSION['domain_uuid']."' and ";
}
$where .= "billsec = '0' ";
$where .= "and direction = 'inbound' "; $where .= "and direction = 'inbound' ";
$stats[$i]['missed'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $where); $stats[$i]['missed'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $where);
$stats[$i]['asr'] = (($stats[$i]['volume'] - $stats[$i]['missed']) / ($stats[$i]['volume']) * 100); $stats[$i]['asr'] = (($stats[$i]['volume'] - $stats[$i]['missed']) / ($stats[$i]['volume']) * 100);
@ -211,8 +235,12 @@ else {
$stats[$i]['minutes'] = $stats[$i]['seconds'] / 60; $stats[$i]['minutes'] = $stats[$i]['seconds'] / 60;
$stats[$i]['avg_sec'] = $stats[$i]['seconds'] / $stats[$i]['volume']; $stats[$i]['avg_sec'] = $stats[$i]['seconds'] / $stats[$i]['volume'];
$stats[$i]['avg_min'] = ($stats[$i]['volume'] - $stats[$i]['missed']) / (60*24*30); $stats[$i]['avg_min'] = ($stats[$i]['volume'] - $stats[$i]['missed']) / (60*24*30);
$where = "where domain_uuid = '".$_SESSION['domain_uuid']."' "; if ($_GET['showall'] && permission_exists('xml_cdr_all')) {
$where .= "and billsec = '0' "; $where .= "where ";
} else {
$where = "where domain_uuid = '".$_SESSION['domain_uuid']."' and";
}
$where .= " billsec = '0' ";
$where .= "and direction = 'inbound' "; $where .= "and direction = 'inbound' ";
$stats[$i]['missed'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $where); $stats[$i]['missed'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $where);
$stats[$i]['asr'] = (($stats[$i]['volume'] - $stats[$i]['missed']) / ($stats[$i]['volume']) * 100); $stats[$i]['asr'] = (($stats[$i]['volume'] - $stats[$i]['missed']) / ($stats[$i]['volume']) * 100);