mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into feat/sk-7/planning
This commit is contained in:
@ -75,7 +75,7 @@ class PedidoLineaModel extends \App\Models\BaseModel
|
||||
}
|
||||
}
|
||||
|
||||
if($cliente_id != -1) {
|
||||
if($cliente_id != -1 && $cliente_id != "-1") {
|
||||
$builder->where("t3.cliente_id", $cliente_id);
|
||||
}
|
||||
|
||||
@ -106,9 +106,11 @@ class PedidoLineaModel extends \App\Models\BaseModel
|
||||
|
||||
$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($cliente_id != -1) {
|
||||
if($cliente_id != -1 && $cliente_id != "-1") {
|
||||
$builder->where("t3.cliente_id", $cliente_id);
|
||||
}
|
||||
|
||||
@ -128,7 +130,7 @@ class PedidoLineaModel extends \App\Models\BaseModel
|
||||
}
|
||||
|
||||
if ($estado !== '') {
|
||||
$builder->where('estado', $estado);
|
||||
$builder->where('t2.estado', $estado);
|
||||
}
|
||||
|
||||
// Aplicar el orden y el límite
|
||||
@ -146,8 +148,11 @@ class PedidoLineaModel extends \App\Models\BaseModel
|
||||
|
||||
$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($cliente_id != -1) {
|
||||
if($cliente_id != -1 && $cliente_id != "-1") {
|
||||
$builder->where("t3.cliente_id", $cliente_id);
|
||||
}
|
||||
|
||||
@ -167,7 +172,7 @@ class PedidoLineaModel extends \App\Models\BaseModel
|
||||
}
|
||||
|
||||
if ($estado !== '') {
|
||||
$builder->where('estado', $estado);
|
||||
$builder->where('t2.estado', $estado);
|
||||
}
|
||||
|
||||
// Aplicar el orden y el límite
|
||||
@ -177,7 +182,7 @@ class PedidoLineaModel extends \App\Models\BaseModel
|
||||
return $builder->get()->getRow()->total;
|
||||
}
|
||||
|
||||
public function getTotalOfTotalAceptado()
|
||||
public function getTotalOfTotalAceptado($estado = "")
|
||||
{
|
||||
|
||||
$builder = $this->db
|
||||
@ -187,10 +192,30 @@ class PedidoLineaModel extends \App\Models\BaseModel
|
||||
$builder->join("pedidos t2", "t2.id = t1.pedido_id", "left");
|
||||
$builder->join("presupuestos t3", "t1.presupuesto_id = t3.id", "left");
|
||||
|
||||
if ($estado !== '') {
|
||||
$builder->where('t2.estado', $estado);
|
||||
}
|
||||
|
||||
return $builder->get()->getRow()->total;
|
||||
}
|
||||
|
||||
public function getTotalTirada($estado = "")
|
||||
{
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->selectSum('t3.tirada', 'total_tirada');
|
||||
|
||||
$builder->join("pedidos t2", "t2.id = t1.pedido_id", "left");
|
||||
$builder->join("presupuestos t3", "t1.presupuesto_id = t3.id", "left");
|
||||
|
||||
if ($estado !== '') {
|
||||
$builder->where('t2.estado', $estado);
|
||||
}
|
||||
|
||||
return $builder->get()->getRow()->total_tirada;
|
||||
}
|
||||
|
||||
public function obtenerLineasPedidoSinFacturar($cliente_id) {
|
||||
$resultaArray = [];
|
||||
|
||||
@ -208,7 +233,7 @@ class PedidoLineaModel extends \App\Models\BaseModel
|
||||
->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")
|
||||
->whereIn("t2.estado", ["produccion", "enviado","finalizado"])
|
||||
->where("(t3.tirada > IFNULL(fpl.total_cantidad, 0))");
|
||||
|
||||
// Ejecutar la consulta y devolver resultados
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Models\Pedidos;
|
||||
|
||||
use App\Entities\Presupuestos\OrdenTrabajoEntity;
|
||||
use App\Entities\Produccion\OrdenTrabajoEntity;
|
||||
use App\Models\OrdenTrabajo\OrdenTrabajoModel;
|
||||
|
||||
use function PHPSTORM_META\map;
|
||||
|
||||
@ -193,7 +193,7 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel
|
||||
->table($this->table . " t1")
|
||||
->set('presupuesto_id', $presupuesto_id)
|
||||
->set('tarifa_acabado_id', $tarifa->tarifa_id)
|
||||
->set('proveedor_id', $proveedor, false)
|
||||
->set('proveedor_id', $proveedor)
|
||||
->set('precio_unidad', $tarifa->precio_unidad)
|
||||
->set('precio_total', $tarifa->precio_total)
|
||||
->set('margen', $tarifa->margen)
|
||||
|
||||
Reference in New Issue
Block a user