<?php
#G
/****************************************************************************
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");
opensession("Gest",true);


//Cas d'un accès depuis Sadmin '
if ($sess_statut=="Sadmin") {
	$etab_id=$_GET['etab_id'];
	$etabli=getetab($etab_id);
	$etab_nom=$etabli['nom'];
	$etab_adresse=$etabli['adresse'];
	$etab_codepostal=$etabli['codepostal'];
	$etab_ville=$etabli['ville'];
	$etab_niveau=getniveau($etab_id);
	$chemin_theme="../include/general.css";
	$etab_nb_validations=$etabli['nbval'];
	}
else $chemin_theme="../themes/".$etab_theme."/b2i.css";


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>Effectifs par item</title>
<link rel="stylesheet" href="<?php echo $chemin_theme; ?>">
<base target="_self">
</head>
<body class="arialgest" >
<?php
if ($MODULE=="GiSCCo") $tabniv=array(1=>'Ecole',2=>'Collège',3=>'Lycée & CFA');
else $tabniv=array(1=>' 1',2=>' 2',3=>' 3');

//Affichage établissement et nb élèves ?
//En-tête pour impression
$nbprfs=getnbprofs($etab_id);
if ($etab_nb_validations>1) $s='s'; else $s='';
$stitre="$nbprfs professeurs inscrits&nbsp;&nbsp;--&nbsp;&nbsp;$etab_nb_validations&nbsp;validation$s par item";
Print "<p class='libelle_admin'>".$etab_nom."&nbsp;&nbsp;&nbsp;&nbsp;".
                 $etab_adresse."&nbsp;&nbsp;&nbsp;&nbsp;".$etab_codepostal.
                 "&nbsp;&nbsp;".$etab_ville."&nbsp;&nbsp;".date("d/m/Y");
print "<p class='titre_petit'>$stitre</p>";

  $values=array();
  $absc=array();
  $absc2=array();
  $num=array();
  $titre=" Répartition des validations par professeur ";	

  //Recherche valeurs
  $resresult=query("SELECT profs.nom, profs.prenom,disciplines.libelle,  count(profs.prof_id) as nbprofs 
  		FROM profs, disciplines, reponses, demandes, resultats
		WHERE profs.etab_id=$etab_id
		AND profs.annee='".$sess_ascol."'
		AND  profs.prof_id=reponses.prof_id
		AND profs.disc_id=disciplines.disc_id
		AND reponses.message_id=demandes.message_id
		AND demandes.eleve_id=resultats.eleve_id
		AND demandes.item_id=resultats.item_id
		AND demandes.disc_id=resultats.disc_id
		GROUP BY profs.prof_id ORDER BY nbprofs DESC");
  $compter=0;
  while (list($nprof,$pprof,$diprof, $nb)=mysql_fetch_array($resresult)) {
  	$pprof=substr($pprof,0,1);
	$pr=$nprof." ".$pprof.". (".$diprof.")";
	$absc[]=$pr;
	$values[]=$nb;
	$compter++;
	$absc2[]=substr($nprof." ".$pprof,0,8)."..";
	//$num[]=$compter;
	}
  mysql_free_result($resresult);
  $index=implode(',',$absc);
  $nombre=implode(',',$values);
  $index2=implode(',',$absc2);
  //$ordre=implode(',',$num);
  
  //print "<br>".$index;
  //print "<br>".$nombre;
	
  //echo "<a href='../outils/graph_camembert_profs.php?titre=".urlencode($titre)."&index=".urlencode($index)."&nombre=".$nombre."'>graphique</a>";
  echo "<p class='sous_titre'><img src='../outils/graph_camembert_profs.php?titre=".urlencode($titre)."&index=".urlencode($index)."&nombre=".$nombre."'></p>";
  echo "<br><br><p class='titre_petit'>$titre (en nombre de validations)<p/>\n";
  //echo "<p class='centre attention'>En abscisse le numéro de chaque professeur indiqué dans la légende ci-dessus </p>";
  echo "<p class='sous_titre'><img src='../outils/graph_courbe.php?titre=".urlencode($titre)."&index=".urlencode($index2)."&nombre=".$nombre."'></p>";


?>
</html>

