From d4373a401f13e4e3412aa284fd3a2085bd76e4d7 Mon Sep 17 00:00:00 2001 From: imnavajas Date: Mon, 5 Aug 2024 13:36:26 +0200 Subject: [PATCH] Arreglando filtrado --- ci4/app/Controllers/Pedidos/Pedido.php | 6 ++++-- ci4/app/Controllers/Presupuestos/Buscador.php | 2 +- .../themes/vuexy/form/pedidos/viewPedidosList.php | 15 +++++++++------ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/ci4/app/Controllers/Pedidos/Pedido.php b/ci4/app/Controllers/Pedidos/Pedido.php index bc8254dd..66849729 100755 --- a/ci4/app/Controllers/Pedidos/Pedido.php +++ b/ci4/app/Controllers/Pedidos/Pedido.php @@ -245,13 +245,15 @@ class Pedido extends \App\Controllers\BaseResourceController $estado = $reqData['estado'] ?? 'todos'; if($estado == 'todos') $estado = ''; + $searchValues = get_filter_datatables_columns($reqData); + $model_linea = model('\App\Models\Pedidos\PedidoLineaModel'); - $resourceData = $model_linea->getResource($search, $estado)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); + $resourceData = $model_linea->getResource($searchValues, $estado)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); return $this->respond(Collection::datatable( $resourceData, $model_linea->getResource("", $estado)->countAllResults(), - $model_linea->getResource($search, $estado)->countAllResults() + $model_linea->getResource($searchValues, $estado)->countAllResults() )); } else { return $this->failUnauthorized('Invalid request', 403); diff --git a/ci4/app/Controllers/Presupuestos/Buscador.php b/ci4/app/Controllers/Presupuestos/Buscador.php index 30b7b53e..edfe067d 100644 --- a/ci4/app/Controllers/Presupuestos/Buscador.php +++ b/ci4/app/Controllers/Presupuestos/Buscador.php @@ -111,7 +111,7 @@ class Buscador extends \App\Controllers\BaseResourceController return $this->respond(Collection::datatable( $resourceData, $this->model->getResource("")->countAllResults(), - $this->model->getResource($search)->countAllResults() + $this->model->getResource($searchValues)->countAllResults() )); } else { return $this->failUnauthorized('Invalid request', 403); diff --git a/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidosList.php b/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidosList.php index 351031c4..c172c254 100644 --- a/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidosList.php +++ b/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidosList.php @@ -17,7 +17,7 @@ - + @@ -125,10 +125,13 @@ $('#tableOfPedidos thead tr:eq(1) th').each(function (i) { }); theTable = $('#tableOfPedidos').DataTable({ + orderCellsTop: true, + fixedHeader: true, processing: true, serverSide: true, autoWidth: true, responsive: true, + searching: true, scrollX: true, lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ], pageLength: 50, @@ -141,7 +144,7 @@ $('#tableOfPedidos thead tr:eq(1) th').each(function (i) { pageSize: 'A4' } ], - stateSave: true, + stateSave: false, order: [[0, 'asc']], language: { url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" @@ -158,7 +161,7 @@ $('#tableOfPedidos thead tr:eq(1) th').each(function (i) { columnDefs: [ { orderable: false, - searchable: false, + searchable: true, targets: [lastColNr] } ], @@ -209,14 +212,14 @@ $('#tableOfPedidos thead tr:eq(1) th').each(function (i) { }); theTable.on( 'draw.dt', function () { - const boolCols = []; + //const boolCols = []; const dateCols = [1]; const priceCols = [10]; - for (let coln of boolCols) { + /*for (let coln of boolCols) { theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) { cell.innerHTML = cell.innerHTML == '1' ? '' : ''; }); - } + }*/ for (let coln of dateCols) { theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) {