mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en pagos (datepicker)
This commit is contained in:
@ -78,38 +78,39 @@ class PedidoLineaModel extends \App\Models\BaseModel
|
||||
}
|
||||
|
||||
|
||||
public function obtenerLineasPedidoSinFacturar($cliente_id){
|
||||
|
||||
public function obtenerLineasPedidoSinFacturar($cliente_id) {
|
||||
$resultaArray = [];
|
||||
|
||||
|
||||
$subquery = $this->db
|
||||
->table('facturas_pedidos_lineas')
|
||||
->select('pedido_linea_id, SUM(cantidad) AS total_cantidad')
|
||||
->groupBy('pedido_linea_id')
|
||||
->getCompiledSelect();
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select("t1.id AS id, t1.pedido_id AS pedido_id, t3.titulo AS titulo, t4.codigo AS tipo_impresion");
|
||||
|
||||
$builder->join("pedidos t2", "t2.id = t1.pedido_id", "left");
|
||||
$builder->join("presupuestos t3", "t3.id = t1.presupuesto_id", "left");
|
||||
$builder->join("tipos_presupuestos t4", "t4.id = t3.tipo_impresion_id", "left");
|
||||
|
||||
$builder->join("facturas_pedidos_lineas fpl", "fpl.pedido_linea_id = t1.id", "left");
|
||||
|
||||
$builder->where("t3.cliente_id", $cliente_id);
|
||||
$builder->where("t2.estado", "finalizado");
|
||||
|
||||
|
||||
$builder->where("(`t3`.`tirada` > `fpl`.`cantidad` OR fpl.pedido_linea_id IS NULL)");
|
||||
|
||||
->select("t1.id AS id, t1.pedido_id AS pedido_id, t3.titulo AS titulo, t4.codigo AS tipo_impresion")
|
||||
->join("pedidos t2", "t2.id = t1.pedido_id", "left")
|
||||
->join("presupuestos t3", "t3.id = t1.presupuesto_id", "left")
|
||||
->join("tipos_presupuestos t4", "t4.id = t3.tipo_impresion_id", "left")
|
||||
->join("($subquery) fpl", "fpl.pedido_linea_id = t1.id", "left")
|
||||
->where("t3.cliente_id", $cliente_id)
|
||||
->where("t2.estado", "finalizado")
|
||||
->where("(t3.tirada > IFNULL(fpl.total_cantidad, 0))");
|
||||
|
||||
// Ejecutar la consulta y devolver resultados
|
||||
$query = $builder->get();
|
||||
$data = $query->getResult();
|
||||
|
||||
foreach($data as $register){
|
||||
|
||||
foreach($data as $register) {
|
||||
$item = (object)[
|
||||
'id' => $register->id,
|
||||
'text' => '['. lang('Pedidos.pedido') . ' ' . $register->pedido_id . '] ' . $register->titulo . ' - ' . lang('Presupuestos.' . $register->tipo_impresion),
|
||||
];
|
||||
array_push($resultaArray, $item);
|
||||
}
|
||||
|
||||
|
||||
return $resultaArray;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user