Skip to content
Snippets Groups Projects
Commit 8984b74c authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Possibilité de rechercher un intervenant dont le nom comporte un apostrophe...

Possibilité de rechercher un intervenant dont le nom comporte un apostrophe (#50815) + nettoyage code
parent dcf53ce3
No related branches found
No related tags found
No related merge requests found
......@@ -41,19 +41,13 @@ class RechercheProcessus
if (strlen($critere) < 2) return [];
$anneeId = (int)$this->getServiceContext()->getAnnee()->getId();
$critere = self::reduce($critere);
$critere = Util::reduce($critere);
$criteres = explode('_', $critere);
$sqlSource = '';
if (!$onlyLocale) {
$sqlSource = ' UNION ALL ' . $this->sqlSource();
}
$sql = '
WITH vrec AS (
' . $this->sqlLocale() . '
' . $sqlSource . '
)
SELECT * FROM vrec WHERE
rownum <= ' . (int)$limit . ' AND annee_id = ' . $anneeId;
......@@ -234,4 +228,23 @@ class RechercheProcessus
return $this->rechercheGenerique($critere, $limit, $key, true);
}
/**
* @param string $str Chaine à nettoyer
* @param string $encoding Encodage en sortie
*
* @return string
*/
private static function reduce (string $str, string $encoding = 'UTF-8'): string
{
$from = 'ÀÁÂÃÄÅÇÐÈÉÊËÌÍÎÏÒÓÔÕÖØÙÚÛÜŸÑàáâãäåçðèéêëìíîïòóôõöøùúûüÿñ€@()…,<> /?€%!":';
$to = 'aaaaaacdeeeeiiiioooooouuuuynaaaaaacdeeeeiiiioooooouuuuynea________________';
$str = strtolower(Util::strtr($str, $from, $to, false, $encoding));
//On escape les quotes simples pour la requête sql
return str_replace("'", "''", $str);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment