mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
generando el grupo de envios
This commit is contained in:
@ -4,6 +4,7 @@ namespace App\Controllers\Logistica;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Services\ImpresoraEtiquetaService;
|
||||
use App\Services\LogisticaService;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@ -70,28 +71,14 @@ class LogisticaController extends BaseController
|
||||
|
||||
public function searchPedidoOrISBN($search = ""){
|
||||
|
||||
$modelPedido = model('App\Models\Pedidos\PedidoModel');
|
||||
|
||||
$search = trim($search);
|
||||
$searchClean = str_replace('-', '', $search);
|
||||
$modelPedido = model('App\Models\Pedidos\PedidoModel');
|
||||
|
||||
// Builder con joins
|
||||
$builder = $modelPedido->builder();
|
||||
$builder->select('pedidos.*');
|
||||
$builder->join('pedidos_linea', 'pedidos_linea.pedido_id = pedidos.id', 'left');
|
||||
$builder->join('presupuestos', 'presupuestos.id = pedidos_linea.presupuesto_id', 'left');
|
||||
|
||||
// Agrupar condiciones: por ID exacto o por ISBN sin guiones
|
||||
$builder->groupStart()
|
||||
->where('pedidos.id', $search)
|
||||
->orWhere("REPLACE(presupuestos.isbn, '-', '')", $searchClean)
|
||||
->groupEnd();
|
||||
|
||||
$result = $builder->get()->getResult();
|
||||
$response = [
|
||||
'status' => true,
|
||||
'data' => $result,
|
||||
];
|
||||
if(empty($search)){
|
||||
$result = [
|
||||
'status' => false,
|
||||
'message' => lang('Logistica.errors.noDataToFind'),
|
||||
];
|
||||
return $this->response->setJSON($result);
|
||||
}
|
||||
$result = LogisticaService::findPedidoOrISBN($search);
|
||||
return $this->response->setJSON($result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user