diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 1ff10f91b5..78297c4f3c 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -5412,7 +5412,6 @@ function get_help_info($section_name) break; } - // hd($result); return $result; } @@ -5456,7 +5455,7 @@ if (!function_exists('getallheaders')) { function integria_api_call($api_hostname, $user, $user_pass, $api_pass, $operation, $params_array=[], $show_credentials_error_msg=false) { $params_string = implode(',', $params_array); - hd($params_string, true); + $url_data = [ 'user' => $user, 'user_pass' => $user_pass, diff --git a/pandora_console/include/functions_integriaims.php b/pandora_console/include/functions_integriaims.php new file mode 100644 index 0000000000..c121572a73 --- /dev/null +++ b/pandora_console/include/functions_integriaims.php @@ -0,0 +1,145 @@ +'.html_print_image('images/setup.png', true, ['title' => __('Configure Integria IMS')]).''; + $list_tab['text'] = ''.html_print_image('images/list.png', true, ['title' => __('List incidents')]).''; + $create_tab['text'] = ''.html_print_image('images/pencil.png', true, ['title' => __('New incident')]).''; + + if ($active_tab) { + switch ($active_tab) { + case 'setup_tab': + $setup_tab['active'] = true; + $list_tab['active'] = false; + $create_tab['active'] = false; + break; + + case 'list_tab': + $setup_tab['active'] = false; + $list_tab['active'] = true; + $create_tab['active'] = false; + break; + + case 'create_tab': + $setup_tab['active'] = false; + $list_tab['active'] = false; + $create_tab['active'] = true; + break; + + case is_numeric($active_tab): + $create_tab['text'] = ''.html_print_image('images/pencil.png', true, ['title' => __('Edit incident')]).''; + $view_tab['text'] = ''.html_print_image('images/operation.png', true, ['title' => __('View incident')]).''; + $setup_tab['active'] = false; + $list_tab['active'] = false; + $create_tab['active'] = false; + $view_tab['active'] = true; + break; + + default: + $setup_tab['active'] = false; + $list_tab['active'] = false; + $create_tab['active'] = false; + break; + } + } else { + $setup_tab['active'] = false; + $list_tab['active'] = false; + $create_tab['active'] = false; + } + + $onheader = [ + 'view' => $view_tab, + 'configure' => $setup_tab, + 'list' => $list_tab, + 'create' => $create_tab, + ]; + + return $onheader; +} + + +/** + * Gets all the details of Integria IMS API + * + * @param string $details Type of API call. + * @param number $detail_index Send index if you want return the text. + * + * @return string or array with result of API call. + */ +function integriaims_get_details($details, $detail_index=false) +{ + global $config; + + switch ($details) { + case 'status': + $operation = 'get_incidents_status'; + break; + + case 'group': + $operation = 'get_groups'; + break; + + case 'priority': + $operation = 'get_incident_priorities'; + break; + + case 'resolution': + $operation = 'get_incidents_resolutions'; + break; + + case 'type': + $operation = 'get_types'; + break; + + default: + // code... + break; + } + + $api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], $operation); + $result = []; + get_array_from_csv_data_pair($api_call, $result); + + if ($detail_index !== false) { + if ($result[$detail_index] == '' || $result[$detail_index] === null) { + return __('None'); + } else { + return $result[$detail_index]; + } + } else { + return $result; + } +} diff --git a/pandora_console/include/styles/integriaims.css b/pandora_console/include/styles/integriaims.css index 420873c90c..59f424f8ab 100644 --- a/pandora_console/include/styles/integriaims.css +++ b/pandora_console/include/styles/integriaims.css @@ -13,7 +13,7 @@ div.priority { div.integria_details { display: grid; grid-column-gap: 10px; - grid-template-columns: repeat(3, 1fr); + grid-template-columns: repeat(3, minmax(min-content, auto)); grid-auto-rows: 1fr; } @@ -47,11 +47,12 @@ div.integria_details_row_three { div.integria_details_description { width: 100%; +} + +div.integria_details_description textarea { + width: 100%; background-color: #fbfbfb; - border: 1px solid #cbcbcb; - border-radius: 3px; - padding: 5px 10px 5px 5px; - min-height: 100px; + resize: vertical; } .integriaims_details_box { diff --git a/pandora_console/operation/incidents/configure_integriaims_incident.php b/pandora_console/operation/incidents/configure_integriaims_incident.php index 4620fd8d02..356bbbdcd4 100644 --- a/pandora_console/operation/incidents/configure_integriaims_incident.php +++ b/pandora_console/operation/incidents/configure_integriaims_incident.php @@ -14,6 +14,8 @@ // Load global vars global $config; +require_once 'include/functions_integriaims.php'; + check_login(); if (!(check_acl($config['id_user'], 0, 'IW') && check_acl($config['id_user'], 0, 'IR'))) { @@ -25,10 +27,11 @@ if (!(check_acl($config['id_user'], 0, 'IW') && check_acl($config['id_user'], 0, $update = (isset($_GET['incident_id']) === true); +$onheader = integriaims_tabs('create_tab'); if ($update) { - ui_print_page_header(__('Update Integria IMS Incident'), '', false, '', false, ''); + ui_print_page_header(__('Update Integria IMS Incident'), '', false, '', false, $onheader); } else { - ui_print_page_header(__('Create Integria IMS Incident'), '', false, '', false, ''); + ui_print_page_header(__('Create Integria IMS Incident'), '', false, '', false, $onheader); } // Check if Integria integration enabled. diff --git a/pandora_console/operation/incidents/dashboard_detail_integriaims_incident.php b/pandora_console/operation/incidents/dashboard_detail_integriaims_incident.php index fb26b3b118..3ce47cb054 100644 --- a/pandora_console/operation/incidents/dashboard_detail_integriaims_incident.php +++ b/pandora_console/operation/incidents/dashboard_detail_integriaims_incident.php @@ -14,6 +14,8 @@ // Load global vars global $config; +require_once 'include/functions_integriaims.php'; + check_login(); if (! check_acl($config['id_user'], 0, 'IR') && ! check_acl($config['id_user'], 0, 'IW') && ! check_acl($config['id_user'], 0, 'IM')) { @@ -58,7 +60,11 @@ get_array_from_csv_data_all($result_api_call_list, $array_get_incidents); // Remove index (id) $array_get_incidents = $array_get_incidents[$incident_id]; -ui_print_page_header($array_get_incidents[3].__(' - Details'), '', false, '', false, ''); + +// Header tabs. +$onheader = integriaims_tabs($incident_id); +ui_print_page_header($array_get_incidents[3].' - '.__('Details'), '', false, '', false, $onheader); + // Data. $status = $array_get_incidents[6]; @@ -84,49 +90,11 @@ if ($closed_by == '') { // API calls. -// Get status. -$status_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incidents_status'); -$status_incident = []; -get_array_from_csv_data_pair($status_api_call, $status_incident); - -if ($status_incident[$status] == '') { - $status_text = __('None'); -} else { - $status_text = $status_incident[$status]; -} - -// Get group. -$group_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_groups'); -$group_incident = []; -get_array_from_csv_data_pair($group_api_call, $group_incident); -$group_text = $group_incident[$group]; - -// Get priority. -$priority_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_priorities'); -$priority_incident = []; -get_array_from_csv_data_pair($priority_api_call, $priority_incident); -$priority_text = $priority_incident[$priority]; - -// Get resolution. -$resolution_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incidents_resolutions'); -$resolution_incident = []; -get_array_from_csv_data_pair($resolution_api_call, $resolution_incident); - -if ($resolution_incident[$resolution] == '') { - $resolution_text = __('None'); -} else { - $resolution_text = $resolution_incident[$resolution]; -} - -// Get types. -$type_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_types'); -$type_incident = []; -get_array_from_csv_data_pair($type_api_call, $type_incident); -if ($type_incident[$type] == '') { - $type_text = __('None'); -} else { - $type_text = $type_incident[$type]; -} +$status_text = integriaims_get_details('status', $status); +$group_text = integriaims_get_details('group', $group); +$priority_text = integriaims_get_details('priority', $priority); +$resolution_text = integriaims_get_details('resolution', $resolution); +$type_text = integriaims_get_details('type', $type); // Details box. @@ -141,7 +109,7 @@ $details_box .= '