viewData['usingSweetAlert'] = true; $this->viewData = ['usingServerSideDataTable' => true]; // JJO // Breadcrumbs $this->viewData['breadcrumb'] = [ ['title' => lang("App.menu_presupuestos"), 'route' => "javascript:void(0);", 'active' => false], ['title' => "Listado", 'route' => site_url('presupuestocliente/list'), 'active' => true] ]; $this->messageService = service('messages'); parent::initController($request, $response, $logger); $this->model = new ImportadorModel(); } public function index() { $viewData = [ 'currentModule' => static::$controllerSlug, 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Presupuestos.moduleName')]), ]; $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class return view(static::$viewPath . 'viewImportadorPresupuestos', $viewData); } public function getClientList() { $search = ""; if ($this->request->getGet("q")) { $search = $this->request->getGet("q"); } $dataOld = (new ImportadorModel())->getClientList(); $dataNew = (new ClienteModel())->getIdName($search); $newKeys = array_map(fn($item) => $item->id . '_' . $item->name, $dataNew); // Filtrar $dataOld para obtener solo los elementos comunes $commonData = array_filter($dataOld, fn($item) => in_array($item->id . '_' . $item->name, $newKeys)); return $this->response->setJSON(array_values($commonData)); } public function getPresupuestosList(){ $search = ""; if ($this->request->getGet("q")) { $search = $this->request->getGet("q"); } $clienteId = $this->request->getGet("clienteId"); $data = (new ImportadorModel())->getPresupuestosList($clienteId, $search); return $this->response->setJSON($data); } }