fixed group by extra_id pandora_enterprise#9425

This commit is contained in:
Daniel Barbero 2022-10-10 13:18:57 +02:00
parent 38dea9e01b
commit d068a9e9cc
2 changed files with 31 additions and 16 deletions

View File

@ -387,8 +387,6 @@ function events_delete($id_evento, $filter=null, $history=false, $force_node=fal
$filter = ['group_rep' => EVENT_GROUP_REP_ALL];
}
hd($filter['group_rep'], true);
switch ($filter['group_rep']) {
case EVENT_GROUP_REP_ALL:
case EVENT_GROUP_REP_AGENTS:
@ -1543,8 +1541,8 @@ function events_get_all(
}
}
if (($filter['group_rep'] === EVENT_GROUP_REP_EVENTS
|| $filter['group_rep'] === EVENT_GROUP_REP_EXTRAIDS) && $count === false
if (((int) $filter['group_rep'] === EVENT_GROUP_REP_EVENTS
|| (int) $filter['group_rep'] === EVENT_GROUP_REP_EXTRAIDS) && $count === false
) {
$sql = sprintf(
'SELECT %s
@ -1576,7 +1574,9 @@ function events_get_all(
%s
%s
%s JOIN tgrupo tg
ON %s',
ON %s
%s
%s',
join(',', $fields),
$group_selects_trans,
$tevento,
@ -1605,7 +1605,8 @@ function events_get_all(
join(' ', $agent_join_filters),
$tgrupo_join,
join(' ', $tgrupo_join_filters),
join(' ', $sql_filters)
join(' ', $sql_filters),
$order_by
);
} else {
$sql = sprintf(

View File

@ -6510,7 +6510,7 @@ function ui_print_breadcrums($tab_name)
/**
* Show last comment
*
* @param array $comments array with comments
* @param string $comments String with comments.
*
* @return string HTML string with the last comment of the events.
*/
@ -6534,31 +6534,45 @@ function ui_print_comments($comments)
foreach ($comments_array as $comm) {
// Show the comments more recent first.
if (is_array($comm)) {
$last_comment[] = array_reverse($comm);
$order_utimestamp = array_reduce(
$comm,
function ($carry, $item) {
$carry[$item['utimestamp']] = $item;
return $carry;
}
);
$key_max_utimestamp = max(array_keys($order_utimestamp));
$last_comment = $order_utimestamp[$key_max_utimestamp];
}
}
if (empty($last_comment) === true) {
return '';
}
// Only show the last comment. If commment its too long,the comment will short with ...
// If $config['prominent_time'] is timestamp the date show Month, day, hour and minutes.
// Else show comments hours ago
if ($last_comment[0][0]['action'] != 'Added comment') {
$last_comment[0][0]['comment'] = $last_comment[0][0]['action'];
if ($last_comment['action'] != 'Added comment') {
$last_comment['comment'] = $last_comment['action'];
}
$short_comment = substr($last_comment[0][0]['comment'], 0, 20);
$short_comment = substr($last_comment['comment'], 0, 20);
if ($config['prominent_time'] == 'timestamp') {
$comentario = '<i>'.date($config['date_format'], $last_comment[0][0]['utimestamp']).'&nbsp;('.$last_comment[0][0]['id_user'].'):&nbsp;'.$last_comment[0][0]['comment'].'';
$comentario = '<i>'.date($config['date_format'], $last_comment['utimestamp']).'&nbsp;('.$last_comment['id_user'].'):&nbsp;'.$last_comment['comment'].'';
if (strlen($comentario) > '200px') {
$comentario = '<i>'.date($config['date_format'], $last_comment[0][0]['utimestamp']).'&nbsp;('.$last_comment[0][0]['id_user'].'):&nbsp;'.$short_comment.'...';
$comentario = '<i>'.date($config['date_format'], $last_comment['utimestamp']).'&nbsp;('.$last_comment['id_user'].'):&nbsp;'.$short_comment.'...';
}
} else {
$rest_time = (time() - $last_comment[0][0]['utimestamp']);
$rest_time = (time() - $last_comment['utimestamp']);
$time_last = (($rest_time / 60) / 60);
$comentario = '<i>'.number_format($time_last, 0).'&nbsp; Hours &nbsp;('.$last_comment[0][0]['id_user'].'):&nbsp;'.$last_comment[0][0]['comment'].'';
$comentario = '<i>'.number_format($time_last, 0).'&nbsp; Hours &nbsp;('.$last_comment['id_user'].'):&nbsp;'.$last_comment['comment'].'';
if (strlen($comentario) > '200px') {
$comentario = '<i>'.number_format($time_last, 0).'&nbsp; Hours &nbsp;('.$last_comment[0][0]['id_user'].'):&nbsp;'.$short_comment.'...';
$comentario = '<i>'.number_format($time_last, 0).'&nbsp; Hours &nbsp;('.$last_comment['id_user'].'):&nbsp;'.$short_comment.'...';
}
}