arraglado fallo en buscador cuando se limpia, orden precios y replace de , a .

This commit is contained in:
2024-08-27 19:04:18 +02:00
parent 49314e166d
commit e2289030db
5 changed files with 49 additions and 24 deletions

View File

@ -18,9 +18,9 @@ class TarifaAcabadoLineaModel extends \App\Models\BaseModel
const SORTABLE = [
0 => "t3.nombre",
1 => "t1.tirada_min",
2 => "t1.precio_min",
2 => "t1.precio_max",
3 => "t1.tirada_max",
4 => "t1.precio_max",
4 => "t1.precio_min",
5 => "t1.margen",
];
@ -150,33 +150,57 @@ class TarifaAcabadoLineaModel extends \App\Models\BaseModel
if (empty($search))
return $builder;
else {
$builder->groupStart();
$filterEnabled = 0;
foreach ($search as $col_search) {
if($col_search[0] != 0){
$values = explode(",",$col_search[2]);
$min_val = floatval($values[0]);
$max_val = floatval($values[1]);
if(!is_nan($min_val) && !is_null($min_val) && strlen($values[0]) > 0){
$builder->where(self::SORTABLE[$col_search[0]] . " >=", $min_val);
}
if(!is_nan($max_val) && !is_null($max_val) && strlen($values[1]) > 0){
$builder->where(self::SORTABLE[$col_search[0]] . " <", $max_val);
if(strlen($col_search[2]) > 1){
$values = explode(",",$col_search[2]);
$min_val = floatval($values[0]);
$max_val = floatval($values[1]);
if(!is_nan($min_val) && !is_null($min_val) && strlen($values[0]) > 0){
if($filterEnabled == 0){
$builder->groupStart();
$filterEnabled = 1;
}
$builder->where(self::SORTABLE[$col_search[0]] . " >=", $min_val);
}
if(!is_nan($max_val) && !is_null($max_val) && strlen($values[1]) > 0){
if($filterEnabled == 0){
$builder->groupStart();
$filterEnabled = 1;
}
$builder->where(self::SORTABLE[$col_search[0]] . " <", $max_val);
}
}
}
else{
$values = explode(",",$col_search[2]);
if(count($values) > 1){
foreach ($values as $value) {
$builder->orWhere("t1.proveedor_id", $value);
if(strlen($col_search[2]) > 1){
$values = explode(",",$col_search[2]);
if(count($values) > 1){
foreach ($values as $value) {
if($filterEnabled == 0){
$builder->groupStart();
$filterEnabled = 1;
}
$builder->orWhere("t1.proveedor_id", $value);
}
}
else{
if($filterEnabled == 0){
$builder->groupStart();
$filterEnabled = 1;
}
$builder->where("t1.proveedor_id", $col_search[2]);
}
}
else{
$builder->where("t1.proveedor_id", $col_search[2]);
}
}
}
$builder->groupEnd();
if($filterEnabled == 1){
$builder->groupEnd();
}
return $builder;
}