mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Diferenciar naming en base a donde se invoca la descarga, OT vs PRESUPUESTO
This commit is contained in:
@ -3686,21 +3686,30 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
public function download_zip()
|
||||
{
|
||||
$presupuesto_id = $this->request->getPost('presupuesto_id');
|
||||
$ot_id = $this->request->getPost('ot_id');
|
||||
|
||||
if (!$presupuesto_id) {
|
||||
return $this->response->setStatusCode(400)->setBody('Presupuesto ID requerido');
|
||||
}
|
||||
|
||||
// Definir prefijo si se recibió un ot_id válido
|
||||
$prefijo = (!empty($ot_id) && is_numeric($ot_id)) ? "OT_{$ot_id}" : null;
|
||||
|
||||
$ftpClient = new \App\Libraries\SafekatFtpClient();
|
||||
try {
|
||||
$zipPath = $ftpClient->downloadZipPresupuesto((int) $presupuesto_id);
|
||||
$zipPath = $ftpClient->downloadZipPresupuesto((int) $presupuesto_id, $prefijo);
|
||||
|
||||
if ($zipPath === null || !file_exists($zipPath)) {
|
||||
return $this->response->setStatusCode(404)->setBody('No se encontraron archivos');
|
||||
}
|
||||
|
||||
$nombreArchivo = $prefijo
|
||||
? "{$prefijo}_PRESUPUESTO_{$presupuesto_id}.zip"
|
||||
: "archivos_presupuesto_{$presupuesto_id}.zip";
|
||||
|
||||
return $this->response
|
||||
->download($zipPath, null) // null = usar nombre original del archivo
|
||||
->setFileName('archivos_presupuesto_' . $presupuesto_id . '.zip');
|
||||
->download($zipPath, null)
|
||||
->setFileName($nombreArchivo);
|
||||
} catch (\Throwable $e) {
|
||||
log_message('error', $e->getMessage());
|
||||
return $this->response->setStatusCode(500)->setBody('Error interno');
|
||||
@ -3708,4 +3717,5 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Produccion;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
|
||||
class Ordenmaquina extends BaseController
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo 'Orden maquina';
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Produccion;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
|
||||
class Ordentrabajomaquetacion extends BaseController
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo 'Orden maquetación';
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Produccion;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
|
||||
class Pedidoproduccion extends BaseController
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo 'Pedido produccion';
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -115,7 +115,7 @@ class SafekatFtpClient
|
||||
return implode('/', [$this->base_dir, 'pedidos_files', $rootIdExtern]);
|
||||
}
|
||||
|
||||
public function downloadZipPresupuesto(int $presupuesto_id): ?string
|
||||
public function downloadZipPresupuesto(int $presupuesto_id, ?string $prefijo = null): ?string
|
||||
{
|
||||
$modelPedidoLinea = model(PedidoLineaModel::class);
|
||||
$model = model(PresupuestoFicheroModel::class);
|
||||
@ -143,8 +143,11 @@ class SafekatFtpClient
|
||||
|
||||
foreach ($files as $file) {
|
||||
$originalName = $file->nombre ?? basename($file->file_path);
|
||||
$localFile = $localTempDir . '/' . $originalName;
|
||||
$prefixedName = $prefijo ? $prefijo . '_' . $originalName : $originalName;
|
||||
|
||||
$localFile = $localTempDir . '/' . $prefixedName;
|
||||
$remoteFile = $remotePath . '/' . basename($file->file_path);
|
||||
|
||||
$this->ftp->get($remoteFile, $localFile);
|
||||
}
|
||||
|
||||
@ -167,4 +170,5 @@ class SafekatFtpClient
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
data-bs-parent="#accordionPresupuestoFiles">
|
||||
<div class="accordion-body">
|
||||
<div class="col-12">
|
||||
<div class="dropzone needsclick" id="<?= $id ?>" data-id="<?= $modelId ?>">
|
||||
<div class="dropzone needsclick" id="<?= $id ?>" data-id="<?= $modelId ?>" data-ot-id="<?= $otId ?? '' ?>">
|
||||
|
||||
<div class="dz-message needsclick">
|
||||
Arrastre aquí los ficheros o haga click
|
||||
|
||||
@ -1,5 +1,9 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<?= view("themes/vuexy/components/dropzone",data: ['id' => 'dropzone-ot-files','modelId' => $presupuesto->id]) ?>
|
||||
<?= view("themes/vuexy/components/dropzone", data: [
|
||||
'id' => 'dropzone-ot-files',
|
||||
'modelId' => $presupuesto->id,
|
||||
'otId' => $ot->id
|
||||
]) ?>
|
||||
</div><!--//.col -->
|
||||
</div><!--//.row -->
|
||||
Reference in New Issue
Block a user