From 8ccae142da5ffe28117feff5b28045d0949d6406 Mon Sep 17 00:00:00 2001 From: Damien LASSERRE Date: Thu, 19 Jan 2012 08:50:33 +0000 Subject: [PATCH] =?UTF-8?q?Cr=C3=A9ation=20des=20fonctions=20pour=20gerer?= =?UTF-8?q?=20tous=20dans=20fields.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/Scores/Field.php | 54 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) 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');