correction code naf arbo
This commit is contained in:
parent
46c7f5a8ee
commit
569150e763
@ -654,7 +654,7 @@ Class Fields
|
|||||||
if(strlen($valeur) < 5){
|
if(strlen($valeur) < 5){
|
||||||
if($valeur[0] == 'D') {
|
if($valeur[0] == 'D') {
|
||||||
$table = new Application_Model_Codepostaux();
|
$table = new Application_Model_Codepostaux();
|
||||||
$sql = $table->select()->where('Codepos LIKE "'.$valeur.'%"');
|
$sql = $table->select()->where('Codepos LIKE "'.substr($valeur, 1).'%"');
|
||||||
$codes = $table->fetchAll($sql)->toArray();
|
$codes = $table->fetchAll($sql)->toArray();
|
||||||
foreach($codes as $code) {
|
foreach($codes as $code) {
|
||||||
$values[] = $code['Codepos'];
|
$values[] = $code['Codepos'];
|
||||||
@ -679,19 +679,24 @@ Class Fields
|
|||||||
|
|
||||||
protected function nafArbo($key, $valeur)
|
protected function nafArbo($key, $valeur)
|
||||||
{
|
{
|
||||||
$value = array();
|
$value = array();
|
||||||
$table = new Application_Model_Naf();
|
$table = new Application_Model_Naf();
|
||||||
|
|
||||||
$sql = $table->select()->from('naf')->where('parent = ?', $valeur);
|
if(strlen($valeur) == 1)
|
||||||
$result = $sql->query();
|
{
|
||||||
$codes = $result->fetchAll();
|
$sql = $table->select()->where('parent = ?', $valeur);
|
||||||
foreach ($codes as $code) {
|
$result =$table->fetchAll($sql)->toArray();
|
||||||
$sql = $table->select()->from('naf')->where("code LIKE '".$code['code']."%' and niveau = 5");
|
foreach($result as $code) $where .= " code LIKE '".$code['code']."%' and niveau = 5 or ";
|
||||||
$result = $sql->query();
|
$where = substr($where, 0, (strlen($where)) - 3);
|
||||||
$elements = $result->fetchAll();
|
$sql = $table->select()->where($where);
|
||||||
foreach($elements as $element) {
|
$result = $table->fetchAll($sql)->toArray();
|
||||||
$value[] = $element['code'];
|
foreach($result as $code) $value[] = $code['code'];
|
||||||
}
|
} else if(strlen($valeur) < 5){
|
||||||
|
$sql = $table->select()->where("code LIKE '".$valeur."%' and niveau = 5");
|
||||||
|
$result = $table->fetchAll($sql)->toArray();
|
||||||
|
foreach($result as $code) $value[] = $code['code'];
|
||||||
|
} else if(strlen($valeur) == 5) {
|
||||||
|
$value[] = $valeur;
|
||||||
}
|
}
|
||||||
return ($value);
|
return ($value);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user