Subversion Repositories Sites.obs-saisons.fr

Rev

Rev 92 | Rev 173 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 92 Rev 105
Line 33... Line 33...
33
    /**
33
    /**
34
     * Méthode appelée pour ajouter un élément.
34
     * Méthode appelée pour ajouter un élément.
35
     */
35
     */
36
    public function createElement($params) {
36
    public function createElement($params) {
Line 37... Line 37...
37
    	
37
    	
38
    	$elements_requis = array('id_participant','station_nom', 'station_commune', 'station_lat', 'station_lon','station_milieu');
38
    	$elements_requis = array('id_participant','station_nom', 'station_commune', 'station_lat', 'station_lon','station_milieu','station_alt');
Line 39... Line 39...
39
    	$erreurs = array();
39
    	$erreurs = array();
40
        
40
        
41
    	foreach($elements_requis as $requis) {
41
    	foreach($elements_requis as $requis) {
Line 46... Line 46...
46
    	
46
    	
47
    	if(!empty($erreurs)) {
47
    	if(!empty($erreurs)) {
48
    		$this->envoyer($erreurs);
48
    		$this->envoyer($erreurs);
Line 49... Line -...
49
    	}
-
 
50
    	
-
 
51
    	$station['alt'] = '0';
49
    	}
Line 52... Line 50...
52
    	
50
    	
53
    	$id_participant = $params['id_participant'];
51
    	$id_participant = $params['id_participant'];
54
    	
52
    	
Line 79... Line 77...
79
    /**
77
    /**
80
     * Méthode appelée pour mettre à jour un élément
78
     * Méthode appelée pour mettre à jour un élément
81
     */
79
     */
82
    public function updateElement($uid, $params)    {
80
    public function updateElement($uid, $params)    {
Line -... Line 81...
-
 
81
    	
83
    	
82
	    $elements_requis = array('id_participant','station_nom', 'station_commune', 'station_lat', 'station_lon','station_milieu','station_alt');
-
 
83
    	$erreurs = array();
-
 
84
        
84
	    if(!isset($uid[0])) {
85
    	foreach($elements_requis as $requis) {
85
    		$id_participant = $uid[0];
86
    		if(!isset($params[$requis])) {
86
    	} else {
87
    			$erreurs[$requis] = 'erreur ';
87
    		return;
88
    		}
Line 88... Line 89...
88
    	}
89
    	}
89
    	
90
    	
90
    	if(!isset($uid[1])) {
91
    	if(!empty($erreurs)) {
-
 
92
    		$this->envoyer($erreurs);
-
 
93
    	}
-
 
94
    	
-
 
95
    	$id_participant = $params['id_participant'];
91
    		$id_station = $uid[1];
96
    	
-
 
97
    	if(!isset($uid[0])) {
-
 
98
    		return;
92
    	} else {
99
    	} else {
Line 93... Line 100...
93
    		return;
100
    		$id_station = $uid[0];;
94
    	}
101
    	}
95
    	
102
    	
Line 100... Line 107...
100
			'os_latitude ='.$this->proteger($params['station_lat']).','.
107
			'os_latitude ='.$this->proteger($params['station_lat']).','.
101
			'os_longitude ='.$this->proteger($params['station_lon']).','.
108
			'os_longitude ='.$this->proteger($params['station_lon']).','.
102
			'os_altitude ='.$this->proteger($params['station_alt']).','.
109
			'os_altitude ='.$this->proteger($params['station_alt']).','.
103
			'os_ce_environnement ='.$this->proteger($params['station_milieu']).','.
110
			'os_ce_environnement ='.$this->proteger($params['station_milieu']).','.
104
			'os_commentaire ='.$this->proteger($params['station_description']).' '.
111
			'os_commentaire ='.$this->proteger($params['station_description']).' '.
105
			'WHERE os_ce_particant = '.$this->proteger($id_participant).' '.
112
			'WHERE os_ce_participant = '.$this->proteger($id_participant).' '.
106
        	'AND os_id_station = '.$this->proteger($id_station);
113
        	'AND os_id_station = '.$this->proteger($id_station);
Line 107... Line 114...
107
							
114
							
-
 
115
		$modification_station = $this->executerRequeteSimple($requete_modification_station);
-
 
116
		
Line 108... Line 117...
108
		$modification_station = $this->executerRequeteSimple($requete_creation_station);
117
		$retour = array();
-
 
118
		
-
 
119
		if(!$modification_station) {
109
		
120
    		$retour['erreurs'] = 'Erreur lors de la modification de la station';
110
		if(!$modification_station) {
121
    	} else {
111
    		// TODO: comment gère t'on les erreurs ?
122
    		$retour['reponse'] = 'OK';
112
    	}
123
    	}
113
    	
124
 
Line 114... Line 125...
114
    	$this->envoyer();
125
    	$this->envoyer($retour);
115
    }
126
    }
116
   
127
   
Line 206... Line 217...
206
    private function obtenirInformationsCommuneParId($id_commune) {
217
    private function obtenirInformationsCommuneParId($id_commune) {
Line 207... Line 218...
207
    	
218
    	
208
    	//$requete_infos_commune = 'SELECT * FROM ods_communes WHERE oc_id_commune = '.$this->proteger($id_commune);
219
    	//$requete_infos_commune = 'SELECT * FROM ods_communes WHERE oc_id_commune = '.$this->proteger($id_commune);
Line -... Line 220...
-
 
220
    	//$infos_commune = $this->executerRequete($requete_infos_commune);
209
    	//$infos_commune = $this->executerRequete($requete_infos_commune);
221
    	
Line 210... Line 222...
210
    	
222
    	//TODO: en attendant de stocker les ids
211
    	return '';
223
    	return $id_commune;
Line 212... Line 224...
212
    	
224
    	
Line 213... Line 225...
213
    	return $infos_commune;
225
    	//return $infos_commune;
214
    }
226
    }
Line -... Line 227...
-
 
227
    
215
    
228
	private function obtenirInformationsCommuneParCodeInsee($code_insee_commune) {
Line 216... Line 229...
216
	private function obtenirInformationsCommuneParCodeInsee($code_insee_commune) {
229
    	
217
    	
230
    	//$requete_infos_commune = 'SELECT * FROM ods_communes WHERE oc_code_insee = '.$this->proteger($code_insee_commune);
Line 218... Line 231...
218
    	//$requete_infos_commune = 'SELECT * FROM ods_communes WHERE oc_code_insee = '.$this->proteger($code_insee_commune);
231
    	//$infos_commune = $this->executerRequete($requete_infos_commune);
Line 219... Line 232...
219
    	//$infos_commune = $this->executerRequete($requete_infos_commune);
232