diff --git a/library/Scores/Field.php b/library/Scores/Field.php index f6180b0f..2087954d 100644 --- a/library/Scores/Field.php +++ b/library/Scores/Field.php @@ -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');