<?php
/****************************************************************************
Copyright 2002, Daniel Deycard, Jacques Messines, Alain Pomirol
(CATICE Académie de Bordeaux)

This file is part of GiBii/Melia.

GiBii/Melia is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

GiBii/Melia is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GiBii/Melia; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

****************************************************************************/

//on a reçu les paramètres suivants par GET (exemple) :
//statut=Admin&classe_id=1&divcod=Classe_Test

include("../include/vars_adm.php");
include("../include/util.inc.php");
$statut=$_REQUEST['statut'];
opensession($statut,false);
connecte($host,$user,$mdp,$db);

if (empty($etab_rne)) $prefixe=$etab_id;
else $prefixe=$etab_rne;
$fichier="$db.$prefixe.$divcod.".date("Ymj").'.csv';
prepare_download($fichier);
$sql="SELECT eleves.nom, eleves.prenom, eleves.dnaiss, eleves.eleve_id, comptes.login
        FROM eleves, comptes,lien_eleves_classes
       WHERE eleves.eleve_id=comptes.eleve_id
         and eleves.eleve_id=lien_eleves_classes.eleve_id
         and lien_eleves_classes.classe_id=$classe_id
         and eleves.annee='$sess_ascol'
       ORDER BY nom, prenom;" ;
$resclasse=query($sql);
$nbelev=0;
$envoi='';
while ($rowclasse=mysql_fetch_array($resclasse)) {
	$nbelev++;
	$ligne=stripslashes($rowclasse["nom"]).';';
	$ligne.=stripslashes($rowclasse["prenom"]).';';
	$ligne.=$rowclasse["dnaiss"].';';
	$ligne.=stripslashes($rowclasse["login"]);
	$envoi.=$ligne."\n";
	}
print $envoi; //download
?>