Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 795 Rev 1300
1
<?php
1
<?php
2
class GeneralFormateur implements Formateur {
2
class GeneralFormateur implements Formateur {
3
	public $dest_map = array();
3
	public $dest_map = array();
4
	public $img = array();
4
	public $img = array();
5
	public function __construct($info) {
5
	public function __construct($info) {
6
		$this->info = $info;
6
		$this->info = $info;
7
	}
7
	}
8
	public function img() {
8
	public function img() {
9
		$qualite = 9;
9
		$qualite = 9;
10
		imagepng($this->img['general'], Config::get('cache_stockageChemin').$this->dest_map['general'], $qualite);
10
		imagepng($this->img['general'], Config::get('cache_stockageChemin').$this->dest_map['general'], $qualite);
11
	}
11
	}
12
	//+----------------------------------------------------------------------------------------------------------------+
12
	//+----------------------------------------------------------------------------------------------------------------+
13
	// Méthodes d'accès aux objets du Framework
13
	// Méthodes d'accès aux objets du Framework
14
	/**
14
	/**
15
	* Méthode de connection à la base de données sur demande.
15
	* Méthode de connection à la base de données sur demande.
16
	* Tous les services web n'ont pas besoin de s'y connecter.
16
	* Tous les services web n'ont pas besoin de s'y connecter.
17
	*/
17
	*/
18
	protected function getBdd() {
18
	protected function getBdd() {
19
		if (! isset($this->Bdd)) {
19
		if (! isset($this->Bdd)) {
20
			$this->Bdd = new Bdd();
20
			$this->Bdd = new Bdd();
21
		}
21
		}
22
		return $this->Bdd;
22
		return $this->Bdd;
23
	}
23
	}
24
	
24
	
25
	public function definirCouleurs() {
25
	public function definirCouleurs() {
26
		// green
26
		// green
27
		$couleur['green'] = imagecolorallocate($this->img['general'], 0, 255, 0);
27
		$couleur['green'] = imagecolorallocate($this->img['general'], 0, 255, 0);
28
		// red
28
		// red
29
		$couleur['red'] = imagecolorallocate($this->img['general'], 255, 0, 0);
29
		$couleur['red'] = imagecolorallocate($this->img['general'], 255, 0, 0);
30
		// blue
30
		// blue
31
		$couleur['blue'] = imagecolorallocate($this->img['general'], 0, 0, 255);
31
		$couleur['blue'] = imagecolorallocate($this->img['general'], 0, 0, 255);
32
		// purple
32
		// purple
33
		$couleur['purple'] = imagecolorallocate($this->img['general'], 255, 0, 255);
33
		$couleur['purple'] = imagecolorallocate($this->img['general'], 255, 0, 255);
34
		// black
34
		// black
35
		$couleur['black'] = imagecolorallocate($this->img['general'], 0, 0, 0);
35
		$couleur['black'] = imagecolorallocate($this->img['general'], 0, 0, 0);
36
		return $couleur;
36
		return $couleur;
37
	}
37
	}
38
	
38
	
39
	public function initialiserImage() {
39
	public function initialiserImage() {
40
		// Nom du fichier image en sortie
40
		// Nom du fichier image en sortie
41
		$this->cheminCartesBase = Config::get('Cartes.chemin');
41
		$this->cheminCartesBase = Config::get('Cartes.chemin');
42
		$this->dest_map['general'] = 'nt'.$this->info['nt'].'_'.$this->info['src_map'];
42
		$this->dest_map['general'] = 'nt'.$this->info['nt'].'_'.$this->info['src_map'];
43
		$this->img['general'] = imagecreatefrompng($this->cheminCartesBase.$this->info['src_map']);
43
		$this->img['general'] = imagecreatefrompng($this->cheminCartesBase.$this->info['src_map']);
44
	}
44
	}
45
	
45
	
46
	public function testerParametresProjets() {
46
	public function testerParametresProjets() {
47
		$test = true;
47
		$test = true;
48
		return $test;
48
		return $test;
49
	}
49
	}
50
	
50
	
51
	public function chargerDonnees() {
51
	public function chargerDonnees() {
52
		// Recherche nom correspondant au numero nomenclatural en cours (pour etablir le lien avec les donnees moissonnes).
52
		// Recherche nom correspondant au numero nomenclatural en cours (pour etablir le lien avec les donnees moissonnes).
53
	
53
	
54
		// Récuperation donnée inventaire
54
		// Récuperation donnée inventaire
55
		/*
55
		/*
56
		* Les donnees issues du carnet en ligne sont recuperes directement, sans passer par le mecanisme de moissonage car :
56
		* Les donnees issues du carnet en ligne sont recuperes directement, sans passer par le mecanisme de moissonage car :
57
		*   - pour l'instant le service de moissonage n'est pas automatise et donc il y a un decalage dans l'affichage des donnees transmises
57
		*   - pour l'instant le service de moissonage n'est pas automatise et donc il y a un decalage dans l'affichage des donnees transmises
58
		*   - la table contenant les donnees moissonees ne reprend pas tous les champs necessaires a l'exploitation par eflore (notamment pas de code localite, pas d'identifiant libre)
58
		*   - la table contenant les donnees moissonees ne reprend pas tous les champs necessaires a l'exploitation par eflore (notamment pas de code localite, pas d'identifiant libre)
59
		*
59
		*
60
		* A terme, utilser vraiment le moissonage, y compris pour les donnees issues du CEL, en utilisant ABCD et en modifiant le programme d'harvesting.
60
		* A terme, utilser vraiment le moissonage, y compris pour les donnees issues du CEL, en utilisant ABCD et en modifiant le programme d'harvesting.
61
		*/
61
		*/
62
		if ($this->info['nt'] == 0) {
62
		if ($this->info['nt'] == 0) {
63
			$inventoriesCel = array();
63
			$inventoriesCel = array();
64
		} else {
64
		} else {
65
			$queryCel = "SELECT 'cel' as collection_code,  zone_geo as location, REPLACE(ce_zone_geo,'INSEE-C:','') as id_location, date_observation,  ".
65
			$queryCel = "SELECT 'cel' as collection_code,  zone_geo as location, REPLACE(ce_zone_geo,'INSEE-C:','') as id_location, date_observation,  ".
66
				"	longitude as y_utm, latitude as x_utm, geodatum as sector, courriel_utilisateur as identifiant FROM tb_cel.cel_obs ".
66
				"	longitude as y_utm, latitude as x_utm, geodatum as sector, courriel_utilisateur as identifiant FROM tb_new_cel.cel_obs ".
67
				"WHERE nt = '".$this->info['nt']."' ".
67
				"WHERE nt = '".$this->info['nt']."' ".
68
				"	AND transmission = 1";
68
				"	AND transmission = 1";
69
			$inventoriesCel = $this->getBdd()->recupererTous($queryCel);
69
			$inventoriesCel = $this->getBdd()->recupererTous($queryCel);
70
		}
70
		}
71
			
71
			
72
		// Recuperation des donnees de moissonage
72
		// Recuperation des donnees de moissonage
73
		// Collection code = 'flore' (Cenlr)
73
		// Collection code = 'flore' (Cenlr)
74
		if ($this->info['nom'] == '') {
74
		if ($this->info['nom'] == '') {
75
			$inventoriesCenlr = array();
75
			$inventoriesCenlr = array();
76
		} else {
76
		} else {
77
			$queryCenlr = "SELECT collection_code, locality as location, county as id_location, ".
77
			$queryCenlr = "SELECT collection_code, locality as location, county as id_location, ".
78
				"	STR_TO_DATE(concat(year, '/',month, '/',day), '%Y/%m/%d') as date_observation, latitude as y_utm , ". 
78
				"	STR_TO_DATE(concat(year, '/',month, '/',day), '%Y/%m/%d') as date_observation, latitude as y_utm , ". 
79
		    	"	longitude as x_utm , max_altitude as sector,  collector_name as identifiant ".
79
		    	"	longitude as x_utm , max_altitude as sector,  collector_name as identifiant ".
80
				"FROM tb_hit_indexation.raw_occurrence_record ".
80
				"FROM tb_hit_indexation.raw_occurrence_record ".
81
				"WHERE scientific_name = ".$this->getBdd()->proteger($this->info['nom']).
81
				"WHERE scientific_name = ".$this->getBdd()->proteger($this->info['nom']).
82
				"	AND collection_code = 'flore' ".
82
				"	AND collection_code = 'flore' ".
83
				"	AND (deleted IS NULL OR deleted = '0000-00-00 00:00:00')";
83
				"	AND (deleted IS NULL OR deleted = '0000-00-00 00:00:00')";
84
			$inventoriesCenlr = $this->getBdd()->recupererTous($queryCenlr);
84
			$inventoriesCenlr = $this->getBdd()->recupererTous($queryCenlr);
85
		}
85
		}
86
	
86
	
87
		// Collection code = 'FLORE - VAR' (Cbnmed)
87
		// Collection code = 'FLORE - VAR' (Cbnmed)
88
		/*$queryCbnmed = "SELECT collection_code, locality as location, county as id_location, ".
88
		/*$queryCbnmed = "SELECT collection_code, locality as location, county as id_location, ".
89
							"	STR_TO_DATE(concat(ifnull(year,0),'/', ifnull(month,0), '/',ifnull(day,0)), '%Y/%m/%d') as date_observation, ".
89
							"	STR_TO_DATE(concat(ifnull(year,0),'/', ifnull(month,0), '/',ifnull(day,0)), '%Y/%m/%d') as date_observation, ".
90
							"	latitude as y_utm , longitude as x_utm , max_altitude as sector, collector_name as identifiant ".
90
							"	latitude as y_utm , longitude as x_utm , max_altitude as sector, collector_name as identifiant ".
91
							"FROM tb_hit_indexation.raw_occurrence_record ".
91
							"FROM tb_hit_indexation.raw_occurrence_record ".
92
							"WHERE scientific_name = ".$this->getBdd()->proteger($this->info['nom']).
92
							"WHERE scientific_name = ".$this->getBdd()->proteger($this->info['nom']).
93
							"	AND collection_code='FLORE - VAR' ".
93
							"	AND collection_code='FLORE - VAR' ".
94
							"	AND  (deleted IS NULL OR deleted = '0000-00-00 00:00:00')";
94
							"	AND  (deleted IS NULL OR deleted = '0000-00-00 00:00:00')";
95
		$inventoriesCbnmed = $this->getBdd()->recupererTous($queryCbnmed);*/
95
		$inventoriesCbnmed = $this->getBdd()->recupererTous($queryCbnmed);*/
96
	
96
	
97
		// Collection code = 'sophy'
97
		// Collection code = 'sophy'
98
		if ($this->info['nom_ss_auteur'] == '') {
98
		if ($this->info['nom_ss_auteur'] == '') {
99
			$inventoriesSophy = array();
99
			$inventoriesSophy = array();
100
		} else {
100
		} else {
101
			$querySophy = "SELECT 'sophy' as collection_code, lieu_station_nom as location, lieu_commune_code_insee as id_location, ".
101
			$querySophy = "SELECT 'sophy' as collection_code, lieu_station_nom as location, lieu_commune_code_insee as id_location, ".
102
				"	observation_date as date_observation, lieu_station_utm_est as x_utm , ". 
102
				"	observation_date as date_observation, lieu_station_utm_est as x_utm , ". 
103
		    	"	lieu_station_utm_nord as y_utm , lieu_station_utm_zone as sector,  observateur_nom_complet as identifiant ".
103
		    	"	lieu_station_utm_nord as y_utm , lieu_station_utm_zone as sector,  observateur_nom_complet as identifiant ".
104
				"FROM sophy_tapir ".
104
				"FROM sophy_tapir ".
105
				"WHERE nom_scientifique_complet = ".$this->getBdd()->proteger($this->info['nom_ss_auteur']);
105
				"WHERE nom_scientifique_complet = ".$this->getBdd()->proteger($this->info['nom_ss_auteur']);
106
			$inventoriesSophy = $this->getBdd()->recupererTous($querySophy);
106
			$inventoriesSophy = $this->getBdd()->recupererTous($querySophy);
107
		}
107
		}
108
		
108
		
109
		return array_merge($inventoriesCel, $inventoriesCenlr, $inventoriesSophy); //$inventoriesCbnmed,
109
		return array_merge($inventoriesCel, $inventoriesCenlr, $inventoriesSophy); //$inventoriesCbnmed,
110
	}
110
	}
111
	
111
	
112
 
112
 
113
	public function dessinerPoint($text, $merge, $couleurs) {
113
	public function dessinerPoint($text, $merge, $couleurs) {
114
		$usemap['general'] = '';
114
		$usemap['general'] = '';
115
	
115
	
116
		foreach ($text as $coord => $origines ) {
116
		foreach ($text as $coord => $origines ) {
117
			foreach ($origines as $origine => $maptext ) {
117
			foreach ($origines as $origine => $maptext ) {
118
				$maptext = preg_replace("/\"/", "\'", $maptext);
118
				$maptext = preg_replace("/\"/", "\'", $maptext);
119
					
119
					
120
				list($x,$y) = explode('|', $coord);
120
				list($x,$y) = explode('|', $coord);
121
	
121
	
122
				$tpl_area = '<area shape="%s" alt="" class="tooltip" coords="%s" title="%s"/>';
122
				$tpl_area = '<area shape="%s" alt="" class="tooltip" coords="%s" title="%s"/>';
123
				$rayon = 2;
123
				$rayon = 2;
124
				$type = 'circle';
124
				$type = 'circle';
125
				$coords = "$x,$y,5";
125
				$coords = "$x,$y,5";
126
				$on_mouseover = "this.ttBgColor='#99C242';this.ttFontColor='#000000';this.T_OFFSETX=-200;this.T_OFFSETY=-50;this.T_STICKY=1;return escape('$maptext')";
126
				$on_mouseover = "this.ttBgColor='#99C242';this.ttFontColor='#000000';this.T_OFFSETX=-200;this.T_OFFSETY=-50;this.T_STICKY=1;return escape('$maptext')";
127
	
127
	
128
				if (isset($merge[$coord]) && $merge[$coord]) {
128
				if (isset($merge[$coord]) && $merge[$coord]) {
129
					imagefilledrectangle($this->img['general'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['black']);
129
					imagefilledrectangle($this->img['general'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['black']);
130
				} elseif (isset ($text[$coord]['cel']) && ($text[$coord]['cel'])) {
130
				} elseif (isset ($text[$coord]['cel']) && ($text[$coord]['cel'])) {
131
					imagefilledrectangle($this->img['general'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['green']);
131
					imagefilledrectangle($this->img['general'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['green']);
132
				} elseif (isset ($text[$coord]['flore']) && ($text[$coord]['flore'])) {
132
				} elseif (isset ($text[$coord]['flore']) && ($text[$coord]['flore'])) {
133
					imagefilledrectangle($this->img['general'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['red']);
133
					imagefilledrectangle($this->img['general'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['red']);
134
				}/* elseif (isset ($text[$coord]['FLORE - VAR']) && ($text[$coord]['FLORE - VAR'])) {
134
				}/* elseif (isset ($text[$coord]['FLORE - VAR']) && ($text[$coord]['FLORE - VAR'])) {
135
					imagefilledrectangle($this->img['general'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['blue']);
135
					imagefilledrectangle($this->img['general'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['blue']);
136
				}*/ elseif (isset ($text[$coord]['sophy']) && ($text[$coord]['sophy'])) {
136
				}*/ elseif (isset ($text[$coord]['sophy']) && ($text[$coord]['sophy'])) {
137
					imagefilledrectangle($this->img['general'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['purple']);
137
					imagefilledrectangle($this->img['general'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['purple']);
138
				}
138
				}
139
				$usemap['general'] = $usemap['general'].sprintf($tpl_area, $type, $coords, $maptext);
139
				$usemap['general'] = $usemap['general'].sprintf($tpl_area, $type, $coords, $maptext);
140
			}
140
			}
141
		}
141
		}
142
		return $usemap;
142
		return $usemap;
143
	}
143
	}
144
	
144
	
145
	public function formaterCartes($usemap) {
145
	public function formaterCartes($usemap) {
146
		$retour = Config::get('Cartes.cel_dst').$this->dest_map['general'];
146
		$retour = Config::get('Cartes.cel_dst').$this->dest_map['general'];
147
		if ($this->info['retour'] == self::MIME_MAP) {
147
		if ($this->info['retour'] == self::MIME_MAP) {
148
			$retour =  "<img src=\"".$retour."\" style=\"border:none; ".
148
			$retour =  "<img src=\"".$retour."\" style=\"border:none; ".
149
				"cursor:crosshair\" alt=\"\" usemap=\"#themap\" /><br />\n".
149
				"cursor:crosshair\" alt=\"\" usemap=\"#themap\" /><br />\n".
150
				"<map name=\"themap\" id=\"themap\">".utf8_encode($usemap['general'])."</map>";
150
				"<map name=\"themap\" id=\"themap\">".utf8_encode($usemap['general'])."</map>";
151
		}
151
		}
152
		return $retour;
152
		return $retour;
153
	}
153
	}
154
	
154
	
155
	//+----------------------------------------------------------------------------------------------------------------+
155
	//+----------------------------------------------------------------------------------------------------------------+
156
	// sous fonction de calculer répartition
156
	// sous fonction de calculer répartition
157
	public function chercherVille($inventory, $tab_code_insee = array()) {
157
	public function chercherVille($inventory, $tab_code_insee = array()) {
158
		$location_protege = $this->getBdd()->proteger($inventory['location']);
158
		$location_protege = $this->getBdd()->proteger($inventory['location']);
159
		$id_location_protege = '"'.$inventory['id_location'].'"';
159
		$id_location_protege = '"'.$inventory['id_location'].'"';
160
		$utm = array();
160
		$utm = array();
161
		if ($inventory['collection_code'] == 'FLORE - VAR') {
161
		if ($inventory['collection_code'] == 'FLORE - VAR') {
162
			if (isset($tab_code_insee[$location_protege])) {
162
			if (isset($tab_code_insee[$location_protege])) {
163
				$utm = array(0 => $tab_code_insee[$location_protege]);
163
				$utm = array(0 => $tab_code_insee[$location_protege]);
164
			}
164
			}
165
		} elseif ($inventory['collection_code'] == 'sophy') {
165
		} elseif ($inventory['collection_code'] == 'sophy') {
166
			if (strpos($inventory['id_location'], '20') === 0) {
166
			if (strpos($inventory['id_location'], '20') === 0) {
167
				$a = str_replace('20', '2A', $inventory['id_location']);
167
				$a = str_replace('20', '2A', $inventory['id_location']);
168
				if (isset($tab_code_insee[$a])) {
168
				if (isset($tab_code_insee[$a])) {
169
					$utm = array(0 => $tab_code_insee[$a]);
169
					$utm = array(0 => $tab_code_insee[$a]);
170
				} else {
170
				} else {
171
					$b = str_replace('20', '2B', $inventory['id_location']);
171
					$b = str_replace('20', '2B', $inventory['id_location']);
172
					if (isset($tab_code_insee[$b])) {
172
					if (isset($tab_code_insee[$b])) {
173
						$utm = array(0 => $tab_code_insee[$b]);
173
						$utm = array(0 => $tab_code_insee[$b]);
174
					}
174
					}
175
				}
175
				}
176
			} elseif (isset($tab_code_insee[$inventory['id_location']])) {
176
			} elseif (isset($tab_code_insee[$inventory['id_location']])) {
177
				$utm = array(0 => $tab_code_insee[$inventory['id_location']]);
177
				$utm = array(0 => $tab_code_insee[$inventory['id_location']]);
178
			} elseif (strpos($inventory['id_location'], '000') === 2) {
178
			} elseif (strpos($inventory['id_location'], '000') === 2) {
179
				$code = $this->getBdd()->proteger(str_replace('000', '', $inventory['id_location']));
179
				$code = $this->getBdd()->proteger(str_replace('000', '', $inventory['id_location']));
180
				$requete = "SELECT chef_lieu ".
180
				$requete = "SELECT chef_lieu ".
181
							"FROM tb_eflore.insee_d_v2011 ".
181
							"FROM tb_eflore.insee_d_v2011 ".
182
							"WHERE dep = $code ";
182
							"WHERE dep = $code ";
183
				$resultat = $this->getBdd()->recupererTous($requete);
183
				$resultat = $this->getBdd()->recupererTous($requete);
184
				if ($resultat != array() && isset($tab_code_insee[$resultat[0]['chef_lieu']])) {
184
				if ($resultat != array() && isset($tab_code_insee[$resultat[0]['chef_lieu']])) {
185
					$utm = $tab_code_insee[$resultat[0]['chef_lieu']];
185
					$utm = $tab_code_insee[$resultat[0]['chef_lieu']];
186
				}
186
				}
187
			}
187
			}
188
		} else {
188
		} else {
189
			if ($inventory['id_location'] != 'null') {
189
			if ($inventory['id_location'] != 'null') {
190
				if (isset($tab_code_insee[$id_location_protege])) {
190
				if (isset($tab_code_insee[$id_location_protege])) {
191
					$utm = array(0 => $tab_code_insee[$id_location_protege]);
191
					$utm = array(0 => $tab_code_insee[$id_location_protege]);
192
				} else {
192
				} else {
193
					$requete = "SELECT nom as name, code as insee_code, utm_x as x_utm, utm_y as y_utm, utm_secteur as sector ".
193
					$requete = "SELECT nom as name, code as insee_code, utm_x as x_utm, utm_y as y_utm, utm_secteur as sector ".
194
										"FROM tb_cel.cel_zones_geo ".
194
										"FROM tb_new_cel.cel_zones_geo ".
195
										"WHERE nom LIKE $location_protege ".
195
										"WHERE nom LIKE $location_protege ".
196
										"	AND code = $id_location_protege ";
196
										"	AND code = $id_location_protege ";
197
					$resultat = $this->getBdd()->recupererTous($requete);
197
					$resultat = $this->getBdd()->recupererTous($requete);
198
					if ($resultat != false) {
198
					if ($resultat != false) {
199
						$utm = $resultat;
199
						$utm = $resultat;
200
					} 
200
					} 
201
				}
201
				}
202
			} else {
202
			} else {
203
				$requete = "SELECT nom as name, code as insee_code, utm_x as x_utm, utm_y as y_utm, utm_secteur as sector".
203
				$requete = "SELECT nom as name, code as insee_code, utm_x as x_utm, utm_y as y_utm, utm_secteur as sector".
204
					" FROM tb_cel.cel_zones_geo WHERE nom LIKE $location_protege ";
204
					" FROM tb_new_cel.cel_zones_geo WHERE nom LIKE $location_protege ";
205
				$utm = $this->getBdd()->recupererTous($requete);
205
				$utm = $this->getBdd()->recupererTous($requete);
206
			}
206
			}
207
		}
207
		}
208
		return $utm;
208
		return $utm;
209
	}
209
	}
210
 
210
 
211
	public function formerCommentaire($utm, $inventory) {
211
	public function formerCommentaire($utm, $inventory) {
212
		$comment = '';
212
		$comment = '';
213
			
213
			
214
		if ($inventory['date_observation'] != '0000-00-00 00:00:00') {
214
		if ($inventory['date_observation'] != '0000-00-00 00:00:00') {
215
			$comment .= $this->formerDate($inventory);
215
			$comment .= $this->formerDate($inventory);
216
		}
216
		}
217
			
217
			
218
		if ($inventory['collection_code'] == 'cel') {
218
		if ($inventory['collection_code'] == 'cel') {
219
			list($identifiant) = explode("@", $inventory['identifiant']);
219
			list($identifiant) = explode("@", $inventory['identifiant']);
220
			$comment .= " par ".$identifiant."@...";
220
			$comment .= " par ".$identifiant."@...";
221
		} else {
221
		} else {
222
			$comment .= " par ".utf8_decode($inventory['identifiant']);
222
			$comment .= " par ".utf8_decode($inventory['identifiant']);
223
		}
223
		}
224
		return $comment;
224
		return $comment;
225
	}
225
	}
226
	
226
	
227
	public function formerDate($inventory) {
227
	public function formerDate($inventory) {
228
		$date = NULL;
228
		$date = NULL;
229
		if ($inventory['collection_code'] == 'sophy') {
229
		if ($inventory['collection_code'] == 'sophy') {
230
			$date = ', en '.$inventory['date_observation'];
230
			$date = ', en '.$inventory['date_observation'];
231
		}
231
		}
232
		elseif($inventory['date_observation']) {
232
		elseif($inventory['date_observation']) {
233
			list($year, $month, $day) = explode ('-',$inventory['date_observation']);
233
			list($year, $month, $day) = explode ('-',$inventory['date_observation']);
234
			list($day) = explode (' ',$day);
234
			list($day) = explode (' ',$day);
235
			if ($month == '00') {
235
			if ($month == '00') {
236
				$date = ', en '.$year;
236
				$date = ', en '.$year;
237
			} else {
237
			} else {
238
				$date = ', le '.$day.'/'.$month.'/'.$year;
238
				$date = ', le '.$day.'/'.$month.'/'.$year;
239
			}
239
			}
240
		}
240
		}
241
		return $date;
241
		return $date;
242
	}
242
	}
243
	/*
243
	/*
244
	 * Stockage commentaire associe a un point :
244
	 * Stockage commentaire associe a un point :
245
	 * 
245
	 * 
246
	 * Param : 
246
	 * Param : 
247
	 * @text : texte cumule
247
	 * @text : texte cumule
248
	 * @merge : indicateur de commentaire fusionne
248
	 * @merge : indicateur de commentaire fusionne
249
	 * @name : commune associee
249
	 * @name : commune associee
250
	 * @comment : commentaire
250
	 * @comment : commentaire
251
	 * @origine : origine de la donnee
251
	 * @origine : origine de la donnee
252
	 * 
252
	 * 
253
	 * 
253
	 * 
254
	 * TODO : rendre cette fonction independante des valeurs d'origine passee en parametre
254
	 * TODO : rendre cette fonction independante des valeurs d'origine passee en parametre
255
	 */
255
	 */
256
	public function stockerCommentaire($text, $merge, $name, $comment, $origine, $x, $y) {
256
	public function stockerCommentaire($text, $merge, $name, $comment, $origine, $x, $y) {
257
		if ($origine == 'cel') {
257
		if ($origine == 'cel') {
258
			$prefix = 'CEL : ';
258
			$prefix = 'CEL : ';
259
		} elseif ($origine == 'flore') {
259
		} elseif ($origine == 'flore') {
260
			$prefix = 'CEN LR : ';
260
			$prefix = 'CEN LR : ';
261
		} /*elseif ($origine == 'FLORE - VAR') {
261
		} /*elseif ($origine == 'FLORE - VAR') {
262
			$prefix = 'CBN MED : ';
262
			$prefix = 'CBN MED : ';
263
		}*/ elseif ($origine == 'sophy') {
263
		}*/ elseif ($origine == 'sophy') {
264
			$prefix = 'SOPHY : ';
264
			$prefix = 'SOPHY : ';
265
		}
265
		}
266
		
266
		
267
		// Cumul toute origine :   
267
		// Cumul toute origine :   
268
		if (isset($text[$x.'|'.$y]['tout']) && ($text[$x.'|'.$y])) {
268
		if (isset($text[$x.'|'.$y]['tout']) && ($text[$x.'|'.$y])) {
269
			$text[$x.'|'.$y]['tout'] = $text[$x.'|'.$y]['tout'].'<br>'.$prefix.$name.$comment;
269
			$text[$x.'|'.$y]['tout'] = $text[$x.'|'.$y]['tout'].'<br>'.$prefix.$name.$comment;
270
		} else {
270
		} else {
271
			// Nouveau commentaire
271
			// Nouveau commentaire
272
			$text[$x.'|'.$y]['tout']=$prefix.$name.$comment;
272
			$text[$x.'|'.$y]['tout']=$prefix.$name.$comment;
273
		}
273
		}
274
		 
274
		 
275
		// Deja present  pour cette origine ? on ajoute  
275
		// Deja present  pour cette origine ? on ajoute  
276
		if (isset ($text[$x.'|'.$y][$origine]) && ($text[$x.'|'.$y][$origine])) {
276
		if (isset ($text[$x.'|'.$y][$origine]) && ($text[$x.'|'.$y][$origine])) {
277
			$text[$x.'|'.$y][$origine] = $text[$x.'|'.$y][$origine].'<br>'.$name.$comment;
277
			$text[$x.'|'.$y][$origine] = $text[$x.'|'.$y][$origine].'<br>'.$name.$comment;
278
		} else { // Nouveau commentaire
278
		} else { // Nouveau commentaire
279
			$text[$x.'|'.$y][$origine] = $name.$comment;
279
			$text[$x.'|'.$y][$origine] = $name.$comment;
280
		}
280
		}
281
		
281
		
282
		
282
		
283
		// Detection superposition de donnee 
283
		// Detection superposition de donnee 
284
		if ($origine == 'cel') {
284
		if ($origine == 'cel') {
285
			if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) || (isset ($text[$x.'|'.$y]['flore']) && ($text[$x.'|'.$y]['flore'])) 
285
			if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) || (isset ($text[$x.'|'.$y]['flore']) && ($text[$x.'|'.$y]['flore'])) 
286
			|| (isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR']))) {
286
			|| (isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR']))) {
287
				$merge[$x.'|'.$y]=true;
287
				$merge[$x.'|'.$y]=true;
288
			}
288
			}
289
		} elseif ($origine == 'flore') {
289
		} elseif ($origine == 'flore') {
290
			if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) ||(isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) || 
290
			if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) ||(isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) || 
291
			(isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR']))) {
291
			(isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR']))) {
292
				$merge[$x.'|'.$y]=true;
292
				$merge[$x.'|'.$y]=true;
293
			}
293
			}
294
		} elseif ($origine == 'FLORE - VAR') {
294
		} elseif ($origine == 'FLORE - VAR') {
295
			if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) || (isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) || 
295
			if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) || (isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) || 
296
			(isset ($text[$x.'|'.$y]['flore']) && ($text[$x.'|'.$y]['flore']))) {
296
			(isset ($text[$x.'|'.$y]['flore']) && ($text[$x.'|'.$y]['flore']))) {
297
				$merge[$x.'|'.$y]=true;
297
				$merge[$x.'|'.$y]=true;
298
			}					
298
			}					
299
		} elseif ($origine == 'sophy') {
299
		} elseif ($origine == 'sophy') {
300
			if ((isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) || (isset ($text[$x.'|'.$y]['flore']) && ($text[$x.'|'.$y]['flore'])|| 
300
			if ((isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) || (isset ($text[$x.'|'.$y]['flore']) && ($text[$x.'|'.$y]['flore'])|| 
301
				(isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR'])))) {
301
				(isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR'])))) {
302
				$merge[$x.'|'.$y]=true;
302
				$merge[$x.'|'.$y]=true;
303
			}					
303
			}					
304
		}
304
		}
305
		
305
		
306
		return array($text, $merge);
306
		return array($text, $merge);
307
	}
307
	}
308
}
308
}
309
?>
309
?>