mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
cambiado el obtener la lista a pedidos_linea
This commit is contained in:
@ -117,12 +117,13 @@ class Pedido extends \App\Controllers\BaseResourceController
|
|||||||
$order = PedidoModel::SORTABLE_TODOS[$requestedOrder >= 0 ? $requestedOrder : 0];
|
$order = PedidoModel::SORTABLE_TODOS[$requestedOrder >= 0 ? $requestedOrder : 0];
|
||||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||||
|
|
||||||
$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
$model_linea = model('\App\Models\Pedidos\PedidoLineaModel');
|
||||||
|
$resourceData = $model_linea->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||||
|
|
||||||
return $this->respond(Collection::datatable(
|
return $this->respond(Collection::datatable(
|
||||||
$resourceData,
|
$resourceData,
|
||||||
$this->model->getResource()->countAllResults(),
|
$model_linea->getResource()->countAllResults(),
|
||||||
$this->model->getResource($search)->countAllResults()
|
$model_linea->getResource($search)->countAllResults()
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
return $this->failUnauthorized('Invalid request', 403);
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
|
|||||||
@ -39,4 +39,36 @@ class PedidoLineaModel extends \App\Models\BaseModel
|
|||||||
|
|
||||||
public static $labelField = "id";
|
public static $labelField = "id";
|
||||||
|
|
||||||
|
|
||||||
|
public function getResource(string $search = "", $estado="")
|
||||||
|
{
|
||||||
|
$builder = $this->db
|
||||||
|
->table($this->table . " t1")
|
||||||
|
->select(
|
||||||
|
"t2.id AS id, t2.updated_at AS fecha, t2.fecha_entrega_real AS fecha_entrega,
|
||||||
|
t4.nombre AS cliente, CONCAT(t5.first_name, ' ', t5.last_name) AS comercial,
|
||||||
|
t3.titulo AS titulo, t6.nombre AS ubicacion, t3.inc_rei AS inc_rei,
|
||||||
|
t3.paginas AS paginas, t3.tirada AS tirada, t3.total_aceptado AS total_presupuesto,
|
||||||
|
t2.estado AS estado"
|
||||||
|
);
|
||||||
|
|
||||||
|
$builder->join("pedidos t2", "t2.id = t1.pedido_id", "left");
|
||||||
|
$builder->join("presupuestos t3", "t1.presupuesto_id = t3.id", "left");
|
||||||
|
$builder->join("clientes t4", "t4.id = t3.cliente_id", "left");
|
||||||
|
$builder->join("users t5", "t5.id = t4.comercial_id", "left");
|
||||||
|
$builder->join("ubicaciones t6", "t6.id = t1.ubicacion_id", "left");
|
||||||
|
|
||||||
|
if($estado != "") {
|
||||||
|
$builder->where("t1.estado", $estado);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Falta implementar la busqueda por grupos
|
||||||
|
return empty($search)
|
||||||
|
? $builder
|
||||||
|
: $builder
|
||||||
|
->groupStart()
|
||||||
|
->like("t1.id", $search)
|
||||||
|
->orLike("t1.id", $search)
|
||||||
|
->groupEnd();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -53,35 +53,4 @@ class PedidoModel extends \App\Models\BaseModel
|
|||||||
|
|
||||||
public static $labelField = "id";
|
public static $labelField = "id";
|
||||||
|
|
||||||
public function getResource(string $search = "", $estado="")
|
|
||||||
{
|
|
||||||
$builder = $this->db
|
|
||||||
->table($this->table . " t1")
|
|
||||||
->select(
|
|
||||||
"t1.id AS id, t1.updated_at AS fecha, t1.fecha_entrega_real AS fecha_entrega,
|
|
||||||
t4.nombre AS cliente, CONCAT(t5.first_name, ' ', t5.last_name) AS comercial,
|
|
||||||
t3.titulo AS titulo, t6.nombre AS ubicacion, t3.inc_rei AS inc_rei,
|
|
||||||
t3.paginas AS paginas, t3.tirada AS tirada, t3.total_aceptado AS total_presupuesto,
|
|
||||||
t1.estado AS estado"
|
|
||||||
);
|
|
||||||
|
|
||||||
$builder->join("pedidos_linea t2", "t1.id = t2.pedido_id", "left");
|
|
||||||
$builder->join("presupuestos t3", "t2.presupuesto_id = t3.id", "left");
|
|
||||||
$builder->join("clientes t4", "t4.id = t3.cliente_id", "left");
|
|
||||||
$builder->join("users t5", "t5.id = t4.comercial_id", "left");
|
|
||||||
$builder->join("ubicaciones t6", "t6.id = t2.ubicacion_id", "left");
|
|
||||||
|
|
||||||
if($estado != "") {
|
|
||||||
$builder->where("t1.estado", $estado);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Falta implementar la busqueda por grupos
|
|
||||||
return empty($search)
|
|
||||||
? $builder
|
|
||||||
: $builder
|
|
||||||
->groupStart()
|
|
||||||
->like("t1.id", $search)
|
|
||||||
->orLike("t1.id", $search)
|
|
||||||
->groupEnd();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user