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

@ -8,6 +8,7 @@ use App\Models\Tarifas\Acabados\TarifaAcabadoModel;
use App\Models\Compras\ProveedorModel; use App\Models\Compras\ProveedorModel;
use App\Models\Compras\ProveedorTipoModel; use App\Models\Compras\ProveedorTipoModel;
class TarifaAcabados extends BaseResourceController class TarifaAcabados extends BaseResourceController
{ {
@ -220,9 +221,9 @@ class TarifaAcabados extends BaseResourceController
endif; // ($requestMethod === 'post') endif; // ($requestMethod === 'post')
$this->viewData['tarifaacabadoEntity'] = $tarifaacabadoEntity; $this->viewData['tarifaacabadoEntity'] = $tarifaacabadoEntity;
$this->viewData['proveedores'] = $this->getProveedores();
$this->viewData['formAction'] = route_to('updateTarifaAcabado', $id); $this->viewData['formAction'] = route_to('updateTarifaAcabado', $id);
$this->viewData['proveedores'] = $this->getProveedores();
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Tarifaacabado.moduleTitle') . ' ' . lang('Basic.global.edit3'); $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Tarifaacabado.moduleTitle') . ' ' . lang('Basic.global.edit3');

View File

@ -216,7 +216,7 @@ class TarifaAcabadosLineas extends \App\Controllers\BaseResourceController
$searchValues = get_filter_datatables_columns($reqData); $searchValues = get_filter_datatables_columns($reqData);
$resourceData = $this->model->getResource($searchValues, $id_TA)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); $resourceData = $this->model->getResource($searchValues, $id_TA)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
$query = $this->model->db->getLastQuery();
return $this->respond(Collection::datatable( return $this->respond(Collection::datatable(
$resourceData, $resourceData,
$this->model->getResource()->countAllResults(), $this->model->getResource()->countAllResults(),

View File

@ -6,7 +6,7 @@ return [
'id' => 'ID', 'id' => 'ID',
'moduleTitle' => 'Tarifa Acabado Líneas', 'moduleTitle' => 'Tarifa Acabado Líneas',
'deleteLine' => 'el registro seleccionado', 'deleteLine' => 'el registro seleccionado',
'proveedor' => 'Proveedor', 'proveedor' => 'Proveedor',
'precioMax' => 'Precio T. Mín', 'precioMax' => 'Precio T. Mín',
'precioMin' => 'Precio T. Máx', 'precioMin' => 'Precio T. Máx',
'precioUnidad' => 'Precio Unidad', 'precioUnidad' => 'Precio Unidad',

View File

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

View File

@ -208,8 +208,8 @@
$('input', this).on('change clear', function () { $('input', this).on('change clear', function () {
var minInputValue = parseFloat($(`#min_${title}`).val()) || ""; var minInputValue = parseFloat($(`#min_${title}`).val().replace(',','.')) || "";
var maxInputValue = parseFloat($(`#max_${title}`).val()) || ""; var maxInputValue = parseFloat($(`#max_${title}`).val().replace(',','.')) || "";
if (theTable.column(i).search() !== [minInputValue,maxInputValue]) { if (theTable.column(i).search() !== [minInputValue,maxInputValue]) {