Correction des codes postaux
This commit is contained in:
parent
b9cec9515b
commit
d6bcd86464
@ -2,45 +2,45 @@
|
||||
class Object_Codepostaux extends Libs_Row
|
||||
{
|
||||
/* Selection des classes statut pour jstree */
|
||||
public function _jstree_checked()
|
||||
public function _jstree_checked($type)
|
||||
{
|
||||
require_once('Scores/SessionCiblage.php');
|
||||
$session = new SessionCiblage();
|
||||
$valeurs = explode(',', $session->getCritere('adr_com'));
|
||||
|
||||
foreach ($valeurs as $valeur)
|
||||
$return[] = $valeur;
|
||||
if(is_array($return))
|
||||
$valeurs = explode(',', $session->getCritere($type));
|
||||
foreach ($valeurs as $valeur) {
|
||||
if(!empty($valeur)) {
|
||||
$return[] = $valeur;
|
||||
}
|
||||
}
|
||||
if(is_array($return)) {
|
||||
return ($return);
|
||||
}
|
||||
return (array($valeurs));
|
||||
}
|
||||
|
||||
public function _jstree_undetermined($niveau)
|
||||
public function _jstree_undetermined($niveau, $type)
|
||||
{
|
||||
require_once('Scores/SessionCiblage.php');
|
||||
$session = new SessionCiblage();
|
||||
$table = new Table_Departements();
|
||||
$valeurs = explode(',', $session->getCritere('adr_com'));
|
||||
$valeurs = explode(',', $session->getCritere($type));
|
||||
/*$valeurs = array_merge($valeurs, explode(',', $session->getCritere('adr_com')));*/
|
||||
$in = array();
|
||||
|
||||
|
||||
foreach($valeurs as $valeur) {
|
||||
$type = explode(':', $valeur);
|
||||
if($niveau == 0) {
|
||||
if ($type[0] == 'adr_dept'){
|
||||
$valeur = $type[1];
|
||||
if ($type == 'adr_dept'){
|
||||
$insee = $table->fetchAll($table->select('departements', array('codeRegionInsee'))
|
||||
->where('numdep = ?', substr($valeur, 0, 2)))->toArray();
|
||||
foreach ($insee as $code)
|
||||
$in[] = 'adr_reg:'.$code['codeRegionInsee'];
|
||||
} else{
|
||||
$valeur = $type[1];
|
||||
$insee = $table->fetchAll($table->select('departements', array('codeRegionInsee'))
|
||||
->where('numdep = ?', substr($valeur, 0, 2)))->toArray();
|
||||
foreach ($insee as $code)
|
||||
$in[] = 'adr_reg:'.$code['codeRegionInsee'];
|
||||
}
|
||||
} else if ($niveau == 1) {
|
||||
$valeur = $type[1];
|
||||
$insee = $table->fetchAll($table->select('departements', array('codeRegionInsee'))
|
||||
->where('numdep = ?', substr($valeur, 0, 2)))->toArray();
|
||||
foreach ($insee as $code)
|
||||
@ -52,9 +52,10 @@ class Object_Codepostaux extends Libs_Row
|
||||
|
||||
public function _getClass($valeur, $niveau)
|
||||
{
|
||||
if(in_array($valeur, $this->_jstree_checked()))
|
||||
$type = explode(':', $valeur);
|
||||
if(in_array($type[1], $this->_jstree_checked($type[0])))
|
||||
return ('jstree-checked');
|
||||
else if (in_array($valeur, $this->_jstree_undetermined($niveau)))
|
||||
else if (in_array($valeur, $this->_jstree_undetermined($niveau, $type[0])))
|
||||
return ('jstree-undetermined');
|
||||
}
|
||||
|
||||
@ -67,7 +68,7 @@ class Object_Codepostaux extends Libs_Row
|
||||
|
||||
foreach($regions as $nom) {
|
||||
$structure[] = array(
|
||||
'data' => $nom['NCCENR'],
|
||||
'data' => $nom['REGION'].' '.$nom['NCCENR'],
|
||||
'attr' => array('id' => 'adr_reg:'.$nom['REGION'],
|
||||
'niveau' => 0,
|
||||
'class' => $this->_getClass('adr_reg:'.$nom['REGION'], 0)
|
||||
@ -76,7 +77,6 @@ class Object_Codepostaux extends Libs_Row
|
||||
'children' => array()
|
||||
);
|
||||
}
|
||||
|
||||
return (json_encode($structure));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user