Merge branch 'ent-13252-cli-pfms-subrutina-no-definida-en-el-comando-agent_update_custom_fields-en-ubuntu-22' into 'develop'
Changes on CLI -pandora_update_agent_custom_field See merge request artica/pandorafms!7124
This commit is contained in:
commit
af5e96158d
|
@ -4064,8 +4064,16 @@ sub pandora_check_type_custom_field_for_itsm ($) {
|
|||
##########################################################################
|
||||
sub pandora_update_agent_custom_field ($$$$) {
|
||||
my ($dbh, $token, $field, $id_agent) = @_;
|
||||
my $exist_field = get_db_value($dbh, 'SELECT count(*) FROM tagent_custom_data WHERE id_field = ? AND id_agent = ?', $field, $id_agent);
|
||||
my $result = undef;
|
||||
$result = db_update ($dbh, 'UPDATE tagent_custom_data SET description = ? WHERE id_field = ? AND id_agent = ?', safe_input($token), $field, $id_agent);
|
||||
|
||||
$token = safe_input($token);
|
||||
|
||||
if (!$exist_field) {
|
||||
$result = defined(db_insert ($dbh, 'id_field', 'INSERT INTO tagent_custom_data (`description`, `id_field`, `id_agent`) VALUES (?, ?, ?)', $token, $field, $id_agent)) ? 1 : 0;
|
||||
} else {
|
||||
$result = db_update ($dbh, 'UPDATE tagent_custom_data SET description = ? WHERE id_field = ? AND id_agent = ?', $token, $field, $id_agent);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
|
|
@ -3404,9 +3404,14 @@ sub cli_agent_update_custom_fields() {
|
|||
}
|
||||
}
|
||||
|
||||
if(!defined($new_value)) {
|
||||
print_log "[ERROR] Error updating field '$field' no new value has been provided\n\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
print_log "\n[INFO] Updating field '$field' in agent with ID '$id_agent'\n\n";
|
||||
|
||||
my $result = pandora_agent_update_custom_field ($dbh, $new_value, $custom_field, $id_agent);
|
||||
my $result = pandora_update_agent_custom_field ($dbh, $new_value, $custom_field, $id_agent);
|
||||
|
||||
if($result == "0E0"){
|
||||
print_log "[ERROR] Error updating field '$field'\n\n";
|
||||
|
|
Loading…
Reference in New Issue