Merge branch 'ent-6898-Integracion-integria-en-pandora' into 'develop'
Ent 6898 integracion integria en pandora See merge request artica/pandorafms!3898
This commit is contained in:
commit
5bae2be954
|
@ -1,5 +1,8 @@
|
|||
START TRANSACTION;
|
||||
|
||||
|
||||
ALTER TABLE `talert_actions` ADD COLUMN `create_wu_integria` TINYINT(1) default NULL;
|
||||
|
||||
ALTER TABLE `treport_content` ADD COLUMN `summary` tinyint(1) DEFAULT 0;
|
||||
ALTER TABLE `treport_content_template` ADD COLUMN `summary` tinyint(1) DEFAULT 0;
|
||||
|
||||
|
|
|
@ -1380,6 +1380,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`
|
||||
-- ---------------------------------------------------------------------
|
||||
|
|
|
@ -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,30 +43,25 @@ $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.'
|
||||
ORDER BY actualizacion DESC';
|
||||
$count = count($result);
|
||||
|
||||
$count = db_get_value_sql($count_sql);
|
||||
$result = array_slice($result, $offset, $config['block_size']);
|
||||
|
||||
if (empty($result)) {
|
||||
$result = [];
|
||||
|
@ -91,8 +91,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 +113,7 @@ foreach ($result as $row) {
|
|||
|
||||
$data = [];
|
||||
|
||||
$data[0] = '<a href="index.php?sec=incidencias&sec2=operation/incidents/incident_detail&id='.$row['id_incidencia'].'">'.$row['id_incidencia'].'</a>';
|
||||
$data[0] = '<a href="index.php?sec=incident&sec2=operation/incidents/dashboard_detail_integriaims_incident&incident_id='.$row['id_incidencia'].'">'.$row['id_incidencia'].'</a>';
|
||||
$attach = incidents_get_attach($row['id_incidencia']);
|
||||
|
||||
if (!empty($attach)) {
|
||||
|
@ -123,12 +121,10 @@ foreach ($result as $row) {
|
|||
}
|
||||
|
||||
$data[1] = incidents_print_status_img($row['estado'], true);
|
||||
$data[2] = '<a href="index.php?sec=incidencias&sec2=operation/incidents/incident_detail&id='.$row['id_incidencia'].'">'.substr(io_safe_output($row['titulo']), 0, 45).'</a>';
|
||||
$data[2] = '<a href="index.php?sec=incident&sec2=operation/incidents/dashboard_detail_integriaims_incident&incident_id='.$row['id_incidencia'].'">'.substr(io_safe_output($row['titulo']), 0, 45).'</a>';
|
||||
$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);
|
||||
}
|
||||
|
|
|
@ -563,27 +563,6 @@ if ($id_agente) {
|
|||
$agent_wizard['active'] = false;
|
||||
}
|
||||
|
||||
|
||||
$total_incidents = agents_get_count_incidents($id_agente);
|
||||
|
||||
// Incident tab.
|
||||
if ($total_incidents > 0) {
|
||||
$incidenttab['text'] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=incident&id_agente='.$id_agente.'">'.html_print_image(
|
||||
'images/book_edit.png',
|
||||
true,
|
||||
[
|
||||
'title' => __('Incidents'),
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
).'</a>';
|
||||
|
||||
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);
|
||||
|
@ -637,11 +616,6 @@ if ($id_agente) {
|
|||
|
||||
];
|
||||
}
|
||||
|
||||
// Only if the agent has incidents associated show incidents tab.
|
||||
if ($total_incidents) {
|
||||
$onheader['incident'] = $incidenttab;
|
||||
}
|
||||
} else {
|
||||
$onheader = [
|
||||
'view' => $viewtab,
|
||||
|
|
|
@ -62,7 +62,7 @@ if (is_ajax()) {
|
|||
|
||||
$command = alerts_get_alert_command($id);
|
||||
|
||||
// If is setted a description, we change the carriage return by <br> tags
|
||||
// If a description is set, change the carriage return by <br> tags.
|
||||
if (isset($command['description'])) {
|
||||
$command['description'] = str_replace(
|
||||
[
|
||||
|
@ -277,6 +277,76 @@ if (is_ajax()) {
|
|||
$editor_type_chkbx .= '</small></b></div>';
|
||||
$rfield = $editor_type_chkbx;
|
||||
// Select type.
|
||||
} else if (preg_match('/^_integria_type_custom_field_$/i', $field_value)) {
|
||||
$ffield = '';
|
||||
$rfield = '';
|
||||
|
||||
$ffield .= '<div name="field'.$i.'_value_container">'.html_print_switch(
|
||||
[
|
||||
'name' => 'field'.$i.'_value[]',
|
||||
'value' => '',
|
||||
]
|
||||
).'</div>';
|
||||
$rfield .= '<div name="field'.$i.'_recovery_value_container">'.html_print_switch(
|
||||
[
|
||||
'name' => 'field'.$i.'_recovery_value[]',
|
||||
'value' => '',
|
||||
]
|
||||
).'</div>';
|
||||
|
||||
$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);
|
||||
|
@ -316,7 +386,7 @@ if (is_ajax()) {
|
|||
'field'.$i.'_recovery_value',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
__('None'),
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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'];
|
||||
|
||||
if (!check_acl_restricted_all($config['id_user'], $action['id_group'], 'LM')) {
|
||||
db_pandora_audit(
|
||||
|
@ -200,10 +215,18 @@ $table->data[1][1] = '<div class="w250px inline">'.html_print_select_groups(
|
|||
).'</div>';
|
||||
$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',
|
||||
|
@ -281,6 +304,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',
|
||||
|
@ -371,6 +400,173 @@ $(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 || [];
|
||||
var max_macro_fields = <?php echo $config['max_macro_fields']; ?>;
|
||||
|
||||
if (ticket_type_id === null || ticket_type_id === '' || (Array.isArray(values) && values.length === 0 && Array.isArray(recovery_values) && recovery_values.length === 0)) {
|
||||
for (var i=8; i <= max_macro_fields; i++) {
|
||||
$('[name=field'+i+'_value\\[\\]').val('');
|
||||
$('[name=field'+i+'_recovery_value\\[\\]').val('');
|
||||
}
|
||||
}
|
||||
|
||||
// On ticket type change, hide all table rows and inputs corresponding to custom fields, regardless of what its type is.
|
||||
for (var i=8; i <= max_macro_fields; i++) {
|
||||
$('[name=field'+i+'_value\\[\\]').hide();
|
||||
$('[name=field'+i+'_recovery_value\\[\\]').hide();
|
||||
$('#table_macros-field'+i).hide();
|
||||
$('[name=field'+i+'_value_container').hide();
|
||||
$('[name=field'+i+'_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 = <?php echo $config['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('<br>')[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($('<option>', {
|
||||
value: value,
|
||||
text: value
|
||||
}));
|
||||
|
||||
combo_input_recovery.append($('<option>', {
|
||||
value: value,
|
||||
text: value
|
||||
}));
|
||||
});
|
||||
|
||||
if (typeof values[key] !== "undefined") {
|
||||
combo_input.val(values[key]);
|
||||
}
|
||||
|
||||
if (typeof recovery_values[key] !== "undefined") {
|
||||
combo_input_recovery.val(recovery_values[key]);
|
||||
}
|
||||
|
||||
combo_input.show();
|
||||
combo_input_recovery.show();
|
||||
break;
|
||||
case 'date':
|
||||
$('input.datepicker[type="text"][name=field'+custom_field_key+'_value\\[\\]]').removeClass("hasDatepicker");
|
||||
$('input.datepicker[type="text"][name=field'+custom_field_key+'_recovery_value\\[\\]]').removeClass("hasDatepicker");
|
||||
$('input.datepicker[type="text"][name=field'+custom_field_key+'_value\\[\\]]').datepicker("destroy");
|
||||
$('input.datepicker[type="text"][name=field'+custom_field_key+'_recovery_value\\[\\]]').datepicker("destroy");
|
||||
|
||||
$('input.datepicker[type="text"][name=field'+custom_field_key+'_value\\[\\]]').show();
|
||||
$('input.datepicker[type="text"][name=field'+custom_field_key+'_recovery_value\\[\\]]').show();
|
||||
$('input.datepicker[type="text"][name=field'+custom_field_key+'_value\\[\\]]').datepicker({dateFormat: "<?php echo DATE_FORMAT_JS; ?>"});
|
||||
$('input.datepicker[type="text"][name=field'+custom_field_key+'_recovery_value\\[\\]]').datepicker({dateFormat: "<?php echo DATE_FORMAT_JS; ?>"});
|
||||
$.datepicker.setDefaults($.datepicker.regional[ "<?php echo get_user_language(); ?>"]);
|
||||
|
||||
if (typeof values[key] !== "undefined") {
|
||||
$('input.datepicker[type="text"][name=field'+custom_field_key+'_value\\[\\]]').val(values[key]);
|
||||
}
|
||||
|
||||
if (typeof recovery_values[key] !== "undefined") {
|
||||
$('input.datepicker[type="text"][name=field'+custom_field_key+'_recovery_value\\[\\]]').val(recovery_values[key]);
|
||||
}
|
||||
break;
|
||||
case 'text':
|
||||
case 'textarea':
|
||||
case 'numeric':
|
||||
if (typeof values[key] !== "undefined") {
|
||||
$('textarea[name=field'+custom_field_key+'_value\\[\\]]').val(values[key]);
|
||||
}
|
||||
|
||||
if (typeof recovery_values[key] !== "undefined") {
|
||||
$('textarea[name=field'+custom_field_key+'_recovery_value\\[\\]]').val(recovery_values[key]);
|
||||
}
|
||||
|
||||
$('textarea[name=field'+custom_field_key+'_value\\[\\]]').show();
|
||||
$('textarea[name=field'+custom_field_key+'_recovery_value\\[\\]]').show();
|
||||
break;
|
||||
}
|
||||
});
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
$("#id_command").change (function () {
|
||||
values = Array ();
|
||||
values.push({
|
||||
|
@ -406,6 +602,9 @@ $(document).ready (function () {
|
|||
$("#group").val(0);
|
||||
}
|
||||
|
||||
var integria_custom_fields_values = [];
|
||||
var integria_custom_fields_rvalues = [];
|
||||
|
||||
for (i = 1; i <= max_fields; i++) {
|
||||
var old_value = '';
|
||||
var old_recovery_value = '';
|
||||
|
@ -474,6 +673,12 @@ $(document).ready (function () {
|
|||
.val());
|
||||
}
|
||||
}
|
||||
|
||||
if ($("#id_command option:selected").text() === "Integria IMS Ticket" && i > 7) {
|
||||
integria_custom_fields_values.push(old_value);
|
||||
integria_custom_fields_rvalues.push(old_recovery_value);
|
||||
}
|
||||
|
||||
// Add help hint only in first field
|
||||
if (i == 1) {
|
||||
var td_content = $table_macros_field.find('td').eq(0);
|
||||
|
@ -486,7 +691,30 @@ $(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.
|
||||
// Check command by name since it is unvariable in any case, unlike its ID.
|
||||
if ($("#id_command option:selected").text() === "Integria IMS 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.
|
||||
for (var i=8; i <= max_macro_fields; i++) {
|
||||
$('[name=field'+i+'_value\\[\\]').hide();
|
||||
$('[name=field'+i+'_recovery_value\\[\\]').hide();
|
||||
$('#table_macros-field'+i).hide();
|
||||
$('[name=field'+i+'_value_container').hide();
|
||||
$('[name=field'+i+'_recovery_value_container').hide();
|
||||
}
|
||||
|
||||
if ($('#field5_value').val() !== '') {
|
||||
ajax_get_integria_custom_fields($('#field5_value').val(), integria_custom_fields_values, integria_custom_fields_rvalues);
|
||||
}
|
||||
|
||||
$('#field5_value').on('change', function() {
|
||||
ajax_get_integria_custom_fields($(this).val());
|
||||
});
|
||||
}
|
||||
|
||||
var added_config = {
|
||||
"selector": "textarea.tiny-mce-editor",
|
||||
"plugins": "preview, print, table, searchreplace, nonbreaking, xhtmlxtras, noneditable",
|
||||
|
|
|
@ -31,6 +31,12 @@ if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user
|
|||
require_once $config['homedir'].'/include/functions_integriaims.php';
|
||||
|
||||
if (is_ajax()) {
|
||||
$operation = (string) get_parameter('operation', '');
|
||||
|
||||
if ($operation === 'check_api_access') {
|
||||
} else if ($operation === 'sync_inventory') {
|
||||
}
|
||||
|
||||
$integria_user = get_parameter('integria_user', '');
|
||||
$integria_pass = get_parameter('integria_pass', '');
|
||||
$integria_api_hostname = get_parameter('api_hostname', '');
|
||||
|
@ -80,6 +86,16 @@ if (get_parameter('update_config', 0) == 1) {
|
|||
);
|
||||
}
|
||||
|
||||
$ticket_types = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_types', '', false, 'json');
|
||||
|
||||
$types_string = '';
|
||||
|
||||
if ($ticket_types !== '') {
|
||||
foreach (json_decode($ticket_types, true) as $key => $value) {
|
||||
$types_string .= $value['id'].','.$value['name'].';';
|
||||
}
|
||||
}
|
||||
|
||||
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(
|
||||
|
@ -89,7 +105,8 @@ if (get_parameter('update_config', 0) == 1) {
|
|||
'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').'"]',
|
||||
'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').'","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_"]',
|
||||
'fields_values' => '["", "", "","","'.$types_string.'","","","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_"]',
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -115,41 +132,80 @@ if (get_parameter('update_config', 0) == 1) {
|
|||
|
||||
alerts_create_alert_action(io_safe_input('Create Integria IMS ticket'), $id_command_inserted, $action_values);
|
||||
} else {
|
||||
// Update 'Create Integria IMS Ticket' action when setup data is updated, user enables IntegriaIMS integration and command does exist in database.
|
||||
db_process_sql_update(
|
||||
'talert_actions',
|
||||
[
|
||||
'field1' => io_safe_input($config['incident_title']),
|
||||
'field1_recovery' => io_safe_input($config['incident_title']),
|
||||
'field2' => io_safe_input($config['default_group']),
|
||||
'field2_recovery' => io_safe_input($config['default_group']),
|
||||
'field3' => io_safe_input($config['default_criticity']),
|
||||
'field3_recovery' => io_safe_input($config['default_criticity']),
|
||||
'field4' => io_safe_input($config['default_owner']),
|
||||
'field4_recovery' => io_safe_input($config['default_owner']),
|
||||
'field5' => io_safe_input($config['incident_type']),
|
||||
'field5_recovery' => io_safe_input($config['incident_type']),
|
||||
'field6' => io_safe_input($config['incident_status']),
|
||||
'field6_recovery' => io_safe_input($config['incident_status']),
|
||||
'field7' => io_safe_input($config['incident_content']),
|
||||
'field7_recovery' => io_safe_input($config['incident_content']),
|
||||
],
|
||||
['name' => io_safe_input('Create Integria IMS ticket')]
|
||||
// Update 'Integria IMS Ticket' command with ticket types retrieved from Integria IMS.
|
||||
$sql_update_command_values = sprintf(
|
||||
'
|
||||
UPDATE talert_commands
|
||||
SET fields_values = \'["","","","","%s","","","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_"]\'
|
||||
WHERE name="%s"',
|
||||
$types_string,
|
||||
io_safe_input('Integria IMS Ticket')
|
||||
);
|
||||
|
||||
db_process_sql($sql_update_command_values);
|
||||
|
||||
// Update those actions that make use of 'Integria IMS Ticket' command when setup default fields are updated. Empty fields in actions will be filled in with default values.
|
||||
$update_action_values = [
|
||||
$config['incident_title'],
|
||||
$config['default_group'],
|
||||
$config['default_criticity'],
|
||||
$config['default_owner'],
|
||||
$config['incident_type'],
|
||||
$config['incident_status'],
|
||||
$config['incident_content'],
|
||||
];
|
||||
|
||||
foreach ($update_action_values as $key => $value) {
|
||||
$field_key = ($key + 1);
|
||||
|
||||
$sql_update_action_field = sprintf(
|
||||
'
|
||||
UPDATE talert_actions taa
|
||||
INNER JOIN talert_commands tac
|
||||
ON taa.id_alert_command=tac.id
|
||||
SET field%s= "%s"
|
||||
WHERE tac.name="Integria IMS Ticket"
|
||||
AND (
|
||||
taa.field%s IS NULL OR taa.field%s=""
|
||||
)',
|
||||
$field_key,
|
||||
$value,
|
||||
$field_key,
|
||||
$field_key,
|
||||
$field_key
|
||||
);
|
||||
|
||||
db_process_sql($sql_update_action_field);
|
||||
}
|
||||
|
||||
foreach ($update_action_values as $key => $value) {
|
||||
$field_key = ($key + 1);
|
||||
|
||||
$sql_update_action_recovery_field = sprintf(
|
||||
'
|
||||
UPDATE talert_actions taa
|
||||
INNER JOIN talert_commands tac
|
||||
ON taa.id_alert_command=tac.id
|
||||
SET field%s_recovery = "%s"
|
||||
WHERE tac.name="Integria IMS Ticket"
|
||||
AND (
|
||||
taa.field%s_recovery IS NULL OR taa.field%s_recovery=""
|
||||
)',
|
||||
$field_key,
|
||||
$value,
|
||||
$field_key,
|
||||
$field_key,
|
||||
$field_key
|
||||
);
|
||||
|
||||
db_process_sql($sql_update_action_recovery_field);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($event_response_exists != false) {
|
||||
if ($event_response_exists !== false) {
|
||||
// Delete 'Create incident in IntegriaIMS from event' event response if it does exist and IntegriaIMS integration is disabled.
|
||||
db_process_sql_delete('tevent_response', ['name' => io_safe_input('Create ticket in IntegriaIMS from event')]);
|
||||
}
|
||||
|
||||
if ($command_exists != false) {
|
||||
// Delete 'Integria IMS Ticket' command if it does exist and IntegriaIMS integration is disabled.
|
||||
db_process_sql_delete('talert_commands', ['name' => io_safe_input('Integria IMS Ticket')]);
|
||||
|
||||
// Delete 'Create Integria IMS Ticket' action if command exists and IntegriaIMS integration is disabled.
|
||||
db_process_sql_delete('talert_actions', ['name' => io_safe_input('Create Integria IMS ticket')]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -243,6 +299,14 @@ $row['name'] = __('Request timeout');
|
|||
$row['control'] = html_print_input_text('integria_req_timeout', $config['integria_req_timeout'], '', 3, 10, true);
|
||||
$table_remote->data['integria_req_timeout'] = $row;
|
||||
|
||||
$row = [];
|
||||
$row['name'] = __('Inventory');
|
||||
$row['control'] = html_print_button(__('Sync inventory'), 'sync-inventory', false, '', 'class="sub next"', true);
|
||||
$row['control'] .= '<span id="test-integria-spinner-sync" style="display:none;"> '.html_print_image('images/spinner.gif', true).'</span>';
|
||||
$row['control'] .= '<span id="test-integria-success-sync" style="display:none;"> '.html_print_image('images/status_sets/default/severity_normal.png', true).'</span>';
|
||||
$row['control'] .= '<span id="test-integria-failure-sync" style="display:none;"> '.html_print_image('images/status_sets/default/severity_critical.png', true).'</span>';
|
||||
$table_remote->data['integria_sync_inventory'] = $row;
|
||||
|
||||
// Alert settings.
|
||||
$table_alert_settings = new StdClass();
|
||||
$table_alert_settings->data = [];
|
||||
|
@ -661,8 +725,8 @@ echo '</form>';
|
|||
var api_pass = $('input[name=integria_api_pass]').val();
|
||||
|
||||
var data = {
|
||||
page: "godmode/setup/setup_integria",
|
||||
check_api_access: 1,
|
||||
page: 'godmode/setup/setup_integria',
|
||||
operation: 'check_api_access',
|
||||
integria_user: integria_user,
|
||||
integria_pass: integria_pass,
|
||||
api_hostname: api_hostname,
|
||||
|
@ -694,7 +758,100 @@ echo '</form>';
|
|||
hideLoadingImage();
|
||||
});
|
||||
}
|
||||
|
||||
var handleInventorySync = function (event) {
|
||||
|
||||
var badRequestMessage = '<?php echo __('Empty user or password'); ?>';
|
||||
var notFoundMessage = '<?php echo __('User not found'); ?>';
|
||||
var invalidPassMessage = '<?php echo __('Invalid password'); ?>';
|
||||
|
||||
var hideLoadingImage = function () {
|
||||
$('span#test-integria-spinner-sync').hide();
|
||||
}
|
||||
var showLoadingImage = function () {
|
||||
$('span#test-integria-spinner-sync').show();
|
||||
}
|
||||
var hideSuccessImage = function () {
|
||||
$('span#test-integria-success-sync').hide();
|
||||
}
|
||||
var showSuccessImage = function () {
|
||||
$('span#test-integria-success-sync').show();
|
||||
}
|
||||
var hideFailureImage = function () {
|
||||
$('span#test-integria-failure-sync').hide();
|
||||
}
|
||||
var showFailureImage = function () {
|
||||
$('span#test-integria-failure-sync').show();
|
||||
}
|
||||
|
||||
|
||||
hideSuccessImage();
|
||||
hideFailureImage();
|
||||
showLoadingImage();
|
||||
|
||||
var integria_user = $('input[name=integria_user]').val();
|
||||
var integria_pass = $('input[name=integria_pass]').val();
|
||||
var api_hostname = $('input[name=integria_hostname]').val();
|
||||
var api_pass = $('input[name=integria_api_pass]').val();
|
||||
|
||||
if (!api_hostname.match(/^[a-zA-Z]+:\/\//))
|
||||
{
|
||||
api_hostname = 'http://' + api_hostname;
|
||||
}
|
||||
|
||||
var url = api_hostname + '/integria/include/api.php';
|
||||
|
||||
<?php
|
||||
// Retrieve all agents and codify string in the format that will be sent over in Ajax call.
|
||||
$agent_fields = [
|
||||
'nombre',
|
||||
'alias',
|
||||
'id_os',
|
||||
'direccion',
|
||||
'id_agente',
|
||||
'id_grupo',
|
||||
];
|
||||
|
||||
$agents = agents_get_agents(false, $agent_fields);
|
||||
|
||||
$agents_query_string_array = [];
|
||||
|
||||
foreach ($agents as $agent_data) {
|
||||
$agents_query_string_array[] = implode('|;|', $agent_data);
|
||||
}
|
||||
?>
|
||||
|
||||
var agents_query_string_array = <?php echo json_encode($agents_query_string_array); ?>;
|
||||
|
||||
var data = {
|
||||
op: 'sync_pandora_agents_inventory',
|
||||
user: integria_user,
|
||||
user_pass: integria_pass,
|
||||
pass: api_pass,
|
||||
params: agents_query_string_array,
|
||||
token: '|;|'
|
||||
}
|
||||
|
||||
// AJAX call to check API connection.
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
dataType: "json",
|
||||
data: data
|
||||
})
|
||||
.done(function(data, textStatus, xhr) {
|
||||
showSuccessImage();
|
||||
})
|
||||
.fail(function(xhr, textStatus, errorThrown) {
|
||||
showFailureImage();
|
||||
})
|
||||
.always(function(xhr, textStatus) {
|
||||
hideLoadingImage();
|
||||
});
|
||||
}
|
||||
|
||||
$('input#button-test-integria').click(handleTest);
|
||||
$('input#button-sync-inventory').click(handleInventorySync);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2750,6 +2750,7 @@ function alerts_ui_update_or_create_actions($update=true)
|
|||
$id_alert_command = (int) get_parameter('id_command');
|
||||
$group = get_parameter('group');
|
||||
$action_threshold = (int) get_parameter('action_threshold');
|
||||
$create_wu_integria = (int) get_parameter('create_wu_integria');
|
||||
|
||||
// Validate some values
|
||||
if (!$id_alert_command) {
|
||||
|
@ -2772,14 +2773,36 @@ function alerts_ui_update_or_create_actions($update=true)
|
|||
$info_fields = '';
|
||||
$values = [];
|
||||
for ($i = 1; $i <= $config['max_macro_fields']; $i++) {
|
||||
$values['field'.$i] = (string) get_parameter('field'.$i.'_value');
|
||||
$field_value = get_parameter('field'.$i.'_value');
|
||||
|
||||
if (is_array($field_value)) {
|
||||
$field_value = reset(array_filter($field_value));
|
||||
|
||||
if ($field_value === false) {
|
||||
$field_value = '';
|
||||
}
|
||||
}
|
||||
|
||||
$values['field'.$i] = (string) $field_value;
|
||||
$info_fields .= ' Field'.$i.': '.$values['field'.$i];
|
||||
$values['field'.$i.'_recovery'] = (string) get_parameter('field'.$i.'_recovery_value');
|
||||
|
||||
$field_recovery_value = get_parameter('field'.$i.'_recovery_value');
|
||||
|
||||
if (is_array($field_recovery_value)) {
|
||||
$field_recovery_value = reset(array_filter($field_recovery_value));
|
||||
|
||||
if ($field_recovery_value === false) {
|
||||
$field_recovery_value = '';
|
||||
}
|
||||
}
|
||||
|
||||
$values['field'.$i.'_recovery'] = (string) $field_recovery_value;
|
||||
$info_fields .= ' Field'.$i.'Recovery: '.$values['field'.$i.'_recovery'];
|
||||
}
|
||||
|
||||
$values['id_group'] = $group;
|
||||
$values['action_threshold'] = $action_threshold;
|
||||
$values['create_wu_integria'] = $create_wu_integria;
|
||||
if ($update) {
|
||||
$values['name'] = $name;
|
||||
$values['id_alert_command'] = $id_alert_command;
|
||||
|
|
|
@ -1564,7 +1564,13 @@ function config_update_config()
|
|||
$error_update[] = __('Integria password');
|
||||
}
|
||||
|
||||
if (!config_update_value('integria_hostname', (string) get_parameter('integria_hostname', $config['integria_hostname']))) {
|
||||
$integria_hostname = (string) get_parameter('integria_hostname', $config['integria_hostname']);
|
||||
|
||||
if (parse_url($integria_hostname, PHP_URL_SCHEME) === null) {
|
||||
$integria_hostname = 'http://'.$integria_hostname;
|
||||
}
|
||||
|
||||
if (!config_update_value('integria_hostname', $integria_hostname)) {
|
||||
$error_update[] = __('integria API hostname');
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ require_once $config['homedir'].'/include/functions_reporting.php';
|
|||
require_once $config['homedir'].'/include/functions_agents.php';
|
||||
require_once $config['homedir'].'/include/functions_modules.php';
|
||||
require_once $config['homedir'].'/include/functions_users.php';
|
||||
require_once $config['homedir'].'/include/functions_integriaims.php';
|
||||
|
||||
|
||||
/**
|
||||
|
@ -2971,43 +2972,25 @@ function graph_sla_slicebar(
|
|||
function grafico_incidente_prioridad()
|
||||
{
|
||||
global $config;
|
||||
global $graphic_type;
|
||||
|
||||
$data_tmp = [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
];
|
||||
$sql = 'SELECT COUNT(id_incidencia) n_incidents, prioridad
|
||||
FROM tincidencia
|
||||
GROUP BY prioridad
|
||||
ORDER BY 2 DESC';
|
||||
$incidents = db_get_all_rows_sql($sql);
|
||||
$integria_ticket_count_by_priority_json = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_tickets_count', ['prioridad', 30], false, '', '|;|');
|
||||
|
||||
if ($incidents == false) {
|
||||
$incidents = [];
|
||||
$integria_priorities_map_json = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_priorities', '', false, 'json');
|
||||
|
||||
$integria_ticket_count_by_priority = json_decode($integria_ticket_count_by_priority_json, true);
|
||||
$integria_priorities_map = json_decode($integria_priorities_map_json, true);
|
||||
|
||||
$integria_priorities_map_ids = array_column($integria_priorities_map, 'id');
|
||||
$integria_priorities_map_names = array_column($integria_priorities_map, 'name');
|
||||
$integria_priorities_map_indexed_by_id = array_combine($integria_priorities_map_ids, $integria_priorities_map_names);
|
||||
|
||||
$data = [];
|
||||
|
||||
foreach ($integria_ticket_count_by_priority as $item) {
|
||||
$priority_name = $integria_priorities_map_indexed_by_id[$item['prioridad']];
|
||||
$data[__($priority_name)] = $item['n_incidents'];
|
||||
}
|
||||
|
||||
foreach ($incidents as $incident) {
|
||||
if ($incident['prioridad'] < 5) {
|
||||
$data_tmp[$incident['prioridad']] = $incident['n_incidents'];
|
||||
} else {
|
||||
$data_tmp[5] += $incident['n_incidents'];
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
__('Informative') => $data_tmp[0],
|
||||
__('Low') => $data_tmp[1],
|
||||
__('Medium') => $data_tmp[2],
|
||||
__('Serious') => $data_tmp[3],
|
||||
__('Very serious') => $data_tmp[4],
|
||||
__('Maintenance') => $data_tmp[5],
|
||||
];
|
||||
|
||||
if ($config['fixed_graph'] == false) {
|
||||
$water_mark = [
|
||||
'file' => $config['homedir'].'/images/logo_vertical_water.png',
|
||||
|
@ -3034,52 +3017,23 @@ function grafico_incidente_prioridad()
|
|||
function graph_incidents_status()
|
||||
{
|
||||
global $config;
|
||||
global $graphic_type;
|
||||
$data = [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
];
|
||||
|
||||
$integria_ticket_count_by_status_json = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_tickets_count', ['estado', 30], false, '', '|;|');
|
||||
|
||||
$integria_status_map_json = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incidents_status', '', false, 'json');
|
||||
|
||||
$integria_ticket_count_by_status = json_decode($integria_ticket_count_by_status_json, true);
|
||||
$integria_status_map = json_decode($integria_status_map_json, true);
|
||||
|
||||
$integria_status_map_ids = array_column($integria_status_map, 'id');
|
||||
$integria_status_map_names = array_column($integria_status_map, 'name');
|
||||
$integria_status_map_indexed_by_id = array_combine($integria_status_map_ids, $integria_status_map_names);
|
||||
|
||||
$data = [];
|
||||
$data[__('Open incident')] = 0;
|
||||
$data[__('Closed incident')] = 0;
|
||||
$data[__('Outdated')] = 0;
|
||||
$data[__('Invalid')] = 0;
|
||||
|
||||
$incidents = db_get_all_rows_filter(
|
||||
'tincidencia',
|
||||
[
|
||||
'estado' => [
|
||||
0,
|
||||
2,
|
||||
3,
|
||||
13,
|
||||
],
|
||||
],
|
||||
['estado']
|
||||
);
|
||||
if ($incidents === false) {
|
||||
$incidents = [];
|
||||
}
|
||||
|
||||
foreach ($incidents as $incident) {
|
||||
if ($incident['estado'] == 0) {
|
||||
$data[__('Open incident')]++;
|
||||
}
|
||||
|
||||
if ($incident['estado'] == 2) {
|
||||
$data[__('Closed incident')]++;
|
||||
}
|
||||
|
||||
if ($incident['estado'] == 3) {
|
||||
$data[__('Outdated')]++;
|
||||
}
|
||||
|
||||
if ($incident['estado'] == 13) {
|
||||
$data[__('Invalid')]++;
|
||||
}
|
||||
foreach ($integria_ticket_count_by_status as $item) {
|
||||
$status_name = $integria_status_map_indexed_by_id[$item['estado']];
|
||||
$data[__($status_name)] = $item['n_incidents'];
|
||||
}
|
||||
|
||||
if ($config['fixed_graph'] == false) {
|
||||
|
@ -3108,53 +3062,19 @@ function graph_incidents_status()
|
|||
function graphic_incident_group()
|
||||
{
|
||||
global $config;
|
||||
global $graphic_type;
|
||||
|
||||
$integria_ticket_count_by_group_json = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_tickets_count', ['id_grupo', 30], false, '', '|;|');
|
||||
|
||||
$integria_group_map_json = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_groups', '', false, 'json');
|
||||
|
||||
$integria_ticket_count_by_group = json_decode($integria_ticket_count_by_group_json, true);
|
||||
$integria_group_map = json_decode($integria_group_map_json, true);
|
||||
|
||||
$data = [];
|
||||
$max_items = 5;
|
||||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
$sql = sprintf(
|
||||
'SELECT COUNT(id_incidencia) n_incidents, nombre
|
||||
FROM tincidencia,tgrupo
|
||||
WHERE tgrupo.id_grupo = tincidencia.id_grupo
|
||||
GROUP BY tgrupo.id_grupo, nombre ORDER BY 1 DESC LIMIT %d',
|
||||
$max_items
|
||||
);
|
||||
break;
|
||||
|
||||
case 'oracle':
|
||||
$sql = sprintf(
|
||||
'SELECT COUNT(id_incidencia) n_incidents, nombre
|
||||
FROM tincidencia,tgrupo
|
||||
WHERE tgrupo.id_grupo = tincidencia.id_grupo
|
||||
AND rownum <= %d
|
||||
GROUP BY tgrupo.id_grupo, nombre ORDER BY 1 DESC',
|
||||
$max_items
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
$incidents = db_get_all_rows_sql($sql);
|
||||
|
||||
$sql = sprintf(
|
||||
'SELECT COUNT(id_incidencia) n_incidents
|
||||
FROM tincidencia
|
||||
WHERE tincidencia.id_grupo = 0'
|
||||
);
|
||||
|
||||
$incidents_all = db_get_value_sql($sql);
|
||||
|
||||
if ($incidents == false) {
|
||||
$incidents = [];
|
||||
}
|
||||
|
||||
foreach ($incidents as $incident) {
|
||||
$data[$incident['nombre']] = $incident['n_incidents'];
|
||||
}
|
||||
|
||||
if ($incidents_all > 0) {
|
||||
$data[__('All')] = $incidents_all;
|
||||
foreach ($integria_ticket_count_by_group as $item) {
|
||||
$group_name = $integria_group_map[$item['id_grupo']];
|
||||
$data[__($group_name)] = $item['n_incidents'];
|
||||
}
|
||||
|
||||
if ($config['fixed_graph'] == false) {
|
||||
|
@ -3188,47 +3108,15 @@ function graphic_incident_group()
|
|||
function graphic_incident_user()
|
||||
{
|
||||
global $config;
|
||||
global $graphic_type;
|
||||
|
||||
$integria_ticket_count_by_user_json = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_tickets_count', ['id_usuario', 30], false, '', '|;|');
|
||||
|
||||
$integria_ticket_count_by_user = json_decode($integria_ticket_count_by_user_json, true);
|
||||
|
||||
$data = [];
|
||||
$max_items = 5;
|
||||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
$sql = sprintf(
|
||||
'SELECT COUNT(id_incidencia) n_incidents, id_usuario
|
||||
FROM tincidencia
|
||||
GROUP BY id_usuario
|
||||
ORDER BY 1 DESC LIMIT %d',
|
||||
$max_items
|
||||
);
|
||||
break;
|
||||
|
||||
case 'oracle':
|
||||
$sql = sprintf(
|
||||
'SELECT COUNT(id_incidencia) n_incidents, id_usuario
|
||||
FROM tincidencia
|
||||
WHERE rownum <= %d
|
||||
GROUP BY id_usuario
|
||||
ORDER BY 1 DESC',
|
||||
$max_items
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
$incidents = db_get_all_rows_sql($sql);
|
||||
|
||||
if ($incidents == false) {
|
||||
$incidents = [];
|
||||
}
|
||||
|
||||
foreach ($incidents as $incident) {
|
||||
if ($incident['id_usuario'] == false) {
|
||||
$name = __('System');
|
||||
} else {
|
||||
$name = $incident['id_usuario'];
|
||||
}
|
||||
|
||||
$data[$name] = $incident['n_incidents'];
|
||||
foreach ($integria_ticket_count_by_user as $item) {
|
||||
$data[__($item['id_usuario'])] = $item['n_incidents'];
|
||||
}
|
||||
|
||||
if ($config['fixed_graph'] == false) {
|
||||
|
|
|
@ -161,22 +161,32 @@ function integriaims_get_details($details, $detail_index=false)
|
|||
* @param string User password.
|
||||
* @param string API password.
|
||||
* @param string API Operation.
|
||||
* @param array Array with parameters required by the API function.
|
||||
* @param mixed String or array with parameters required by the API function.
|
||||
*
|
||||
* @return boolean True if API request succeeded, false if API request failed.
|
||||
*/
|
||||
function integria_api_call($api_hostname, $user, $user_pass, $api_pass, $operation, $params_array=[], $show_credentials_error_msg=false)
|
||||
function integria_api_call($api_hostname, $user, $user_pass, $api_pass, $operation, $params='', $show_credentials_error_msg=false, $return_type='', $token='')
|
||||
{
|
||||
$params_string = implode(',', $params_array);
|
||||
if (is_array($params)) {
|
||||
$params = implode($token, $params);
|
||||
}
|
||||
|
||||
$url_data = [
|
||||
'user' => $user,
|
||||
'user_pass' => $user_pass,
|
||||
'pass' => $api_pass,
|
||||
'op' => $operation,
|
||||
'params' => html_entity_decode($params_string),
|
||||
'params' => html_entity_decode($params),
|
||||
];
|
||||
|
||||
if ($return_type !== '') {
|
||||
$url_data['return_type'] = $return_type;
|
||||
}
|
||||
|
||||
if ($token !== '') {
|
||||
$url_data['token'] = $token;
|
||||
}
|
||||
|
||||
// Build URL for API request.
|
||||
$url = $api_hostname.'/integria/include/api.php';
|
||||
|
||||
|
@ -355,7 +365,10 @@ function get_tickets_integriaims($tickets_filters)
|
|||
'0',
|
||||
$incident_owner,
|
||||
$incident_creator,
|
||||
]
|
||||
],
|
||||
false,
|
||||
'',
|
||||
','
|
||||
);
|
||||
|
||||
// Return array of api call 'get_incidents'.
|
||||
|
|
|
@ -1525,11 +1525,9 @@ $onheader = [
|
|||
'external_tools' => $external_tools,
|
||||
];
|
||||
|
||||
// Added after it exists
|
||||
// If the agent has incidents associated.
|
||||
if ($total_incidents) {
|
||||
$onheader['incident'] = $incidenttab;
|
||||
}
|
||||
|
||||
$onheader['incident'] = $incidenttab;
|
||||
|
||||
|
||||
if ($agent['url_address'] != '') {
|
||||
$onheader['url_address'] = $urladdresstab;
|
||||
|
|
|
@ -37,12 +37,12 @@ if ($update) {
|
|||
|
||||
// Check if Integria integration enabled.
|
||||
if ($config['integria_enabled'] == 0) {
|
||||
ui_print_error_message(__('Integria integration must be enabled in Pandora setup'));
|
||||
ui_print_error_message(__('In order to access ticket management system, integration with Integria IMS must be enabled and properly configured'));
|
||||
return;
|
||||
}
|
||||
|
||||
// Check connection to Integria IMS API.
|
||||
$has_connection = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_login', []);
|
||||
$has_connection = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_login');
|
||||
|
||||
if ($has_connection === false) {
|
||||
ui_print_error_message(__('Integria IMS API is not reachable'));
|
||||
|
@ -59,19 +59,19 @@ $integria_users_values = [];
|
|||
$integria_types_values = [];
|
||||
$integria_status_values = [];
|
||||
|
||||
$integria_groups_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_groups', []);
|
||||
$integria_groups_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_groups');
|
||||
|
||||
get_array_from_csv_data_pair($integria_groups_csv, $integria_group_values);
|
||||
|
||||
$integria_status_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incidents_status', []);
|
||||
$integria_status_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incidents_status');
|
||||
|
||||
get_array_from_csv_data_pair($integria_status_csv, $integria_status_values);
|
||||
|
||||
$integria_criticity_levels_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_priorities', []);
|
||||
$integria_criticity_levels_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_priorities');
|
||||
|
||||
get_array_from_csv_data_pair($integria_criticity_levels_csv, $integria_criticity_values);
|
||||
|
||||
$integria_users_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_users', []);
|
||||
$integria_users_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_users');
|
||||
|
||||
$csv_array = explode("\n", $integria_users_csv);
|
||||
|
||||
|
@ -81,7 +81,7 @@ foreach ($csv_array as $csv_line) {
|
|||
}
|
||||
}
|
||||
|
||||
$integria_types_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_types', []);
|
||||
$integria_types_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_types');
|
||||
|
||||
get_array_from_csv_data_pair($integria_types_csv, $integria_types_values);
|
||||
|
||||
|
@ -105,7 +105,7 @@ $incident_content = str_replace(',', ':::', $incident_content);
|
|||
// Perform action.
|
||||
if ($create_incident === true) {
|
||||
// Call Integria IMS API method to create an incident.
|
||||
$result_api_call = integria_api_call($config['integria_hostname'], $incident_creator, $config['integria_pass'], $config['integria_api_pass'], 'create_incident', [$incident_title, $incident_group_id, $incident_criticity_id, $incident_content, '', $incident_type, '', $incident_owner, '0', $incident_status]);
|
||||
$result_api_call = integria_api_call($config['integria_hostname'], $incident_creator, $config['integria_pass'], $config['integria_api_pass'], 'create_incident', [$incident_title, $incident_group_id, $incident_criticity_id, $incident_content, '', $incident_type, '', $incident_owner, '0', $incident_status], false, '', ',');
|
||||
|
||||
// Necessary to explicitly set true if not false because function returns api call result in case of success instead of true value.
|
||||
$incident_created_ok = ($result_api_call != false) ? true : false;
|
||||
|
@ -117,7 +117,7 @@ if ($create_incident === true) {
|
|||
);
|
||||
} else if ($update_incident === true) {
|
||||
// Call Integria IMS API method to update an incident.
|
||||
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'update_incident', [$incident_id_edit, $incident_title, $incident_content, '', $incident_group_id, $incident_criticity_id, 0, $incident_status, $incident_owner, 0, $incident_type]);
|
||||
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'update_incident', [$incident_id_edit, $incident_title, $incident_content, '', $incident_group_id, $incident_criticity_id, 0, $incident_status, $incident_owner, 0, $incident_type], false, '', ',');
|
||||
|
||||
// Necessary to explicitly set true if not false because function returns api call result in case of success instead of true value.
|
||||
$incident_updated_ok = ($result_api_call != false) ? true : false;
|
||||
|
@ -132,7 +132,7 @@ if ($create_incident === true) {
|
|||
// If incident id is specified, retrieve incident values from api to populate combos with such values.
|
||||
if ($update) {
|
||||
// Call Integria IMS API method to get details of an incident given its id.
|
||||
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_details', [$incident_id_edit]);
|
||||
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_details', [$incident_id_edit], false, '', ',');
|
||||
|
||||
// API call does not return indexes, therefore future modifications of API function in Integria IMS may lead to inconsistencies when accessing resulting array in this file.
|
||||
$incident_details_separator = explode(',', $result_api_call);
|
||||
|
|
|
@ -27,7 +27,7 @@ if (!check_acl($config['id_user'], 0, 'IR')) {
|
|||
|
||||
// Check if Integria integration enabled.
|
||||
if ($config['integria_enabled'] == 0) {
|
||||
ui_print_error_message(__('Integria integration must be enabled in Pandora setup'));
|
||||
ui_print_error_message(__('In order to access ticket management system, integration with Integria IMS must be enabled and properly configured'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,503 +0,0 @@
|
|||
<script type="text/javascript">
|
||||
|
||||
$( document ).ready(function() {
|
||||
|
||||
$('[id^=checkbox-id_inc]').change(function(){
|
||||
if($(this).parent().parent().hasClass('checkselected')){
|
||||
$(this).parent().parent().removeClass('checkselected');
|
||||
}
|
||||
else{
|
||||
$(this).parent().parent().addClass('checkselected');
|
||||
}
|
||||
});
|
||||
|
||||
$('[id^=checkbox-all_action]').change(function(){
|
||||
if ($("#checkbox-all_action").prop("checked")) {
|
||||
$('[id^=checkbox-id_inc]').parent().parent().addClass('checkselected');
|
||||
$('[name^=id_inc]').prop("checked", true);
|
||||
}
|
||||
else{
|
||||
$('[id^=checkbox-id_inc]').parent().parent().removeClass('checkselected');
|
||||
$('[name^=id_inc]').prop("checked", false);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
global $config;
|
||||
require_once 'include/functions_incidents.php';
|
||||
|
||||
check_login();
|
||||
|
||||
$incident_r = check_acl($config['id_user'], 0, 'IR');
|
||||
$incident_w = check_acl($config['id_user'], 0, 'IW');
|
||||
$incident_m = check_acl($config['id_user'], 0, 'IM');
|
||||
$access = ($incident_r == true) ? 'IR' : (($incident_w == true) ? 'IW' : (($incident_m == true) ? 'IM' : 'IR'));
|
||||
|
||||
if (!$incident_r && !$incident_w && !$incident_m) {
|
||||
db_pandora_audit('ACL Violation', 'Trying to access incident viewer');
|
||||
include 'general/noaccess.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
// Header
|
||||
ui_print_page_header(
|
||||
__('Incident management'),
|
||||
'images/book_edit.png',
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
''
|
||||
);
|
||||
|
||||
// Take input parameters
|
||||
// Offset adjustment
|
||||
if (isset($_GET['offset'])) {
|
||||
$offset = get_parameter('offset');
|
||||
} else {
|
||||
$offset = 0;
|
||||
}
|
||||
|
||||
// Check action. Try to get author and group
|
||||
$action = get_parameter('action');
|
||||
|
||||
if ($action == 'mass') {
|
||||
$id_inc = get_parameter('id_inc', []);
|
||||
$delete_btn = get_parameter('delete_btn', -1);
|
||||
$own_btn = get_parameter('own_btn', -1);
|
||||
|
||||
foreach ($id_inc as $incident) {
|
||||
if (check_acl($config['id_user'], incidents_get_group($incident), 'IM') || incidents_get_author($incident) == $config['id_user'] || incidents_get_owner($incident) == $config['id_user']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
db_pandora_audit('ACL Forbidden', 'Mass-update or deletion of incident');
|
||||
include 'general/noaccess.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($delete_btn != -1) {
|
||||
$result = incidents_delete_incident($id_inc);
|
||||
ui_print_result_message(
|
||||
$result,
|
||||
__('Successfully deleted'),
|
||||
__('Could not be deleted')
|
||||
);
|
||||
}
|
||||
|
||||
if ($own_btn != -1) {
|
||||
$result = incidents_process_chown($id_inc, $config['id_user']);
|
||||
ui_print_result_message(
|
||||
$result,
|
||||
__('Successfully reclaimed ownership'),
|
||||
__('Could not reclame ownership')
|
||||
);
|
||||
}
|
||||
} else if ($action == 'update') {
|
||||
$id_inc = get_parameter('id_inc', 0);
|
||||
$author = incidents_get_author($id_inc);
|
||||
$owner = incidents_get_owner($id_inc);
|
||||
$grupo = incidents_get_group($id_inc);
|
||||
|
||||
if ($author != $config['id_user'] && $owner != $config['id_user'] && !check_acl($config['id_user'], $grupo, 'IM')) {
|
||||
// Only admins (manage incident) or owners/creators can modify incidents
|
||||
db_pandora_audit('ACL Forbidden', 'Update incident #'.$id_inc, $author);
|
||||
include 'general/noaccess.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
$titulo = get_parameter('titulo');
|
||||
$titulo = io_safe_input(strip_tags(io_safe_output($titulo)));
|
||||
$descripcion = get_parameter('descripcion');
|
||||
$origen = get_parameter('origen_form');
|
||||
$prioridad = get_parameter('prioridad_form', 0);
|
||||
$estado = get_parameter('estado_form', 0);
|
||||
$grupo = get_parameter('grupo_form', 1);
|
||||
$usuario = get_parameter('usuario_form', $config['id_user']);
|
||||
$id_agent = get_parameter('id_agent');
|
||||
|
||||
$sql = sprintf(
|
||||
"UPDATE tincidencia
|
||||
SET titulo = '%s', origen = '%s', estado = %d, id_grupo = %d, id_usuario = '%s', prioridad = %d, descripcion = '%s', id_lastupdate = '%s', id_agent = %d
|
||||
WHERE id_incidencia = %d",
|
||||
$titulo,
|
||||
$origen,
|
||||
$estado,
|
||||
$grupo,
|
||||
$usuario,
|
||||
$prioridad,
|
||||
$descripcion,
|
||||
$config['id_user'],
|
||||
$id_agent,
|
||||
$id_inc
|
||||
);
|
||||
$result = db_process_sql($sql);
|
||||
|
||||
if ($result !== false) {
|
||||
db_pandora_audit('Incident updated', 'User '.$config['id_user'].' updated incident #'.$id_inc);
|
||||
}
|
||||
|
||||
ui_print_result_message(
|
||||
$result,
|
||||
__('Successfully updated'),
|
||||
__('Could not be updated')
|
||||
);
|
||||
} else if ($action == 'insert') {
|
||||
// Create incident
|
||||
$grupo = get_parameter('grupo_form', 1);
|
||||
|
||||
if (!check_acl($config['id_user'], $grupo, 'IW')) {
|
||||
db_pandora_audit('ACL Forbidden', 'User '.$config['id_user'].' tried to update incident');
|
||||
include 'general/noaccess.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
// Read input variables
|
||||
$titulo = get_parameter('titulo');
|
||||
$titulo = io_safe_input(strip_tags(io_safe_output($titulo)));
|
||||
$descripcion = get_parameter('descripcion');
|
||||
$origen = get_parameter('origen_form');
|
||||
$prioridad = get_parameter('prioridad_form');
|
||||
$id_creator = $config['id_user'];
|
||||
$estado = get_parameter('estado_form');
|
||||
$usuario = get_parameter('usuario_form', '');
|
||||
$id_agent = get_parameter('id_agent');
|
||||
|
||||
$sql = sprintf(
|
||||
"INSERT INTO tincidencia
|
||||
(inicio, actualizacion, titulo, descripcion, id_usuario, origen, estado, prioridad, id_grupo, id_creator, id_agent, id_agente_modulo)
|
||||
VALUES
|
||||
(NOW(), NOW(), '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, 0)",
|
||||
$titulo,
|
||||
$descripcion,
|
||||
$usuario,
|
||||
$origen,
|
||||
$estado,
|
||||
$prioridad,
|
||||
$grupo,
|
||||
$config['id_user'],
|
||||
$id_agent
|
||||
);
|
||||
$id_inc = db_process_sql($sql, 'insert_id');
|
||||
|
||||
if ($id_inc === false) {
|
||||
ui_print_error_message(__('Error creating incident'));
|
||||
} else {
|
||||
ui_print_success_message(__('Incident created'));
|
||||
db_pandora_audit('Incident created', 'User '.$config['id_user'].' created incident #'.$id_inc);
|
||||
}
|
||||
}
|
||||
|
||||
// Search
|
||||
$filter = '';
|
||||
|
||||
$texto = (string) get_parameter('texto', '');
|
||||
if ($texto != '') {
|
||||
$filter .= sprintf(" AND (titulo LIKE '%%%s%%' OR descripcion LIKE '%%%s%%')", $texto, $texto);
|
||||
}
|
||||
|
||||
$usuario = (string) get_parameter('usuario', '');
|
||||
if ($usuario != '') {
|
||||
$filter .= sprintf(" AND id_usuario = '%s'", $usuario);
|
||||
}
|
||||
|
||||
$estado = (int) get_parameter('estado', -1);
|
||||
if ($estado >= 0) {
|
||||
// -1 = All
|
||||
$filter .= sprintf(' AND estado = %d', $estado);
|
||||
}
|
||||
|
||||
$grupo = (int) get_parameter('grupo', 0);
|
||||
if ($grupo > 0) {
|
||||
$filter .= sprintf(' AND id_grupo = %d', $grupo);
|
||||
if (check_acl($config['id_user'], $grupo, 'IM') == 0) {
|
||||
db_pandora_audit('ACL Forbidden', 'User tried to read incidents from group without access');
|
||||
include 'general/noaccess.php';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$prioridad = (int) get_parameter('prioridad', -1);
|
||||
if ($prioridad != -1) {
|
||||
// -1 = All
|
||||
$filter .= sprintf(' AND prioridad = %d', $prioridad);
|
||||
}
|
||||
|
||||
$agent_search = (int) get_parameter('agent_search');
|
||||
if ($agent_search != 0) {
|
||||
$filter .= sprintf(' AND id_agent = %d', $agent_search);
|
||||
}
|
||||
|
||||
$offset = (int) get_parameter('offset', 0);
|
||||
$groups = users_get_groups($config['id_user'], 'IR');
|
||||
|
||||
// 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'];
|
||||
$count_sql = 'SELECT count(*) FROM tincidencia WHERE
|
||||
id_grupo IN ('.implode(',', array_keys($groups)).')'.$filter.'
|
||||
ORDER BY actualizacion DESC';
|
||||
$total_sql = 'SELECT count(*) FROM tincidencia WHERE
|
||||
id_grupo IN ('.implode(',', array_keys($groups)).')
|
||||
ORDER BY actualizacion DESC';
|
||||
break;
|
||||
|
||||
case 'postgresql':
|
||||
case 'oracle':
|
||||
$set = [];
|
||||
$set['limit'] = $config['block_size'];
|
||||
$set['offset'] = $offset;
|
||||
$sql = 'SELECT * FROM tincidencia WHERE
|
||||
id_grupo IN ('.implode(',', array_keys($groups)).')'.$filter.'
|
||||
ORDER BY actualizacion DESC';
|
||||
$sql = oracle_recode_query($sql, $set);
|
||||
$count_sql = 'SELECT count(*) FROM tincidencia WHERE
|
||||
id_grupo IN ('.implode(',', array_keys($groups)).')'.$filter;
|
||||
$total_sql = 'SELECT count(*) FROM tincidencia WHERE
|
||||
id_grupo IN ('.implode(',', array_keys($groups)).')';
|
||||
break;
|
||||
}
|
||||
|
||||
$result = db_get_all_rows_sql($sql);
|
||||
$count = db_get_value_sql($count_sql);
|
||||
$count_total = db_get_value_sql($total_sql);
|
||||
|
||||
if (empty($result)) {
|
||||
$result = [];
|
||||
$count = 0;
|
||||
}
|
||||
|
||||
if ($count_total >= 1) {
|
||||
echo '<form name="visualizacion" method="post" action="index.php?sec=workspace&sec2=operation/incidents/incident">';
|
||||
|
||||
echo '<table class="databox filters" cellpadding="4" cellspacing="4" width="100%"><tr>
|
||||
<td valign="middle"><h3>'.__('Filter').'</h3>';
|
||||
|
||||
$fields = incidents_get_status();
|
||||
echo '<b>'.__('Incidents:').'</b>'.' ';
|
||||
html_print_select($fields, 'estado', $estado, 'javascript:this.form.submit();', __('All incidents'), -1, false, false, false, 'w155');
|
||||
|
||||
// Legend
|
||||
echo '</td><td valign="middle"><noscript>';
|
||||
html_print_submit_button(__('Show'), 'submit-estado', false, ['class' => 'sub']);
|
||||
|
||||
echo '</noscript></td><td rowspan="7" class="f9" class="pdd_l_30px align-top"><h3>'.__('Status').'</h3>';
|
||||
foreach (incidents_get_status() as $id => $str) {
|
||||
incidents_print_status_img($id);
|
||||
echo ' - '.$str.'<br />';
|
||||
}
|
||||
|
||||
echo '</td><td rowspan="7" class="f9" class="pdd_l_30px align-top"><h3>'.__('Priority').'</h3>';
|
||||
foreach (incidents_get_priorities() as $id => $str) {
|
||||
incidents_print_priority_img($id);
|
||||
echo ' - '.$str.'<br />';
|
||||
}
|
||||
|
||||
echo '</td></tr><tr><td>';
|
||||
|
||||
$fields = incidents_get_priorities();
|
||||
|
||||
echo '<b>'.__('Priorities:').'</b>'.' ';
|
||||
html_print_select($fields, 'prioridad', $prioridad, 'javascript:this.form.submit();', __('All priorities'), -1, false, false, false, 'w155');
|
||||
|
||||
echo '</td></tr><tr><td>';
|
||||
|
||||
echo '<b>'.__('Users:').'</b>'.' ';
|
||||
html_print_select(users_get_info(), 'usuario', $usuario, 'javascript:this.form.submit();', __('All users'), '', false, false, false, 'w155');
|
||||
|
||||
echo '</td></tr><tr><td>';
|
||||
|
||||
$agents_incidents = agents_get_agents(false, ['id_agente', 'nombre']);
|
||||
|
||||
if ($agents_incidents === false) {
|
||||
$agents_incidents = [];
|
||||
}
|
||||
|
||||
$result_agent_incidents = [];
|
||||
foreach ($agents_incidents as $agent_incident) {
|
||||
$result_agent_incidents[$agent_incident['id_agente']] = $agent_incident['nombre'];
|
||||
}
|
||||
|
||||
echo '<b>'.__('Agents:').'</b>'.' ';
|
||||
html_print_select(
|
||||
$result_agent_incidents,
|
||||
'agent_search',
|
||||
$agent_search,
|
||||
'javascript:this.form.submit();',
|
||||
__('All agents'),
|
||||
'',
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
'w155'
|
||||
);
|
||||
|
||||
echo '</td></tr><tr><td colspan=3>';
|
||||
|
||||
echo '<b>'.__('Groups:').'</b>'.' ';
|
||||
echo '<div class="w250px inline">';
|
||||
html_print_select_groups($config['id_user'], 'IR', true, 'grupo', $grupo, 'javascript:this.form.submit();', '', '', false, false, false, 'w155');
|
||||
echo '</div>';
|
||||
|
||||
// echo " ";
|
||||
echo '</td></tr><tr><td colspan=3>';
|
||||
|
||||
echo '<b>'.__('Free text:').'</b>'.ui_print_help_tip(
|
||||
__('Search by incident name or description, list matches.'),
|
||||
true
|
||||
).' ';
|
||||
html_print_input_text('texto', $texto, '', 45);
|
||||
echo ' ';
|
||||
html_print_input_image('submit', 'images/zoom.png', __('Search'), 'padding:0;', false, ['alt' => __('Search')]);
|
||||
|
||||
echo '</td></tr></table>';
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
if ($count_total < 1) {
|
||||
include_once $config['homedir'].'/general/first_task/incidents.php';
|
||||
} else {
|
||||
// TOTAL incidents
|
||||
$url = 'index.php?sec=workspace&sec2=operation/incidents/incident';
|
||||
|
||||
$estado = -1;
|
||||
|
||||
// add form filter values for group, priority, state, and search fields: user and text
|
||||
if ($grupo != -1) {
|
||||
$url .= '&grupo='.$grupo;
|
||||
}
|
||||
|
||||
if ($prioridad != -1) {
|
||||
$url .= '&prioridad='.$prioridad;
|
||||
}
|
||||
|
||||
if ($estado != -1) {
|
||||
$url .= '&estado='.$estado;
|
||||
}
|
||||
|
||||
if ($usuario != '') {
|
||||
$url .= '&usuario='.$usuario;
|
||||
}
|
||||
|
||||
if ($texto != '') {
|
||||
$url .= '&texto='.$texto;
|
||||
}
|
||||
|
||||
// Show pagination
|
||||
ui_pagination($count, $url, $offset, 0, false);
|
||||
// ($count + $offset) it's real count of incidents because it's use LIMIT $offset in query.
|
||||
echo '<br />';
|
||||
|
||||
// Show headers
|
||||
$table->width = '100%';
|
||||
$table->class = 'info_table';
|
||||
$table->cellpadding = 0;
|
||||
$table->cellspacing = 0;
|
||||
$table->head = [];
|
||||
$table->data = [];
|
||||
$table->size = [];
|
||||
$table->align = [];
|
||||
|
||||
$table->head[0] = html_print_checkbox('all_action', 0, false, true, false);
|
||||
$table->head[1] = __('ID');
|
||||
$table->head[2] = __('Status');
|
||||
$table->head[3] = __('Incident');
|
||||
$table->head[4] = __('Priority');
|
||||
$table->head[5] = __('Group');
|
||||
$table->head[6] = __('Updated');
|
||||
$table->head[7] = __('Source');
|
||||
$table->head[8] = __('Owner');
|
||||
|
||||
$table->size[0] = '20px';
|
||||
|
||||
$table->align[0] = 'left';
|
||||
$table->align[2] = 'left';
|
||||
$table->align[4] = 'left';
|
||||
$table->align[5] = 'left';
|
||||
|
||||
$rowPair = true;
|
||||
$iterator = 0;
|
||||
foreach ($result as $row) {
|
||||
if ($rowPair) {
|
||||
$table->rowclass[$iterator] = 'rowPair';
|
||||
} else {
|
||||
$table->rowclass[$iterator] = 'rowOdd';
|
||||
}
|
||||
|
||||
$rowPair = !$rowPair;
|
||||
$iterator++;
|
||||
|
||||
$data = [];
|
||||
|
||||
if (check_acl($config['id_user'], $row['id_grupo'], 'IM') || $config['id_user'] == $row['id_usuario'] || $config['id_user'] == $row['id_creator']) {
|
||||
$data[0] = html_print_checkbox('id_inc[]', $row['id_incidencia'], false, true);
|
||||
} else {
|
||||
$data[0] = '';
|
||||
}
|
||||
|
||||
$data[1] = '<a href="index.php?sec=workspace&sec2=operation/incidents/incident_detail&id='.$row['id_incidencia'].'">'.$row['id_incidencia'].'</a>';
|
||||
$attach = incidents_get_attach($row['id_incidencia']);
|
||||
|
||||
if (!empty($attach)) {
|
||||
$data[1] .= ' '.html_print_image('images/attachment.png', true, ['style' => 'align:middle;']);
|
||||
}
|
||||
|
||||
$data[2] = incidents_print_status_img($row['estado'], true);
|
||||
$data[3] = '<a href="index.php?sec=workspace&sec2=operation/incidents/incident_detail&id='.$row['id_incidencia'].'">'.ui_print_truncate_text(io_safe_output($row['titulo']), 'item_title').'</a>';
|
||||
$data[4] = incidents_print_priority_img($row['prioridad'], true);
|
||||
$data[5] = ui_print_group_icon($row['id_grupo'], true);
|
||||
$data[6] = ui_print_timestamp($row['actualizacion'], true);
|
||||
$data[7] = $row['origen'];
|
||||
if (empty($row['id_usuario'])) {
|
||||
$data[8] = 'SYSTEM';
|
||||
} else {
|
||||
$data[8] = ui_print_username($row['id_usuario'], true);
|
||||
}
|
||||
|
||||
array_push($table->data, $data);
|
||||
}
|
||||
|
||||
echo '<form method="post" action="'.$url.'&action=mass" class="mrgn_btn_0px">';
|
||||
html_print_table($table);
|
||||
echo '<div class="right float-right">';
|
||||
if (check_acl($config['id_user'], 0, 'IW')) {
|
||||
html_print_submit_button(__('Delete incidents'), 'delete_btn', false, 'class="sub delete" class="mrgn_right_5px"');
|
||||
}
|
||||
|
||||
if (check_acl($config['id_user'], 0, 'IM')) {
|
||||
html_print_submit_button(__('Become owner'), 'own_btn', false, 'class="sub upd"');
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
unset($table);
|
||||
if (check_acl($config['id_user'], 0, 'IW')) {
|
||||
echo '<div class="right float-right pdd_r_5px">';
|
||||
echo '<form method="post" action="index.php?sec=workspace&sec2=operation/incidents/incident_detail&insert_form=1">';
|
||||
html_print_submit_button(__('Create incident'), 'crt', false, 'class="sub next"');
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo '<div id="both"> </div>';
|
|
@ -1,532 +0,0 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// Load global vars
|
||||
global $config;
|
||||
require_once 'include/functions_incidents.php';
|
||||
require_once 'include/functions_events.php';
|
||||
// To get events group information
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'IR') && ! check_acl($config['id_user'], 0, 'IW') && ! check_acl($config['id_user'], 0, 'IM')) {
|
||||
// Doesn't have access to this page
|
||||
db_pandora_audit('ACL Violation', 'Trying to access incident details');
|
||||
include 'general/noaccess.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
$inicio = get_system_time();
|
||||
// Just inits the variable
|
||||
$actualizacion = get_system_time();
|
||||
|
||||
// EDITION MODE
|
||||
if (isset($_GET['id'])) {
|
||||
$id_inc = (int) get_parameter('id', 0);
|
||||
|
||||
// Obtain group of this incident
|
||||
$row = db_get_row('tincidencia', 'id_incidencia', $id_inc);
|
||||
|
||||
// Get values
|
||||
$titulo = $row['titulo'];
|
||||
$texto = $row['descripcion'];
|
||||
$inicio = time_w_fixed_tz($row['inicio']);
|
||||
$actualizacion = time_w_fixed_tz($row['actualizacion']);
|
||||
$estado = $row['estado'];
|
||||
$prioridad = $row['prioridad'];
|
||||
$origen = $row['origen'];
|
||||
$usuario = $row['id_usuario'];
|
||||
// owner
|
||||
$id_grupo = $row['id_grupo'];
|
||||
$id_creator = $row['id_creator'];
|
||||
// creator
|
||||
$id_lastupdate = $row['id_lastupdate'];
|
||||
// last updater
|
||||
$id_agent = $row['id_agent'];
|
||||
// Agent
|
||||
// Note add - everybody that can read incidents, can add notes
|
||||
if (isset($_GET['insertar_nota'])) {
|
||||
$nota = get_parameter('nota');
|
||||
|
||||
$sql = sprintf(
|
||||
"INSERT INTO tnota (id_usuario, id_incident, nota)
|
||||
VALUES ('%s', %d, '%s')",
|
||||
$config['id_user'],
|
||||
$id_inc,
|
||||
$nota
|
||||
);
|
||||
$id_nota = db_process_sql($sql, 'insert_id');
|
||||
|
||||
if ($id_nota !== false) {
|
||||
incidents_process_touch($id_inc);
|
||||
}
|
||||
|
||||
ui_print_result_message(
|
||||
$id_nota,
|
||||
__('Successfully added'),
|
||||
__('Could not be added')
|
||||
);
|
||||
}
|
||||
|
||||
// Delete note
|
||||
if (isset($_POST['delete_nota'])) {
|
||||
$id_nota = get_parameter('delete_nota', 0);
|
||||
$note_user = incidents_get_notes_author($id_nota);
|
||||
if (((check_acl($config['id_user'], $id_grupo, 'IM') == 1) or ($note_user == $config['id_user'])) or ($id_owner == $config['id_user'])) {
|
||||
// Only admins (manage incident) or owners can modify
|
||||
// incidents notes. note authors are
|
||||
// able to delete their own notes
|
||||
$result = incidents_delete_note($id_nota);
|
||||
|
||||
if (!empty($result)) {
|
||||
incidents_process_touch($id_inc);
|
||||
}
|
||||
|
||||
ui_print_result_message(
|
||||
$id_nota,
|
||||
__('Successfully deleted'),
|
||||
__('Could not be deleted')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete file
|
||||
if (((check_acl($config['id_user'], $id_grupo, 'IM') == 1)
|
||||
or ($id_owner == $config['id_user'])) and isset($_POST['delete_file'])
|
||||
) {
|
||||
$file_id = (int) get_parameter('delete_file', 0);
|
||||
$filename = db_get_value('filename', 'tattachment', 'id_attachment', $file_id);
|
||||
$sql = sprintf(
|
||||
'
|
||||
DELETE
|
||||
FROM tattachment
|
||||
WHERE id_attachment = %d',
|
||||
$file_id
|
||||
);
|
||||
$result = db_process_sql($sql);
|
||||
|
||||
if (!empty($result)) {
|
||||
if (file_exists($config['homedir'].'/attachment/pand'.$row['id_attachment'].'_'.$row['filename'].'.zip')) {
|
||||
unlink(
|
||||
$config['attachment_store'].'/pand'.$file_id.'_'.io_safe_output($filename).'.zip'
|
||||
);
|
||||
} else {
|
||||
unlink(
|
||||
$config['attachment_store'].'/pand'.$file_id.'_'.io_safe_output($filename)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
incidents_process_touch($id_inc);
|
||||
}
|
||||
|
||||
ui_print_result_message(
|
||||
$result,
|
||||
__('Successfully deleted'),
|
||||
__('Could not be deleted')
|
||||
);
|
||||
}
|
||||
|
||||
// Upload file
|
||||
if ((check_acl($config['id_user'], $id_grupo, 'IW') == 1) && isset($_GET['upload_file']) && ($_FILES['userfile']['name'] != '')) {
|
||||
$description = get_parameter('file_description', __('No description available'));
|
||||
|
||||
// Insert into database
|
||||
$filename = strip_tags(io_safe_input($_FILES['userfile']['name']), '<br>');
|
||||
$filesize = io_safe_input($_FILES['userfile']['size']);
|
||||
|
||||
// The following is if you have clamavlib installed
|
||||
// (php5-clamavlib) and enabled in php.ini
|
||||
// http://www.howtoforge.com/scan_viruses_with_php_clamavlib
|
||||
if (extension_loaded('clamav')) {
|
||||
cl_setlimits(5, 1000, 200, 0, 10485760);
|
||||
$malware = cl_scanfile($_FILES['file']['tmp_name']);
|
||||
if ($malware) {
|
||||
$error = 'Malware detected: '.$malware.'<br>ClamAV version: '.clam_get_version();
|
||||
die($error);
|
||||
// On malware, we die because it's not good to handle it
|
||||
}
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
"INSERT INTO tattachment (id_incidencia, id_usuario, filename, description, size)
|
||||
VALUES (%d, '%s', '%s', '%s', %d)",
|
||||
$id_inc,
|
||||
$config['id_user'],
|
||||
$filename,
|
||||
$description,
|
||||
$filesize
|
||||
);
|
||||
|
||||
$id_attachment = db_process_sql($sql, 'insert_id');
|
||||
|
||||
// Copy file to directory and change name
|
||||
if ($id_attachment !== false) {
|
||||
$nombre_archivo = $config['attachment_store'].'/pand'.$id_attachment.'_'.$_FILES['userfile']['name'];
|
||||
|
||||
|
||||
$zip = new ZipArchive;
|
||||
|
||||
if ($zip->open($nombre_archivo.'.zip', ZIPARCHIVE::CREATE) === true) {
|
||||
$zip->addFile($_FILES['userfile']['tmp_name'], io_safe_output($filename));
|
||||
$zip->close();
|
||||
}
|
||||
|
||||
|
||||
// $result = copy ($_FILES['userfile']['tmp_name'], $nombre_archivo);
|
||||
} else {
|
||||
ui_print_error_message(__('File could not be saved due to database error'));
|
||||
$result = false;
|
||||
}
|
||||
|
||||
if ($result !== false) {
|
||||
unlink($_FILES['userfile']['tmp_name']);
|
||||
incidents_process_touch($id_inc);
|
||||
} else {
|
||||
db_process_sql('DELETE FROM tattachment WHERE id_attachment = '.$id_attachment);
|
||||
}
|
||||
|
||||
ui_print_result_message(
|
||||
$result,
|
||||
__('File uploaded'),
|
||||
__('File could not be uploaded')
|
||||
);
|
||||
}
|
||||
} //end if
|
||||
// Create incident from event... read event data
|
||||
else if (isset($_GET['insert_form'])) {
|
||||
$titulo = '';
|
||||
$descripcion = '';
|
||||
$origen = '';
|
||||
$prioridad = 0;
|
||||
$id_grupo = 0;
|
||||
$estado = 0;
|
||||
$texto = '';
|
||||
$usuario = $config['id_user'];
|
||||
$id_creator = $config['id_user'];
|
||||
$id_grupo = 0;
|
||||
$id_agent = 0;
|
||||
|
||||
if (isset($_GET['from_event'])) {
|
||||
$event = get_parameter('from_event');
|
||||
$texto = io_safe_output(events_get_description($event));
|
||||
$titulo = ui_print_truncate_text(events_get_description($event), 'description', false, true, false);
|
||||
$id_grupo = events_get_group($event);
|
||||
$origen = 'Pandora FMS Event';
|
||||
$id_agent = db_get_value('id_agente', 'tevento', 'id_evento', $event);
|
||||
unset($event);
|
||||
}
|
||||
|
||||
$prioridad = 0;
|
||||
} else {
|
||||
db_pandora_audit('HACK', 'Trying to get to incident details in an unusual way');
|
||||
include 'general/noaccess.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ********************************************************************************************************
|
||||
// ********************************************************************************************************
|
||||
// Show the form
|
||||
// ********************************************************************************************************
|
||||
// This is for the pretty slide down attachment form
|
||||
echo "<script type=\"text/javascript\">
|
||||
$(document).ready(function() {
|
||||
$('#file_control').hide();
|
||||
$('#add_note').hide();
|
||||
$('a.attachment').click(function() {
|
||||
$('a.attachment').fadeOut('fast');
|
||||
$('#file_control').slideDown('slow');
|
||||
return false;
|
||||
});
|
||||
$('a.note_control').click(function() {
|
||||
$('a.note_control').fadeOut('fast');
|
||||
$('#add_note').slideDown('slow');
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>";
|
||||
|
||||
if (isset($id_inc)) {
|
||||
// If $id_inc is set (when $_GET["id"] is set, not $_GET["insert_form"]
|
||||
ui_print_page_header(__('Incident details').' #'.$id_inc, 'images/book_edit.png', false, '', false, '');
|
||||
echo '<form name="accion_form" method="POST" action="index.php?sec=workspace&sec2=operation/incidents/incident&action=update">';
|
||||
echo '<input type="hidden" name="id_inc" value="'.$id_inc.'">';
|
||||
} else {
|
||||
ui_print_page_header(__('Create incident'), 'images/book_edit.png', false, '', false, '');
|
||||
echo '<form name="accion_form" method="POST" action="index.php?sec=workspace&sec2=operation/incidents/incident&action=insert">';
|
||||
}
|
||||
|
||||
echo '<table cellpadding="4" cellspacing="4" class="databox filters" width="100%">';
|
||||
echo '<tr>
|
||||
<td class="datos"><b>'.__('Incident').'</b></td>
|
||||
<td colspan="3" class="datos">';
|
||||
|
||||
if ((check_acl($config['id_user'], $id_grupo, 'IM') == 1)
|
||||
or ($usuario == $config['id_user'])
|
||||
) {
|
||||
html_print_input_text('titulo', $titulo, '', 70);
|
||||
} else {
|
||||
html_print_input_text_extended('titulo', $titulo, '', '', 70, '', false, '', 'readonly');
|
||||
}
|
||||
|
||||
echo '</td>
|
||||
</tr>';
|
||||
|
||||
echo '<tr>
|
||||
<td class="datos2"><b>'.__('Opened at').'</b></td>
|
||||
<td class="datos2"><i>'.date($config['date_format'], $inicio).'</i></td>
|
||||
<td class="datos2"><b>'.__('Updated at').'</b></td>
|
||||
<td class="datos2"><i>'.date($config['date_format'], $actualizacion).'</i></td>
|
||||
</tr>';
|
||||
|
||||
echo '<tr>
|
||||
<td class="datos"><b>'.__('Owner').'</b></td>
|
||||
<td class="datos">';
|
||||
|
||||
if ((check_acl($config['id_user'], $id_grupo, 'IM') == 1) or ($usuario == $config['id_user'])) {
|
||||
html_print_select(users_get_info(), 'usuario_form', $usuario, '', 'SYSTEM', '', false, false, true, 'w135');
|
||||
} else {
|
||||
html_print_select(users_get_info(), 'usuario_form', $usuario, '', 'SYSTEM', '', false, false, true, 'w135', true);
|
||||
}
|
||||
|
||||
echo '</td>
|
||||
<td class="datos"><b>'.__('Status').'</b></td>
|
||||
<td class="datos">';
|
||||
|
||||
if ((check_acl($config['id_user'], $id_grupo, 'IM') == 1) or ($usuario == $config['id_user'])) {
|
||||
html_print_select(incidents_get_status(), 'estado_form', $estado, '', '', '', false, false, false, 'w135');
|
||||
} else {
|
||||
html_print_select(incidents_get_status(), 'estado_form', $estado, '', '', '', false, false, false, 'w135', true);
|
||||
}
|
||||
|
||||
echo '</td>
|
||||
</tr>';
|
||||
|
||||
echo '<tr>
|
||||
<td class="datos2"><b>'.__('Source').'</b></td>
|
||||
<td class="datos2">';
|
||||
|
||||
$fields = [];
|
||||
$return = db_get_all_rows_sql('SELECT origen FROM torigen ORDER BY origen');
|
||||
if ($return === false) {
|
||||
$return[0] = $estado;
|
||||
// Something must be displayed
|
||||
}
|
||||
|
||||
foreach ($return as $row) {
|
||||
$fields[$row['origen']] = $row['origen'];
|
||||
}
|
||||
|
||||
// Only owner could change source or user with Incident management privileges
|
||||
if ((check_acl($config['id_user'], $id_grupo, 'IM') == 1) or ($usuario == $config['id_user'])) {
|
||||
html_print_select($fields, 'origen_form', $origen, '', '', '', false, false, false, 'w135');
|
||||
} else {
|
||||
html_print_select($fields, 'origen_form', $origen, '', '', '', false, false, false, 'w135', true);
|
||||
}
|
||||
|
||||
echo '</td><td class="datos2"><b>'.__('Group').'</b></td><td class="datos2">';
|
||||
|
||||
// Group combo
|
||||
echo '<div class="w250px">';
|
||||
if ((check_acl($config['id_user'], $id_grupo, 'IM') == 1) or ($usuario == $config['id_user'])) {
|
||||
html_print_select_groups($config['id_user'], 'IR', true, 'grupo_form', $id_grupo, '', '', '', false, false, false, 'w135');
|
||||
} else {
|
||||
html_print_select_groups($config['id_user'], 'IR', true, 'grupo_form', $id_grupo, '', '', '', false, false, true, 'w135', true);
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
echo '</td></tr><tr><td class="datos"><b>'.__('Priority').'</b></td><td class="datos">';
|
||||
|
||||
if ((check_acl($config['id_user'], $id_grupo, 'IM') == 1) or ($usuario == $config['id_user'])) {
|
||||
html_print_select(incidents_get_priorities(), 'prioridad_form', $prioridad, '', '', '', false, false, false, 'w135');
|
||||
} else {
|
||||
html_print_select(incidents_get_priorities(), 'prioridad_form', $prioridad, '', '', '', false, false, false, 'w135', true);
|
||||
}
|
||||
|
||||
echo '</td><td class="datos"><b>'.__('Creator').'</b></td><td class="datos">';
|
||||
if (empty($id_creator)) {
|
||||
echo 'SYSTEM';
|
||||
} else {
|
||||
echo $id_creator.' (<i>'.get_user_fullname($id_creator).'</i>)';
|
||||
}
|
||||
|
||||
$agents_incidents = agents_get_agents(false, ['id_agente', 'nombre']);
|
||||
|
||||
if ($agents_incidents === false) {
|
||||
$agents_incidents = [];
|
||||
}
|
||||
|
||||
foreach ($agents_incidents as $agent_incident) {
|
||||
$result_agent_incidents[$agent_incident['id_agente']] = $agent_incident['nombre'];
|
||||
}
|
||||
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
|
||||
echo '<tr>';
|
||||
echo '<td class="datos"><b>'.__('Agent').'</b></td>';
|
||||
echo '<td class="datos">';
|
||||
$params = [];
|
||||
$params['show_helptip'] = true;
|
||||
$params['input_name'] = 'agent';
|
||||
$params['value'] = db_get_value('alias', 'tagente', 'id_agente', $id_agent);
|
||||
$params['print_hidden_input_idagent'] = true;
|
||||
$params['hidden_input_idagent_value'] = $id_agent;
|
||||
$params['hidden_input_idagent_name'] = 'id_agent';
|
||||
ui_print_agent_autocomplete_input($params);
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
echo '<tr><td class="datos2" colspan="4">';
|
||||
|
||||
if ((check_acl($config['id_user'], $id_grupo, 'IM') == 1) or ($usuario == $config['id_user'])) {
|
||||
html_print_textarea('descripcion', 15, 80, $texto, 'class="height_200px"');
|
||||
} else {
|
||||
html_print_textarea('descripcion', 15, 80, $texto, 'class="height:200px" disabled');
|
||||
}
|
||||
|
||||
echo '</td></tr></table><div class="w100p right">';
|
||||
|
||||
// Only if user is the used who opened incident or (s)he is admin
|
||||
if (isset($id_inc) and ((check_acl($config['id_user'], $id_grupo, 'IM') == 1) or ($usuario == $config['id_user']))) {
|
||||
html_print_submit_button(__('Update incident'), 'accion', false, 'class="sub upd"');
|
||||
} else if (check_acl($config['id_user'], $id_grupo, 'IW')) {
|
||||
html_print_submit_button(__('Create'), 'accion', false, 'class="sub wand"');
|
||||
} else {
|
||||
html_print_submit_button(__('Submit'), 'accion', true, 'class="sub upd"');
|
||||
}
|
||||
|
||||
echo '</div></form>';
|
||||
|
||||
// If we're actually working on an incident
|
||||
if (isset($id_inc)) {
|
||||
// ******************************************************************
|
||||
// Notes
|
||||
// ******************************************************************
|
||||
echo '<div>';
|
||||
|
||||
echo '<a class="note_control" href="#">';
|
||||
echo html_print_image('images/add.png', true);
|
||||
echo __('Add note');
|
||||
echo '</a>';
|
||||
echo '</div><div>';
|
||||
echo '<form id="add_note" name="nota" method="POST" action="index.php?sec=workspace&sec2=operation/incidents/incident_detail&insertar_nota=1&id='.$id_inc.'"><h4>'.__('Add note').'</h4>';
|
||||
|
||||
echo '<table cellpadding="4" cellspacing="4" class="databox" width="100%">
|
||||
<tr><td class="datos2"><textarea name="nota" rows="5" cols="70" class="height_100px"></textarea></td>
|
||||
<td valign="bottom"><input name="addnote" type="submit" class="sub wand" value="'.__('Add').'"></td></tr>
|
||||
</table></form></div><div>';
|
||||
|
||||
$result = incidents_get_notes($id_inc);
|
||||
|
||||
$table->cellpadding = 4;
|
||||
$table->cellspacing = 4;
|
||||
$table->class = 'databox';
|
||||
$table->width = '98%';
|
||||
$table->data = [];
|
||||
$table->head = [];
|
||||
|
||||
foreach ($result as $row) {
|
||||
$data = [];
|
||||
$data[0] = html_print_image('images/page_white_text.png', true, ['class' => 'invert_filter', 'border' => '0']);
|
||||
$data[1] = __('Author').': '.ui_print_username($row['id_usuario'], true).' ('.ui_print_timestamp($row['timestamp'], true).')';
|
||||
array_push($table->data, $data);
|
||||
|
||||
$data = [];
|
||||
$data[0] = '';
|
||||
if ((check_acl($config['id_user'], $id_grupo, 'IM') == 1) or ($row['id_usuario'] == $config['id_user'])) {
|
||||
$data[0] .= html_print_input_image('delete_nota', 'images/cross.png', $row['id_nota'], 'border:0px;" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;', true);
|
||||
}
|
||||
|
||||
$data[1] = $row['nota'];
|
||||
array_push($table->data, $data);
|
||||
}
|
||||
|
||||
if (!empty($table->data)) {
|
||||
echo '<h4>'.__('Notes attached to incident').'</h4>';
|
||||
echo '<form method="POST" action="index.php?sec=workspace&sec2=operation/incidents/incident_detail&id='.$id_inc.'">';
|
||||
html_print_table($table);
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
unset($table);
|
||||
|
||||
|
||||
// ******************************************************************
|
||||
// Files attached to this incident
|
||||
// ******************************************************************
|
||||
$result = incidents_get_attach($id_inc);
|
||||
|
||||
$table->cellpadding = 4;
|
||||
$table->cellspacing = 4;
|
||||
$table->class = 'databox';
|
||||
$table->width = '98%';
|
||||
$table->head = [];
|
||||
$table->data = [];
|
||||
|
||||
$table->head[0] = __('Filename');
|
||||
$table->head[1] = __('Description');
|
||||
$table->head[2] = __('Size');
|
||||
$table->head[3] = __('Delete');
|
||||
|
||||
$table->align[2] = 'center';
|
||||
$table->align[3] = 'center';
|
||||
|
||||
foreach ($result as $row) {
|
||||
if (file_exists($config['homedir'].'/attachment/pand'.$row['id_attachment'].'_'.io_safe_output($row['filename']).'.zip')) {
|
||||
$url = 'attachment/pand'.$row['id_attachment'].'_'.io_safe_output($row['filename']).'.zip';
|
||||
} else {
|
||||
$url = 'attachment/pand'.$row['id_attachment'].'_'.io_safe_output($row['filename']);
|
||||
}
|
||||
|
||||
$data[0] = html_print_image('images/disk.png', true, ['border' => '0', 'align' => 'top']).' <a target="_new" href="'.$url.'"><b>'.$row['filename'].'</b></a>';
|
||||
$data[1] = $row['description'];
|
||||
$data[2] = format_for_graph($row['size']).'B';
|
||||
if ((check_acl($config['id_user'], $id_grupo, 'IM') == 1) or ($usuario == $config['id_user'])) {
|
||||
$data[3] = html_print_input_image('delete_file', 'images/cross.png', $row['id_attachment'], 'border:0px;" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;', true);
|
||||
} else {
|
||||
$data[3] = '';
|
||||
}
|
||||
|
||||
array_push($table->data, $data);
|
||||
}
|
||||
|
||||
if (!empty($table->data)) {
|
||||
echo '<h4>'.__('Attached files').'</h4>';
|
||||
echo '<form method="POST" action="index.php?sec=workspace&sec2=operation/incidents/incident_detail&id='.$id_inc.'">';
|
||||
html_print_table($table);
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
unset($table);
|
||||
|
||||
// ******************************************************************
|
||||
// Upload control
|
||||
// ******************************************************************
|
||||
// Upload control
|
||||
if ((check_acl($config['id_user'], $id_grupo, 'IW') == 1)) {
|
||||
echo '<div>';
|
||||
echo '<a class="attachment" href="#">';
|
||||
echo html_print_image('images/add.png', true);
|
||||
echo __('Add attachment');
|
||||
echo '</a>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div><form method="post" id="file_control" action="index.php?sec=workspace&sec2=operation/incidents/incident_detail&id='.$id_inc.'&upload_file=1" enctype="multipart/form-data"><h4>'.__('Add attachment').'</h4>';
|
||||
echo '<table cellpadding="4" cellspacing="3" class="databox" width="98%">
|
||||
<tr><td class="datos">'.__('Filename').'</td><td class="datos"><input type="file" name="userfile" value="userfile" class="sub" size="40" /></td></tr>
|
||||
<tr><td class="datos2">'.__('Description').'</td><td class="datos2" colspan="3"><input type="text" name="file_description" size="47"></td></tr>
|
||||
<tr><td colspan="2" class="right"> <input type="submit" name="upload" value="'.__('Upload').'" class="sub wand"></td></tr>
|
||||
</table></form></div>';
|
||||
}
|
||||
}
|
|
@ -26,6 +26,11 @@ if (! check_acl($config['id_user'], 0, 'IR') && ! check_acl($config['id_user'],
|
|||
|
||||
ui_print_page_header(__('Incidents').' » '.__('Statistics'), 'images/book_edit.png', false, '', false, '');
|
||||
|
||||
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'));
|
||||
exit;
|
||||
}
|
||||
|
||||
echo '<table width="90%">
|
||||
<tr><td valign="top"><h3>'.__('Incidents by status').'</h3>';
|
||||
echo graph_incidents_status();
|
||||
|
@ -39,7 +44,4 @@ echo graphic_incident_group();
|
|||
echo '<td><h3>'.__('Incidents by user').'</h3>';
|
||||
echo graphic_incident_user();
|
||||
|
||||
echo '<tr><td><h3>'.__('Incidents by source').'</h3>';
|
||||
echo graphic_incident_source();
|
||||
|
||||
echo '</table>';
|
||||
|
|
|
@ -38,7 +38,7 @@ ui_print_page_header(
|
|||
|
||||
// Check if Integria integration enabled.
|
||||
if ($config['integria_enabled'] == 0) {
|
||||
ui_print_error_message(__('Integria integration must be enabled in Pandora setup'));
|
||||
ui_print_error_message(__('In order to access ticket management system, integration with Integria IMS must be enabled and properly configured'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -493,9 +493,8 @@ if (check_acl($config['id_user'], 0, 'IR')
|
|||
];
|
||||
|
||||
$sub2 = [];
|
||||
$sub2['operation/incidents/incident']['text'] = __('List of Incidents');
|
||||
$sub2[$sec2sub]['text'] = __('Statistics');
|
||||
$sub2['operation/incidents/list_integriaims_incidents']['text'] = __('Integria IMS Tickets');
|
||||
$sub2[$sec2sub]['text'] = __('Integria IMS statistics');
|
||||
$sub2['operation/incidents/list_integriaims_incidents']['text'] = __('Integria IMS ticket list');
|
||||
|
||||
$sub[$sec2]['sub2'] = $sub2;
|
||||
$sec2 = $temp_sec2;
|
||||
|
|
|
@ -441,6 +441,7 @@ CREATE TABLE IF NOT EXISTS `talert_actions` (
|
|||
`field19_recovery` text NOT NULL,
|
||||
`field20_recovery` text NOT NULL,
|
||||
`previous_name` text,
|
||||
`create_wu_integria` tinyint(1) default NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`id_alert_command`) REFERENCES talert_commands(`id`)
|
||||
ON DELETE CASCADE ON UPDATE CASCADE
|
||||
|
|
|
@ -44,8 +44,6 @@ Exported Functions:
|
|||
|
||||
=item * C<pandora_create_group>
|
||||
|
||||
=item * C<pandora_create_incident>
|
||||
|
||||
=item * C<pandora_create_module>
|
||||
|
||||
=item * C<pandora_disable_autodisable_agents>
|
||||
|
@ -161,6 +159,9 @@ use LWP::Simple;
|
|||
use IO::Socket::INET6;
|
||||
use LWP::UserAgent;
|
||||
use HTTP::Request::Common;
|
||||
use URI::URL;
|
||||
use LWP::UserAgent;
|
||||
use JSON;
|
||||
|
||||
# For IPv6 support in Net::HTTP.
|
||||
BEGIN {
|
||||
|
@ -179,7 +180,6 @@ our @EXPORT = qw(
|
|||
pandora_create_agent
|
||||
pandora_create_alert_command
|
||||
pandora_create_group
|
||||
pandora_create_incident
|
||||
pandora_create_module
|
||||
pandora_create_module_from_hash
|
||||
pandora_create_module_from_network_component
|
||||
|
@ -254,6 +254,8 @@ our @EXPORT = qw(
|
|||
pandora_self_monitoring
|
||||
pandora_sample_agent
|
||||
pandora_process_policy_queue
|
||||
pandora_sync_agents_integria
|
||||
pandora_get_integria_ticket_types
|
||||
subst_alert_macros
|
||||
subst_column_macros
|
||||
locate_agent
|
||||
|
@ -1564,6 +1566,12 @@ sub pandora_execute_action ($$$$$$$$$;$) {
|
|||
|
||||
# Integria IMS Ticket
|
||||
} elsif ($clean_name eq "Integria IMS Ticket") {
|
||||
my $config_integria_enabled = pandora_get_tconfig_token ($dbh, 'integria_enabled', '');
|
||||
|
||||
if (!$config_integria_enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
my $config_api_path = pandora_get_tconfig_token ($dbh, 'integria_hostname', '');
|
||||
my $config_api_pass = pandora_get_tconfig_token ($dbh, 'integria_api_pass', '');
|
||||
my $config_integria_user = pandora_get_tconfig_token ($dbh, 'integria_user', '');
|
||||
|
@ -1575,6 +1583,19 @@ 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 (Integria IMS API path)
|
||||
my $api_path = $config_api_path . "/integria/include/api.php";
|
||||
|
@ -1627,7 +1648,28 @@ sub pandora_execute_action ($$$$$$$$$;$) {
|
|||
# Field 7 (Ticket description);
|
||||
my $ticket_description = safe_output($field7);
|
||||
|
||||
pandora_create_integria_ticket($pa_config, $api_path, $api_pass, $integria_user, $integria_user_pass, $ticket_name, $ticket_group_id, $ticket_priority, $ticket_owner, $ticket_type, $ticket_status, $ticket_description);
|
||||
my $create_wu_on_close_recovery = 0;
|
||||
|
||||
if ($alert_mode == RECOVERED_ALERT && $action->{'create_wu_integria'} == '1') {
|
||||
$create_wu_on_close_recovery = 1;
|
||||
}
|
||||
|
||||
# Ticket type custom fields
|
||||
my $ticket_custom_field1 = $field8;
|
||||
my $ticket_custom_field2 = $field9;
|
||||
my $ticket_custom_field3 = $field10;
|
||||
my $ticket_custom_field4 = $field11;
|
||||
my $ticket_custom_field5 = $field12;
|
||||
my $ticket_custom_field6 = $field13;
|
||||
my $ticket_custom_field7 = $field14;
|
||||
my $ticket_custom_field8 = $field15;
|
||||
my $ticket_custom_field9 = $field16;
|
||||
my $ticket_custom_field10 = $field17;
|
||||
my $ticket_custom_field11 = $field18;
|
||||
my $ticket_custom_field12 = $field19;
|
||||
my $ticket_custom_field13 = $field20;
|
||||
|
||||
pandora_create_integria_ticket($pa_config, $api_path, $api_pass, $integria_user, $integria_user_pass, $agent->{'nombre'}, $agent->{'alias'}, $agent->{'id_os'}, $agent->{'direccion'}, $agent->{'id_agente'}, $agent->{'id_grupo'}, $ticket_name, $ticket_group_id, $ticket_priority, $ticket_owner, $ticket_type, $ticket_status, $ticket_description, $create_wu_on_close_recovery, $ticket_custom_field1, $ticket_custom_field2, $ticket_custom_field3, $ticket_custom_field4, $ticket_custom_field5, $ticket_custom_field6, $ticket_custom_field7, $ticket_custom_field8, $ticket_custom_field9, $ticket_custom_field10, $ticket_custom_field11, $ticket_custom_field12, $ticket_custom_field13);
|
||||
|
||||
# Generate notification
|
||||
} elsif ($clean_name eq "Generate Notification") {
|
||||
|
@ -3040,27 +3082,6 @@ sub pandora_module_keep_alive ($$$$$) {
|
|||
}
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
=head2 C<< pandora_create_incident (I<$pa_config>, I<$dbh>, I<$title>, I<$text>, I<$priority>, I<$status>, I<$origin>, I<$id_group>) >>
|
||||
|
||||
Create an internal Pandora incident.
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_create_incident ($$$$$$$$;$) {
|
||||
my ($pa_config, $dbh, $title, $text,
|
||||
$priority, $status, $origin, $id_group, $owner) = @_;
|
||||
|
||||
logger($pa_config, "Creating incident '$text' source '$origin'.", 8);
|
||||
|
||||
# Initialize default parameters
|
||||
$owner = '' unless defined ($owner);
|
||||
|
||||
db_do($dbh, 'INSERT INTO tincidencia (inicio, titulo, descripcion, origen, estado, prioridad, id_grupo, id_usuario)
|
||||
VALUES (NOW(), ?, ?, ?, ?, ?, ?, ?)', $title, $text, $origin, $status, $priority, $id_group, $owner);
|
||||
}
|
||||
|
||||
|
||||
##########################################################################
|
||||
=head2 C<< pandora_audit (I<$pa_config>, I<$description>, I<$name>, I<$action>, I<$dbh>) >>
|
||||
|
||||
|
@ -6213,30 +6234,61 @@ sub pandora_edit_custom_graph ($$$$$$$$$$$) {
|
|||
return $res;
|
||||
}
|
||||
|
||||
sub pandora_create_integria_ticket ($$$$$$$$$$$) {
|
||||
my ($pa_config,$api_path,$api_pass,$integria_user,$user_pass,$ticket_name,$ticket_group_id,$ticket_priority,$ticket_owner,$ticket_type,$ticket_status,$ticket_description) = @_;
|
||||
sub pandora_create_integria_ticket ($$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$) {
|
||||
my ($pa_config,$api_path,$api_pass,$integria_user,$user_pass,$agent_name,$agent_alias,$agent_os,$agent_addr,$agent_id,$agent_group,$ticket_name,$ticket_group_id,$ticket_priority,$ticket_owner,$ticket_type,$ticket_status,$ticket_description, $create_wu_on_close_recovery, $ticket_custom_field1, $ticket_custom_field2, $ticket_custom_field3, $ticket_custom_field4, $ticket_custom_field5, $ticket_custom_field6, $ticket_custom_field7, $ticket_custom_field8, $ticket_custom_field9, $ticket_custom_field10, $ticket_custom_field11, $ticket_custom_field12, $ticket_custom_field13) = @_;
|
||||
|
||||
use URI::URL;
|
||||
use URI::Escape;
|
||||
use HTML::Entities;
|
||||
|
||||
my $data_ticket;
|
||||
my $call_api;
|
||||
|
||||
$data_ticket = $ticket_name .
|
||||
my $uri = URI->new($api_path);
|
||||
|
||||
if ($uri->scheme eq "") {
|
||||
$api_path = "http://" . $api_path;
|
||||
}
|
||||
|
||||
my $ticket_create_wu = 0;
|
||||
|
||||
if ($create_wu_on_close_recovery == 1 && $ticket_status eq '7') {
|
||||
$ticket_create_wu = 1;
|
||||
}
|
||||
|
||||
$data_ticket = $agent_name .
|
||||
"|;|" . uri_escape(decode_entities($agent_alias)) .
|
||||
"|;|" . $agent_os .
|
||||
"|;|" . $agent_addr .
|
||||
"|;|" . $agent_id .
|
||||
"|;|" . $agent_group .
|
||||
"|;|" . $ticket_name .
|
||||
"|;|" . $ticket_group_id .
|
||||
"|;|" . $ticket_priority .
|
||||
"|;|" . $ticket_description .
|
||||
"|;|" .
|
||||
"|;|" . $ticket_type .
|
||||
"|;|" .
|
||||
"|;|" . $ticket_owner .
|
||||
"|;|" .
|
||||
"|;|" . $ticket_status .
|
||||
"|;|" .
|
||||
"|;|";
|
||||
|
||||
"|;|" . $ticket_create_wu .
|
||||
"|;|" . $ticket_custom_field1 .
|
||||
"|;|" . $ticket_custom_field2 .
|
||||
"|;|" . $ticket_custom_field3 .
|
||||
"|;|" . $ticket_custom_field4 .
|
||||
"|;|" . $ticket_custom_field5 .
|
||||
"|;|" . $ticket_custom_field6 .
|
||||
"|;|" . $ticket_custom_field7 .
|
||||
"|;|" . $ticket_custom_field8 .
|
||||
"|;|" . $ticket_custom_field9 .
|
||||
"|;|" . $ticket_custom_field10 .
|
||||
"|;|" . $ticket_custom_field11 .
|
||||
"|;|" . $ticket_custom_field12 .
|
||||
"|;|" . $ticket_custom_field13;
|
||||
|
||||
$call_api = $api_path . '?' .
|
||||
'user=' . $integria_user . '&' .
|
||||
'user_pass=' . $user_pass . '&' .
|
||||
'pass=' . $api_pass . '&' .
|
||||
'op=create_incident&' .
|
||||
'op=create_pandora_ticket&' .
|
||||
'params=' . $data_ticket .'&' .
|
||||
'token=|;|';
|
||||
|
||||
|
@ -6250,6 +6302,86 @@ sub pandora_create_integria_ticket ($$$$$$$$$$$) {
|
|||
}
|
||||
}
|
||||
|
||||
sub pandora_sync_agents_integria ($) {
|
||||
my ($dbh) = @_;
|
||||
|
||||
my $config_integria_enabled = pandora_get_tconfig_token ($dbh, 'integria_enabled', '');
|
||||
|
||||
if (!$config_integria_enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
my $config_api_path = pandora_get_tconfig_token ($dbh, 'integria_hostname', '');
|
||||
my $config_api_pass = pandora_get_tconfig_token ($dbh, 'integria_api_pass', '');
|
||||
my $config_integria_user = pandora_get_tconfig_token ($dbh, 'integria_user', '');
|
||||
my $config_integria_user_pass = pandora_get_tconfig_token ($dbh, 'integria_pass', '');
|
||||
|
||||
my $api_path = $config_api_path . "/integria/include/api.php";
|
||||
|
||||
my @agents_string = '';
|
||||
my @agents = get_db_rows ($dbh, 'SELECT * FROM tagente');
|
||||
|
||||
my @agents_array = ();
|
||||
my $agents_string = '';
|
||||
|
||||
foreach my $agent (@agents) {
|
||||
push @agents_array, $agent->{'nombre'} .
|
||||
"|;|" .
|
||||
$agent->{'alias'} .
|
||||
"|;|" .
|
||||
$agent->{'id_os'} .
|
||||
"|;|" .
|
||||
$agent->{'direccion'} .
|
||||
"|;|" .
|
||||
$agent->{'id_grupo'};
|
||||
}
|
||||
|
||||
my $ua = LWP::UserAgent->new();
|
||||
my $response = $ua->post( $api_path, {
|
||||
'user' => $config_integria_user,
|
||||
'user_pass' => $config_integria_user_pass,
|
||||
'pass' => $config_api_pass,
|
||||
'op' => 'sync_pandora_agents_inventory',
|
||||
'params[]' => [@agents_array],
|
||||
'token' => '|;|'
|
||||
});
|
||||
|
||||
my $content = $response->decoded_content();
|
||||
|
||||
if (defined $content && is_numeric($content) && $content ne "-1") {
|
||||
return $content;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
sub pandora_get_integria_ticket_types($) {
|
||||
my ($dbh) = @_;
|
||||
|
||||
my $config_api_path = pandora_get_tconfig_token ($dbh, 'integria_hostname', '');
|
||||
my $config_api_pass = pandora_get_tconfig_token ($dbh, 'integria_api_pass', '');
|
||||
my $config_integria_user = pandora_get_tconfig_token ($dbh, 'integria_user', '');
|
||||
my $config_integria_user_pass = pandora_get_tconfig_token ($dbh, 'integria_pass', '');
|
||||
|
||||
my $api_path = $config_api_path . "/integria/include/api.php";
|
||||
|
||||
my $call_api = $api_path . '?' .
|
||||
'user=' . $config_integria_user . '&' .
|
||||
'user_pass=' . $config_integria_user_pass . '&' .
|
||||
'pass=' . $config_api_pass . '&' .
|
||||
'op=get_types&' .
|
||||
'return_type=json';
|
||||
|
||||
my $content = get($call_api);
|
||||
|
||||
my @decoded_json;
|
||||
@decoded_json = @{decode_json($content)} if (defined $content && $content ne "");
|
||||
|
||||
return @decoded_json;
|
||||
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
=head2 C<< pandora_input_password (I<$pa_config>, I<$password>) >>
|
||||
|
||||
|
|
|
@ -1169,6 +1169,24 @@ if (defined($history_dbh)) {
|
|||
|
||||
}
|
||||
|
||||
# Keep integrity between PandoraFMS agents and IntegriaIMS inventory objects.
|
||||
pandora_sync_agents_integria($dbh);
|
||||
|
||||
# Get Integria IMS ticket types for alert commands.
|
||||
my @types = pandora_get_integria_ticket_types($dbh);
|
||||
|
||||
if (scalar(@types) != 0) {
|
||||
my $query_string = '';
|
||||
foreach my $type (@types) {
|
||||
$query_string .= $type->{'id'} . ',' . $type->{'name'} . ';';
|
||||
}
|
||||
|
||||
$query_string = substr $query_string, 0, -1;
|
||||
|
||||
db_do($dbh, "UPDATE talert_commands SET fields_descriptions='[\"Ticket title\",\"Ticket group ID\",\"Ticket priority\",\"Ticket owner\",\"Ticket type\",\"Ticket status\",\"Ticket description\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\"]' WHERE name=\"Integria IMS Ticket\"");
|
||||
db_do($dbh, "UPDATE talert_commands SET fields_values='[\"\", \"\", \"\",\"\",\"" . $query_string . "\",\"\",\"\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\"]' WHERE name=\"Integria IMS Ticket\"");
|
||||
}
|
||||
|
||||
# Release the lock
|
||||
if ($lock == 1) {
|
||||
db_release_lock ($dbh, $lock_name);
|
||||
|
|
|
@ -202,8 +202,6 @@ sub help_screen{
|
|||
help_screen_line('--validate_event_id', '<event_id>', 'Validate event given a event id');
|
||||
help_screen_line('--get_event_info', '<event_id>[<csv_separator>]', 'Show info about a event given a event id');
|
||||
help_screen_line('--add_event_comment', '<event_id> <user_name> <comment>', 'Add event\'s comment');
|
||||
print "\nINCIDENTS:\n\n" unless $param ne '';
|
||||
help_screen_line('--create_incident', "<title> <description> <origin> <status> <priority 0 for Informative, \n\t 1 for Low, 2 for Medium, 3 for Serious, 4 for Very serious or 5 for Maintenance>\n\t <group> [<owner>]", 'Create incidents');
|
||||
print "\nPOLICIES:\n\n" unless $param ne '';
|
||||
help_screen_line('--apply_policy', '<id_policy> [<id_agent> <name(boolean)> <id_server>]', 'Force apply a policy in an agent');
|
||||
help_screen_line('--apply_all_policies', '', 'Force apply to all the policies');
|
||||
|
@ -4364,21 +4362,6 @@ sub cli_add_event_comment() {
|
|||
pandora_update_event_from_hash ($update, 'id_evento', $id_event, $dbh);
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
# Create incident.
|
||||
# Related option: --create_incident
|
||||
##############################################################################
|
||||
|
||||
sub cli_create_incident() {
|
||||
my ($title, $description, $origin, $status, $priority, $group_name, $owner) = @ARGV[2..8];
|
||||
|
||||
my $id_group = get_group_id($dbh,$group_name);
|
||||
exist_check($id_group,'group',$group_name);
|
||||
|
||||
pandora_create_incident ($conf, $dbh, $title, $description, $priority, $status, $origin, $id_group, $owner);
|
||||
print_log "[INFO] Creating incident '$title'\n\n";
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
# Delete data.
|
||||
# Related option: --delete_data
|
||||
|
@ -7392,10 +7375,6 @@ sub pandora_manage_main ($$$) {
|
|||
param_check($ltotal, 3);
|
||||
cli_add_event_comment();
|
||||
}
|
||||
elsif ($param eq '--create_incident') {
|
||||
param_check($ltotal, 7, 1);
|
||||
cli_create_incident();
|
||||
}
|
||||
elsif ($param eq '--delete_data') {
|
||||
param_check($ltotal, 4, 2);
|
||||
cli_delete_data($ltotal);
|
||||
|
|
|
@ -136,13 +136,6 @@ sub recon_scan($$) {
|
|||
|
||||
# Mark the recon task as done.
|
||||
update_recon_task ($DBH, $task->{'id_rt'}, -1);
|
||||
|
||||
# Create an incident.
|
||||
if (defined($ADDED_HOSTS[0]) && $task->{'create_incident'} == 1) {
|
||||
my $text = "At " . strftime ("%Y-%m-%d %H:%M:%S", localtime()) . " (". scalar(@ADDED_HOSTS) . ") new hosts were detected by Pandora FMS WMI Recon Script running on [" . $CONF{'servername'} . "_Recon]. This incident has been automatically created following instructions for this recon task [" . $task->{'id_group'} . "].\n\n";
|
||||
$text .= "\n\nThis is the list of IP addresses found: \n\n" . join(',', @ADDED_HOSTS);
|
||||
pandora_create_incident (\%CONF, $DBH, "[RECON] New hosts detected", $text, 0, 0, 'Pandora FMS Recon Server', $task->{'id_group'});
|
||||
}
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
|
@ -369,6 +362,5 @@ die("Error retrieving recon task ID $TASK_ID\n") unless defined($task);
|
|||
# Scan!
|
||||
$task->{'subnet'} = $NETWORKS;
|
||||
$task->{'id_group'} = $GROUP_ID;
|
||||
$task->{'create_incident'} = $CREATE_INCIDENT;
|
||||
recon_scan($task, \&wmi_scan);
|
||||
|
||||
|
|
Loading…
Reference in New Issue