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

View File

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

View File

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

View File

@ -12566,3 +12566,7 @@ tr[id^="network_component-plugin-snmp-fields-dynamicMacroRow-"] input {
.ui-date-range-in > a { .ui-date-range-in > a {
background-color: #81b92e3b !important; 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; $show_tab_issue = false;
try { try {
$ITSM = new ITSM(); $ITSM = new ITSM();
$list = $ITSM->listIncidenceAgents($id_agente); $list = $ITSM->listIncidenceAgents($id_agente, false);
if (empty($list) === false) { if (empty($list) === false) {
$show_tab_issue = true; $show_tab_issue = true;
} }

View File

@ -56,6 +56,18 @@ if (empty($error) === false) {
ui_print_error_message($error); 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) { if (empty($successfullyMsg) === false) {
ui_print_success_message($successfullyMsg); ui_print_success_message($successfullyMsg);
} }

View File

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

View File

@ -3897,8 +3897,31 @@ 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 = pandora_get_agent_custom_field_data($dbh,$id_agent);
my %agent_custom_field_data_reducer = (); my %agent_custom_field_data_reducer = ();
my $type = 'text';
foreach my $data (@{$agent_custom_field_data}) { foreach my $data (@{$agent_custom_field_data}) {
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}) {
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'}) { if ($data->{'is_password_type'}) {
$type = 'password'; $type = 'password';
} elsif ($data->{'is_link_enabled'}) { } elsif ($data->{'is_link_enabled'}) {
@ -3907,20 +3930,12 @@ sub pandora_get_custom_field_for_itsm ($$) {
$type = 'text'; $type = 'text';
} }
my %test = ( my %data_type = (
'data' => safe_output($data->{'description'}), 'data' => safe_output($data->{'description'}),
'type' => $type 'type' => $type
); );
$agent_custom_field_data_reducer{$data->{'name'}} = \%test; return \%data_type;
}
my %result = ();
foreach my $custom_field (@{$custom_fields}) {
$result{safe_output($custom_field->{'name'})} = $agent_custom_field_data_reducer{$custom_field->{'name'}};
}
return \%result;
} }
########################################################################## ##########################################################################