Keep In process status for new events with same extra id

This commit is contained in:
alejandro.campos@artica.es 2023-04-12 17:32:52 +02:00
parent 9da3816a88
commit 2ca27ae15d
4 changed files with 41 additions and 2 deletions

View File

@ -704,7 +704,7 @@ $table->data[$i][] = html_print_label_input_block(
)
);
$table->data[$i][] = html_print_label_input_block(
$table->data[$i++][] = html_print_label_input_block(
__('Check conexion interval'),
html_print_input_number(
[
@ -715,6 +715,16 @@ $table->data[$i][] = html_print_label_input_block(
)
);
$table->data[$i][] = html_print_label_input_block(
__('Keep In process status for new events with extra ID'),
html_print_checkbox_switch(
'keep_in_process_status_extra_id',
1,
$config['keep_in_process_status_extra_id'],
true
)
);
echo '<form class="max_floating_element_size" id="form_setup" method="post" action="index.php?sec=gsetup&sec2=godmode/setup/setup&amp;section=general&amp;pure='.$config['pure'].'">';
echo '<fieldset class="margin-bottom-10">';

View File

@ -13090,10 +13090,17 @@ function api_set_create_event($id, $trash1, $other, $returnType)
if ($other['data'][18] != '') {
$values['id_extra'] = $other['data'][18];
$sql_validation = 'SELECT id_evento FROM tevento where estado IN (0,2) and id_extra ="'.$other['data'][18].'";';
$sql_validation = 'SELECT id_evento,estado FROM tevento where estado IN (0,2) and id_extra ="'.$other['data'][18].'";';
$validation = db_get_all_rows_sql($sql_validation);
if ($validation) {
foreach ($validation as $val) {
if ((int) $val['estado'] === EVENT_STATUS_INPROCESS
&& (int) $values['status'] === 0
) {
$values['status'] = 2;
}
api_set_validate_event_by_id($val['id_evento']);
}
}

View File

@ -370,6 +370,10 @@ function config_update_config()
$error_update[] = __('alias_as_name');
}
if (config_update_value('keep_in_process_status_extra_id', get_parameter('keep_in_process_status_extra_id'), true) === false) {
$error_update[] = __('keep_in_process_status_extra_id');
}
if (config_update_value('console_log_enabled', get_parameter('console_log_enabled'), true) === false) {
$error_update[] = __('Console log enabled');
}
@ -2343,6 +2347,10 @@ function config_process_config()
config_update_value('alias_as_name', 0);
}
if (!isset($config['keep_in_process_status_extra_id'])) {
config_update_value('keep_in_process_status_extra_id', 0);
}
if (!isset($config['console_log_enabled'])) {
config_update_value('console_log_enabled', 0);
}

View File

@ -4070,6 +4070,20 @@ sub pandora_event {
# Validate events with the same event id
if (defined ($id_extra) && $id_extra ne '') {
my $keep_in_process_status_extra_id = pandora_get_tconfig_token ($dbh, 'keep_in_process_status_extra_id', 0);
if ($keep_in_process_status_extra_id == 1) {
# Keep status if the latest event was In process
logger($pa_config, "Checking status of latest event with extended id '$id_extra'.", 10);
my $id_extra_last_status = get_db_value_limit ($dbh, 'SELECT estado FROM tevento WHERE id_extra=? ORDER BY timestamp DESC', 1, $id_extra);
# Only when the event comes as New. Validated events are excluded
if (defined ($id_extra_last_status) && $id_extra_last_status == 2 && $event_status == 0) {
logger($pa_config, "Keeping In process status from last event with extended id '$id_extra'.", 10);
$event_status = 2;
}
}
logger($pa_config, "Updating events with extended id '$id_extra'.", 10);
db_do ($dbh, 'UPDATE tevento SET estado = 1, ack_utimestamp = ? WHERE estado IN (0,2) AND id_extra=?', $utimestamp, $id_extra);
}