wip integration integriaIMS pandora_enterprise#11471

This commit is contained in:
daniel 2023-06-29 09:45:44 +02:00
parent 6e3eddff08
commit 64c8086854
8 changed files with 1014 additions and 94 deletions

View File

@ -3,9 +3,6 @@
/* Function get custom fields incidences */
// eslint-disable-next-line no-unused-vars
function getInputFieldsIncidenceType(idIncidenceType, fieldsData, ajaxUrl) {
console.log(idIncidenceType);
console.log(fieldsData);
console.log(ajaxUrl);
// Failed request handler.
var handleFail = function(jqXHR, textStatus, errorThrown) {
console.log(jqXHR, textStatus, errorThrown);
@ -32,3 +29,38 @@ function getInputFieldsIncidenceType(idIncidenceType, fieldsData, ajaxUrl) {
.done(handleSuccess)
.fail(handleFail);
}
/* Function get custom fields incidences */
// eslint-disable-next-line no-unused-vars
function downloadIncidenceAttachment(
idIncidence,
idAttachment,
ajaxUrl,
filename
) {
$.ajax({
type: "POST",
url: ajaxUrl,
data: {
page: "operation/ITSM/itsm",
method: "getDownloadIncidenceAttachment",
idIncidence: idIncidence,
idAttachment: idAttachment
},
dataType: "binary",
xhrFields: {
responseType: "arraybuffer"
},
success: function(data) {
var blob = new Blob([data], { type: "application/octetstream" });
var link = document.createElement("a");
link.href = window.URL.createObjectURL(blob);
link.download = filename;
document.body.appendChild(link);
link.click();
},
error: function(jqXHR, textStatus, message) {
console.error(textStatus, message);
}
});
}

View File

@ -56,6 +56,8 @@ class ITSM
* @param array $postFields Params send post.
* @param mixed $id Specific id for path.
* @param string|null $method Request method.
* @param array|null $file Upload file.
* @param boolean $download Download file.
*
* @return array Array result.
* @throws \Exception On error.
@ -65,7 +67,9 @@ class ITSM
?array $queryParams=null,
?array $postFields=null,
mixed $id=null,
?string $method='POST'
?string $method='POST',
?array $file=null,
?bool $download=false
) {
$headers = [
'accept: application/json',
@ -76,18 +80,49 @@ class ITSM
$path = $this->pathAction($action, $queryParams, $id);
$url = $this->url.$path;
// Debugger.
// hd($url, true);
$data = [];
// Clean safe_input forms.
if (empty($postFields) === false) {
foreach ($postFields as $key => $field) {
if ($field !== null) {
$field = io_safe_output($field);
}
$data[$key] = $field;
}
}
if ($file !== null && file_exists($file['tmp_name']) === true) {
$data['attachment'] = curl_file_create(
$file['tmp_name'],
$file['type'],
$file['name']
);
$headers = [
'Content-Type: multipart/form-data',
'Authorization: Bearer '.$this->userBearer,
];
} else {
$data = json_encode($data);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postFields));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$response = curl_exec($ch);
if ($download === true) {
return $response;
}
$result = json_decode($response, true);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new \Exception(__('Invalid response').', '.$response);
@ -135,6 +170,10 @@ class ITSM
$path = '/incidence/status/list';
break;
case 'listPriorities':
$path = '/incidence/priority/list';
break;
case 'listUsers':
$path = '/user/list';
break;
@ -155,6 +194,30 @@ class ITSM
$path = '/incidence/'.$id;
break;
case 'deleteIncidence':
$path = '/incidence/'.$id;
break;
case 'incidenceWus':
$path = '/incidence/'.$id.'/workunit/list';
break;
case 'incidenceFiles':
$path = '/incidence/'.$id.'/attachment/list';
break;
case 'createIncidenceAttachment':
$path = '/incidence/'.$id.'/attachment';
break;
case 'deleteIncidenceAttachment':
$path = '/incidence/'.$id['idIncidence'].'/attachment/'.$id['idAttachment'];
break;
case 'downloadIncidenceAttachment':
$path = '/incidence/'.$id['idIncidence'].'/attachment/'.$id['idAttachment'].'/download';
break;
default:
// Not posible.
break;

View File

@ -27,6 +27,7 @@ class Manager
'getListTickets',
'getUserSelect',
'getInputFieldsIncidenceType',
'getDownloadIncidenceAttachment',
];
/**
@ -107,17 +108,21 @@ class Manager
*/
public function run()
{
ui_require_css_file('integriaims');
\ui_require_css_file('integriaims');
\ui_require_javascript_file('ITSM');
switch ($this->operation) {
case 'list':
$this->showList();
break;
case 'edit':
\ui_require_javascript_file('ITSM');
$this->showEdit();
break;
case 'detail':
$this->showDetail();
break;
case 'dashboard':
default:
$this->showDashboard();
@ -133,11 +138,26 @@ class Manager
*/
private function showList()
{
$idIncidence = \get_parameter('idIncidence', 0);
$error = '';
$successfullyMsg = '';
if (empty($idIncidence) === false) {
$ITSM = new ITSM();
try {
$this->deleteIncidence($ITSM, $idIncidence);
$successfullyMsg = __('Delete ticket successfully');
} catch (\Throwable $th) {
$error = $th->getMessage();
}
}
View::render(
'ITSM/ITSMTicketListView',
[
'ajaxController' => $this->ajaxController,
'urlAjax' => \ui_get_full_url('ajax.php'),
'ajaxController' => $this->ajaxController,
'urlAjax' => \ui_get_full_url('ajax.php'),
'error' => $error,
'successfullyMsg' => $successfullyMsg,
]
);
}
@ -154,14 +174,12 @@ class Manager
$update_incidence = (bool) \get_parameter('update_incidence', 0);
$idIncidence = \get_parameter('idIncidence', 0);
// Debugger.
// hd($_POST);
$error = '';
$ITSM = new ITSM();
try {
$objectTypes = $this->getObjectypes($ITSM);
$groups = $this->getGroups($ITSM);
// $priorities = $ITSM->callApi('listPriorities');
$priorities = $this->getPriorities($ITSM);
$resolutions = $this->getResolutions($ITSM);
$status = $this->getStatus($ITSM);
@ -172,16 +190,14 @@ class Manager
$error = $th->getMessage();
}
// TODO: END POINT priorities.
// \get_parameter('priority', 'LOW').
$incidence = [
'title' => \get_parameter('title', ($incidenceData['title'] ?? '')),
'idIncidenceType' => \get_parameter('idIncidenceType', ($incidenceData['idIncidenceType'] ?? 0)),
'idGroup' => \get_parameter('idGroup', ($incidenceData['idGroup'] ?? 0)),
'priority' => 'LOW',
'priority' => \get_parameter('priority', ($incidenceData['priority'] ?? 'LOW')),
'status' => \get_parameter('status', ($incidenceData['status'] ?? 'NEW')),
'idCreator' => \get_parameter('idCreator', ($incidenceData['idCreator'] ?? '')),
'owner' => \get_parameter('owner_hidden', ''),
'owner' => \get_parameter('owner_hidden', ($incidenceData['owner'] ?? '')),
'resolution' => \get_parameter('resolution', ($incidenceData['resolution'] ?? null)),
'description' => \get_parameter('description', ($incidenceData['description'] ?? '')),
];
@ -203,6 +219,8 @@ class Manager
}
$incidence['typeFieldData'] = $typeFieldData;
} else {
$incidence['typeFieldData'] = $incidenceData['typeFieldData'];
}
if ($create_incidence === true) {
@ -229,6 +247,7 @@ class Manager
'priorities' => [],
'resolutions' => $resolutions,
'status' => $status,
'priorities' => $priorities,
'error' => $error,
'incidence' => $incidence,
'idIncidence' => $idIncidence,
@ -238,6 +257,107 @@ class Manager
}
/**
* Draw list tickets.
*
* @return void
*/
private function showDetail()
{
$idIncidence = (int) \get_parameter('idIncidence', 0);
$uploadFile = (bool) \get_parameter('upload_file', 0);
$idAttachment = (int) \get_parameter('idAttachment', 0);
$addComment = (bool) \get_parameter('addComment', 0);
$error = '';
$successfullyMsg = null;
$incidence = null;
$objectTypes = null;
$groups = null;
$resolutions = null;
$status = null;
$wus = null;
$files = null;
$users = null;
$priorities = null;
$priorityDiv = null;
$ITSM = new ITSM();
try {
if (empty($idIncidence) === false) {
if ($uploadFile === true) {
$attachment = [
'description' => get_parameter('file_description', ''),
];
$incidenceAttachment = $this->createIncidenceAttachment(
$ITSM,
$idIncidence,
$attachment,
get_parameter('userfile')
);
if ($incidenceAttachment !== false) {
$successfullyMsg = __('File added succesfully');
}
}
if (empty($idAttachment) === false) {
$this->deleteIncidenceAttachment($ITSM, $idIncidence, $idAttachment);
$successfullyMsg = __('Delete File successfully');
}
$incidence = $this->getIncidence($ITSM, $idIncidence);
$objectTypes = $this->getObjectypes($ITSM);
$groups = $this->getGroups($ITSM);
$resolutions = $this->getResolutions($ITSM);
$status = $this->getStatus($ITSM);
$priorities = $this->getPriorities($ITSM);
$wus = $this->getIncidenceWus($ITSM, $idIncidence);
$files = $this->getIncidenceFiles($ITSM, $idIncidence);
$usersInvolved = [];
$usersInvolved[$incidence['idCreator']] = $incidence['idCreator'];
$usersInvolved[$incidence['owner']] = $incidence['owner'];
$usersInvolved[$incidence['closedBy']] = $incidence['closedBy'];
foreach ($wus['data'] as $wu) {
$usersInvolved[$wu['idUser']] = $wu['idUser'];
}
foreach ($files['data'] as $file) {
$usersInvolved[$file['idUser']] = $file['idUser'];
}
$users = $this->getUsers($ITSM, $usersInvolved);
$priorityDiv = $this->priorityDiv($incidence['priority'], $priorities[$incidence['priority']]);
}
} catch (\Throwable $th) {
$error = $th->getMessage();
}
View::render(
'ITSM/ITSMTicketDetailView',
[
'ajaxController' => $this->ajaxController,
'urlAjax' => \ui_get_full_url('ajax.php'),
'error' => $error,
'successfullyMsg' => $successfullyMsg,
'incidence' => $incidence,
'objectTypes' => $objectTypes,
'groups' => $groups,
'resolutions' => $resolutions,
'status' => $status,
'wus' => $wus,
'files' => $files,
'users' => $users,
'priorities' => $priorities,
'priorityDiv' => $priorityDiv,
]
);
}
/**
* Get Incidences types.
*
@ -353,6 +473,20 @@ class Manager
}
/**
* Get Priorities.
*
* @param ITSM $ITSM Object for callApi.
*
* @return array Return mode select.
*/
private function getPriorities(ITSM $ITSM): array
{
$listPriorities = $ITSM->callApi('listPriorities');
return $listPriorities;
}
/**
* Get Incidence.
*
@ -375,6 +509,26 @@ class Manager
}
/**
* Delete Incidence.
*
* @param ITSM $ITSM Object for callApi.
* @param integer $idIncidence Incidence ID.
*
* @return void
*/
private function deleteIncidence(ITSM $ITSM, int $idIncidence): void
{
$ITSM->callApi(
'deleteIncidence',
[],
[],
$idIncidence,
'DELETE'
);
}
/**
* Get fields incidence type.
*
@ -399,6 +553,167 @@ class Manager
}
/**
* Get Incidence Work units.
*
* @param ITSM $ITSM Object for callApi.
* @param integer $idIncidence Incidence ID.
*
* @return array Data workUnits incidence.
*/
private function getIncidenceWus(ITSM $ITSM, int $idIncidence): array
{
$result = $ITSM->callApi(
'incidenceWus',
[
'page' => 0,
'sizePage' => 0,
],
[],
$idIncidence
);
return $result;
}
/**
* Get Incidence Attachments.
*
* @param ITSM $ITSM Object for callApi.
* @param integer $idIncidence Incidence ID.
*
* @return array Data attachment incidence.
*/
private function getIncidenceFiles(ITSM $ITSM, int $idIncidence): array
{
$result = $ITSM->callApi(
'incidenceFiles',
[
'page' => 0,
'sizePage' => 0,
],
[],
$idIncidence
);
return $result;
}
/**
* Get Users.
*
* @param ITSM $ITSM Object for callApi.
* @param array $users Users ID.
*
* @return array Users.
*/
private function getUsers(ITSM $ITSM, array $users): array
{
$result = $ITSM->callApi(
'listUsers',
[
'page' => 0,
'sizePage' => 0,
],
[
'multipleSearchString' => [
'field' => 'idUser',
'data' => $users,
],
]
);
$res = [];
if (empty($result['data']) === false) {
$res = array_reduce(
$result['data'],
function ($carry, $user) {
$carry[$user['idUser']] = $user['fullName'];
return $carry;
}
);
}
return $res;
}
/**
* Create incidence
*
* @param ITSM $ITSM Object for callApi.
* @param integer $idIncidence Id incidence.
* @param array $attachment Params insert.
* @param array $file Info file.
*
* @return array
*/
private function createIncidenceAttachment(ITSM $ITSM, int $idIncidence, array $attachment, array $file): array
{
$incidenceAttachment = $ITSM->callApi(
'createIncidenceAttachment',
null,
$attachment,
$idIncidence,
'POST',
$file
);
return $incidenceAttachment;
}
/**
* Delete Attachment.
*
* @param ITSM $ITSM Object for callApi.
* @param integer $idIncidence Incidence ID.
* @param integer $idAttachment Attachment ID.
*
* @return void
*/
private function deleteIncidenceAttachment(ITSM $ITSM, int $idIncidence, int $idAttachment): void
{
$ITSM->callApi(
'deleteIncidenceAttachment',
[],
[],
[
'idIncidence' => $idIncidence,
'idAttachment' => $idAttachment,
],
'DELETE'
);
}
/**
* Download Attachment.
*
* @param ITSM $ITSM Object for callApi.
* @param integer $idIncidence Incidence ID.
* @param integer $idAttachment Attachment ID.
*
* @return mixed
*/
private function downloadIncidenceAttachment(ITSM $ITSM, int $idIncidence, int $idAttachment)
{
return $ITSM->callApi(
'downloadIncidenceAttachment',
[],
[],
[
'idIncidence' => $idIncidence,
'idAttachment' => $idAttachment,
],
'GET',
null,
true
);
}
/**
* Draw list dashboards.
*
@ -416,6 +731,51 @@ class Manager
}
/**
* Draw priority div.
*
* @param string $priority Priority incidence.
* @param string $label Name.
*
* @return string Html output.
*/
private function priorityDiv(string $priority, string $label)
{
$output = '';
switch ($priority) {
case 'LOW':
$color = COL_NORMAL;
break;
case 'INFORMATIVE':
$color = COL_UNKNOWN;
break;
case 'MEDIUM':
$color = COL_WARNING;
break;
case 'SERIOUS':
$color = COL_ALERTFIRED;
break;
case 'VERY_SERIOUS':
$color = COL_CRITICAL;
break;
default:
$color = COL_NOTINIT;
break;
}
$output = '<div class="priority" style="background: '.$color.'">';
$output .= $label;
$output .= '</div>';
return $output;
}
/**
* Get list tickets and prepare data for datatable.
*
@ -428,20 +788,19 @@ class Manager
// Init data.
$data = [];
// Catch post parameters.
$start = get_parameter('start', 0);
$length = get_parameter('length', $config['block_size']);
$start = (int) get_parameter('start', 1);
$length = (int) get_parameter('length', $config['block_size']);
$order = get_datatable_order(true);
$filters = get_parameter('filter', []);
try {
ob_start();
$queryParams = array_merge(
[
'page' => $start,
'sizePage' => $length,
],
$order
);
$queryParams = [
'page' => ($start === 0) ? $start : ($start / $length),
'sizePage' => $length,
'sortField' => $order['field'],
'sortDirection' => $order['direction'],
];
$ITSM = new ITSM();
$result = $ITSM->callApi(
@ -450,23 +809,83 @@ class Manager
$filters
);
$groups = $this->getGroups($ITSM);
$resolutions = $this->getResolutions($ITSM);
$resolutions['NOTRESOLVED'] = __('None');
$status = $this->getStatus($ITSM);
$priorities = $this->getPriorities($ITSM);
$usersInvolved = [];
foreach ($result['data'] as $incidence) {
$usersInvolved[$incidence['idCreator']] = $incidence['idCreator'];
$usersInvolved[$incidence['owner']] = $incidence['owner'];
$usersInvolved[$incidence['closedBy']] = $incidence['closedBy'];
}
$users = $this->getUsers($ITSM, $usersInvolved);
$url = \ui_get_full_url('index.php?sec=manageTickets&sec2=operation/ITSM/itsm');
$data = array_reduce(
$result['data'],
function ($carry, $item) {
global $config;
function ($carry, $item) use ($groups, $resolutions, $status, $priorities, $users, $url) {
// Transforms array of arrays $data into an array
// of objects, making a post-process of certain fields.
$tmp = (object) $item;
$new = (object) [];
$new->id = $tmp->idIncidence;
$new->title = $tmp->title;
$new->groupCompany = $tmp->idGroup.'/'.$tmp->idCompany;
$new->statusResolution = $tmp->status.'/'.$tmp->resolution;
$new->priority = $tmp->priority;
$new->updated = $tmp->updateDate;
$new->started = $tmp->startDate;
$new->creator = $tmp->idCreator;
$new->owner = $tmp->owner;
$new->idIncidence = $tmp->idIncidence;
$new->title = '<a href="'.$url.'&operation=detail&idIncidence='.$tmp->idIncidence.'">';
$new->title .= $tmp->title;
$new->title .= '</a>';
$new->groupCompany = $groups[$tmp->idGroup];
if (empty($tmp->idCompany) === false) {
$new->groupCompany .= '/'.$tmp->idCompany;
}
$new->statusResolution = $status[$tmp->status].'/'.$resolutions[$tmp->resolution];
$new->priority = $this->priorityDiv($tmp->priority, $priorities[$tmp->priority]);
$new->updateDate = $tmp->updateDate;
$new->startDate = $tmp->startDate;
$new->idCreator = $users[$tmp->idCreator];
$new->owner = $users[$tmp->owner];
$new->operation = '<div class="table_action_buttons">';
$new->operation .= '<a href="'.$url.'&operation=edit&idIncidence='.$tmp->idIncidence.'">';
$new->operation .= html_print_image(
'images/edit.svg',
true,
[
'title' => __('Edit'),
'class' => 'main_menu_icon invert_filter',
]
);
$new->operation .= '</a>';
$new->operation .= '<a href="'.$url.'&operation=detail&idIncidence='.$tmp->idIncidence.'">';
$new->operation .= html_print_image(
'images/enable.svg',
true,
[
'title' => __('Detail'),
'class' => 'main_menu_icon invert_filter',
]
);
$new->operation .= '</a>';
$urlDelete = $url.'&operation=list&idIncidence='.$tmp->idIncidence;
$urlOnClick = 'javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;';
$new->operation .= '<a href="'.$urlDelete.'" onClick="'.$urlOnClick.'">';
$new->operation .= html_print_image(
'images/delete.svg',
true,
[
'title' => __('Delete'),
'class' => 'main_menu_icon invert_filter',
]
);
$new->operation .= '</a>';
$new->operation .= '</div>';
$carry[] = $new;
return $carry;
@ -583,4 +1002,27 @@ class Manager
}
/**
* Get Download.
*
* @return void
*/
public function getDownloadIncidenceAttachment()
{
$idIncidence = (int) get_parameter('idIncidence', true);
$idAttachment = (int) get_parameter('idAttachment', true);
try {
$ITSM = new ITSM();
$result = $this->downloadIncidenceAttachment($ITSM, $idIncidence, $idAttachment);
} catch (Throwable $e) {
echo $e->getMessage();
exit;
}
echo $result;
exit;
}
}

View File

@ -4,7 +4,7 @@ div.priority {
color: #fff;
text-align: center;
border-radius: 5px;
padding: 5px;
padding: 0px;
display: table-cell;
vertical-align: middle;
}
@ -47,13 +47,8 @@ div.integria_details_row_three {
div.integria_details_description {
width: 100%;
}
div.integria_details_description textarea {
width: 100%;
background-color: #fbfbfb;
resize: vertical;
color: #000;
overflow: auto;
padding: 0px 10px;
}
.integriaims_details_box {
@ -143,3 +138,10 @@ div.incidence-type-custom-fields {
.incidence-type-custom-fields > div.incidence-type-custom-fields-textarea {
flex: 1 1 100%;
}
.label_select,
.label_select_simple {
display: flex;
flex-direction: column;
margin: 0;
}

View File

@ -49,7 +49,6 @@ if (empty($customFields) === true) {
'name' => 'custom-fields['.$field['idIncidenceTypeField'].']',
'required' => $field['isRequired'],
'return' => true,
'value' => ($fieldsData[$field['idIncidenceTypeField']] ?? null),
];
$class = '';
@ -57,10 +56,13 @@ if (empty($customFields) === true) {
switch ($field['type']) {
case 'COMBO':
$options['type'] = 'select';
$options['fields'] = explode(',', $field['comboValue']);
$fieldsValues = explode(',', $field['comboValue']);
$options['fields'] = array_combine($fieldsValues, $fieldsValues);
$options['selected'] = ($fieldsData[$field['idIncidenceTypeField']] ?? null);
break;
case 'TEXT':
$options['value'] = ($fieldsData[$field['idIncidenceTypeField']] ?? null);
$options['type'] = 'text';
break;
@ -73,10 +75,12 @@ if (empty($customFields) === true) {
break;
case 'NUMERIC':
$options['value'] = ($fieldsData[$field['idIncidenceTypeField']] ?? null);
$options['type'] = 'number';
break;
case 'TEXTAREA':
$options['value'] = ($fieldsData[$field['idIncidenceTypeField']] ?? null);
$options['type'] = 'textarea';
$options['rows'] = 4;
$options['columns'] = 0;

View File

@ -0,0 +1,386 @@
<?php
/**
* ITSM View detailed ticket
*
* @category Console Class
* @package Pandora FMS
* @subpackage ITSM
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2023 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;
ui_require_css_file('integriaims');
// Header tabs.
ui_print_standard_header(
__('ITSM Detailed'),
'',
false,
'integria_tab',
false,
[],
[
[
'link' => 'index.php?sec=ITSM&sec2=operation/ITSM/itsm',
'label' => __('ITSM'),
],
[
'link' => 'index.php?sec=ITSM&sec2=operation/ITSM/itsm&operation=list',
'label' => __('ITSM Tickets'),
],
[
'link' => 'index.php?sec=ITSM&sec2=operation/ITSM/itsm',
'label' => __('ITSM Detailed'),
],
]
);
if (empty($error) === false) {
ui_print_error_message($error);
}
if (empty($successfullyMsg) === false) {
ui_print_success_message($successfullyMsg);
}
if (empty($incidence) === true) {
ui_print_info_message(__('Incidence not found'));
} else {
$nameIncidence = '--';
if (empty($incidence['idIncidenceType']) === false) {
$nameIncidence = $objectTypes[$incidence['idIncidenceType']];
}
// Details box.
$details_box = '<div class="integriaims_details_box integriaims_details_box_five">';
$details_box .= '<div class="integriaims_details_titles">'.__('Status').'</div>';
$details_box .= '<div class="integriaims_details_titles">'.__('Resolution').'</div>';
$details_box .= '<div class="integriaims_details_titles">'.__('Group').'</div>';
$details_box .= '<div class="integriaims_details_titles">'.__('Priority').'</div>';
$details_box .= '<div class="integriaims_details_titles">'.__('Type').'</div>';
$details_box .= '<div>';
$details_box .= html_print_image('images/heart.png', true, ['class' => 'invert_filter']);
$details_box .= '</div>';
$details_box .= '<div>';
$details_box .= html_print_image('images/builder@svg.svg', true, ['class' => 'invert_filter']);
$details_box .= '</div>';
$details_box .= '<div>';
$details_box .= html_print_image('images/user_green.png', true, ['class' => 'invert_filter']);
$details_box .= '</div>';
$details_box .= '<div>';
$details_box .= $priorityDiv;
$details_box .= '</div>';
$details_box .= '<div>';
$details_box .= html_print_image('images/incidents.png', true, ['class' => 'invert_filter']);
$details_box .= '</div>';
$details_box .= '<div>'.$status[$incidence['status']].'</div>';
$details_box .= '<div>';
$details_box .= ($incidence['resolution'] !== 'NOTRESOLVED') ? $resolutions[$incidence['resolution']] : '--';
$details_box .= '</div>';
$details_box .= '<div>'.$groups[$incidence['idGroup']].'</div>';
$details_box .= '<div>'.$priorities[$incidence['priority']].'</div>';
$details_box .= '<div>';
$details_box .= $nameIncidence;
$details_box .= '</div>';
$details_box .= '</div>';
// People box.
$people_box = '<div class="integriaims_details_box integriaims_details_box_three">';
$people_box .= '<div>';
$people_box .= html_print_image('images/header_user_green.png', true, ['width' => '21']);
$people_box .= '</div>';
$people_box .= '<div>';
$people_box .= html_print_image('images/header_user_green.png', true, ['width' => '21']);
$people_box .= '</div>';
$people_box .= '<div>';
$people_box .= html_print_image('images/header_user_green.png', true, ['width' => '21']);
$people_box .= '</div>';
$people_box .= '<div class="integriaims_details_titles">'.__('Created by').':</div>';
$people_box .= '<div class="integriaims_details_titles">'.__('Owned by').':</div>';
$people_box .= '<div class="integriaims_details_titles">'.__('Closed by').':</div>';
$people_box .= '<div>';
$people_box .= (empty($incidence['idCreator']) === false) ? $users[$incidence['idCreator']] : '--';
$people_box .= '</div>';
$people_box .= '<div>';
$people_box .= (empty($incidence['owner']) === false) ? $users[$incidence['owner']] : '--';
$people_box .= '</div>';
$people_box .= '<div>';
$people_box .= (empty($incidence['closedBy']) === false) ? $users[$incidence['closedBy']] : '--';
$people_box .= '</div>';
$people_box .= '</div>';
// Dates box.
$dates_box = '<div class="integriaims_details_box integriaims_details_box_three">';
$dates_box .= '<div>';
$dates_box .= html_print_image('images/tick.png', true, ['class' => 'invert_filter']);
$dates_box .= '</div>';
$dates_box .= '<div>';
$dates_box .= html_print_image('images/update.png', true, ['width' => '21', 'class' => 'invert_filter']);
$dates_box .= '</div>';
$dates_box .= '<div>';
$dates_box .= html_print_image('images/mul.png', true, ['class' => 'invert_filter']);
$dates_box .= '</div>';
$dates_box .= '<div class="integriaims_details_titles">'.__('Created at').':</div>';
$dates_box .= '<div class="integriaims_details_titles">'.__('Updated at').':</div>';
$dates_box .= '<div class="integriaims_details_titles">'.__('Closed at').':</div>';
$dates_box .= '<div>'.$incidence['startDate'].'</div>';
$dates_box .= '<div>'.$incidence['updateDate'].'</div>';
$dates_box .= '<div>';
$dates_box .= (($incidence['closeDate'] === '0000-00-00 00:00:00') ? '--' : $incidence['closeDate']);
$dates_box .= '</div>';
$dates_box .= '</div>';
// Show details, people and dates.
echo '<div class="integria_details">';
ui_toggle(
$details_box,
__('Details'),
'',
'details_box',
false,
false,
'',
'integria_details_content white-box-content',
'integria_details_shadow box-flat white_table_graph'
);
ui_toggle(
$people_box,
__('People'),
'',
'people_box',
false,
false,
'',
'integria_details_content white-box-content',
'integria_details_shadow box-flat white_table_graph'
);
ui_toggle(
$dates_box,
__('Dates'),
'',
'dates_box',
false,
false,
'',
'integria_details_content white-box-content',
'integria_details_shadow box-flat white_table_graph'
);
echo '</div>';
// Show description.
$description_box = '<div class="integria_details_description">';
$description_box .= $incidence['description'];
$description_box .= '</div>';
ui_toggle($description_box, __('Description'), '', '', false);
// Files section table.
$table_files_section = new stdClass();
$table_files_section->width = '100%';
$table_files_section->id = 'files_section_table';
$table_files_section->class = 'databox filters';
$table_files_section->head = [];
$table_files_section->data = [];
$table_files_section->size = [];
$table_files_section->size[0] = '20%';
$table_files_section->size[1] = '60%';
$table_files_section->size[2] = '20%';
$table_files_section->data[0][0] = '<div class="label_select">';
$table_files_section->data[0][0] .= '<p class="input_label">'.__('File name').':</p>';
$table_files_section->data[0][0] .= html_print_input_file('userfile', true);
$table_files_section->data[0][1] = '<div class="label_select">';
$table_files_section->data[0][1] .= '<p class="input_label">';
$table_files_section->data[0][1] .= __('Attachment description');
$table_files_section->data[0][1] .= ':</p>';
$table_files_section->data[0][1] .= html_print_textarea(
'file_description',
3,
20,
'',
'',
true,
'w100p'
);
$table_files_section->data[0][2] = '<div class="w100p">';
$table_files_section->data[0][2] .= html_print_submit_button(
__('Upload'),
'accion',
false,
[
'icon' => 'wand',
'mode' => 'mini secondary',
'class' => 'right',
],
true
);
$table_files_section->data[0][2] .= '</div>';
// Files list table.
$table_files = new stdClass();
$table_files->width = '100%';
$table_files->class = 'info_table';
$table_files->head = [];
$table_files->head[0] = __('Filename');
$table_files->head[1] = __('Timestamp');
$table_files->head[2] = __('Description');
$table_files->head[3] = __('User');
$table_files->head[4] = __('Size');
$table_files->head[5] = __('Delete');
$table_files->data = [];
$url = \ui_get_full_url('index.php?sec=manageTickets&sec2=operation/ITSM/itsm');
foreach ($files['data'] as $key => $file) {
$onClick = 'downloadIncidenceAttachment('.$file['idIncidence'].','.$file['idAttachment'];
$onClick .= ',\''.ui_get_full_url('ajax.php').'\',\''.$file['filename'].'\')';
$table_files->data[$key][0] = '<a href="#" onclick="'.$onClick.'">'.$file['filename'].'</a>';
$table_files->data[$key][1] = $file['timestamp'];
$table_files->data[$key][2] = $file['description'];
$table_files->data[$key][3] = $file['idUser'];
$table_files->data[$key][4] = $file['size'];
$urlDelete = $url.'&operation=detail&idIncidence='.$file['idIncidence'].'&idAttachment='.$file['idAttachment'];
$onclickDelete = 'javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;';
$table_files->data[$key][5] .= '<a href="'.$urlDelete.'" onClick="'.$onclickDelete.'">';
$table_files->data[$key][5] .= html_print_image(
'images/delete.svg',
true,
[
'title' => __('Delete'),
'class' => 'invert_filter main_menu_icon',
]
);
$table_files->data[$key][5] .= '</a>';
}
$upload_file_form = '<div class="w100p">';
$upload_file_form .= '<form method="post" id="file_control" enctype="multipart/form-data">';
$upload_file_form .= '<h4>'.__('Add attachment').'</h4>';
$upload_file_form .= html_print_table($table_files_section, true);
$upload_file_form .= html_print_input_hidden('upload_file', true, true);
$upload_file_form .= '<h4>'.__('Attached files').'</h4>';
$upload_file_form .= html_print_table($table_files, true);
$upload_file_form .= '</form>';
$upload_file_form .= '</div>';
echo '<div class="ui_toggle">';
ui_toggle(
$upload_file_form,
__('Attached files'),
'',
'',
true,
false,
'white-box-content',
'w98p'
);
echo '</div>';
// Comments section table.
$table_comments_section = new stdClass();
$table_comments_section->width = '100%';
$table_comments_section->id = 'files_section_table';
$table_comments_section->class = 'databox filters';
$table_comments_section->head = [];
$table_comments_section->size = [];
$table_comments_section->size[0] = '80%';
$table_comments_section->size[1] = '20%';
$table_comments_section->data = [];
$table_comments_section->data[0][0] = '<div class="label_select">';
$table_comments_section->data[0][0] .= '<p class="input_label">';
$table_comments_section->data[0][0] .= __('Description');
$table_comments_section->data[0][0] .= ':</p>';
$table_comments_section->data[0][0] .= html_print_textarea(
'comment_description',
3,
20,
'',
'',
true,
'w100p'
);
$table_comments_section->data[0][1] = '<div class="w100p">';
$table_comments_section->data[0][1] .= html_print_submit_button(
__('Add'),
'accion',
false,
[
'icon' => 'wand',
'mode' => 'mini secondary',
'class' => 'right',
],
true
);
$table_comments_section->data[0][1] .= '</div>';
// Comments list table.
$comment_table = '';
if (empty($wus) === false) {
foreach ($wus['data'] as $wu) {
$comment_table .= '<div class="comment_title">';
$comment_table .= $wu['idUser'];
$comment_table .= '<span>&nbspsaid&nbsp</span>';
$comment_table .= $wu['timestamp'];
$comment_table .= '<span class="float-right">';
$comment_table .= $wu['duration'];
$comment_table .= '&nbspHours</span>';
$comment_table .= '</div>';
$comment_table .= '<div class="comment_body">';
$comment_table .= $wu['description'];
$comment_table .= '</div>';
}
} else {
$comment_table = __('No comments found');
}
$upload_comment_form = '<div class="w100p">';
$upload_comment_form .= '<form method="post" id="comment_form" enctype="multipart/form-data">';
$upload_comment_form .= '<h4>'.__('Add comment').'</h4>';
$upload_comment_form .= html_print_table($table_comments_section, true);
$upload_comment_form .= html_print_input_hidden('addComment', 1, true);
$upload_comment_form .= '</form>';
$upload_comment_form .= '<h4>'.__('Comments').'</h4>';
$upload_comment_form .= $comment_table;
$upload_comment_form .= '</div>';
echo '<div class="ui_toggle">';
ui_toggle(
$upload_comment_form,
__('Comments'),
'',
'',
true,
false,
'white-box-content',
'w98p'
);
echo '</div>';
}

View File

@ -55,7 +55,6 @@ ui_print_standard_header(
]
);
if (empty($error) === false) {
ui_print_error_message($error);
}
@ -92,7 +91,7 @@ $table->data[0][0] = html_print_label_input_block(
);
$integria_logo = 'images/integria_logo_gray.png';
if ($config['style'] === 'pandora_black' && !is_metaconsole()) {
if ($config['style'] === 'pandora_black' && is_metaconsole() === false) {
$integria_logo = 'images/integria_logo.svg';
}
@ -177,7 +176,10 @@ $table->data[3][0] = html_print_label_input_block(
);
$table->data[3][1] = html_print_label_input_block(
__('Creator').ui_print_help_tip(__('This field corresponds to the Integria IMS user specified in Integria IMS setup'), true),
__('Creator').ui_print_help_tip(
__('This field corresponds to the Integria IMS user specified in Integria IMS setup'),
true
),
html_print_input_text(
'idCreator',
$config['integria_user'],
@ -200,7 +202,7 @@ $table->data[3][2] = html_print_label_input_block(
true,
0,
false,
false,
true,
'w100p',
)
);
@ -235,24 +237,10 @@ $table->data[5][0] = html_print_label_input_block(
)
);
// $table->data[5][0] = html_print_label_input_block(
// __('File name'),
// html_print_input_file('userfile', true)
// );
//
// $table->data[6][0] = html_print_label_input_block(
// __('Attachment description'),
// html_print_textarea(
// 'file_description',
// 3,
// 20,
// '',
// '',
// true
// )
// );
// Print forms and stuff.
echo '<form class="max_floating_element_size" id="create_integria_incident_form" name="create_integria_incident_form" method="POST" enctype="multipart/form-data">';
$formName = 'create_integria_incident_form';
$classForm = 'max_floating_element_size';
$enctype = 'multipart/form-data';
echo '<form class="'.$classForm.'" id="'.$formName.'" name="'.$formName.'" method="POST" enctype="'.$enctype.'">';
html_print_table($table);
$buttons = '';
if (empty($idIncidence) === true) {
@ -279,6 +267,8 @@ if (empty($idIncidence) === true) {
html_print_action_buttons($buttons);
echo '</form>';
ui_require_javascript_file('tinymce', 'vendor/tinymce/tinymce/');
?>
<script type="text/javascript">
@ -286,6 +276,8 @@ echo '</form>';
var ajax_url = '<?php echo ui_get_full_url('ajax.php'); ?>';
var fieldsData = '<?php echo json_encode($incidence['typeFieldData']); ?>';
defineTinyMCE('#textarea_description');
$('#status').on('change', function() {
if ($(this).val() === 'CLOSED') {
$('#incidence-resolution').show();

View File

@ -53,36 +53,26 @@ ui_print_standard_header(
]
);
/*
if (isset($resultDelete) === true) {
\ui_print_result_message(
$resultDelete,
__('Successfully deleted'),
__('Could not be deleted')
);
}
if (isset($resultCopy) === true) {
\ui_print_result_message(
$resultCopy,
__('Successfully duplicate'),
__('Could not be duplicate')
);
}
*/
if (empty($error) === false) {
ui_print_error_message($error);
}
if (empty($successfullyMsg) === false) {
ui_print_success_message($successfullyMsg);
}
try {
$columns = [
'id',
'idIncidence',
'title',
'groupCompany',
'statusResolution',
'priority',
'updated',
'started',
'creator',
'updateDate',
'startDate',
'idCreator',
'owner',
'operation',
];
$column_names = [
@ -95,6 +85,10 @@ try {
__('Started'),
__('Creator'),
__('Owner'),
[
'text' => __('Op.'),
'class' => 'table_action_buttons w90px',
],
];
ui_print_datatable(
@ -109,6 +103,11 @@ try {
'no_sortable_columns' => [
2,
3,
-1,
],
'order' => [
'field' => 'updateDate',
'direction' => 'desc',
],
'search_button_class' => 'sub filter float-right',
'filter_main_class' => 'box-flat white_table_graph fixed_filter_bar',
@ -118,14 +117,14 @@ try {
echo $e->getMessage();
}
$input_button = '';
$input_button = html_print_button(
$input_button = '<form method="post" action="index.php?sec=manageTickets&sec2=operation/ITSM/itsm&operation=edit">';
$input_button .= html_print_submit_button(
__('Create'),
'',
false,
'',
['icon' => 'next'],
true
);
$input_button .= '</form>';
html_print_action_buttons($input_button);