X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvalidations%2Fentreprises.inc.php;h=635173d3e5be603c2ae1ea9f677c9b2fc1cf6854;hb=a0ad593aec01fe6387ee83f3ef487bcdc3c3c5bd;hp=2e1cd9a66e28987f81d256004dc2680eda6ae418;hpb=2504be33ed7e7436c428f188bdafa9e72248131d;p=platal.git diff --git a/include/validations/entreprises.inc.php b/include/validations/entreprises.inc.php index 2e1cd9a..635173d 100644 --- a/include/validations/entreprises.inc.php +++ b/include/validations/entreprises.inc.php @@ -1,6 +1,6 @@ id = $_id; - $this->name = $_name; - $this->acronym = $_acronym; - $this->url = $_url; - $this->email = $_email; - $this->tel = $_tel; - $this->fax = $_fax; + parent::__construct($_user, false, 'entreprise', $_stamp); + $this->id = $_id; + $this->name = $_name; + $this->acronym = $_acronym; + $this->url = $_url; + $this->email = $_email; + $this->tel = $_tel; + $this->fax = $_fax; + + $_name = preg_replace('/[^0-9a-z]/i', ' ', strtolower(replace_accent($_name))); + $name = explode(" ", $_name); + $name_array = array_map("trim", $name); + $length = count($name_array); + $where = ""; + for ($i = 0; $i < $length; $i++) { + if (strlen($name_array[$i]) > 2) { + if ($where !== "") { + $where .= " OR "; + } + $where .= "name LIKE '%" . $name_array[$i] . "%'"; + } + } + $res = XDB::iterator("SELECT name + FROM profile_job_enum + WHERE " + . $where); + $this->suggestions = "| "; + while ($sug = $res->next()) { + $this->suggestions .= $sug['name'] . " | "; + } } // }}}