From 98d5e4fd6754807b182b34905381e15b25c10829 Mon Sep 17 00:00:00 2001 From: Alex <40072887+alexdcrane@users.noreply.github.com> Date: Mon, 13 May 2024 13:20:33 -0700 Subject: [PATCH] Dashboard - Added chart cutout and text size default settings (#6976) --- .../dashboard/call_center_agents.php | 20 ++++++------ .../resources/dashboard/device_keys.php | 32 +++++++++---------- .../resources/dashboard/voicemails.php | 4 +-- .../resources/dashboard/missed_calls.php | 4 +-- .../resources/dashboard/recent_calls.php | 4 +-- core/dashboard/dashboard_edit.php | 18 +++++++++-- core/dashboard/index.php | 20 ++++-------- themes/default/app_config.php | 16 ++++++++++ 8 files changed, 71 insertions(+), 47 deletions(-) diff --git a/app/call_centers/resources/dashboard/call_center_agents.php b/app/call_centers/resources/dashboard/call_center_agents.php index 18fa2f2782..e8178fee7f 100644 --- a/app/call_centers/resources/dashboard/call_center_agents.php +++ b/app/call_centers/resources/dashboard/call_center_agents.php @@ -42,8 +42,8 @@ $text = $language->get($_SESSION['domain']['language']['code'], 'app/call_centers'); //get http variables and set as php variables - $order_by = $_GET["order_by"]; - $order = $_GET["order"]; + $order_by = $_GET["order_by"] ?? null; + $order = $_GET["order"] ?? null; //connect to the database if (!isset($database)) { @@ -119,7 +119,7 @@ $cmd = "callcenter_config tier del ".$row['queue_extension']."@".$_SESSION['domain_name']." ".$row['id']; $response = event_socket::api($cmd); } - + //small sleep usleep(200); } @@ -164,8 +164,8 @@ } //get the agent details from event socket - $switch_cmd = 'callcenter_config agent list '.$agent['call_center_agent_uuid']; - $event_socket_str = trim(event_socket_request($fp, 'api '.$switch_cmd)); + $switch_cmd = 'callcenter_config agent list '.($agent['call_center_agent_uuid'] ?? null); + $event_socket_str = trim(event_socket_request($fp ?? null, 'api '.$switch_cmd)); $call_center_agent = csv_to_named_array($event_socket_str, '|'); //set the agent status @@ -173,7 +173,7 @@ //update the queue status $x = 0; - if (is_array($call_center_queues)) { + if (!empty($call_center_queues) && is_array($call_center_queues)) { foreach ($call_center_queues as $queue) { $call_center_queues[$x]['queue_status'] = 'Logged Out'; foreach ($call_center_tiers as $tier) { @@ -228,7 +228,7 @@ //echo " radio_checked_value = 'Logged Out';\n"; //echo " }\n"; echo " if (radio_button.checked) { console.log('checked: '+radio_button.value) }\n"; - echo " if (radio_button.value === 'Available' && agent_status === 'Available') {\n"; // radio_checked_value == 'On Break' && + echo " if (radio_button.value === 'Available' && agent_status === 'Available') {\n"; // radio_checked_value == 'On Break' && //echo " radio_button.checked = true;\n"; //echo " radio_button.value = 'Available';\n"; //echo " radio_button[agent_status]\"]:checked').value == 'On Break';\n"; @@ -236,7 +236,7 @@ //echo " console.log('need to change status On Break to Available');\n"; //echo " console.log('---');\n"; echo " }\n"; - echo " if (radio_button.value === 'On Break' && agent_status === 'On Break') {\n"; // radio_checked_value == 'Available' && + echo " if (radio_button.value === 'On Break' && agent_status === 'On Break') {\n"; // radio_checked_value == 'Available' && //echo " radio_button.checked = true;\n"; //echo " radio_button.value = 'On Break';\n"; //echo " radio_button[agent_status]\"]:checked').value == 'On Break';\n"; @@ -259,7 +259,7 @@ //show the content echo "
\n"; - echo "
".$text['header-call_center_queues'].($agent['agent_name'] != '' ? "    Agent: ".$agent['agent_name']."" : "")."
\n"; + echo "
".$text['header-call_center_queues'].(!empty($agent['agent_name']) ? "    Agent: ".$agent['agent_name']."" : "")."
\n"; echo "
\n"; echo button::create(['type'=>'button','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'collapse'=>false,'onclick'=>"document.getElementById('form_list_call_center_agent_dashboard').submit();"]); echo "
\n"; @@ -274,7 +274,7 @@ echo " ".$text['label-status']."\n"; echo "\n"; - if (is_array($call_center_queues) && @sizeof($call_center_queues) != 0) { + if (!empty($call_center_queues) && is_array($call_center_queues) && @sizeof($call_center_queues) != 0) { $x = 0; foreach ($call_center_queues as $row) { $onclick = "onclick=\"cycle('agents[".$x."][agent_status]');\""; diff --git a/app/devices/resources/dashboard/device_keys.php b/app/devices/resources/dashboard/device_keys.php index 23a5eeaf2e..54439c8d2e 100644 --- a/app/devices/resources/dashboard/device_keys.php +++ b/app/devices/resources/dashboard/device_keys.php @@ -308,7 +308,7 @@ unset($sql, $parameters, $row); //get device lines - if (is_uuid($device_uuid)) { + if (!empty($device_uuid) && is_uuid($device_uuid)) { $sql = "select * from v_device_lines "; $sql .= "where device_uuid = :device_uuid "; $parameters['device_uuid'] = $device_uuid; @@ -317,7 +317,7 @@ } //get the user - if (is_array($device_lines)) { + if (!empty($device_lines) && is_array($device_lines)) { foreach ($device_lines as $row) { if ($_SESSION['domain_name'] == $row['server_address']) { $user_id = $row['user_id']; @@ -331,7 +331,7 @@ $sip_profile_name = 'internal'; //get the device keys in the right order where device keys are listed after the profile keys - if (is_uuid($device_uuid)) { + if (!empty($device_uuid) && is_uuid($device_uuid)) { $sql = "select * from v_device_keys "; $sql .= "where ("; $sql .= "device_uuid = :device_uuid "; @@ -356,7 +356,7 @@ } //override profile keys with device keys - if (is_array($keys) && @sizeof($keys) != 0) { + if (!empty($keys) && is_array($keys) && @sizeof($keys) != 0) { foreach($keys as $row) { $id = $row['device_key_id']; $device_keys[$id] = $row; @@ -371,7 +371,7 @@ } //get the vendor count and last and device information - if (is_array($device_keys) && @sizeof($device_keys) != 0) { + if (!empty($device_keys) && is_array($device_keys) && @sizeof($device_keys) != 0) { $vendor_count = 0; foreach($device_keys as $row) { if ($previous_vendor != $row['device_key_vendor']) { @@ -388,10 +388,10 @@ //add a new key if (permission_exists('device_key_add')) { - $device_keys[$x]['device_key_category'] = $device_key_category; + $device_keys[$x]['device_key_category'] = $device_key_category ?? ''; $device_keys[$x]['device_key_id'] = ''; - $device_keys[$x]['device_uuid'] = $device_uuid; - $device_keys[$x]['device_key_vendor'] = $device_key_vendor; + $device_keys[$x]['device_uuid'] = $device_uuid ?? ''; + $device_keys[$x]['device_key_vendor'] = $device_key_vendor ?? ''; $device_keys[$x]['device_key_type'] = ''; $device_keys[$x]['device_key_line'] = ''; $device_keys[$x]['device_key_value'] = ''; @@ -422,7 +422,7 @@ unset($device_keys[$row['device_key_id']]); } //hide protected keys - if ($row['device_key_protected'] == "true") { + if (!empty($row['device_key_protected']) && $row['device_key_protected'] == "true") { unset($device_keys[$row['device_key_id']]); } } @@ -436,13 +436,13 @@ echo "
\n"; echo "
".$text['title-device_keys']."
\n"; echo "
\n"; - echo button::create(['type'=>'button','label'=>$text['button-apply'],'icon'=>$_SESSION['theme']['button_icon_save'],'collapse'=>false,'onclick'=>"document.location.href='".PROJECT_PATH."/app/devices/cmd.php?cmd=check_sync&profile=".$sip_profile_name."&user=".$user_id."@".$server_address."&domain=".$server_address."&agent=".$device_key_vendor."';"]); + echo button::create(['type'=>'button','label'=>$text['button-apply'],'icon'=>$_SESSION['theme']['button_icon_save'],'collapse'=>false,'onclick'=>"document.location.href='".PROJECT_PATH."/app/devices/cmd.php?cmd=check_sync&profile=".$sip_profile_name."&user=".($user_id ?? '')."@".($server_address ?? '')."&domain=".($server_address ?? '')."&agent=".($device_key_vendor ?? '')."';"]); echo button::create(['type'=>'button','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'collapse'=>false,'onclick'=>"list_form_submit('form_list_device_keys');"]); echo "
\n"; echo "
\n"; echo "
\n"; - if (!$is_included) { + if (!empty($is_included) && !$is_included) { echo $text['description-device_keys']."\n"; echo "

\n"; } @@ -458,7 +458,7 @@ $device_vendor = $row['device_key_vendor']; //set the column names - if ($previous_device_key_vendor != $row['device_key_vendor'] || $row['device_key_vendor'] == '') { + if (!empty($previous_device_key_vendor) && $previous_device_key_vendor != $row['device_key_vendor'] || $row['device_key_vendor'] == '') { echo " \n"; echo " ".$text['label-device_key_id']."\n"; if (!empty($row['device_key_vendor'])) { @@ -572,9 +572,9 @@ echo " \n"; echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; echo " \n"; - echo " \n"; + echo " \n"; echo " \n"; if (permission_exists('device_key_icon')) { echo " \n"; diff --git a/app/voicemails/resources/dashboard/voicemails.php b/app/voicemails/resources/dashboard/voicemails.php index e5bcc29d0c..36639ff332 100644 --- a/app/voicemails/resources/dashboard/voicemails.php +++ b/app/voicemails/resources/dashboard/voicemails.php @@ -55,7 +55,7 @@ echo "
\n"; echo " ".$text['label-new_messages'].""; - if ($dashboard_chart_type == "doughnut") { + if ($row['dashboard_chart_type'] == "doughnut") { //add doughnut chart ?>
@@ -100,7 +100,7 @@ ".$messages['new'].""; } echo "
\n"; diff --git a/app/xml_cdr/resources/dashboard/missed_calls.php b/app/xml_cdr/resources/dashboard/missed_calls.php index ffc45077e0..e70e263bf4 100644 --- a/app/xml_cdr/resources/dashboard/missed_calls.php +++ b/app/xml_cdr/resources/dashboard/missed_calls.php @@ -93,7 +93,7 @@ echo "
\n"; echo " ".$text['label-missed_calls'].""; - if ($dashboard_chart_type == "doughnut") { + if ($row['dashboard_chart_type'] == "doughnut") { //add doughnut chart ?>
@@ -138,7 +138,7 @@ ".$num_rows.""; } echo "
\n"; diff --git a/app/xml_cdr/resources/dashboard/recent_calls.php b/app/xml_cdr/resources/dashboard/recent_calls.php index 3244d5ef56..f7295923ec 100644 --- a/app/xml_cdr/resources/dashboard/recent_calls.php +++ b/app/xml_cdr/resources/dashboard/recent_calls.php @@ -90,7 +90,7 @@ echo "
\n"; echo " ".$text['label-recent_calls']."\n"; - if ($dashboard_chart_type == "doughnut") { + if ($row['dashboard_chart_type'] == "doughnut") { //add doughnut chart ?> @@ -136,7 +136,7 @@ ".$num_rows.""; } echo "
\n"; diff --git a/core/dashboard/dashboard_edit.php b/core/dashboard/dashboard_edit.php index 525b0bbc3b..d5a31aa97c 100644 --- a/core/dashboard/dashboard_edit.php +++ b/core/dashboard/dashboard_edit.php @@ -44,11 +44,14 @@ $dashboard_path = 'core/dashboard/resources/dashboard/icon.php'; $dashboard_url = ''; $dashboard_icon = ''; + $dashboard_heading_text_color = ''; + $dashboard_heading_background_color = ''; + $dashboard_number_text_color = ''; $dashboard_groups = []; $dashboard_column_span = ''; $dashboard_details_state = ''; $dashboard_order = ''; - $dashboard_enabled = 'false'; + $dashboard_enabled = $row["dashboard_enabled"] ?? 'true'; $dashboard_description = ''; $dashboard_uuid = ''; @@ -319,6 +322,17 @@ $dashboard_details_state = "expanded"; } +//add a default value to $dashboard_chart_type + if (!isset($dashboard_chart_type) && $dashboard_path == 'app/voicemails/resources/dashboard/voicemails.php') { + $dashboard_chart_type = "none"; + } + if (!isset($dashboard_chart_type) && $dashboard_path == 'app/xml_cdr/resources/dashboard/missed_calls.php') { + $dashboard_chart_type = "none"; + } + if (!isset($dashboard_chart_type) && $dashboard_path == 'app/xml_cdr/resources/dashboard/recent_calls.php') { + $dashboard_chart_type = "none"; + } + //add an empty row $x = is_array($dashboard_groups) ? count($dashboard_groups) : 0; $dashboard_groups[$x]['dashboard_uuid'] = $dashboard_uuid; @@ -752,4 +766,4 @@ //include the footer require_once "resources/footer.php"; -?> \ No newline at end of file +?> diff --git a/core/dashboard/index.php b/core/dashboard/index.php index 8b1be6de5b..7dd6e4707c 100644 --- a/core/dashboard/index.php +++ b/core/dashboard/index.php @@ -153,11 +153,11 @@ //chart variables echo "\n"; // determine initial state all button to display @@ -257,7 +257,6 @@ span.hud_stat { padding-bottom: 27px; } echo " background-image: linear-gradient(to right, ".$detail_background_color[1]." 0%, ".$detail_background_color[0]." 30%, ".$detail_background_color[0]." 70%, ".$detail_background_color[1]." 100%);"; echo "}"; } - ?> /* Screen smaller than 575px? 1 columns */ @@ -294,13 +293,7 @@ span.hud_stat { padding-bottom: 27px; } echo " display: none;\n"; echo "}\n"; } - if ($row['dashboard_details_state'] == "hidden") { - echo "#".$dashboard_name." .hud_box .hud_expander, \n"; - echo "#".$dashboard_name." .hud_box .hud_details {\n"; - echo " display: none;\n"; - echo "}\n"; - } - if ($row['dashboard_details_state'] == "disabled") { + if ($row['dashboard_details_state'] == "hidden" || $row['dashboard_details_state'] == "disabled") { echo "#".$dashboard_name." .hud_box .hud_expander, \n"; echo "#".$dashboard_name." .hud_box .hud_details {\n"; echo " display: none;\n"; @@ -342,7 +335,7 @@ span.hud_stat { padding-bottom: 27px; }