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 ".$p['encodage']." 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' ".
|
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 216... |
Line 216... |
216 |
|
216 |
|
217 |
|
217 |
|
218 |
if (isset($p['filtre']) && $p['filtre'] != "*") {
|
218 |
if (isset($p['filtre']) && $p['filtre'] != "*") {
|
219 |
$param_filtres = explode(",",$p["filtre"]);
|
219 |
$param_filtres = explode(",",$p["filtre"]);
|
220 |
$dernier_filtre = array_pop($param_filtres);
|
220 |
$dernier_filtre = array_pop($param_filtres);
|
221 |
$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'");
|
222 |
"snsc" => "a.num_nom_retenu != ''", "qnsc" => "a.num_nom_retenu = ''");
|
222 |
if ($dernier_filtre != '' && $dernier_filtre != '*') {
|
223 |
if ($dernier_filtre != '' && !isset($filtres[$dernier_filtre])) { // si il s'agit du filtre famille
|
223 |
if (!isset($filtres[$dernier_filtre])) {// si il s'agit du filtre famille
|
- |
|
224 |
$filtres["fam"] = "a.famille = '".$dernier_filtre."'";
|
- |
|
225 |
$dernier_filtre = "fam";
|
224 |
$filtres["fam"] = "a.famille = '".$dernier_filtre."'";
|
226 |
}
|
225 |
$dernier_filtre = "fam";
|
- |
|
- |
|
227 |
array_push($param_filtres, $dernier_filtre);
|
226 |
}
|
228 |
}
|
227 |
array_push($param_filtres, $dernier_filtre);
|
229 |
|
228 |
$requete .= " WHERE ".implode(" AND ",array_intersect_key($filtres, array_flip($param_filtres)));
|
230 |
$requete .= " WHERE ".implode(" AND ",array_intersect_key($filtres, array_flip($param_filtres)));
|
229 |
}
|
231 |
}
|
230 |
$requete .= ")";
|
232 |
$requete .= ")";
|
Line 238... |
Line 240... |
238 |
}
|
240 |
}
|
239 |
} catch (PDOException $e) {
|
241 |
} catch (PDOException $e) {
|
240 |
$this->messages[] = sprintf($this->getTxt('sql_erreur'), $e->getFile(), $e->getLine(), $e->getMessage()).$requete;
|
242 |
$this->messages[] = sprintf($this->getTxt('sql_erreur'), $e->getFile(), $e->getLine(), $e->getMessage()).$requete;
|
241 |
}
|
243 |
}
|
242 |
}
|
244 |
}
|
- |
|
245 |
|
Line 243... |
Line 246... |
243 |
|
246 |
|
244 |
return $fichier;
|
247 |
return $fichier;
|
Line -... |
Line 248... |
- |
|
248 |
}
|
245 |
}
|
249 |
|
246 |
|
250 |
|
247 |
private function formaterColonnes($colonnes, $ref) {
|
251 |
private function formaterColonnes($colonnes, $ref) {
|
248 |
$colonnesOrdonnees = array("nn" => array("a.num_nom", "num_nom", "Numéro nomenclatural"),
|
252 |
$colonnesOrdonnees = array("nn" => array("a.num_nom", "num_nom", "Numéro nomenclatural"),
|
249 |
"nr" => array("a.num_nom_retenu", "num_nom_retenu", "Numéro nomenclatural du nom retenu"),
|
253 |
"nr" => array("a.num_nom_retenu", "num_nom_retenu", "Numéro nomenclatural du nom retenu"),
|
Line 278... |
Line 282... |
278 |
"stcult" => array("a.statut_culture", "statut_culture", "Statut de culture"),
|
282 |
"stcult" => array("a.statut_culture", "statut_culture", "Statut de culture"),
|
279 |
"notes" => array("a.notes", "notes", "Remarques"),
|
283 |
"notes" => array("a.notes", "notes", "Remarques"),
|
280 |
"nomadd" => array("a.nom_addendum", "nom_addendum", "Commentaires nomenclaturaux"),
|
284 |
"nomadd" => array("a.nom_addendum", "nom_addendum", "Commentaires nomenclaturaux"),
|
281 |
"nsr" => array("b.nom_sci as nom_sci_retenu", "nom_sci", "Nom retenu sans auteur"),
|
285 |
"nsr" => array("b.nom_sci as nom_sci_retenu", "nom_sci", "Nom retenu sans auteur"),
|
282 |
"hom" => array("a.homonyme", "homonyme", "Homonymie"),
|
286 |
"hom" => array("a.homonyme", "homonyme", "Homonymie"),
|
- |
|
287 |
"syn" => array("CASE a.num_nom_retenu WHEN a.num_nom THEN 'retenu'
|
- |
|
288 |
WHEN '' THEN 'ambigu'
|
- |
|
289 |
ELSE 'synonyme' END AS synonymie", "num_nom_retenu", "Statut du nom" ),
|
283 |
"synprop" => array("a.synonyme_proparte", "synonyme_proparte", "Synonyme proprate"),
|
290 |
"synprop" => array("a.synonyme_proparte", "synonyme_proparte", "Synonyme proprate"),
|
284 |
"syndout" => array("a.synonyme_douteux", "synonyme_douteux", "Synonyme douteux"),
|
291 |
"syndout" => array("a.synonyme_douteux", "synonyme_douteux", "Synonyme douteux"),
|
285 |
"synmapp" => array("a.synonyme_mal_applique", "synonyme_mal_applique", "Synonyme mal appliqué"),
|
292 |
"synmapp" => array("a.synonyme_mal_applique", "synonyme_mal_applique", "Synonyme mal appliqué"),
|
286 |
"synorth" => array("a.synonyme_orthographique", "synonyme_orthographique", "Synonyme orthographique"),
|
293 |
"synorth" => array("a.synonyme_orthographique", "synonyme_orthographique", "Synonyme orthographique"),
|
287 |
"orthori" => array("a.orthographe_originelle", "orthographe_originelle", "Orthographe originelle"),
|
294 |
"orthori" => array("a.orthographe_originelle", "orthographe_originelle", "Orthographe originelle"),
|