<?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/get.inc.php");
require_once("../include/define.inc.php");
include("../include/attestations.inc.php");
include("../include/insert.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>Valider Fiche d'une classe</title>     
<link rel="stylesheet" href="<?php echo "../themes/".$etab_theme."/b2i.css" ?>">
</head>
<?php
// Ajustage quote ! '
switch ($statut) {
       case "Prof":
           echo "<BODY class='arialprof'>";
           break;
       case "Admin":
           echo "<BODY class='arialadmin'>";
           break;
       case "Gest":
           echo "<BODY class='arialgest'>";
           break;
   }

print "<font size='-1' ><i>Enregistrement</i><br></font>";
$conn  = connecte($host, $user, $mdp, $db);
$aujourdhui = date("d/m/Y");
$cont=0;

while (isset($CBItem[$cont]))
        {
        $num_item=$CBItem[$cont];
        $cont++;
        if ($num_item>0)
        {
         // mise à jour de resultat
         //Discipline validatrice ?
         if (!isset($disc_id)) $disc_id=-1;
         $disc_valid=$disc_id;
         
         if ($MODULE=="Melia") $did=$choixlang; else $did=-1;
         ajout_resultat($eleve_id,$num_item,$did,-1,0); //c'est l'admin, donc message_id=-1 et prof_id=0, donc pas d'enregistrement dans lrt
         
         
         //Virer les demandes et réponses afférentes !
         if ($MODULE=="Melia") $and_disc="and disc_id=$choixlang"; else $and_disc="and disc_id=-1";
         $sqldem="SELECT message_id FROM demandes WHERE eleve_id=$eleve_id  and item_id=$num_item and disc_id=$did";
         $resdem=query($sqldem);
         while ($rowdem=mysql_fetch_array($resdem)) {
             $mess_id=$rowdem["message_id"];
             //on peut virer les réponses éventuelles correspondantes
             $sqlnet="DELETE FROM reponses WHERE message_id=$mess_id";
             query ($sqlnet);
         }
         //Maintenant on vire la ou les demandes sur cet item

         $sqlnet="DELETE FROM demandes WHERE eleve_id=$eleve_id and item_id=$num_item ".$and_disc.";";
         query ($sqlnet);
         }
         }

echo "<i>$cont Item(s) acquis.</i><center>demande traitée";
calcule_brevets($eleve_id);
echo "<form method='post' action='../admin/fiche_classe.php?classe_id=$classe_id&divcod=$divcod&objet=valider&statut=$statut&divgro=$divgro'>
<input type='submit' class='coul' name='retour' value='Retour'>
</form>
</body>";