From 0e59b56b220630128296e50c15fe507971702360 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Fri, 15 Sep 2023 12:34:25 +0200 Subject: [PATCH] Added functionality that allows you to filter table information. --- .../include/lib/Dashboard/Manager.php | 20 +++++- pandora_console/views/dashboard/list.php | 68 +++++++++++++++++++ 2 files changed, 86 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/lib/Dashboard/Manager.php b/pandora_console/include/lib/Dashboard/Manager.php index 40b6d2d1a0..181777b405 100644 --- a/pandora_console/include/lib/Dashboard/Manager.php +++ b/pandora_console/include/lib/Dashboard/Manager.php @@ -731,7 +731,8 @@ class Manager implements PublicLogin int $limit=-1, bool $favourite=false, bool $slideshow=false, - string $id_user='' + string $id_user='', + array $rowFilter=[] ):array { global $config; @@ -749,6 +750,14 @@ class Manager implements PublicLogin $sql_where .= 'AND td.cells_slideshow = 1'; } + if (empty((int) $rowFilter['id_group']) === false) { + $sql_where .= ' AND td.id_group = '.$rowFilter['id_group']; + } + + if (empty($rowFilter['name_filter']) === false) { + $sql_where .= ' AND td.name like "%'.$rowFilter['name_filter'].'%"'; + } + if (empty($id_user) === true) { $id_user = $config['id_user']; } @@ -944,6 +953,13 @@ class Manager implements PublicLogin private function showList() { global $config; + $id_group_filter = \get_parameter_post('id_group', ''); + $name_filter = \get_parameter_post('name', ''); + + $rowFilter = [ + 'id_group' => $id_group_filter, + 'name_filter' => $name_filter, + ]; $limit_sql = $config['block_size']; @@ -957,7 +973,7 @@ class Manager implements PublicLogin $resultCopy = $this->copy(); } - $dashboards = $this->getDashboards($this->offset, $limit_sql); + $dashboards = $this->getDashboards($this->offset, $limit_sql, false, false, '', $rowFilter); $count = $this->getDashboardsCount(); View::render( diff --git a/pandora_console/views/dashboard/list.php b/pandora_console/views/dashboard/list.php index 2645724a6e..fe6802392e 100644 --- a/pandora_console/views/dashboard/list.php +++ b/pandora_console/views/dashboard/list.php @@ -67,6 +67,74 @@ if (isset($resultCopy) === true) { ); } +// Filter table. +$filter_id_group = \get_parameter_post('id_group', ''); +$filter_name = \get_parameter_post('name', ''); + +$filterTable = new stdClass(); +$filterTable->class = 'filter-table-adv w100p'; +$filterTable->size[0] = '20%'; +$filterTable->size[1] = '20%'; +$filterTable->data = []; + +$filterTable->data[0][0] = html_print_label_input_block( + __('Group'), + html_print_select_groups( + false, + 'AR', + true, + 'id_group', + $filter_id_group, + '', + '', + '', + true, + false, + true, + 'w100p', + false, + '' + ) +); + +$filterTable->data[0][1] = html_print_label_input_block( + __('Name'), + html_print_input_text('name', $filter_name, '', 25, 80, true) +); + +$form_html = ''; + +ui_toggle( + $form_html, + ''.__('Filter').'', + 'dashboard_search', + false, + true, + false, + '', + 'white-box-content', + 'box-flat white_table_graph fixed_filter_bar' +); + + if (empty($dashboards) === true) { ui_print_info_message( [