Création des fonctions pour gerer tous dans fields.

This commit is contained in:
Damien LASSERRE 2012-01-19 08:50:33 +00:00
parent e60e38af74
commit 8ccae142da

View File

@ -597,6 +597,60 @@ Class Fields
);
protected $requeteSql = array('cj');
public function getValues()
{
$session = new Zend_Session_Namespace('ciblage');
$values = array();
foreach($session->ciblage as $key => $item)
{
if($this->fields[$key]['type'] == 'interval' or
$this->fields[$key]['type'] == 'textarea' and
empty($this->fields[$key]['action']))
{
$values[$key] = explode(',', $item);
} else if (!empty($this->fields[$key]['action'])) {
$values[$key] = $this->getArbo($key, $item);
} else {
$values[$key] = $item;
}
}
return ($values);
}
public function getArbo($name, $valeur)
{
$values = array();
switch($name)
{
case 'ape_etab' :
$nafs = explode(',', $valeur);
foreach($nafs as $naf)
$values = array_merge($values, $this->nafArbo($name, $naf));
break;
}
return ($values);
}
protected function nafArbo($key, $valeur)
{
$value = array();
$table = new Application_Model_Naf();
$sql = $table->select()->from('naf')->where('parent = ?', $valeur);
$result = $sql->query();
$codes = $result->fetchAll();
foreach ($codes as $code) {
$sql = $table->select()->from('naf')->where("code LIKE '".$code['code']."%' and niveau = 5");
$result = $sql->query();
$elements = $result->fetchAll();
foreach($elements as $element) {
$value[] = $element['code'];
}
}
return ($value);
}
public function __construct($login)
{
require_once('Scores/SessionCiblage.php');