Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 1576 Rev 1579
Line 69... Line 69...
69
	
69
	
70
	private function getUrlServeurGraph() {
70
	private function getUrlServeurGraph() {
71
		$url = sprintf($this->url_serveur_graph_tpl, rand(0, 9).'.');
71
		$url = sprintf($this->url_serveur_graph_tpl, rand(0, 9).'.');
72
		return $url;
72
		return $url;
-
 
73
	}
73
	}
74
	
74
	private function construireUrlGraph($graph) {
75
	private function construireUrlGraph($graph) {
Line 75... Line 76...
75
		$graph = $this->protegerGraphPourUrl($graph);
76
		$graph = $this->protegerGraphPourUrl($graph);
76
		
77
		
Line 87... Line 88...
87
			$graph['chtt'] = str_replace(' ', '+', $graph['chtt']);
88
			$graph['chtt'] = str_replace(' ', '+', $graph['chtt']);
88
		}
89
		}
89
		return $graph;
90
		return $graph;
90
	}
91
	}
Line -... Line 92...
-
 
92
	
-
 
93
	private function existerParametre($numero) {
-
 
94
		$exister = (isset($this->parametres[$numero]) && $this->parametres[$numero] != '*') ? true : false;
-
 
95
		return $exister;
-
 
96
	}
91
	
97
	
92
	private function getNombreDonnees() {
98
	private function getNombreDonnees() {
93
		// Récupération des données
99
		// Récupération des données
94
		$types = array(	array('Commentaires', 'commentaire', 'ccm'),
100
		$types = array(	array('Commentaires', 'commentaire', 'ccm'),
95
						array('Publications', 'publication', 'cpu'),
101
						array('Publications', 'publication', 'cpu'),
Line 109... Line 115...
109
		$etiquettes = implode('|', array_keys($donnees));
115
		$etiquettes = implode('|', array_keys($donnees));
Line 110... Line 116...
110
		
116
		
111
		// Paramètres du graphique
117
		// Paramètres du graphique
112
		$graph = array(
118
		$graph = array(
113
			'cht' => 'bhs',
119
			'cht' => 'bhs',
114
			'chs' => '250x180',
120
			'chs' => '290x210',
115
			'chco' => '4D89F9',
121
			'chco' => '264327|5D7E2D|84A435|B5CD75|DFF1B3',// Source : Broccoli par DandL : http://www.colourlovers.com/palette/1371426/Broccoli
116
			'chd' => "t:$valeurs",
122
			'chd' => "t:$valeurs",
117
			'chds' => '0,'.max($donnees),
123
			'chds' => '0,'.max($donnees),
118
			'chxt' => 'y',
124
			'chxt' => 'y',
119
			'chxl' => "0	:|$etiquettes|",
125
			'chxl' => "0:|$etiquettes|",
120
			'chm' => 'N ** ,000000,0,-1,10',
126
			'chm' => 'N ** ,000000,0,-1,10',
121
			'chtt' => 'Nombre de données');
127
			'chtt' => 'Nombre de données');
122
		return $graph;
128
		return $graph;
Line 141... Line 147...
141
		}
147
		}
142
		return $nbre;
148
		return $nbre;
143
	}
149
	}
Line 144... Line 150...
144
 
150
 
145
	private function getMesDonnees() {
-
 
146
		$personne_id = (isset($this->parametres[0]) ? $this->parametres[0] : null);
151
	private function getMesDonnees() {
147
		// Récupération des données
152
		// Récupération des données
148
		$types = array(	'Commentaires' => '107',
153
		$types = array(	'Commentaires' => array('107', 'ccm'),
149
						'Publications' => '118, 119',
154
						'Publications' => array('118, 119', 'cpu,cpuap'),
150
						'Personnes' => '113, 114',
155
						'Personnes' => array('113, 114', 'cp,cpar'),
151
						'Collections' => '101, 102, 103, 104, 105, 106',
156
						'Collections' => array('101, 102, 103, 104, 106', 'cc,ccac,ccap,ccapu,ccb'),
152
						'Structures' => '120, 121, 122, 123');
157
						'Structures' => array('120, 121, 122, 123', 'cs,csap,csc,csv'));
153
		$etats = array(1 => 'Ajouts',
158
		$etats = array(1 => 'Ajouts',
154
						2 => 'Modifications',
159
						2 => 'Modifications',
155
						3 => 'Suppressions');
160
						3 => 'Suppressions');
156
		$donnees = array();
161
		$donnees = array();
-
 
162
		foreach ($types as $type => $tables_parametres) {
-
 
163
			$tables_infos['identifiants'] = $tables_parametres[0];
157
		foreach ($types as $type => $table_identifiants) {
164
			$tables_infos['abreviations'] = $tables_parametres[1];
158
			foreach ($etats as $etat_id => $etat_type) {
165
			foreach ($etats as $etat_id => $etat_type) {
159
				$donnees[$etat_type][$type] = $this->executerRequeteNombreDansHistorique($table_identifiants, $etat_id, $personne_id);
166
				$donnees[$etat_type][$type] = $this->executerRequeteNombreDansHistorique($tables_infos, $etat_id);
160
			}
167
			}
Line 161... Line 168...
161
		}
168
		}
162
		
169
		
Line 178... Line 185...
178
		$moitier = round(($maximum / 2), 1);
185
		$moitier = round(($maximum / 2), 1);
179
		$valeurs = implode('|', $ensembles_donnees);
186
		$valeurs = implode('|', $ensembles_donnees);
180
		$etiquettes = implode('|', array_keys($types));
187
		$etiquettes = implode('|', array_keys($types));
181
		$legende = implode('|', $etats);
188
		$legende = implode('|', $etats);
182
		$etiquettes_x = "0|$moitier|$maximum";
189
		$etiquettes_x = "0|$moitier|$maximum";
-
 
190
		$titre = $this->existerParametre(0) ? 'Ma participation' : 'Participation';
-
 
191
		$titre .= $this->existerParametre(1) ? ' au projet' : ' tous projets confondus';
183
		
192
		  
184
		// Paramètres du graphique
193
		// Paramètres du graphique
185
		$graph = array(
194
		$graph = array(
186
			'cht' => 'bhs',
195
			'cht' => 'bhg',
187
			'chs' => '320x180',
196
			'chs' => '290x210',
188
			'chbh' => 'a,2,4',
197
			'chbh' => 'a,2,4',
189
			'chco' => '66B032,FABC02,FE2712',
198
			'chco' => '66B032,FABC02,FE2712',
190
			'chdl' => $legende,
199
			'chdl' => $legende,
191
			'chdlp' => 'b',
200
			'chdlp' => 'r',
192
			'chd' => "t:$valeurs",
201
			'chd' => "t:$valeurs",
193
			'chds' => "0,$maximum",
202
			'chds' => "0,$maximum",
194
			'chxt' => 'y,x',
203
			'chxt' => 'y,x',
195
			'chxl' => "0:|$etiquettes|1:|$etiquettes_x",
204
			'chxl' => "0:|$etiquettes|1:|$etiquettes_x",
196
			'chm' => 'N,000000,0,-1,10,1|N,000000,1,-1,10,1|N,000000,2,-1,10,1',
205
			'chm' => 'N,000000,0,-1,10,1|N,000000,1,-1,10,1|N,000000,2,-1,10,1',
197
			'chtt' => 'Ma participation tous projets confondus');
206
			'chtt' => $titre);
Line 198... Line 207...
198
		
207
		
199
		return $graph;
208
		return $graph;
Line 200... Line 209...
200
	}
209
	}
-
 
210
	
-
 
211
	private function executerRequeteNombreDansHistorique($tables_infos, $etat) {
-
 
212
		// Récupération des paramêtres
-
 
213
		$personne_id = (isset($this->parametres[0]) && $this->parametres[0] != '*') ? $this->bdd->quote($this->parametres[0]) : null;
-
 
214
		$projet_id = (isset($this->parametres[1]) && $this->parametres[1] != '*') ? $this->bdd->quote($this->parametres[1]) : null;
-
 
215
		
-
 
216
		// Construction du Xpath si nécessaire
-
 
217
		if (isset($projet_id)) {
-
 
218
			$squelette = '//row[1]/%s_ce_projet';
-
 
219
			$abreviations = explode(',', $tables_infos['abreviations']);
201
	
220
			$xpath = array();
-
 
221
			foreach ($abreviations as $abr) {
-
 
222
				$xpath[] = sprintf($squelette, $abr);
-
 
223
			}
Line -... Line 224...
-
 
224
			$xpath = implode(' | ', $xpath);
202
	private function executerRequeteNombreDansHistorique($table_identifiants, $etat, $personne_id = null) {
225
		}
203
		$personne_id = $this->bdd->quote($personne_id);
226
		
204
		
227
		// Récupération des données
205
		$requete = 	"SELECT COUNT(cmhl_date_modification) AS nbre ".
228
		$requete = 	"SELECT COUNT(cmhl_date_modification) AS nbre ".
206
					"FROM coel_meta_historique_ligne ".
229
					"FROM coel_meta_historique_ligne ".
-
 
230
					"WHERE cmhl_ce_table IN ({$tables_infos['identifiants']}) ".
207
					"WHERE cmhl_ce_table IN ($table_identifiants) ".
231
					"	AND cmhl_ce_etat = $etat ".
208
					"	AND cmhl_ce_etat = $etat ".
232
					(isset($personne_id) ? "	AND cmhl_ce_modifier_par = $personne_id " : '').
209
					(isset($personne_id) ? "	AND cmhl_ce_modifier_par = $personne_id " : '');
233
					(isset($projet_id) ? "	AND ExtractValue(cmhl_enregistrement, '$xpath') = $projet_id " : '');
210
		try {
234
		try {
211
			$nbre = $this->bdd->query($requete)->fetchColumn();
235
			$nbre = $this->bdd->query($requete)->fetchColumn();
Line 253... Line 277...
253
		$etiquettes = implode('|', array_keys($donnees));
277
		$etiquettes = implode('|', array_keys($donnees));
Line 254... Line 278...
254
		
278
		
255
		// Paramètres du graphique
279
		// Paramètres du graphique
256
		$graph = array(
280
		$graph = array(
257
			'cht' => 'bhs',
281
			'cht' => 'bhs',
258
			'chs' => '250x170',
282
			'chs' => '290x210',
259
			'chco' => '4D89F9',
283
			'chco' => '264327|5D7E2D|84A435|B5CD75|DFF1B3',
260
			'chd' => "t:$valeurs",
284
			'chd' => "t:$valeurs",
261
			'chds' => '0,'.(max($donnees)+5),
285
			'chds' => '0,'.(max($donnees)+5),
262
			'chxt' => 'y',
286
			'chxt' => 'y',
263
			'chxl' => "0	:|$etiquettes|",
287
			'chxl' => "0:|$etiquettes|",
264
			'chm' => 'N *,000000,0,-1,10',
288
			'chm' => 'N *,000000,0,-1,10',
265
			'chtt' => 'Type de dépôt|des collections',
289
			'chtt' => 'Type de dépôt|des collections',
Line 266... Line 290...
266
			'chts' => '000000,12');
290
			'chts' => '000000,12');
Line 323... Line 347...
323
		//$legende = implode('|', array_keys($donnees));
347
		//$legende = implode('|', array_keys($donnees));
Line 324... Line 348...
324
		
348
		
325
		// Paramètres du graphique
349
		// Paramètres du graphique
326
		$graph = array(
350
		$graph = array(
327
			'cht' => 'p3',
351
			'cht' => 'p3',
328
			'chs' => '350x200',
352
			'chs' => '400x225',
329
			'chco' => 'EDC951|DEB0DB|DEC9B0|B0DEB3|B0C4DE|B0B0DE|927CBA',
353
			'chco' => 'EDC951|DEB0DB|DEC9B0|B0DEB3|B0C4DE|B0B0DE|927CBA',
330
			'chd' => "t:$valeurs",
354
			'chd' => "t:$valeurs",
331
			'chds' => '0,'.max($donnees),
355
			'chds' => '0,'.max($donnees),
332
			'chdl' => $etiquettes,
356
			'chdl' => $etiquettes,
Line 772... Line 796...
772
			// Post traitement des données de la base de données
796
			// Post traitement des données de la base de données
773
			$donnees = array();
797
			$donnees = array();
774
			foreach ($infos as $info) {
798
			foreach ($infos as $info) {
775
				// Récupération du type d'herbier
799
				// Récupération du type d'herbier
776
				$type_id = ($info['ccb_ce_truk_type'] != '') ? $info['ccb_ce_truk_type'] : 0;
800
				$type_id = ($info['ccb_ce_truk_type'] != '') ? $info['ccb_ce_truk_type'] : 0;
-
 
801
				$type_nom = $types[$type_id]['nom'];
777
 
802
				
778
				// Augmentation du nombre de collection par période 
803
				// Augmentation du nombre de collection par période
779
				if (! isset($donnees[$types[$type_id]['nom']])) {
804
				if (! isset($donnees[$type_nom])) {
780
					$donnees[$types[$type_id]['nom']] = 1;
805
					$donnees[$type_nom] = 1;
781
				} else {
806
				} else {
782
					$donnees[$types[$type_id]['nom']]++;
807
					$donnees[$type_nom]++;
783
				}
808
				}
784
			}
809
			}
Line 785... Line 810...
785
			
810
			
786
			$donnees_tmp = $donnees;
811
			$donnees_tmp = $donnees;
787
			$donnees = array();
812
			$donnees = array();
-
 
813
			foreach ($donnees_tmp as $cle => $valeur) {
-
 
814
				if ($remplacement = preg_replace('/^([^(]+) \([^\)]+\)/', '$1', $cle)) {
-
 
815
					$cle = $remplacement;
-
 
816
				}
-
 
817
				$legende = $cle.' ('.$valeur.')';
788
			foreach ($donnees_tmp as $cle => $valeur) {
818
				
789
				$donnees[$cle.' ('.$valeur.')'] = $valeur;
819
				$donnees[$legende] = $valeur;
Line 790... Line 820...
790
			}
820
			}
791
			
821
			
792
			asort($donnees);
822
			asort($donnees);
Line 793... Line 823...
793
			$valeurs = implode(',', $donnees);
823
			$valeurs = implode(',', $donnees);
794
			$legende = implode('|', array_keys($donnees));
824
			$legende = implode('|', array_keys($donnees));
795
			
825
			
796
			// Paramètres du graphique
826
			// Paramètres du graphique
797
			$graph = array(
827
			$graph = array(
798
				'cht' => 'p3',
828
				'cht' => 'p3',
799
				'chs' => '300x350',
829
				'chs' => '400x225',
800
				'chco' => 'EDC951|DEB0DB|DEC9B0|B0DEB3|B0C4DE|B0B0DE|927CBA',
830
				'chco' => 'EDC951|DEB0DB|DEC9B0|B0DEB3|B0C4DE|B0B0DE|927CBA',
801
				'chd' => "t:$valeurs",
831
				'chd' => "t:$valeurs",
802
				'chds' => '0,'.max($donnees),
832
				'chds' => '0,'.max($donnees),
803
				'chdl' => $legende,
833
				'chdl' => $legende,
804
				'chdlp' => 'bv',
834
				'chdlp' => 'r',
805
				'chtt' => "Nombre d'herbier par type",
835
				'chtt' => "Nombre d'herbier par type",
806
				'chts' => '000000,11.5',
836
				'chts' => '000000,11.5',