Subversion Repositories Sites.obs-saisons.fr

Rev

Rev 91 | Rev 287 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 91 Rev 210
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 de saisies pour le module individus.
4
 * Modèle d'accès à la base de données de saisies pour le module individus.
5
 *
5
 *
6
 * @package ODS_saisie
6
 * @package ODS_saisie
7
 * @category    php 5.2
7
 * @category    php 5.2
8
 * @author      Aurélien Peronnet <aurelien@tela-botanica.org>
8
 * @author      Aurélien Peronnet <aurelien@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: StationDao.php 154 2010-09-13 12:15:11Z aurelien $
12
 * @version SVN: $Id: StationDao.php 154 2010-09-13 12:15:11Z aurelien $
13
 *
13
 *
14
 */
14
 */
15
class IndividuDao extends Dao {
15
class IndividuDao extends Dao {
16
	
16
	
17
	const SERVICE_INDIVIDU = 'OdsIndividu';
17
	const SERVICE_INDIVIDU = 'OdsIndividu';
18
	const METHODE_INDIVIDUS_STATION = 'IndividusPourStation';
18
	const METHODE_INDIVIDUS_STATION = 'IndividusPourStation';
19
	const METHODE_INDIVIDUS_STATION_ESPECE = 'IndividusPourStationPourEspece';
19
	const METHODE_INDIVIDUS_STATION_ESPECE = 'IndividusPourStationPourEspece';
20
	
20
	
21
    /**
21
    /**
22
     * Retourne l'ensemble des informations d'un individu.
22
     * Retourne l'ensemble des informations d'un individu.
23
     *
23
     *
24
     * @param integer l'id d'une station.
24
     * @param integer l'id d'une station.
25
     * @return array un tableau contenant les informations sur les individus de cette station.
25
     * @return array un tableau contenant les informations sur les individus de cette station.
26
     */
26
     */
27
    public function getListeIndividusPourStation($id_station) {
27
    public function getListeIndividusPourStation($id_station) {
28
		
28
		
29
	    $url = $this->url_jrest.self::SERVICE_INDIVIDU.'/'.self::METHODE_INDIVIDUS_STATION.'/'.$id_station;
29
	    $url = $this->url_jrest.self::SERVICE_INDIVIDU.'/'.self::METHODE_INDIVIDUS_STATION.'/'.$id_station;
30
        $json = $this->envoyerRequeteConsultation($url);
30
        $json = $this->envoyerRequeteConsultation($url);
31
        $donnees = json_decode($json, true);   
31
        $donnees = json_decode($json, true);   
32
        return $donnees;
32
        return $donnees;
33
	}
33
	}
34
	
34
	
35
	public function getListeIndividusPourStationPourEspece($id_station, $id_espece) {
35
	public function getListeIndividusPourStationPourEspece($id_station, $id_espece) {
36
		
36
		
37
		$url = $this->url_jrest.self::SERVICE_INDIVIDU.'/'.self::METHODE_INDIVIDUS_STATION_ESPECE.'/'.$id_station.'/'.$id_espece;
37
		$url = $this->url_jrest.self::SERVICE_INDIVIDU.'/'.self::METHODE_INDIVIDUS_STATION_ESPECE.'/'.$id_station.'/'.$id_espece;
38
        $json = $this->envoyerRequeteConsultation($url);
38
        $json = $this->envoyerRequeteConsultation($url);
39
        $donnees = json_decode($json, true);   
39
        $donnees = json_decode($json, true);   
40
        
40
        
41
        return $donnees;
41
        return $donnees;
42
	}
42
	}
43
	    
43
	    
44
	public function getInformationsIndividu($id_individu) {
44
	public function getInformationsIndividu($id_individu) {
45
	    	    
45
	    	    
46
	    if (is_numeric($id_individu)) {
46
	    if (is_numeric($id_individu)) {
47
		    $url = $this->url_jrest.self::SERVICE_INDIVIDU."/$id_individu";
47
		    $url = $this->url_jrest.self::SERVICE_INDIVIDU."/$id_individu";
48
	        $json = $this->envoyerRequeteConsultation($url);
48
	        $json = $this->envoyerRequeteConsultation($url);
49
	        $donnees = json_decode($json, true);
49
	        $donnees = json_decode($json, true);
50
	        return $donnees;
50
	        return $donnees;
51
	    }
51
	    }
52
	}
52
	}
53
	
53
	
54
	public function ajouterIndividu($valeurs_individu_verifiees) {
54
	public function ajouterIndividu($valeurs_individu_verifiees) {
55
		
55
		
56
		$donnees = $valeurs_individu_verifiees;
56
		$donnees = $valeurs_individu_verifiees;
57
		
57
		
58
        $url = $this->url_jrest.self::SERVICE_INDIVIDU."/";
58
        $url = $this->url_jrest.self::SERVICE_INDIVIDU."/";
59
        $json = $this->envoyerRequeteAjout($url, $donnees);
59
        $json = $this->envoyerRequeteAjout($url, $donnees);
60
        $donnees = json_decode($json, true);
60
        $donnees = json_decode($json, true);
61
        
61
        
62
		$donnees_retour = json_decode($json, true);
62
		$donnees_retour = json_decode($json, true);
63
		
63
		
64
		return $donnees_retour;
64
		return $donnees_retour;
65
	}
65
	}
66
	
66
	
67
	public function modifierIndividu($id_individu, $valeurs_individu_verifiees) {
67
	public function modifierIndividu($id_individu, $valeurs_individu_verifiees) {
68
		
68
		
69
		$donnees = $valeurs_individu_verifiees;
69
		$donnees = $valeurs_individu_verifiees;
70
		
70
		
71
        if (is_numeric($id_individu)) {
71
        if (is_numeric($id_individu)) {
72
            $url = $this->url_jrest.self::SERVICE_INDIVIDU."/$id_individu";
72
            $url = $this->url_jrest.self::SERVICE_INDIVIDU."/$id_individu";
-
 
73
            
73
            $json = $this->envoyerRequeteModif($url, $donnees);
74
            $json = $this->envoyerRequeteModif($url, $donnees);
74
            $donnees = json_decode($json, true);
75
            $donnees = json_decode($json, true);
-
 
76
            
75
            if (true) {
77
            if($donnees_retour['reponse'] == 'OK') {
76
            	//TODO: verifier modification   
78
           		return true;
77
            }
79
           	}
78
        }
80
        }
79
		
81
		
-
 
82
		return false;
-
 
83
	}
-
 
84
	
-
 
85
	public function supprimerIndividu($id_individu) {
-
 
86
		
-
 
87
		$donnees = $valeurs_individu_verifiees;
-
 
88
		
-
 
89
        if (is_numeric($id_individu)) {
-
 
90
            $url = $this->url_jrest.self::SERVICE_INDIVIDU."/".AppControleur::getIdUtilisateur()."/".$id_individu;
-
 
91
            $json = $this->envoyerRequeteSuppression($url, $donnees);
-
 
92
            $donnees = json_decode($json, true);
-
 
93
            
-
 
94
           	$donnees_retour = json_decode($json, true);
-
 
95
           	
-
 
96
           	if($donnees_retour['reponse'] == 'OK') {
-
 
97
           		return true;
-
 
98
           	}
-
 
99
                   
-
 
100
        }
-
 
101
		
80
		return true;
102
		return false;
81
	}
103
	}
82
}
104
}
83
?>
105
?>