terminado a falta de pruebas

This commit is contained in:
2025-04-26 10:50:59 +02:00
parent ef173ab0fc
commit b5b86b4164
6 changed files with 159 additions and 69 deletions

View File

@ -128,9 +128,53 @@ class LogisticaController extends BaseController
$envio_id = $this->request->getPost('envio_id');
$ids = $this->request->getPost('envio_lineas');
$cajas = $this->request->getPost('cajas');
$result = ['status' => true];//LogisticaService::imprimirEtiquetas($ids);
return $this->response->setJSON($result);
$printer_id = $this->request->getPost('printer_id');
if($cajas == null || $cajas == 0){
return $this->response->setJSON([
'status' => false,
'message' => 'Cajas no válidas'
]);
}
$model = model('App\Models\Logistica\EnvioModel');
$envio = $model->select('envios.*, clientes.nombre as cliente')
->join('clientes', 'clientes.id = envios.cliente_id', 'left')
->where('envios.id', $envio_id)
->first();
if($envio == null){
return $this->response->setJSON([
'status' => false,
'message' => 'Envio no válido'
]);
}
$model = model('App\Models\Logistica\EnvioLineaModel');
$lineas = $model->select('envios_lineas.*, presupuestos.titulo as titulo, presupuestos.referencia_cliente as referencia_cliente')
->join('presupuestos', 'presupuestos.id = envios_lineas.presupuesto_id', 'left')
->whereIn('envios_lineas.id', $ids)->findAll();
if($lineas == null){
return $this->response->setJSON([
'status' => false,
'message' => 'Lineas no válidas'
]);
}
$modelImpresora = model('App\Models\Configuracion\ImpresoraEtiquetaModel');
$impresora = $modelImpresora->select('id, name')
->where('deleted_at', null)
->where('id', $printer_id)
->orderBy('name', 'asc')
->first();
if($impresora == null){
return $this->response->setJSON([
'status' => false,
'message' => 'Impresora no válida'
]);
}
$response = LogisticaService::generateEtiquetasTitulos($envio, $lineas, $impresora, $cajas);
return $this->response->setJSON($response);
} else {
return $this->failUnauthorized('Invalid request', 403);
@ -236,6 +280,14 @@ class LogisticaController extends BaseController
$envioEntity->proveedor_nombre = $proveedor->nombre;
}
$modelImpresora = model('App\Models\Configuracion\ImpresoraEtiquetaModel');
$impresoras = $modelImpresora->select('id, name')
->where('deleted_at', null)
->where('tipo', 1)
->orderBy('name', 'asc')
->findAll();
$envioEntity->impresoras = $impresoras;
$viewData = [
'currentModule' => static::$controllerSlug,
'boxTitle' => '<i class="ti ti-truck ti-xl"></i>' . ' ' . lang('Logistica.envio') . ' [' . $envioEntity->id . ']: ' . $envioEntity->direccion,