 <?php
#=
/****************************************************************************
Copyright 2002-2004, 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/util.inc.php");
include("../include/vars_adm.php");
include("../include/utiljs.php");

opensession("Admin",false);
$nompage=basename($_SERVER['PHP_SELF']);


//récupération des paramètres :
// le resultat_id concerné et la liste des prof_id déjà témoins
// (au 2e passage, prof_id en GET indépendant)

$getp=$_GET['p'];
$tparams=unserialize(base64_decode($getp));
$resultat_id=$tparams[0];
$item_id=$tparams[1];
$disc_id=$tparams[2];
$temoins=$tparams[3]; // tableau de prof_id déjà validateurs

/*
print_r($_GET);
print "<br>";
print "res=$resultat_id - it=$item_id - témoins=";print_r($tparams);print"<br>";
*/

print "Item $item_id";
if (isset($_GET['prof_id'])) {
    //2e passage
    $prof_id=$_GET['prof_id'];
    query("INSERT INTO lrp SET resultat_id=$resultat_id, prof_id=$prof_id"); //date : l'admin choisira
    //js("alert(window.opener.location.href)");
    js_begin();
    js_ins("window.opener.location.reload();");
    //js_ins("window.opener.document.alafin.focus();");
    js_ins("window.close();");
    js_end();
    }
else {  

    ?><!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>Caractéristiques d'un élève</TITLE>
    <link rel="stylesheet" href="<?php echo "../themes/".$etab_theme."/b2i.css" ?>" />
    </HEAD><BODY class="arialadmin">
    <?php
    //Proposer des profs "compatibles" (même étab -pas obligt la même classe-, même disc pour Melia : plus tard], compétents)
    //caca ci-dessous à cause de la marge de la classe CSS sous_titre... et la flemme.
    print "<p style=\"color:Navy;font-size:x-large;font-family:serif;font-style:italic;text-align:center;\" > Liste de validateurs. </p><hr>\n";
    print "<div align='center'><table border='1' cellpadding='2' width='80%'>\n";
    if ($MODULE=='Melia') $whereMelia="AND profs.disc_id=$disc_id";
    else $whereMelia='';
    
    $res=query("SELECT * 
                FROM profs
                INNER JOIN lpi ON lpi.prof_id=profs.prof_id
                WHERE   lpi.item_id=$item_id
                        $whereMelia
                AND     profs.etab_id=$etab_id");
    
    $nbprofs=0;
    while (list($prof_id,$nom,$prenom)=mysql_fetch_array($res)) {
        if (!in_array($prof_id,$temoins)) {
            print "<tr><td width='100%'>";
            print "<a href=\"$nompage?prof_id=$prof_id&p=$getp\">&nbsp; $nom $prenom </a></td>";
            //print "<td width='20%' class='centre'>$prof_id</td>";
            print "</tr>\n";
            $nbprofs++;
            }
        }
    print "</table></div>\n";
    if (!$nbprofs) {
        alert("Pas d'autre prof dans l'établissement\npour apporter une validation");
        close_window();
        }
    }   
?>
</body></html>