fix validate events pandora_enterprise#10175

This commit is contained in:
daniel 2023-01-25 11:25:20 +01:00
parent 77b3be4d60
commit ddebce7a3c
5 changed files with 82 additions and 30 deletions

View File

@ -1515,9 +1515,37 @@ if ($change_status === true) {
}
if ($get_Acknowledged === true) {
$event_id = get_parameter('event_id');
$event_id = (int) get_parameter('event_id', 0);
$server_id = (int) get_parameter('server_id', 0);
$return = '';
try {
if (is_metaconsole() === true
&& $server_id > 0
) {
$node = new Node($server_id);
$node->connect();
}
echo events_page_general_acknowledged($event_id);
return;
} catch (\Exception $e) {
// Unexistent agent.
if (is_metaconsole() === true
&& $server_id > 0
) {
$node->disconnect();
}
$return = false;
} finally {
if (is_metaconsole() === true
&& $server_id > 0
) {
$node->disconnect();
}
}
return $return;
}
if ($change_owner === true) {

View File

@ -226,7 +226,7 @@ function format_numeric($number, $decimals=1)
global $config;
// Translate to float in case there are characters in the string so
// fmod doesn't throw a notice
// fmod doesn't throw a notice.
$number = (float) $number;
if ($number == 0) {
@ -234,10 +234,20 @@ function format_numeric($number, $decimals=1)
}
if (fmod($number, 1) > 0) {
return number_format($number, $decimals, $config['decimal_separator'], $config['thousand_separator']);
return number_format(
$number,
$decimals,
$config['decimal_separator'],
($config['thousand_separator'] ?? ',')
);
}
return number_format($number, 0, $config['decimal_separator'], $config['thousand_separator']);
return number_format(
$number,
0,
$config['decimal_separator'],
($config['thousand_separator'] ?? ',')
);
}

View File

@ -496,9 +496,13 @@ function events_update_status($id_evento, $status, $filter=null)
// No groups option direct update.
$update_sql = sprintf(
'UPDATE tevento
SET estado = %d
SET estado = %d,
ack_utimestamp = %d,
id_usuario = "%s"
WHERE id_evento = %d',
$status,
time(),
$config['id_user'],
$id_evento
);
break;
@ -4797,14 +4801,15 @@ function events_page_general($event)
$data = [];
$table_general->rowid[7] = 'general_status';
$table_general->rowid[count($table_general->data)] = 'general_status';
$table_general->cellclass[count($table_general->data)][1] = 'general_status';
$data[0] = __('Status');
$data[1] = $event_st['title'];
$data[2] = html_print_image($event_st['img'], true);
$table_general->data[] = $data;
// If event is validated, show who and when acknowleded it.
$table_general->cellclass[8][1] = 'general_acknowleded';
$table_general->cellclass[count($table_general->data)][1] = 'general_acknowleded';
$data = [];
$data[0] = __('Acknowledged by');
@ -4825,7 +4830,17 @@ function events_page_general($event)
}
}
$data[1] = $user_ack.' ( '.date($config['date_format'], $event['ack_utimestamp_raw']).' ) ';
$data[1] = $user_ack.' ( ';
if ($event['ack_utimestamp_raw'] !== false
&& $event['ack_utimestamp_raw'] !== 'false'
) {
$data[1] .= date(
$config['date_format'],
$event['ack_utimestamp_raw']
);
}
$data[1] .= ' ) ';
} else {
$data[1] = '<i>'.__('N/A').'</i>';
}
@ -4932,9 +4947,9 @@ function events_page_general_acknowledged($event_id)
{
global $config;
$Acknowledged = '';
$event = db_get_all_rows_filter('tevento', 'id_evento', $event_id);
if ($event) {
$event = db_get_row('tevento', 'id_evento', $event_id);
hd($event['ack_utimestamp'], true);
if ($event !== false && $event['estado'] == 1) {
$user_ack = db_get_value(
'fullname',
'tusuario',
@ -4946,7 +4961,17 @@ function events_page_general_acknowledged($event_id)
$user_ack = $config['id_user'];
}
$Acknowledged = $user_ack.'&nbsp;(&nbsp;'.date($config['date_format'], $event['ack_utimestamp_raw']).'&nbsp;)&nbsp;';
$Acknowledged = $user_ack.'&nbsp;(&nbsp;';
if ($event['ack_utimestamp'] !== false
&& $event['ack_utimestamp'] !== 'false'
) {
$Acknowledged .= date(
$config['date_format'],
$event['ack_utimestamp']
);
}
$Acknowledged .= '&nbsp;)&nbsp;';
} else {
$Acknowledged = 'N/A';
}

View File

@ -6597,10 +6597,10 @@ function ui_print_comments($comments)
$rest_time = (time() - $last_comment['utimestamp']);
$time_last = (($rest_time / 60) / 60);
$comentario = '<i>'.number_format($time_last, 0, $config['decimal_separator'], $config['thousand_separator']).'&nbsp; Hours &nbsp;('.$last_comment['id_user'].'):&nbsp;'.$last_comment['comment'].'';
$comentario = '<i>'.number_format($time_last, 0, $config['decimal_separator'], ($config['thousand_separator'] ?? ',')).'&nbsp; Hours &nbsp;('.$last_comment['id_user'].'):&nbsp;'.$last_comment['comment'].'';
if (strlen($comentario) > '200px') {
$comentario = '<i>'.number_format($time_last, 0, $config['decimal_separator'], $config['thousand_separator']).'&nbsp; Hours &nbsp;('.$last_comment['id_user'].'):&nbsp;'.$short_comment.'...';
$comentario = '<i>'.number_format($time_last, 0, $config['decimal_separator'], ($config['thousand_separator'] ?? ',')).'&nbsp; Hours &nbsp;('.$last_comment['id_user'].'):&nbsp;'.$short_comment.'...';
}
}

View File

@ -336,19 +336,17 @@ function event_change_status(event_ids, server_id) {
}
if (data.status == "status_ok") {
// if (typeof dt_events !== "undefined") {
// dt_events.draw(false);
// }
$.ajax({
type: "POST",
url: "ajax.php",
data: {
page: "include/ajax/events",
get_Acknowledged: 1,
event_id: event_ids
event_id: event_ids,
server_id: server_id
},
success: function(response) {
$("#table4-9-1").html(response);
$(".general_acknowleded").html(response);
}
});
@ -356,15 +354,6 @@ function event_change_status(event_ids, server_id) {
.DataTable()
.draw(false);
$("#notification_status_success").show();
if (new_status == 1) {
$("#extended_event_general_page table td.general_acknowleded").text(
data.user
);
} else {
$("#extended_event_general_page table td.general_acknowleded").text(
"N/A"
);
}
$("#general_status")
.find(".general_status")