Merge branch 'ent-13246-cambios-de-estados-en-grouped-by-events-en-los-detalles-de-evento' into 'develop'

Ent 13246 Cambios de estados en grouped by events en los detalles de evento

See merge request artica/pandorafms!7335
This commit is contained in:
Jose Martin 2024-05-17 09:15:59 +00:00
commit 97750b7370
3 changed files with 26 additions and 22 deletions

View File

@ -1550,7 +1550,7 @@ if ($add_comment === true) {
if ($change_status === true) {
$event_ids = get_parameter('event_ids');
$new_status = get_parameter('new_status');
$group_rep = (int) get_parameter('group_rep', 0);
$filter = get_parameter('filter', []);
$server_id = 0;
if (is_metaconsole() === true) {
$server_id = (int) get_parameter('server_id');
@ -1564,19 +1564,11 @@ if ($change_status === true) {
$node->connect();
}
if ($group_rep !== 3) {
$return = events_change_status(
explode(',', $event_ids),
$new_status
);
} else {
// Update all elements with same extraid.
$return = events_update_status(
$event_ids,
(int) $new_status,
['group_rep' => $group_rep]
$filter
);
}
} catch (\Exception $e) {
// Unexistent agent.
if (is_metaconsole() === true

View File

@ -585,25 +585,30 @@ function events_update_status($id_evento, $status, $filter=null)
if ((int) $filter['group_rep'] === EVENT_GROUP_REP_EXTRAIDS) {
$sql = sprintf(
'SELECT tu.id_evento FROM tevento tu INNER JOIN ( %s ) tf
ON tu.id_extra = tf.id_extra
'SELECT te.id_evento FROM tevento te INNER JOIN ( %s ) tf
ON te.id_extra = tf.id_extra
AND tf.max_id_evento = %d',
$sql,
$id_evento
);
} else {
$sql = sprintf(
'SELECT tu.id_evento FROM tevento tu INNER JOIN ( %s ) tf
ON tu.estado = tf.estado
AND tu.evento = tf.evento
AND tu.id_agente = tf.id_agente
AND tu.id_agentmodule = tf.id_agentmodule
'SELECT te.id_evento FROM tevento te INNER JOIN ( %s ) tf
ON te.estado = tf.estado
AND te.evento = tf.evento
AND te.id_agente = tf.id_agente
AND te.id_agentmodule = tf.id_agentmodule
AND tf.max_id_evento = %d',
$sql,
$id_evento
);
}
$filter_date = get_filter_date($filter);
if (is_array($filter_date) === true && count($filter_date) > 0) {
$sql .= implode(' ', $filter_date);
}
$target_ids = db_get_all_rows_sql($sql);
// Try to avoid deadlock while updating full set.

View File

@ -323,6 +323,12 @@ function perform_response(response, response_id, index = "") {
// Change the status of an event to new, in process or validated.
function event_change_status(event_ids, server_id, group_rep) {
var inputs = $("#events_form :input");
var values = {};
inputs.each(function() {
values[this.name] = $(this).val();
});
var new_status = $("#estado").val();
$("#button-status_button").attr("disabled", "disabled");
@ -335,7 +341,8 @@ function event_change_status(event_ids, server_id, group_rep) {
event_ids: event_ids,
new_status: new_status,
server_id: server_id,
group_rep: group_rep
group_rep: group_rep,
filter: values
},
type: "POST",
url: getUrlAjax(),