ITSM pandora_enterprise#11471

This commit is contained in:
daniel 2023-09-04 16:36:58 +02:00
parent 1a1087e311
commit a059f18b4b
9 changed files with 86 additions and 14 deletions

View File

@ -173,7 +173,7 @@ if (check_acl($config['id_user'], 0, 'AW')) {
$buttons['ITSM'] = [
'active' => false,
'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup&section=ITSM').'">'.html_print_image(
'images/integria.png',
'images/itsm.png',
true,
[
'title' => __('ITSM'),
@ -185,7 +185,7 @@ $buttons['ITSM'] = [
$buttons['ehorus'] = [
'active' => false,
'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup&section=ehorus').'">'.html_print_image(
'images/ehorus/ehorus.png',
'images/RC.png',
true,
[
'title' => __('eHorus'),

Binary file not shown.

After

Width:  |  Height:  |  Size: 845 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 892 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 895 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 852 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@ -1658,7 +1658,7 @@ if ((bool) $config['ehorus_enabled'] === true && empty($config['ehorus_custom_fi
if (empty($ehorus_agent_id) === false) {
$tab_url = 'index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=ehorus&id_agente='.$id_agente;
$ehorus_tab['text'] = '<a href="'.$tab_url.'" class="ehorus_tab">'.html_print_image(
'images/ehorus/ehorus.png',
'images/RC.png',
true,
[
'title' => __('eHorus'),

View File

@ -52,8 +52,6 @@ ui_print_standard_header(
]
);
hd($inventories);
if (empty($error) === false) {
ui_print_error_message($error);
}
@ -196,6 +194,30 @@ if (empty($incidence) === true) {
$description_box .= '</div>';
ui_toggle($description_box, __('Description'), '', '', false);
if (empty($inventories) === false) {
$inventories_box = '<div class="ITSM_details_description">';
$inventories_box .= '<ul>';
foreach ($inventories as $inventory) {
$inventories_box .= '<li>';
if (empty($inventory['idPandora']) === true) {
$inventories_box .= $inventory['name'];
} else {
$id_agent = explode('-', $inventory['idPandora'])[1];
$url_agent = $config['homeurl'];
$url_agent .= 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agent;
$inventories_box .= '<a href="'.$url_agent.'" target="_blanK" title="'.__('Agent').'">';
$inventories_box .= $inventory['name'];
$inventories_box .= '</a>';
}
$inventories_box .= '</li>';
}
$inventories_box .= '</ul>';
$inventories_box .= '</div>';
ui_toggle($inventories_box, __('Related to inventory object'), '', '', false);
}
// Files section table.
$table_files_section = new stdClass();
$table_files_section->width = '100%';

View File

@ -1927,13 +1927,43 @@ sub pandora_execute_action ($$$$$$$$$;$$) {
# Extract custom field valid with data.
my $custom_fields_data = pandora_get_custom_field_for_itsm($dbh, $agent->{'id_agente'});
my %OS = (
'data' => safe_output(get_db_value($dbh, 'select name from tconfig_os where id_os = ?', $agent->{'id_os'})),
'type' => 'text'
);
my %ip_address = (
'data' => safe_output($agent->{'direccion'}),
'type' => 'text'
);
my %url_address = (
'data' => '["Agent", "' . safe_output($agent->{'url_address'} . '"]'),
'type' => 'link'
);
my %id_agent = (
'data' => $agent->{'id_agente'},
'type' => 'numeric'
);
my %group = (
'data' => safe_output(get_db_value($dbh, 'select nombre from tgrupo where id_grupo = ?', $agent->{'id_grupo'})),
'type' => 'text'
);
my %os_version = (
'data' => $agent->{'os_version'},
'type' => 'text'
);
my %inventory_custom_fields = (
'OS' => safe_output(get_db_value($dbh, 'select name from tconfig_os where id_os = ?', $agent->{'id_os'})),
'IP Address' => safe_output($agent->{'direccion'}),
'URL Address' => safe_output($agent->{'url_address'}),
'ID Agent' => $agent->{'id_agente'},
'Group' => safe_output(get_db_value($dbh, 'select nombre from tgrupo where id_grupo = ?', $agent->{'id_grupo'})),
'OS Version' => $agent->{'os_version'}
'OS' => \%OS,
'IP Address' => \%ip_address,
'URL Address' => \%url_address,
'ID Agent' => \%id_agent,
'Group' => \%group,
'OS Version' => \%os_version
);
my %dataSend = (
@ -1949,6 +1979,12 @@ sub pandora_execute_action ($$$$$$$$$;$$) {
'createWu' => $action->{'create_wu_integria'}
);
my $test = pandora_prepare_info_object_inventory_itsm($dbh);
# TODO: change to logger.
use Data::Dumper;
$Data::Dumper::SortKeys = 1;
print Dumper($test);
my $response = pandora_API_ITSM_call($pa_config, 'post', $ITSM_path . '/pandorafms/alert', $ITSM_token, \%dataSend);
if (!defined($response)){
return;
@ -3854,7 +3890,7 @@ sub pandora_get_custom_fields ($) {
sub pandora_get_agent_custom_field_data ($$) {
my ($dbh, $id_agent) = @_;
my @result = get_db_rows($dbh, 'select tagent_custom_fields.id_field, tagent_custom_fields.name, tagent_custom_data.id_agent, tagent_custom_data.description from tagent_custom_fields INNER JOIN tagent_custom_data ON tagent_custom_data.id_field = tagent_custom_fields.id_field where tagent_custom_data.id_agent = ?', $id_agent);
my @result = get_db_rows($dbh, 'select tagent_custom_fields.id_field, tagent_custom_fields.name, tagent_custom_data.id_agent, tagent_custom_data.description, tagent_custom_fields.is_password_type, tagent_custom_fields.is_link_enabled from tagent_custom_fields INNER JOIN tagent_custom_data ON tagent_custom_data.id_field = tagent_custom_fields.id_field where tagent_custom_data.id_agent = ?', $id_agent);
return \@result;
}
@ -3868,13 +3904,27 @@ sub pandora_get_custom_field_for_itsm ($$) {
my $agent_custom_field_data = pandora_get_agent_custom_field_data($dbh,$id_agent);
my %agent_custom_field_data_reducer = ();
my $type = 'text';
foreach my $data (@{$agent_custom_field_data}) {
$agent_custom_field_data_reducer{$data->{'name'}} = $data->{'description'};
if ($data->{'is_password_type'}) {
$type = 'password';
} elsif ($data->{'is_link_enabled'}) {
$type = 'link';
} else {
$type = 'text';
}
my %test = (
'data' => safe_output($data->{'description'}),
'type' => $type
);
$agent_custom_field_data_reducer{$data->{'name'}} = \%test;
}
my %result = ();
foreach my $custom_field (@{$custom_fields}) {
$result{safe_output($custom_field->{'name'})} = safe_output($agent_custom_field_data_reducer{$custom_field->{'name'}});
$result{safe_output($custom_field->{'name'})} = $agent_custom_field_data_reducer{$custom_field->{'name'}};
}
return \%result;