From e4dce6485810fbc972db49922b5ab337fffa7962 Mon Sep 17 00:00:00 2001 From: Ezequiel Lafuente Date: Wed, 4 Apr 2018 16:11:16 -0300 Subject: [PATCH] Ajustes na pesquisa de processos, agora ela pesquisa sem restrições a acentos e caracteres especiais --- controlador_ws.php | 4 ++-- rn/MdWsSeiProcedimentoRN.php | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/controlador_ws.php b/controlador_ws.php index 169caf7..f00f9ce 100644 --- a/controlador_ws.php +++ b/controlador_ws.php @@ -578,14 +578,14 @@ $app->group('/api/v1',function(){ $this->get('/tipo/listar', function($request, $response, $args){ /** @var $request Slim\Http\Request */ $rn = new MdWsSeiProcedimentoRN(); - $objGetMdWsSeiTipoProcedimentoDTO = new MdWsSeiTipoProcedimentoDTO(); + $objGetMdWsSeiTipoProcedimentoDTO = new MdWsSeiTipoProcedimentoDTO(); $objGetMdWsSeiTipoProcedimentoDTO->setNumIdTipoProcedimento($request->getParam('id')); $objGetMdWsSeiTipoProcedimentoDTO->setStrNome($request->getParam('filter')); // $objGetMdWsSeiTipoProcedimentoDTO->setStrSinInterno($request->getParam('internos')); $objGetMdWsSeiTipoProcedimentoDTO->setStrFavoritos($request->getParam('favoritos')); $objGetMdWsSeiTipoProcedimentoDTO->setNumStart($request->getParam('start')); $objGetMdWsSeiTipoProcedimentoDTO->setNumLimit($request->getParam('limit')); - + return $response->withJSON( $rn->listarTipoProcedimento($objGetMdWsSeiTipoProcedimentoDTO) ); diff --git a/rn/MdWsSeiProcedimentoRN.php b/rn/MdWsSeiProcedimentoRN.php index e1491ab..bb704f4 100644 --- a/rn/MdWsSeiProcedimentoRN.php +++ b/rn/MdWsSeiProcedimentoRN.php @@ -90,10 +90,16 @@ class MdWsSeiProcedimentoRN extends InfraRN //FILTRA NOME, ID e INTERNO if($arrObjTipoProcedimentoDTO){ foreach ($arrObjTipoProcedimentoDTO as $aux) { + + setlocale(LC_CTYPE, 'pt_BR'); // Defines para pt-br + + $objDtoFormatado = strtolower(iconv('ISO-8859-1', 'ASCII//TRANSLIT', $aux->getStrNome())); + $nomeFormatado = str_replace('?','',strtolower(iconv('ISO-8859-1', 'ASCII//TRANSLIT', $nome))); + if( ($aux->getNumIdTipoProcedimento() == $id || !$id) && - (($nome && strpos($aux->getStrNome(), $nome) !== false) || !$nome) + (($nome && strpos($objDtoFormatado, $nomeFormatado) !== false) || !$nomeFormatado) // && // ($aux->getStrSinInterno() == $interno || !$interno) ){ @@ -127,12 +133,16 @@ class MdWsSeiProcedimentoRN extends InfraRN } } - if($start) $arrayRetorno = array_slice($arrayRetorno, ($start-1)); - if($limit) $arrayRetorno = array_slice($arrayRetorno, 0,($limit)); - $total = 0; $total = count($arrayRetorno); - + + if($start) $arrayRetorno = array_slice($arrayRetorno, ($start-1)); + if($limit) $arrayRetorno = array_slice($arrayRetorno, 0,($limit)); + + + /*$total = 0; + $total = count($arrayRetorno);*/ + return MdWsSeiRest::formataRetornoSucessoREST(null, $arrayRetorno, $total); } catch (Exception $e) { return MdWsSeiRest::formataRetornoErroREST($e); -- libgit2 0.21.2