diff --git a/pandora_console/include/javascript/ITSM.js b/pandora_console/include/javascript/ITSM.js
index 974af45a37..4ad40b329c 100644
--- a/pandora_console/include/javascript/ITSM.js
+++ b/pandora_console/include/javascript/ITSM.js
@@ -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);
+ }
+ });
+}
diff --git a/pandora_console/include/lib/ITSM/ITSM.php b/pandora_console/include/lib/ITSM/ITSM.php
index 8c9756ab06..8e23161b67 100644
--- a/pandora_console/include/lib/ITSM/ITSM.php
+++ b/pandora_console/include/lib/ITSM/ITSM.php
@@ -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;
diff --git a/pandora_console/include/lib/ITSM/Manager.php b/pandora_console/include/lib/ITSM/Manager.php
index 2431547dd8..7c702fc4a8 100644
--- a/pandora_console/include/lib/ITSM/Manager.php
+++ b/pandora_console/include/lib/ITSM/Manager.php
@@ -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 = '
';
+ $output .= $label;
+ $output .= '
';
+
+ 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 = '';
+ $new->title .= $tmp->title;
+ $new->title .= '';
+ $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 = '';
$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;
+ }
+
+
}
diff --git a/pandora_console/include/styles/integriaims.css b/pandora_console/include/styles/integriaims.css
index e55c992bbe..01383a8833 100644
--- a/pandora_console/include/styles/integriaims.css
+++ b/pandora_console/include/styles/integriaims.css
@@ -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;
+}
diff --git a/pandora_console/views/ITSM/ITSMCustomFields.php b/pandora_console/views/ITSM/ITSMCustomFields.php
index 6837ff43f4..378c7d3151 100644
--- a/pandora_console/views/ITSM/ITSMCustomFields.php
+++ b/pandora_console/views/ITSM/ITSMCustomFields.php
@@ -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;
diff --git a/pandora_console/views/ITSM/ITSMTicketDetailView.php b/pandora_console/views/ITSM/ITSMTicketDetailView.php
new file mode 100644
index 0000000000..592cd44b8f
--- /dev/null
+++ b/pandora_console/views/ITSM/ITSMTicketDetailView.php
@@ -0,0 +1,386 @@
+ '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 = '';
+ $details_box .= '
'.__('Status').'
';
+ $details_box .= '
'.__('Resolution').'
';
+ $details_box .= '
'.__('Group').'
';
+ $details_box .= '
'.__('Priority').'
';
+ $details_box .= '
'.__('Type').'
';
+ $details_box .= '
';
+ $details_box .= html_print_image('images/heart.png', true, ['class' => 'invert_filter']);
+ $details_box .= '
';
+ $details_box .= '
';
+ $details_box .= html_print_image('images/builder@svg.svg', true, ['class' => 'invert_filter']);
+ $details_box .= '
';
+ $details_box .= '
';
+ $details_box .= html_print_image('images/user_green.png', true, ['class' => 'invert_filter']);
+ $details_box .= '
';
+ $details_box .= '
';
+ $details_box .= $priorityDiv;
+ $details_box .= '
';
+ $details_box .= '
';
+ $details_box .= html_print_image('images/incidents.png', true, ['class' => 'invert_filter']);
+ $details_box .= '
';
+ $details_box .= '
'.$status[$incidence['status']].'
';
+ $details_box .= '
';
+ $details_box .= ($incidence['resolution'] !== 'NOTRESOLVED') ? $resolutions[$incidence['resolution']] : '--';
+ $details_box .= '
';
+ $details_box .= '
'.$groups[$incidence['idGroup']].'
';
+ $details_box .= '
'.$priorities[$incidence['priority']].'
';
+ $details_box .= '
';
+ $details_box .= $nameIncidence;
+ $details_box .= '
';
+ $details_box .= '
';
+
+ // People box.
+ $people_box = '';
+ $people_box .= '
';
+ $people_box .= html_print_image('images/header_user_green.png', true, ['width' => '21']);
+ $people_box .= '
';
+ $people_box .= '
';
+ $people_box .= html_print_image('images/header_user_green.png', true, ['width' => '21']);
+ $people_box .= '
';
+ $people_box .= '
';
+ $people_box .= html_print_image('images/header_user_green.png', true, ['width' => '21']);
+ $people_box .= '
';
+
+ $people_box .= '
'.__('Created by').':
';
+ $people_box .= '
'.__('Owned by').':
';
+ $people_box .= '
'.__('Closed by').':
';
+
+ $people_box .= '
';
+ $people_box .= (empty($incidence['idCreator']) === false) ? $users[$incidence['idCreator']] : '--';
+ $people_box .= '
';
+ $people_box .= '
';
+ $people_box .= (empty($incidence['owner']) === false) ? $users[$incidence['owner']] : '--';
+ $people_box .= '
';
+ $people_box .= '
';
+ $people_box .= (empty($incidence['closedBy']) === false) ? $users[$incidence['closedBy']] : '--';
+ $people_box .= '
';
+ $people_box .= '
';
+
+ // Dates box.
+ $dates_box = '';
+ $dates_box .= '
';
+ $dates_box .= html_print_image('images/tick.png', true, ['class' => 'invert_filter']);
+ $dates_box .= '
';
+ $dates_box .= '
';
+ $dates_box .= html_print_image('images/update.png', true, ['width' => '21', 'class' => 'invert_filter']);
+ $dates_box .= '
';
+ $dates_box .= '
';
+ $dates_box .= html_print_image('images/mul.png', true, ['class' => 'invert_filter']);
+ $dates_box .= '
';
+
+ $dates_box .= '
'.__('Created at').':
';
+ $dates_box .= '
'.__('Updated at').':
';
+ $dates_box .= '
'.__('Closed at').':
';
+
+ $dates_box .= '
'.$incidence['startDate'].'
';
+ $dates_box .= '
'.$incidence['updateDate'].'
';
+ $dates_box .= '
';
+ $dates_box .= (($incidence['closeDate'] === '0000-00-00 00:00:00') ? '--' : $incidence['closeDate']);
+ $dates_box .= '
';
+ $dates_box .= '
';
+
+ // Show details, people and dates.
+ echo '';
+ 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 '
';
+
+ // Show description.
+ $description_box = '';
+ $description_box .= $incidence['description'];
+ $description_box .= '
';
+ 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] = '';
+ $table_files_section->data[0][0] .= '
'.__('File name').':
';
+ $table_files_section->data[0][0] .= html_print_input_file('userfile', true);
+ $table_files_section->data[0][1] = '
';
+ $table_files_section->data[0][1] .= '
';
+ $table_files_section->data[0][1] .= __('Attachment description');
+ $table_files_section->data[0][1] .= ':
';
+ $table_files_section->data[0][1] .= html_print_textarea(
+ 'file_description',
+ 3,
+ 20,
+ '',
+ '',
+ true,
+ 'w100p'
+ );
+
+ $table_files_section->data[0][2] = '
';
+ $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] .= '
';
+
+ // 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] = '
'.$file['filename'].'';
+ $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] .= '
';
+ $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] .= '';
+ }
+
+ $upload_file_form = '
';
+ $upload_file_form .= '';
+ $upload_file_form .= '
';
+
+ echo '
';
+ ui_toggle(
+ $upload_file_form,
+ __('Attached files'),
+ '',
+ '',
+ true,
+ false,
+ 'white-box-content',
+ 'w98p'
+ );
+ echo '
';
+
+ // 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] = '
';
+ $table_comments_section->data[0][0] .= '
';
+ $table_comments_section->data[0][0] .= __('Description');
+ $table_comments_section->data[0][0] .= ':
';
+ $table_comments_section->data[0][0] .= html_print_textarea(
+ 'comment_description',
+ 3,
+ 20,
+ '',
+ '',
+ true,
+ 'w100p'
+ );
+
+ $table_comments_section->data[0][1] = '
';
+ $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] .= '
';
+
+ // Comments list table.
+ $comment_table = '';
+ if (empty($wus) === false) {
+ foreach ($wus['data'] as $wu) {
+ $comment_table .= '';
+ $comment_table .= '
';
+ $comment_table .= $wu['description'];
+ $comment_table .= '
';
+ }
+ } else {
+ $comment_table = __('No comments found');
+ }
+
+ $upload_comment_form = '
';
+ $upload_comment_form .= '';
+ $upload_comment_form .= '
'.__('Comments').'
';
+ $upload_comment_form .= $comment_table;
+ $upload_comment_form .= '';
+
+ echo '
';
+ ui_toggle(
+ $upload_comment_form,
+ __('Comments'),
+ '',
+ '',
+ true,
+ false,
+ 'white-box-content',
+ 'w98p'
+ );
+ echo '
';
+}
diff --git a/pandora_console/views/ITSM/ITSMTicketEditView.php b/pandora_console/views/ITSM/ITSMTicketEditView.php
index 7ebfaa69ad..8c55f32845 100644
--- a/pandora_console/views/ITSM/ITSMTicketEditView.php
+++ b/pandora_console/views/ITSM/ITSMTicketEditView.php
@@ -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 '
';
+
+ui_require_javascript_file('tinymce', 'vendor/tinymce/tinymce/');
?>