added order filters to events table

This commit is contained in:
alejandro-campos 2018-07-10 15:11:18 +02:00
parent 3c31d0216e
commit 6ec4787c38
3 changed files with 58 additions and 11 deletions

View File

@ -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":

View File

@ -130,7 +130,7 @@ else {
//headers
$i = 0;
$table->head[$i] = __('ID');
$table->head[$i] = __('ID') . ' ' . '<a href="index.php?sec=eventos&sec2=operation/events/events&offset='.$offset.'&sort_field=event_id&sort=up&disabled='.$disabled.'">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp)) . '</a>' . '<a href="index.php?sec=eventos&sec2=operation/events/events&sort_field=event_id&sort=down&disabled=$disabled">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown)) . '</a>';
$table->align[$i] = 'left';
@ -141,7 +141,7 @@ else {
$i++;
}
if (in_array('estado', $show_fields)) {
$table->head[$i] = __('Status');
$table->head[$i] = __('Status') . ' ' . '<a href="index.php?sec=eventos&sec2=operation/events/events&offset='.$offset.'&sort_field=status&sort=up&disabled='.$disabled.'">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp)) . '</a>' . '<a href="index.php?sec=eventos&sec2=operation/events/events&sort_field=status&sort=down&disabled=$disabled">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown)) . '</a>';
$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') . ' ' . '<a href="index.php?sec=eventos&sec2=operation/events/events&offset='.$offset.'&sort_field=event_name&sort=up&disabled='.$disabled.'">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp)) . '</a>' . '<a href="index.php?sec=eventos&sec2=operation/events/events&sort_field=event_name&sort=down&disabled=$disabled">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown)) . '</a>';
$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') . ' ' . '<a href="index.php?sec=eventos&sec2=operation/events/events&offset='.$offset.'&sort_field=agent_id&sort=up&disabled='.$disabled.'">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp)) . '</a>' . '<a href="index.php?sec=eventos&sec2=operation/events/events&sort_field=agent_id&sort=down&disabled=$disabled">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown)) . '</a>';
$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') . ' ' . '<a href="index.php?sec=eventos&sec2=operation/events/events&offset='.$offset.'&sort_field=timestamp&sort=up&disabled='.$disabled.'">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp)) . '</a>' . '<a href="index.php?sec=eventos&sec2=operation/events/events&sort_field=timestamp&sort=down&disabled=$disabled">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown)) . '</a>';
$table->align[$i] = 'left';
$i++;
@ -741,7 +741,7 @@ else {
echo '<div id="events_list">';
if (!empty ($table->data)) {
if ($allow_pagination) {
ui_pagination ($total_events, $url, $offset, $pagination);
}

View File

@ -28,6 +28,10 @@ enterprise_include_once('include/functions_events.php');
check_login ();
$sort_field = get_parameter("sort_field", "timestamp");
$sort_order = get_parameter("sort", "down");
$event_a = check_acl ($config['id_user'], 0, "ER");
$event_w = check_acl ($config['id_user'], 0, "EW");
$event_m = check_acl ($config['id_user'], 0, "EM");
@ -758,7 +762,8 @@ elseif ($group_rep == 1) {
$history,
false,
false,
'DESC');
$sort_order,
$sort_field);
}
elseif ($group_rep == 2) {
$filter_resume['duplicate'] = $group_rep;