diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 1348afc96b..bf3c2b49df 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -126,10 +126,10 @@ function events_get_events_no_grouped($sql_post, $offset = 0, function events_get_events_grouped($sql_post, $offset = 0, $pagination = 1, $meta = false, $history = false, $total = false, - $history_db = false, $order = "DESC") { - - global $config; + $history_db = false, $order = "down", $sort_field = "timestamp") { + global $config; + $table = events_get_events_table($meta, $history); if ($meta) { @@ -139,6 +139,7 @@ function events_get_events_grouped($sql_post, $offset = 0, $groupby_extra = ''; } + switch ($config["dbtype"]) { case "mysql": db_process_sql ('SET group_concat_max_len = 9999999'); @@ -162,7 +163,48 @@ function events_get_events_grouped($sql_post, $offset = 0, FROM $table te LEFT JOIN tagent_secondary_group tasg ON te.id_grupo = tasg.id_group WHERE 1=1 " . $sql_post . " GROUP BY estado, evento, id_agente, id_agentmodule" . $groupby_extra . " - ORDER BY timestamp_rep " . $order . " LIMIT " . $offset . "," . $pagination; + ORDER BY "; + + if (!empty($sort_field)) { + switch ($sort_field) { + case 'event_id': + if ($order=='up') + $sql .= "id_evento" . " ASC"; + if ($order=='down') + $sql .= "id_evento" . " DESC"; + break; + case 'event_name': + if ($order=='up') + $sql .= "evento" . " ASC"; + if ($order=='down') + $sql .= "evento" . " DESC"; + break; + case 'status': + if ($order=='up') + $sql .= "estado" . " ASC"; + if ($order=='down') + $sql .= "estado" . " DESC"; + break; + case 'agent_id': + if ($order=='up') + $sql .= "id_agente" . " ASC"; + if ($order=='down') + $sql .= "id_agente" . " DESC"; + break; + case 'timestamp': + if ($order=='up') + $sql .= "timestamp_rep" . " ASC"; + if ($order=='down') + $sql .= "timestamp_rep" . " DESC"; + break; + default: + $sql .= "timestamp_rep" . " DESC"; + } + } + + + $sql .= " LIMIT " . $offset . "," . $pagination; + } break; case "postgresql": diff --git a/pandora_console/operation/events/events.build_table.php b/pandora_console/operation/events/events.build_table.php index d00dbd522a..ca54bac707 100644 --- a/pandora_console/operation/events/events.build_table.php +++ b/pandora_console/operation/events/events.build_table.php @@ -130,7 +130,7 @@ else { //headers $i = 0; - $table->head[$i] = __('ID'); + $table->head[$i] = __('ID') . ' ' . '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp)) . '' . '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown)) . ''; $table->align[$i] = 'left'; @@ -141,7 +141,7 @@ else { $i++; } if (in_array('estado', $show_fields)) { - $table->head[$i] = __('Status'); + $table->head[$i] = __('Status') . ' ' . '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp)) . '' . '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown)) . ''; $table->align[$i] = 'left'; $i++; } @@ -152,19 +152,19 @@ else { $i++; } if (in_array('evento', $show_fields)) { - $table->head[$i] = __('Event Name'); + $table->head[$i] = __('Event Name') . ' ' . '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp)) . '' . '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown)) . ''; $table->align[$i] = 'left'; $table->style[$i] = 'min-width: 200px; max-width: 350px; word-break: break-all;'; $i++; } if (in_array('id_agente', $show_fields)) { - $table->head[$i] = __('Agent name'); + $table->head[$i] = __('Agent name') . ' ' . '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp)) . '' . '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown)) . ''; $table->align[$i] = 'left'; $table->style[$i] = 'max-width: 350px; word-break: break-all;'; $i++; } if (in_array('timestamp', $show_fields)) { - $table->head[$i] = __('Timestamp'); + $table->head[$i] = __('Timestamp') . ' ' . '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp)) . '' . '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown)) . ''; $table->align[$i] = 'left'; $i++; @@ -741,7 +741,7 @@ else { echo '