mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
arraglado fallo en buscador cuando se limpia, orden precios y replace de , a .
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user