Subversion Repositories Applications.referentiel

Rev

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

Rev 349 Rev 350
Line 197... Line 197...
197
	* Si un des paramètres est absent, il prendre la valeur *
197
	* Si un des paramètres est absent, il prendre la valeur *
198
	*/
198
	*/
199
	public function getElementExport($param) {
199
	public function getElementExport($param) {
200
		// Initialisation des variables
200
		// Initialisation des variables
201
		$info = array();
201
		$info = array();
202
		$p = $this->traiterParametresUrl(array("ref","version","champs","filtre"), $param, false);
202
		$p = $this->traiterParametresUrl(array("ref","version","champs","filtre", "encodage"), $param, false);
203
		$ref = $p['ref'].'_v'.$p['version'];
203
		$ref = $p['ref'].'_v'.$p['version'];
204
		$racine_tmp = $this->config['chemins']['chemin_tmp'];
204
		$racine_tmp = $this->config['chemins']['chemin_tmp'];
205
		$dossier = $racine_tmp.date('Y_m_d').'/';
205
		$dossier = $racine_tmp.date('Y_m_d').'/';
206
		if(!is_dir($dossier)){
206
		if(!is_dir($dossier)){
207
			mkdir($dossier);
207
			mkdir($dossier);
Line 209... Line 209...
209
		}
209
		}
210
		$fichier = $dossier.$ref."_".time().'.csv'; 
210
		$fichier = $dossier.$ref."_".time().'.csv'; 
211
		if (isset($p['champs'])) {
211
		if (isset($p['champs'])) {
212
			$champs = $this->formaterColonnes($p['champs'], $ref);		
212
			$champs = $this->formaterColonnes($p['champs'], $ref);		
213
			$requete = 'SELECT "'.implode('","', $champs['titre']).'" UNION (SELECT '.implode(', ',$champs['select']).
213
			$requete = 'SELECT "'.implode('","', $champs['titre']).'" UNION (SELECT '.implode(', ',$champs['select']).
214
				" INTO OUTFILE '".$fichier."' CHARACTER SET utf8 FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\n' ". 
214
				" INTO OUTFILE '".$fichier."' CHARACTER SET ".$p['encodage']." FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\n' ". 
215
			" FROM $ref a left join $ref b on b.num_nom=a.num_nom_retenu";
215
			" FROM $ref a left join $ref b on b.num_nom=a.num_nom_retenu";
Line -... Line 216...
-
 
216
	
216
	
217
	
217
			if (isset($p['filtre']) && $p['filtre'] != "*") {
218
			if (isset($p['filtre']) && $p['filtre'] != "*") {
218
				$param_filtres = explode(",",$p["filtre"]);
219
				$param_filtres = explode(",",$p["filtre"]);
219
				$dernier_filtre = array_pop($param_filtres);
220
				$dernier_filtre = array_pop($param_filtres);
220
				$filtres = array("nnr"=>"a.num_nom = a.num_nom_retenu", "pre" => "a.presence = 'P'");
221
				$filtres = array("nnr"=>"a.num_nom = a.num_nom_retenu", "pre" => "a.presence = 'P'");