ITSM pandora_enterprise#11471

This commit is contained in:
daniel 2023-08-16 16:52:57 +02:00
parent 7baad52e79
commit 8bc65474f0
15 changed files with 236 additions and 202 deletions

View File

@ -6,4 +6,35 @@ DROP TABLE `tincidencia`;
DROP TABLE `tnota`;
DROP TABLE `tattachment`;
ALTER TABLE `talert_commands` ADD CONSTRAINT UNIQUE (`name`);
ALTER TABLE `talert_actions` MODIFY COLUMN `name` VARCHAR(500);
ALTER TABLE `talert_actions` ADD CONSTRAINT UNIQUE (`name`);
SET @command_name = 'Pandora ITSM Ticket';
SET @command_description = 'Create a ticket in Pandora ITSM';
SET @action_name = 'Create Pandora ITSM ticket';
UPDATE `talert_commands` SET `name` = @command_name, `description` = @command_description WHERE `name` = 'Integria IMS Ticket' AND `internal` = 1;
INSERT IGNORE INTO `talert_commands` (`name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (@command_name,'Internal type',@command_description,1,'["Ticket title","Ticket group ID","Ticket priority","Ticket owner","Ticket type","Ticket status","Ticket description","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_"]','["", "_ITSM_groups_", "_ITSM_priorities_","_ITSM_users_","_ITSM_types_","_ITSM_status_","_html_editor_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_"]');
SELECT @id_alert_command := `id` FROM `talert_commands` WHERE `name` = @command_name;
UPDATE `talert_actions` SET `name` = @action_name WHERE `name` = 'Create Integria IMS ticket' AND `id_alert_command` = @id_alert_command;
INSERT IGNORE INTO `talert_actions` (`name`, `id_alert_command`) VALUES (@action_name,@id_alert_command);
SET @event_response_name = 'Create ticket in Pandora ITSM from event';
SET @event_response_description = 'Create a ticket in Pandora ITSM from an event';
SET @event_response_target = 'index.php?sec=manageTickets&sec2=operation/ITSM/itsm&operation=edit&from_event=_event_id_';
SET @event_response_type = 'url';
SET @event_response_id_group = 0;
SET @event_response_modal_width = 0;
SET @event_response_modal_height = 0;
SET @event_response_new_window = 1;
SET @event_response_params = '';
SET @event_response_server_to_exec = 0;
SET @event_response_command_timeout = 90;
SET @event_response_display_command = 1;
UPDATE `tevent_response` SET `name` = @event_response_name, `description` = @event_response_description, `target` = @event_response_target, `display_command` = @event_response_display_command WHERE `name` = 'Create ticket in IntegriaIMS from event';
INSERT IGNORE INTO `tevent_response` (`name`, `description`, `target`,`type`,`id_group`,`modal_width`,`modal_height`,`new_window`,`params`,`server_to_exec`,`command_timeout`,`display_command`) VALUES (@event_response_name, @event_response_description, @event_response_target, @event_response_type, @event_response_id_group, @event_response_modal_width, @event_response_modal_height, @event_response_new_window, @event_response_params, @event_response_server_to_exec, @event_response_command_timeout, @event_response_display_command);
COMMIT;

View File

@ -405,6 +405,12 @@ $actions = array_slice($actions, $offset, $limit);
$rowPair = true;
$iterator = 0;
foreach ($actions as $action) {
if ((isset($config['ITSM_enabled']) === false || (bool) $config['ITSM_enabled'] === false)
&& $action['name'] === 'Create Pandora ITSM ticket'
) {
continue;
}
if ($rowPair) {
$table->rowclass[$iterator] = 'rowPair';
} else {

View File

@ -153,7 +153,7 @@ if (is_ajax()) {
$style = ((int) $field_hidden === 1) ? '-webkit-text-security: disc; font-family: text-security-disc;' : '';
$recovery_disabled = 0;
if (empty($command) === false && $command['name'] === io_safe_input('Integria IMS Ticket')) {
if (empty($command) === false && $command['name'] === io_safe_input('Pandora ITSM Ticket')) {
if ($management_is_not_allowed == 0) {
if (preg_match('/^_html_editor_$/i', $field_value) || $field_description === 'Ticket status') {
$recovery_disabled = 0;
@ -1027,6 +1027,12 @@ $commands = array_slice($commands, $offset, $limit);
foreach ($commands as $command) {
$data = [];
if ((isset($config['ITSM_enabled']) === false || (bool) $config['ITSM_enabled'] === false)
&& $command['name'] === 'Pandora ITSM Ticket'
) {
continue;
}
$data['name'] = '<span>';
// (IMPORTANT, DO NOT CHANGE!) only users with permissions over "All" group have access to edition of commands belonging to "All" group.

View File

@ -106,7 +106,7 @@ if (!empty($groups_user)) {
$groups = implode(',', array_keys($groups_user));
if ($config['ITSM_enabled'] == 0) {
$integria_command = 'Integria&#x20;IMS&#x20;Ticket';
$integria_command = 'Pandora&#x20;ITSM&#x20;Ticket';
$sql = sprintf('SELECT taa.id, taa.name FROM talert_actions taa INNER JOIN talert_commands tac ON taa.id_alert_command = tac.id WHERE tac.name <> "%s" AND taa.id_group IN (%s)', $integria_command, $groups);
} else {
$sql = "SELECT id, name FROM talert_actions WHERE id_group IN ($groups)";

View File

@ -159,19 +159,20 @@ if ($id) {
$name = $action['name'];
$id_command = $action['id_alert_command'];
$command = alerts_get_alert_command($id_command);
if (empty($command) === false && $command['name'] === io_safe_input('Integria IMS Ticket')) {
$action['field2'] = ($action['field2'] ?? $config['default_group']);
$action['field3'] = ($action['field3'] ?? $config['default_criticity']);
$action['field4'] = ($action['field4'] ?? $config['default_owner']);
$action['field5'] = ($action['field5'] ?? $config['incident_type']);
$action['field6'] = ($action['field6'] ?? $config['incident_status']);
$action['field7'] = ($action['field7'] ?? $config['incident_content']);
$action['field2_recovery'] = ($action['field2'] ?? $config['default_group']);
$action['field3_recovery'] = ($action['field3'] ?? $config['default_criticity']);
$action['field4_recovery'] = ($action['field4'] ?? $config['default_owner']);
$action['field5_recovery'] = ($action['field5'] ?? $config['incident_type']);
$action['field6_recovery'] = ($action['field6_recovery'] ?? $config['incident_status']);
$action['field7_recovery'] = ($action['field7_recovery'] ?? $config['incident_content']);
if (empty($command) === false && $command['name'] === io_safe_input('Pandora ITSM Ticket')) {
$action['field1'] = io_safe_output(($action['field1'] ?? $config['incident_title']));
$action['field2'] = io_safe_output(($action['field2'] ?? $config['default_group']));
$action['field3'] = io_safe_output(($action['field3'] ?? $config['default_criticity']));
$action['field4'] = io_safe_output(($action['field4'] ?? $config['default_owner']));
$action['field5'] = io_safe_output(($action['field5'] ?? $config['incident_type']));
$action['field6'] = io_safe_output(($action['field6'] ?? $config['incident_status']));
$action['field7'] = io_safe_output(($action['field7'] ?? $config['incident_content']));
$action['field2_recovery'] = io_safe_output(($action['field2'] ?? $config['default_group']));
$action['field3_recovery'] = io_safe_output(($action['field3'] ?? $config['default_criticity']));
$action['field4_recovery'] = io_safe_output(($action['field4'] ?? $config['default_owner']));
$action['field5_recovery'] = io_safe_output(($action['field5'] ?? $config['incident_type']));
$action['field6_recovery'] = io_safe_output(($action['field6_recovery'] ?? $config['incident_status']));
$action['field7_recovery'] = io_safe_output(($action['field7_recovery'] ?? $config['incident_content']));
}
$group = $action['id_group'];
@ -258,7 +259,7 @@ $table->data[0][1] = html_print_label_input_block(
)
);
$create_ticket_command_id = db_get_value('id', 'talert_commands', 'name', io_safe_input('Integria IMS Ticket'));
$create_ticket_command_id = db_get_value('id', 'talert_commands', 'name', io_safe_input('Pandora ITSM Ticket'));
$sql_exclude_command_id = '';
@ -378,13 +379,13 @@ $table_macros->data[1][2] = html_print_label_input_block(
)
);
if (empty($command) === false && $command['name'] === io_safe_input('Integria IMS Ticket')) {
if (empty($command) === false && $command['name'] === io_safe_input('Pandora ITSM Ticket')) {
// Selector will work only with Integria activated.
$integriaIdName = 'integria_wu';
$table_macros->colspan[$integriaIdName][0] = 3;
$table_macros->data[$integriaIdName][0] = html_print_label_input_block(
__('Create workunit on recovery').ui_print_help_tip(
__('If closed status is set on recovery, a workunit will be added to the ticket in Integria IMS rather that closing the ticket.'),
__('If closed status is set on recovery, a workunit will be added to the ticket in Pandora ITSM rather that closing the ticket.'),
true
),
html_print_checkbox_switch_extended(
@ -749,54 +750,62 @@ $(document).ready (function () {
disabled = $("[name=field" + i + "_value]").attr('disabled');
}
if ($("#id_command option:selected").text() === "Integria IMS Ticket" && (!old_value || !old_recovery_value) ) {
if (i === 2) {
if ($("#id_command option:selected").text() === "Pandora ITSM Ticket" && (!old_value || !old_recovery_value) ) {
if (i === 1) {
if(!old_value) {
old_value = '<?php echo $config['default_group']; ?>';
old_value = '<?php echo io_safe_output($config['incident_title']); ?>';
}
if(!old_recovery_value) {
old_recovery_value = '<?php echo $config['default_group']; ?>';
old_recovery_value = '<?php echo io_safe_output($config['incident_title']); ?>';
}
} else if (i === 2) {
if(!old_value || old_value == 0) {
old_value = '<?php echo io_safe_output($config['default_group']); ?>';
}
if(!old_recovery_value) {
old_recovery_value = '<?php echo io_safe_output($config['default_group']); ?>';
}
} else if (i === 3) {
if(!old_value) {
old_value = '<?php echo $config['default_criticity']; ?>';
old_value = '<?php echo io_safe_output($config['default_criticity']); ?>';
}
if(!old_recovery_value) {
old_recovery_value = '<?php echo $config['default_criticity']; ?>';
old_recovery_value = '<?php echo io_safe_output($config['default_criticity']); ?>';
}
} else if (i === 4) {
if(!old_value) {
old_value = '<?php echo $config['default_owner']; ?>';
old_value = '<?php echo io_safe_output($config['default_owner']); ?>';
}
if(!old_recovery_value) {
old_recovery_value = '<?php echo $config['default_owner']; ?>';
old_recovery_value = '<?php echo io_safe_output($config['default_owner']); ?>';
}
} else if (i === 5) {
if(!old_value) {
old_value = '<?php echo $config['incident_type']; ?>';
old_value = '<?php echo io_safe_output($config['incident_type']); ?>';
}
if(!old_recovery_value) {
old_recovery_value = '<?php echo $config['incident_type']; ?>';
old_recovery_value = '<?php echo io_safe_output($config['incident_type']); ?>';
}
} else if (i === 6) {
if(!old_value) {
old_value = '<?php echo $config['incident_status']; ?>';
old_value = '<?php echo io_safe_output($config['incident_status']); ?>';
}
if(!old_recovery_value) {
old_recovery_value = '<?php echo $config['incident_status']; ?>';
old_recovery_value = '<?php echo io_safe_output($config['incident_status']); ?>';
}
} else if (i === 7) {
if(!old_value) {
old_value = '<?php echo $config['incident_content']; ?>';
old_value = '<?php echo io_safe_output($config['incident_content']); ?>';
}
if(!old_recovery_value) {
old_recovery_value = '<?php echo $config['incident_content']; ?>';
old_recovery_value = '<?php echo io_safe_output($config['incident_content']); ?>';
}
}
}
@ -863,7 +872,7 @@ $(document).ready (function () {
}
}
if ($("#id_command option:selected").text() === "Integria IMS Ticket" && i > 7) {
if ($("#id_command option:selected").text() === "Pandora ITSM Ticket" && i > 7) {
integria_custom_fields_values.push(old_value);
integria_custom_fields_rvalues.push(old_recovery_value);
}
@ -885,9 +894,9 @@ $(document).ready (function () {
$table_macros_field.show();
}
// Ad-hoc solution for Integria IMS command: get Integia IMS Ticket custom fields only when this command is selected and we selected a ticket type to retrieve fields from.
// Ad-hoc solution for Pandora ITSM command: get Integia IMS Ticket custom fields only when this command is selected and we selected a ticket type to retrieve fields from.
// Check command by name since it is unvariable in any case, unlike its ID.
if ($("#id_command option:selected").text() === "Integria IMS Ticket") {
if ($("#id_command option:selected").text() === "Pandora ITSM Ticket") {
var max_macro_fields = <?php echo $config['max_macro_fields']; ?>;
// At start hide all rows and inputs corresponding to custom fields, regardless of what its type is.

View File

@ -75,6 +75,12 @@ foreach ($event_responses as $response) {
continue;
}
if ((isset($config['ITSM_enabled']) === false || (bool) $config['ITSM_enabled'] === false)
&& $response['name'] === 'Create&#x20;ticket&#x20;in&#x20;Pandora&#x20;ITSM&#x20;from&#x20;event'
) {
continue;
}
$data = [];
$data[0] = '<a href="index.php?sec=geventos&sec2=godmode/events/events&section=responses&mode=editor&id_response='.$response['id'].'&amp;pure='.$config['pure'].'">'.$response['name'].'</a>';
$data[1] = $response['description'];

View File

@ -63,78 +63,6 @@ if ($has_connection === false && $config['ITSM_enabled']) {
ui_print_error_message(__('ITSM API is not reachable, %s', $error));
}
if (get_parameter('update_config', 0) == 1) {
// Try to retrieve event response 'Create incident in IntegriaIMS from event' to check if it exists.
$event_response_exists = db_get_row_filter(
'tevent_response',
['name' => io_safe_input('Create ticket in IntegriaIMS from event')]
);
// Try to retrieve command 'Integia IMS Ticket' to check if it exists.
$command_exists = db_get_row_filter(
'talert_commands',
['name' => io_safe_input('Integria IMS Ticket')]
);
if ($config['ITSM_enabled'] == 1) {
if ($event_response_exists === false) {
// Create 'Create incident in IntegriaIMS from event' event response only when user enables IntegriaIMS integration and it does not exist in database.
db_process_sql_insert(
'tevent_response',
[
'name' => io_safe_input('Create ticket in IntegriaIMS from event'),
'description' => io_safe_input('Create a ticket in Integria IMS from an event'),
'target' => io_safe_input('index.php?sec=incident&sec2=operation/incidents/configure_integriaims_incident&from_event=_event_id_'),
'type' => 'url',
'id_group' => '0',
'modal_width' => '0',
'modal_height' => '0',
'new_window' => '1',
'params' => '',
'server_to_exec' => '0',
]
);
}
if ($command_exists === false) {
// Create 'Integria IMS Ticket' command only when user enables IntegriaIMS integration and it does not exist in database.
$id_command_inserted = db_process_sql_insert(
'talert_commands',
[
'name' => io_safe_input('Integria IMS Ticket'),
'command' => io_safe_input('Internal type'),
'internal' => 1,
'description' => io_safe_input('Create a ticket in Integria IMS'),
'fields_descriptions' => '["'.io_safe_input('Ticket title').'","'.io_safe_input('Ticket group ID').'","'.io_safe_input('Ticket priority').'","'.io_safe_input('Ticket owner').'","'.io_safe_input('Ticket type').'","'.io_safe_input('Ticket status').'","'.io_safe_input('Ticket description').'","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_"]',
'fields_values' => '["", "_ITSM_groups_", "_ITSM_priorities_","_ITSM_users_","_ITSM_types_","_ITSM_status_","_html_editor_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_"]',
]
);
// Create 'Create Integria IMS Ticket' action only when user enables IntegriaIMS integration and command exists in database.
$action_values = [
'field1' => $config['incident_title'],
'field1_recovery' => $config['incident_title'],
'field2' => $config['default_group'],
'field2_recovery' => $config['default_group'],
'field3' => $config['default_criticity'],
'field3_recovery' => $config['default_criticity'],
'field4' => $config['default_owner'],
'field4_recovery' => $config['default_owner'],
'field5' => $config['incident_type'],
'field5_recovery' => $config['incident_type'],
'field6' => $config['incident_status'],
'field6_recovery' => $config['incident_status'],
'field7' => $config['incident_content'],
'field7_recovery' => $config['incident_content'],
'id_group' => 0,
'action_threshold' => 0,
];
alerts_create_alert_action(io_safe_input('Create Integria IMS ticket'), $id_command_inserted, $action_values);
}
}
}
$table_enable = new StdClass();
$table_enable->data = [];
$table_enable->width = '100%';

View File

@ -1923,11 +1923,11 @@ function config_update_config()
$error_update[] = __('Pandora ITSM default creator');
}
if (config_update_value('default_owner', (string) get_parameter('default_owner', $config['default_owner']), true) === false) {
if (config_update_value('default_owner', (string) get_parameter('default_owner_hidden', $config['default_owner']), true) === false) {
$error_update[] = __('Pandora ITSM default owner');
}
if (config_update_value('cr_default_owner', (string) get_parameter('cr_default_owner', $config['cr_default_owner']), true) === false) {
if (config_update_value('cr_default_owner', (string) get_parameter('cr_default_owner_hidden', $config['cr_default_owner']), true) === false) {
$error_update[] = __('Pandora ITSM custom response default owner');
}

View File

@ -3635,6 +3635,12 @@ function events_page_responses($event)
} else {
$responses = [];
foreach ($event_responses as $v) {
if ((isset($config['ITSM_enabled']) === false || (bool) $config['ITSM_enabled'] === false)
&& $v['name'] === 'Create&#x20;ticket&#x20;in&#x20;Pandora&#x20;ITSM&#x20;from&#x20;event'
) {
continue;
}
$responses[$v['id']] = $v['name'];
}

View File

@ -6405,52 +6405,72 @@ function html_print_autocomplete_users_from_pandora_itsm(
}
$(document).ready (function () {
$("#text-<?php echo $name; ?>").autocomplete({
minLength: 2,
source: function( request, response ) {
var term = request.term; //Word to search
data_params = {
page: "operation/ITSM/itsm",
search_term: term,
method: "getUserSelect",
};
jQuery.ajax ({
data: data_params,
async: false,
type: "POST",
url: action="<?php echo $javascript_ajax_page; ?>",
timeout: 10000,
dataType: "json",
success: function (data) {
temp = [];
$.each(data, function (id, module) {
temp.push({
'value' : id,
'label' : module});
});
response(temp);
}
});
},
change: function( event, ui ) {
if (!ui.item)
$("input[name='<?php echo $name; ?>_hidden']")
.val(0);
return false;
},
select: function( event, ui ) {
$("input[name='<?php echo $name; ?>_hidden']")
.val(ui.item.value);
$("#text-<?php echo $name; ?>").val( ui.item.label );
return false;
$("#text-<?php echo $name; ?>").autocomplete({
minLength: 2,
source: function( request, response ) {
var term = request.term; //Word to search
var data_params = {
page: "operation/ITSM/itsm",
search_term: term,
method: "getUserSelect",
};
jQuery.ajax ({
data: data_params,
async: false,
type: "POST",
url: action="<?php echo $javascript_ajax_page; ?>",
timeout: 10000,
dataType: "json",
success: function (data) {
temp = [];
$.each(data, function (id, module) {
temp.push({
'value' : id,
'label' : module});
});
response(temp);
}
});
},
change: function( event, ui ) {
if (!ui.item) {
$("input[name='<?php echo $name; ?>_hidden']")
.val(0);
}
);
return false;
},
select: function( event, ui ) {
$("input[name='<?php echo $name; ?>_hidden']")
.val(ui.item.value);
$("#text-<?php echo $name; ?>").val( ui.item.label );
return false;
}
});
if($("input[name='<?php echo $name; ?>_hidden']").val() !== ''){
var data_params_initial = {
page: "operation/ITSM/itsm",
search_term: $("input[name='<?php echo $name; ?>_hidden']").val(),
method: "getUserSelect",
};
jQuery.ajax ({
data: data_params_initial,
async: false,
type: "POST",
url: action="<?php echo $javascript_ajax_page; ?>",
timeout: 10000,
dataType: "json",
success: function (data) {
$("#text-<?php echo $name; ?>").val(Object.entries(data)[0][1])
}
});
}
});
</script>
<?php
$output = ob_get_clean();

View File

@ -181,11 +181,13 @@ class Manager
*/
private function showEdit()
{
global $config;
$create_incidence = (bool) \get_parameter('create_incidence', 0);
$update_incidence = (bool) \get_parameter('update_incidence', 0);
$idIncidence = \get_parameter('idIncidence', 0);
$idIncidence = (int) \get_parameter('idIncidence', 0);
$idEvent = (int) \get_parameter('from_event', 0);
$headerTabs = $this->headersTabs('edit', (bool) $idIncidence);
$headerTabs = $this->headersTabs('edit', $idIncidence);
$error = '';
try {
@ -203,16 +205,42 @@ class Manager
$error = $th->getMessage();
}
$default_values = [
'title' => '',
'idIncidenceType' => 0,
'idGroup' => 0,
'priority' => 'LOW',
'status' => 'NEW',
'idCreator' => '',
'owner' => '',
'resolution' => null,
'description' => '',
];
if (empty($idEvent) === false) {
$default_values = [
'title' => $config['cr_incident_title'],
'idIncidenceType' => $config['cr_incident_type'],
'idGroup' => $config['cr_default_group'],
'priority' => $config['cr_default_criticity'],
'status' => $config['cr_incident_status'],
'idCreator' => '',
'owner' => $config['cr_default_owner'],
'resolution' => null,
'description' => $config['cr_incident_content'],
];
}
$incidence = [
'title' => \get_parameter('title', ($incidenceData['title'] ?? '')),
'idIncidenceType' => \get_parameter('idIncidenceType', ($incidenceData['idIncidenceType'] ?? 0)),
'idGroup' => \get_parameter('idGroup', ($incidenceData['idGroup'] ?? 0)),
'priority' => \get_parameter('priority', ($incidenceData['priority'] ?? 'LOW')),
'status' => \get_parameter('status', ($incidenceData['status'] ?? 'NEW')),
'idCreator' => \get_parameter('idCreator', ($incidenceData['idCreator'] ?? '')),
'owner' => \get_parameter('owner_hidden', ($incidenceData['owner'] ?? '')),
'resolution' => \get_parameter('resolution', ($incidenceData['resolution'] ?? null)),
'description' => \get_parameter('description', ($incidenceData['description'] ?? '')),
'title' => \get_parameter('title', ($incidenceData['title'] ?? $default_values['title'])),
'idIncidenceType' => \get_parameter('idIncidenceType', ($incidenceData['idIncidenceType'] ?? $default_values['idIncidenceType'])),
'idGroup' => \get_parameter('idGroup', ($incidenceData['idGroup'] ?? $default_values['idGroup'])),
'priority' => \get_parameter('priority', ($incidenceData['priority'] ?? $default_values['priority'])),
'status' => \get_parameter('status', ($incidenceData['status'] ?? $default_values['status'])),
'idCreator' => \get_parameter('idCreator', ($incidenceData['idCreator'] ?? $default_values['idCreator'])),
'owner' => \get_parameter('owner_hidden', ($incidenceData['owner'] ?? $default_values['owner'])),
'resolution' => \get_parameter('resolution', ($incidenceData['resolution'] ?? $default_values['resolution'])),
'description' => \get_parameter('description', ($incidenceData['description'] ?? $default_values['description'])),
];
$successfullyMsg = '';
@ -283,7 +311,7 @@ class Manager
$idAttachment = (int) \get_parameter('idAttachment', 0);
$addComment = (bool) \get_parameter('addComment', 0);
$headerTabs = $this->headersTabs('detail', (bool) $idIncidence);
$headerTabs = $this->headersTabs('detail', $idIncidence);
$error = '';
$successfullyMsg = null;

View File

@ -397,7 +397,8 @@ CREATE TABLE IF NOT EXISTS `talert_commands` (
`fields_values` TEXT,
`fields_hidden` TEXT,
`previous_name` TEXT,
PRIMARY KEY (`id`)
PRIMARY KEY (`id`),
UNIQUE (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
-- -----------------------------------------------------
@ -405,7 +406,7 @@ CREATE TABLE IF NOT EXISTS `talert_commands` (
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `talert_actions` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` TEXT,
`name` VARCHAR(500),
`id_alert_command` INT UNSIGNED NULL DEFAULT 0,
`field1` TEXT,
`field2` TEXT,
@ -452,6 +453,7 @@ CREATE TABLE IF NOT EXISTS `talert_actions` (
`previous_name` TEXT,
`create_wu_integria` TINYINT DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE (`name`),
FOREIGN KEY (`id_alert_command`) REFERENCES talert_commands(`id`)
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;

File diff suppressed because one or more lines are too long

View File

@ -1850,8 +1850,8 @@ sub pandora_execute_action ($$$$$$$$$;$$) {
}
}
# Integria IMS Ticket
} elsif ($clean_name eq "Integria IMS Ticket") {
# Pandora ITSM Ticket
} elsif ($clean_name eq "Pandora ITSM Ticket") {
my $config_ITSM_enabled = pandora_get_tconfig_token ($dbh, 'ITSM_enabled', '');
if (!$config_ITSM_enabled) {
return;
@ -1867,19 +1867,6 @@ sub pandora_execute_action ($$$$$$$$$;$$) {
$field5 = subst_alert_macros ($field5, \%macros, $pa_config, $dbh, $agent, $module, $alert);
$field6 = subst_alert_macros ($field6, \%macros, $pa_config, $dbh, $agent, $module, $alert);
$field7 = subst_alert_macros ($field7, \%macros, $pa_config, $dbh, $agent, $module, $alert);
$field8 = subst_alert_macros ($field8, \%macros, $pa_config, $dbh, $agent, $module, $alert);
$field9 = subst_alert_macros ($field9, \%macros, $pa_config, $dbh, $agent, $module, $alert);
$field10 = subst_alert_macros ($field10, \%macros, $pa_config, $dbh, $agent, $module, $alert);
$field11 = subst_alert_macros ($field11, \%macros, $pa_config, $dbh, $agent, $module, $alert);
$field12 = subst_alert_macros ($field12, \%macros, $pa_config, $dbh, $agent, $module, $alert);
$field13 = subst_alert_macros ($field13, \%macros, $pa_config, $dbh, $agent, $module, $alert);
$field14 = subst_alert_macros ($field14, \%macros, $pa_config, $dbh, $agent, $module, $alert);
$field15 = subst_alert_macros ($field15, \%macros, $pa_config, $dbh, $agent, $module, $alert);
$field16 = subst_alert_macros ($field16, \%macros, $pa_config, $dbh, $agent, $module, $alert);
$field17 = subst_alert_macros ($field17, \%macros, $pa_config, $dbh, $agent, $module, $alert);
$field18 = subst_alert_macros ($field18, \%macros, $pa_config, $dbh, $agent, $module, $alert);
$field19 = subst_alert_macros ($field19, \%macros, $pa_config, $dbh, $agent, $module, $alert);
$field20 = subst_alert_macros ($field20, \%macros, $pa_config, $dbh, $agent, $module, $alert);
# Field 1 (Ticket name)
my $ticket_name = safe_output($field1);
@ -1913,12 +1900,15 @@ sub pandora_execute_action ($$$$$$$$$;$$) {
# Field 6 (Ticket status)
my $ticket_status = $field6;
if ($ticket_status eq '0') {
$ticket_status = 1;
if ($ticket_status eq '') {
$ticket_status = 'new';
}
# Field 7 (Ticket description);
my $ticket_description = subst_alert_macros(safe_output($field7), \%macros, $pa_config, $dbh, $agent, $module, $alert);
my $ticket_description = $field7;
if ($ticket_description eq '') {
$ticket_description = '';
}
my $external_id = $agent->{'nombre'} . '-' . $module->{'id_agente'} . '-' . $module->{'id_agente_modulo'};
@ -1959,19 +1949,19 @@ sub pandora_execute_action ($$$$$$$$$;$$) {
# Ticket type custom fields
my %custom_fields = (
'field0' => subst_alert_macros(safe_output($field8), \%macros, $pa_config, $dbh, $agent, $module, $alert),
'field1' => subst_alert_macros(safe_output($field9), \%macros, $pa_config, $dbh, $agent, $module, $alert),
'field2' => subst_alert_macros(safe_output($field10), \%macros, $pa_config, $dbh, $agent, $module, $alert),
'field3' => subst_alert_macros(safe_output($field11), \%macros, $pa_config, $dbh, $agent, $module, $alert),
'field4' => subst_alert_macros(safe_output($field12), \%macros, $pa_config, $dbh, $agent, $module, $alert),
'field5' => subst_alert_macros(safe_output($field13), \%macros, $pa_config, $dbh, $agent, $module, $alert),
'field6' => subst_alert_macros(safe_output($field14), \%macros, $pa_config, $dbh, $agent, $module, $alert),
'field7' => subst_alert_macros(safe_output($field15), \%macros, $pa_config, $dbh, $agent, $module, $alert),
'field8' => subst_alert_macros(safe_output($field16), \%macros, $pa_config, $dbh, $agent, $module, $alert),
'field9' => subst_alert_macros(safe_output($field17), \%macros, $pa_config, $dbh, $agent, $module, $alert),
'field10' => subst_alert_macros(safe_output($field18), \%macros, $pa_config, $dbh, $agent, $module, $alert),
'field11' => subst_alert_macros(safe_output($field19), \%macros, $pa_config, $dbh, $agent, $module, $alert),
'field12' => subst_alert_macros(safe_output($field20), \%macros, $pa_config, $dbh, $agent, $module, $alert)
'field0' => $field8 ne "" ? subst_alert_macros(safe_output($field8), \%macros, $pa_config, $dbh, $agent, $module, $alert) : undef,
'field1' => $field9 ne "" ? subst_alert_macros(safe_output($field9), \%macros, $pa_config, $dbh, $agent, $module, $alert) : undef,
'field2' => $field10 ne "" ? subst_alert_macros(safe_output($field10), \%macros, $pa_config, $dbh, $agent, $module, $alert) : undef,
'field3' => $field11 ne "" ? subst_alert_macros(safe_output($field11), \%macros, $pa_config, $dbh, $agent, $module, $alert) : undef,
'field4' => $field12 ne "" ? subst_alert_macros(safe_output($field12), \%macros, $pa_config, $dbh, $agent, $module, $alert) : undef,
'field5' => $field13 ne "" ? subst_alert_macros(safe_output($field13), \%macros, $pa_config, $dbh, $agent, $module, $alert) : undef,
'field6' => $field14 ne "" ? subst_alert_macros(safe_output($field14), \%macros, $pa_config, $dbh, $agent, $module, $alert) : undef,
'field7' => $field15 ne "" ? subst_alert_macros(safe_output($field15), \%macros, $pa_config, $dbh, $agent, $module, $alert) : undef,
'field8' => $field16 ne "" ? subst_alert_macros(safe_output($field16), \%macros, $pa_config, $dbh, $agent, $module, $alert) : undef,
'field9' => $field17 ne "" ? subst_alert_macros(safe_output($field17), \%macros, $pa_config, $dbh, $agent, $module, $alert) : undef,
'field10' => $field18 ne "" ? subst_alert_macros(safe_output($field18), \%macros, $pa_config, $dbh, $agent, $module, $alert) : undef,
'field11' => $field19 ne "" ? subst_alert_macros(safe_output($field19), \%macros, $pa_config, $dbh, $agent, $module, $alert) : undef,
'field12' => $field20 ne "" ? subst_alert_macros(safe_output($field20), \%macros, $pa_config, $dbh, $agent, $module, $alert) : undef
);
# Check exit inventory object.

View File

@ -2359,13 +2359,13 @@ sub api_call {
# TODO: change to logger.
use Data::Dumper;
$Data::Dumper::SortKeys = 1;
print Dumper("------------------");
if ($@) { print Dumper($@); }
#print Dumper($response);
print Dumper($response->{'_rc'});
print Dumper($response->{'_content'});
print Dumper($response->{'_request'});
logger($pa_config, 'Api response failure: ' . $response->{'_rc'} . '. Description error: ' . $response->{'_content'}, 3);
logger($pa_config, $response->{'_request'}, 3);
return undef;
}