issue #0001477 : Ajout nouveau champs code départements
This commit is contained in:
parent
e986fc30f1
commit
09a3134052
@ -371,7 +371,7 @@ class Scores_Fields
|
||||
'codesinsee' => array(
|
||||
'label' => 'Liste de codes Insee',
|
||||
'fields' => array(
|
||||
'list' => array(),
|
||||
'list' => array('title' => "Liste de codes Insee"),
|
||||
),
|
||||
'famille' => 'geographique',
|
||||
'activated' => true,
|
||||
@ -380,11 +380,20 @@ class Scores_Fields
|
||||
'codespostaux' => array(
|
||||
'label' => 'Liste de codes postaux',
|
||||
'fields' => array(
|
||||
'list' => array(),
|
||||
'list' => array('title' => "Liste de codes postaux"),
|
||||
),
|
||||
'famille' => 'geographique',
|
||||
'activated' => true,
|
||||
'title' => 'Liste de codes postaux séparés des virgules ou des points-virgules',
|
||||
'title' => 'Liste de codes postaux séparés par des virgules ou des points-virgules',
|
||||
),
|
||||
'codesdepts' => array(
|
||||
'label' => 'Liste de départements',
|
||||
'fields' => array(
|
||||
'list' => array('title' => "Liste de départements"),
|
||||
),
|
||||
'famille' => 'geographique',
|
||||
'activated' => true,
|
||||
'title' => 'Liste de code départements séparés par des virgules ou des points-virgules',
|
||||
),
|
||||
'adr_reg' => array(
|
||||
'label' => 'Liste code région',
|
||||
@ -798,7 +807,7 @@ Les zones urbaines sensibles constituent un sous-ensemble de l'ensemble plus lar
|
||||
$this->ciblage['NB']['insee'] = $this->insee;
|
||||
$session->ciblage = $this->ciblage;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* After define criteres and no error return, set the session externaly
|
||||
* @return void
|
||||
@ -826,18 +835,18 @@ Les zones urbaines sensibles constituent un sous-ensemble de l'ensemble plus lar
|
||||
Zend_Registry::get('firebug')->info('CLE INCORRECT');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$sessionKey = $key;
|
||||
if (array_key_exists('sessionKey', $this->fields[$key])) {
|
||||
$sessionKey = $this->fields[$key]['sessionKey'];
|
||||
}
|
||||
|
||||
|
||||
//Remove critere for these values on all type of fields
|
||||
if ( in_array($value, array('', '-', null)) ) {
|
||||
unset($this->ciblage[$sessionKey]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* single
|
||||
* interval
|
||||
@ -874,7 +883,7 @@ Les zones urbaines sensibles constituent un sous-ensemble de l'ensemble plus lar
|
||||
if ( in_array($types[0], array('interval', 'intervalDate')) ) {
|
||||
$value = explode(',', $value);
|
||||
}
|
||||
|
||||
|
||||
//Remove duplicate values
|
||||
if (is_array($value) ) {
|
||||
$value = array_unique($value);
|
||||
@ -892,7 +901,7 @@ Les zones urbaines sensibles constituent un sous-ensemble de l'ensemble plus lar
|
||||
if ($minmax!==false) {
|
||||
$valMin = $minmax->min;
|
||||
$valMax = $minmax->max;
|
||||
|
||||
|
||||
if ($value[0]<$valMin) {
|
||||
$value[0] = $valMin;
|
||||
}
|
||||
@ -905,7 +914,7 @@ Les zones urbaines sensibles constituent un sous-ensemble de l'ensemble plus lar
|
||||
if ($value[1]<$valMin) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
case 'checkbox':
|
||||
@ -917,7 +926,7 @@ Les zones urbaines sensibles constituent un sous-ensemble de l'ensemble plus lar
|
||||
//@todo : Check if values exist
|
||||
break;
|
||||
case 'list':
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -931,10 +940,10 @@ Les zones urbaines sensibles constituent un sous-ensemble de l'ensemble plus lar
|
||||
Zend_Registry::get('firebug')->info($value);
|
||||
$this->ciblage[$sessionKey]['in'] = $value;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Définir les critères en une fois
|
||||
* @param array $criteres Criteres as array with key => val
|
||||
@ -1122,13 +1131,13 @@ Les zones urbaines sensibles constituent un sous-ensemble de l'ensemble plus lar
|
||||
$communeM = new Application_Model_CodePostaux();
|
||||
$sql = $communeM->select()->from($communeM, array('Commune'))->where('INSEE = ?', substr($item, 1));
|
||||
$result = $communeM->fetchAll($sql)->toArray();
|
||||
$out[] = $result[0]['Commune'];
|
||||
$out[] = $result[0]['Commune'].' ('.$result[0]['Codepos'].')';
|
||||
break;
|
||||
case 'D':
|
||||
$departementsM = new Application_Model_Departements();
|
||||
$sql = $departementsM->select()->from($departementsM, array('libdep'))->where('numdep = ?', substr($item, 1));
|
||||
$result = $departementsM->fetchAll($sql)->toArray();
|
||||
$out[] = $result[0]['libdep'];
|
||||
$out[] = $result[0]['libdep'].' ('.$result[0]['numdep'].')';
|
||||
break;
|
||||
case 'R':
|
||||
$regionsM = new Application_Model_Regions();
|
||||
@ -1141,6 +1150,44 @@ Les zones urbaines sensibles constituent un sous-ensemble de l'ensemble plus lar
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function getValueLabelCodespostaux($values)
|
||||
{
|
||||
foreach ( $values as $item ) {
|
||||
$communeM = new Application_Model_CodePostaux();
|
||||
$sql = $communeM->select()->from($communeM, array('Commune'))->where('Codepos = ?', $item);
|
||||
$result = $communeM->fetchAll($sql)->toArray();
|
||||
$strCommunes = '';
|
||||
foreach ( $result as $c ) {
|
||||
if (!empty($strCommunes)) $strCommunes.= ', ';
|
||||
$strCommunes.= $c['Commune'];
|
||||
}
|
||||
$out[] = $item.' ('.$strCommunes.')';
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function getValueLabelCodesdepts($values)
|
||||
{
|
||||
foreach ( $values as $item ) {
|
||||
$departementsM = new Application_Model_Departements();
|
||||
$sql = $departementsM->select()->from($departementsM, array('libdep'))->where('numdep = ?', $item);
|
||||
$result = $departementsM->fetchAll($sql)->toArray();
|
||||
$out[] = $item.' ('.$result[0]['libdep'].')';
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function getValueLabelCodeinsee($values)
|
||||
{
|
||||
foreach ( $values as $item ) {
|
||||
$communeM = new Application_Model_CodePostaux();
|
||||
$sql = $communeM->select()->from($communeM, array('Commune'))->where('INSEE = ?', $item);
|
||||
$result = $communeM->fetchAll($sql)->toArray();
|
||||
$out[] = $item.' ('.$result[0]['Commune'].')';
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function getValueLabelJuridique($values)
|
||||
{
|
||||
$values = array_map(function($value){ return '"'.$value.'"'; }, $values);
|
||||
@ -1150,7 +1197,7 @@ Les zones urbaines sensibles constituent un sous-ensemble de l'ensemble plus lar
|
||||
$sql = $fjM->select()->from($fjM, array('fjLibelle'))->where('fjCode IN ('.join(',',$values).')');
|
||||
$result = $fjM->fetchAll($sql)->toArray();
|
||||
foreach ( $result as $elem ) {
|
||||
$out[] = $elem['fjLibelle'];
|
||||
$out[] = $elem['fjLibelle'].' ('.$elem['fjCode'].')';
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
@ -1212,6 +1259,10 @@ Les zones urbaines sensibles constituent un sous-ensemble de l'ensemble plus lar
|
||||
return $this->{'getValueLabel'.$action}($values);
|
||||
//Recherche des valeurs
|
||||
break;
|
||||
case 'list':
|
||||
$action = ucfirst($name);
|
||||
return $this->{'getValueLabel'.$action}($values);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user