From fc600f3be2d2b82390f52e1eb3184ece2e1a0367 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Wed, 16 May 2012 14:16:58 +0000 Subject: [PATCH] =?UTF-8?q?Rappel=20des=20crit=C3=A8res=20dans=20l'arbores?= =?UTF-8?q?cence?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/ArborescenceController.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/application/controllers/ArborescenceController.php b/application/controllers/ArborescenceController.php index 8f5a3f26..eb8381a9 100644 --- a/application/controllers/ArborescenceController.php +++ b/application/controllers/ArborescenceController.php @@ -201,8 +201,8 @@ class ArborescenceController extends Zend_Controller_Action if ($val != null){ $valuesChecked = $val['in']; if (count($valuesChecked)>0) { - foreach($valuesChecked as $value){ - //$valuesUndetermined = array_merge($valuesUndetermined, $this->getNafParent($value, true)); + foreach($valuesChecked as $value){ + $valuesUndetermined = array_merge($valuesUndetermined, $this->getGeoParent($value)); } } } @@ -269,17 +269,15 @@ class ArborescenceController extends Zend_Controller_Action protected function getGeoParent($code) { - if (susbtr($code,0,1)=='D') { + if (substr($code,0,1)=='D') { $departementsM = new Application_Model_Departements(); $sql = $departementsM->select() ->from($departementsM, array('codeRegionInsee')) ->where('numdep = ?', substr($code,1)); - $departements = $departementsM->fetchRow($sql); + $departement = $departementsM->fetchRow($sql); - Zend_Registry::get('firebug')->info($departements); - - return array('R'.$departements->codeRegionInsee); + return array('R'.$departement->codeRegionInsee); } elseif ( substr($code,0,1)=='C' ) { @@ -289,8 +287,13 @@ class ArborescenceController extends Zend_Controller_Action ->where('INSEE = ?', substr($code,1)); $commune = $codePostauxM->fetchRow($sql); - return array('D'.substr($commune->Codepos,0,2)); + $departement = 'D'.substr($commune->Codepos,0,2); + $region = $this->getGeoParent($departement); + + return array_merge(array($departement), $region); } + + return array(); }