mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 16:24:54 +02:00
New view - List of Integria IMS tickets - #4642
This commit is contained in:
parent
ca6fe42298
commit
027f9fd9d4
@ -138,11 +138,11 @@ $integria_types_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($integria_groups_csv, $group_values);
|
get_array_from_csv_data_pair($integria_groups_csv, $group_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($integria_criticity_levels_csv, $integria_criticity_values);
|
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', []);
|
||||||
|
|
||||||
@ -156,7 +156,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($integria_types_csv, $integria_types_values);
|
get_array_from_csv_data_pair($integria_types_csv, $integria_types_values);
|
||||||
|
|
||||||
// Enable table.
|
// Enable table.
|
||||||
$table_enable = new StdClass();
|
$table_enable = new StdClass();
|
||||||
|
@ -5453,7 +5453,7 @@ if (!function_exists('getallheaders')) {
|
|||||||
*
|
*
|
||||||
* @return boolean True if API request succeeded, false if API request failed.
|
* @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_array=[], $show_credentials_error_msg=false)
|
||||||
{
|
{
|
||||||
$params_string = implode(',', $params_array);
|
$params_string = implode(',', $params_array);
|
||||||
|
|
||||||
@ -5506,7 +5506,7 @@ function integria_api_call($api_hostname, $user, $user_pass, $api_pass, $operati
|
|||||||
|
|
||||||
|
|
||||||
// Parse CSV consisting of one or more lines of the form key-value pair into an array.
|
// Parse CSV consisting of one or more lines of the form key-value pair into an array.
|
||||||
function get_array_from_csv_data($csv_data, &$array_values)
|
function get_array_from_csv_data_pair($csv_data, &$array_values)
|
||||||
{
|
{
|
||||||
$csv_array = explode("\n", $csv_data);
|
$csv_array = explode("\n", $csv_data);
|
||||||
|
|
||||||
@ -5520,3 +5520,81 @@ function get_array_from_csv_data($csv_data, &$array_values)
|
|||||||
$array_values[$new_csv_value[0]] = $new_csv_value[1];
|
$array_values[$new_csv_value[0]] = $new_csv_value[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse CSV consisting of one or more lines of the form key-value pair into an array.
|
||||||
|
*
|
||||||
|
* @param string $csv_data Data returned of csv api call.
|
||||||
|
* @param string $array_values Returned array.
|
||||||
|
* @param array $index Array to create an associative index (opcional).
|
||||||
|
*/
|
||||||
|
function get_array_from_csv_data_all($csv_data, &$array_values, $index=false)
|
||||||
|
{
|
||||||
|
$csv_array = explode("\n", $csv_data);
|
||||||
|
|
||||||
|
foreach ($csv_array as $csv_value) {
|
||||||
|
if (empty($csv_value)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$new_csv_value = str_getcsv($csv_value);
|
||||||
|
|
||||||
|
if ($index !== false) {
|
||||||
|
foreach ($new_csv_value as $key => $value) {
|
||||||
|
$new_csv_value_index[$index[$key]] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
$array_values[$new_csv_value[0]] = $new_csv_value_index;
|
||||||
|
} else {
|
||||||
|
$array_values[$new_csv_value[0]] = $new_csv_value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print priority for Integria IMS with colors.
|
||||||
|
*
|
||||||
|
* @param string $priority value of priority in Integria IMS.
|
||||||
|
* @param string $priority_label text shown in color box.
|
||||||
|
*
|
||||||
|
* @return HTML code to print the color box.
|
||||||
|
*/
|
||||||
|
function ui_print_integria_incident_priority($priority, $priority_label)
|
||||||
|
{
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
$output = '';
|
||||||
|
switch ($priority) {
|
||||||
|
case 0:
|
||||||
|
$color = COL_UNKNOWN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
$color = COL_NORMAL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 10:
|
||||||
|
$color = COL_NOTINIT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
$color = COL_WARNING;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
$color = COL_ALERTFIRED;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
$color = COL_CRITICAL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output = '<div class="priority" style="background: '.$color.'">';
|
||||||
|
$output .= $priority_label;
|
||||||
|
$output .= '</div>';
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
@ -3356,3 +3356,108 @@ function html_print_input($data, $wrapper='div', $input_only=false)
|
|||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print an autocomplete input filled out with Integria IMS users.
|
||||||
|
*
|
||||||
|
* @param string $name The name of ajax control, by default is "users".
|
||||||
|
* @param string $default The default value to show in the ajax control.
|
||||||
|
* @param boolean $return If it is true return a string with the output instead to echo the output.
|
||||||
|
* @param string $size Size.
|
||||||
|
*
|
||||||
|
* @return mixed If the $return is true, return the output as string.
|
||||||
|
*/
|
||||||
|
function html_print_autocomplete_users_from_integria(
|
||||||
|
$name='users',
|
||||||
|
$default='',
|
||||||
|
$return=false,
|
||||||
|
$size='30'
|
||||||
|
) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
|
||||||
|
html_print_input_text_extended(
|
||||||
|
$name,
|
||||||
|
$default,
|
||||||
|
'text-'.$name,
|
||||||
|
'',
|
||||||
|
$size,
|
||||||
|
100,
|
||||||
|
false,
|
||||||
|
'',
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
html_print_input_hidden($name.'_hidden', $id_agent_module);
|
||||||
|
ui_print_help_tip(__('Type at least two characters to search the module.'), false);
|
||||||
|
|
||||||
|
$javascript_ajax_page = ui_get_full_url('ajax.php', false, false, false, false);
|
||||||
|
?>
|
||||||
|
<script type="text/javascript">
|
||||||
|
function escapeHTML (str)
|
||||||
|
{
|
||||||
|
var div = document.createElement('div');
|
||||||
|
var text = document.createTextNode(str);
|
||||||
|
div.appendChild(text);
|
||||||
|
return div.innerHTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready (function () {
|
||||||
|
$("#text-<?php echo $name; ?>").autocomplete({
|
||||||
|
minLength: 2,
|
||||||
|
source: function( request, response ) {
|
||||||
|
var term = request.term; //Word to search
|
||||||
|
|
||||||
|
data_params = {
|
||||||
|
page: "include/ajax/integria_incidents.ajax",
|
||||||
|
search_term: term,
|
||||||
|
get_users: 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
jQuery.ajax ({
|
||||||
|
data: data_params,
|
||||||
|
async: false,
|
||||||
|
type: "POST",
|
||||||
|
url: action="<?php echo $javascript_ajax_page; ?>",
|
||||||
|
timeout: 10000,
|
||||||
|
dataType: "json",
|
||||||
|
success: function (data) {
|
||||||
|
console.log(data);
|
||||||
|
temp = [];
|
||||||
|
$.each(data, function (id, module) {
|
||||||
|
temp.push({
|
||||||
|
'value' : id,
|
||||||
|
'label' : module});
|
||||||
|
});
|
||||||
|
|
||||||
|
response(temp);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
change: function( event, ui ) {
|
||||||
|
if (!ui.item)
|
||||||
|
$("input[name='<?php echo $name; ?>_hidden']")
|
||||||
|
.val(0);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
select: function( event, ui ) {
|
||||||
|
$("input[name='<?php echo $name; ?>_hidden']")
|
||||||
|
.val(ui.item.value);
|
||||||
|
|
||||||
|
$("#text-<?php echo $name; ?>").val( ui.item.label );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
$output = ob_get_clean();
|
||||||
|
|
||||||
|
if ($return) {
|
||||||
|
return $output;
|
||||||
|
} else {
|
||||||
|
echo $output;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -5884,3 +5884,14 @@ table.table_modal_alternate tr td:first-child {
|
|||||||
.fullwidth {
|
.fullwidth {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Class for integria incidents */
|
||||||
|
div.priority {
|
||||||
|
width: 80px;
|
||||||
|
color: #fff;
|
||||||
|
text-align: center;
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 5px;
|
||||||
|
display: table-cell;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
@ -47,11 +47,11 @@ $integria_types_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($integria_groups_csv, $group_values);
|
get_array_from_csv_data_pair($integria_groups_csv, $group_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($integria_criticity_levels_csv, $integria_criticity_values);
|
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', []);
|
||||||
|
|
||||||
@ -65,7 +65,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($integria_types_csv, $integria_types_values);
|
get_array_from_csv_data_pair($integria_types_csv, $integria_types_values);
|
||||||
|
|
||||||
$event_id = (int) get_parameter('from_event');
|
$event_id = (int) get_parameter('from_event');
|
||||||
$create_incident = (int) get_parameter('create_incident', 0);
|
$create_incident = (int) get_parameter('create_incident', 0);
|
||||||
|
@ -480,6 +480,7 @@ if (check_acl($config['id_user'], 0, 'IR')
|
|||||||
$sub2['operation/incidents/incident']['text'] = __('List of Incidents');
|
$sub2['operation/incidents/incident']['text'] = __('List of Incidents');
|
||||||
$sub2[$sec2sub]['text'] = __('Statistics');
|
$sub2[$sec2sub]['text'] = __('Statistics');
|
||||||
$sub2['operation/incidents/configure_integriaims_incident']['text'] = __('Create Integria IMS Incident');
|
$sub2['operation/incidents/configure_integriaims_incident']['text'] = __('Create Integria IMS Incident');
|
||||||
|
$sub2['operation/incidents/list_integriaims_incidents']['text'] = __('Integria IMS Incidents');
|
||||||
|
|
||||||
$sub[$sec2]['sub2'] = $sub2;
|
$sub[$sec2]['sub2'] = $sub2;
|
||||||
$sec2 = $temp_sec2;
|
$sec2 = $temp_sec2;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user