mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando
This commit is contained in:
@ -120,6 +120,7 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
*
|
||||
@ -572,4 +573,109 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
$query = $this->db->getLastQuery();
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getPapelGenericoCliente($data)
|
||||
{
|
||||
/*
|
||||
1.-> Tipo impresion
|
||||
2.-> Maquina
|
||||
3.-> Papeles impresion asociados a esa maquina
|
||||
4.-> papeles genericos que aparecen en esos papeles impresion
|
||||
*/
|
||||
|
||||
if ($data->POD == true && ($data->tipo == 'color')) {
|
||||
if ($data->tipo == 'color')
|
||||
$data->tipo = 'colorhq';
|
||||
else if ($data->tipo == 'negro')
|
||||
$data->tipo = 'negrohq';
|
||||
}
|
||||
|
||||
|
||||
$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")
|
||||
|
||||
->where("t1.is_deleted", 0)
|
||||
->where("t1.show_in_client", 1)
|
||||
->where("t1.tipo_papel_generico_id", $data->tipo_papel_generico_id)
|
||||
->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.min <= ", $data->tirada)
|
||||
->where("t4.max >= ", $data->tirada)
|
||||
->where("t4.tipo", "impresion")
|
||||
->where("t5.is_deleted", 0)
|
||||
->where("t5.tipo", $data->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) {
|
||||
$subQuery->select("t1_inner.id")
|
||||
->from("lg_papel_generico t1_inner")
|
||||
->join("lg_papel_impresion t2_inner", "t2_inner.papel_generico_id = t1_inner.id", "inner")
|
||||
->join("lg_maquina_papel_impresion t3_inner", "t3_inner.papel_impresion_id = t2_inner.id", "inner")
|
||||
->where("t3_inner.active", 1);
|
||||
});
|
||||
|
||||
$builder->groupStart()
|
||||
->groupStart()
|
||||
->where("t4.ancho_impresion >", $data->ancho)
|
||||
->where("t4.alto_impresion >", $data->alto)
|
||||
->groupEnd()
|
||||
->orGroupStart()
|
||||
->where("t4.ancho_impresion >", $data->alto)
|
||||
->where("t4.alto_impresion >", $data->ancho)
|
||||
->groupEnd()
|
||||
->orGroupStart()
|
||||
->where("t4.ancho_impresion >", $data->alto)
|
||||
->where("t4.is_rotativa", 1)
|
||||
->groupEnd()
|
||||
->groupEnd();
|
||||
|
||||
if ($data->cubierta == true) {
|
||||
$builder->where("t2.cubierta", 1);
|
||||
$builder->where("t5.uso", 'cubierta');
|
||||
if ($data->tapa_dura == true) {
|
||||
$builder->where("t2.use_for_tapa_dura", 1);
|
||||
}
|
||||
} else if ($data->sobrecubierta == true) {
|
||||
$builder->where("t2.sobrecubierta", 1);
|
||||
$builder->where("t5.uso", 'sobrecubierta');
|
||||
} else if ($data->guardas == true) {
|
||||
$builder->where("t2.guardas", 1);
|
||||
$builder->where("t5.uso", 'interior');
|
||||
} else {
|
||||
$builder->where("t2.interior", 1);
|
||||
$builder->where("t5.uso", 'interior');
|
||||
if ($data->tipo == 'negro' || $data->tipo == 'negrohq')
|
||||
$builder->where("t2.bn", 1);
|
||||
else if ($data->tipo == 'color' || $data->tipo == 'colorhq')
|
||||
$builder->where("t2.color", 1);
|
||||
}
|
||||
|
||||
if ($data->tipo == 'colorhq' || $data->tipo == 'negrohq') {
|
||||
$builder->where("t2.rotativa", 0);
|
||||
} else {
|
||||
if ($data->POD == false) {
|
||||
$builder->where("t2.rotativa", 1);
|
||||
} else if ($data->POD == true) {
|
||||
$builder->where("t2.rotativa", 0);
|
||||
}
|
||||
}
|
||||
|
||||
$data = $builder->orderBy("t1.nombre", "asc")->get()->getResultObject();
|
||||
//$query = $this->db->getLastQuery(); // DEBUG
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user