Merge branch 'ent-10820-15230-Mantener-el-estado-del-evento-anterior-con-Extra-ID' into 'develop'

Ent 10820 15230 mantener el estado del evento anterior con extra

See merge request artica/pandorafms!5709
This commit is contained in:
Daniel Rodriguez 2023-04-28 06:07:10 +00:00
commit 191c7d3098
4 changed files with 48 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,21 @@ $table->data[$i][] = html_print_label_input_block(
)
);
$help_tip = ui_print_help_tip(
__('If there are any "In process" events with a specific Extra ID and a New event with that Extra ID is received, it will be created as "In process" instead.'),
true
);
$table->data[$i][] = html_print_label_input_block(
__('Keep In process status for new events with extra ID').$help_tip,
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,18 @@ 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 ((bool) $config['keep_in_process_status_extra_id'] === true
&& (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');
}
@ -2347,6 +2351,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

@ -4073,6 +4073,21 @@ 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 (defined ($keep_in_process_status_extra_id) && $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);
# Check if there is a previous event with that extra ID and it is currently in "in process" state
my $id_extra_inprocess_count = get_db_value ($dbh, 'SELECT COUNT(*) FROM tevento WHERE id_extra=? AND estado=2', $id_extra);
# Only when the event comes as New. Validated events are excluded
if (defined($id_extra_inprocess_count) && $id_extra_inprocess_count > 0 && $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);
}