Răsfoiți Sursa

Add Dashboard settings URL and Icon

FusionPBX 1 an în urmă
părinte
comite
8591f9b32f

+ 13 - 1
core/dashboard/app_config.php

@@ -72,6 +72,18 @@
 		$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
 		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the dashboard path.';
 		$z++;
+
+$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_url';
+$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
+$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the dashboard url.';
+$z++;
+$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_icon';
+$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
+$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the dashboard icon.';
+$z++;
+
 		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_chart_type';
 		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
 		$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
@@ -199,4 +211,4 @@
 	//default settings
 		$y=0;
 
-?>
+?>

+ 74 - 2
core/dashboard/dashboard_edit.php

@@ -18,7 +18,7 @@
 
 	The Initial Developer of the Original Code is
 	Mark J Crane <[email protected]>
-	Portions created by the Initial Developer are Copyright (C) 2021-2023
+	Portions created by the Initial Developer are Copyright (C) 2021-2024
 	the Initial Developer. All Rights Reserved.
 */
 
@@ -42,6 +42,8 @@
 //set the defaults
 	$dashboard_name = '';
 	$dashboard_path = '';
+$dashboard_url = '';
+$dashboard_icon = '';
 	$dashboard_groups = [];
 	$dashboard_column_span = '';
 	$dashboard_details_state = '';
@@ -64,6 +66,8 @@
 	if (!empty($_POST)) {
 		$dashboard_name = $_POST["dashboard_name"] ?? '';
 		$dashboard_path = $_POST["dashboard_path"] ?? '';
+$dashboard_icon = $_POST["dashboard_icon"] ?? '';
+$dashboard_url = $_POST["dashboard_url"] ?? '';
 		$dashboard_groups = $_POST["dashboard_groups"] ?? '';
 		$dashboard_chart_type = $_POST["dashboard_chart_type"] ?? '';
 		$dashboard_heading_background_color = $_POST["dashboard_heading_background_color"] ?? '';
@@ -168,6 +172,10 @@
 			$array['dashboard'][0]['dashboard_uuid'] = $dashboard_uuid;
 			$array['dashboard'][0]['dashboard_name'] = $dashboard_name;
 			$array['dashboard'][0]['dashboard_path'] = $dashboard_path;
+
+$array['dashboard'][0]['dashboard_icon'] = $dashboard_icon;
+$array['dashboard'][0]['dashboard_url'] = $dashboard_url;
+
 			$array['dashboard'][0]['dashboard_chart_type'] = $dashboard_chart_type;
 			$array['dashboard'][0]['dashboard_heading_background_color'] = $dashboard_heading_background_color;
 			$array['dashboard'][0]['dashboard_heading_text_color'] = $dashboard_heading_text_color;
@@ -218,6 +226,10 @@
 		$sql .= " dashboard_uuid, ";
 		$sql .= " dashboard_name, ";
 		$sql .= " dashboard_path, ";
+
+$sql .= " dashboard_icon, ";
+$sql .= " dashboard_url, ";
+
 		$sql .= " dashboard_chart_type, ";
 		$sql .= " dashboard_heading_background_color, ";
 		$sql .= " dashboard_heading_text_color, ";
@@ -236,6 +248,10 @@
 		if (is_array($row) && @sizeof($row) != 0) {
 			$dashboard_name = $row["dashboard_name"];
 			$dashboard_path = $row["dashboard_path"];
+
+			$dashboard_icon = $row["dashboard_icon"];
+			$dashboard_url = $row["dashboard_url"];
+
 			$dashboard_chart_type = $row["dashboard_chart_type"];
 			$dashboard_heading_background_color = $row["dashboard_heading_background_color"];
 			$dashboard_heading_text_color = $row["dashboard_heading_text_color"];
@@ -374,6 +390,62 @@
 	echo "</td>\n";
 	echo "</tr>\n";
 
+echo "<tr>\n";
+echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
+echo "	".$text['label-link']."\n";
+echo "</td>\n";
+echo "<td class='vtable' style='position: relative;' align='left'>\n";
+echo "	<input class='formfld' type='text' name='dashboard_url' maxlength='255' value='".escape($dashboard_url)."'>\n";
+echo "<br />\n";
+echo $text['description-dashboard_url']."\n";
+echo "</td>\n";
+echo "</tr>\n";
+
+echo "	<tr>";
+echo "		<td class='vncell'>".$text['label-icon']."</td>";
+echo "		<td class='vtable' style='vertical-align: bottom;'>";
+if (file_exists($_SERVER["PROJECT_ROOT"].'/resources/fontawesome/fas_icons.php')) {
+	include 'resources/fontawesome/fas_icons.php';
+	if (is_array($font_awesome_solid_icons) && @sizeof($font_awesome_solid_icons) != 0) {
+		// rebuild and sort array
+		foreach ($font_awesome_solid_icons as $i => $icon_class) {
+			$icon_label = str_replace('fa-', '', $icon_class);
+			$icon_label = str_replace('-', ' ', $icon_label);
+			$icon_label = ucwords($icon_label);
+			$icons[$icon_class] = $icon_label;
+		}
+		asort($icons, SORT_STRING);
+		echo "<table cellpadding='0' cellspacing='0' border='0'>\n";
+		echo "	<tr>\n";
+		echo "		<td>\n";
+		echo "			<select class='formfld' name='dashboard_icon' id='dashboard_icon' onchange=\"$('#icons').slideUp(); $('#grid_icon').fadeIn();\">\n";
+		echo "				<option value=''></option>\n";
+		foreach ($icons as $icon_class => $icon_label) {
+			$selected = ($dashboard_icon == $icon_class) ? "selected" : null;
+			echo "			<option value='".escape($icon_class)."' ".$selected.">".escape($icon_label)."</option>\n";
+		}
+		echo "			</select>\n";
+		echo "		</td>\n";
+		echo "		<td style='padding: 0 0 0 5px;'>\n";
+		echo "			<button id='grid_icon' type='button' class='btn btn-default list_control_icon' style='font-size: 15px; padding-top: 1px; padding-left: 3px;' onclick=\"$('#icons').fadeIn(); $(this).fadeOut();\"><span class='fas fa-th'></span></button>";
+		echo "		</td>\n";
+		echo "	</tr>\n";
+		echo "</table>\n";
+		echo "<div id='icons' style='clear: both; display: none; margin-top: 8px; padding-top: 10px; color: #000; max-height: 400px; overflow: auto;'>\n";
+		foreach ($icons as $icon_class => $icon_label) {
+			echo "<span class='fas ".escape($icon_class)." fa-fw' style='font-size: 24px; float: left; margin: 0 8px 8px 0; cursor: pointer; opacity: 0.3;' title='".escape($icon_label)."' onclick=\"$('#dashboard_icon').val('".escape($icon_class)."'); $('#icons').slideUp(); $('#grid_icon').fadeIn();\" onmouseover=\"this.style.opacity='1';\" onmouseout=\"this.style.opacity='0.3';\"></span>\n";
+		}
+		echo "</div>";
+	}
+}
+else {
+	echo "		<input type='text' class='formfld' name='dashboard_icon' value='".escape($dashboard_icon)."'>";
+}
+echo "		</td>";
+echo "	</tr>";
+
+
+
 	echo "<tr>\n";
 	echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
 	echo "	".$text['label-dashboard_groups']."\n";
@@ -603,4 +675,4 @@
 //include the footer
 	require_once "resources/footer.php";
 
-?>
+?>

+ 11 - 6
core/dashboard/index.php

@@ -17,7 +17,7 @@
 
 	The Initial Developer of the Original Code is
 	Mark J Crane <[email protected]>
-	Portions created by the Initial Developer are Copyright (C) 2022-2023
+	Portions created by the Initial Developer are Copyright (C) 2022-2024
 	the Initial Developer. All Rights Reserved.
 
 	Contributor(s):
@@ -72,6 +72,8 @@
 	$sql .= "dashboard_uuid, \n";
 	$sql .= "dashboard_name, \n";
 	$sql .= "dashboard_path, \n";
+	$sql .= "dashboard_url, \n";
+	$sql .= "dashboard_icon, \n";
 	$sql .= "dashboard_chart_type, \n";
 	$sql .= "dashboard_heading_background_color, \n";
 	$sql .= "dashboard_heading_text_color, \n";
@@ -108,6 +110,8 @@
 					if ($widget == $dashboard_name) {
 						$dashboard_order = $dashboard_order + 10;
 						$array['dashboard'][$x]['dashboard_name'] = $row['dashboard_name'];
+						$array['dashboard'][$x]['dashboard_url'] = $row['dashboard_url'];
+						$array['dashboard'][$x]['dashboard_icon'] = $row['dashboard_icon'];
 						$array['dashboard'][$x]['dashboard_uuid'] = $row['dashboard_uuid'];
 						$array['dashboard'][$x]['dashboard_order'] = $dashboard_order;
 						$x++;
@@ -303,15 +307,16 @@
 	echo "<div class='widgets' id='widgets' style='padding: 0 5px;'>\n";
 	$x = 0;
 	foreach($dashboard as $row) {
-		$dashboard_name = strtolower($row['dashboard_name']);
-		$dashboard_name = str_replace(" ", "_", $dashboard_name);
+		$dashboard_name = $row['dashboard_name'];
+		$dashboard_icon = $row['dashboard_icon'] ?? '';
+		$dashboard_url  = $row['dashboard_url'] ?? '';
 		$dashboard_chart_type = $row['dashboard_chart_type'] ?? 'doughnut';
 		$dashboard_heading_background_color = $row['dashboard_heading_background_color'] ?? $settings->get('theme', 'dashboard_heading_background_color');
 		$dashboard_heading_text_color = $row['dashboard_heading_text_color'] ?? $settings->get('theme', 'dashboard_heading_text_color');
 		$dashboard_number_background_color = $row['dashboard_number_background_color'] ?? $settings->get('theme', 'dashboard_number_background_color');
 		$dashboard_number_text_color = $row['dashboard_number_text_color'] ?? $settings->get('theme', 'dashboard_number_text_color');
-		echo "<div class='widget' id='".$dashboard_name."' draggable='false'>\n";
-			include($row['dashboard_path']);
+		echo "<div class='widget' id='".str_replace(" ", "_", strtolower($dashboard_name))."' draggable='false'>\n";
+		include($row['dashboard_path']);
 		echo "</div>\n";
 		$x++;
 	}
@@ -416,4 +421,4 @@
 //show the footer
 	require_once "resources/footer.php";
 
-?>
+?>

+ 33 - 0
core/dashboard/resources/classes/dashboard/icon.php

@@ -0,0 +1,33 @@
+<?php
+
+//includes files
+	require_once  dirname(__DIR__, 4) . "/resources/require.php";
+	require_once "resources/check_auth.php";
+
+//add multi-lingual support
+	$language = new text;
+	$text = $language->get($_SESSION['domain']['language']['code'], 'core/dashboard');
+
+//dashboard icon
+	echo "<div class='hud_box'>\n";
+
+	echo "<div style='display: flex; flex-wrap: wrap; justify-content: center; padding-bottom: 13px; background-color: ".$dashboard_number_background_color.";' onclick=\"$('#hud_icon_details').slideToggle('fast');\">\n";
+	echo "	<span class='hud_title' style='background-color: ".$dashboard_heading_background_color."; color: ".$dashboard_heading_text_color.";' onclick=\"document.location.href='".$dashboard_url."'\">". $dashboard_name . "</span>"; // (isset($text['label-'.$dashboard_name])) ? $text['label-'.$dashboard_name] : $dashboard_name
+	echo "	<a href='".$dashboard_url."'><span class='hud_stat' style='height: 150px; padding-bottom: 27px; color: ".$dashboard_number_text_color.";'><i class=\"fas ".$dashboard_icon."\" style=\"color: ".$dashboard_number_text_color."; font-size: 0.8em;\"></i></span></a>\n";
+	echo "</div>\n";
+
+	echo "<div class='hud_details hud_box' id='hud_icon_details'>";
+	echo "<table class='tr_hover' width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
+	echo "<tr>\n";
+	echo "<td>\n";
+	echo "	&nbsp;\n";
+	echo "</td>\n";
+	echo "</table>\n";
+	//echo "<span style='display: block; margin: 6px 0 7px 0;'><a href='".PROJECT_PATH."/app/xml_cdr/xml_cdr.php?status=missed'>".$text['label-view_all']."</a></span>\n";
+	echo "</div>";
+	//$n++;
+
+	echo "<span class='hud_expander' onclick=\"$('#hud_icon_details').slideToggle('fast');\"><span class='fas fa-ellipsis-h'></span></span>";
+	echo "</div>\n";
+
+?>