mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminadas respuesta. falta repasar todo y cabecera datatable y permisos menus y botones
This commit is contained in:
@ -202,6 +202,10 @@ const SK_PERMISSION_MATRIX = [
|
|||||||
"tarifa-encuadernacion.edit",
|
"tarifa-encuadernacion.edit",
|
||||||
"tarifa-encuadernacion.delete",
|
"tarifa-encuadernacion.delete",
|
||||||
"tarifa-encuadernacion.menu",
|
"tarifa-encuadernacion.menu",
|
||||||
|
"tarifa-extra.create",
|
||||||
|
"tarifa-extra.edit",
|
||||||
|
"tarifa-extra.delete",
|
||||||
|
"tarifa-extra.menu",
|
||||||
"tarifa-envio.create",
|
"tarifa-envio.create",
|
||||||
"tarifa-envio.edit",
|
"tarifa-envio.edit",
|
||||||
"tarifa-envio.delete",
|
"tarifa-envio.delete",
|
||||||
@ -246,5 +250,8 @@ const SK_PERMISSION_MATRIX = [
|
|||||||
"roles-permisos.edit",
|
"roles-permisos.edit",
|
||||||
"roles-permisos.delete",
|
"roles-permisos.delete",
|
||||||
"roles-permisos.menu",
|
"roles-permisos.menu",
|
||||||
|
"tickets.create",
|
||||||
|
"tickets.edit",
|
||||||
|
"tickets.menu",
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
@ -16,7 +16,7 @@ class Ticketcontroller extends \App\Controllers\BaseResourceController
|
|||||||
{
|
{
|
||||||
|
|
||||||
protected $modelName = TicketModel::class;
|
protected $modelName = TicketModel::class;
|
||||||
protected $format = 'json';
|
protected $format = 'json';
|
||||||
|
|
||||||
protected static $singularObjectNameCc = 'ticket';
|
protected static $singularObjectNameCc = 'ticket';
|
||||||
protected static $singularObjectName = 'Ticket';
|
protected static $singularObjectName = 'Ticket';
|
||||||
@ -25,13 +25,13 @@ class Ticketcontroller extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
protected static $viewPath = 'themes/vuexy/form/soporte/';
|
protected static $viewPath = 'themes/vuexy/form/soporte/';
|
||||||
|
|
||||||
protected $indexRoute = 'viewTicketList';
|
protected $indexRoute = 'ticketList';
|
||||||
|
|
||||||
|
|
||||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||||
{
|
{
|
||||||
$this->viewData['pageTitle'] = lang('Tickets.moduleTitle');
|
$this->viewData['pageTitle'] = lang('Tickets.moduleTitle');
|
||||||
|
|
||||||
// Breadcrumbs
|
// Breadcrumbs
|
||||||
$this->viewData['breadcrumb'] = [
|
$this->viewData['breadcrumb'] = [
|
||||||
['title' => lang("App.menu_soporte"), 'route' => "javascript:void(0);", 'active' => false],
|
['title' => lang("App.menu_soporte"), 'route' => "javascript:void(0);", 'active' => false],
|
||||||
@ -49,20 +49,19 @@ class Ticketcontroller extends \App\Controllers\BaseResourceController
|
|||||||
'currentModule' => static::$controllerSlug,
|
'currentModule' => static::$controllerSlug,
|
||||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Tickets.tickets')]),
|
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Tickets.tickets')]),
|
||||||
'usingServerSideDataTable' => true,
|
'usingServerSideDataTable' => true,
|
||||||
'userType' => auth()->user()->can('tickets.edit')? 1:0,
|
'userType' => auth()->user()->can('tickets.edit') ? 1 : 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
||||||
|
|
||||||
return view(static::$viewPath . 'viewTicketList', $viewData);
|
return view(static::$viewPath . 'viewTicketList', $viewData);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add()
|
public function add()
|
||||||
{
|
{
|
||||||
|
|
||||||
//checkPermission('tickets.create', $this->indexRoute);
|
//checkPermission('tickets.create', $this->indexRoute);
|
||||||
|
|
||||||
if ($this->request->getPost()) :
|
if ($this->request->getPost()) :
|
||||||
|
|
||||||
$nullIfEmpty = false; // !(phpversion() >= '8.1');
|
$nullIfEmpty = false; // !(phpversion() >= '8.1');
|
||||||
@ -97,33 +96,7 @@ class Ticketcontroller extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
$id = $this->model->db->insertID();
|
$id = $this->model->db->insertID();
|
||||||
|
|
||||||
$uploadPath = WRITEPATH . 'uploads/tickets/';
|
$this->saveImages($id, $this->request->getFiles());
|
||||||
|
|
||||||
$fileModel = new ticketFileModel();
|
|
||||||
$files = $this->request->getFiles();
|
|
||||||
if ($files && isset($files['files'])) {
|
|
||||||
foreach ($files['files'] as $file) {
|
|
||||||
if ($file->isValid() && !$file->hasMoved()) {
|
|
||||||
$originalName = $file->getClientName();
|
|
||||||
$fileExt = $file->getExtension();
|
|
||||||
|
|
||||||
// Generar hash SHA-256 basado en el contenido del archivo
|
|
||||||
$fileHash = hash_file("sha256", $file->getTempName());
|
|
||||||
$newFileName = $fileHash . '.' . $fileExt;
|
|
||||||
|
|
||||||
// Mover el archivo con el nombre basado en el hash
|
|
||||||
$file->move($uploadPath, $newFileName);
|
|
||||||
|
|
||||||
// Guardar en la base de datos
|
|
||||||
$fileModel->insert([
|
|
||||||
'nombre' => $originalName,
|
|
||||||
'ticket_id' => $id,
|
|
||||||
'hash' => $fileHash,
|
|
||||||
'path' => 'uploads/tickets/' . $newFileName
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
|
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
|
||||||
|
|
||||||
@ -149,6 +122,8 @@ class Ticketcontroller extends \App\Controllers\BaseResourceController
|
|||||||
$this->viewData['estados'] = $this->model->getEstados();
|
$this->viewData['estados'] = $this->model->getEstados();
|
||||||
$this->viewData['secciones'] = $this->model->getSecciones();
|
$this->viewData['secciones'] = $this->model->getSecciones();
|
||||||
|
|
||||||
|
$this->viewData['supportUsers'] = $this->getSupportUsers();
|
||||||
|
|
||||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Tickets.ticket') . ' ' . lang('Basic.global.addNewSuffix');
|
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Tickets.ticket') . ' ' . lang('Basic.global.addNewSuffix');
|
||||||
|
|
||||||
|
|
||||||
@ -157,7 +132,8 @@ class Ticketcontroller extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
public function edit($requestedId = null)
|
public function edit($requestedId = null)
|
||||||
{
|
{
|
||||||
|
$modelRespuesta = new \App\Models\Soporte\TicketRespuestaModel();
|
||||||
|
|
||||||
if ($requestedId == null) :
|
if ($requestedId == null) :
|
||||||
return $this->redirect2listView();
|
return $this->redirect2listView();
|
||||||
endif;
|
endif;
|
||||||
@ -169,16 +145,42 @@ class Ticketcontroller extends \App\Controllers\BaseResourceController
|
|||||||
return $this->redirect2listView('errorMessage', $message);
|
return $this->redirect2listView('errorMessage', $message);
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
if(!auth()->user()->can('Tickets.edit') && auth()->user()->id != $ticket->usuario_id){
|
||||||
|
return redirect()->to(route_to('TicketIndex'))->with('errorMessage', lang('Basic.global.noPermission'));
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->request->getPost()) :
|
if ($this->request->getPost()) :
|
||||||
|
|
||||||
$postData = $this->request->getPost();
|
$postData = $this->request->getPost();
|
||||||
$sanitizedData = $this->sanitized($postData, false);
|
$sanitizedData = $this->sanitized($postData, false);
|
||||||
|
|
||||||
$noException = true;
|
$noException = true;
|
||||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||||
if ($this->canValidate()) :
|
if ($this->canValidate()) :
|
||||||
try {
|
try {
|
||||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||||
|
|
||||||
|
$this->saveImages($id, $this->request->getFiles());
|
||||||
|
|
||||||
|
if(auth()->user()->can('Tickets.edit')){
|
||||||
|
|
||||||
|
$respuesta = $modelRespuesta->where('ticket_id', $id)->first();
|
||||||
|
if($respuesta == null){
|
||||||
|
$modelRespuesta->insert([
|
||||||
|
'ticket_id' => $id,
|
||||||
|
'usuario_id' => auth()->user()->id,
|
||||||
|
'mensaje' => $sanitizedData['respuesta_mensaje']
|
||||||
|
]);
|
||||||
|
}else{
|
||||||
|
$modelRespuesta->update($respuesta->id, [
|
||||||
|
'mensaje' => $sanitizedData['respuesta_mensaje'],
|
||||||
|
'usuario_id' => auth()->user()->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$noException = false;
|
$noException = false;
|
||||||
$this->dealWithException($e);
|
$this->dealWithException($e);
|
||||||
@ -204,34 +206,22 @@ class Ticketcontroller extends \App\Controllers\BaseResourceController
|
|||||||
return $this->redirect2listView('successMessage', $message);
|
return $this->redirect2listView('successMessage', $message);
|
||||||
endif;
|
endif;
|
||||||
else:
|
else:
|
||||||
$this->session->setFlashData('sweet-success', $message);
|
return redirect()->to(route_to("editTicket", $id))->with('successMessage', $message);
|
||||||
|
//$this->session->setFlashData('sweet-success', $message);
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
endif; // $noException && $successfulResult
|
endif; // $noException && $successfulResult
|
||||||
endif; // ($requestMethod === 'post')
|
endif; // ($requestMethod === 'post')
|
||||||
|
|
||||||
$this->viewData['ticket'] = $ticket;
|
$this->viewData['ticket'] = $ticket;
|
||||||
|
$this->viewData['respuesta'] = $modelRespuesta->where('ticket_id', $id)->first();
|
||||||
|
|
||||||
$this->viewData['formAction'] = route_to('updateTicket', $id);
|
$this->viewData['formAction'] = route_to('updateTicket', $id);
|
||||||
|
|
||||||
$this->viewData['categorias'] = $this->model->getCategorias();
|
$this->viewData['categorias'] = $this->model->getCategorias();
|
||||||
$this->viewData['estados'] = $this->model->getEstados();
|
$this->viewData['estados'] = $this->model->getEstados();
|
||||||
$this->viewData['secciones'] = $this->model->getSecciones();
|
$this->viewData['secciones'] = $this->model->getSecciones();
|
||||||
$defatulSoporteUserId = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('default_soporte_user_id')->value;
|
$this->viewData['supportUsers'] = $this->getSupportUsers();
|
||||||
$this->viewData['supportUsers'] = array(
|
|
||||||
array(
|
|
||||||
'id' => $defatulSoporteUserId,
|
|
||||||
'name' => model('App\Models\UserModel')->getFullName($defatulSoporteUserId)
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'id' => 2,
|
|
||||||
'name' => model('App\Models\UserModel')->getFullName(2)
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'id' => 1,
|
|
||||||
'name' => model('App\Models\UserModel')->getFullName(1)
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->viewData['imagesTicket'] = $this->getImages('ticket', $id);
|
$this->viewData['imagesTicket'] = $this->getImages('ticket', $id);
|
||||||
$this->viewData['imagesRespuesta'] = $this->getImages('respuesta', $id);
|
$this->viewData['imagesRespuesta'] = $this->getImages('respuesta', $id);
|
||||||
@ -240,7 +230,6 @@ class Ticketcontroller extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
|
|
||||||
return $this->displayForm(__METHOD__, $id);
|
return $this->displayForm(__METHOD__, $id);
|
||||||
|
|
||||||
} // end function edit(...)
|
} // end function edit(...)
|
||||||
|
|
||||||
public function datatable()
|
public function datatable()
|
||||||
@ -259,7 +248,13 @@ class Ticketcontroller extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
$searchValues = get_filter_datatables_columns($reqData);
|
$searchValues = get_filter_datatables_columns($reqData);
|
||||||
|
|
||||||
$resourceData = $this->model->getResource($searchValues);
|
if(auth()->user()->can('tickets.edit')){
|
||||||
|
$user_id = null;
|
||||||
|
}else{
|
||||||
|
$user_id = auth()->user()->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$resourceData = $this->model->getResource($searchValues, $user_id);
|
||||||
foreach ($requestedOrder as $order) {
|
foreach ($requestedOrder as $order) {
|
||||||
$column = $order['column'] ?? 0;
|
$column = $order['column'] ?? 0;
|
||||||
$dir = $order['dir'] ?? 'asc';
|
$dir = $order['dir'] ?? 'asc';
|
||||||
@ -269,7 +264,7 @@ class Ticketcontroller extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$resourceData = $resourceData->limit($length, $start)->get()->getResultObject();
|
$resourceData = $resourceData->limit($length, $start)->get()->getResultObject();
|
||||||
|
|
||||||
return $this->respond(Collection::datatable(
|
return $this->respond(Collection::datatable(
|
||||||
$resourceData,
|
$resourceData,
|
||||||
$this->model->getResource($searchValues)->countAllResults(),
|
$this->model->getResource($searchValues)->countAllResults(),
|
||||||
@ -295,27 +290,57 @@ class Ticketcontroller extends \App\Controllers\BaseResourceController
|
|||||||
->setBody(file_get_contents($filePath));
|
->setBody(file_get_contents($filePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function saveImages($ticket_id, $files = [])
|
||||||
|
{
|
||||||
|
$uploadPath = WRITEPATH . 'uploads/tickets/';
|
||||||
|
|
||||||
|
$fileModel = new ticketFileModel();
|
||||||
|
|
||||||
|
if ($files && isset($files['files'])) {
|
||||||
|
foreach ($files['files'] as $file) {
|
||||||
|
if ($file->isValid() && !$file->hasMoved()) {
|
||||||
|
$originalName = $file->getClientName();
|
||||||
|
$fileExt = $file->getExtension();
|
||||||
|
|
||||||
|
// Generar hash SHA-256 basado en el contenido del archivo
|
||||||
|
$fileHash = hash_file("sha256", $file->getTempName());
|
||||||
|
$newFileName = $fileHash . '.' . $fileExt;
|
||||||
|
|
||||||
|
// Mover el archivo con el nombre basado en el hash
|
||||||
|
$file->move($uploadPath, $newFileName);
|
||||||
|
|
||||||
|
// Guardar en la base de datos
|
||||||
|
$fileModel->insert([
|
||||||
|
'nombre' => $originalName,
|
||||||
|
'ticket_id' => $ticket_id,
|
||||||
|
'hash' => $fileHash,
|
||||||
|
'path' => 'uploads/tickets/' . $newFileName
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function getImages($tipo = 'ticket', $id = null)
|
private function getImages($tipo = 'ticket', $id = null)
|
||||||
{
|
{
|
||||||
$images = [];
|
$images = [];
|
||||||
|
|
||||||
$model = new ticketFileModel();
|
$model = new ticketFileModel();
|
||||||
if($tipo == 'ticket'){
|
if ($tipo == 'ticket') {
|
||||||
$files = $model->where('ticket_id', $id)->findAll();
|
$files = $model->where('ticket_id', $id)->findAll();
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
$ext = pathinfo($file['nombre'], PATHINFO_EXTENSION);
|
$ext = pathinfo($file['nombre'], PATHINFO_EXTENSION);
|
||||||
array_push($images,array(
|
array_push($images, array(
|
||||||
"path" => '/soporte/image/' . $file['hash'] .".". $ext,
|
"path" => '/soporte/image/' . $file['hash'] . "." . $ext,
|
||||||
"name" => $file['nombre']
|
"name" => $file['nombre']
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$files = $model->where('respuesta_id', $id)->findAll();
|
$files = $model->where('respuesta_id', $id)->findAll();
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
$ext = pathinfo($file['nombre'], PATHINFO_EXTENSION);
|
$ext = pathinfo($file['nombre'], PATHINFO_EXTENSION);
|
||||||
array_push($images,array(
|
array_push($images, array(
|
||||||
"path" => '/soporte/image/' . $file['hash'] .".". $ext,
|
"path" => '/soporte/image/' . $file['hash'] . "." . $ext,
|
||||||
"name" => $file['nombre']
|
"name" => $file['nombre']
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -323,4 +348,24 @@ class Ticketcontroller extends \App\Controllers\BaseResourceController
|
|||||||
return $images;
|
return $images;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getSupportUsers()
|
||||||
|
{
|
||||||
|
$defatulSoporteUserId = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('default_soporte_user_id')->value;
|
||||||
|
$supportUsers = array(
|
||||||
|
array(
|
||||||
|
'id' => $defatulSoporteUserId,
|
||||||
|
'name' => model('App\Models\UserModel')->getFullName($defatulSoporteUserId)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'id' => 2,
|
||||||
|
'name' => model('App\Models\UserModel')->getFullName(2)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'id' => 1,
|
||||||
|
'name' => model('App\Models\UserModel')->getFullName(1)
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return $supportUsers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,6 +61,7 @@ class CreateTicketsSystem extends Migration
|
|||||||
'usuario_id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true],
|
'usuario_id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true],
|
||||||
'mensaje' => ['type' => 'TEXT'],
|
'mensaje' => ['type' => 'TEXT'],
|
||||||
'created_at' => ['type' => 'DATETIME', 'null' => true],
|
'created_at' => ['type' => 'DATETIME', 'null' => true],
|
||||||
|
'updated_at' => ['type' => 'DATETIME', 'null' => true],
|
||||||
]);
|
]);
|
||||||
$this->forge->addPrimaryKey('id');
|
$this->forge->addPrimaryKey('id');
|
||||||
$this->forge->addForeignKey('ticket_id', 'tickets', 'id', '', 'NO ACTION');
|
$this->forge->addForeignKey('ticket_id', 'tickets', 'id', '', 'NO ACTION');
|
||||||
|
|||||||
20
ci4/app/Entities/Soporte/TicketRespuestaEntity.php
Normal file
20
ci4/app/Entities/Soporte/TicketRespuestaEntity.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entities\Soporte;
|
||||||
|
|
||||||
|
use CodeIgniter\Entity\Entity;
|
||||||
|
|
||||||
|
class TicketRespuestaEntity extends Entity
|
||||||
|
{
|
||||||
|
protected $attributes = [
|
||||||
|
'id' => null,
|
||||||
|
'ticket_id' => null,
|
||||||
|
'usuario_id' => null,
|
||||||
|
'mensaje' => null,
|
||||||
|
'created_at' => null,
|
||||||
|
'updated_at' => null,
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $dates = ['created_at', 'updated_at'];
|
||||||
|
|
||||||
|
}
|
||||||
@ -88,6 +88,7 @@ return [
|
|||||||
'line' => 'la línea',
|
'line' => 'la línea',
|
||||||
'error_tittle' => 'Error',
|
'error_tittle' => 'Error',
|
||||||
],
|
],
|
||||||
|
'noPermission' => 'No tiene permiso para acceder a esta página.',
|
||||||
'ok' => 'Ok',
|
'ok' => 'Ok',
|
||||||
'wait' => 'Espere',
|
'wait' => 'Espere',
|
||||||
'yes' => 'Si',
|
'yes' => 'Si',
|
||||||
|
|||||||
@ -17,6 +17,7 @@ return [
|
|||||||
"usuario" => "Creado por",
|
"usuario" => "Creado por",
|
||||||
"createTicket" => "Crear Ticket",
|
"createTicket" => "Crear Ticket",
|
||||||
"fechaCreacion" => "Fecha de creación",
|
"fechaCreacion" => "Fecha de creación",
|
||||||
|
"respuesta" => "Respuesta",
|
||||||
|
|
||||||
// categorías
|
// categorías
|
||||||
'errores' => 'Errores',
|
'errores' => 'Errores',
|
||||||
@ -45,6 +46,5 @@ return [
|
|||||||
// FIcheros
|
// FIcheros
|
||||||
'adjuntos' => 'Adjuntar imágenes',
|
'adjuntos' => 'Adjuntar imágenes',
|
||||||
'adjuntos_ticket' => 'Imágenes adjuntas',
|
'adjuntos_ticket' => 'Imágenes adjuntas',
|
||||||
'adjuntos_respuesta' => 'Imágenes adjuntos de la respuesta',
|
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
@ -71,7 +71,7 @@ class TicketModel extends \App\Models\BaseModel
|
|||||||
return $this->find($id);
|
return $this->find($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getResource($search = [], )
|
public function getResource($search = [], $user_id = null)
|
||||||
{
|
{
|
||||||
$builder = $this->db
|
$builder = $this->db
|
||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
@ -91,6 +91,9 @@ class TicketModel extends \App\Models\BaseModel
|
|||||||
$builder->join("tickets_estados t4", "t1.estado_id = t4.id", "left");
|
$builder->join("tickets_estados t4", "t1.estado_id = t4.id", "left");
|
||||||
$builder->join("tickets_secciones t5", "t1.seccion_id = t5.id", "left");
|
$builder->join("tickets_secciones t5", "t1.seccion_id = t5.id", "left");
|
||||||
|
|
||||||
|
if ($user_id !== null)
|
||||||
|
$builder->where("t1.usuario_id", $user_id);
|
||||||
|
|
||||||
if (empty($search))
|
if (empty($search))
|
||||||
return $builder;
|
return $builder;
|
||||||
else {
|
else {
|
||||||
|
|||||||
17
ci4/app/Models/Soporte/TicketRespuestaModel.php
Normal file
17
ci4/app/Models/Soporte/TicketRespuestaModel.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Soporte;
|
||||||
|
|
||||||
|
|
||||||
|
class TicketRespuestaModel extends \App\Models\BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $table = 'tickets_respuestas';
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
protected $allowedFields = ['ticket_id', 'usuario_id', 'mensaje' ,'createt_at', 'updated_at'];
|
||||||
|
|
||||||
|
protected $useTimestamps = true;
|
||||||
|
|
||||||
|
protected $returnType = "App\Entities\Soporte\TicketRespuestaEntity";
|
||||||
|
|
||||||
|
}
|
||||||
@ -33,7 +33,7 @@
|
|||||||
<div class="mb-3 col-9">
|
<div class="mb-3 col-9">
|
||||||
<label class="form-label"><?= lang("Tickets.asunto") ?></label>
|
<label class="form-label"><?= lang("Tickets.asunto") ?></label>
|
||||||
<input type="text" name="titulo" class="form-control"
|
<input type="text" name="titulo" class="form-control"
|
||||||
<?= ($formAction !== route_to('NewTicket', $ticket->id))?"readonly":"" ?>
|
<?= ($formAction !== route_to('NewTicket', $ticket->id)) ? "readonly" : "" ?>
|
||||||
value="<?= old('titulo', $ticket->titulo) ?>">
|
value="<?= old('titulo', $ticket->titulo) ?>">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -43,7 +43,7 @@
|
|||||||
<div class="col-3 mb-3">
|
<div class="col-3 mb-3">
|
||||||
<label class="form-label"><?= lang("Tickets.tipo") ?></label>
|
<label class="form-label"><?= lang("Tickets.tipo") ?></label>
|
||||||
<select id="categoria" name="categoria_id" class="form-control select2"
|
<select id="categoria" name="categoria_id" class="form-control select2"
|
||||||
<?= ($formAction !== route_to('NewTicket', $ticket->id) && !auth()->user()->can('tickets.edit'))?"disabled":"" ?>>
|
<?= ($formAction !== route_to('NewTicket', $ticket->id) && !auth()->user()->can('tickets.edit')) ? "disabled" : "" ?>>
|
||||||
<?php foreach ($categorias as $categoria): ?>
|
<?php foreach ($categorias as $categoria): ?>
|
||||||
<option value="<?= $categoria['id']; ?>" <?= $categoria['id'] == $ticket->categoria_id ? ' selected' : '' ?>> <?= $categoria['text']; ?>
|
<option value="<?= $categoria['id']; ?>" <?= $categoria['id'] == $ticket->categoria_id ? ' selected' : '' ?>> <?= $categoria['text']; ?>
|
||||||
</option>
|
</option>
|
||||||
@ -55,7 +55,7 @@
|
|||||||
<div class="col-3 mb-3">
|
<div class="col-3 mb-3">
|
||||||
<label class="form-label"><?= lang("Tickets.seccion") ?></label>
|
<label class="form-label"><?= lang("Tickets.seccion") ?></label>
|
||||||
<select id="seccion" name="seccion_id" class="form-control select2"
|
<select id="seccion" name="seccion_id" class="form-control select2"
|
||||||
<?= ($formAction !== route_to('NewTicket', $ticket->id) && !auth()->user()->can('tickets.edit'))?"disabled":"" ?>>
|
<?= ($formAction !== route_to('NewTicket', $ticket->id) && !auth()->user()->can('tickets.edit')) ? "disabled" : "" ?>>
|
||||||
<?php foreach ($secciones as $seccion): ?>
|
<?php foreach ($secciones as $seccion): ?>
|
||||||
<option value="<?= $seccion['id']; ?>" <?= $seccion['id'] == $ticket->seccion_id ? ' selected' : '' ?>><?= $seccion['text']; ?>
|
<option value="<?= $seccion['id']; ?>" <?= $seccion['id'] == $ticket->seccion_id ? ' selected' : '' ?>><?= $seccion['text']; ?>
|
||||||
</option>
|
</option>
|
||||||
@ -67,14 +67,14 @@
|
|||||||
<label class="form-label"><?= lang("Tickets.estado") ?></label>
|
<label class="form-label"><?= lang("Tickets.estado") ?></label>
|
||||||
<?php if ($formAction !== route_to('NewTicket') && auth()->user()->can('tickets.edit')): ?>
|
<?php if ($formAction !== route_to('NewTicket') && auth()->user()->can('tickets.edit')): ?>
|
||||||
<select id="estado" name="estado_id" class="form-control select2">
|
<select id="estado" name="estado_id" class="form-control select2">
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<select id="estado" name="estado_id" class="form-control select2" disabled>
|
<select id="estado" name="estado_id" class="form-control select2" disabled>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php foreach ($estados as $estado): ?>
|
<?php foreach ($estados as $estado): ?>
|
||||||
<option value="<?= $estado['id']; ?>" <?= $estado['id'] == $ticket->estado_id ? ' selected' : '' ?>><?= $estado['text']; ?>
|
<option value="<?= $estado['id']; ?>" <?= $estado['id'] == $ticket->estado_id ? ' selected' : '' ?>><?= $estado['text']; ?>
|
||||||
</option>
|
</option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -114,11 +114,24 @@
|
|||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label"><?= lang("Tickets.descripcion") ?></label>
|
<label class="form-label"><?= lang("Tickets.descripcion") ?></label>
|
||||||
<textarea id="descripcion" name="descripcion" class="form-control"
|
<textarea id="descripcion" name="descripcion" class="form-control"
|
||||||
<?= ($formAction !== route_to('NewTicket', $ticket->id))?"readonly":"" ?>
|
<?= ($formAction !== route_to('NewTicket', $ticket->id)) ? "readonly" : "" ?>
|
||||||
rows="4"><?= old('descripcion', $ticket->descripcion) ?></textarea>
|
rows="4"><?= old('descripcion', $ticket->descripcion) ?></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php if ($formAction === route_to('NewTicket')): ?>
|
<?php if (isset($respuesta) || ($formAction !== route_to('NewTicket') && auth()->user()->can('tickets.edit'))) : ?>
|
||||||
|
|
||||||
|
<h4><?= lang("Tickets.respuesta") ?></h4>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label"><?= lang("Tickets.respuesta") ?></label>
|
||||||
|
<textarea id="respuestaMensaje" name="respuesta_mensaje" class="form-control"
|
||||||
|
<?= !auth()->user()->can('tickets.edit') ? "readonly" : "" ?>
|
||||||
|
rows="4"><?= isset($respuesta) ? old('respuestaMensaje', $respuesta->mensaje) : "" ?></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if ($formAction === route_to('NewTicket') || ($formAction !== route_to('NewTicket') && auth()->user()->can('tickets.edit'))): ?>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
@ -127,8 +140,9 @@
|
|||||||
accept="image/*">
|
accept="image/*">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php else: ?>
|
<?php if ($formAction !== route_to('NewTicket')): ?>
|
||||||
<h4><?= lang("Tickets.adjuntos_ticket") ?></h4>
|
<h4><?= lang("Tickets.adjuntos_ticket") ?></h4>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<?php foreach ($imagesTicket as $image): ?>
|
<?php foreach ($imagesTicket as $image): ?>
|
||||||
@ -145,14 +159,15 @@
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<div class="pt-4">
|
<div class="pt-4">
|
||||||
<?php if ($formAction === route_to('NewTicket') ||
|
<?php if (
|
||||||
($formAction !== route_to('NewTicket') && auth()->user()->can('tickets.edit'))): ?>
|
$formAction === route_to('NewTicket') ||
|
||||||
|
($formAction !== route_to('NewTicket') && auth()->user()->can('tickets.edit'))
|
||||||
|
): ?>
|
||||||
<input
|
<input
|
||||||
type="submit"
|
type="submit"
|
||||||
class="btn btn-primary float-start me-sm-3 me-1"
|
class="btn btn-primary float-start me-sm-3 me-1"
|
||||||
name="save"
|
name="save"
|
||||||
value="<?= lang("Basic.global.Save") ?>"
|
value="<?= lang("Basic.global.Save") ?>" />
|
||||||
/>
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?= anchor(route_to("TicketIndex"), lang("Basic.global.back"), ["class" => "btn btn-secondary"]) ?>
|
<?= anchor(route_to("TicketIndex"), lang("Basic.global.back"), ["class" => "btn btn-secondary"]) ?>
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>403 Forbidden</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<p>Directory access is forbidden.</p>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Reference in New Issue
Block a user