<?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

****************************************************************************/
include("../include/vars_adm.php");
include("../include/util.inc.php");
include("../include/utiljs.php");

	
opensession("Admin",false);
connecte($host,$user,$mdp,$db);
$sql="SELECT profs.nom, profs.prenom, profs.dnaiss, comptes.login,
       disciplines.libelle, profs.admin , opt_dem1an FROM comptes, profs  LEFT JOIN disciplines
              ON disciplines.disc_id=profs.disc_id
               WHERE profs.compte_id=comptes.compte_id
                 and profs.etab_id=$etab_id
                 and profs.annee=$sess_ascol
                 and profs.tag<=0
               ORDER BY nom, prenom" ;
$envoi="";
$resprofs=query ($sql);
while ($rowprof=mysql_fetch_array($resprofs)) {
	$nom=$rowprof["nom"];
	$prenom=$rowprof["prenom"];
	$dnaiss=$rowprof["dnaiss"];
	$login=$rowprof["login"];
	$disc=$rowprof["libelle"];
	$fadm=$rowprof['admin'];
	$longues=$rowprof['opt_dem1an'];
	
	if (empty($disc)) $disc="??";
	if ($fadm & 1) $adm1="PA"; else $adm1="";
	if ($fadm & 2) $adm2="AA"; else $adm2="";
	if ($fadm & 4) $adm4="GA"; else $adm4="";
	if ($longues) $demlongues="longues"; else $demlongues="";
	$envoi.="$nom;$prenom;$dnaiss;$disc;$login;$adm1;$adm2;$adm4;$demlongues\n";
	}
if (empty($etab_rne)) $prefixe=$etab_id;
else $prefixe=$etab_rne;
$fichier="$db.$prefixe.profs.".date("Ymj").'.csv';
prepare_download($fichier);
print $envoi;

?>