terminada revision de pedidos

This commit is contained in:
2025-03-28 00:52:49 +01:00
parent 0e91105f68
commit 33ce64df0f
20 changed files with 960 additions and 806 deletions

View File

@ -61,9 +61,9 @@ class OrdenTrabajoDate extends Model
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = [];
protected $afterInsert = ["updateOrdenTrabajoUser"];
protected $afterInsert = [];
protected $beforeUpdate = [];
protected $afterUpdate = ["updateOrdenTrabajoUser"];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];

View File

@ -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 = [];

View File

@ -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)

View File

@ -9,7 +9,7 @@ use CodeIgniter\Model;
class TarifaExtraMaquinaModel extends Model
{
protected $table = 'tarifa_acabado_maquinas';
protected $table = 'tarifa_extra_maquinas';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = TarifaExtraMaquinaEntity::class;