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_view')) { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //set additional variables $search = $_GET["search"] ?? ''; $show = $_GET["show"] ?? ''; //get the http post data if (!empty($_POST['dashboards'])) { $action = $_POST['action']; $search = $_POST['search'] ?? ''; $dashboards = $_POST['dashboards']; } //process the http post data by action if (!empty($action) && is_array($dashboards) && @sizeof($dashboards) != 0) { switch ($action) { case 'copy': if (permission_exists('dashboard_add')) { $obj = new dashboard; $obj->copy($dashboards); } break; case 'toggle': if (permission_exists('dashboard_edit')) { $obj = new dashboard; $obj->toggle($dashboards); } break; case 'delete': if (permission_exists('dashboard_delete')) { $obj = new dashboard; $obj->delete($dashboards); } break; } //redirect the user header('Location: dashboard.php'.($search != '' ? '?search='.urlencode($search) : '')); exit; } //get order and order by $order_by = $_GET["order_by"] ?? null; $order = $_GET["order"] ?? null; //get the count $sql = "select count(dashboard_uuid) "; $sql .= "from v_dashboards "; $sql .= "where true \n"; if ($show == "all" && permission_exists('dashboard_all')) { //$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; //$parameters['domain_uuid'] = $_SESSION['domain_uuid']; } else { $sql .= "and ( "; $sql .= " domain_uuid = :domain_uuid "; if (permission_exists('dashboard_domain')) { $sql .= " or domain_uuid is null "; } $sql .= ") "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; } if (isset($_GET["search"])) { $sql .= "and (\n"; $sql .= " lower(dashboard_name) like :search \n"; $sql .= " or lower(dashboard_description) like :search \n"; $sql .= ")\n"; $parameters['search'] = '%'.strtolower($search).'%'; } $num_rows = $database->select($sql, $parameters ?? null, 'column'); unset($sql, $parameters); //get the list $sql = "select \n"; $sql .= "domain_uuid, \n"; $sql .= "dashboard_uuid, \n"; $sql .= "dashboard_name, \n"; $sql .= "cast(dashboard_enabled as text), \n"; $sql .= "dashboard_description \n"; $sql .= "from v_dashboards as d \n"; $sql .= "where true \n"; if ($show == "all" && permission_exists('dashboard_all')) { //$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; //$parameters['domain_uuid'] = $_SESSION['domain_uuid']; } else { $sql .= "and ( "; $sql .= " domain_uuid = :domain_uuid "; if (permission_exists('dashboard_domain')) { $sql .= " or domain_uuid is null "; } $sql .= ") "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; } if (isset($_GET["search"])) { $sql .= "and (\n"; $sql .= " lower(dashboard_name) like :search \n"; $sql .= " or lower(dashboard_description) like :search \n"; $sql .= ")\n"; $parameters['search'] = '%'.strtolower($search).'%'; } $sql .= order_by($order_by, $order, 'dashboard_name', 'asc'); $sql .= limit_offset($rows_per_page ?? null, $offset ?? null); $dashboards = $database->select($sql, $parameters ?? null, 'all'); unset($sql, $parameters); //create token $object = new token; $token = $object->create($_SERVER['PHP_SELF']); //additional includes $document['title'] = $text['title-dashboards']; require_once "resources/header.php"; //show the content echo "
\n"; echo "
".$text['title-dashboards']."
".number_format($num_rows)."
\n"; echo "
\n"; echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme', 'button_icon_back'),'id'=>'btn_back','name'=>'btn_back','style'=>'margin-right: 15px;','link'=>'index.php']); if (permission_exists('dashboard_add')) { echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','name'=>'btn_add','link'=>'dashboard_edit.php']); } if (permission_exists('dashboard_add') && !empty($dashboards)) { 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_edit') && !empty($dashboards)) { echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$settings->get('theme', 'button_icon_toggle'),'id'=>'btn_toggle','name'=>'btn_toggle','style'=>'display:none;','onclick'=>"modal_open('modal-toggle','btn_toggle');"]); } if (permission_exists('dashboard_delete') && !empty($dashboards)) { 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;','onclick'=>"modal_open('modal-delete','btn_delete');"]); } if (permission_exists('domain_all')) { if ($show == 'all') { echo " "; } else { echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$settings->get('theme', 'button_icon_all'),'link'=>'?type='.urlencode($destination_type ?? '').'&show=all'.($search != '' ? "&search=".urlencode($search ?? '') : null)]); } } echo "\n"; echo "
\n"; echo "
\n"; echo "
\n"; if (permission_exists('dashboard_add') && !empty($dashboards)) { echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('copy'); list_form_submit('form_list');"])]); } if (permission_exists('dashboard_edit') && !empty($dashboards)) { echo modal::create(['id'=>'modal-toggle','type'=>'toggle','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_toggle','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('toggle'); list_form_submit('form_list');"])]); } if (permission_exists('dashboard_delete') && !empty($dashboards)) { echo modal::create(['id'=>'modal-delete','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'); list_form_submit('form_list');"])]); } echo "
\n"; echo "\n"; echo "\n"; echo "
\n"; echo "\n"; echo "\n"; if (permission_exists('dashboard_add') || permission_exists('dashboard_edit') || permission_exists('dashboard_delete')) { echo " \n"; } if ($show == 'all' && permission_exists('dashboard_all')) { echo th_order_by('domain_name', $text['label-domain'], $order_by, $order); } echo th_order_by('dashboard_name', $text['label-dashboard_name'], $order_by, $order); echo th_order_by('dashboard_enabled', $text['label-dashboard_enabled'], $order_by, $order, null, "class='center'"); echo " \n"; if (permission_exists('dashboard_edit') && $settings->get('theme', 'list_row_edit_button', false)) { echo " \n"; } echo "\n"; if (!empty($dashboards)) { $x = 0; foreach ($dashboards as $row) { $list_row_url = ''; if (permission_exists('dashboard_edit')) { $list_row_url = "dashboard_edit.php?id=".urlencode($row['dashboard_uuid']); if (!empty($row['domain_uuid']) && $row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) { $list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true'; } } echo "\n"; if (permission_exists('dashboard_add') || permission_exists('dashboard_edit') || permission_exists('dashboard_delete')) { echo " \n"; } if (!empty($show) && $show == 'all' && permission_exists('domain_all')) { if (!empty($row['domain_uuid']) && is_uuid($row['domain_uuid'])) { echo " \n"; } else { echo " \n"; } } echo " \n"; if (permission_exists('dashboard_edit')) { echo " \n"; echo " \n"; if (permission_exists('dashboard_edit') && $settings->get('theme', 'list_row_edit_button', false)) { echo " \n"; } echo "\n"; $x++; } unset($dashboards); } echo "
\n"; echo " \n"; echo " ".$text['label-dashboard_description']." 
\n"; echo " \n"; echo " \n"; echo " ".escape($_SESSION['domains'][$row['domain_uuid']]['domain_name'])."".$text['label-global']."\n"; if (permission_exists('dashboard_edit')) { echo " ".escape($row['dashboard_name'])."\n"; } else { echo " ".escape($row['dashboard_name']); } echo " \n"; echo $text['label-'.($row['dashboard_enabled']?:'false')]; } echo " ".escape($row['dashboard_description'])."\n"; echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$settings->get('theme', 'button_icon_edit'),'link'=>$list_row_url]); echo "
\n"; echo "
\n"; echo "
\n"; echo "
".($paging_controls ?? '')."
\n"; echo "\n"; echo "
\n"; //include the footer require_once "resources/footer.php"; ?>