Recherche par mots sur les NAFs

This commit is contained in:
Michael RICOIS 2012-08-07 08:40:29 +00:00
parent 7c574d164e
commit b53665953f

View File

@ -46,13 +46,29 @@ class FieldsController extends Zend_Controller_Action
switch ($name) {
case 'ape_etab':
case 'ape_entrep':
/**
* @todo : Ajouter la recherche par code
*/
$separator = ' , ';
$table = new Application_Model_Naf();
$sql = $table->select();
$sql->where('LOWER(lib) LIKE "%'.$q.'%"');
if (count($queries)>0) {
$where = '';
$i = 0;
foreach ($queries as $item) {
if (strlen($item)>2) {
$where = 'LIKE "%'.strtolower($item).'%"';
}
$i++;
if (count($queries) < $i){
$where.= ' OR ';
}
}
$sql->where("LOWER(lib) ".$where);
}
$sql->where('niveau = 5');
$result = $table->fetchAll($sql);
foreach ($result as $item) {
$output[] = array(