Portions created by the Initial Developer are Copyright (C) 2021-2025 the Initial Developer. All Rights Reserved. */ //includes files require_once dirname(__DIR__, 2) . "/resources/require.php"; require_once "resources/check_auth.php"; //check permissions if (!(permission_exists('dashboard_widget_add') || permission_exists('dashboard_widget_edit'))) { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //set the defaults $widget_uuid = ''; $widget_name = ''; $widget_path = 'dashboard/icon'; $widget_icon = ''; $widget_icon_color = ''; $widget_url = ''; $widget_target = 'self'; $widget_width = ''; $widget_height = ''; $widget_content = ''; $widget_content_text_align = ''; $widget_content_details = ''; $widget_groups = []; $widget_label_enabled = ''; $widget_label_text_color = ''; $widget_label_text_color_hover = ''; $widget_label_background_color = ''; $widget_label_background_color_hover = ''; $widget_number_text_color = ''; $widget_number_background_color = ''; $widget_background_gradient_style = ''; $widget_background_gradient_angle = 0; $widget_column_span = ''; $widget_row_span = ''; $widget_details_state = ''; $widget_parent_uuid = ''; $widget_order = ''; $widget_enabled = ''; $widget_description = ''; //action add or update if (!empty($_REQUEST["widget_uuid"]) && is_uuid($_REQUEST["widget_uuid"])) { $action = "update"; $dashboard_uuid = $_REQUEST["id"]; $widget_uuid = $_REQUEST["widget_uuid"]; } else { $action = "add"; $dashboard_uuid = $_REQUEST["id"]; } //get http post variables and set them to php variables if (!empty($_POST)) { $widget_name = $_POST["widget_name"] ?? ''; $widget_path = $_POST["widget_path"] ?? ''; $widget_icon = $_POST["widget_icon"] ?? ''; $widget_icon_color = $_POST["widget_icon_color"] ?? ''; $widget_url = $_POST["widget_url"] ?? ''; $widget_target = $_POST["widget_target"] ?? 'self'; $widget_width = $_POST["widget_width"] ?? ''; $widget_height = $_POST["widget_height"] ?? ''; $widget_content = $_POST["widget_content"] ?? ''; $widget_content_text_align = $_POST["widget_content_text_align"] ?? ''; $widget_content_details = $_POST["widget_content_details"] ?? ''; $widget_groups = $_POST["dashboard_widget_groups"] ?? ''; $widget_chart_type = $_POST["widget_chart_type"] ?? ''; $widget_label_enabled = $_POST["widget_label_enabled"]; $widget_label_text_color = $_POST["widget_label_text_color"] ?? ''; $widget_label_text_color_hover = $_POST["widget_label_text_color_hover"] ?? ''; $widget_label_background_color = $_POST["widget_label_background_color"] ?? ''; $widget_label_background_color_hover = $_POST["widget_label_background_color_hover"] ?? ''; $widget_number_text_color = $_POST["widget_number_text_color"] ?? ''; $widget_number_text_color_hover = $_POST["widget_number_text_color_hover"] ?? ''; $widget_number_background_color = $_POST["widget_number_background_color"] ?? ''; $widget_background_color = $_POST["widget_background_color"] ?? ''; $widget_background_color_hover = $_POST["widget_background_color_hover"] ?? ''; $widget_detail_background_color = $_POST["widget_detail_background_color"] ?? ''; $widget_background_gradient_style = $_POST["widget_background_gradient_style"] ?? 'mirror'; $widget_background_gradient_angle = $_POST["widget_background_gradient_angle"] ?? '0'; $widget_column_span = $_POST["widget_column_span"] ?? ''; $widget_row_span = $_POST["widget_row_span"] ?? ''; $widget_details_state = $_POST["widget_details_state"] ?? ''; $widget_parent_uuid = $_POST["dashboard_widget_parent_uuid"] ?? ''; $widget_order = $_POST["widget_order"] ?? ''; $widget_enabled = $_POST["widget_enabled"]; $widget_description = $_POST["widget_description"] ?? ''; //define the regex patterns $uuid_pattern = '/[^-A-Fa-f0-9]/'; $number_pattern = '/[^-A-Za-z0-9()*#]/'; $text_pattern = '/[^a-zA-Z0-9 _\-\/.\?:\=#\n,()]/'; //sanitize the data $widget_name = trim($widget_name); $widget_path = preg_replace($text_pattern, '', strtolower($widget_path)); $widget_icon = preg_replace($text_pattern, '', $widget_icon); $widget_icon_color = preg_replace($text_pattern, '', $widget_icon_color); $widget_url = trim(preg_replace($text_pattern, '', $widget_url)); $widget_target = trim(preg_replace($text_pattern, '', $widget_target)); $widget_width = trim(preg_replace($text_pattern, '', $widget_width)); $widget_height = trim(preg_replace($text_pattern, '', $widget_height)); $widget_content = trim($widget_content); $widget_content_text_align = trim(preg_replace($text_pattern, '', $widget_content_text_align)); $widget_content_details = trim(preg_replace($text_pattern, '', $widget_content_details)); $widget_chart_type = preg_replace($text_pattern, '', $widget_chart_type); $widget_label_enabled = preg_replace($text_pattern, '', $widget_label_enabled); $widget_label_text_color = preg_replace($text_pattern, '', $widget_label_text_color); $widget_label_text_color_hover = preg_replace($text_pattern, '', $widget_label_text_color_hover); $widget_label_background_color = preg_replace($text_pattern, '', $widget_label_background_color); $widget_label_background_color_hover = preg_replace($text_pattern, '', $widget_label_background_color_hover); $widget_number_text_color = preg_replace($text_pattern, '', $widget_number_text_color); $widget_number_text_color_hover = preg_replace($text_pattern, '', $widget_number_text_color_hover); $widget_number_background_color = preg_replace($text_pattern, '', $widget_number_background_color); $widget_background_color = preg_replace($text_pattern, '', $widget_background_color); $widget_background_color_hover = preg_replace($text_pattern, '', $widget_background_color_hover); $widget_detail_background_color = preg_replace($text_pattern, '', $widget_detail_background_color); $widget_background_gradient_style = preg_replace($text_pattern, '', $widget_background_gradient_style); $widget_background_gradient_angle = preg_replace($text_pattern, '', $widget_background_gradient_angle); $widget_column_span = preg_replace($number_pattern, '', $widget_column_span); $widget_row_span = preg_replace($number_pattern, '', $widget_row_span); $widget_details_state = preg_replace($text_pattern, '', $widget_details_state); $widget_parent_uuid = preg_replace($uuid_pattern, '', $widget_parent_uuid); $widget_order = preg_replace($number_pattern, '', $widget_order); $widget_enabled = preg_replace($text_pattern, '', $widget_enabled); $widget_description = preg_replace($text_pattern, '', $widget_description); } //delete the group from the sub table if (!empty($_POST["action"]) && $_POST["action"] === "delete" && permission_exists("dashboard_widget_group_delete") && is_uuid($_POST["dashboard_widget_group_uuid"]) && is_uuid($_POST["dashboard_widget_uuid"])) { //get the uuid $widget_group_uuid = $_POST['dashboard_widget_group_uuid']; //validate the token $token = new token; if (!$token->validate($_SERVER['PHP_SELF'])) { message::add($text['message-invalid_token'],'negative'); header('Location: dashboard_edit.php?id='.urlencode($dashboard_uuid)); exit; } //delete the group from the widget $array['dashboard_widget_groups'][0]['dashboard_widget_group_uuid'] = $widget_group_uuid; $database->delete($array); unset($array); //redirect the user message::add($text['message-delete']); header("Location: dashboard_widget_edit.php?id=".urlencode($dashboard_uuid)."&widget_uuid=".urlencode($widget_uuid)); return; } //process the user data and save it to the database if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //validate the token $token = new token; if (!$token->validate($_SERVER['PHP_SELF'])) { message::add($text['message-invalid_token'],'negative'); header('Location: dashboard_edit.php?id='.urlencode($dashboard_uuid)); exit; } //process the http post data by submitted action if (!empty($_POST['action'])) { //prepare the array(s) //send the array to the database class switch ($_POST['action']) { case 'copy': if (permission_exists('dashboard_widget_add')) { $database->copy($array); } break; case 'delete': if (permission_exists('dashboard_widget_delete')) { $database->delete($array); } break; case 'toggle': if (permission_exists('dashboard_update')) { $database->toggle($array); } break; } //redirect the user if (in_array($_POST['action'], array('copy', 'delete', 'toggle'))) { header('Location: dashboard_edit.php?id='.urlencode($dashboard_uuid)); exit; } } //check for all required data $msg = ''; //if (empty($widget_name)) { $msg .= $text['message-required']." ".$text['label-widget_name']."
\n"; } //if (empty($widget_path)) { $msg .= $text['message-required']." ".$text['label-widget_path']."
\n"; } //if (empty($widget_groups)) { $msg .= $text['message-required']." ".$text['label-widget_groups']."
\n"; } //if (empty($widget_order)) { $msg .= $text['message-required']." ".$text['label-widget_order']."
\n"; } //if (empty($widget_enabled)) { $msg .= $text['message-required']." ".$text['label-widget_enabled']."
\n"; } //if (empty($widget_description)) { $msg .= $text['message-required']." ".$text['label-widget_description']."
\n"; } if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; echo "
\n"; echo $msg."
\n"; echo "
\n"; persistformvar($_POST); echo "
\n"; require_once "resources/footer.php"; return; } //add the dashboard_widget_uuid if (!is_uuid($_POST["dashboard_widget_uuid"])) { $widget_uuid = uuid(); } //remove empty values and convert to json if (!empty($widget_background_color)) { if (is_array($widget_background_color)) { $widget_background_color = array_filter($widget_background_color); if (count($widget_background_color) > 0) { $widget_background_color = json_encode($widget_background_color); } else { $widget_background_color = ''; } } } if (!empty($widget_background_color_hover)) { if (is_array($widget_background_color_hover)) { $widget_background_color_hover = array_filter($widget_background_color_hover); if (count($widget_background_color_hover) > 0) { $widget_background_color_hover = json_encode($widget_background_color_hover); } else { $widget_background_color_hover = ''; } } } if (!empty($widget_detail_background_color)) { if (is_array($widget_detail_background_color)) { $widget_detail_background_color = array_filter($widget_detail_background_color); if (count($widget_detail_background_color) > 0) { $widget_detail_background_color = json_encode($widget_detail_background_color); } else { $widget_detail_background_color = ''; } } } //prepare the array $array['dashboard_widgets'][0]['dashboard_uuid'] = $dashboard_uuid; $array['dashboard_widgets'][0]['dashboard_widget_uuid'] = $widget_uuid; $array['dashboard_widgets'][0]['widget_name'] = $widget_name; $array['dashboard_widgets'][0]['widget_path'] = $widget_path; $array['dashboard_widgets'][0]['widget_icon'] = $widget_icon; $array['dashboard_widgets'][0]['widget_icon_color'] = $widget_icon_color; $array['dashboard_widgets'][0]['widget_url'] = $widget_url; $array['dashboard_widgets'][0]['widget_width'] = $widget_width; $array['dashboard_widgets'][0]['widget_height'] = $widget_height; $array['dashboard_widgets'][0]['widget_target'] = $widget_target; $array['dashboard_widgets'][0]['widget_content'] = $widget_content; $array['dashboard_widgets'][0]['widget_content_text_align'] = $widget_content_text_align; $array['dashboard_widgets'][0]['widget_content_details'] = $widget_content_details; $array['dashboard_widgets'][0]['widget_chart_type'] = $widget_chart_type; $array['dashboard_widgets'][0]['widget_label_enabled'] = $widget_label_enabled; $array['dashboard_widgets'][0]['widget_label_text_color'] = $widget_label_text_color; $array['dashboard_widgets'][0]['widget_label_text_color_hover'] = $widget_label_text_color_hover; $array['dashboard_widgets'][0]['widget_label_background_color'] = $widget_label_background_color; $array['dashboard_widgets'][0]['widget_label_background_color_hover'] = $widget_label_background_color_hover; $array['dashboard_widgets'][0]['widget_number_text_color'] = $widget_number_text_color; $array['dashboard_widgets'][0]['widget_number_text_color_hover'] = $widget_number_text_color_hover; $array['dashboard_widgets'][0]['widget_number_background_color'] = $widget_number_background_color; $array['dashboard_widgets'][0]['widget_background_color'] = $widget_background_color; $array['dashboard_widgets'][0]['widget_background_color_hover'] = $widget_background_color_hover; $array['dashboard_widgets'][0]['widget_detail_background_color'] = $widget_detail_background_color; $array['dashboard_widgets'][0]['widget_background_gradient_style'] = $widget_background_gradient_style; $array['dashboard_widgets'][0]['widget_background_gradient_angle'] = $widget_background_gradient_angle; $array['dashboard_widgets'][0]['widget_column_span'] = $widget_column_span; $array['dashboard_widgets'][0]['widget_row_span'] = $widget_row_span; $array['dashboard_widgets'][0]['widget_details_state'] = $widget_details_state; $array['dashboard_widgets'][0]['dashboard_widget_parent_uuid'] = $widget_parent_uuid; $array['dashboard_widgets'][0]['widget_order'] = $widget_order; $array['dashboard_widgets'][0]['widget_enabled'] = $widget_enabled; $array['dashboard_widgets'][0]['widget_description'] = $widget_description; $y = 0; if (is_array($widget_groups)) { foreach ($widget_groups as $row) { if (isset($row['group_uuid']) && is_uuid($row['group_uuid'])) { $array['dashboard_widgets'][0]['dashboard_widget_groups'][$y]['dashboard_uuid'] = $dashboard_uuid; $array['dashboard_widgets'][0]['dashboard_widget_groups'][$y]['dashboard_widget_group_uuid'] = uuid(); $array['dashboard_widgets'][0]['dashboard_widget_groups'][$y]['group_uuid'] = $row["group_uuid"]; $y++; } } } //save the data $result = $database->save($array); //redirect the user if (isset($action)) { if ($action == "add") { $_SESSION["message"] = $text['message-add']; header('Location: dashboard_edit.php?id='.urlencode($dashboard_uuid)); } if ($action == "update") { $_SESSION["message"] = $text['message-update']; header('Location: dashboard_widget_edit.php?id='.urlencode($dashboard_uuid).'&widget_uuid='.urlencode($widget_uuid)); } return; } } //pre-populate the form if (empty($_POST["persistformvar"])) { $sql = "select "; $sql .= " dashboard_widget_uuid, "; $sql .= " widget_name, "; $sql .= " widget_path, "; $sql .= " widget_icon, "; $sql .= " widget_icon_color, "; $sql .= " widget_url, "; $sql .= " widget_width, "; $sql .= " widget_height, "; $sql .= " widget_target, "; $sql .= " widget_content, "; $sql .= " widget_content_text_align, "; $sql .= " widget_content_details, "; $sql .= " widget_chart_type, "; $sql .= " widget_label_enabled, "; $sql .= " widget_label_text_color, "; $sql .= " widget_label_text_color_hover, "; $sql .= " widget_label_background_color, "; $sql .= " widget_label_background_color_hover, "; $sql .= " widget_number_text_color, "; $sql .= " widget_number_text_color_hover, "; $sql .= " widget_number_background_color, "; $sql .= " widget_background_color, "; $sql .= " widget_background_color_hover, "; $sql .= " widget_detail_background_color, "; $sql .= " widget_background_gradient_style, "; $sql .= " widget_background_gradient_angle, "; $sql .= " widget_column_span, "; $sql .= " widget_row_span, "; $sql .= " widget_details_state, "; $sql .= " dashboard_widget_parent_uuid, "; $sql .= " widget_order, "; $sql .= " widget_enabled, "; $sql .= " widget_description "; $sql .= "from v_dashboard_widgets "; $sql .= "where dashboard_widget_uuid = :dashboard_widget_uuid "; $parameters['dashboard_widget_uuid'] = $widget_uuid; $row = $database->select($sql, $parameters, 'row'); if (is_array($row) && @sizeof($row) != 0) { $widget_name = $row["widget_name"]; $widget_path = $row["widget_path"]; $widget_icon = $row["widget_icon"]; $widget_icon_color = $row["widget_icon_color"]; $widget_url = $row["widget_url"]; $widget_width = $row["widget_width"]; $widget_height = $row["widget_height"]; $widget_target = $row["widget_target"]; $widget_content = $row["widget_content"]; $widget_content_text_align = $row["widget_content_text_align"]; $widget_content_details = $row["widget_content_details"]; $widget_chart_type = $row["widget_chart_type"]; $widget_label_enabled = $row["widget_label_enabled"]; $widget_label_text_color = $row["widget_label_text_color"]; $widget_label_text_color_hover = $row["widget_label_text_color_hover"]; $widget_label_background_color = $row["widget_label_background_color"]; $widget_label_background_color_hover = $row["widget_label_background_color_hover"]; $widget_number_text_color = $row["widget_number_text_color"]; $widget_number_text_color_hover = $row["widget_number_text_color_hover"]; $widget_number_background_color = $row["widget_number_background_color"]; $widget_background_color = $row["widget_background_color"]; $widget_background_color_hover = $row["widget_background_color_hover"]; $widget_detail_background_color = $row["widget_detail_background_color"]; $widget_background_gradient_style = $row["widget_background_gradient_style"]; $widget_background_gradient_angle = $row["widget_background_gradient_angle"]; $widget_column_span = $row["widget_column_span"]; $widget_row_span = $row["widget_row_span"]; $widget_details_state = $row["widget_details_state"]; $widget_parent_uuid = $row["dashboard_widget_parent_uuid"]; $widget_order = $row["widget_order"]; $widget_enabled = $row["widget_enabled"]; $widget_description = $row["widget_description"]; } unset($sql, $parameters, $row); } //find the application and widget $widget_path_array = explode('/', $widget_path); $application_name = $widget_path_array[0]; $widget_path_name = $widget_path_array[1]; $path_array = glob(dirname(__DIR__, 2).'/*/'.$application_name.'/resources/dashboard/config.php'); if (file_exists($path_array[0])) { $x = 0; include($path_array[0]); } //find the chart type options $widget_chart_type_options = []; if (!empty($array['dashboard_widgets'])) { foreach ($array['dashboard_widgets'] as $index => $row) { if ($row['widget_path'] === "$application_name/$widget_path_name") { $widget_chart_type_options = $row['widget_chart_type_options']; break; } } } //get the child data if (!empty($widget_uuid) && is_uuid($widget_uuid)) { $sql = "select "; $sql .= " dashboard_widget_group_uuid, "; $sql .= " group_uuid "; $sql .= "from v_dashboard_widget_groups "; $sql .= "where dashboard_widget_uuid = :dashboard_widget_uuid "; $parameters['dashboard_widget_uuid'] = $widget_uuid; $widget_groups = $database->select($sql, $parameters, 'all'); unset ($sql, $parameters); } //add the $widget_group_uuid if (empty($widget_group_uuid) || !empty($widget_group_uuid) && !is_uuid($widget_group_uuid)) { $widget_group_uuid = uuid(); } //convert the json to an array if (!empty($widget_background_color) && is_json($widget_background_color)) { $widget_background_color = json_decode($widget_background_color, true); } if (!empty($widget_background_color_hover) && is_json($widget_background_color_hover)) { $widget_background_color_hover = json_decode($widget_background_color_hover, true); } if (!empty($widget_detail_background_color) && is_json($widget_detail_background_color)) { $widget_detail_background_color = json_decode($widget_detail_background_color, true); } //add an empty row $x = is_array($widget_groups) ? count($widget_groups) : 0; $widget_groups[$x]['dashboard_widget_uuid'] = $widget_uuid; $widget_groups[$x]['dashboard_widget_group_uuid'] = uuid(); $widget_groups[$x]['group_uuid'] = ''; //create token $object = new token; $token = $object->create($_SERVER['PHP_SELF']); //show the header $document['title'] = $text['title-dashboard_widget']; require_once "resources/header.php"; //get the dashboard groups $sql = "SELECT * FROM v_dashboard_widget_groups as x, v_groups as g "; $sql .= "WHERE x.dashboard_widget_uuid = :dashboard_widget_uuid "; $sql .= "AND x.group_uuid = g.group_uuid "; $parameters['dashboard_widget_uuid'] = $widget_uuid ?? ''; $widget_groups = $database->select($sql, $parameters, 'all'); unset ($sql, $parameters); //get the groups $sql = "SELECT group_uuid, domain_uuid, group_name FROM v_groups "; $sql .= "WHERE (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "ORDER BY domain_uuid desc, group_name asc "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; $groups = $database->execute($sql, $parameters, 'all'); unset ($sql, $parameters); //get the dashboards $sql = "SELECT dashboard_widget_uuid, widget_name FROM v_dashboard_widgets "; $sql .= "WHERE widget_path = 'dashboard/parent' "; $sql .= "AND dashboard_uuid = :dashboard_uuid "; $sql .= "ORDER by widget_order, widget_name asc "; $parameters['dashboard_uuid'] = $dashboard_uuid; $widget_parents = $database->execute($sql, $parameters, 'all'); unset ($sql, $parameters); //set the assigned_groups array if (is_array($widget_groups) && sizeof($widget_groups) != 0) { $assigned_groups = array(); foreach ($widget_groups as $field) { if (!empty($field['group_name'])) { if (is_uuid($field['group_uuid'])) { $assigned_groups[] = $field['group_uuid']; } } } } //build the $widget_tools array $i = 0; foreach(glob($_SERVER["DOCUMENT_ROOT"].'/*/*/resources/dashboard/*.php') as $value) { //skip adding config.php to the array if (basename($value) === 'config.php') { continue; } //ensure the slashes are consistent $value = str_replace('\\', '/', $value); //prepare the key $key_replace[] = $_SERVER["DOCUMENT_ROOT"].'/core/'; $key_replace[] = $_SERVER["DOCUMENT_ROOT"].'/app/'; $key_replace[] = 'resources/dashboard/'; $key_replace[] = '.php'; $key = str_replace($key_replace, '', $value); //prepare the value $value_replace[] = $_SERVER["DOCUMENT_ROOT"].'/'; $value = str_replace($value_replace, '', $value); //build the array $widget_tools[$key] = $value; $i++; } //decide what settings to show $widget_settings_config = [ 'shared' => [ 'widget_name', 'widget_path', 'widget_groups', 'widget_label_enabled', 'widget_label_text_color', 'widget_label_background_color', 'widget_background_color', 'widget_detail_background_color', 'widget_background_gradient_style', 'widget_background_gradient_angle', 'widget_details_state', 'widget_column_span', 'widget_row_span', 'widget_parent_uuid', 'widget_order', 'widget_enabled', 'widget_description', ], 'icon' => [ 'widget_icon', 'widget_icon_color', 'widget_url', 'widget_target', 'widget_width', 'widget_height', 'widget_content_details', 'widget_label_text_color_hover', 'widget_label_background_color_hover', 'widget_background_color_hover', ], 'content' => [ 'widget_content', 'widget_content_text_align', 'widget_content_details', ], 'parent' => [//doesn't use shared settings 'widget_name', 'widget_path', 'widget_groups', 'widget_background_color', 'widget_background_gradient_style', 'widget_background_gradient_angle', 'widget_column_span', 'widget_row_span', 'widget_order', 'widget_enabled', 'widget_description', ], 'chart' => [ 'widget_chart_type', 'widget_number_text_color', 'icon' => [ 'widget_icon', 'widget_icon_color', 'widget_label_text_color_hover', 'widget_label_background_color_hover', 'widget_number_text_color_hover', 'widget_number_background_color', 'widget_background_color_hover', ], ], ]; //build the dashboard settings array $widget_settings = $widget_settings_config['shared']; $items_to_remove = []; if ($action == "add" || $widget_path == "dashboard/icon") { $widget_settings = array_merge($widget_settings, $widget_settings_config['icon']); if (empty($widget_url)) { $items_to_remove[] = 'widget_target'; } if (empty($widget_url) || $widget_target != "new") { $items_to_remove[] = 'widget_width'; $items_to_remove[] = 'widget_height'; } if ($widget_label_enabled === false) { $items_to_remove[] = 'widget_label_text_color'; $items_to_remove[] = 'widget_label_text_color_hover'; $items_to_remove[] = 'widget_label_background_color'; $items_to_remove[] = 'widget_label_background_color_hover'; } } else if ($widget_path == "dashboard/content") { $widget_settings = array_merge($widget_settings, $widget_settings_config['content']); } else if ($widget_path == "dashboard/parent") { $widget_settings = $widget_settings_config['parent']; } if (!empty($widget_chart_type) && !empty($widget_chart_type_options)) { $widget_settings = array_merge($widget_settings, array_filter($widget_settings_config['chart'], 'is_scalar')); if ($widget_chart_type == "icon") { $widget_settings = array_merge($widget_settings, $widget_settings_config['chart']['icon']); } else if ($widget_chart_type == "line") { $items_to_remove[] = 'widget_number_text_color'; } } if (empty($widget_details_state) || $widget_details_state == 'none') { $items_to_remove[] = 'widget_details_state'; } $widget_settings = array_diff($widget_settings, $items_to_remove); ?> \n"; echo "\n"; echo "
\n"; echo "
".$text['title-dashboard_widget']."
\n"; echo "
\n"; echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme', 'button_icon_back'),'id'=>'btn_back','collapse'=>'hide-xs','style'=>'margin-right: 15px;','link'=>'dashboard_edit.php?id='.urlencode($dashboard_uuid)]); if ($action == 'update') { if (permission_exists('dashboard_widget_group_add')) { echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$settings->get('theme', 'button_icon_copy'),'id'=>'btn_copy','name'=>'btn_copy','style'=>'display: none;','onclick'=>"modal_open('modal-copy','btn_copy');"]); } if (permission_exists('dashboard_widget_group_delete')) { echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$settings->get('theme', 'button_icon_delete'),'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none; margin-right: 15px;','onclick'=>"modal_open('modal-delete','btn_delete');"]); } } echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$settings->get('theme', 'button_icon_save'),'id'=>'btn_save','collapse'=>'hide-xs']); echo "
\n"; echo "
\n"; echo "
\n"; //echo $text['title_description-dashboard']."\n"; //echo "

\n"; if (!empty($action) && $action == 'update') { if (permission_exists('dashboard_widget_add')) { echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'copy','onclick'=>"modal_close();"])]); } if (permission_exists('dashboard_widget_delete')) { echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'delete','onclick'=>"modal_close();"])]); } } echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; 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('dashboard_widget_parent_uuid')) { echo " \n"; echo " \n"; echo " \n"; echo " \n"; } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; echo $text['label-widget_name'] ?? ''; echo "\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-widget_name']."\n"; echo "
\n"; echo " ".$text['label-widget_path']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-widget_path']."\n"; echo "
".$text['label-icon']."\n"; if (file_exists($_SERVER["PROJECT_ROOT"].'/resources/fontawesome/fa_icons.php')) { include $_SERVER["PROJECT_ROOT"].'/resources/fontawesome/fa_icons.php'; } if (!empty($font_awesome_icons) && is_array($font_awesome_icons)) { echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " = 3) { delay_submit(this.value); } else if (this.value == '') { load_icons(); } else { $('#icons').html(''); }\" placeholder=\"".$text['label-search']."\">\n"; echo "
\n"; echo "\n"; echo "\n"; } else { echo " \n"; } echo $text['description-widget_icon']."\n"; echo "
\n"; echo $text['label-widget_icon_color']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-widget_icon_color']."\n"; echo "
\n"; echo " ".$text['label-link']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-widget_url'] ?? ''; echo "\n"; echo "
\n"; echo $text['label-target']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-widget_target']."\n"; echo "
\n"; echo " ".$text['label-width']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-widget_width'] ?? ''; echo "\n"; echo "
\n"; echo " ".$text['label-height']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-widget_height'] ?? ''; echo "\n"; echo "
\n"; echo " ".$text['label-content']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-widget_content']."\n"; echo "
\n"; echo " ".$text['label-widget_content_text_align']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-widget_content_text_align']."\n"; echo "
\n"; echo " ".$text['label-details']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-widget_content_details']."\n"; echo "
\n"; echo " ".$text['label-widget_groups']."\n"; echo "\n"; if (is_array($widget_groups) && sizeof($widget_groups) != 0) { echo "\n"; if (permission_exists('dashboard_widget_group_delete')) { echo " \n"; echo " \n"; } $x = 0; foreach($widget_groups as $field) { if (!empty($field['group_name'])) { echo "\n"; echo " \n"; if (permission_exists('dashboard_widget_group_delete')) { echo " \n"; } echo "\n"; $x++; } } echo "
\n"; echo $field['group_name'].((!empty($field['domain_uuid'])) ? "@".$_SESSION['domains'][$field['domain_uuid']]['domain_name'] : null); echo " \n"; echo button::create(['type'=>'button','icon'=>'fas fa-minus','id'=>'btn_delete','class'=>'default list_control_icon','name'=>'btn_delete','onclick'=>"modal_open('modal-delete-group-$x','btn_delete');"]); echo modal::create(['id'=>'modal-delete-group-'.$x,'type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); document.getElementById('dashboard_widget_group_uuid').value = '".escape($field['dashboard_widget_group_uuid'])."'; list_form_submit('frm');"])]); echo "
\n"; } if (!empty($groups) && is_array($groups)) { if (!empty($widget_groups)) { echo "
\n"; } echo "\n"; echo button::create(['type'=>'submit','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add')]); } echo "
\n"; echo $text['description-widget_groups']."\n"; echo "
\n"; echo $text['label-widget_chart_type']."\n"; echo "\n"; echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo $text['description-widget_chart_type']."\n"; echo "
\n"; echo $text['label-widget_label_enabled'] ?? ''; echo "\n"; echo "\n"; if ($input_toggle_style_switch) { echo " \n"; } echo " \n"; if ($input_toggle_style_switch) { echo " \n"; echo " \n"; } echo "
\n"; echo $text['description-widget_label_enabled']."\n"; echo "
\n"; echo $text['label-widget_label_text_color']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-widget_label_text_color']."\n"; echo "
\n"; echo $text['label-widget_label_text_color_hover']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-widget_label_text_color_hover']."\n"; echo "
\n"; echo $text['label-widget_label_background_color']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-widget_label_background_color']."\n"; echo "
\n"; echo $text['label-widget_label_background_color_hover']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-widget_label_background_color_hover']."\n"; echo "
\n"; echo $text['label-widget_number_text_color']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-widget_number_text_color']."\n"; echo "
\n"; echo $text['label-widget_number_text_color_hover']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-widget_number_text_color_hover']."\n"; echo "
\n"; echo $text['label-widget_number_background_color']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-widget_number_background_color']."\n"; echo "
\n"; echo $text['label-widget_background_color']."\n"; echo "\n"; if (!empty($widget_background_color) && is_array($widget_background_color)) { foreach ($widget_background_color as $c => $background_color) { echo " \n"; if ($c < sizeof($widget_background_color) - 1) { echo "
\n"; } } //swap button if (!empty($widget_background_color) && is_array($widget_background_color) && sizeof($widget_background_color) > 1) { echo " \n"; echo button::create(['type'=>'button','title'=>$text['button-swap'],'icon'=>'fa-solid fa-arrow-right-arrow-left fa-rotate-90','style'=>"z-index: 0; position: absolute; display: inline-block; margin: -14px 0 0 7px;",'onclick'=>"document.getElementById('widget_background_color_temp').value = document.getElementById('widget_background_color_0').value; document.getElementById('widget_background_color_0').value = document.getElementById('widget_background_color_1').value; document.getElementById('widget_background_color_1').value = document.getElementById('widget_background_color_temp').value; this.blur();"])."
\n"; } else { echo "
\n"; } } if (empty($widget_background_color) || (is_array($widget_background_color) && count($widget_background_color) < 2)) { echo " \n"; if (empty($widget_background_color)) { echo " \n"; } } if (!empty($widget_background_color) && !is_array($widget_background_color)) { echo "
\n"; echo "
\n"; } echo $text['description-widget_background_color']."\n"; echo "
\n"; echo $text['label-widget_background_color_hover']."\n"; echo "\n"; if (!empty($widget_background_color_hover) && is_array($widget_background_color_hover)) { foreach ($widget_background_color_hover as $c => $background_color) { echo " \n"; if ($c < sizeof($widget_background_color_hover) - 1) { echo "
\n"; } } //swap button if (!empty($widget_background_color_hover) && is_array($widget_background_color_hover) && sizeof($widget_background_color_hover) > 1) { echo " \n"; echo button::create(['type'=>'button','title'=>$text['button-swap'],'icon'=>'fa-solid fa-arrow-right-arrow-left fa-rotate-90','style'=>"z-index: 0; position: absolute; display: inline-block; margin: -14px 0 0 7px;",'onclick'=>"document.getElementById('widget_background_color_hover_temp').value = document.getElementById('widget_background_color_hover_0').value; document.getElementById('widget_background_color_hover_0').value = document.getElementById('widget_background_color_hover_1').value; document.getElementById('widget_background_color_hover_1').value = document.getElementById('widget_background_color_hover_temp').value; this.blur();"])."
\n"; } else { echo "
\n"; } } if (empty($widget_background_color_hover) || (is_array($widget_background_color_hover) && count($widget_background_color_hover) < 2)) { echo " \n"; if (empty($widget_background_color_hover)) { echo " \n"; } } if (!empty($widget_background_color_hover) && !is_array($widget_background_color_hover)) { echo "
\n"; echo "
\n"; } echo $text['description-widget_background_color_hover']."\n"; echo "
\n"; echo $text['label-widget_detail_background_color']."\n"; echo "\n"; if (!empty($widget_detail_background_color) && is_array($widget_detail_background_color)) { foreach ($widget_detail_background_color as $c => $detail_background_color) { echo " \n"; if ($c < sizeof($widget_detail_background_color) - 1) { echo "
\n"; } } //swap button if (!empty($widget_detail_background_color) && is_array($widget_detail_background_color) && sizeof($widget_detail_background_color) > 1) { echo " \n"; echo button::create(['type'=>'button','title'=>$text['button-swap'],'icon'=>'fa-solid fa-arrow-right-arrow-left fa-rotate-90','style'=>"z-index: 0; position: absolute; display: inline-block; margin: -14px 0 0 7px;",'onclick'=>"document.getElementById('widget_detail_background_color_temp').value = document.getElementById('widget_detail_background_color_0').value; document.getElementById('widget_detail_background_color_0').value = document.getElementById('widget_detail_background_color_1').value; document.getElementById('widget_detail_background_color_1').value = document.getElementById('widget_detail_background_color_temp').value; this.blur();"])."
\n"; } else { echo "
\n"; } } if (empty($widget_detail_background_color) || (is_array($widget_detail_background_color) && count($widget_detail_background_color) < 2)) { echo " \n"; if (empty($widget_detail_background_color)) { echo " \n"; } } if (!empty($widget_detail_background_color) && !is_array($widget_detail_background_color)) { echo "
\n"; echo "
\n"; } echo $text['description-widget_detail_background_color']."\n"; echo "
\n"; echo $text['label-widget_background_gradient_style']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-widget_background_gradient_style']."\n"; echo "
\n"; echo $text['label-widget_background_gradient_angle']."\n"; echo "\n"; echo "
\n"; echo " \n"; echo " \n"; echo "
\n"; echo $text['description-widget_background_gradient_angle']."\n"; echo "
\n"; echo " ".$text['label-widget_column_span']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-widget_column_span']."\n"; echo "
\n"; echo " ".$text['label-widget_row_span']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-widget_row_span']."\n"; echo "
\n"; echo " ".$text['label-widget_details_state']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-widget_details_state']."\n"; echo "
".$text['label-dashboard_widget_parent_uuid']."\n"; echo " \n"; echo "
\n"; echo $text['description-dashboard_widget_parent_uuid']."\n"; echo "
\n"; echo " ".$text['label-widget_order']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-widget_order']."\n"; echo "
\n"; echo " ".$text['label-widget_enabled']."\n"; echo "\n"; if ($input_toggle_style_switch) { echo " \n"; } echo " \n"; if ($input_toggle_style_switch) { echo " \n"; echo " \n"; } echo "
\n"; echo $text['description-widget_enabled']."\n"; echo "
\n"; echo " ".$text['label-widget_description']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-widget_description']."\n"; echo "
\n"; echo "
\n"; echo "

\n"; echo "\n"; echo "\n"; //include the footer require_once "resources/footer.php"; ?>