diff --git a/pandora_console/extras/mr/45.sql b/pandora_console/extras/mr/45.sql
new file mode 100644
index 0000000000..c02109bd16
--- /dev/null
+++ b/pandora_console/extras/mr/45.sql
@@ -0,0 +1,5 @@
+START TRANSACTION;
+
+ALTER TABLE `talert_actions` ADD COLUMN `create_wu_integria` TINYINT(1) default NULL;
+
+COMMIT;
diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql
index bae705f725..4a279450f3 100644
--- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql
+++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql
@@ -1378,6 +1378,8 @@ ALTER TABLE `talert_actions` MODIFY COLUMN `field11` text NOT NULL,
MODIFY COLUMN `field14` text NOT NULL,
MODIFY COLUMN `field15` text NOT NULL;
+ALTER TABLE `talert_actions` ADD COLUMN `create_wu_integria` TINYINT(1) default NULL;
+
-- ---------------------------------------------------------------------
-- Table `talert_commands`
-- ---------------------------------------------------------------------
diff --git a/pandora_console/godmode/agentes/agent_incidents.php b/pandora_console/godmode/agentes/agent_incidents.php
index c144cdfdcd..c669af992e 100644
--- a/pandora_console/godmode/agentes/agent_incidents.php
+++ b/pandora_console/godmode/agentes/agent_incidents.php
@@ -18,6 +18,11 @@ require_once 'include/functions_incidents.php';
check_login();
+if (!$config['integria_enabled']) {
+ ui_print_error_message(__('In order to access ticket management system, integration with Integria IMS must be enabled and properly configured'));
+ return;
+}
+
$group = $id_grupo;
if (! check_acl($config['id_user'], $group, 'AW', $id_agente)) {
@@ -38,24 +43,21 @@ $groups = users_get_groups($config['id_user'], 'IR');
$filter = ' AND id_agent = '.$id_agent;
$url = 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=incident&id_agente='.$id_agent;
-// Select incidencts where the user has access to ($groups from
-// get_user_groups), array_keys for the id, implode to pass to SQL
-switch ($config['dbtype']) {
- case 'mysql':
- $sql = 'SELECT * FROM tincidencia WHERE
- id_grupo IN ('.implode(',', array_keys($groups)).')'.$filter.'
- ORDER BY actualizacion DESC LIMIT '.$offset.','.$config['block_size'];
- break;
+$params = [
+ '',
+ '-10',
+ '1',
+ '-1',
+ '0',
+ '',
+ '',
+ '',
+ agents_get_name($id_agent),
+];
- case 'oracle':
- $sql = 'SELECT * FROM tincidencia WHERE
- id_grupo IN ('.implode(',', array_keys($groups)).')'.$filter.'
- AND rownum <= '.$offset.','.$config['block_size'].'
- ORDER BY actualizacion DESC';
- break;
-}
+$result = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incidents', $params, false, 'json', ',');
-$result = db_get_all_rows_sql($sql);
+$result = json_decode($result, true);
$count_sql = 'SELECT count(*) FROM tincidencia WHERE
id_grupo IN ('.implode(',', array_keys($groups)).')'.$filter.'
@@ -91,8 +93,6 @@ $table->head[2] = __('Incident');
$table->head[3] = __('Priority');
$table->head[4] = __('Group');
$table->head[5] = __('Updated');
-$table->head[6] = __('Source');
-$table->head[7] = __('Owner');
$table->size[0] = 43;
$table->size[7] = 50;
@@ -115,7 +115,7 @@ foreach ($result as $row) {
$data = [];
- $data[0] = ''.$row['id_incidencia'].'';
+ $data[0] = ''.$row['id_incidencia'].'';
$attach = incidents_get_attach($row['id_incidencia']);
if (!empty($attach)) {
@@ -123,12 +123,10 @@ foreach ($result as $row) {
}
$data[1] = incidents_print_status_img($row['estado'], true);
- $data[2] = ''.substr(io_safe_output($row['titulo']), 0, 45).'';
+ $data[2] = ''.substr(io_safe_output($row['titulo']), 0, 45).'';
$data[3] = incidents_print_priority_img($row['prioridad'], true);
- $data[4] = ui_print_group_icon($row['id_grupo'], true);
+ $data[4] = $row['id_grupo'];
$data[5] = ui_print_timestamp($row['actualizacion'], true);
- $data[6] = $row['origen'];
- $data[7] = ui_print_username($row['id_usuario'], true);
array_push($table->data, $data);
}
diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php
index 72fc0ef125..1f765c7d86 100644
--- a/pandora_console/godmode/agentes/configurar_agente.php
+++ b/pandora_console/godmode/agentes/configurar_agente.php
@@ -486,20 +486,6 @@ if ($id_agente) {
$agent_wizard['active'] = false;
}
-
- $total_incidents = agents_get_count_incidents($id_agente);
-
- // Incident tab.
- if ($total_incidents > 0) {
- $incidenttab['text'] = ''.html_print_image('images/book_edit.png', true, ['title' => __('Incidents')]).'';
-
- if ($tab == 'incident') {
- $incidenttab['active'] = true;
- } else {
- $incidenttab['active'] = false;
- }
- }
-
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) {
if ($has_remote_conf) {
$agent_name = agents_get_name($id_agente);
@@ -550,11 +536,6 @@ if ($id_agente) {
];
}
-
- // Only if the agent has incidents associated show incidents tab.
- if ($total_incidents) {
- $onheader['incident'] = $incidenttab;
- }
} else {
$onheader = [
'view' => $viewtab,
diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php
index 53272f6273..2175c8f7b2 100644
--- a/pandora_console/godmode/alerts/alert_commands.php
+++ b/pandora_console/godmode/alerts/alert_commands.php
@@ -56,7 +56,7 @@ if (is_ajax()) {
$command = alerts_get_alert_command($id);
- // If is setted a description, we change the carriage return by
tags
+ // If a description is set, change the carriage return by
tags.
if (isset($command['description'])) {
$command['description'] = str_replace(
[
@@ -265,6 +265,76 @@ if (is_ajax()) {
$editor_type_chkbx .= '';
$rfield = $editor_type_chkbx;
// Select type.
+ } else if (preg_match('/^_integria_type_custom_field_$/i', $field_value)) {
+ $ffield = '';
+ $rfield = '';
+
+ $ffield .= '
'.html_print_switch(
+ [
+ 'name' => 'field'.$i.'_value[]',
+ 'value' => '',
+ ]
+ ).'
';
+ $rfield .= ''.html_print_switch(
+ [
+ 'name' => 'field'.$i.'_recovery_value[]',
+ 'value' => '',
+ ]
+ ).'
';
+
+ $ffield .= html_print_select(
+ '',
+ 'field'.$i.'_value[]',
+ '',
+ '',
+ __('None'),
+ '',
+ true,
+ false,
+ false,
+ 'fields',
+ $is_central_policies_on_node
+ );
+
+ $rfield .= html_print_select(
+ '',
+ 'field'.$i.'_recovery_value[]',
+ '',
+ '',
+ __('None'),
+ '',
+ true,
+ false,
+ false,
+ 'fields',
+ $is_central_policies_on_node
+ );
+
+ $ffield .= html_print_input_text('field'.$i.'_value[]', '', '', 10, 10, true, false, false, '', 'datepicker');
+ $rfield .= html_print_input_text('field'.$i.'_recovery_value[]', '', '', 10, 10, true, false, false, '', 'datepicker');
+
+ $ffield .= html_print_textarea(
+ 'field'.$i.'_value[]',
+ 1,
+ 1,
+ '',
+ 'style="min-height:40px; '.$style.'" class="fields"',
+ true,
+ '',
+ $is_central_policies_on_node
+ );
+
+
+ $rfield .= html_print_textarea(
+ 'field'.$i.'_recovery_value[]',
+ 1,
+ 1,
+ '',
+ 'style="min-height:40px; '.$style.'" class="fields_recovery',
+ true,
+ '',
+ $is_central_policies_on_node
+ );
} else {
$fields_value_select = [];
$fv = explode(';', $field_value);
diff --git a/pandora_console/godmode/alerts/alert_list.builder.php b/pandora_console/godmode/alerts/alert_list.builder.php
index 4fa89805ce..e1c07778c3 100644
--- a/pandora_console/godmode/alerts/alert_list.builder.php
+++ b/pandora_console/godmode/alerts/alert_list.builder.php
@@ -97,7 +97,14 @@ $table->data[1][0] = __('Actions');
$groups_user = users_get_groups($config['id_user']);
if (!empty($groups_user)) {
$groups = implode(',', array_keys($groups_user));
- $sql = "SELECT id, name FROM talert_actions WHERE id_group IN ($groups)";
+
+ if ($config['integria_enabled'] == 0) {
+ $integria_command = 'Integria IMS 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)";
+ }
+
$actions = db_get_all_rows_sql($sql);
}
diff --git a/pandora_console/godmode/alerts/configure_alert_action.php b/pandora_console/godmode/alerts/configure_alert_action.php
index 67a2837955..f3dfc35250 100644
--- a/pandora_console/godmode/alerts/configure_alert_action.php
+++ b/pandora_console/godmode/alerts/configure_alert_action.php
@@ -16,6 +16,7 @@ global $config;
require_once $config['homedir'].'/include/functions_alerts.php';
require_once $config['homedir'].'/include/functions_users.php';
+require_once $config['homedir'].'/include/functions_integriaims.php';
enterprise_include_once('meta/include/functions_alerts_meta.php');
check_login();
@@ -36,6 +37,19 @@ $id = (int) get_parameter('id');
$al_action = alerts_get_alert_action($id);
$pure = get_parameter('pure', 0);
+if (is_ajax()) {
+ $get_integria_ticket_custom_types = (bool) get_parameter('get_integria_ticket_custom_types');
+
+ if ($get_integria_ticket_custom_types) {
+ $ticket_type_id = get_parameter('ticket_type_id');
+
+ $api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_fields', $ticket_type_id, false, 'json');
+
+ echo $api_call;
+ return;
+ }
+}
+
if (defined('METACONSOLE')) {
$sec = 'advanced';
} else {
@@ -101,6 +115,7 @@ if ($id) {
$group = $action['id_group'];
$action_threshold = $action['action_threshold'];
+ $create_wu_integria = $action['create_wu_integria'];
}
// Hidden div with help hint to fill with javascript.
@@ -185,10 +200,18 @@ $table->data[1][1] = ''.html_print_select_groups(
).'
';
$table->colspan[1][1] = 2;
+$create_ticket_command_id = db_get_value('id', 'talert_commands', 'name', io_safe_input('Integria IMS Ticket'));
+
+$sql_exclude_command_id = '';
+
+if ($config['integria_enabled'] == 0 && $create_ticket_command_id !== false) {
+ $sql_exclude_command_id = ' AND id <> '.$create_ticket_command_id;
+}
+
$table->data[2][0] = __('Command');
$commands_sql = db_get_all_rows_filter(
'talert_commands',
- ['id_group' => array_keys(users_get_groups(false, 'LW'))],
+ 'id_group IN ('.implode(',', array_keys(users_get_groups(false, 'LW'))).')'.$sql_exclude_command_id,
[
'id',
'name',
@@ -266,6 +289,12 @@ $table->data[5][2] = html_print_textarea(
true
);
+$table->data[6][0] = __('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.'),
+ true
+);
+$table->data[6][1] = html_print_checkbox_switch_extended('create_wu_integria', 1, $create_wu_integria, false, '', '', true);
+
for ($i = 1; $i <= $config['max_macro_fields']; $i++) {
$table->data['field'.$i][0] = html_print_image(
'images/spinner.gif',
@@ -356,6 +385,182 @@ $(document).ready (function () {
render_command_description(command_description);
}
+ function ajax_get_integria_custom_fields(ticket_type_id, values, recovery_values) {
+ var values = values || [];
+ var recovery_values = recovery_values || [];
+
+ if (ticket_type_id === null || ticket_type_id === '' || (Array.isArray(values) && values.length === 0 && Array.isArray(recovery_values) && recovery_values.length === 0)) {
+ $('[name=field8_value\\[\\]').val('');
+ $('[name=field9_value\\[\\]').val('');
+ $('[name=field10_value\\[\\]').val('');
+ $('[name=field8_recovery_value\\[\\]').val('');
+ $('[name=field9_recovery_value\\[\\]').val('');
+ $('[name=field10_recovery_value\\[\\]').val('');
+ }
+
+ // On ticket type change, hide all table rows and inputs corresponding to custom fields, regardless of what its type is.
+ $('[name=field8_value\\[\\]').hide();
+ $('[name=field9_value\\[\\]').hide();
+ $('[name=field10_value\\[\\]').hide();
+ $('[name=field8_recovery_value\\[\\]').hide();
+ $('[name=field9_recovery_value\\[\\]').hide();
+ $('[name=field10_recovery_value\\[\\]').hide();
+ $('#table_macros-field8').hide();
+ $('#table_macros-field9').hide();
+ $('#table_macros-field10').hide();
+ $('[name=field8_value_container').hide();
+ $('[name=field9_value_container').hide();
+ $('[name=field10_value_container').hide();
+ $('[name=field8_recovery_value_container').hide();
+ $('[name=field9_recovery_value_container').hide();
+ $('[name=field10_recovery_value_container').hide();
+
+ jQuery.post(
+ "ajax.php",
+ {
+ page: "godmode/alerts/configure_alert_action",
+ get_integria_ticket_custom_types: 1,
+ ticket_type_id: ticket_type_id
+ },
+ function(data) {
+ var max_macro_fields = ;
+
+ data.forEach(function(custom_field, key) {
+ var custom_field_key = key+8; // Custom fields start from field 8.
+
+ if (custom_field_key > max_macro_fields) {
+ return;
+ }
+
+ // Display field row for current input.
+ var custom_field_row = $('#table_macros-field'+custom_field_key);
+ custom_field_row.show();
+
+ // Replace label text of field row for current input.
+ var label_html = $('#table_macros-field'+custom_field_key+' td').first().html();
+ var label_name = label_html.split('
')[0];
+ var new_html_content = custom_field_row.html().replace(label_name, custom_field.label);
+ custom_field_row.html(new_html_content);
+
+ switch (custom_field.type) {
+ case 'checkbox':
+ var checkbox_selector = $('input:not(.datepicker)[name=field'+custom_field_key+'_value\\[\\]]');
+ var checkbox_recovery_selector = $('input:not(.datepicker)[name=field'+custom_field_key+'_recovery_value\\[\\]]');
+
+ checkbox_selector.on('change', function() {
+ if (checkbox_selector.prop('checked')) {
+ checkbox_selector.attr('value', "1");
+ } else {
+ checkbox_selector.attr('value', "0");
+ }
+ });
+
+ checkbox_recovery_selector.on('change', function() {
+ if (checkbox_recovery_selector.prop('checked')) {
+ checkbox_recovery_selector.attr('value', "1");
+ } else {
+ checkbox_recovery_selector.attr('value', "0");
+ }
+ });
+
+ if (typeof values[key] !== "undefined") {
+ if (values[key] == 1) {
+ checkbox_selector.prop('checked', true);
+ checkbox_selector.attr('value', "1");
+ } else {
+ checkbox_selector.prop('checked', false);
+ checkbox_selector.attr('value', "0");
+ }
+ }
+
+ if (typeof recovery_values[key] !== "undefined") {
+ if (recovery_values[key] == 1) {
+ checkbox_recovery_selector.prop('checked', true);
+ checkbox_recovery_selector.attr('value', "1");
+ } else {
+ checkbox_recovery_selector.prop('checked', false);
+ checkbox_recovery_selector.attr('value', "0");
+ }
+ }
+
+ $('[name=field'+custom_field_key+'_value_container]').show();
+ $('[name=field'+custom_field_key+'_recovery_value_container]').show();
+ $('input:not(.datepicker)[name=field'+custom_field_key+'_value\\[\\]]').show();
+ $('input:not(.datepicker)[name=field'+custom_field_key+'_recovery_value\\[\\]]').show();
+ break;
+ case 'combo':
+ var combo_input = $('select[name=field'+custom_field_key+'_value\\[\\]]');
+ var combo_input_recovery = $('select[name=field'+custom_field_key+'_recovery_value\\[\\]]');
+
+ combo_input.find('option').remove();
+ combo_input_recovery.find('option').remove();
+
+ var combo_values_array = custom_field.combo_value.split(',');
+
+ combo_values_array.forEach(function(value) {
+ combo_input.append($('