mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
diseño interior con selector de papeles
This commit is contained in:
@ -324,52 +324,51 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
|
||||
if ($selected_papel_id != null) {
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t2.gramaje as gramaje",
|
||||
// for debug, t2.nombre AS nombre_papel_impresion, t4.nombre AS maquina_nombre, t5.uso AS tarifa_uso, t5.tipo AS tarifa_tipo"
|
||||
)
|
||||
->join("lg_papel_impresion t2", "t2.papel_generico_id = t1.id", "inner")
|
||||
->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "inner")
|
||||
->join("lg_maquinas t4", "t3.maquina_id = t4.id", "inner")
|
||||
->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "inner")
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t2.gramaje as gramaje",
|
||||
// for debug, t2.nombre AS nombre_papel_impresion, t4.nombre AS maquina_nombre, t5.uso AS tarifa_uso, t5.tipo AS tarifa_tipo"
|
||||
)
|
||||
->join("lg_papel_impresion t2", "t2.papel_generico_id = t1.id", "inner")
|
||||
->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "inner")
|
||||
->join("lg_maquinas t4", "t3.maquina_id = t4.id", "inner")
|
||||
->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "inner")
|
||||
|
||||
->where("t1.id", $selected_papel_id)
|
||||
->where("t1.is_deleted", 0)
|
||||
->where("t1.show_in_client", 1)
|
||||
->where("t2.is_deleted", 0)
|
||||
->where("t2.isActivo", 1)
|
||||
->where("t2.use_in_client", 1)
|
||||
->where("t3.active", 1)
|
||||
->where("t4.is_deleted", 0)
|
||||
->where("t4.tipo", "impresion")
|
||||
->where("t5.is_deleted", 0)
|
||||
->where("t5.tipo", $tipo)
|
||||
->distinct('t2.gramaje');
|
||||
}
|
||||
else{
|
||||
->where("t1.id", $selected_papel_id)
|
||||
->where("t1.is_deleted", 0)
|
||||
->where("t1.show_in_client", 1)
|
||||
->where("t2.is_deleted", 0)
|
||||
->where("t2.isActivo", 1)
|
||||
->where("t2.use_in_client", 1)
|
||||
->where("t3.active", 1)
|
||||
->where("t4.is_deleted", 0)
|
||||
->where("t4.tipo", "impresion")
|
||||
->where("t5.is_deleted", 0)
|
||||
->where("t5.tipo", $tipo)
|
||||
->distinct('t2.gramaje');
|
||||
} else {
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id as id, t1.nombre AS nombre",
|
||||
// for debug, t2.nombre AS nombre_papel_impresion, t4.nombre AS maquina_nombre, t5.uso AS tarifa_uso, t5.tipo AS tarifa_tipo"
|
||||
)
|
||||
->join("lg_papel_impresion t2", "t2.papel_generico_id = t1.id", "inner")
|
||||
->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "inner")
|
||||
->join("lg_maquinas t4", "t3.maquina_id = t4.id", "inner")
|
||||
->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "inner")
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id as id, t1.nombre AS nombre",
|
||||
// for debug, t2.nombre AS nombre_papel_impresion, t4.nombre AS maquina_nombre, t5.uso AS tarifa_uso, t5.tipo AS tarifa_tipo"
|
||||
)
|
||||
->join("lg_papel_impresion t2", "t2.papel_generico_id = t1.id", "inner")
|
||||
->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "inner")
|
||||
->join("lg_maquinas t4", "t3.maquina_id = t4.id", "inner")
|
||||
->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "inner")
|
||||
|
||||
->where("t1.is_deleted", 0)
|
||||
->where("t1.show_in_client", 1)
|
||||
->where("t2.is_deleted", 0)
|
||||
->where("t2.isActivo", 1)
|
||||
->where("t2.use_in_client", 1)
|
||||
->where("t3.active", 1)
|
||||
->where("t4.is_deleted", 0)
|
||||
->where("t4.tipo", "impresion")
|
||||
->where("t5.is_deleted", 0)
|
||||
->where("t5.tipo", $tipo)
|
||||
->distinct('t1.id');
|
||||
->where("t1.is_deleted", 0)
|
||||
->where("t1.show_in_client", 1)
|
||||
->where("t2.is_deleted", 0)
|
||||
->where("t2.isActivo", 1)
|
||||
->where("t2.use_in_client", 1)
|
||||
->where("t3.active", 1)
|
||||
->where("t4.is_deleted", 0)
|
||||
->where("t4.tipo", "impresion")
|
||||
->where("t5.is_deleted", 0)
|
||||
->where("t5.tipo", $tipo)
|
||||
->distinct('t1.id');
|
||||
}
|
||||
// Validación adicional para asegurar que t1.id esté presente en las combinaciones con t3.active = 1
|
||||
$builder->whereIn("t1.id", function ($subQuery) {
|
||||
@ -400,7 +399,10 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
}
|
||||
|
||||
|
||||
$data = $builder->orderBy("t1.nombre", "asc")->get()->getResultObject();
|
||||
if ($selected_papel_id != null)
|
||||
$data = $builder->orderBy("t2.gramaje", "asc")->get()->getResultObject();
|
||||
else
|
||||
$data = $builder->orderBy("t1.nombre", "asc")->get()->getResultObject();
|
||||
//$query = $this->db->getLastQuery();
|
||||
return $data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user