mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
problema muestra genericos que no
This commit is contained in:
@ -63,7 +63,8 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
];
|
||||
|
||||
|
||||
public function getIdFromCode(string $code=""){
|
||||
public function getIdFromCode(string $code = "")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
@ -78,7 +79,8 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
}
|
||||
|
||||
|
||||
public function getCodeFromId($id=0){
|
||||
public function getCodeFromId($id = 0)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
@ -113,16 +115,16 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.code", $search)
|
||||
->orLike("t1.code_ot", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.code", $search)
|
||||
->orLike("t1.code_ot", $search)
|
||||
->groupEnd();
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.code", $search)
|
||||
->orLike("t1.code_ot", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.code", $search)
|
||||
->orLike("t1.code_ot", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
|
||||
@ -130,9 +132,9 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
{
|
||||
/*
|
||||
1.-> Tipo impresion
|
||||
2.-> Maquina
|
||||
3.-> Papeles impresion asociados a esa maquina
|
||||
4.-> papeles genericos que aparecen en esos papeles impresion
|
||||
2.-> Maquina
|
||||
3.-> Papeles impresion asociados a esa maquina
|
||||
4.-> papeles genericos que aparecen en esos papeles impresion
|
||||
*/
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
@ -155,48 +157,48 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
->where("t5.is_deleted", 0)
|
||||
->where("t5.tipo", $tipo);
|
||||
|
||||
if($is_cubierta==true){
|
||||
|
||||
$builder->where("t2.cubierta", 1);
|
||||
$builder->where("t5.uso", 'cubierta');
|
||||
}
|
||||
|
||||
if($is_sobrecubierta==true){
|
||||
$builder->where("t2.sobrecubierta", 1);
|
||||
$builder->where("t5.uso", 'sobrecubierta');
|
||||
}
|
||||
if ($is_cubierta == true) {
|
||||
|
||||
if($is_cubierta==false && $is_sobrecubierta==false){
|
||||
$builder->where("t5.uso", 'interior');
|
||||
}
|
||||
$builder->where("t2.cubierta", 1);
|
||||
$builder->where("t5.uso", 'cubierta');
|
||||
}
|
||||
|
||||
if($is_guardas==true){
|
||||
$builder->where("t2.guardas", 1);
|
||||
}
|
||||
if ($is_sobrecubierta == true) {
|
||||
$builder->where("t2.sobrecubierta", 1);
|
||||
$builder->where("t5.uso", 'sobrecubierta');
|
||||
}
|
||||
|
||||
if($rotativa==true){
|
||||
$builder->where("t2.rotativa", 1);
|
||||
}
|
||||
if ($is_cubierta == false && $is_sobrecubierta == false) {
|
||||
$builder->where("t5.uso", 'interior');
|
||||
}
|
||||
|
||||
if($mostrar_cliente!=null){
|
||||
$builder->where("t1.show_in_client", $mostrar_cliente);
|
||||
}
|
||||
if ($is_guardas == true) {
|
||||
$builder->where("t2.guardas", 1);
|
||||
}
|
||||
|
||||
if ($rotativa == true) {
|
||||
$builder->where("t2.rotativa", 1);
|
||||
}
|
||||
|
||||
if ($mostrar_cliente != null) {
|
||||
$builder->where("t1.show_in_client", $mostrar_cliente);
|
||||
}
|
||||
|
||||
$data = $builder->orderBy("t1.nombre", "asc")->get()->getResultObject();
|
||||
//var_dump($this->db->getLastQuery());
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getGramajeComparador(string $papel_generico_nombre="", $uso="", $ejemplares=0)
|
||||
public function getGramajeComparador(string $papel_generico_nombre = "", $uso = "", $ejemplares = 0)
|
||||
{
|
||||
if($uso == 'cubierta' || $uso == 'sobrecubierta')
|
||||
if ($uso == 'cubierta' || $uso == 'sobrecubierta')
|
||||
$tipo = 'colorhq';
|
||||
else
|
||||
$tipo=$uso; // color y colorhq valen para los dos
|
||||
if($uso == 'bn')
|
||||
$tipo="negro";
|
||||
if($uso == 'bnhq')
|
||||
$tipo="negrohq";
|
||||
$tipo = $uso; // color y colorhq valen para los dos
|
||||
if ($uso == 'bn')
|
||||
$tipo = "negro";
|
||||
if ($uso == 'bnhq')
|
||||
$tipo = "negrohq";
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
@ -207,7 +209,7 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "left")
|
||||
->join("lg_maquinas t4", "t3.maquina_id = t4.id", "left")
|
||||
->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "left")
|
||||
|
||||
|
||||
->where("t1.is_deleted", 0)
|
||||
->where("t2.is_deleted", 0)
|
||||
->where("t2.isActivo", 1)
|
||||
@ -216,44 +218,43 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
->where("t4.tipo", "impresion")
|
||||
->where("t5.tipo", $tipo)
|
||||
->where("t1.nombre", $papel_generico_nombre);
|
||||
|
||||
$uso_tarifa = 'interior';
|
||||
|
||||
if($uso == 'bn' || $uso == 'bnhq')
|
||||
$builder->where("t2.bn", 1);
|
||||
else if ($uso == 'color' || $uso == 'colorhq')
|
||||
$builder->where("t2.color", 1);
|
||||
else if ($uso == 'cubierta'){
|
||||
$uso_tarifa = 'cubierta';
|
||||
$builder->where("t2.cubierta", 1);
|
||||
}
|
||||
else if ($uso == 'sobrecubierta'){
|
||||
$uso_tarifa = 'sobrecubierta';
|
||||
$builder->where("t2.sobrecubierta", 1);
|
||||
}
|
||||
$uso_tarifa = 'interior';
|
||||
|
||||
$builder->where("t5.uso", $uso_tarifa);
|
||||
if ($uso == 'bn' || $uso == 'bnhq')
|
||||
$builder->where("t2.bn", 1);
|
||||
else if ($uso == 'color' || $uso == 'colorhq')
|
||||
$builder->where("t2.color", 1);
|
||||
else if ($uso == 'cubierta') {
|
||||
$uso_tarifa = 'cubierta';
|
||||
$builder->where("t2.cubierta", 1);
|
||||
} else if ($uso == 'sobrecubierta') {
|
||||
$uso_tarifa = 'sobrecubierta';
|
||||
$builder->where("t2.sobrecubierta", 1);
|
||||
}
|
||||
|
||||
$builder->where("t4.min <=", $ejemplares);
|
||||
$builder->where("t4.max >=", $ejemplares);
|
||||
|
||||
$values = $builder->orderBy("t2.gramaje", "asc")->get()->getResultObject();
|
||||
$id = 1;
|
||||
foreach ($values as $value){
|
||||
$value->id = $id;
|
||||
$id++;
|
||||
}
|
||||
$values_array = array_map( function( $value ) {
|
||||
return $value->text;
|
||||
}, $values );
|
||||
$unique_values = array_unique($values_array);
|
||||
return array_values(array_intersect_key($values, $unique_values));
|
||||
$builder->where("t5.uso", $uso_tarifa);
|
||||
|
||||
$builder->where("t4.min <=", $ejemplares);
|
||||
$builder->where("t4.max >=", $ejemplares);
|
||||
|
||||
$values = $builder->orderBy("t2.gramaje", "asc")->get()->getResultObject();
|
||||
$id = 1;
|
||||
foreach ($values as $value) {
|
||||
$value->id = $id;
|
||||
$id++;
|
||||
}
|
||||
$values_array = array_map(function ($value) {
|
||||
return $value->text;
|
||||
}, $values);
|
||||
$unique_values = array_unique($values_array);
|
||||
return array_values(array_intersect_key($values, $unique_values));
|
||||
|
||||
}
|
||||
|
||||
//tipo: negro, negrohq, color, colorhq
|
||||
//uso: interior, rotativa, cubierta, sobrecubierta
|
||||
public function getGramajeLineasPresupuesto($papel_generico_id=0, $tipo="", $uso="")
|
||||
public function getGramajeLineasPresupuesto($papel_generico_id = 0, $tipo = "", $uso = "")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
@ -264,7 +265,7 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "left")
|
||||
->join("lg_maquinas t4", "t3.maquina_id = t4.id", "left")
|
||||
->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "left")
|
||||
|
||||
|
||||
->where("t1.is_deleted", 0)
|
||||
->where("t2.is_deleted", 0)
|
||||
->where("t2.isActivo", 1)
|
||||
@ -274,42 +275,94 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
->where("t5.tipo", $tipo)
|
||||
->where("t1.id", $papel_generico_id);
|
||||
|
||||
$uso_tarifa = 'interior';
|
||||
$uso_tarifa = 'interior';
|
||||
|
||||
if ($uso == 'cubierta'){
|
||||
$uso_tarifa = 'cubierta';
|
||||
$builder->where("t2.cubierta", 1);
|
||||
}
|
||||
else if ($uso == 'sobrecubierta'){
|
||||
$uso_tarifa = 'sobrecubierta';
|
||||
$builder->where("t2.sobrecubierta", 1);
|
||||
}
|
||||
else{
|
||||
if($tipo == 'negro' || $tipo == 'negrohq')
|
||||
$builder->where("t2.bn", 1);
|
||||
else if ($tipo == 'color' || $tipo == 'colorhq')
|
||||
$builder->where("t2.color", 1);
|
||||
}
|
||||
|
||||
if($uso=='rotativa')
|
||||
$builder->where("t2.rotativa", 1);
|
||||
else
|
||||
$builder->where("t2.rotativa", 0);
|
||||
if ($uso == 'cubierta') {
|
||||
$uso_tarifa = 'cubierta';
|
||||
$builder->where("t2.cubierta", 1);
|
||||
} else if ($uso == 'sobrecubierta') {
|
||||
$uso_tarifa = 'sobrecubierta';
|
||||
$builder->where("t2.sobrecubierta", 1);
|
||||
} else {
|
||||
if ($tipo == 'negro' || $tipo == 'negrohq')
|
||||
$builder->where("t2.bn", 1);
|
||||
else if ($tipo == 'color' || $tipo == 'colorhq')
|
||||
$builder->where("t2.color", 1);
|
||||
}
|
||||
|
||||
$builder->where("t5.uso", $uso_tarifa);
|
||||
|
||||
|
||||
$values = $builder->orderBy("t2.gramaje", "asc")->get()->getResultObject();
|
||||
$id = 1;
|
||||
foreach ($values as $value){
|
||||
$value->id = $id;
|
||||
$id++;
|
||||
}
|
||||
$values_array = array_map( function( $value ) {
|
||||
return $value->text;
|
||||
}, $values );
|
||||
$unique_values = array_unique($values_array);
|
||||
return array_values(array_intersect_key($values, $unique_values));
|
||||
if ($uso == 'rotativa')
|
||||
$builder->where("t2.rotativa", 1);
|
||||
else
|
||||
$builder->where("t2.rotativa", 0);
|
||||
|
||||
$builder->where("t5.uso", $uso_tarifa);
|
||||
|
||||
|
||||
$values = $builder->orderBy("t2.gramaje", "asc")->get()->getResultObject();
|
||||
$id = 1;
|
||||
foreach ($values as $value) {
|
||||
$value->id = $id;
|
||||
$id++;
|
||||
}
|
||||
$values_array = array_map(function ($value) {
|
||||
return $value->text;
|
||||
}, $values);
|
||||
$unique_values = array_unique($values_array);
|
||||
return array_values(array_intersect_key($values, $unique_values));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getPapelGenericoCliente($tipo, $is_cubierta = false, $papel_especial = false)
|
||||
{
|
||||
/*
|
||||
1.-> Tipo impresion
|
||||
2.-> Maquina
|
||||
3.-> Papeles impresion asociados a esa maquina
|
||||
4.-> papeles genericos que aparecen en esos papeles impresion
|
||||
*/
|
||||
$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("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');
|
||||
|
||||
$builder->groupStart()
|
||||
->where("t2.id IS NOT NULL") // Validar relación con `t2`
|
||||
->orWhere("t4.id IS NOT NULL") // Validar relación con `t4`
|
||||
->groupEnd();
|
||||
|
||||
if ($is_cubierta == true) {
|
||||
|
||||
$builder->where("t2.cubierta", 1);
|
||||
$builder->where("t5.uso", 'cubierta');
|
||||
} else {
|
||||
$builder->where("t5.uso", 'interior');
|
||||
}
|
||||
|
||||
if ($papel_especial == true) {
|
||||
$builder->where("t1.show_in_client_special", 1);
|
||||
}
|
||||
|
||||
$data = $builder->orderBy("t1.nombre", "asc")->get()->getResultObject();
|
||||
//var_dump($this->db->getLastQuery());
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user