diff --git a/pandora_console/extras/mr/66.sql b/pandora_console/extras/mr/66.sql index 9e8f9b54ff..a9e063130d 100644 --- a/pandora_console/extras/mr/66.sql +++ b/pandora_console/extras/mr/66.sql @@ -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; \ No newline at end of file diff --git a/pandora_console/godmode/alerts/alert_actions.php b/pandora_console/godmode/alerts/alert_actions.php index 97a492809e..e8915b05eb 100644 --- a/pandora_console/godmode/alerts/alert_actions.php +++ b/pandora_console/godmode/alerts/alert_actions.php @@ -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 { diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index 435f161def..c0e9c3087a 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -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'] = ''; // (IMPORTANT, DO NOT CHANGE!) only users with permissions over "All" group have access to edition of commands belonging to "All" group. diff --git a/pandora_console/godmode/alerts/alert_list.builder.php b/pandora_console/godmode/alerts/alert_list.builder.php index db53e202ad..f86537f945 100644 --- a/pandora_console/godmode/alerts/alert_list.builder.php +++ b/pandora_console/godmode/alerts/alert_list.builder.php @@ -106,7 +106,7 @@ if (!empty($groups_user)) { $groups = implode(',', array_keys($groups_user)); if ($config['ITSM_enabled'] == 0) { - $integria_command = 'Integria IMS Ticket'; + $integria_command = 'Pandora ITSM 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)"; diff --git a/pandora_console/godmode/alerts/configure_alert_action.php b/pandora_console/godmode/alerts/configure_alert_action.php index c2b3d9cbcf..9a3903021f 100644 --- a/pandora_console/godmode/alerts/configure_alert_action.php +++ b/pandora_console/godmode/alerts/configure_alert_action.php @@ -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 = ''; + old_value = ''; } if(!old_recovery_value) { - old_recovery_value = ''; + old_recovery_value = ''; + } + } else if (i === 2) { + if(!old_value || old_value == 0) { + old_value = ''; + } + + if(!old_recovery_value) { + old_recovery_value = ''; } } else if (i === 3) { if(!old_value) { - old_value = ''; + old_value = ''; } if(!old_recovery_value) { - old_recovery_value = ''; + old_recovery_value = ''; } } else if (i === 4) { if(!old_value) { - old_value = ''; + old_value = ''; } if(!old_recovery_value) { - old_recovery_value = ''; + old_recovery_value = ''; } } else if (i === 5) { if(!old_value) { - old_value = ''; + old_value = ''; } if(!old_recovery_value) { - old_recovery_value = ''; + old_recovery_value = ''; } } else if (i === 6) { if(!old_value) { - old_value = ''; + old_value = ''; } if(!old_recovery_value) { - old_recovery_value = ''; + old_recovery_value = ''; } } else if (i === 7) { if(!old_value) { - old_value = ''; + old_value = ''; } if(!old_recovery_value) { - old_recovery_value = ''; + old_recovery_value = ''; } } } @@ -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 = ; // At start hide all rows and inputs corresponding to custom fields, regardless of what its type is. diff --git a/pandora_console/godmode/events/event_responses.list.php b/pandora_console/godmode/events/event_responses.list.php index 0cf83a4eed..0e39683c7e 100644 --- a/pandora_console/godmode/events/event_responses.list.php +++ b/pandora_console/godmode/events/event_responses.list.php @@ -75,6 +75,12 @@ foreach ($event_responses as $response) { continue; } + if ((isset($config['ITSM_enabled']) === false || (bool) $config['ITSM_enabled'] === false) + && $response['name'] === 'Create ticket in Pandora ITSM from event' + ) { + continue; + } + $data = []; $data[0] = ''.$response['name'].''; $data[1] = $response['description']; diff --git a/pandora_console/godmode/setup/setup_ITSM.php b/pandora_console/godmode/setup/setup_ITSM.php index a2b0a69fa5..b65736e61a 100644 --- a/pandora_console/godmode/setup/setup_ITSM.php +++ b/pandora_console/godmode/setup/setup_ITSM.php @@ -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%'; diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 8d105c6740..29e96c7da3 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -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'); } diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 29281ff5bd..202b849fe8 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -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 ticket in Pandora ITSM from event' + ) { + continue; + } + $responses[$v['id']] = $v['name']; } diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 352e3509ca..df8fd7b2e4 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -6405,52 +6405,72 @@ function html_print_autocomplete_users_from_pandora_itsm( } $(document).ready (function () { - $("#text-").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="", - 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='_hidden']") - .val(0); - return false; - }, - select: function( event, ui ) { - $("input[name='_hidden']") - .val(ui.item.value); - - $("#text-").val( ui.item.label ); - return false; + $("#text-").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="", + 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='_hidden']") + .val(0); } - ); + return false; + }, + select: function( event, ui ) { + $("input[name='_hidden']") + .val(ui.item.value); + + $("#text-").val( ui.item.label ); + return false; + } }); + + if($("input[name='_hidden']").val() !== ''){ + var data_params_initial = { + page: "operation/ITSM/itsm", + search_term: $("input[name='_hidden']").val(), + method: "getUserSelect", + }; + + jQuery.ajax ({ + data: data_params_initial, + async: false, + type: "POST", + url: action="", + timeout: 10000, + dataType: "json", + success: function (data) { + $("#text-").val(Object.entries(data)[0][1]) + } + }); + } + }); 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; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index f6b49f1528..22f587d32f 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -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; diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index d25b2b152b..752421ea36 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -26,6 +26,8 @@ INSERT INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal INSERT INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (13,'Generate Notification','Internal type','This command allows you to send an internal notification to any user or group.',1,'[\"Destination user\",\"Destination group\",\"Title\",\"Message\",\"Link\",\"Criticity\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); INSERT INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (14,'Send report by e-mail','Internal type','This command allows you to send a report by email.',1,'[\"Report\",\"e-mail address\",\"Subject\",\"Text\",\"Report type\",\"\",\"\",\"\",\"\",\"\"]','[\"_reports_\",\"\",\"\",\"_html_editor_\",\"xml,XML;pdf,PDF;json,JSON;csv,CSV\",\"\",\"\",\"\",\"\",\"\"]'); INSERT INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (15,'Send report by e-mail (from template)','Internal type','This command allows you to send a report generated from a template by email.',1,'[\"Template\",\"Regexp agent filter\",\"e-mail address\",\"Subject\",\"Text\",\"Report type\",\"\",\"\",\"\",\"\"]','[\"_report_templates_\",\"\",\"\",\"\",\"_html_editor_\",\"xml,XML;pdf,PDF;json,JSON;csv,CSV\",\"\",\"\",\"\",\"\"]'); +INSERT INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (16,'Pandora ITSM Ticket','Internal type','Create a ticket in Pandora ITSM',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_"]'); + -- -- Dumping data for table `tconfig` -- @@ -1156,7 +1158,7 @@ INSERT INTO `talert_actions` (`id`, `name`, `id_alert_command`, `field1`, `field (4,'Send Report by e-mail',14,'','yourmail@domain.es','','<div style="background-color: #eaf0f6; font-family: Arial, Helvetica, sans-serif; padding: 30px; margin: 0;"><table style="max-width: 560px; background-color: white; border-radius: 10px; padding: 10px 20px 40px;" cellspacing="0" cellpadding="0" align="center"><thead><tr><td style="padding: 0px 0px 5px;"><a href="https://pandorafms.com/en/" target="_blank"><img src="https://pandorafms.com/wp-content/uploads/2022/03/System-email-Pandora-FMS.png" width="206px"></a></td><td style="padding: 0px 0px 5px;"><p style="text-align: right; color: #223549; font-weight: bold; line-height: 36px; padding: 0px; font-size: 12px;">Automatic alert system</p></td></tr><tr><td style="padding: 0px 0px 5px;" colspan="2"><hr style="border: 1px solid #f5f5f5; width: 100%; margin: 0px;"></td></tr></thead><tbody><tr><td colspan="2"><img onerror="this.style.display=&quot;none&quot;;" src="_statusimage_" style="display: block; margin-left: auto; margin-right: auto; width: 105px; margin-top: 20px; padding: 0px;" width="105px"></td></tr><tr><td colspan="2"><p style="font-size: 24px; text-align: center; color: #223549; padding: 0px 10%; line-height: 34px; margin: 20px 0px;">We have bad news for you, something is on <span style="text-transform: uppercase; font-weight: 800;">_modulestatus_</span> status!</p><div><!--[if mso]><v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"><w:anchorlock/><center><![endif]--><a style="background-color: #223549; border: none; color: white; padding: 15px 30px; text-align: center; text-decoration: none; display: block; font-size: 16px; margin-left: auto; margin-right: auto; border-radius: 100px; max-width: 50%; margin-top: 0px; font-weight: bold;" href="_homeurl_">Go to Pandora FMS Console</a><!--[if mso]></center></v:rect><![endif]--></div></td></tr><tr><td colspan="2"><div style="background-color: #f6f6f6; border-radius: 10px; padding: 10px 20px; margin-top: 40px;"><p style="font-size: 18px; line-height: 30px; color: #223549;">Monitoring details</p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Data: <span style="font-weight: 400!important;">_data_ <em>(_modulestatus_)</em></span></p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Agent: <span style="font-weight: 400!important;">_agent_ <em>_address_</em></span></p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Module: <span style="font-weight: 400!important;">_module_ <em>_moduledescription_</em></span></p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Timestamp: <span style="font-weight: 400!important;">_timestamp_</span></p></div></td></tr><tr><td style="padding: 20px 0px;" colspan="2"><p style="font-size: 18px; line-height: 30px; color: #223549;">Report details</p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Generated:&nbsp;<span style="font-weight: 400!important;">_report_generated_date_<em><br></em></span></p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Report date:&nbsp;<span style="font-weight: 400!important;">_report_date_<em><br></em></span></p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Description:&nbsp;<span style="font-weight: 400!important;">_report_description_</span></p></td></tr></tbody></table><div style="text-align: center; margin-top: 10px;"><p style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;"><a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/en/contact/">Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/community/forums/forum/english/">Support</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/manual/en/start">Docs</a></p></div></div>','','','','','','',0,0,'','','','<div style="background-color: #eaf0f6; font-family: Arial, Helvetica, sans-serif; padding: 30px; margin: 0;"> <table style="max-width: 560px; background-color: white; border-radius: 10px; padding: 10px 20px 40px;" cellspacing="0" cellpadding="0" align="center"> <thead> <tr> <td style="padding: 0px 0px 5px;"><a href="https://pandorafms.com/en/" target="_blank"><img src="https://pandorafms.com/wp-content/uploads/2022/03/System-email-Pandora-FMS.png" width="206px"></a></td> <td style="padding: 0px 0px 5px;"> <p style="text-align: right; color: #223549; font-weight: bold; line-height: 36px; padding: 0px; font-size: 12px;">Automatic alert system</p> </td> </tr> <tr> <td style="padding: 0px 0px 5px;" colspan="2"><hr style="border: 1px solid #f5f5f5; width: 100%; margin: 0px;"></td> </tr> </thead> <tbody> <tr> <td colspan="2"><img src="https://pandorafms.com/wp-content/uploads/2022/03/System-email-Good-news.png" style="display: block; margin-left: auto; margin-right: auto; width: 105px; margin-top: 20px; padding: 0px;" width="105px"></td> </tr> <tr> <td colspan="2"> <p style="font-size: 24px; text-align: center; color: #223549; padding: 0px 10%; line-height: 34px; margin: 20px 0px;">We have good news for you, alert has been <span style="text-transform: uppercase; font-weight: 800;">recovered</span></p> <div><!--[if mso]><v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"><w:anchorlock/><center><![endif]--><a style="background-color: #223549; border: none; color: white; padding: 15px 30px; text-align: center; text-decoration: none; display: block; font-size: 16px; margin-left: auto; margin-right: auto; border-radius: 100px; max-width: 50%; margin-top: 0px; font-weight: bold;" href="_homeurl_">Go to Pandora FMS Console</a><!--[if mso]></center></v:rect><![endif]--></div> </td> </tr> <tr> <td colspan="2"> <div style="background-color: #f6f6f6; border-radius: 10px; padding: 10px 20px; margin-top: 40px;"> <p style="font-size: 18px; line-height: 30px; color: #223549;">Monitoring details</p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Data: <span style="font-weight: 400!important;">_data_ <em>(_modulestatus_)</em></span></p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Agent: <span style="font-weight: 400!important;">_agent_ <em>_address_</em></span></p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Module: <span style="font-weight: 400!important;">_module_ <em>_moduledescription_</em></span></p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Timestamp: <span style="font-weight: 400!important;">_timestamp_</span></p> </div> </td> </tr> <tr> <td style="padding: 20px 0px;" colspan="2"> <p style="font-size: 18px; line-height: 30px; color: #223549;">Report details</p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Generated:&nbsp;<span style="font-weight: 400!important;">_report_generated_date_<em><br></em></span></p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Report date:&nbsp;<span style="font-weight: 400!important;">_report_date_<em><br></em></span></p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Description:&nbsp;<span style="font-weight: 400!important;">_report_description_</span></p> </td> </tr> </tbody> </table> <div style="text-align: center; margin-top: 10px;"> <p style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;"><a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/en/contact/">Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/community/forums/forum/english/">Support</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/manual/en/start">Docs</a></p> </div> </div>','','','','','',''); INSERT INTO `talert_actions` (`id`, `name`, `id_alert_command`, `field1`, `field2`, `field3`, `field4`, `field5`, `field6`, `field7`, `field8`, `field9`, `field10`, `id_group`, `action_threshold`, `field1_recovery`, `field2_recovery`, `field3_recovery`, `field4_recovery`, `field5_recovery`, `field6_recovery`, `field7_recovery`, `field8_recovery`, `field9_recovery`, `field10_recovery`) VALUES (5,'Send Report by e-mail (from template)',15,'','','yourmail@domain.es','','<div style="background-color: #eaf0f6; font-family: Arial, Helvetica, sans-serif; padding: 30px; margin: 0;"><table style="max-width: 560px; background-color: white; border-radius: 10px; padding: 10px 20px 40px;" cellspacing="0" cellpadding="0" align="center"><thead><tr><td style="padding: 0px 0px 5px;"><a href="https://pandorafms.com/en/" target="_blank"><img src="https://pandorafms.com/wp-content/uploads/2022/03/System-email-Pandora-FMS.png" width="206px"></a></td><td style="padding: 0px 0px 5px;"><p style="text-align: right; color: #223549; font-weight: bold; line-height: 36px; padding: 0px; font-size: 12px;">Automatic alert system</p></td></tr><tr><td style="padding: 0px 0px 5px;" colspan="2"><hr style="border: 1px solid #f5f5f5; width: 100%; margin: 0px;"></td></tr></thead><tbody><tr><td colspan="2"><img onerror="this.style.display=&quot;none&quot;;" src="_statusimage_" style="display: block; margin-left: auto; margin-right: auto; width: 105px; margin-top: 20px; padding: 0px;" width="105px"></td></tr><tr><td colspan="2"><p style="font-size: 24px; text-align: center; color: #223549; padding: 0px 10%; line-height: 34px; margin: 20px 0px;">We have bad news for you, something is on <span style="text-transform: uppercase; font-weight: 800;">_modulestatus_</span> status!</p><div><!--[if mso]><v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"><w:anchorlock/><center><![endif]--><a style="background-color: #223549; border: none; color: white; padding: 15px 30px; text-align: center; text-decoration: none; display: block; font-size: 16px; margin-left: auto; margin-right: auto; border-radius: 100px; max-width: 50%; margin-top: 0px; font-weight: bold;" href="_homeurl_">Go to Pandora FMS Console</a><!--[if mso]></center></v:rect><![endif]--></div></td></tr><tr><td colspan="2"><div style="background-color: #f6f6f6; border-radius: 10px; padding: 10px 20px; margin-top: 40px;"><p style="font-size: 18px; line-height: 30px; color: #223549;">Monitoring details</p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Data: <span style="font-weight: 400!important;">_data_ <em>(_modulestatus_)</em></span></p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Agent: <span style="font-weight: 400!important;">_agent_ <em>_address_</em></span></p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Module: <span style="font-weight: 400!important;">_module_ <em>_moduledescription_</em></span></p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Timestamp: <span style="font-weight: 400!important;">_timestamp_</span></p></div></td></tr><tr><td style="padding: 20px 0px;" colspan="2"><p style="font-size: 18px; line-height: 30px; color: #223549;">Report details</p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Generated:&nbsp;<span style="font-weight: 400!important;">_report_generated_date_<em><br></em></span></p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Report date:&nbsp;<span style="font-weight: 400!important;">_report_date_<em><br></em></span></p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Description:&nbsp;<span style="font-weight: 400!important;">_report_description_</span></p></td></tr></tbody></table><div style="text-align: center; margin-top: 10px;"><p style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;"><a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/en/contact/">Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/community/forums/forum/english/">Support</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/manual/en/start">Docs</a></p></div></div>','','','','','',0,0,'','','','','<div style="background-color: #eaf0f6; font-family: Arial, Helvetica, sans-serif; padding: 30px; margin: 0;"> <table style="max-width: 560px; background-color: white; border-radius: 10px; padding: 10px 20px 40px;" cellspacing="0" cellpadding="0" align="center"> <thead> <tr> <td style="padding: 0px 0px 5px;"><a href="https://pandorafms.com/en/" target="_blank"><img src="https://pandorafms.com/wp-content/uploads/2022/03/System-email-Pandora-FMS.png" width="206px"></a></td> <td style="padding: 0px 0px 5px;"> <p style="text-align: right; color: #223549; font-weight: bold; line-height: 36px; padding: 0px; font-size: 12px;">Automatic alert system</p> </td> </tr> <tr> <td style="padding: 0px 0px 5px;" colspan="2"><hr style="border: 1px solid #f5f5f5; width: 100%; margin: 0px;"></td> </tr> </thead> <tbody> <tr> <td colspan="2"><img src="https://pandorafms.com/wp-content/uploads/2022/03/System-email-Good-news.png" style="display: block; margin-left: auto; margin-right: auto; width: 105px; margin-top: 20px; padding: 0px;" width="105px"></td> </tr> <tr> <td colspan="2"> <p style="font-size: 24px; text-align: center; color: #223549; padding: 0px 10%; line-height: 34px; margin: 20px 0px;">We have good news for you, alert has been <span style="text-transform: uppercase; font-weight: 800;">recovered</span></p> <div><!--[if mso]><v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"><w:anchorlock/><center><![endif]--><a style="background-color: #223549; border: none; color: white; padding: 15px 30px; text-align: center; text-decoration: none; display: block; font-size: 16px; margin-left: auto; margin-right: auto; border-radius: 100px; max-width: 50%; margin-top: 0px; font-weight: bold;" href="_homeurl_">Go to Pandora FMS Console</a><!--[if mso]></center></v:rect><![endif]--></div> </td> </tr> <tr> <td colspan="2"> <div style="background-color: #f6f6f6; border-radius: 10px; padding: 10px 20px; margin-top: 40px;"> <p style="font-size: 18px; line-height: 30px; color: #223549;">Monitoring details</p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Data: <span style="font-weight: 400!important;">_data_ <em>(_modulestatus_)</em></span></p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Agent: <span style="font-weight: 400!important;">_agent_ <em>_address_</em></span></p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Module: <span style="font-weight: 400!important;">_module_ <em>_moduledescription_</em></span></p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Timestamp: <span style="font-weight: 400!important;">_timestamp_</span></p> </div> </td> </tr> <tr> <td style="padding: 20px 0px;" colspan="2"> <p style="font-size: 18px; line-height: 30px; color: #223549;">Report details</p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Generated:&nbsp;<span style="font-weight: 400!important;">_report_generated_date_<em><br></em></span></p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Report date:&nbsp;<span style="font-weight: 400!important;">_report_date_<em><br></em></span></p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Description:&nbsp;<span style="font-weight: 400!important;">_report_description_</span></p> </td> </tr> </tbody> </table> <div style="text-align: center; margin-top: 10px;"> <p style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;"><a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/en/contact/">Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/community/forums/forum/english/">Support</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/manual/en/start">Docs</a></p> </div> </div>','','','','',''); - +INSERT INTO `talert_actions` (`id`, `name`, `id_alert_command`) VALUES (6,'Create Pandora ITSM ticket',16); -- alert templates (default) INSERT INTO `talert_templates` (`id`,`name`,`description`,`id_alert_action`,`field1`,`field2`,`field3`,`field4`,`field5`,`field6`,`field7`,`field8`,`field9`,`field10`,`field11`,`field12`,`field13`,`field14`,`field15`,`field16`,`field17`,`field18`,`field19`,`field20`,`type`,`value`,`matches_value`,`max_value`,`min_value`,`time_threshold`,`max_alerts`,`min_alerts`,`time_from`,`time_to`,`monday`,`tuesday`,`wednesday`,`thursday`,`friday`,`saturday`,`sunday`,`recovery_notify`,`field1_recovery`,`field2_recovery`,`field3_recovery`,`field4_recovery`,`field5_recovery`,`field6_recovery`,`field7_recovery`,`field8_recovery`,`field9_recovery`,`field10_recovery`,`field11_recovery`,`field12_recovery`,`field13_recovery`,`field14_recovery`,`field15_recovery`,`field16_recovery`,`field17_recovery`,`field18_recovery`,`field19_recovery`,`field20_recovery`,`priority`,`id_group`,`special_day`,`wizard_level`,`min_alerts_reset_counter`,`disable_event`,`previous_name`, `schedule`) @@ -1202,7 +1204,7 @@ INSERT INTO `tagent_custom_fields` VALUES (1,'Serial Number',0,0,'',0),(2,' INSERT INTO `ttag` VALUES (1,'network','Network equipment','http://artica.es','','',''),(2,'critical','Critical modules','','','',''),(3,'dmz','DMZ Network Zone','','','',''),(4,'performance','Performance anda capacity modules','','','',''),(5,'configuration','','','','',''); -INSERT INTO `tevent_response` VALUES (1,'Ping to host','Ping to the agent host','ping -c 5 _agent_address_','command',0,620,500,0,'',0,90,0),(3,'Create incident from event','Create a incident from the event with the standard incidents system of Pandora FMS','index.php?sec=workspace&sec2=operation/incidents/incident_detail&insert_form&from_event=_event_id_','url',0,0,0,1,'',0,90,0),(5,'Restart agent','Restart the agent with using UDP protocol. To use this response is necessary to have installed Pandora FMS server and console in the same machine.','/usr/share/pandora_server/util/udp_client.pl _agent_address_ 41122 "REFRESH AGENT"','command',0,620,500,0,'',0,90,0),(6,'Ping to module agent host','Ping to the module agent host','ping -c 5 _module_address_','command',0,620,500,0,'',0,90,0); +INSERT INTO `tevent_response` VALUES (1,'Ping to host','Ping to the agent host','ping -c 5 _agent_address_','command',0,620,500,0,'',0,90,0),(3,'Create incident from event','Create a incident from the event with the standard incidents system of Pandora FMS','index.php?sec=workspace&sec2=operation/incidents/incident_detail&insert_form&from_event=_event_id_','url',0,0,0,1,'',0,90,0),(5,'Restart agent','Restart the agent with using UDP protocol. To use this response is necessary to have installed Pandora FMS server and console in the same machine.','/usr/share/pandora_server/util/udp_client.pl _agent_address_ 41122 "REFRESH AGENT"','command',0,620,500,0,'',0,90,0),(6,'Ping to module agent host','Ping to the module agent host','ping -c 5 _module_address_','command',0,620,500,0,'',0,90,0),(7,'Create ticket in Pandora ITSM from event','Create a ticket in Pandora ITSM from an event','index.php?sec=manageTickets&sec2=operation/ITSM/itsm&operation=edit&from_event=_event_id_','url',0,0,0,1,'',0,90,1); INSERT INTO `tupdate_settings` VALUES ('current_update', '412'), ('customer_key', 'PANDORA-FREE'), ('updating_binary_path', 'Path where the updated binary files will be stored'), ('updating_code_path', 'Path where the updated code is stored'), ('dbname', ''), ('dbhost', ''), ('dbpass', ''), ('dbuser', ''), ('dbport', ''), ('proxy', ''), ('proxy_port', ''), ('proxy_user', ''), ('proxy_pass', ''); diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 10ec468d47..9543750842 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -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. diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 254b304fe7..b712fabe59 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -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; }