<?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/get.inc.php");
include("../include/util.inc.php");

$statut=$_REQUEST['statut'];
opensession($statut,false);
connecte($host,$user,$mdp,$db);
$PHP_SELF=basename($_SERVER['PHP_SELF']);

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>Fiche de validation sans demande pour un élève</title>
<link rel="stylesheet" href="<?php echo "../themes/".$etab_theme."/b2i.css" ?>">
</head>

<?php


switch ($statut) {
       case "Prof":
           echo "<BODY class='arialprof'>";
           break;
       case "Admin":
           echo "<BODY class='arialadmin'>";
           break;
       case "Gest":
           echo "<BODY class='arialgest'>";
           break;
   }





$conn  = connecte($host,$user,$mdp,$db);
$sql="SELECT eleves.nom, eleves.prenom, eleves.dnaiss".
             " FROM  eleves ".
             " WHERE eleves.eleve_id=$eleve_id".
             " ORDER BY nom, prenom" ;
$resclasse=query ($sql);
list($nom,$prenom,$dnaiss)=mysql_fetch_array($resclasse);





//Nom de l'élève en haut de page
print "<p class='nom_prenom'>".$nom." ".$prenom." (".$divcod.")</p>";
print "<p class='attention'>Les items validés ici sont définitivement acquis..</p>";

//Cas Melia !
if ($MODULE=='Melia') {
echo "<form name='formlv' method='POST' action='saisie_admin.php'>";
print "<input type='hidden' name='eleve_id' value='".$eleve_id."'>";
print "<input type='hidden' name='classe_id' value='".$classe_id."'>";
print "<input type='hidden' name='divcod' value='".$divcod."'>";
print "<input type='hidden' name='statut' value='".$statut."'>";
print "<input type='hidden' name='divgro' value='".$divgro."'>";

$discip=getlvchoix($eleve_id);
//Attention aux élèves qui n'ont pas de langue définie !
if (empty($discip)) {
        print "<p class='attention'>Pas de langue définie pour cet élève !</p>";
        exit;
        }


print "<p class='sous_titre'>";
foreach($discip as $lvelev) {
        if (!isset($choixlang)) {
                if (isset($discip[1])) $choixlang=$discip[1];
                elseif (isset($discip[2])) $choixlang=$discip[2];
                else $choixlang=$discip[3];
                }
        if ($choixlang==$lvelev) $check="checked";
        else $check="";
        print "<input type='radio' name='choixlang' value=$lvelev $check onclick='document.formlv.submit();'>&nbsp;".
                $sess_tabcodelang[$lvelev]."&nbsp;&nbsp;";
                }
print "</p>";
print "</form>";

} // Fin cas Melia
else $choixlang=-1;

 switch ($etab_niveau) {
    case "niv1": $condition=" brevet_no=1 ";break;
    case "niv2": $condition=" brevet_no=2 "; break;
    case "niv3": $condition=" brevet_no=3 "; break;
    case "niv12"  : $condition=" (brevet_no=1 || brevet_no=2) "; break;
    case "niv23"  : $condition=" (brevet_no=2 || brevet_no=3) "; break;
    default: $condition="";$condition1="";$condition2="";
}
if ($condition) {
    $condition1="  and ".$condition;
    $condition2 =" where ".$condition;
    }

//obtenir les rubriques du brevet $brevet_no
$resrub=query("select rubriques.*, count(*) as nbitems ".  //nb d'items/rubrique
              "from rubriques,items ".
              "where rubriques.rub_no=items.rub_no ".
              $condition1.
              "group by rubriques.rub_no ".
              "order by rubriques.rub_no;");

//obtenir les items du brevet $brevet_no
$resit =query("select * from items ".
              $condition2.
              "order by rub_no, s_rub_no;");

$reslib=query("select base from libelles,items ".
              "WHERE items.item_id=libelles.item_id ".
              $condition1.
              "order by rub_no, s_rub_no;");

//afficher la liste des items

//Début du formulaire
echo '<form method="POST" action="valider_admin.php">';
print "<input type='hidden' name='choixlang' value='".$choixlang."'>";
print "<input type='hidden' name='eleve_id' value='".$eleve_id."'>";
print "<input type='hidden' name='classe_id' value='".$classe_id."'>";
print "<input type='hidden' name='divcod' value='".$divcod."'>";
print "<input type='hidden' name='statut' value='".$statut."'>";
print "<input type='hidden' name='divgro' value='".$divgro."'>";

$limite=10;
$idximg=0;  //numéros des champs IMG
$tagniv=0;
$cpt=1;
 print "<table border = '0' width='100%'><tr><td class='niveau".$cpt."'></BR> ";
while ($rowrub=mysql_fetch_array($resrub))
{
    $nbitems=$rowrub["nbitems"];
    $num_rub=$rowrub["rub_no"];
    $nivrub=getnivo($num_rub);

    if (($tagniv!=0) and ($nivrub!=$tagniv)) {print"</td></tr></table></BR>";
                                             $cpt++;
                                              print"<table border = '0' width='100%'><tr><td class='niveau".$cpt."'></BR> ";
                                             }
    $tagniv=$nivrub;

    print "<p class='rubrique'>".$rowrub["libelle"];
    if ($MODULE!="Melia") print " (".getlibellenivo(getnivo($num_rub)).")</p>";
    //if ($MODULE=="GiCii") print " (niveau : ".getnivo($num_rub).")</p>";
    print "<center><table  border='0' width='98%'>\n";
    for ($it=0 ; $it<$nbitems ; $it++)
        {
         $rowit=mysql_fetch_array($resit);
         $item_id=$rowit["item_id"];

         //couleur de la ligne suivant sa parité
         $cl=($it%2==0) ? "paire" : "impaire";
         print "<tr class='$cl'>\n";

         //colonne 1 : l'état ou l'action possible sur l'item
         if ($MODULE=='Melia') $di=$choixlang;
         else $di=-1;
         print "<td align='center' valign='middle' width='91' height='28'>\n";
         $nomtagimg="img".$idximg;
         if (itemacquis($eleve_id,$item_id,$di))  {
             $nombasefic="acquis.gif";
             $typeres="a";
             $ancre="  <img name='$nomtagimg' src='../themes/".$etab_theme."/boutons/n$nombasefic' width='89' height='24' border='0' alt='Item obtenu'>\n";
             print "$ancre\n";
                         }
                     else print "<input type='checkbox' name='CBItem[]' value=$item_id>\n";


         print "\n\t</td>\n";
         $idximg++;

         //colonne 2 : le texte de l'item
         $rowlib=mysql_fetch_array($reslib);
         print "\n\t<td><p class=item>\n";
         print "[".$item_id."] ".$rowlib["base"];
         print "\n\t</p></td></tr>\n";
         }
    print "</table></center>\n";

}
    print "</td></tr></table>";
echo ' <div align="center">
<input type="submit" class="coul" value="Valider" name="B1">
</div>
</form>';

?>

</body>
</html>