<?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/get.inc.php");
require_once("../include/define.inc.php");
include("../include/attestations.inc.php");
set_time_limit(600);
$statut=$_REQUEST['statut'];
opensession($statut,false);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<TITLE>nom1</TITLE>
<BASE TARGET="_self">
<link rel="stylesheet" href="<?php echo "../themes/".$etab_theme."/b2i.css" ?>">
</HEAD>
<body class="arialadmin" link="white" vlink="white" alink="white">


<p class="sous_titre" align="center">Calcul et stockage des résultats des 3 niveaux</p><hr>
<p align="left">
</p>
<p class='attention centre '>Veuillez patienter pendant le travail :</p>
<?php
print str_repeat("&nbsp;",200);
flush();

//Connexion à la base
$conn  = mysql_connect($host, $user, $mdp);
mysql_select_db($db, $conn) or die ("Impossible d'accéder à $db");;


if ($MODULE=='GiCii')  $bornesup=3; 
else $bornesup=4;

$nbitems=array();   // (une dimension : par niveau)
for ($i=1;$i<$bornesup;$i++) $nbitems[$i]=get_nbitems($i);

//Recherche par classe
$rescla=query("SELECT eleves.eleve_id, eleves.nom, eleves.prenom, classes.divcod FROM eleves,classes 
			WHERE eleves.classe_id=classes.classe_id
			AND eleves.annee='".ascol(). 
			"' AND eleves.etab_id=$etab_id 
			AND divgro='D' ORDER BY divcod");

//Comptage !
$nbbrev=array(1=>0,2=>0,3=>0);
print "<br />Classes traitées :&nbsp;&nbsp;&nbsp;";  //Pour remettre le curseur à gauche !

//mémoire de la classe
$classold="";
while (list($eid, $en, $epr, $divcod)=mysql_fetch_array($rescla)) {
  if ($divcod!=$classold) {
	print $divcod."... ";
	$classold=$divcod;
	flush();
    }
  $ret_brev=calcule_brevets($eid,false);
  for ($k=1;$k<4;$k++) $nbbrev[$k]+=$ret_brev[$k];
}

//Affichage résultats
print "<br /><br /><br />";
print "<center><br /><p class='avis_transparent'>Travail terminé, voici le nombre actuel de brevets délivrables :";
print "<table>";
for ($i=1;$i<4;$i++) print "<tr><td>".getlibellenivo($i)." : </td><td>".$nbbrev[$i]."</td></tr>";
print "</table></p>";

print "<form action='resultats.php'><input type=hidden name='statut' value='".$statut."'><BUTTON type=submit>Retour</BUTTON></form>";

print "</center>";


?>

</BODY>
</HTML>