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 .= '
'.html_print_image('images/heart.png', true).'
'.html_print_image('images/builder.png', true).'
'.html_print_image('images/user_green.png', true).'
-
'.ui_print_integria_incident_priority($priority, $priority_incident[$priority]).'
+
'.ui_print_integria_incident_priority($priority, $priority_text).'
'.html_print_image('images/incidents.png', true).'
'; $details_box .= '
'.$status_text.'
@@ -194,7 +162,14 @@ echo '
'; echo '
'; // Show description. -$description_box = '
'.$description.'
'; +$description_box = '
'.html_print_textarea( + 'integria_details_description', + 3, + 0, + $description, + 'disabled="disabled"', + true +).'
'; ui_toggle($description_box, __('Description'), '', '', false); ?> diff --git a/pandora_console/operation/incidents/integriaims_export_csv.php b/pandora_console/operation/incidents/integriaims_export_csv.php index c474b3eb94..03a038e58a 100644 --- a/pandora_console/operation/incidents/integriaims_export_csv.php +++ b/pandora_console/operation/incidents/integriaims_export_csv.php @@ -16,6 +16,7 @@ global $config; require_once '../../include/config.php'; require_once '../../include/functions.php'; +require_once '../../include/functions_integriaims.php'; check_login(); @@ -26,25 +27,12 @@ if (! check_acl($config['id_user'], 0, 'IR') && ! check_acl($config['id_user'], exit; } -// 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); -// 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); - -// 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); - -// 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); +// API calls. +$status_incident = integriaims_get_details('status'); +$group_incident = integriaims_get_details('group'); +$priority_incident = integriaims_get_details('priority'); +$resolution_incident = integriaims_get_details('resolution'); // Get data to export. @@ -82,26 +70,29 @@ foreach ($tickets_csv_array as $key => $value) { } $tickets_csv_array_filter[$key] = [ - 'id_incidencia' => $tickets_csv_array[$key][0], - 'titulo' => $tickets_csv_array[$key][3], - 'id_grupo' => $tickets_csv_array[$key][8], - 'estado_resolution' => $tickets_csv_array[$key][6].' / '.$tickets_csv_array[$key][12], - 'prioridad' => $tickets_csv_array[$key][7], - 'actualizacion' => $tickets_csv_array[$key][9], - 'id_creator' => $tickets_csv_array[$key][10], - 'owner' => $tickets_csv_array[$key][5], + 'id_incidencia' => $tickets_csv_array[$key][0], + 'titulo' => $tickets_csv_array[$key][3], + 'id_grupo' => $tickets_csv_array[$key][8], + 'estado' => $tickets_csv_array[$key][6], + 'resolution' => $tickets_csv_array[$key][12], + 'prioridad' => $tickets_csv_array[$key][7], + 'actualizacion' => $tickets_csv_array[$key][9], + 'inicio' => $tickets_csv_array[$key][1], + 'id_creator' => $tickets_csv_array[$key][10], + 'owner' => $tickets_csv_array[$key][5], ]; } - // Header for CSV file. $header = [ __('ID Ticket'), __('Title'), __('Group/Company'), - __('Status/Resolution'), + __('Status'), + __('Resolution'), __('Priority'), - __('Updated/Started'), + __('Updated'), + __('Started'), __('Creator'), __('Owner'), ]; diff --git a/pandora_console/operation/incidents/list_integriaims_incidents.php b/pandora_console/operation/incidents/list_integriaims_incidents.php index 0dd2bd20a4..e22d6c5f43 100644 --- a/pandora_console/operation/incidents/list_integriaims_incidents.php +++ b/pandora_console/operation/incidents/list_integriaims_incidents.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')) { @@ -23,7 +25,9 @@ if (! check_acl($config['id_user'], 0, 'IR') && ! check_acl($config['id_user'], exit; } -ui_print_page_header(__('Integria IMS Incidents'), '', false, '', false, ''); +// Header tabs. +$onheader = integriaims_tabs('list_tab'); +ui_print_page_header(__('Integria IMS Incidents'), '', false, '', false, $onheader); // Check if Integria integration enabled. if ($config['integria_enabled'] == 0) { @@ -84,25 +88,11 @@ $url = ui_get_full_url( // ---- FILTERS ---- // API calls to fill the filters. -// 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); +$status_incident = integriaims_get_details('status'); +$group_incident = integriaims_get_details('group'); +$priority_incident = integriaims_get_details('priority'); +$resolution_incident = integriaims_get_details('resolution'); -// 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); - -// 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); - -// 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); // TABLE FILTERS. $table = new StdClass(); @@ -230,8 +220,7 @@ $integria_incidents_form .= '
'.html_print_submit_button(__('Filter'), 'filt $integria_incidents_form .= '
'; $integria_incidents_form .= ''; -// ui_toggle($integria_incidents_form, __('Add Custom filter')); -echo $integria_incidents_form; +ui_toggle($integria_incidents_form, __('Add Custom filter'), '', '', false); /* * Order api call 'get_incidents'. @@ -315,8 +304,12 @@ foreach ($incidents_paginated as $key => $value) { // Show table incidents. ui_pagination(count($array_get_incidents), $url, $offset); -html_print_table($table); -ui_pagination(count($array_get_incidents), $url, $offset, 0, false, 'offset', true, 'pagination-bottom'); +if (empty($table->data) === true) { + ui_print_info_message(['no_close' => true, 'message' => __('No incidents to show').'.' ]); +} else { + html_print_table($table); + ui_pagination(count($array_get_incidents), $url, $offset, 0, false, 'offset', true, 'pagination-bottom'); +} // Show button to create incident. if (check_acl($config['id_user'], 0, 'IR')) {