From 8ac9df14abea9047d70d529c38cf3a34f19e4fcc Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 28 Feb 2023 19:01:37 +0100 Subject: [PATCH] fixed styles --- pandora_console/include/ajax/module.php | 1 - pandora_console/include/class/Tree.class.php | 1 - .../include/functions_groupview.php | 2 +- .../include/functions_inventory.php | 139 ++-- pandora_console/include/functions_profile.php | 2 - pandora_console/include/functions_ui.php | 16 +- pandora_console/include/styles/tables.css | 4 + .../operation/agentes/alerts_status.php | 76 +- .../operation/agentes/status_monitor.php | 48 +- .../operation/inventory/inventory.php | 684 +++++++++++------- pandora_console/operation/tree.php | 50 +- 11 files changed, 587 insertions(+), 436 deletions(-) diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index ab5695e6f3..9e57c89c1a 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -1158,7 +1158,6 @@ if (check_login()) { } } - hd($data[4], true); // Module thresholds. $data[5] = ''; if ((int) $module['id_tipo_modulo'] !== 25) { diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index 53be0839b3..aa4b98aa86 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -669,7 +669,6 @@ class Tree } $module['statusImageHTML'] = ui_print_status_image($statusType, htmlspecialchars($statusTitle), true, ['is_tree_view' => true]); - hd($module['statusImageHTML'], true); // HTML of the server type image. $module['serverTypeHTML'] = ui_print_servertype_icon((int) $module['server_type']); diff --git a/pandora_console/include/functions_groupview.php b/pandora_console/include/functions_groupview.php index a87bea1650..5554343730 100644 --- a/pandora_console/include/functions_groupview.php +++ b/pandora_console/include/functions_groupview.php @@ -176,7 +176,7 @@ function groupview_get_groups_list($id_user=false, $access='AR', $is_not_paginat [] ); - $total_counters = []; + $list = []; foreach ($agents_counters as $id_group => $agent_counter) { $list[$id_group]['_name_'] = $agent_counter['name']; diff --git a/pandora_console/include/functions_inventory.php b/pandora_console/include/functions_inventory.php index 4146e9f2ac..050f37fe0a 100644 --- a/pandora_console/include/functions_inventory.php +++ b/pandora_console/include/functions_inventory.php @@ -718,7 +718,7 @@ function inventory_get_datatable( } if (array_search(-1, $agents_ids) === false) { - array_push($where, 'id_agente IN ('.implode(',', $agents_ids).')'); + array_push($where, 'tagent_module_inventory.id_agente IN ('.implode(',', $agents_ids).')'); } if ($inventory_module_name[0] !== '0' @@ -732,75 +732,61 @@ function inventory_get_datatable( array_push($where, "tagent_module_inventory.data LIKE '%".$inventory_search_string."%'"); } - $sql = 'SELECT * - FROM tmodule_inventory, tagent_module_inventory - WHERE - '.implode(' AND ', $where).' - ORDER BY tmodule_inventory.id_module_inventory LIMIT '.$offset.', '.$config['block_size']; - - $sql_count = 'SELECT COUNT(*) - FROM tmodule_inventory, tagent_module_inventory - WHERE '.implode(' AND ', $where); + $sql = sprintf( + 'SELECT tmodule_inventory.*, + tagent_module_inventory.*, + tagente.alias as name_agent + FROM tmodule_inventory + INNER JOIN tagent_module_inventory + ON tmodule_inventory.id_module_inventory = tagent_module_inventory.id_module_inventory + LEFT JOIN tagente + ON tagente.id_agente = tagent_module_inventory.id_agente + WHERE %s + ORDER BY tmodule_inventory.id_module_inventory + LIMIT %d, %d', + implode(' AND ', $where), + $offset, + $config['block_size'] + ); $rows = db_get_all_rows_sql($sql); - $count = db_get_sql($sql_count); if ($order_by_agent === false) { $modules = []; - $module_rows = []; - foreach ($rows as $row) { - array_push($modules, $row['name']); - } - - foreach ($modules as $module) { - $rows_tmp = []; - foreach ($rows as $row) { - if ($row['name'] === $module) { - $agent_name = db_get_value_sql( - 'SELECT alias - FROM tagente - WHERE id_agente = '.$row['id_agente'] - ); - - $row['name_agent'] = $agent_name; - array_push($rows_tmp, $row); - $module_rows[$module] = $rows_tmp; + $data_rows = explode(PHP_EOL, $row['data']); + foreach ($data_rows as $data_key => $data_value) { + if (empty($data_value) === false) { + $row['data'] = $data_value; + $modules[$row['name']][$row['name_agent'].'-'.$data_key.'-'.$data_value] = $row; } } } - return $module_rows; + return $modules; } else { $agents_rows = []; $agent_data = []; $rows_tmp = []; foreach ($rows as $row) { - $agent_name = db_get_value_sql( - 'SELECT alias - FROM tagente - WHERE id_agente = '.$row['id_agente'] - ); - $row['name_agent'] = $agent_name; $agent_data[$row['id_agente']][] = $row; } foreach ($agent_data as $id_agent => $rows) { - $agent_name = db_get_value_sql( - 'SELECT alias - FROM tagente - WHERE id_agente = '.$id_agent - ); - - $rows_tmp['agent'] = $agent_name; - + $rows_tmp['agent'] = $row['name_agent']; foreach ($rows as $row) { if ($utimestamp > 0) { $data_row = db_get_row_sql( - "SELECT data, timestamp - FROM tagente_datos_inventory - WHERE utimestamp <= '".$utimestamp."' - AND id_agent_module_inventory = ".$row['id_agent_module_inventory'].' ORDER BY utimestamp DESC' + sprintf( + 'SELECT `data`, + `timestamp` + FROM tagente_datos_inventory + WHERE utimestamp <= "%s" + AND id_agent_module_inventory = %d + ORDER BY utimestamp DESC', + $utimestamp, + $row['id_agent_module_inventory'] + ) ); if ($data_row !== false) { @@ -821,6 +807,63 @@ function inventory_get_datatable( } +function get_data_basic_info_sql($params, $count=false) +{ + $where = 'WHERE 1=1 '; + if ($params['id_agent'] > 0) { + $where .= sprintf(' AND id_agente = %d', $params['id_agent']); + } + + if ($params['search'] > 0) { + $where .= sprintf( + ' AND ( alias LIKE "%%%s%%" )', + $params['search'] + ); + } + + $limit_condition = ''; + $order_condition = ''; + $fields = 'count(*)'; + if ($count !== true) { + $fields = '*'; + + $limit_condition = sprintf( + 'LIMIT %d, %d', + $params['start'], + $params['length'] + ); + + $order_condition = sprintf('ORDER BY %s', $params['order']); + } + + $sql = sprintf( + 'SELECT %s + FROM tagente + %s + %s + %s', + $fields, + $where, + $order_condition, + $limit_condition + ); + + if ($count !== true) { + $result = db_get_all_rows_sql($sql); + if ($result === false) { + $result = []; + } + } else { + $result = db_get_sql($sql); + if ($result === false) { + $result = 0; + } + } + + return $result; +} + + function inventory_get_dates($module_inventory_name, $inventory_agent, $inventory_id_group) { $sql = 'SELECT tagente_datos_inventory.utimestamp, diff --git a/pandora_console/include/functions_profile.php b/pandora_console/include/functions_profile.php index a2eb45a3a2..d656cdeff2 100644 --- a/pandora_console/include/functions_profile.php +++ b/pandora_console/include/functions_profile.php @@ -225,7 +225,6 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c } else { // Only profiles that can be viewed by the user. $group_um = users_get_groups_UM($config['id_user']); - hd($group_um, true); if (isset($group_um[0]) === true) { $group_um_string = implode(',', array_keys(users_get_groups($config['id_user'], 'um', true))); } else { @@ -239,7 +238,6 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c $id, $group_um_string ); - hd($sql, true); $result = db_get_all_rows_sql($sql); } diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index bc51e9613e..b65dbb2b51 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -3728,11 +3728,6 @@ function ui_print_datatable(array $parameters) $("#'.$form_id.'_loading").remove(); } - // Move elements to table_action_buttons bar. - $(".action_buttons_right_content").append($("#'.$table_id.'_wrapper > .dataTables_paginate.paging_simple_numbers")); - $(".action_buttons_right_content").append($("#'.$table_id.'_wrapper > .dataTables_length")); - $(".action_buttons_right_content").append($("#'.$table_id.'_wrapper > .dt-buttons")); - if (json.error) { console.error(json.error); $("#error-'.$table_id.'").html(json.error); @@ -3904,6 +3899,13 @@ function ui_print_datatable(array $parameters) { bSortable: false, targets: '.$no_sortable_columns.' } ], ordering: '.$ordering.', + initComplete: function(settings, json) { + // Move elements to table_action_buttons bar. + $(".action_buttons_right_content").append($("#'.$table_id.'_wrapper > .dataTables_paginate.paging_simple_numbers")); + $(".action_buttons_right_content").append($("#'.$table_id.'_wrapper > .dataTables_length")); + $(".action_buttons_right_content").append($("#'.$table_id.'_wrapper > .dt-buttons")); + $(".action_buttons_right_content").append($("#'.$table_id.'_wrapper > .dataTables_filter")); + }, columns: ['; foreach ($parameters['datacolumns'] as $data) { @@ -3926,8 +3928,6 @@ function ui_print_datatable(array $parameters) $("#button-'.$form_id.'_search_bt").click(function (){ dt_'.$table_id.'.draw().page(0) }); - - //$(".action_buttons_right_content").html($("#'.$table_id.'_wrapper > .dataTables_paginate.paging_simple_numbers")); '; if (isset($parameters['caption']) === true @@ -4407,7 +4407,7 @@ function ui_toggle( $class_table = ''; if ($id_table !== false) { - $class_table = ' $("#'.$id_table.'_wrapper").addClass("w100p");'."\n"; + $class_table = '$("#'.$id_table.'_wrapper").addClass("w100p");'."\n"; } if ($disableToggle === false) { diff --git a/pandora_console/include/styles/tables.css b/pandora_console/include/styles/tables.css index 451d653905..1288832df2 100644 --- a/pandora_console/include/styles/tables.css +++ b/pandora_console/include/styles/tables.css @@ -727,3 +727,7 @@ tr.datos2 > td.datos2 > div > div { .mgn_tp_0_imp { margin-top: 0px !important; } + +.dataTables_wrapper .dataTables_filter input { + margin: 0.5em; +} diff --git a/pandora_console/operation/agentes/alerts_status.php b/pandora_console/operation/agentes/alerts_status.php index 89ac59d704..a7c8cd56b7 100755 --- a/pandora_console/operation/agentes/alerts_status.php +++ b/pandora_console/operation/agentes/alerts_status.php @@ -184,35 +184,27 @@ if ($idAgent != 0) { $print_agent = true; - if (is_metaconsole() === false) { - // Header. - ui_print_standard_header( - __('Alert detail'), - 'images/op_alerts.png', - false, - '', - false, - [], + // Header. + ui_print_standard_header( + __('Alert detail'), + 'images/op_alerts.png', + false, + '', + false, + [], + [ [ - [ - 'link' => '', - 'label' => __('Monitoring'), - ], - [ - 'link' => '', - 'label' => __('Views'), - ], - ] - ); - } else { - ui_meta_print_header(__('Alerts view')); - } + 'link' => '', + 'label' => __('Monitoring'), + ], + [ + 'link' => '', + 'label' => __('Views'), + ], + ] + ); } - -enterprise_hook('open_meta_frame'); - - $alerts = []; if ($tab != null) { @@ -237,7 +229,6 @@ if (is_metaconsole() === false) { [ 'title' => __('Standby'), 'text' => __('Standby'), - 'style' => 'max-width: 5%;', ], ); @@ -252,7 +243,6 @@ if (is_metaconsole() === false) { [ 'title' => __('Policy'), 'text' => __('Policy'), - 'style' => 'max-width: 5%;vertical-align: baseline;', ] ); @@ -278,26 +268,11 @@ if (is_metaconsole() === false) { if ((bool) check_acl($config['id_user'], $id_group, 'AW') === true || (bool) check_acl($config['id_user'], $id_group, 'LM') === true) { array_push( $column_names, - [ - 'text' => 'Module', - 'style' => 'min-width: 15%;vertical-align: baseline;', - ], - [ - 'text' => 'Template', - 'style' => 'min-width: 10%;vertical-align: baseline;', - ], - [ - 'text' => 'Operation', - 'style' => 'min-width: 15%;vertical-align: baseline;', - ], - [ - 'text' => 'Last fired', - 'style' => 'min-width: 15%;', - ], - [ - 'text' => 'Status', - 'style' => 'width: 5%;', - ] + ['text' => 'Module'], + ['text' => 'Template'], + ['text' => 'Operation'], + ['text' => 'Last fired'], + ['text' => 'Status'] ); $columns = array_merge( @@ -439,7 +414,7 @@ if ($agent_view_page === true) { [ 'id' => 'alerts_status_datatable', 'class' => 'info_table', - 'style' => 'width: 99%', + 'style' => 'width: 99%;', 'columns' => $columns, 'column_names' => $column_names, 'no_sortable_columns' => $no_sortable_columns, @@ -538,9 +513,6 @@ html_print_input_text('strict_user_hidden', $strict_user); html_print_input_text('is_meta_hidden', (int) is_metaconsole()); echo ''; -enterprise_hook('close_meta_frame'); - - ui_require_css_file('cluetip', 'include/styles/js/'); ui_require_jquery_file('cluetip'); ?> diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index bdb96133db..91869e9ceb 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -50,7 +50,9 @@ enterprise_include_once('include/functions_metaconsole.php'); $isFunctionPolicies = enterprise_include_once('include/functions_policies.php'); -if (! defined('METACONSOLE')) { +$buttons = []; +$subpage = ''; +if (is_metaconsole() === false) { $section = (string) get_parameter('section', 'view'); $buttons['fields'] = [ @@ -89,34 +91,36 @@ if (! defined('METACONSOLE')) { $buttons['view']['active'] = true; break; } +} - // Header. - ui_print_standard_header( - __('Monitor detail').$subpage, - 'images/agent.png', - false, - '', - true, - $buttons, +// Header. +ui_print_standard_header( + __('Monitor detail').$subpage, + 'images/agent.png', + false, + '', + true, + $buttons, + [ [ - [ - 'link' => '', - 'label' => __('Monitoring'), - ], - [ - 'link' => '', - 'label' => __('Views'), - ], - ] - ); + 'link' => '', + 'label' => __('Monitoring'), + ], + [ + 'link' => '', + 'label' => __('Views'), + ], + ] +); + +if (is_metaconsole() === false) { if ($section == 'fields') { include_once $config['homedir'].'/godmode/agentes/status_monitor_custom_fields.php'; exit(); } } else { $section = (string) get_parameter('sec', 'estado'); - ui_meta_print_header(__('Monitor view')); } $recursion = get_parameter_switch('recursion', false); @@ -191,8 +195,6 @@ if ($id_module) { $ag_freestring = modules_get_agentmodule_agent_alias($id_module); } -enterprise_hook('open_meta_frame'); - // Get Groups and profiles from user. $user_groups = implode(',', array_keys(users_get_groups(false, 'AR', false))); @@ -2240,8 +2242,6 @@ echo "
"; echo ''; echo ''; -enterprise_hook('close_meta_frame'); - ui_require_javascript_file('pandora_modules'); ?> diff --git a/pandora_console/operation/inventory/inventory.php b/pandora_console/operation/inventory/inventory.php index 2565879afa..45caeb85a7 100755 --- a/pandora_console/operation/inventory/inventory.php +++ b/pandora_console/operation/inventory/inventory.php @@ -32,6 +32,7 @@ require_once $config['homedir'].'/include/functions_inventory.php'; if (is_ajax() === true) { $get_csv_url = (bool) get_parameter('get_csv_url'); + $get_data_basic_info = (bool) get_parameter('get_data_basic_info'); if ($get_csv_url) { // $inventory_module = get_parameter ('module_inventory_general_view', 'all'); @@ -109,6 +110,156 @@ if (is_ajax() === true) { return; } + if ($get_data_basic_info === true) { + // Datatables offset, limit and order. + $filter = get_parameter('search', []); + $start = (int) get_parameter('start', 0); + $length = (int) get_parameter('length', $config['block_size']); + $order = get_datatable_order(); + $id_agent = (int) get_parameter('id_agent', 0); + + $params = [ + 'search' => $filter['value'], + 'start' => $start, + 'length' => $length, + 'order' => $order, + 'id_agent' => $id_agent, + ]; + + $data = get_data_basic_info_sql($params); + $count = get_data_basic_info_sql($params, true); + + try { + ob_start(); + + $data = array_reduce( + $data, + function ($carry, $agent) { + // Transforms array of arrays $data into an array + // of objects, making a post-process of certain fields. + $tmp = new stdClass(); + + $id = $agent['id_agente']; + + $tmp->alias = $agent['alias']; + $ip = ''.__('N/A').''; + if (empty($agent['direccion']) === false) { + $ip = $agent['direccion']; + } + + $tmp->ip = $ip; + + $secondary_ips = ''; + foreach (agents_get_addresses($id) as $ip) { + if ($ip !== $agent['direccion']) { + $secondary_ips .= ''.$ip.''; + } + } + + $tmp->secondaryIp = $secondary_ips; + + $tmp->group = groups_get_name($agent['id_grupo']); + $secondary_groups = enterprise_hook('agents_get_secondary_groups', [$id]); + + if (empty($secondary_groups['for_select']) === true) { + $sec_group_data = ''.__('N/A').''; + } else { + $sec_group = []; + foreach ($secondary_groups['for_select'] as $name) { + $sec_group[] = $name; + } + + $sec_group_data = implode(', ', $sec_group); + } + + $tmp->secondaryGroups = $sec_group_data; + + $tmp->os = ui_print_os_icon( + $agent['id_os'], + false, + true, + true, + false, + false, + false, + ['class' => 'main_menu_icon invert_filter'] + ); + + $interval = human_time_description_raw($agent['intervalo'], false, 'large'); + $last_contact = ui_print_timestamp($agent['ultimo_contacto'], true); + // $last_contact .= ' / '.date_w_fixed_tz($agent['ultimo_contacto_remoto']); + $last_status_change_agent = agents_get_last_status_change($agent['id_agente']); + $time_elapsed = !empty($last_status_change_agent) ? human_time_comparation($last_status_change_agent) : ''.__('N/A').''; + + $sql_fields = 'SELECT tcf.name, tcd.description, tcf.is_password_type + FROM tagent_custom_fields tcf + INNER JOIN tagent_custom_data tcd ON tcd.id_field=tcf.id_field + WHERE tcd.id_agent='.$id.' AND tcd.description!=""'; + $field_result = db_get_all_rows_sql($sql_fields); + + $custom_fields_names = ''; + $custom_fields_values = ''; + foreach ($field_result as $field) { + $field_name = str_replace(' ', ' ', io_safe_output($field['name'])); + $custom_fields_names .= ''.$field_name.''; + + $description = $field['description']; + $password_length = strlen(io_safe_output($field['description'])); + $asterisks = ''; + + if ((int) $field['is_password_type'] === 1) { + for ($i = 0; $i < $password_length; $i++) { + $asterisks .= '●'; + } + + $description = $asterisks; + } + + $custom_fields_values .= ''.$description.''; + } + + $tmp->description = $agent['comentarios']; + $tmp->interval = $interval; + $tmp->lastContact = $last_contact; + $tmp->lastStatusChange = $time_elapsed; + $tmp->customFields = $custom_fields_names; + $tmp->valuesCustomFields = $custom_fields_values; + + $carry[] = $tmp; + return $carry; + }, + [] + ); + + // Datatables format: RecordsTotal && recordsfiltered. + echo json_encode( + [ + 'data' => $data, + 'recordsTotal' => $count, + 'recordsFiltered' => $count, + ] + ); + // Capture output. + $response = ob_get_clean(); + } catch (\Exception $e) { + echo json_encode(['error' => $e->getMessage()]); + exit; + } + + // If not valid, show error with issue. + json_decode($response); + if (json_last_error() == JSON_ERROR_NONE) { + // If valid dump. + echo $response; + } else { + echo json_encode( + ['error' => $response] + ); + } + + return; + } + return; } @@ -116,13 +267,8 @@ global $config; check_login(); - $is_metaconsole = is_metaconsole(); -if ($is_metaconsole === true) { - open_meta_frame(); -} - if (! check_acl($config['id_user'], 0, 'AR') && ! check_acl($config['id_user'], 0, 'AW')) { db_pandora_audit( AUDIT_LOG_ACL_VIOLATION, @@ -135,6 +281,9 @@ if (! check_acl($config['id_user'], 0, 'AR') && ! check_acl($config['id_user'], require_once $config['homedir'].'/include/functions_users.php'; require_once $config['homedir'].'/include/functions_inventory.php'; + +// TODO: Button +// echo "".__('Export this list to CSV').''.html_print_image('images/csv.png', true, ['title' => __('Export this list to CSV')]).''; // Header. ui_print_standard_header( __('Inventory'), @@ -160,7 +309,7 @@ if (strlen($inventory_agent) == 0) { $inventory_id_agent = 0; } -$inventory_module = get_parameter('module_inventory_general_view'); +$inventory_module = get_parameter('module_inventory_general_view', 'basic'); $inventory_id_group = (int) get_parameter('id_group'); $inventory_search_string = (string) get_parameter('search_string'); $order_by_agent = (bool) get_parameter('order_by_agent'); @@ -333,17 +482,15 @@ if (is_metaconsole() === true) { $filteringFunction = ''; } -echo '
'; - +$searchForm = ''; $table = new stdClass(); $table->width = '100%'; -$table->class = 'databox filters'; $table->size = []; -$table->size[0] = '120px'; -$table->cellpadding = 0; -$table->cellspacing = 0; +$table->size[0] = '33%'; +$table->size[1] = '33%'; +$table->size[2] = '33%'; +$table->class = 'filter-table-adv'; $table->data = []; -$table->rowspan[0][4] = 2; if ($is_metaconsole === true) { // Node select. @@ -352,37 +499,61 @@ if ($is_metaconsole === true) { $nodes[$row['id']] = $row['server_name']; } - $table->data[-1][0] = ''.__('Server').''; - $table->data[-1][1] = html_print_select($nodes, 'id_server', $id_server, $filteringFunction, __('All'), 0, true, false, true, '', false, 'min-width: 250px; max-width: 300px;'); + $table->data[-1][0] = html_print_label_input_block( + __('Server'), + html_print_select( + $nodes, + 'id_server', + $id_server, + $filteringFunction, + __('All'), + 0, + true, + false, + true, + '', + false, + 'width:100%;' + ) + ); } // Group select. -$table->data[0][0] = ''.__('Group').''; - -$table->data[0][1] = '
'; -$table->data[0][1] .= html_print_select_groups( - $config['id_user'], - $access, - true, - 'id_group', - $inventory_id_group, - $filteringFunction, - '', - '1', - true, - false, - true, - '', - false +$table->data[0][0] = html_print_label_input_block( + __('Group'), + html_print_select_groups( + $config['id_user'], + $access, + true, + 'id_group', + $inventory_id_group, + $filteringFunction, + '', + '1', + true, + false, + true, + '', + false + ) ); -$table->data[0][1] .= '
'; - -// Module selected. -$table->data[0][2] = ''.__('Module').''; if ($is_metaconsole === true) { array_unshift($fields, __('All')); - $table->data[0][3] = html_print_select($fields, 'module_inventory_general_view', $inventory_module, $filteringFunction, __('Basic info'), 'basic', true, false, true, '', false, 'min-width: 194px; max-width: 200px;'); + $module_input = html_print_select( + $fields, + 'module_inventory_general_view', + $inventory_module, + $filteringFunction, + __('Basic info'), + 'basic', + true, + false, + true, + '', + false, + 'width:100%;' + ); } else { $sql = 'SELECT name as indexname, name FROM tmodule_inventory, tagent_module_inventory @@ -404,13 +575,22 @@ if ($is_metaconsole === true) { } array_unshift($fields, __('All')); - $table->data[0][3] = html_print_select($fields, 'module_inventory_general_view', $inventory_module, '', __('Basic info'), 'basic', true, false, false); + $module_input = html_print_select( + $fields, + 'module_inventory_general_view', + $inventory_module, + '', + __('Basic info'), + 'basic', + true, + false, + false, + '', + false, + 'width:100%;' + ); } - -// Button of submit. -$table->data[0][4] = html_print_submit_button(__('Search'), 'submit_filter', $noFilterSelected, "class='sub search'", true); - // Agent select. if ($is_metaconsole === false) { $agents = []; @@ -436,8 +616,6 @@ if ($is_metaconsole === false) { } } -$table->data[1][0] = ''.__('Agent').''; - $params = []; $params['return'] = true; $params['show_helptip'] = true; @@ -459,27 +637,109 @@ if ($is_metaconsole === true) { $params['metaconsole_enabled'] = true; } -$table->data[1][1] = ui_print_agent_autocomplete_input($params); +$table->data[0][1] = html_print_label_input_block( + __('Agent'), + ui_print_agent_autocomplete_input($params) +); + +// Module selected. +$table->data[0][2] = html_print_label_input_block( + __('Module'), + $module_input +); // String search_string. -$table->data[1][2] = ''.__('Search').''; -$table->data[1][3] = html_print_input_text('search_string', $inventory_search_string, '', 25, 0, true, false, false, '', '', $filteringFunction, 'off', false, $filteringFunction); +$table->data[1][0] = html_print_label_input_block( + __('Search'), + html_print_input_text( + 'search_string', + $inventory_search_string, + '', + 25, + 0, + true, + false, + false, + '', + '', + $filteringFunction, + 'off', + false, + $filteringFunction + ) +); + +// Order by agent filter. +$table->data[1][1] = html_print_label_input_block( + __('Order by agent'), + html_print_checkbox( + 'order_by_agent', + 1, + $order_by_agent, + true, + false, + '' + ) +); // Date filter. In Metaconsole has not reason for show. if (is_metaconsole() === false) { - $table->data[2][0] = ''.__('Date').''; - $dates = inventory_get_dates($inventory_module, $inventory_agent, $inventory_id_group); - $table->data[2][1] = html_print_select($dates, 'utimestamp', $utimestamp, '', __('Last'), 0, true); + $dates = inventory_get_dates( + $inventory_module, + $inventory_agent, + $inventory_id_group + ); + + $table->data[1][2] = html_print_label_input_block( + __('Date'), + html_print_select( + $dates, + 'utimestamp', + $utimestamp, + '', + __('Last'), + 0, + true, + false, + true, + '', + false, + 'width:100%;' + ) + ); } -// Order by agent filter. -$table->data[2][2] = ''.__('Order by agent').''; +$searchForm .= html_print_table($table, true); +$searchForm .= html_print_div( + [ + 'class' => 'action-buttons', + 'content' => html_print_submit_button( + __('Filter'), + 'srcbutton', + false, + [ + 'icon' => 'search', + 'mode' => 'mini', + ], + true + ), + ], + true +); -$table->data[2][3] = html_print_checkbox('order_by_agent', 1, $order_by_agent, true, false, ''); +$searchForm .= '
'; -html_print_table($table); - -echo ''; +ui_toggle( + $searchForm, + ''.__('Filters').'', + 'filter_form', + '', + true, + false, + '', + 'white-box-content', + 'box-flat white_table_graph fixed_filter_bar' +); if ($is_metaconsole === false) { // Single agent selected. @@ -507,9 +767,6 @@ if ($is_metaconsole === false) { return; } - echo "
"; - echo "".__('Export this list to CSV').''.html_print_image('images/csv.png', true, ['title' => __('Export this list to CSV')]).''; - echo '
'; echo "'; ?>