Merge branch '2389-Ordenar-eventos-por-campo' into 'develop'
added order filters to events table See merge request artica/pandorafms!1608
This commit is contained in:
commit
22ffd8d1e5
|
@ -128,10 +128,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) {
|
||||
|
@ -141,6 +141,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');
|
||||
|
@ -164,7 +165,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":
|
||||
|
|
|
@ -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++;
|
||||
|
@ -767,7 +767,7 @@ else {
|
|||
|
||||
echo '<div id="events_list">';
|
||||
if (!empty ($table->data)) {
|
||||
|
||||
|
||||
if ($allow_pagination) {
|
||||
ui_pagination ($total_events, $url, $offset, $pagination);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue