From 52303e918567d1d3507851c9b33f3169fd240398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Mon, 14 Oct 2024 14:45:40 +0200 Subject: [PATCH] trabajando en el selector de cliente --- ci4/app/Controllers/Clientes/Cliente.php | 28 ++++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/ci4/app/Controllers/Clientes/Cliente.php b/ci4/app/Controllers/Clientes/Cliente.php index 44c7e8f4..ec271292 100755 --- a/ci4/app/Controllers/Clientes/Cliente.php +++ b/ci4/app/Controllers/Clientes/Cliente.php @@ -333,21 +333,21 @@ class Cliente extends \App\Controllers\BaseResourceController public function getSelect2() { if ($this->request->isAJAX()) { - $searchStr = goSanitize($this->request->getGet('searchTerm'))[0]; - $reqId = goSanitize($this->request->getGet('id'))[0]; - $reqText = goSanitize($this->request->getGet('text'))[0]; - $onlyActiveOnes = false; - $columns2select = [$reqId ?? 'id', $reqText ?? 'nombre']; - $onlyActiveOnes = false; - try{ - $menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr); + $query = $this->model->builder()->select( + [ + "id", + "nombre as name" + ] + )->where("deleted_at", null); + + if ($this->request->getGet("q")) { + $query->groupStart() + ->orLike("clientes.nombre", $this->request->getGet("q")) + ->groupEnd(); } - catch(Exception $e){ - $menu = []; - } - - $menu, - return $this->respond($menu); + + return $this->response->setJSON($query->get()->getResultObject()); + // return $this->respond($menu); } else { return $this->failUnauthorized('Invalid request', 403); }