Add a new dashboard

This commit is contained in:
markjcrane
2021-11-09 18:42:14 -07:00
parent 75e83ff879
commit 032a5aec39
34 changed files with 3249 additions and 20 deletions
@@ -0,0 +1,43 @@
<?php
$array['dashboard'][$x]['dashboard_uuid'] = '6ad0e056-bf3d-465a-956d-bd77d513ab36';
$array['dashboard'][$x]['dashboard_name'] = 'Missed Calls';
$array['dashboard'][$x]['dashboard_path'] = 'app/xml_cdr/resources/dashboard/missed_calls.php';
$array['dashboard'][$x]['dashboard_order'] = '40';
$array['dashboard'][$x]['dashboard_enabled'] = 'true';
$array['dashboard'][$x]['dashboard_description'] = 'Show number and list of calls that were missed.';
$y = 0;
$array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_group_uuid'] = '85573555-7e18-4449-aa59-a264a7addda9';
$array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_uuid'] = '6ad0e056-bf3d-465a-956d-bd77d513ab36';
$array['dashboard'][$x]['dashboard_groups'][$y]['group_name'] = 'superadmin';
$y++;
$array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_group_uuid'] = 'cde35063-58ca-4cdd-94fa-a1c4ee03e66c';
$array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_uuid'] = '6ad0e056-bf3d-465a-956d-bd77d513ab36';
$array['dashboard'][$x]['dashboard_groups'][$y]['group_name'] = 'admin';
$y++;
$array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_group_uuid'] = 'b6e6c697-5351-484c-808d-884589c6d527';
$array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_uuid'] = '6ad0e056-bf3d-465a-956d-bd77d513ab36';
$array['dashboard'][$x]['dashboard_groups'][$y]['group_name'] = 'user';
$x++;
$array['dashboard'][$x]['dashboard_uuid'] = 'c323e296-b1cf-42ea-9c57-fc00697915b7';
$array['dashboard'][$x]['dashboard_name'] = 'Recent Calls';
$array['dashboard'][$x]['dashboard_path'] = 'app/xml_cdr/resources/dashboard/recent_calls.php';
$array['dashboard'][$x]['dashboard_order'] = '60';
$array['dashboard'][$x]['dashboard_enabled'] = 'true';
$array['dashboard'][$x]['dashboard_description'] = 'List of recent calls.';
$y = 0;
$array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_group_uuid'] = '976018d2-ed21-4ccd-a95c-ef7e36c1134e';
$array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_uuid'] = 'c323e296-b1cf-42ea-9c57-fc00697915b7';
$array['dashboard'][$x]['dashboard_groups'][$y]['group_name'] = 'superadmin';
$y++;
$array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_group_uuid'] = '62e53c42-aa15-4a4a-abf0-fb8cd37bafad';
$array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_uuid'] = 'c323e296-b1cf-42ea-9c57-fc00697915b7';
$array['dashboard'][$x]['dashboard_groups'][$y]['group_name'] = 'admin';
$y++;
$array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_group_uuid'] = 'a923b923-f1c9-4244-abfd-132c5a2f5b6e';
$array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_uuid'] = 'c323e296-b1cf-42ea-9c57-fc00697915b7';
$array['dashboard'][$x]['dashboard_groups'][$y]['group_name'] = 'user';
?>
@@ -0,0 +1,144 @@
<?php
//includes
require_once "root.php";
require_once "resources/require.php";
//check permisions
require_once "resources/check_auth.php";
if (permission_exists('xml_cdr_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get($_SESSION['domain']['language']['code'], 'core/user_settings');
//missed calls
//if (is_array($selected_blocks) && in_array('missed', $selected_blocks) && permission_exists('xml_cdr_view') && is_array($_SESSION['user']['extension']) && sizeof($_SESSION['user']['extension']) > 0) {
foreach ($_SESSION['user']['extension'] as $assigned_extension) {
$assigned_extensions[$assigned_extension['extension_uuid']] = $assigned_extension['user'];
}
unset($assigned_extension);
//if also viewing system status, show more recent calls (more room avaialble)
$missed_limit = (is_array($selected_blocks) && in_array('counts', $selected_blocks)) ? 10 : 5;
$sql = "select \n";
$sql .= " direction, \n";
$sql .= " start_stamp, \n";
$sql .= " start_epoch, \n";
$sql .= " caller_id_name, \n";
$sql .= " caller_id_number, \n";
$sql .= " answer_stamp \n";
$sql .= "from \n";
$sql .= " v_xml_cdr \n";
$sql .= "where \n";
$sql .= " domain_uuid = :domain_uuid \n";
$sql .= " and ( \n";
$sql .= " direction = 'inbound' \n";
$sql .= " or direction = 'local' \n";
$sql .= " ) \n";
$sql .= " and (missed_call = true or bridge_uuid is null) ";
if (is_array($assigned_extensions) && sizeof($assigned_extensions) != 0) {
$x = 0;
foreach ($assigned_extensions as $assigned_extension_uuid => $assigned_extension) {
$sql_where_array[] = "extension_uuid = :assigned_extension_uuid_".$x;
$sql_where_array[] = "destination_number = :destination_number_".$x;
$parameters['assigned_extension_uuid_'.$x] = $assigned_extension_uuid;
$parameters['destination_number_'.$x] = $assigned_extension;
$x++;
}
if (is_array($sql_where_array) && sizeof($sql_where_array) != 0) {
$sql .= "and (".implode(' or ', $sql_where_array).") \n";
}
unset($sql_where_array);
}
$sql .= "and start_epoch > ".(time() - 86400)." \n";
$sql .= "order by \n";
$sql .= "start_epoch desc \n";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
//echo $sql;
//view_array($parameters);
$database = new database;
$result = $database->select($sql, $parameters, 'all');
$num_rows = is_array($result) ? sizeof($result) : 0;
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
echo "<span class='hud_title' onclick=\"document.location.href='".PROJECT_PATH."/app/xml_cdr/xml_cdr.php?call_result=missed'\">".$text['label-missed_calls']."</span>";
echo "<span class='hud_stat' onclick=\"$('#hud_missed_calls_details').slideToggle('fast');\">".$num_rows."</span>";
echo "<span class='hud_stat_title' onclick=\"$('#hud_missed_calls_details').slideToggle('fast');\">".$text['label-last_24_hours']."</span>\n";
echo "<div class='hud_details hud_box' id='hud_missed_calls_details'>";
echo "<table class='tr_hover' width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
echo "<tr>\n";
if ($num_rows > 0) {
echo "<th class='hud_heading'>&nbsp;</th>\n";
}
echo "<th class='hud_heading' width='100%'>".$text['label-cid_number']."</th>\n";
echo "<th class='hud_heading'>".$text['label-missed']."</th>\n";
echo "</tr>\n";
if ($num_rows > 0) {
$theme_cdr_images_exist = (
file_exists($theme_image_path."icon_cdr_inbound_voicemail.png") &&
file_exists($theme_image_path."icon_cdr_inbound_cancelled.png") &&
file_exists($theme_image_path."icon_cdr_local_voicemail.png") &&
file_exists($theme_image_path."icon_cdr_local_cancelled.png")
) ? true : false;
foreach($result as $index => $row) {
if ($index + 1 > $missed_limit) { break; } //only show limit
$tmp_year = date("Y", strtotime($row['start_stamp']));
$tmp_month = date("M", strtotime($row['start_stamp']));
$tmp_day = date("d", strtotime($row['start_stamp']));
$tmp_start_epoch = ($_SESSION['domain']['time_format']['text'] == '12h') ? date("n/j g:ia", $row['start_epoch']) : date("n/j H:i", $row['start_epoch']);
//set click-to-call variables
if (permission_exists('click_to_call_call')) {
$tr_link = "onclick=\"send_cmd('".PROJECT_PATH."/app/click_to_call/click_to_call.php".
"?src_cid_name=".urlencode($row['caller_id_name']).
"&src_cid_number=".urlencode($row['caller_id_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($row['caller_id_number']).
"&rec=".(isset($_SESSION['click_to_call']['record']['boolean'])?$_SESSION['click_to_call']['record']['boolean']:"false").
"&ringback=".(isset($_SESSION['click_to_call']['ringback']['text'])?$_SESSION['click_to_call']['ringback']['text']:"us-ring").
"&auto_answer=".(isset($_SESSION['click_to_call']['auto_answer']['boolean'])?$_SESSION['click_to_call']['auto_answer']['boolean']:"true").
"');\" ".
"style='cursor: pointer;'";
}
echo "<tr ".$tr_link.">\n";
echo "<td valign='middle' class='".$row_style[$c]."' style='cursor: help; padding: 0 0 0 6px;'>\n";
if ($theme_cdr_images_exist) {
$call_result = ($row['answer_stamp'] != '') ? 'voicemail' : 'cancelled';
if (isset($row['direction'])) {
echo " <img src='".PROJECT_PATH."/themes/".$_SESSION['domain']['template']['name']."/images/icon_cdr_".$row['direction']."_".$call_result.".png' width='16' style='border: none;' title='".$text['label-'.$row['direction']].": ".$text['label-'.$call_result]."'>\n";
}
}
echo "</td>\n";
echo "<td valign='top' class='".$row_style[$c]." hud_text' nowrap='nowrap'><a href='javascript:void(0);' ".(($row['caller_id_name'] != '') ? "title=\"".$row['caller_id_name']."\"" : null).">".((is_numeric($row['caller_id_number'])) ? format_phone($row['caller_id_number']) : $row['caller_id_number'])."</td>\n";
echo "<td valign='top' class='".$row_style[$c]." hud_text' nowrap='nowrap'>".$tmp_start_epoch."</td>\n";
echo "</tr>\n";
$c = ($c) ? 0 : 1;
}
}
unset($sql, $parameters, $result, $num_rows, $index, $row);
echo "</table>\n";
echo "<span style='display: block; margin: 6px 0 7px 0;'><a href='".PROJECT_PATH."/app/xml_cdr/xml_cdr.php?call_result=missed'>".$text['label-view_all']."</a></span>\n";
echo "</div>";
$n++;
//}
echo " <span class='hud_expander' onclick=\"$('#hud_missed_calls_details').slideToggle('fast');\"><span class='fas fa-ellipsis-h'></span></span>";
?>
@@ -0,0 +1,176 @@
<?php
//includes
require_once "root.php";
require_once "resources/require.php";
//check permisions
require_once "resources/check_auth.php";
if (permission_exists('xml_cdr_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get($_SESSION['domain']['language']['code'], 'core/user_settings');
//recent calls
//if (is_array($selected_blocks) && in_array('recent', $selected_blocks) && permission_exists('xml_cdr_view') && is_array($_SESSION['user']['extension']) && sizeof($_SESSION['user']['extension']) > 0) {
foreach ($_SESSION['user']['extension'] as $assigned_extension) {
$assigned_extensions[$assigned_extension['extension_uuid']] = $assigned_extension['user'];
}
//if also viewing system status, show more recent calls (more room avaialble)
$recent_limit = (is_array($selected_blocks) && in_array('counts', $selected_blocks)) ? 10 : 5;
$sql = "
select
direction,
start_stamp,
start_epoch,
caller_id_name,
caller_id_number,
destination_number,
answer_stamp,
bridge_uuid,
sip_hangup_disposition
from
v_xml_cdr
where
domain_uuid = :domain_uuid ";
if (is_array($assigned_extensions) && sizeof($assigned_extensions) != 0) {
$x = 0;
foreach ($assigned_extensions as $assigned_extension_uuid => $assigned_extension) {
$sql_where_array[] = "extension_uuid = :extension_uuid_".$x;
$sql_where_array[] = "caller_id_number = :caller_id_number_".$x;
$sql_where_array[] = "destination_number = :destination_number_1_".$x;
$sql_where_array[] = "destination_number = :destination_number_2_".$x;
$parameters['extension_uuid_'.$x] = $assigned_extension_uuid;
$parameters['caller_id_number_'.$x] = $assigned_extension;
$parameters['destination_number_1_'.$x] = $assigned_extension;
$parameters['destination_number_2_'.$x] = '*99'.$assigned_extension;
$x++;
}
if (is_array($sql_where_array) && sizeof($sql_where_array) != 0) {
$sql .= "and (".implode(' or ', $sql_where_array).") ";
}
unset($sql_where_array);
}
$sql .= "
and start_epoch > ".(time() - 86400)."
order by
start_epoch desc";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$result = $database->select($sql, $parameters, 'all');
$num_rows = is_array($result) ? sizeof($result) : 0;
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
echo "<span class='hud_title' onclick=\"document.location.href='".PROJECT_PATH."/app/xml_cdr/xml_cdr.php';\">".$text['label-recent_calls']."</span>";
echo "<span class='hud_stat' onclick=\"$('#hud_recent_calls_details').slideToggle('fast');\">".$num_rows."</span>";
echo "<span class='hud_stat_title' onclick=\"$('#hud_recent_calls_details').slideToggle('fast');\">".$text['label-last_24_hours']."</span>\n";
echo "<div class='hud_details hud_box' id='hud_recent_calls_details'>";
echo "<table class='tr_hover' width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
echo "<tr>\n";
if ($num_rows > 0) {
echo "<th class='hud_heading'>&nbsp;</th>\n";
}
echo "<th class='hud_heading' width='100%'>".$text['label-cid_number']."</th>\n";
echo "<th class='hud_heading'>".$text['label-date_time']."</th>\n";
echo "</tr>\n";
if ($num_rows > 0) {
$theme_cdr_images_exist = (
file_exists($theme_image_path."icon_cdr_inbound_answered.png") &&
file_exists($theme_image_path."icon_cdr_inbound_voicemail.png") &&
file_exists($theme_image_path."icon_cdr_inbound_cancelled.png") &&
file_exists($theme_image_path."icon_cdr_inbound_failed.png") &&
file_exists($theme_image_path."icon_cdr_outbound_answered.png") &&
file_exists($theme_image_path."icon_cdr_outbound_cancelled.png") &&
file_exists($theme_image_path."icon_cdr_outbound_failed.png") &&
file_exists($theme_image_path."icon_cdr_local_answered.png") &&
file_exists($theme_image_path."icon_cdr_local_voicemail.png") &&
file_exists($theme_image_path."icon_cdr_local_cancelled.png") &&
file_exists($theme_image_path."icon_cdr_local_failed.png")
) ? true : false;
foreach($result as $index => $row) {
if ($index + 1 > $recent_limit) { break; } //only show limit
$tmp_year = date("Y", strtotime($row['start_stamp']));
$tmp_month = date("M", strtotime($row['start_stamp']));
$tmp_day = date("d", strtotime($row['start_stamp']));
$tmp_start_epoch = ($_SESSION['domain']['time_format']['text'] == '12h') ? date("n/j g:ia", $row['start_epoch']) : date("n/j H:i", $row['start_epoch']);
//determine name
$cdr_name = ($row['direction'] == 'inbound' || ($row['direction'] == 'local' && is_array($assigned_extensions) && in_array($row['destination_number'], $assigned_extensions))) ? $row['caller_id_name'] : $row['destination_number'];
//determine number to display
if ($row['direction'] == 'inbound' || ($row['direction'] == 'local' && is_array($assigned_extensions) && in_array($row['destination_number'], $assigned_extensions))) {
$cdr_number = (is_numeric($row['caller_id_number'])) ? format_phone($row['caller_id_number']) : $row['caller_id_number'];
$dest = $row['caller_id_number'];
}
else if ($row['direction'] == 'outbound' || ($row['direction'] == 'local' && is_array($assigned_extensions) && in_array($row['caller_id_number'], $assigned_extensions))) {
$cdr_number = (is_numeric($row['destination_number'])) ? format_phone($row['destination_number']) : $row['destination_number'];
$dest = $row['destination_number'];
}
//set click-to-call variables
if (permission_exists('click_to_call_call')) {
$tr_link = "onclick=\"send_cmd('".PROJECT_PATH."/app/click_to_call/click_to_call.php".
"?src_cid_name=".urlencode($cdr_name).
"&src_cid_number=".urlencode($cdr_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($dest).
"&rec=".(isset($_SESSION['click_to_call']['record']['boolean'])?$_SESSION['click_to_call']['record']['boolean']:"false").
"&ringback=".(isset($_SESSION['click_to_call']['ringback']['text'])?$_SESSION['click_to_call']['ringback']['text']:"us-ring").
"&auto_answer=".(isset($_SESSION['click_to_call']['auto_answer']['boolean'])?$_SESSION['click_to_call']['auto_answer']['boolean']:"true").
"');\" ".
"style='cursor: pointer;'";
}
echo "<tr ".$tr_link.">\n";
//determine call result and appropriate icon
echo "<td valign='middle' class='".$row_style[$c]."' style='cursor: help; padding: 0 0 0 6px;'>\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 (isset($row['direction'])) {
echo "<img src='".PROJECT_PATH."/themes/".$_SESSION['domain']['template']['name']."/images/icon_cdr_".$row['direction']."_".$call_result.".png' width='16' style='border: none;' title='".$text['label-'.$row['direction']].": ".$text['label-'.$call_result]."'>\n";
}
}
echo "</td>\n";
echo "<td valign='top' class='".$row_style[$c]." hud_text' nowrap='nowrap'><a href='javascript:void(0);' ".(($cdr_name != '') ? "title=\"".$cdr_name."\"" : null).">".$cdr_number."</a></td>\n";
echo "<td valign='top' class='".$row_style[$c]." hud_text' nowrap='nowrap'>".$tmp_start_epoch."</td>\n";
echo "</tr>\n";
unset($cdr_name, $cdr_number);
$c = ($c) ? 0 : 1;
}
}
unset($sql, $parameters, $result, $num_rows, $index, $row);
echo "</table>\n";
echo "<span style='display: block; margin: 6px 0 7px 0;'><a href='".PROJECT_PATH."/app/xml_cdr/xml_cdr.php'>".$text['label-view_all']."</a></span>\n";
echo "</div>";
$n++;
//}
echo " <span class='hud_expander' onclick=\"$('#hud_recent_calls_details').slideToggle('fast');\"><span class='fas fa-ellipsis-h'></span></span>";
?>
+90
View File
@@ -0,0 +1,90 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
// make sure the PATH_SEPARATOR is defined
umask(2);
if (!defined("PATH_SEPARATOR")) {
if (strpos($_ENV["OS"], "Win") !== false) {
define("PATH_SEPARATOR", ";");
} else {
define("PATH_SEPARATOR", ":");
}
}
if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html';
// make sure the document_root is set
$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]);
if(PHP_SAPI == 'cli'){
chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME));
$script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]);
$dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME));
if (file_exists('/project_root.php')) {
$path = '/';
} else {
$i = 1;
$path = '';
while ($i < count($dirs)) {
$path .= '/' . $dirs[$i];
if (file_exists($path. '/project_root.php')) {
break;
}
$i++;
}
}
$_SERVER["DOCUMENT_ROOT"] = $path;
}else{
$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
}
$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
// try to detect if a project path is being used
if (!defined('PROJECT_PATH')) {
if (is_dir($_SERVER["DOCUMENT_ROOT"]. '/fusionpbx')) {
define('PROJECT_PATH', '/fusionpbx');
} elseif (file_exists($_SERVER["DOCUMENT_ROOT"]. '/project_root.php')) {
define('PROJECT_PATH', '');
} else {
$dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME)));
$i = 1;
$path = $_SERVER["DOCUMENT_ROOT"];
while ($i < count($dirs)) {
$path .= '/' . $dirs[$i];
if (file_exists($path. '/project_root.php')) {
break;
}
$i++;
}
if(!file_exists($path. '/project_root.php')){
die("Failed to locate the Project Root by searching for project_root.php please contact support for assistance");
}
$project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path);
define('PROJECT_PATH', $project_path);
}
$_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH);
set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]);
}
?>