Portions created by the Initial Developer are Copyright (C) 2021 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ //include the root directory include "root.php"; //if config.php file does not exist then redirect to the install page if (file_exists($_SERVER["PROJECT_ROOT"]."/resources/config.php")) { //do nothing } elseif (file_exists($_SERVER["PROJECT_ROOT"]."/resources/config.php")) { //original directory } elseif (file_exists("/etc/fusionpbx/config.php")){ //linux } elseif (file_exists("/usr/local/etc/fusionpbx/config.php")){ //bsd } else { header("Location: ".PROJECT_PATH."/core/install/install.php"); exit; } //additional includes require_once "resources/check_auth.php"; //disable login message if (isset($_GET['msg']) && $_GET['msg'] == 'dismiss') { unset($_SESSION['login']['message']['text']); $sql = "update v_default_settings "; $sql .= "set default_setting_enabled = 'false' "; $sql .= "where "; $sql .= "default_setting_category = 'login' "; $sql .= "and default_setting_subcategory = 'message' "; $sql .= "and default_setting_name = 'text' "; $database = new database; $database->execute($sql); unset($sql); } //build a list of groups the user is a member of to be used in a SQL in foreach($_SESSION['user']['groups'] as $group) { $group_uuids[] = $group['group_uuid']; } $group_uuids_in = "'".implode("','", $group_uuids)."'"; //get the list $sql = "select \n"; $sql .= "dashboard_uuid, \n"; $sql .= "dashboard_name, \n"; $sql .= "dashboard_path, \n"; $sql .= "dashboard_column_span, \n"; $sql .= "dashboard_order, \n"; $sql .= "cast(dashboard_enabled as text), \n"; $sql .= "dashboard_description \n"; $sql .= "from v_dashboard as d \n"; $sql .= "where dashboard_enabled = 'true' \n"; $sql .= "and dashboard_uuid in (\n"; $sql .= " select dashboard_uuid from v_dashboard_groups where group_uuid in (\n"; $sql .= " ".$group_uuids_in." \n"; $sql .= " )\n"; $sql .= ")\n"; $sql .= "order by dashboard_order asc \n"; $database = new database; $dashboard = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); //get http post variables and set them to php variables if (count($_POST) > 0 && permission_exists('dashboard_edit')) { //set the variables from the http values if (isset($_POST["widget_order"])) { $widgets = explode(",", $_POST["widget_order"]); $dashboard_order = '0'; $x = 0; foreach($widgets as $widget) { foreach($dashboard as $row) { $dashboard_name = strtolower($row['dashboard_name']); $dashboard_name = str_replace(" ", "_", $dashboard_name); if ($widget == $dashboard_name) { $dashboard_order = $dashboard_order + 10; $array['dashboard'][$x]['dashboard_name'] = $row['dashboard_name']; $array['dashboard'][$x]['dashboard_uuid'] = $row['dashboard_uuid']; $array['dashboard'][$x]['dashboard_order'] = $dashboard_order; $x++; } } } //save the data $database = new database; $database->app_name = 'dashboard'; $database->app_uuid = '55533bef-4f04-434a-92af-999c1e9927f7'; $database->save($array); //redirect the browser message::add($text['message-update']); header("Location: /core/dashboard/index.php"); return; } } //add multi-lingual support $language = new text; $text = $language->get(); //load the header $document['title'] = $text['title-dashboard']; require_once "resources/header.php"; //include sortablejs echo ""; //include chart.js echo ""; //chart variables ?> \n"; echo "
\n"; echo "
".$text['title-dashboard']."
\n"; echo "
\n"; if ($_SESSION['theme']['menu_style']['text'] != 'side') { echo " ".$text['label-welcome']." ".$_SESSION["username"]."   "; } if (permission_exists('dashboard_edit')) { if ($_GET['edit'] == 'true') { echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','name'=>'btn_back','link'=>'index.php']); echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','name'=>'btn_save']); } else { echo button::create(['type'=>'button','label'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'id'=>'btn_edit','name'=>'btn_edit','link'=>'index.php?edit=true']); } echo button::create(['type'=>'button','label'=>$text['button-settings'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','name'=>'btn_add','link'=>'dashboard.php']); } echo "
\n"; echo "
".$text['description-dashboard']."
\n"; echo "
\n"; echo "\n"; echo "\n"; //display login message if (if_group("superadmin") && isset($_SESSION['login']['message']['text']) && $_SESSION['login']['message']['text'] != '') { echo "
".$text['login-message_attention']."  ".$_SESSION['login']['message']['text']."  (".$text['login-message_dismiss'].")
\n"; } ?> \n"; $x = 0; foreach($dashboard as $row) { $dashboard_name = strtolower($row['dashboard_name']); $dashboard_name = str_replace(" ", "_", $dashboard_name); $draggable = ''; if ($_GET['edit'] == 'true') { $draggable = "draggable='true'"; } echo "
\n"; include($row['dashboard_path']); echo "
\n"; $x++; } echo "\n"; //begin edit if ($_GET['edit'] == 'true') { ?>