Subversion Repositories eFlore/Applications.coel-consultation

Rev

Rev 169 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 169 Rev 195
1
<?php
1
<?php
2
// declare(encoding='UTF-8');
2
// declare(encoding='UTF-8');
3
/**
3
/**
4
 * Modèle d'accès à la base de données des Collections pour le module Structure.
4
 * Modèle d'accès à la base de données des Collections pour le module Structure.
5
 *
5
 *
6
 * @package	Collection
6
 * @package	Collection
7
 * @category	php 5.2
7
 * @category	php 5.2
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
 * @copyright	2010 Tela-Botanica
9
 * @copyright	2010 Tela-Botanica
10
 * @license	http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
10
 * @license	http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
11
 * @license	http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
11
 * @license	http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
12
 * @version	SVN: $Id: StructureDao.php 169 2011-03-11 09:15:42Z jpm $
12
 * @version	SVN: $Id: StructureDao.php 195 2014-01-22 13:29:20Z aurelien $
13
 *
13
 *
14
 */
14
 */
15
class StructureDao extends Dao {
15
class StructureDao extends Dao {
16
	const ROLE_EQUIPE = 2027;
16
	const ROLE_EQUIPE = 2027;
17
	const SERVICE_STRUCTURE = 'CoelStructure';
17
	const SERVICE_STRUCTURE = 'CoelStructure';
18
	const SERVICE_STRUCTURE_A_PERSONNE = 'CoelStructureAPersonne';
18
	const SERVICE_STRUCTURE_A_PERSONNE = 'CoelStructureAPersonne';
19
	
19
	
20
	/**
20
	/**
21
	 * Retourne l'ensemble des information sur une structure.
21
	 * Retourne l'ensemble des information sur une structure.
22
	 * 
22
	 * 
23
	 * @param integer l'id de la structure.
23
	 * @param integer l'id de la structure.
24
	 * @return array un tableau contenant les informations sur la structure.
24
	 * @return array un tableau contenant les informations sur la structure.
25
	 */
25
	 */
26
	public function getStructure($id_structure) {
26
	public function getStructure($id_structure) {
27
		$url = $this->url_jrest.self::SERVICE_STRUCTURE."/*/$id_structure/*";
27
		$url = $this->url_jrest.self::SERVICE_STRUCTURE."/$id_structure/*";
28
		$json = $this->envoyerRequeteConsultation($url);
28
		$json = $this->envoyerRequeteConsultation($url);
29
		$donnees = json_decode($json, true);
29
		$donnees = json_decode($json, true);
30
		return $donnees['structures'];
30
		return $donnees['structures'];
31
	}
31
	}
32
	
32
	
33
	/**
33
	/**
34
	 * Retourne le nombre de structure par zone géographique.
34
	 * Retourne le nombre de structure par zone géographique.
35
	 * 
35
	 * 
36
	 * @param integer le type de recherche à effectuée.
36
	 * @param integer le type de recherche à effectuée.
37
	 * @return array un tableau contenant les informations sur le nombre de structures par zone.
37
	 * @return array un tableau contenant les informations sur le nombre de structures par zone.
38
	 */
38
	 */
39
	public function getStructureParZoneGeo($type_recherche) {
39
	public function getStructureParZoneGeo($type_recherche) {
40
		$url = $this->url_jrest.self::SERVICE_STRUCTURE."/ParZoneGeo/$type_recherche";
40
		$url = $this->url_jrest.self::SERVICE_STRUCTURE."/ParZoneGeo/$type_recherche";
41
		$url = $this->limiterParProjets($url);
-
 
42
		$json = $this->envoyerRequeteConsultation($url);
41
		$json = $this->envoyerRequeteConsultation($url);
43
		$donnees = json_decode($json, true);
42
		$donnees = json_decode($json, true);
44
		return $donnees;
43
		return $donnees;
45
	}
44
	}
46
	
-
 
47
	private function limiterParProjets($url) {
-
 
48
		if (Config::get('projets') != '') {
-
 
49
			$url .= '/'.Config::get('projets');
-
 
50
		}
-
 
51
		return $url;
-
 
52
	}
-
 
53
	
45
	
54
	/**
46
	/**
55
	 * Retourne l'ensemble des informations du personnel d'une structure.
47
	 * Retourne l'ensemble des informations du personnel d'une structure.
56
	 * 
48
	 * 
57
	 * @param integer l'id de la structure.
49
	 * @param integer l'id de la structure.
58
	 * @return array un tableau contenant les informations sur le personnel de la structure.
50
	 * @return array un tableau contenant les informations sur le personnel de la structure.
59
	 */
51
	 */
60
	public function getPersonnel($id_structure) {
52
	public function getPersonnel($id_structure) {
61
		$donnees = $this->getStructureAPersonne($id_structure);
53
		$donnees = $this->getStructureAPersonne($id_structure);
62
		$personnel = $this->filtrerRoleEquipe($donnees['structuresAPersonne']);
54
		$personnel = $this->filtrerRoleEquipe($donnees['structuresAPersonne']);
63
		return $personnel;
55
		return $personnel;
64
	}
56
	}
65
	
57
	
66
	/**
58
	/**
67
	 * Retourne le nombre de personnel d'une structure.
59
	 * Retourne le nombre de personnel d'une structure.
68
	 * 
60
	 * 
69
	 * @param integer l'id de la structure.
61
	 * @param integer l'id de la structure.
70
	 * @return integer le nombre de personnel de la structure.
62
	 * @return integer le nombre de personnel de la structure.
71
	 */
63
	 */
72
	public function getNbrePersonnel($id_structure) {
64
	public function getNbrePersonnel($id_structure) {
73
		$donnees = $this->getStructureAPersonne($id_structure);
65
		$donnees = $this->getStructureAPersonne($id_structure);
74
		$personnel = $this->filtrerRoleEquipe($donnees['structuresAPersonne']);
66
		$personnel = $this->filtrerRoleEquipe($donnees['structuresAPersonne']);
75
		$nbre_personnel = count($personnel);
67
		$nbre_personnel = count($personnel);
76
		return $nbre_personnel;
68
		return $nbre_personnel;
77
	}
69
	}
78
	
70
	
79
	private function getStructureAPersonne($id_structure) {
71
	private function getStructureAPersonne($id_structure) {
80
		$url = $this->url_jrest.self::SERVICE_STRUCTURE_A_PERSONNE."/$id_structure";
72
		$url = $this->url_jrest.self::SERVICE_STRUCTURE_A_PERSONNE."/$id_structure";
81
		$json = $this->envoyerRequeteConsultation($url);
73
		$json = $this->envoyerRequeteConsultation($url);
82
		$donnees = json_decode($json, true);
74
		$donnees = json_decode($json, true);
83
		return $donnees;
75
		return $donnees;
84
	}
76
	}
85
	
77
	
86
	private function filtrerRoleEquipe($personnes) {
78
	private function filtrerRoleEquipe($personnes) {
87
		$personnel = array();
79
		$personnel = array();
88
		foreach ($personnes as $personne) {
80
		foreach ($personnes as $personne) {
89
			if ($personne['csap_id_role'] == self::ROLE_EQUIPE) {
81
			if ($personne['csap_id_role'] == self::ROLE_EQUIPE) {
90
				$personnel[] = $personne;
82
				$personnel[] = $personne;
91
			}
83
			}
92
		}
84
		}
93
		return $personnel;
85
		return $personnel;
94
	}
86
	}
95
}
87
}
96
?>
88
?>