ITSM pandora_enterprise#11471

This commit is contained in:
daniel 2023-09-14 16:36:52 +02:00
parent af968b5e13
commit 09bcedde62
8 changed files with 149 additions and 84 deletions

View File

@ -377,8 +377,8 @@ if (is_ajax()) {
'field'.$i.'_value[]',
'',
'',
10,
10,
50,
50,
true,
false,
false,
@ -387,7 +387,7 @@ if (is_ajax()) {
'',
'off',
false,
false,
'',
'',
'',
$management_is_not_allowed
@ -396,8 +396,8 @@ if (is_ajax()) {
'field'.$i.'_recovery_value[]',
'',
'',
10,
10,
50,
50,
true,
false,
false,
@ -406,7 +406,7 @@ if (is_ajax()) {
'',
'off',
false,
false,
'',
'',
'',
$management_is_not_allowed || $recovery_disabled

View File

@ -459,7 +459,7 @@ class ITSM
*
* @return array list Incidences.
*/
public function listIncidenceAgents(int $idAgent): array
public function listIncidenceAgents(int $idAgent, ?bool $blocked=null): array
{
global $config;
$listIncidences = $this->callApi(
@ -468,7 +468,10 @@ class ITSM
'page' => 0,
'sizePage' => 0,
],
['externalIdLike' => $config['metaconsole_node_id'].'-'.$idAgent]
[
'externalIdLike' => $config['metaconsole_node_id'].'-'.$idAgent,
'blocked' => $blocked,
]
);
return $listIncidences['data'];

View File

@ -145,6 +145,7 @@ class Manager
$successfullyMsg = '';
$groups = [];
$status = [];
$priorities = [];
$headerTabs = $this->headersTabs('list');
@ -152,6 +153,7 @@ class Manager
$ITSM = new ITSM();
$groups = $ITSM->getGroups();
$status = $ITSM->getStatus();
$priorities = $ITSM->getPriorities();
if (empty($idIncidence) === false) {
$this->deleteIncidence($ITSM, $idIncidence);
$successfullyMsg = __('Delete ticket successfully');
@ -169,6 +171,7 @@ class Manager
'successfullyMsg' => $successfullyMsg,
'groups' => $groups,
'status' => $status,
'priorities' => $priorities,
'headerTabs' => $headerTabs,
]
);
@ -315,6 +318,9 @@ class Manager
$headerTabs = $this->headersTabs('detail', $idIncidence);
$error = '';
$error_upload = '';
$error_comment = '';
$error_delete_attachment = '';
$successfullyMsg = null;
$incidence = null;
$objectTypes = null;
@ -328,46 +334,60 @@ class Manager
$priorityDiv = null;
$inventories = null;
$ITSM = new ITSM();
try {
if ($uploadFile === true) {
$attachment = [
'description' => get_parameter('file_description', ''),
];
$incidenceAttachment = $this->createIncidenceAttachment(
$ITSM,
$idIncidence,
$attachment,
get_parameter('userfile')
);
if ($incidenceAttachment !== false) {
$successfullyMsg = __('File added succesfully');
}
}
} catch (\Exception $e) {
hd($e->getMessage());
$error_upload = $e->getMessage();
}
try {
if ($addComment === true) {
$wu = [
'description' => get_parameter('comment_description', ''),
];
$incidenceAttachment = $this->createIncidenceWu(
$ITSM,
$idIncidence,
$wu
);
if ($incidenceAttachment !== false) {
$successfullyMsg = __('Comment added succesfully');
}
}
} catch (\Exception $e) {
$error_comment = $e->getMessage();
}
try {
if (empty($idAttachment) === false) {
$this->deleteIncidenceAttachment($ITSM, $idIncidence, $idAttachment);
$successfullyMsg = __('Delete File successfully');
}
} catch (\Exception $e) {
$error_delete_attachment = $e->getMessage();
}
try {
if (empty($idIncidence) === false) {
if ($uploadFile === true) {
$attachment = [
'description' => get_parameter('file_description', ''),
];
$incidenceAttachment = $this->createIncidenceAttachment(
$ITSM,
$idIncidence,
$attachment,
get_parameter('userfile')
);
if ($incidenceAttachment !== false) {
$successfullyMsg = __('File added succesfully');
}
}
if ($addComment === true) {
$wu = [
'description' => get_parameter('comment_description', ''),
];
$incidenceAttachment = $this->createIncidenceWu(
$ITSM,
$idIncidence,
$wu
);
if ($incidenceAttachment !== false) {
$successfullyMsg = __('Comment added succesfully');
}
}
if (empty($idAttachment) === false) {
$this->deleteIncidenceAttachment($ITSM, $idIncidence, $idAttachment);
$successfullyMsg = __('Delete File successfully');
}
$incidence = $this->getIncidence($ITSM, $idIncidence);
$objectTypes = $ITSM->getObjectypes();
$groups = $ITSM->getGroups();
@ -403,29 +423,32 @@ class Manager
}
}
}
} catch (\Throwable $th) {
$error = $th->getMessage();
} catch (\Exception $e) {
$error = $e->getMessage();
}
View::render(
'ITSM/ITSMTicketDetailView',
[
'ajaxController' => $this->ajaxController,
'urlAjax' => \ui_get_full_url('ajax.php'),
'error' => $error,
'successfullyMsg' => $successfullyMsg,
'incidence' => $incidence,
'objectTypes' => $objectTypes,
'groups' => $groups,
'resolutions' => $resolutions,
'status' => $status,
'wus' => $wus,
'files' => $files,
'users' => $users,
'priorities' => $priorities,
'priorityDiv' => $priorityDiv,
'headerTabs' => $headerTabs,
'inventories' => $inventories,
'ajaxController' => $this->ajaxController,
'urlAjax' => \ui_get_full_url('ajax.php'),
'error' => $error,
'error_upload' => $error_upload,
'error_comment' => $error_comment,
'error_delete_attachment' => $error_delete_attachment,
'successfullyMsg' => $successfullyMsg,
'incidence' => $incidence,
'objectTypes' => $objectTypes,
'groups' => $groups,
'resolutions' => $resolutions,
'status' => $status,
'wus' => $wus,
'files' => $files,
'users' => $users,
'priorities' => $priorities,
'priorityDiv' => $priorityDiv,
'headerTabs' => $headerTabs,
'inventories' => $inventories,
]
);
}

View File

@ -12566,3 +12566,7 @@ tr[id^="network_component-plugin-snmp-fields-dynamicMacroRow-"] input {
.ui-date-range-in > a {
background-color: #81b92e3b !important;
}
.ui-datepicker-title > span {
color: #82b92e !important;
}

View File

@ -950,7 +950,7 @@ if ((bool) $config['ITSM_enabled'] === true) {
$show_tab_issue = false;
try {
$ITSM = new ITSM();
$list = $ITSM->listIncidenceAgents($id_agente);
$list = $ITSM->listIncidenceAgents($id_agente, false);
if (empty($list) === false) {
$show_tab_issue = true;
}

View File

@ -56,6 +56,18 @@ if (empty($error) === false) {
ui_print_error_message($error);
}
if (empty($error_upload) === false) {
ui_print_error_message($error_upload);
}
if (empty($error_comment) === false) {
ui_print_error_message($error_comment);
}
if (empty($error_delete_attachment) === false) {
ui_print_error_message($error_delete_attachment);
}
if (empty($successfullyMsg) === false) {
ui_print_success_message($successfullyMsg);
}

View File

@ -121,7 +121,15 @@ try {
'type' => 'select',
'name' => 'status',
'fields' => $status,
'nothing' => 'None',
'nothing' => __('Any'),
'nothing_value' => null,
],
[
'label' => __('Priorities'),
'type' => 'select',
'name' => 'priority',
'fields' => $priorities,
'nothing' => __('Any'),
'nothing_value' => null,
],
[
@ -129,7 +137,7 @@ try {
'type' => 'select',
'name' => 'idGroup',
'fields' => $groups,
'nothing' => 'None',
'nothing' => __('Any'),
'nothing_value' => null,
],
[
@ -137,7 +145,7 @@ try {
'type' => 'interval',
'name' => 'fromDate',
'value' => 0,
'nothing' => __('None'),
'nothing' => __('Any'),
'nothing_value' => 0,
],
],

View File

@ -3897,32 +3897,47 @@ 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}) {
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 $array_data = pandora_check_type_custom_field_for_itsm($data);
$agent_custom_field_data_reducer{$data->{'name'}} = $array_data;
}
my %result = ();
foreach my $custom_field (@{$custom_fields}) {
$result{safe_output($custom_field->{'name'})} = $agent_custom_field_data_reducer{$custom_field->{'name'}};
if($agent_custom_field_data_reducer{$custom_field->{'name'}}) {
$result{safe_output($custom_field->{'name'})} = $agent_custom_field_data_reducer{$custom_field->{'name'}};
} else {
$result{safe_output($custom_field->{'name'})} = pandora_check_type_custom_field_for_itsm($custom_field);
}
}
return \%result;
}
##########################################################################
## Check type custom field and data for agent.
##########################################################################
sub pandora_check_type_custom_field_for_itsm ($) {
my ($data) = @_;
my $type = 'text';
if ($data->{'is_password_type'}) {
$type = 'password';
} elsif ($data->{'is_link_enabled'}) {
$type = 'link';
} else {
$type = 'text';
}
my %data_type = (
'data' => safe_output($data->{'description'}),
'type' => $type
);
return \%data_type;
}
##########################################################################
## Update a custom field from agent of tagent_custom_data
##########################################################################