Refactorizacion

This commit is contained in:
imnavajas
2025-07-23 11:56:43 +02:00
parent 065903be2f
commit e65e942e58
15 changed files with 491 additions and 181 deletions

View File

@ -3,6 +3,7 @@
namespace App\Controllers\Sistema;
use CodeIgniter\Controller;
use App\Models\Presupuestos\PresupuestoFicheroModel;
class Intranet extends Controller
{
@ -11,25 +12,24 @@ class Intranet extends Controller
{
helper('file');
$resource_path = WRITEPATH . 'uploads/presupuestos/' . $resource_name;
$model = new PresupuestoFicheroModel();
$file = $model->where('file_path LIKE', "%{$resource_name}")->first();
if (file_exists($resource_path)) {
// Get the mime type of the file
$mime_type = mime_content_type($resource_path);
// Get an instance of the Response class
$response = service('response');
// Set the content type
$response->setContentType($mime_type);
// Set the output
$response->setBody(file_get_contents($resource_path));
// Send the response to the browser
$response->send();
if (!$file) {
return service('response')->setStatusCode(404)->setBody("Archivo no encontrado");
}
$resource_path = WRITEPATH . $file->file_path;
if (file_exists($resource_path)) {
$mime_type = mime_content_type($resource_path);
$response = service('response');
$response->setContentType($mime_type);
$response->setBody(file_get_contents($resource_path));
$response->send();
} else {
return service('response')->setStatusCode(404)->setBody("Archivo no encontrado");
}
}
function tickets($resource_name)
@ -54,7 +54,6 @@ class Intranet extends Controller
// Send the response to the browser
$response->send();
}
}
function orden_trabajo($ot_id, $resource_name)
{
@ -76,7 +75,6 @@ class Intranet extends Controller
// Send the response to the browser
$response->send();
}
}
function catalogo($catalogo_id, $resource_name)
@ -99,7 +97,5 @@ class Intranet extends Controller
// Send the response to the browser
$response->send();
}
}
}
}