diff --git a/application/modules/frontend/models/Objects/Codepostaux.php b/application/modules/frontend/models/Objects/Codepostaux.php index f3ceae98..ece37e20 100644 --- a/application/modules/frontend/models/Objects/Codepostaux.php +++ b/application/modules/frontend/models/Objects/Codepostaux.php @@ -28,25 +28,24 @@ class Object_Codepostaux extends Libs_Row if ($valeur[0] == 'D'){ $valeur = substr($valeur, 1, strlen($valeur)); $insee = $table->fetchAll($table->select('departements', array('codeRegionInsee')) - ->where('numdep = ?', $valeur))->toArray(); + ->where('numdep = ?', substr($valeur, 0, 2)))->toArray(); foreach ($insee as $code) $in[] = 'R'.$code['codeRegionInsee']; } else{ - $valeur = substr($valeur, 1, strlen($valeur)); + $valeur = substr($valeur, 0, strlen($valeur)); $insee = $table->fetchAll($table->select('departements', array('codeRegionInsee')) ->where('numdep = ?', substr($valeur, 0, 2)))->toArray(); foreach ($insee as $code) - $in[] = $code; + $in[] = 'R'.$code['codeRegionInsee']; } } else if ($niveau == 1) { - $valeur = substr($valeur, 1, strlen($valeur)); + $valeur = substr($valeur, 0, strlen($valeur)); $insee = $table->fetchAll($table->select('departements', array('codeRegionInsee')) ->where('numdep = ?', substr($valeur, 0, 2)))->toArray(); foreach ($insee as $code) - $in[] = $code; + $in[] = 'D'.$code['numdep']; } } - return ($in); }