Line 206... |
Line 206... |
206 |
if(!is_dir($dossier)){
|
206 |
if(!is_dir($dossier)){
|
207 |
mkdir($dossier);
|
207 |
mkdir($dossier);
|
208 |
chmod($dossier, 0777);
|
208 |
chmod($dossier, 0777);
|
209 |
}
|
209 |
}
|
210 |
$fichier = $dossier.$ref."_".time().'.csv';
|
210 |
$fichier = $dossier.$ref."_".time().'.csv';
|
- |
|
211 |
if (isset($p['champs'])) {
|
211 |
$champs = $this->formaterColonnes($p['champs'], $ref);
|
212 |
$champs = $this->formaterColonnes($p['champs'], $ref);
|
212 |
$requete = 'SELECT "'.implode('","', $champs['titre']).'" UNION (SELECT '.implode(', ',$champs['select']).
|
213 |
$requete = 'SELECT "'.implode('","', $champs['titre']).'" UNION (SELECT '.implode(', ',$champs['select']).
|
213 |
" INTO OUTFILE '".$fichier."' CHARACTER SET utf8 FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\n' ".
|
214 |
" INTO OUTFILE '".$fichier."' CHARACTER SET utf8 FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\n' ".
|
214 |
" 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";
|
215 |
|
216 |
|
216 |
if (isset($p['filtre']) && $p['filtre'] != "*") {
|
217 |
if (isset($p['filtre']) && $p['filtre'] != "*") {
|
217 |
$param_filtres = explode(",",$p["filtre"]);
|
218 |
$param_filtres = explode(",",$p["filtre"]);
|
218 |
$dernier_filtre = array_pop($param_filtres);
|
219 |
$dernier_filtre = array_pop($param_filtres);
|
219 |
$filtres = array("nnr"=>"a.num_nom = a.num_nom_retenu", "pre" => "a.presence = 'P'");
|
220 |
$filtres = array("nnr"=>"a.num_nom = a.num_nom_retenu", "pre" => "a.presence = 'P'");
|
220 |
if (!isset($filtres[$dernier_filtre])) { // si il s'agit du filtre famille
|
221 |
if (!isset($filtres[$dernier_filtre])) { // si il s'agit du filtre famille
|
221 |
$filtres["fam"] = "a.famille = '".$dernier_filtre."'";
|
222 |
$filtres["fam"] = "a.famille = '".$dernier_filtre."'";
|
222 |
$dernier_filtre = "fam";
|
223 |
$dernier_filtre = "fam";
|
- |
|
224 |
}
|
- |
|
225 |
array_push($param_filtres, $dernier_filtre);
|
- |
|
226 |
$requete .= " WHERE ".implode(" AND ",array_intersect_key($filtres, array_flip($param_filtres)));
|
223 |
}
|
227 |
}
|
224 |
array_push($param_filtres, $dernier_filtre);
|
- |
|
225 |
$requete .= " WHERE ".implode(" AND ",array_intersect_key($filtres, array_flip($param_filtres)));
|
- |
|
226 |
}
|
- |
|
227 |
$requete .= ")";
|
228 |
$requete .= ")";
|
228 |
// Récupération des résultats
|
229 |
// Récupération des résultats
|
229 |
try {
|
230 |
try {
|
230 |
$donnees = $this->bdd->query($requete);
|
231 |
$donnees = $this->bdd->query($requete);
|
231 |
if ($donnees === false) {
|
232 |
if ($donnees === false) {
|
232 |
$this->messages[] = "La requête a retourné aucun résultat : $requete";
|
233 |
$this->messages[] = "La requête a retourné aucun résultat : $requete";
|
233 |
} else {
|
234 |
} else {
|
234 |
$info = $donnees;
|
235 |
$info = $donnees;
|
- |
|
236 |
}
|
- |
|
237 |
} catch (PDOException $e) {
|
- |
|
238 |
$this->messages[] = sprintf($this->getTxt('sql_erreur'), $e->getFile(), $e->getLine(), $e->getMessage()).$requete;
|
235 |
}
|
239 |
}
|
236 |
} catch (PDOException $e) {
|
- |
|
237 |
$this->messages[] = sprintf($this->getTxt('sql_erreur'), $e->getFile(), $e->getLine(), $e->getMessage()).$requete;
|
- |
|
238 |
}
|
240 |
}
|
Line 239... |
Line 241... |
239 |
|
241 |
|
240 |
return $fichier;
|
242 |
return $fichier;
|