Fix: add similitude test
This commit is contained in:
parent
925af263fc
commit
edb6195cc2
@ -845,7 +845,7 @@ class Societe extends CommonObject
|
|||||||
* @param string $clause Clause for filters
|
* @param string $clause Clause for filters
|
||||||
* @return array Array of thirdparties object
|
* @return array Array of thirdparties object
|
||||||
*/
|
*/
|
||||||
function searchByName($name, $type='0', $filters = array(), $exact = false, $case = false, $clause = 'AND')
|
function searchByName($name, $type='0', $filters = array(), $exact = false, $case = false, $similar = false, $clause = 'AND')
|
||||||
{
|
{
|
||||||
$thirdparties = array();
|
$thirdparties = array();
|
||||||
|
|
||||||
@ -875,10 +875,18 @@ class Societe extends CommonObject
|
|||||||
$sql.= " AND ";
|
$sql.= " AND ";
|
||||||
if (is_array($filters) && ! empty($filters))
|
if (is_array($filters) && ! empty($filters))
|
||||||
$sql.= "(";
|
$sql.= "(";
|
||||||
if (! $case)
|
if ($similar)
|
||||||
$sql.= "nom LIKE '".$this->db->escape($name)."'";
|
{
|
||||||
|
// For test similitude
|
||||||
|
$sql.= "(LOCATE('".$name."', nom) > 0 OR LOCATE(nom, '".$name."') > 0)";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
$sql.= "nom LIKE BINARY '".$this->db->escape($name)."'";
|
{
|
||||||
|
if (! $case)
|
||||||
|
$sql.= "nom LIKE '".$this->db->escape($name)."'";
|
||||||
|
else
|
||||||
|
$sql.= "nom LIKE BINARY '".$this->db->escape($name)."'";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (is_array($filters) && ! empty($filters))
|
if (is_array($filters) && ! empty($filters))
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user