Subversion Repositories Applications.annuaire

Rev

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

Rev 220 Rev 251
Line 292... Line 292...
292
	}
292
	}
Line 293... Line 293...
293
 
293
 
294
	/** Charge le nombre d'inscrits d'une table annuaire mappée en les groupant par pays
294
	/** Charge le nombre d'inscrits d'une table annuaire mappée en les groupant par pays
295
	 * @param int $identifiant l'identifiant de l'annuaire mappé
295
	 * @param int $identifiant l'identifiant de l'annuaire mappé
296
	 * @param array $id_recherchees un tableau contenant les codes de pays à rechercher
296
	 * @param array $id_recherchees un tableau contenant les codes de pays à rechercher
297
	 * @return array un tableau indexé par les numéros de departement contenant le nombre d'inscrits à chacun
297
	 * @return array un tableau indexé par les numéros de pays contenant le nombre d'inscrits à chacun
298
	 *
298
	 *
299
	 */
299
	 */
300
	public function chargerNombreAnnuaireListeInscritsParPays($id_annuaire, $ids_recherchees) {
300
	public function chargerNombreAnnuaireListeInscritsParPays($id_annuaire, $ids_recherchees) {
301
 
301
		
302
		$requete_informations_annuaire = 	'SELECT aa_bdd, aa_table '.
302
		$requete_informations_annuaire = 	'SELECT aa_bdd, aa_table '.
303
					'FROM  annu_annuaire '.
303
					'FROM  annu_annuaire '.
304
					'WHERE aa_id_annuaire = '.$id_annuaire.' ';
304
					'WHERE aa_id_annuaire = '.$id_annuaire.' ';
Line 309... Line 309...
309
		}
309
		}
Line 310... Line 310...
310
 
310
 
311
		$tableau_mappage = $this->obtenirChampsCartographie($id_annuaire);
311
		$tableau_mappage = $this->obtenirChampsCartographie($id_annuaire);
Line 312... Line 312...
312
		$champ_pays = $tableau_mappage['champ_pays'][0];
312
		$champ_pays = $tableau_mappage['champ_pays'][0];
Line 313... Line 313...
313
 
313
 
Line 314... Line 314...
314
		$ids_recherchees = array_map('strtoupper', $ids_recherchees);
314
		//$ids_recherchees = array_map(array($this,'formaterAbreviationPaysPourRecherche'), $ids_recherchees);
315
 
315
 
Line 341... Line 341...
341
		}
341
		}
Line 342... Line 342...
342
 
342
 
343
		return $resultat_nombre_inscrits;
343
		return $resultat_nombre_inscrits;
Line -... Line 344...
-
 
344
	}
-
 
345
	
-
 
346
	private function formaterAbreviationPaysPourRecherche($chaine) {
-
 
347
		return $this->proteger(strtoupper($chaine));
344
	}
348
	}
345
	
349
	
346
	/**
350
	/**
347
	 * Recherche selon une valeur d'un champ qui peut être une valeur approximative (avec des %) dans un champ d'annuaire donné
351
	 * Recherche selon une valeur d'un champ qui peut être une valeur approximative (avec des %) dans un champ d'annuaire donné
348
	 * @param int $id_annuaire l'identifiant de l'annuaire
352
	 * @param int $id_annuaire l'identifiant de l'annuaire
Line 900... Line 904...
900
		} else {
904
		} else {
901
			return $resultat_selection_utilisateur;
905
			return $resultat_selection_utilisateur;
902
		}
906
		}
903
	}
907
	}
Line -... Line 908...
-
 
908
	
-
 
909
	public function obtenirNombreInscriptionsDansIntervalleDate($id_annuaire, $date_debut, $date_fin) {
-
 
910
		
-
 
911
		$champs_mappage = $this->obtenirChampsMappageAnnuaire($id_annuaire);
-
 
912
 
-
 
913
		$requete_infos_annuaire = 'SELECT * '.
-
 
914
			'FROM annu_annuaire '.
-
 
915
			'WHERE aa_id_annuaire = '.$id_annuaire.' ';
-
 
916
 
-
 
917
		$resultat_infos_annuaire = $this->requeteUn($requete_infos_annuaire);
-
 
918
 
-
 
919
		// en cas d'erreur on renvoie false
-
 
920
		// TODO: lever une exception
-
 
921
		if(!$resultat_infos_annuaire) {
-
 
922
			return false;
-
 
923
		}
-
 
924
 
-
 
925
		//$supprimer_donnes = false;
-
 
926
		$valeurs_mappees = array();
-
 
927
 
-
 
928
		$champs_date = $this->obtenirChampDateEtValidite($id_annuaire);
-
 
929
		
-
 
930
		$date_inscription = $champs_date['champ_date_inscription'];
-
 
931
		
-
 
932
		$requete_nb_inscrits_intervalle = 'SELECT COUNT(*) as nb '.
-
 
933
						'FROM '.$resultat_infos_annuaire['aa_bdd'].'.'.$resultat_infos_annuaire['aa_table'].' '.
-
 
934
						'WHERE '.$date_inscription.' >= "'.date('Y-m-d H:i:s', $date_debut).'" '.
-
 
935
						'AND '.$date_inscription.' < "'.date('Y-m-d H:i:s', $date_fin).'" ';
-
 
936
		
-
 
937
		$resultat_nb_inscrits_intervalle = $this->requeteUn($requete_nb_inscrits_intervalle);
-
 
938
		
-
 
939
		if(!$resultat_nb_inscrits_intervalle) {
-
 
940
			return 0;
-
 
941
		}
-
 
942
 
-
 
943
		return $resultat_nb_inscrits_intervalle['nb'];
-
 
944
		
-
 
945
	}
Line 904... Line 946...
904
	
946
	
905
	
947
	
906
 
948
 
Line 1134... Line 1176...
1134
			$resultat_recherche_inscrits = array();
1176
			$resultat_recherche_inscrits = array();
1135
		}
1177
		}
Line 1136... Line 1178...
1136
 
1178
 
1137
		return array('total' => $nb_inscrits, 'resultat' => $resultat_recherche_inscrits) ;
1179
		return array('total' => $nb_inscrits, 'resultat' => $resultat_recherche_inscrits) ;
-
 
1180
	}
-
 
1181
	
-
 
1182
	public function rechercherDoublonsDansAnnuaireMappe($id_annuaire, $numero_page = 1, $taille_page = 50) {
-
 
1183
 
-
 
1184
		$requete_informations_annuaire = 'SELECT aa_bdd, aa_table '.
-
 
1185
					'FROM  annu_annuaire '.
-
 
1186
					'WHERE aa_id_annuaire = '.$id_annuaire.' ';
-
 
1187
 
-
 
1188
		$resultat_informations_annuaire = $this->requeteUn($requete_informations_annuaire);
-
 
1189
				
-
 
1190
		$champs_mappage = $this->obtenirChampsMappageAnnuaire($id_annuaire);
-
 
1191
 
-
 
1192
		$champ_id = $champs_mappage[0]['champ_id'];
-
 
1193
		$champ_mail = $champs_mappage[0]['champ_mail'];
-
 
1194
		$champ_nom = $champs_mappage[0]['champ_nom'];
-
 
1195
		$champ_prenom = $champs_mappage[0]['champ_prenom'];
-
 
1196
		$champ_ville = $champs_mappage[0]['champ_ville'];
-
 
1197
		 	
-
 
1198
		$requete_recherche_doublon = 'SELECT DISTINCT t2.'.$champ_id.
-
 
1199
									' FROM '.$resultat_informations_annuaire['aa_bdd'].'.'.$resultat_informations_annuaire['aa_table'].' t1 '.
-
 
1200
									'LEFT JOIN '.$resultat_informations_annuaire['aa_bdd'].'.'.$resultat_informations_annuaire['aa_table'].' t2 '.
-
 
1201
									'USING ('.$champ_nom.','.$champ_prenom.','.$champ_ville.') '.
-
 
1202
									'WHERE t1.'.$champ_id.' != t2.'.$champ_id.' '.
-
 
1203
									'ORDER BY '.$champ_nom.', '.$champ_prenom.' ';
-
 
1204
		
-
 
1205
 
-
 
1206
 
-
 
1207
		$requete_nb_doublons = 'SELECT COUNT(DISTINCT t2.'.$champs_mappage[0]['champ_id'].') as nb'.
-
 
1208
									' FROM '.$resultat_informations_annuaire['aa_bdd'].'.'.$resultat_informations_annuaire['aa_table'].' t1 '.
-
 
1209
									'LEFT JOIN '.$resultat_informations_annuaire['aa_bdd'].'.'.$resultat_informations_annuaire['aa_table'].' t2 '.
-
 
1210
									'USING ('.$champ_nom.','.$champ_prenom.','.$champ_ville.') '.
-
 
1211
									'WHERE t1.'.$champ_id.' != t2.'.$champ_id;
-
 
1212
				
-
 
1213
		$resultat_nb_doublons = $this->requeteUn($requete_nb_doublons);
-
 
1214
 
-
 
1215
		$nb_doublons = 0;
-
 
1216
		if($resultat_nb_doublons) {
-
 
1217
			$nb_doublons = $resultat_nb_doublons['nb'];
-
 
1218
		}
-
 
1219
				
-
 
1220
		$resultat_recherche_doublons = $this->requeteTous($requete_recherche_doublon);
-
 
1221
		
-
 
1222
		if(!$resultat_recherche_doublons) {
-
 
1223
			$resultat_recherche_doublons = array();
-
 
1224
		} else {
-
 
1225
			if($taille_page != 0) {
-
 
1226
				$resultat_recherche_doublons = array_slice($resultat_recherche_doublons,($numero_page-1)*$taille_page,$taille_page);
-
 
1227
			}
-
 
1228
		}
-
 
1229
 
-
 
1230
		return array('total' => $nb_doublons, 'resultat' => $resultat_recherche_doublons) ;
Line 1138... Line 1231...
1138
	}
1231
	}
1139
 
1232
 
1140
	/**
1233
	/**
1141
	 * Reinitialise un mot de passe associé à un mail donné et en renvoie un nouveau,
1234
	 * Reinitialise un mot de passe associé à un mail donné et en renvoie un nouveau,