diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 9fdbe4a7d7..ce4eaf30e8 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2010-07-19 Miguel de Dios + + * include/functions_agents.php: in function "get_agents" added the parameter + $order to order list of agents. + + * operation/agentes/estado_agente.php: added icons for order by columns and + source code for management this ordenation by Name, Os, Interval, Group and + Last Contact. + 2010-07-19 Raúl Mateos * operation/agentes/status_monitor.php, godmode/groups/group_list.php: diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 2d54f20921..749bc9c6cd 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -265,10 +265,11 @@ function get_agent_alerts_compound ($id_agent = false, $filter = '', $options = * format_array_to_where_clause_sql() * @param array Fields to get. * @param string Access needed in the agents groups. + * @param array $order The order of agents, by default is upward for field nombre. * * @return mixed An array with all alerts defined for an agent or false in case no allowed groups are specified. */ -function get_agents ($filter = false, $fields = false, $access = 'AR') { +function get_agents ($filter = false, $fields = false, $access = 'AR', $order = array('field' => 'nombre', 'order' => 'ASC')) { if (! is_array ($filter)) { $filter = array (); } @@ -307,6 +308,8 @@ function get_agents ($filter = false, $fields = false, $access = 'AR') { $fields[0] = "id_agente"; $fields[1] = "nombre"; } + + $filter['order'] = $order['field'] . ' ' . $order['order']; return get_db_all_rows_filter ('tagente', $filter, $fields); } diff --git a/pandora_console/operation/agentes/estado_agente.php b/pandora_console/operation/agentes/estado_agente.php index 89e845be18..7fee251acc 100644 --- a/pandora_console/operation/agentes/estado_agente.php +++ b/pandora_console/operation/agentes/estado_agente.php @@ -68,6 +68,8 @@ if (is_ajax ()) { // Take some parameters (GET) $group_id = get_parameter ("group_id", 0); $search = get_parameter ("search", ""); +$offset = get_parameter('offset', 0); +$refr = get_parameter('refr', 0); print_page_header ( __("Agent detail"), "images/bricks.png", false, "agent_status"); @@ -97,10 +99,103 @@ echo ' '; if ($search != ""){ $filter = array ("string" => '%'.$search.'%'); -} else { +} +else { $filter = array (); } +$sortField = get_parameter('sort_field'); +$sort = get_parameter('sort', 'none'); + +$selected = 'border: 1px solid black;'; +$selectNameUp = ''; +$selectNameDown = ''; +$selectOsUp = ''; +$selectOsDown = ''; +$selectIntervalUp = ''; +$selectIntervalDown = ''; +$selectGroupUp = ''; +$selectGroupDown = ''; +$selectLastContactUp = ''; +$selectLastContactDown = ''; +$order = null; + +switch ($sortField) { + case 'name': + switch ($sort) { + case 'up': + $selectNameUp = $selected; + $order = array('field' => 'nombre', 'order' => 'ASC'); + break; + case 'down': + $selectNameDown = $selected; + $order = array('field' => 'nombre', 'order' => 'DESC'); + break; + } + break; + case 'os': + switch ($sort) { + case 'up': + $selectOsUp = $selected; + $order = array('field' => 'id_os', 'order' => 'ASC'); + break; + case 'down': + $selectOsDown = $selected; + $order = array('field' => 'id_os', 'order' => 'DESC'); + break; + } + break; + case 'interval': + switch ($sort) { + case 'up': + $selectIntervalUp = $selected; + $order = array('field' => 'intervalo', 'order' => 'ASC'); + break; + case 'down': + $selectIntervalDown = $selected; + $order = array('field' => 'intervalo', 'order' => 'DESC'); + break; + } + break; + case 'group': + switch ($sort) { + case 'up': + $selectGroupUp = $selected; + $order = array('field' => 'id_grupo', 'order' => 'ASC'); + break; + case 'down': + $selectGroupDown = $selected; + $order = array('field' => 'id_grupo', 'order' => 'DESC'); + break; + } + break; + case 'last_contact': + switch ($sort) { + case 'up': + $selectLastContactUp = $selected; + $order = array('field' => 'ultimo_contacto', 'order' => 'ASC'); + break; + case 'down': + $selectLastContactDown = $selected; + $order = array('field' => 'ultimo_contacto', 'order' => 'DESC'); + break; + } + break; + default: + $selectNameUp = $selected; + $selectNameDown = ''; + $selectOsUp = ''; + $selectOsDown = ''; + $selectIntervalUp = ''; + $selectIntervalDown = ''; + $selectGroupUp = ''; + $selectGroupDown = ''; + $selectLastContactUp = ''; + $selectLastContactDown = ''; + $order = array('field' => 'nombre', 'order' => 'ASC'); + break; +} + // Show only selected groups if ($group_id > 0) { $groups = $group_id; @@ -130,14 +225,17 @@ if (! empty ($agent_names)) { 'id_grupo', 'id_os', 'ultimo_contacto', - 'intervalo'));} + 'intervalo'), + 'AR', + $order); +} if (empty ($agents)) { $agents = array (); } // Prepare pagination -pagination ($total_agents, get_url_refresh (array ('group_id' => $group_id, 'search' => $search))); +pagination ($total_agents, get_url_refresh (array ('group_id' => $group_id, 'search' => $search, 'sort_field' => $sortField, 'sort' => $sort))); // Show data. $table->cellpadding = 4; @@ -146,14 +244,24 @@ $table->width = "98%"; $table->class = "databox"; $table->head = array (); -$table->head[0] = __('Agent'); -$table->head[1] = __('OS'); -$table->head[2] = __('Interval'); -$table->head[3] = __('Group'); +$table->head[0] = __('Agent'). ' ' . + '' . + ''; +$table->head[1] = __('OS'). ' ' . + '' . + ''; +$table->head[2] = __('Interval'). ' ' . + '' . + ''; +$table->head[3] = __('Group'). ' ' . + '' . + ''; $table->head[4] = __('Modules'); $table->head[5] = __('Status'); $table->head[6] = __('Alerts'); -$table->head[7] = __('Last contact'); +$table->head[7] = __('Last contact'). ' ' . + '' . + ''; $table->align = array (); $table->align[1] = "center"; @@ -239,6 +347,7 @@ foreach ($agents as $agent) { if (!empty ($table->data)) { print_table ($table); + pagination ($total_agents, get_url_refresh (array ('group_id' => $group_id, 'search' => $search, 'sort_field' => $sortField, 'sort' => $sort))); unset ($table); } else { echo '
'.__('There are no agents included in this group').'
';