fix user model imports

This commit is contained in:
amazuecos
2025-04-09 07:04:06 +02:00
parent ae9af197ac
commit 014b48e693
3 changed files with 30 additions and 23 deletions

View File

@ -15,6 +15,7 @@ use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\I18n\Time;
use CodeIgniter\Validation\Validation;
use Config\LogoImpresion;
use Exception;
use Hermawan\DataTables\DataTable;
use Psr\Log\LoggerInterface;
@ -276,16 +277,26 @@ class Ordentrabajo extends BaseController
}
public function get_portada_img($orden_trabajo_id)
{
$ot = $this->otModel->find($orden_trabajo_id);
if ($ot->portada_path) {
$filePath = WRITEPATH . 'uploads/' . $ot->portada_path;
$mimeType = mime_content_type($filePath);
return $this->response
->setHeader('Content-Type', $mimeType)
->setHeader('Content-Length', filesize($filePath))
->setBody(file_get_contents($filePath));
} else {
return $this->response->setJSON(["message" => "Portada error", "error" => "No hay portada"])->setStatusCode(400);
try {
$ot = $this->otModel->find($orden_trabajo_id);
if ($ot->portada_path) {
$filePath = WRITEPATH . 'uploads/' . $ot->portada_path;
if (file_exists($filePath)) {
$mimeType = mime_content_type($filePath);
return $this->response
->setHeader('Content-Type', $mimeType)
->setHeader('Content-Length', filesize($filePath))
->setBody(file_get_contents($filePath));
} else {
throw new Exception('File' . $ot->portada_path . ' does not exist');
}
} else {
return $this->response->setJSON(["message" => "Portada error", "error" => "No hay portada"])->setStatusCode(400);
}
} catch (\Throwable $th) {
return $this->response->setJSON(["message" => "Portada error", "error" => $th->getMessage()])->setStatusCode(500);
}
}
public function planning_rotativa_datatable()
@ -302,8 +313,8 @@ class Ordentrabajo extends BaseController
{
$q = $this->produccionService->planningPlanaQueryDatatable();
$padreId = $this->request->getGet('padre_id');
if($padreId){
$q->where('lg_maquinas.padre_id',$padreId);
if ($padreId) {
$q->where('lg_maquinas.padre_id', $padreId);
}
return DataTable::of($q)
->edit("tiempo_real_sum", fn($q) => $q->tiempo_real_sum)
@ -372,9 +383,9 @@ class Ordentrabajo extends BaseController
$ps = $this->produccionService->init($bodyData["orden_trabajo_id"]);
$existingFiles = json_decode($bodyData["oldFiles"]);
$ps->deleteOtFiles($existingFiles);
if($files){
if ($files) {
$response = $ps->storeOtFiles($files);
}else{
} else {
$response = null;
}
return $this->response->setJSON([