added comment management and fixed some errors in incident edition
This commit is contained in:
parent
e09db0b9a9
commit
0df2447770
|
@ -5456,7 +5456,7 @@ if (!function_exists('getallheaders')) {
|
||||||
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);
|
||||||
|
hd($params_string, true);
|
||||||
$url_data = [
|
$url_data = [
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
'user_pass' => $user_pass,
|
'user_pass' => $user_pass,
|
||||||
|
|
|
@ -6651,7 +6651,6 @@ function events_get_field_value_by_event_id(
|
||||||
) {
|
) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
$return = '';
|
|
||||||
$meta = false;
|
$meta = false;
|
||||||
$event = db_get_row('tevento', 'id_evento', $event_id);
|
$event = db_get_row('tevento', 'id_evento', $event_id);
|
||||||
|
|
||||||
|
@ -6674,11 +6673,11 @@ function events_get_field_value_by_event_id(
|
||||||
$ip = __('N/A');
|
$ip = __('N/A');
|
||||||
}
|
}
|
||||||
|
|
||||||
$return = str_replace('_agent_address_', $ip, $value);
|
$value = str_replace('_agent_address_', $ip, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($value, '_agent_id_') !== false) {
|
if (strpos($value, '_agent_id_') !== false) {
|
||||||
$return = str_replace('_agent_id_', $event['id_agente'], $value);
|
$value = str_replace('_agent_id_', $event['id_agente'], $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($value, '_module_address_') !== false) {
|
if (strpos($value, '_module_address_') !== false) {
|
||||||
|
@ -6693,7 +6692,7 @@ function events_get_field_value_by_event_id(
|
||||||
$module['ip_target'] = __('N/A');
|
$module['ip_target'] = __('N/A');
|
||||||
}
|
}
|
||||||
|
|
||||||
$return = str_replace('_module_address_', $module['ip_target'], $value);
|
$value = str_replace('_module_address_', $module['ip_target'], $value);
|
||||||
if (empty($module['nombre'])) {
|
if (empty($module['nombre'])) {
|
||||||
$module['nombre'] = __('N/A');
|
$module['nombre'] = __('N/A');
|
||||||
}
|
}
|
||||||
|
@ -6702,7 +6701,7 @@ function events_get_field_value_by_event_id(
|
||||||
metaconsole_restore_db();
|
metaconsole_restore_db();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$return = str_replace('_module_address_', __('N/A'), $value);
|
$value = str_replace('_module_address_', __('N/A'), $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6718,7 +6717,7 @@ function events_get_field_value_by_event_id(
|
||||||
$module['ip_target'] = __('N/A');
|
$module['ip_target'] = __('N/A');
|
||||||
}
|
}
|
||||||
|
|
||||||
$return = str_replace(
|
$value = str_replace(
|
||||||
'_module_name_',
|
'_module_name_',
|
||||||
io_safe_output($module['nombre']),
|
io_safe_output($module['nombre']),
|
||||||
$value
|
$value
|
||||||
|
@ -6728,28 +6727,28 @@ function events_get_field_value_by_event_id(
|
||||||
metaconsole_restore_db();
|
metaconsole_restore_db();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$return = str_replace('_module_name_', __('N/A'), $value);
|
$value = str_replace('_module_name_', __('N/A'), $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($value, '_event_id_') !== false) {
|
if (strpos($value, '_event_id_') !== false) {
|
||||||
$return = str_replace('_event_id_', $event['id_evento'], $value);
|
$value = str_replace('_event_id_', $event['id_evento'], $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($value, '_user_id_') !== false) {
|
if (strpos($value, '_user_id_') !== false) {
|
||||||
if (!empty($event['id_usuario'])) {
|
if (!empty($event['id_usuario'])) {
|
||||||
$return = str_replace('_user_id_', $event['id_usuario'], $value);
|
$value = str_replace('_user_id_', $event['id_usuario'], $value);
|
||||||
} else {
|
} else {
|
||||||
$return = str_replace('_user_id_', __('N/A'), $value);
|
$value = str_replace('_user_id_', __('N/A'), $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($value, '_group_id_') !== false) {
|
if (strpos($value, '_group_id_') !== false) {
|
||||||
$return = str_replace('_group_id_', $event['id_grupo'], $value);
|
$value = str_replace('_group_id_', $event['id_grupo'], $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($value, '_group_name_') !== false) {
|
if (strpos($value, '_group_name_') !== false) {
|
||||||
$return = str_replace(
|
$value = str_replace(
|
||||||
'_group_name_',
|
'_group_name_',
|
||||||
groups_get_name($event['id_grupo'], true),
|
groups_get_name($event['id_grupo'], true),
|
||||||
$value
|
$value
|
||||||
|
@ -6757,7 +6756,7 @@ function events_get_field_value_by_event_id(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($value, '_event_utimestamp_') !== false) {
|
if (strpos($value, '_event_utimestamp_') !== false) {
|
||||||
$return = str_replace(
|
$value = str_replace(
|
||||||
'_event_utimestamp_',
|
'_event_utimestamp_',
|
||||||
$event['utimestamp'],
|
$event['utimestamp'],
|
||||||
$value
|
$value
|
||||||
|
@ -6765,7 +6764,7 @@ function events_get_field_value_by_event_id(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($value, '_event_date_') !== false) {
|
if (strpos($value, '_event_date_') !== false) {
|
||||||
$return = str_replace(
|
$value = str_replace(
|
||||||
'_event_date_',
|
'_event_date_',
|
||||||
date($config['date_format'], $event['utimestamp']),
|
date($config['date_format'], $event['utimestamp']),
|
||||||
$value
|
$value
|
||||||
|
@ -6773,7 +6772,7 @@ function events_get_field_value_by_event_id(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($value, '_event_text_') !== false) {
|
if (strpos($value, '_event_text_') !== false) {
|
||||||
$return = str_replace(
|
$value = str_replace(
|
||||||
'_event_text_',
|
'_event_text_',
|
||||||
events_display_name($event['evento']),
|
events_display_name($event['evento']),
|
||||||
$value
|
$value
|
||||||
|
@ -6781,7 +6780,7 @@ function events_get_field_value_by_event_id(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($value, '_event_type_') !== false) {
|
if (strpos($value, '_event_type_') !== false) {
|
||||||
$return = str_replace(
|
$value = str_replace(
|
||||||
'_event_type_',
|
'_event_type_',
|
||||||
events_print_type_description($event['event_type'], true),
|
events_print_type_description($event['event_type'], true),
|
||||||
$value
|
$value
|
||||||
|
@ -6789,7 +6788,7 @@ function events_get_field_value_by_event_id(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($value, '_alert_id_') !== false) {
|
if (strpos($value, '_alert_id_') !== false) {
|
||||||
$return = str_replace(
|
$value = str_replace(
|
||||||
'_alert_id_',
|
'_alert_id_',
|
||||||
empty($event['is_alert_am']) ? __('N/A') : $event['is_alert_am'],
|
empty($event['is_alert_am']) ? __('N/A') : $event['is_alert_am'],
|
||||||
$value
|
$value
|
||||||
|
@ -6797,11 +6796,11 @@ function events_get_field_value_by_event_id(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($value, '_event_severity_id_') !== false) {
|
if (strpos($value, '_event_severity_id_') !== false) {
|
||||||
$return = str_replace('_event_severity_id_', $event['criticity'], $value);
|
$value = str_replace('_event_severity_id_', $event['criticity'], $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($value, '_event_severity_text_') !== false) {
|
if (strpos($value, '_event_severity_text_') !== false) {
|
||||||
$return = str_replace(
|
$value = str_replace(
|
||||||
'_event_severity_text_',
|
'_event_severity_text_',
|
||||||
get_priority_name($event['criticity']),
|
get_priority_name($event['criticity']),
|
||||||
$value
|
$value
|
||||||
|
@ -6809,27 +6808,27 @@ function events_get_field_value_by_event_id(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($value, '_module_id_') !== false) {
|
if (strpos($value, '_module_id_') !== false) {
|
||||||
$return = str_replace('_module_id_', $event['id_agentmodule'], $value);
|
$value = str_replace('_module_id_', $event['id_agentmodule'], $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($value, '_event_tags_') !== false) {
|
if (strpos($value, '_event_tags_') !== false) {
|
||||||
$return = str_replace('_event_tags_', $event['tags'], $value);
|
$value = str_replace('_event_tags_', $event['tags'], $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($value, '_event_extra_id_') !== false) {
|
if (strpos($value, '_event_extra_id_') !== false) {
|
||||||
if (empty($event['id_extra'])) {
|
if (empty($event['id_extra'])) {
|
||||||
$return = str_replace('_event_extra_id_', __('N/A'), $value);
|
$value = str_replace('_event_extra_id_', __('N/A'), $value);
|
||||||
} else {
|
} else {
|
||||||
$return = str_replace('_event_extra_id_', $event['id_extra'], $value);
|
$value = str_replace('_event_extra_id_', $event['id_extra'], $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($value, '_event_source_') !== false) {
|
if (strpos($value, '_event_source_') !== false) {
|
||||||
$return = str_replace('_event_source_', $event['source'], $value);
|
$value = str_replace('_event_source_', $event['source'], $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($value, '_event_instruction_') !== false) {
|
if (strpos($value, '_event_instruction_') !== false) {
|
||||||
$return = str_replace(
|
$value = str_replace(
|
||||||
'_event_instruction_',
|
'_event_instruction_',
|
||||||
events_display_instructions($event['event_type'], $event, false),
|
events_display_instructions($event['event_type'], $event, false),
|
||||||
$value
|
$value
|
||||||
|
@ -6838,15 +6837,15 @@ function events_get_field_value_by_event_id(
|
||||||
|
|
||||||
if (strpos($value, '_owner_user_') !== false) {
|
if (strpos($value, '_owner_user_') !== false) {
|
||||||
if (empty($event['owner_user'])) {
|
if (empty($event['owner_user'])) {
|
||||||
$return = str_replace('_owner_user_', __('N/A'), $value);
|
$value = str_replace('_owner_user_', __('N/A'), $value);
|
||||||
} else {
|
} else {
|
||||||
$return = str_replace('_owner_user_', $event['owner_user'], $value);
|
$value = str_replace('_owner_user_', $event['owner_user'], $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($value, '_event_status_') !== false) {
|
if (strpos($value, '_event_status_') !== false) {
|
||||||
$event_st = events_display_status($event['estado']);
|
$event_st = events_display_status($event['estado']);
|
||||||
$return = str_replace('_event_status_', $event_st['title'], $value);
|
$value = str_replace('_event_status_', $event_st['title'], $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($value, '_group_custom_id_') !== false) {
|
if (strpos($value, '_group_custom_id_') !== false) {
|
||||||
|
@ -6857,26 +6856,22 @@ function events_get_field_value_by_event_id(
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$event_st = events_display_status($event['estado']);
|
$event_st = events_display_status($event['estado']);
|
||||||
$return = str_replace('_group_custom_id_', $group_custom_id, $value);
|
$value = str_replace('_group_custom_id_', $group_custom_id, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the event custom data.
|
// Parse the event custom data.
|
||||||
if (!empty($event['custom_data'])) {
|
if (!empty($event['custom_data'])) {
|
||||||
$custom_data = json_decode(base64_decode($event['custom_data']));
|
$custom_data = json_decode(base64_decode($event['custom_data']));
|
||||||
foreach ($custom_data as $key => $val) {
|
foreach ($custom_data as $key => $val) {
|
||||||
$return = str_replace('_customdata_'.$key.'_', $val, $value);
|
$value = str_replace('_customdata_'.$key.'_', $val, $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This will replace the macro with the current logged user.
|
// This will replace the macro with the current logged user.
|
||||||
if (strpos($value, '_current_user_') !== false) {
|
if (strpos($value, '_current_user_') !== false) {
|
||||||
$return = str_replace('_current_user_', $config['id_user'], $value);
|
$value = str_replace('_current_user_', $config['id_user'], $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($return)) {
|
|
||||||
return $value;
|
return $value;
|
||||||
} else {
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5904,7 +5904,11 @@ table.table_modal_alternate tr td:first-child {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Class for integria incidents */
|
/*
|
||||||
|
* ---------------------------------------------------------------------
|
||||||
|
* - INTEGRIA INCIDENTS
|
||||||
|
* ---------------------------------------------------------------------
|
||||||
|
*/
|
||||||
div.priority {
|
div.priority {
|
||||||
width: 80px;
|
width: 80px;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
|
@ -5914,3 +5918,13 @@ div.priority {
|
||||||
display: table-cell;
|
display: table-cell;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.comment_title {
|
||||||
|
padding: 5px 10px 5px 20px;
|
||||||
|
background-color: rgba(130, 185, 46, 0.16);
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comment_body {
|
||||||
|
padding: 15px 20px 15px 20px;
|
||||||
|
}
|
||||||
|
|
|
@ -16,14 +16,20 @@ global $config;
|
||||||
|
|
||||||
check_login();
|
check_login();
|
||||||
|
|
||||||
if (! check_acl($config['id_user'], 0, 'IR') && ! check_acl($config['id_user'], 0, 'IW') && ! check_acl($config['id_user'], 0, 'IM')) {
|
if (!(check_acl($config['id_user'], 0, 'IW') && check_acl($config['id_user'], 0, 'IR'))) {
|
||||||
// Doesn't have access to this page.
|
// Doesn't have access to this page.
|
||||||
db_pandora_audit('ACL Violation', 'Trying to access IntegriaIMS ticket creation');
|
db_pandora_audit('ACL Violation', 'Trying to access IntegriaIMS ticket creation');
|
||||||
include 'general/noaccess.php';
|
include 'general/noaccess.php';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$update = (isset($_GET['incident_id']) === true);
|
||||||
|
|
||||||
|
if ($update) {
|
||||||
|
ui_print_page_header(__('Update Integria IMS Incident'), '', false, '', false, '');
|
||||||
|
} else {
|
||||||
ui_print_page_header(__('Create Integria IMS Incident'), '', false, '', false, '');
|
ui_print_page_header(__('Create Integria IMS Incident'), '', false, '', false, '');
|
||||||
|
}
|
||||||
|
|
||||||
// Check if Integria integration enabled.
|
// Check if Integria integration enabled.
|
||||||
if ($config['integria_enabled'] == 0) {
|
if ($config['integria_enabled'] == 0) {
|
||||||
|
@ -85,8 +91,6 @@ $incident_status = (int) get_parameter('status');
|
||||||
$incident_title = events_get_field_value_by_event_id($event_id, get_parameter('incident_title'));
|
$incident_title = events_get_field_value_by_event_id($event_id, get_parameter('incident_title'));
|
||||||
$incident_content = events_get_field_value_by_event_id($event_id, get_parameter('incident_content'));
|
$incident_content = events_get_field_value_by_event_id($event_id, get_parameter('incident_content'));
|
||||||
|
|
||||||
$update = (isset($_GET['incident_id']) === true);
|
|
||||||
|
|
||||||
// If incident id is specified, retrieve incident values from api to populate combos with such values.
|
// If incident id is specified, retrieve incident values from api to populate combos with such values.
|
||||||
if ($update) {
|
if ($update) {
|
||||||
// Call Integria IMS API method to get details of an incident given its id.
|
// Call Integria IMS API method to get details of an incident given its id.
|
||||||
|
@ -148,7 +152,9 @@ $table->data[0][0] .= '<div class="label_select_parent">'.html_print_input_text(
|
||||||
100,
|
100,
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
true
|
true,
|
||||||
|
'',
|
||||||
|
'w100p'
|
||||||
).'</div>';
|
).'</div>';
|
||||||
|
|
||||||
$table->data[1][0] = '<div class="label_select"><p class="input_label">'.__('Type').': </p>';
|
$table->data[1][0] = '<div class="label_select"><p class="input_label">'.__('Type').': </p>';
|
||||||
|
@ -174,7 +180,7 @@ $table->data[2][0] .= '<div class="label_select_parent">'.html_print_select(
|
||||||
$update ? $incident_details[6] : $config['incident_status'],
|
$update ? $incident_details[6] : $config['incident_status'],
|
||||||
'',
|
'',
|
||||||
__('Select'),
|
__('Select'),
|
||||||
0,
|
1,
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
|
@ -240,9 +246,12 @@ $table->data[3][0] .= '<div class="label_select_parent">'.html_print_textarea(
|
||||||
true
|
true
|
||||||
).'</div>';
|
).'</div>';
|
||||||
|
|
||||||
|
if ($update) {
|
||||||
// Here starts incident file management.
|
// Here starts incident file management.
|
||||||
$upload_file = get_parameter('upload_file');
|
$upload_file = get_parameter('upload_file');
|
||||||
$delete_file_id = get_parameter('delete_file');
|
$delete_file_id = get_parameter('delete_file');
|
||||||
|
$download_file_id = get_parameter('download_file');
|
||||||
|
$download_file_name = get_parameter('download_file_name');
|
||||||
|
|
||||||
// Files section table.
|
// Files section table.
|
||||||
$table_files_section = new stdClass();
|
$table_files_section = new stdClass();
|
||||||
|
@ -312,11 +321,37 @@ if (check_acl($config['id_user'], 0, 'IW') && $upload_file && ($_FILES['userfile
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete file.
|
// Delete file.
|
||||||
if (isset($_GET['delete_file']) && check_acl($config['id_user'], 0, 'IW')) {
|
if (isset($_GET['delete_file'])) {
|
||||||
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'delete_file', [$delete_file_id]);
|
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'delete_file', [$delete_file_id]);
|
||||||
header('Location: index.php?sec=incident&sec2=operation/incidents/configure_integriaims_incident&incident_id='.$incident_id_edit);
|
header('Location: index.php?sec=incident&sec2=operation/incidents/configure_integriaims_incident&incident_id='.$incident_id_edit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Download file.
|
||||||
|
if (isset($_GET['download_file'])) {
|
||||||
|
$file_base64 = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'download_file', [$download_file_id]);
|
||||||
|
ob_end_clean();
|
||||||
|
|
||||||
|
$decoded = base64_decode($file_base64);
|
||||||
|
|
||||||
|
file_put_contents($download_file_name, $decoded);
|
||||||
|
ob_end_clean();
|
||||||
|
|
||||||
|
if (file_exists($download_file_name)) {
|
||||||
|
header('Content-Description: File Transfer');
|
||||||
|
header('Content-Type: application/octet-stream');
|
||||||
|
header('Content-Disposition: attachment; filename="'.basename($download_file_name).'"');
|
||||||
|
header('Expires: 0');
|
||||||
|
header('Cache-Control: must-revalidate');
|
||||||
|
header('Pragma: public');
|
||||||
|
header('Content-Length: '.filesize($download_file_name));
|
||||||
|
ob_end_clean();
|
||||||
|
readfile($download_file_name);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
header('Location: index.php?sec=incident&sec2=operation/incidents/configure_integriaims_incident&incident_id='.$incident_id_edit);
|
||||||
|
}
|
||||||
|
|
||||||
// Retrieve files belonging to incident and create list table.
|
// Retrieve files belonging to incident and create list table.
|
||||||
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_files', [$incident_id_edit]);
|
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_files', [$incident_id_edit]);
|
||||||
|
|
||||||
|
@ -334,26 +369,19 @@ if ($result_api_call != false && strlen($result_api_call) > 0) {
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
foreach ($files as $key => $value) {
|
foreach ($files as $key => $value) {
|
||||||
$table_files->data[$i][0] = $value[11];
|
$table_files->data[$i][0] = '<a id="link_delete_file" href="'.ui_get_full_url('index.php?sec=incident&sec2=operation/incidents/configure_integriaims_incident&incident_id='.$incident_id_edit.'&download_file='.$value[0]).'&download_file_name='.$value[11].'">'.$value[11].'</a>';
|
||||||
$table_files->data[$i][1] = $value[14];
|
$table_files->data[$i][1] = $value[14];
|
||||||
$table_files->data[$i][2] = $value[12];
|
$table_files->data[$i][2] = $value[12];
|
||||||
$table_files->data[$i][3] = $value[8];
|
$table_files->data[$i][3] = $value[8];
|
||||||
$table_files->data[$i][4] = $value[13];
|
$table_files->data[$i][4] = $value[13];
|
||||||
if (check_acl($config['id_user'], 0, 'IW')) {
|
|
||||||
$table_files->data[$i][5] .= '<a id="link_delete_file" href="'.ui_get_full_url('index.php?sec=incident&sec2=operation/incidents/configure_integriaims_incident&incident_id='.$incident_id_edit.'&delete_file='.$value[0]).'"
|
$table_files->data[$i][5] .= '<a id="link_delete_file" href="'.ui_get_full_url('index.php?sec=incident&sec2=operation/incidents/configure_integriaims_incident&incident_id='.$incident_id_edit.'&delete_file='.$value[0]).'"
|
||||||
onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">';
|
onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">';
|
||||||
$table_files->data[$i][5] .= html_print_image('images/cross.png', true, ['title' => __('Delete')]);
|
$table_files->data[$i][5] .= html_print_image('images/cross.png', true, ['title' => __('Delete')]);
|
||||||
$table_files->data[$i][5] .= '</a>';
|
$table_files->data[$i][5] .= '</a>';
|
||||||
}
|
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// header("Content-type: text/plain");
|
|
||||||
// header("Content-Disposition: attachment; filename=savethis.txt");
|
|
||||||
// do your Db stuff here to get the content into $content
|
|
||||||
// echo "This is some text...\n";
|
|
||||||
// print $content;
|
|
||||||
$table_files_section->data[0][0] = '<div class="label_select"><p class="input_label">'.__('File name').':</p>';
|
$table_files_section->data[0][0] = '<div class="label_select"><p class="input_label">'.__('File name').':</p>';
|
||||||
$table_files_section->data[0][0] .= html_print_input_file('userfile', true);
|
$table_files_section->data[0][0] .= html_print_input_file('userfile', true);
|
||||||
$table_files_section->data[1][0] = '<div class="label_select"><p class="input_label">'.__('Description').':</p>';
|
$table_files_section->data[1][0] = '<div class="label_select"><p class="input_label">'.__('Description').':</p>';
|
||||||
|
@ -369,9 +397,14 @@ $table_files_section->data[1][0] .= html_print_input_text(
|
||||||
|
|
||||||
$table_files_section->data[2][0] .= '<div style="width: 100%; text-align:right;">'.html_print_submit_button(__('Upload'), 'accion', false, 'class="sub wand"', true).'</div>';
|
$table_files_section->data[2][0] .= '<div style="width: 100%; text-align:right;">'.html_print_submit_button(__('Upload'), 'accion', false, 'class="sub wand"', true).'</div>';
|
||||||
|
|
||||||
$upload_file_form = '<div><form method="post" id="file_control" enctype="multipart/form-data"><h4>'.__('Add attachment').'</h4>'.html_print_table($table_files_section, true).html_print_input_hidden('upload_file', 1, true).'<h4>'.__('Attached files').'</h4>'.html_print_table($table_files, true).'</form></div>';
|
$upload_file_form = '<div><form method="post" id="file_control" enctype="multipart/form-data">'.'<h4>'.__('Add attachment').'</h4>'.html_print_table($table_files_section, true).html_print_input_hidden('upload_file', 1, true).'<h4>'.__('Attached files').'</h4>'.html_print_table($table_files, true).'</form></div>';
|
||||||
|
}
|
||||||
|
|
||||||
// Here starts incident comments management.
|
// Here starts incident comments management.
|
||||||
|
if ($update) {
|
||||||
|
$upload_comment = get_parameter('upload_comment');
|
||||||
|
$comment_description = get_parameter('comment_description');
|
||||||
|
|
||||||
// Comments section table.
|
// Comments section table.
|
||||||
$table_comments_section = new stdClass();
|
$table_comments_section = new stdClass();
|
||||||
$table_comments_section->width = '100%';
|
$table_comments_section->width = '100%';
|
||||||
|
@ -398,21 +431,36 @@ $table_comments->head[5] = __('Delete');
|
||||||
$table_comments->data = [];
|
$table_comments->data = [];
|
||||||
|
|
||||||
$table_comments_section->data[0][0] = '<div class="label_select"><p class="input_label">'.__('Description').':</p>';
|
$table_comments_section->data[0][0] = '<div class="label_select"><p class="input_label">'.__('Description').':</p>';
|
||||||
$table_comments_section->data[0][0] .= html_print_input_text(
|
$table_comments_section->data[0][0] .= html_print_textarea(
|
||||||
'file_description',
|
'comment_description',
|
||||||
|
3,
|
||||||
|
20,
|
||||||
'',
|
'',
|
||||||
__('Description'),
|
'',
|
||||||
50,
|
true
|
||||||
100,
|
|
||||||
true,
|
|
||||||
false
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$i = 0;
|
$table_comments_section->data[1][1] .= '<div style="width: 100%; text-align:right;">'.html_print_submit_button(__('Add'), 'accion', false, 'class="sub wand"', true).'</div>';
|
||||||
|
|
||||||
|
// Upload comment.
|
||||||
|
if ($upload_comment) {
|
||||||
|
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'create_workunit', [$incident_id_edit, $comment_description, '0.00', 'no', 'no', '0']);
|
||||||
|
|
||||||
|
// API method returns id of new comment if success.
|
||||||
|
$comment_added = ($result_api_call >= '0') ? true : false;
|
||||||
|
|
||||||
|
ui_print_result_message(
|
||||||
|
$comment_added,
|
||||||
|
__('Comment successfully added'),
|
||||||
|
__('Comment could not be added')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Retrieve comments belonging to incident and create comments table.
|
// Retrieve comments belonging to incident and create comments table.
|
||||||
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_workunits', [$incident_id_edit]);
|
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_workunits', [$incident_id_edit]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($result_api_call != false && strlen($result_api_call) > 0) {
|
if ($result_api_call != false && strlen($result_api_call) > 0) {
|
||||||
$comments = [];
|
$comments = [];
|
||||||
$csv_array = explode("\n", $result_api_call);
|
$csv_array = explode("\n", $result_api_call);
|
||||||
|
@ -424,25 +472,15 @@ if ($result_api_call != false && strlen($result_api_call) > 0) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$upload_comment_form = '';
|
||||||
foreach ($comments as $key => $value) {
|
foreach ($comments as $key => $value) {
|
||||||
$table_comments->data[$i][0] = $value[11];
|
$upload_comment_form .= '<div class="comment_title">'.$value[3].'<span> said </span>'.$value[1].'<span style="float: right;">'.$value[2].' Hours</span></div>';
|
||||||
$table_comments->data[$i][1] = $value[14];
|
$upload_comment_form .= '<div class="comment_body">'.$value[4].'</div>';
|
||||||
$table_comments->data[$i][2] = $value[12];
|
}
|
||||||
$table_comments->data[$i][3] = $value[8];
|
|
||||||
$table_comments->data[$i][4] = $value[13];
|
$upload_comment_form = '<div><form method="post" id="comment_form" enctype="multipart/form-data"><h4>'.__('Add comment').'</h4>'.html_print_table($table_comments_section, true).html_print_input_hidden('upload_comment', 1, true).'</form>'.'<h4>'.__('Comments').'</h4>'.$upload_comment_form.'</div>';
|
||||||
|
|
||||||
$i++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
$upload_file_form = '<div><form method="post" id="file_control" enctype="multipart/form-data"><h4>'.__('Add comment').'</h4>'
|
|
||||||
.html_print_table($table_comments_section, true)
|
|
||||||
.html_print_input_hidden('upload_file', 1, true)
|
|
||||||
.'</form>'
|
|
||||||
.'<h4>'.__('Comments').'</h4>'
|
|
||||||
.html_print_table($table_comments, true)
|
|
||||||
.'</div>';*/
|
|
||||||
//
|
|
||||||
// Print forms and stuff.
|
// Print forms and stuff.
|
||||||
echo '<form id="create_integria_incident_form" name="create_integria_incident_form" method="POST">';
|
echo '<form id="create_integria_incident_form" name="create_integria_incident_form" method="POST">';
|
||||||
html_print_table($table);
|
html_print_table($table);
|
||||||
|
@ -453,6 +491,7 @@ if (!$update) {
|
||||||
html_print_input_hidden('update_incident', 1);
|
html_print_input_hidden('update_incident', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($update) {
|
||||||
echo '</form>';
|
echo '</form>';
|
||||||
echo '<div class="ui_toggle">';
|
echo '<div class="ui_toggle">';
|
||||||
ui_toggle(
|
ui_toggle(
|
||||||
|
@ -467,6 +506,25 @@ ui_toggle(
|
||||||
);
|
);
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
|
||||||
echo '<div style="width: 100%; text-align:right;">';
|
echo '<div class="ui_toggle">';
|
||||||
html_print_submit_button(__('Create'), 'accion', false, 'form="create_integria_incident_form" class="sub wand"');
|
ui_toggle(
|
||||||
|
$upload_comment_form,
|
||||||
|
__('Comments'),
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
'white_box white_box_opened',
|
||||||
|
'no-border flex'
|
||||||
|
);
|
||||||
|
echo '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '<div style="width: 100%; text-align:right;">';
|
||||||
|
if ($update) {
|
||||||
|
html_print_submit_button(__('Update'), 'accion', false, 'form="create_integria_incident_form" class="sub wand"');
|
||||||
|
} else {
|
||||||
|
html_print_submit_button(__('Create'), 'accion', false, 'form="create_integria_incident_form" class="sub wand"');
|
||||||
|
}
|
||||||
|
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
|
Loading…
Reference in New Issue