Recherche par mots sur les NAFs
This commit is contained in:
parent
7c574d164e
commit
b53665953f
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user