<?php
#=
/****************************************************************************
Copyright 2002, Daniel Deycard, Jacques Messines, Stéphanie Roussel, Jean-Marie Treins
(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/pdf.inc.php");
include("../include/get.inc.php");
include("../include/attestations.inc.php");
$statut=$_REQUEST['statut'];
opensession($statut,false);

print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
?>
<html>

<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Attestations</title>
<meta name="generator" content="amaya">
<link rel="stylesheet" href="<?php echo "../themes/".$etab_theme."/b2i.css" ?>">
<base target="_self">
<?php include("../include/utiljs.php"); ?>
</head>

<?php


print "<body class='arialgest'>";
if (!isset($divcod)) {

 print "<p class='sous_titre'>Edition des feuilles de position </p><hr>";
 print "<br><p class='avis'>Pour une classe chargée, la création du fichier peut être assez longue ; veuillez patienter...</p>";
 print "</body>\n";
 print "</html>\n";
 exit;
}
if ($divgro=='D') $midtit="de la classe "; else $midtit="du groupe ";
print "<p class='sous_titre'>Edition des feuilles de position ".$midtit." : $divcod</p><hr>";


//Préparer fichier
//Crée un fichier PDF qui affichera le PDF
//Préparation page en PDF
creertousrep("$DATA/$etab_rne/diplomes/");
$fich_pdf="$DATA/$etab_rne/diplomes/etats_eleves.php";
cree_pdf($fich_pdf);


//DEBUG
set_time_limit(0);
$w1=getmicrotime();


//Préparer la liste des élèves
$resdiv=query("SELECT eleves.eleve_id, nom, prenom FROM eleves, lien_eleves_classes
               WHERE eleves.annee='$sess_ascol'
               AND eleves.eleve_id=lien_eleves_classes.eleve_id
               AND lien_eleves_classes.classe_id=$classe_id
               ORDER BY nom, prenom");
if (mysql_num_rows($resdiv)==0) print "Pas d'élève !";
else {
 //Affichage lien PDF
 print "<center><table width='40%' border='0'><tr><td width='85%'class='paire centre encadre_loin'>
       Pour accéder au fichier PDF créé...</td><td class='centre paire encadre_loin'>
       <a href='$fich_pdf' target=_blank >
       <img src=\"../themes/".$etab_theme."/pdf.gif\" border='0'  alt='pdf'></a></td></tr></table></center>";

     print "<center><table border='1'><tr>";
     while (list($elid, $enom, $eprenom)=mysql_fetch_array($resdiv)) {
         $identite="$enom $eprenom";
         print "<td>&nbsp;$enom</td><td class='indente'>&nbsp;$eprenom </td></tr><tr>";

         //On y va pour le pdf !
         etats_eleves_pdf($fich_pdf, $elid, $classe_id,$fpos);
         }
     print "</table></center>";
     //Fin fichier pdf
     ferme_pdf($fich_pdf);


}

//DEBUG
$w2=getmicrotime();
$dureebig=$w2-$w1;
//print "<br><br>Calcul en : ".$dureebig." secondes !";


?>


</body>

</html>