mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminado tickets. faltan respuestas
This commit is contained in:
@ -2,16 +2,21 @@
|
||||
|
||||
namespace App\Controllers\Soporte;
|
||||
|
||||
use App\Models\TicketModel;
|
||||
use App\Models\Soporte\TicketModel;
|
||||
use App\Models\CategoriaModel;
|
||||
use App\Models\EstadoModel;
|
||||
use CodeIgniter\Controller;
|
||||
use App\Entities\Soporte\TicketEntity;
|
||||
use App\Models\Soporte\ticketFileModel;
|
||||
|
||||
class Ticketcontroller extends \App\Controllers\GoBaseController
|
||||
|
||||
use App\Models\Collection;
|
||||
|
||||
class Ticketcontroller extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
protected static $primaryModelName = 'App\Models\Soporte\ticketModel';
|
||||
|
||||
protected $modelName = TicketModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectNameCc = 'ticket';
|
||||
protected static $singularObjectName = 'Ticket';
|
||||
@ -34,17 +39,22 @@ class Ticketcontroller extends \App\Controllers\GoBaseController
|
||||
];
|
||||
|
||||
parent::initController($request, $response, $logger);
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
//checkPermission('tickets.menu');
|
||||
|
||||
$this->viewData['usingClientSideDataTable'] = true;
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Tickets.tickets')]),
|
||||
'usingServerSideDataTable' => true,
|
||||
'userType' => auth()->user()->can('tickets.edit')? 1:0,
|
||||
];
|
||||
|
||||
$this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Tickets.tickets')]);
|
||||
parent::index();
|
||||
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
||||
|
||||
return view(static::$viewPath . 'viewTicketList', $viewData);
|
||||
|
||||
}
|
||||
|
||||
@ -109,7 +119,7 @@ class Ticketcontroller extends \App\Controllers\GoBaseController
|
||||
'nombre' => $originalName,
|
||||
'ticket_id' => $id,
|
||||
'hash' => $fileHash,
|
||||
'path' => 'uploads/' . $newFileName
|
||||
'path' => 'uploads/tickets/' . $newFileName
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -139,7 +149,7 @@ class Ticketcontroller extends \App\Controllers\GoBaseController
|
||||
$this->viewData['estados'] = $this->model->getEstados();
|
||||
$this->viewData['secciones'] = $this->model->getSecciones();
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Tarifaextra.tarifaextra') . ' ' . lang('Basic.global.addNewSuffix');
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Tickets.ticket') . ' ' . lang('Basic.global.addNewSuffix');
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__);
|
||||
@ -147,32 +157,22 @@ class Ticketcontroller extends \App\Controllers\GoBaseController
|
||||
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
/*
|
||||
checkPermission('tarifa-extra.edit', $this->indexRoute);
|
||||
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$tarifaextraEntity = $this->model->find($id);
|
||||
$ticket = $this->model->find($id);
|
||||
|
||||
if ($tarifaextraEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Tarifaextra.tarifaextra')), $id]);
|
||||
if ($ticket == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Tickets.ticket')), $id]);
|
||||
return $this->redirect2listView('errorMessage', $message);
|
||||
endif;
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
$sanitizedData = $this->sanitized($postData, true);
|
||||
|
||||
// JJO
|
||||
if (isset($this->model->user_updated_id)) {
|
||||
$sanitizedData['user_updated_id'] = auth()->user()->id;
|
||||
}
|
||||
if ($this->request->getPost('mostrar_en_presupuesto') == null) {
|
||||
$sanitizedData['mostrar_en_presupuesto'] = false;
|
||||
}
|
||||
$sanitizedData = $this->sanitized($postData, false);
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
@ -184,17 +184,17 @@ class Ticketcontroller extends \App\Controllers\GoBaseController
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Tarifaextra.tarifaextra'))]);
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Tickets.ticket'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$tarifaextraEntity->fill($sanitizedData);
|
||||
$ticket->fill($sanitizedData);
|
||||
|
||||
$thenRedirect = false;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $tarifaextraEntity->id ?? $id;
|
||||
$id = $ticket->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
@ -210,15 +210,37 @@ class Ticketcontroller extends \App\Controllers\GoBaseController
|
||||
endif; // $noException && $successfulResult
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['tarifaextraEntity'] = $tarifaextraEntity;
|
||||
$this->viewData['ticket'] = $ticket;
|
||||
|
||||
$this->viewData['formAction'] = route_to('updateTarifaextra', $id);
|
||||
$this->viewData['formAction'] = route_to('updateTicket', $id);
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Tarifaextra.tarifaextra') . ' ' . lang('Basic.global.edit3');
|
||||
$this->viewData['categorias'] = $this->model->getCategorias();
|
||||
$this->viewData['estados'] = $this->model->getEstados();
|
||||
$this->viewData['secciones'] = $this->model->getSecciones();
|
||||
$defatulSoporteUserId = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('default_soporte_user_id')->value;
|
||||
$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['imagesRespuesta'] = $this->getImages('respuesta', $id);
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Tickets.ticket') . ' ' . lang('Basic.global.edit3');
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
*/
|
||||
|
||||
} // end function edit(...)
|
||||
|
||||
public function datatable()
|
||||
@ -237,7 +259,7 @@ class Ticketcontroller extends \App\Controllers\GoBaseController
|
||||
|
||||
$searchValues = get_filter_datatables_columns($reqData);
|
||||
|
||||
$resourceData = $this->model->getResource($searchValues, $cliente_id);
|
||||
$resourceData = $this->model->getResource($searchValues);
|
||||
foreach ($requestedOrder as $order) {
|
||||
$column = $order['column'] ?? 0;
|
||||
$dir = $order['dir'] ?? 'asc';
|
||||
@ -258,4 +280,47 @@ class Ticketcontroller extends \App\Controllers\GoBaseController
|
||||
}
|
||||
}
|
||||
|
||||
public function image($imageName)
|
||||
{
|
||||
$filePath = WRITEPATH . "uploads/tickets/" . $imageName;
|
||||
|
||||
if (!file_exists($filePath)) {
|
||||
return $this->response->setStatusCode(404, 'Imagen no encontrada');
|
||||
}
|
||||
|
||||
$mimeType = mime_content_type($filePath);
|
||||
|
||||
return $this->response
|
||||
->setHeader('Content-Type', $mimeType)
|
||||
->setBody(file_get_contents($filePath));
|
||||
}
|
||||
|
||||
private function getImages($tipo = 'ticket', $id = null)
|
||||
{
|
||||
$images = [];
|
||||
|
||||
$model = new ticketFileModel();
|
||||
if($tipo == 'ticket'){
|
||||
$files = $model->where('ticket_id', $id)->findAll();
|
||||
foreach ($files as $file) {
|
||||
$ext = pathinfo($file['nombre'], PATHINFO_EXTENSION);
|
||||
array_push($images,array(
|
||||
"path" => '/soporte/image/' . $file['hash'] .".". $ext,
|
||||
"name" => $file['nombre']
|
||||
));
|
||||
}
|
||||
}
|
||||
else{
|
||||
$files = $model->where('respuesta_id', $id)->findAll();
|
||||
foreach ($files as $file) {
|
||||
$ext = pathinfo($file['nombre'], PATHINFO_EXTENSION);
|
||||
array_push($images,array(
|
||||
"path" => '/soporte/image/' . $file['hash'] .".". $ext,
|
||||
"name" => $file['nombre']
|
||||
));
|
||||
}
|
||||
}
|
||||
return $images;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user