mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Add no answer, aloc, and busy to the extension summary.
This commit is contained in:
@@ -26,15 +26,104 @@
|
||||
|
||||
require_once "root.php";
|
||||
require_once "resources/require.php";
|
||||
require_once "resources/check_auth.php";
|
||||
|
||||
if (permission_exists('xml_cdr_view')) {
|
||||
//access granted
|
||||
}
|
||||
else {
|
||||
echo "access denied";
|
||||
exit;
|
||||
}
|
||||
//check permisisions
|
||||
require_once "resources/check_auth.php";
|
||||
if (permission_exists('xml_cdr_view')) {
|
||||
//access granted
|
||||
}
|
||||
else {
|
||||
echo "access denied";
|
||||
exit;
|
||||
}
|
||||
|
||||
//get current extension info
|
||||
$sql = "select ";
|
||||
$sql .= "extension_uuid, ";
|
||||
$sql .= "extension, ";
|
||||
$sql .= "number_alias, ";
|
||||
$sql .= "description ";
|
||||
$sql .= "from ";
|
||||
$sql .= "v_extensions ";
|
||||
$sql .= "where ";
|
||||
$sql .= "enabled = 'true' ";
|
||||
$sql .= "and domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
$sql .= "order by ";
|
||||
$sql .= "extension asc";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
$result_count = count($result);
|
||||
if ($result_count > 0) {
|
||||
foreach($result as $row) {
|
||||
$extensions[$row['extension']]['extension'] = $row['extension'];
|
||||
$extensions[$row['extension']]['extension_uuid'] = $row['extension_uuid'];
|
||||
$extensions[$row['extension']]['number_alias'] = $row['number_alias'];
|
||||
$extensions[$row['extension']]['description'] = $row['description'];
|
||||
}
|
||||
}
|
||||
unset ($sql, $prep_statement, $result, $row_count);
|
||||
// create list of extensions for query below
|
||||
foreach ($extensions as $extension => $blah) {
|
||||
$ext_array[] = $extension;
|
||||
}
|
||||
$ext_list = implode("','", $ext_array);
|
||||
|
||||
//calculate the summary data
|
||||
$sql = "select ";
|
||||
$sql .= "caller_id_number, ";
|
||||
$sql .= "destination_number, ";
|
||||
$sql .= "billsec, ";
|
||||
$sql .= "hangup_cause ";
|
||||
$sql .= "from v_xml_cdr ";
|
||||
$sql .= "where ";
|
||||
$sql .= "domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
$sql .= "and ( ";
|
||||
$sql .= " caller_id_number in ('".$ext_list."') or ";
|
||||
$sql .= " destination_number in ('".$ext_list."') ";
|
||||
$sql .= ") ";
|
||||
if (!$include_internal) {
|
||||
$sql .= " and ( direction = 'inbound' or direction = 'outbound' ) ";
|
||||
}
|
||||
if (strlen($start_stamp_begin) == 0 && strlen($start_stamp_end) == 0) {
|
||||
$sql .= "and start_stamp >= '".date('Y-m-d H:i:s.000', strtotime("-1 week"))."' "; // show last 7 days if no range specified
|
||||
}
|
||||
else if (strlen($start_stamp_begin) > 0 && strlen($start_stamp_end) > 0) { $sql .= " and start_stamp BETWEEN '".$start_stamp_begin.":00.000' AND '".$start_stamp_end.":59.999'"; }
|
||||
else {
|
||||
if (strlen($start_stamp_begin) > 0) { $sql .= " and start_stamp >= '".$start_stamp_begin.":00.000'"; }
|
||||
if (strlen($start_stamp_end) > 0) { $sql .= " and start_stamp <= '".$start_stamp_end.":59.999'"; }
|
||||
}
|
||||
//echo $sql."<br><br>";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
$result_count = count($result);
|
||||
|
||||
if ($result_count > 0) {
|
||||
foreach($result as $row) {
|
||||
if ($summary[$row['destination_number']]['missed'] == null) {
|
||||
$summary[$row['destination_number']]['missed'] = 0;
|
||||
}
|
||||
if (in_array($row['caller_id_number'], $ext_array)) {
|
||||
$summary[$row['caller_id_number']]['outbound']['count']++;
|
||||
$summary[$row['caller_id_number']]['outbound']['seconds'] += $row['billsec'];
|
||||
}
|
||||
if (in_array($row['destination_number'], $ext_array)) {
|
||||
$summary[$row['destination_number']]['inbound']['count']++;
|
||||
$summary[$row['destination_number']]['inbound']['seconds'] += $row['billsec'];
|
||||
if ($row['billsec'] == "0") {
|
||||
$summary[$row['destination_number']]['missed']++;
|
||||
}
|
||||
}
|
||||
if ($row['hangup_cause'] == "NO_ANSWER") {
|
||||
$summary[$row['destination_number']]['no_answer']++;
|
||||
}
|
||||
if ($row['hangup_cause'] == "USER_BUSY") {
|
||||
$summary[$row['destination_number']]['busy']++;
|
||||
}
|
||||
} //end foreach
|
||||
} //end if results
|
||||
unset ($sql, $prep_statement, $result, $row_count);
|
||||
|
||||
//add multi-lingual support
|
||||
require_once "app_languages.php";
|
||||
@@ -45,7 +134,7 @@ else {
|
||||
//additional includes
|
||||
require_once "resources/header.php";
|
||||
|
||||
// retrieve submitted data
|
||||
//retrieve submitted data
|
||||
$start_stamp_begin = check_str($_REQUEST['start_stamp_begin']);
|
||||
$start_stamp_end = check_str($_REQUEST['start_stamp_end']);
|
||||
$include_internal = check_str($_REQUEST['include_internal']);
|
||||
@@ -116,10 +205,8 @@ else {
|
||||
echo " </tr>";
|
||||
echo " <tr>";
|
||||
echo " <td colspan='3' style='padding-top: 8px;' align='right'>";
|
||||
|
||||
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 " </td>";
|
||||
echo " </tr>";
|
||||
echo "</table>";
|
||||
@@ -128,105 +215,60 @@ else {
|
||||
echo "<br /><br />";
|
||||
}
|
||||
|
||||
// get current extension info
|
||||
$sql = "select ";
|
||||
$sql .= "extension_uuid, ";
|
||||
$sql .= "extension, ";
|
||||
$sql .= "number_alias ";
|
||||
$sql .= "from ";
|
||||
$sql .= "v_extensions ";
|
||||
$sql .= "where ";
|
||||
$sql .= "enabled = 'true' ";
|
||||
$sql .= "and domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
$sql .= "order by ";
|
||||
$sql .= "extension asc";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
$result_count = count($result);
|
||||
if ($result_count > 0) {
|
||||
foreach($result as $row) {
|
||||
$extensions[$row['extension']]['extension_uuid'] = $row['extension_uuid'];
|
||||
$extensions[$row['extension']]['number_alias'] = $row['number_alias'];
|
||||
}
|
||||
}
|
||||
unset ($sql, $prep_statement, $result, $row_count);
|
||||
// create list of extensions for query below
|
||||
foreach ($extensions as $extension => $blah) {
|
||||
$ext_array[] = $extension;
|
||||
}
|
||||
$ext_list = implode("','", $ext_array);
|
||||
|
||||
// calculate the summary data
|
||||
$sql = "select ";
|
||||
$sql .= "caller_id_number, ";
|
||||
$sql .= "destination_number, ";
|
||||
$sql .= "billsec ";
|
||||
$sql .= "from ";
|
||||
$sql .= "v_xml_cdr ";
|
||||
$sql .= "where ";
|
||||
$sql .= "domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
$sql .= "and ( ";
|
||||
$sql .= " caller_id_number in ('".$ext_list."') or ";
|
||||
$sql .= " destination_number in ('".$ext_list."') ";
|
||||
$sql .= ") ";
|
||||
if (!$include_internal) {
|
||||
$sql .= " and ( direction = 'inbound' or direction = 'outbound' ) ";
|
||||
}
|
||||
if (strlen($start_stamp_begin) == 0 && strlen($start_stamp_end) == 0) {
|
||||
$sql .= "and start_stamp >= '".date('Y-m-d H:i:s.000', strtotime("-1 week"))."' "; // show last 7 days if no range specified
|
||||
}
|
||||
else if (strlen($start_stamp_begin) > 0 && strlen($start_stamp_end) > 0) { $sql .= " and start_stamp BETWEEN '".$start_stamp_begin.":00.000' AND '".$start_stamp_end.":59.999'"; }
|
||||
else {
|
||||
if (strlen($start_stamp_begin) > 0) { $sql .= " and start_stamp >= '".$start_stamp_begin.":00.000'"; }
|
||||
if (strlen($start_stamp_end) > 0) { $sql .= " and start_stamp <= '".$start_stamp_end.":59.999'"; }
|
||||
}
|
||||
//echo $sql."<br><br>";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
$result_count = count($result);
|
||||
|
||||
if ($result_count > 0) {
|
||||
foreach($result as $row) {
|
||||
if (in_array($row['caller_id_number'], $ext_array)) {
|
||||
$summary[$row['caller_id_number']]['outbound']['count']++;
|
||||
$summary[$row['caller_id_number']]['outbound']['seconds'] += $row['billsec'];
|
||||
}
|
||||
if (in_array($row['destination_number'], $ext_array)) {
|
||||
$summary[$row['destination_number']]['inbound']['count']++;
|
||||
$summary[$row['destination_number']]['inbound']['seconds'] += $row['billsec'];
|
||||
}
|
||||
} //end foreach
|
||||
} //end if results
|
||||
unset ($sql, $prep_statement, $result, $row_count);
|
||||
|
||||
//show the results
|
||||
echo "<table xclass='tr_hover' width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <th>".$text['label-extension']."</th>\n";
|
||||
echo " <th>".$text['label-number_alias']."</th>\n";
|
||||
echo " <th>".$text['label-missed']."</th>\n";
|
||||
echo " <th>".$text['label-no_answer']."</th>\n";
|
||||
echo " <th>".$text['label-busy']."</th>\n";
|
||||
echo " <th>".$text['label-aloc']."</th>\n";
|
||||
echo " <th style='text-align: right;'>".$text['label-inbound_calls']."</th>\n";
|
||||
echo " <th style='text-align: right;'>".$text['label-inbound_duration']."</th>\n";
|
||||
echo " <th style='text-align: right;'>".$text['label-outbound_calls']."</th>\n";
|
||||
echo " <th style='text-align: right;'>".$text['label-outbound_duration']."</th>\n";
|
||||
echo " <th style='text-align: right;'>".$text['label-description']."</th>\n";
|
||||
echo " </tr>\n";
|
||||
|
||||
$c = 0;
|
||||
$row_style["0"] = "row_style0";
|
||||
$row_style["1"] = "row_style1";
|
||||
|
||||
foreach ($extensions as $extension => $ext) {
|
||||
$seconds['inbound'] = $summary[$extension]['inbound']['seconds'];
|
||||
$seconds['outbound'] = $summary[$extension]['outbound']['seconds'];
|
||||
if ($summary[$extension]['missed'] == null) {
|
||||
$summary[$extension]['missed'] = 0;
|
||||
}
|
||||
if ($summary[$extension]['no_answer'] == null) {
|
||||
$summary[$extension]['no_answer'] = 0;
|
||||
}
|
||||
if ($summary[$extension]['busy'] == null) {
|
||||
$summary[$extension]['busy'] = 0;
|
||||
}
|
||||
|
||||
//missed
|
||||
$missed = $summary[$extension]['missed'];
|
||||
|
||||
//volume
|
||||
$volume = $summary[$extension]['inbound']['seconds'] + $summary[$extension]['outbound']['seconds'];
|
||||
|
||||
//average length of call
|
||||
$summary[$extension]['aloc'] = ($seconds['inbound'] + $seconds['outbound']) / ($volume - $missed);
|
||||
|
||||
$tr_link = "xhref='xml_cdr.php?'";
|
||||
echo "<tr ".$tr_link.">\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".$extension."</td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".$ext['number_alias']." </td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".$summary[$extension]['missed']." </td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".$summary[$extension]['no_answer']." </td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".$summary[$extension]['busy']." </td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".$summary[$extension]['aloc']." </td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."' style='text-align: right;'> ".(($summary[$extension]['inbound']['count'] != '') ? $summary[$extension]['inbound']['count'] : "0")."</td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."' style='text-align: right;'>".(($seconds['inbound'] != '') ? gmdate("G:i:s", $seconds['inbound']) : '0:00:00')."</td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."' style='text-align: right;'> ".(($summary[$extension]['outbound']['count'] != '') ? $summary[$extension]['outbound']['count'] : "0")."</td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."' style='text-align: right;'>".(($seconds['outbound'] != '') ? gmdate("G:i:s", $seconds['outbound']) : '0:00:00')."</td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".$ext['description']." </td>\n";
|
||||
echo "</tr>\n";
|
||||
$c = ($c==0) ? 1 : 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user