<?PHP
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------------+
// | <G a n e s h a> - Free Web Based Training System                           |
// +----------------------------------------------------------------------------+
// | <G a n e s h a> - Plate-forme de téléformation gratuite et en open source  |
// +----------------------------------------------------------------------------|
// | Copyright (C) 2001-2003  Anéma Formation  <http://www.anema.fr/>           |
// +----------------------------------------------------------------------------+
// |           Developer : Georges CALDEIRA <gcaldeira@anemalab.org>            |
// +----------------------------------------------------------------------------+
// |              Infos on project <http://anemalab.org/>                       |
// +----------------------------------------------------------------------------+
// | This program 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.                                        |
// |                                                                            |
// | This program 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 this program; if not, write to the Free Software                |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   |
// +----------------------------------------------------------------------------+

/**
* Page resultat du tracking
*
* @author	Georges Caldeira <gcaldeira@anemalab.org>
* @package	GaneshaCommun
*/
	/**
	* include des fichiers + verification de la cnx
	*/

	include_once("anema.inc.php");

	$profil_stagiaire= $HTTP_GET_VARS['stagiaire']	;
	$userid			 = $HTTP_GET_VARS['userid']		;
	$groupe			 = $HTTP_GET_VARS['groupe']		;
	
	$ClsColor->Read($userid) ;

	// Init des variables globales
	$current_titremodule = ""	;
	$current_titrechapitre = ""	;
	$current_nb_tracking = 0	;
	$totaltemps = 0				;
	$totalnote = 0				;

	/**
	* Affiche un bouton de fermeture
	* @access	private
	*/
	function CloseMyWindow() { 
	 global $profil_stagiaire ;
	 global $st_texte ;
		//if ( isset($profil_stagiaire) && $profil_stagiaire!="" ) {
		//	BackWindow();
		//} else {
		
			CloseWindow();
		//}
	}

	/**
	* function main()
	* Affichage de la page des resultats
	*/
	InitPageHtml( ".:: Détails du Tracking ::.",false)	;

	$nbtracking = $ClsTracking->Nb($userid,$groupe)		;
	$text = $ClsMembre->GetPrenom($userid).' '.$ClsMembre->GetNom($userid).' ('.$nbtracking.')' ;
	$print = '<A href="javascript:self.print()"><IMG border=0 hspace="2" src="'.HTTP_IMAGES.'printer.gif"  alt="Imprimer"></A>';
	Title($print.' '.$st_texte['result'].CSS($text));	

	$ret = $ClsTracking->readTrackingUser($userid,$groupe) ;

	if ( is_array($ret) ) {
		$lmodule = array_keys ($ret)	;
		$cnt_lmodule = count($lmodule)	;
		// traitement des modules
		for($i=0;$i<$cnt_lmodule;$i++) {
			$line = 0 ;
			Title($ClsModule->Title($lmodule[$i]));
			$lchapitre = array_keys ($ret[$lmodule[$i]]);
			$cnt_lchapitre = count($lchapitre)			;
			// traitement des chapitres
			for($j=0;$j<$cnt_lchapitre;$j++) {
				$titrechapitre = $ClsChapitre->Title($lmodule[$i],$lchapitre[$j]);
				BeginTableTracking($titrechapitre);
				$ldate = array_keys ($ret[$lmodule[$i]][$lchapitre[$j]]);
				$cnt_ldate = count($ldate)			;
				//traitement des dates et des resultats
				$data = array();
				for($k=0;$k<$cnt_ldate;$k++) {
					$line++ ;
					$date	= $ldate[$k]; 
					$temps	= $ret[$lmodule[$i]][$lchapitre[$j]][$ldate[$k]]['temps']; 
					$note	= $ret[$lmodule[$i]][$lchapitre[$j]][$ldate[$k]]['note'];
					$status	= $ret[$lmodule[$i]][$lchapitre[$j]][$ldate[$k]]['status'];
					ItemTableTracking($line,$date,$titrechapitre,$note,$temps,$status) ;
					//$chapitreLu = (($note==100 && $temps==100)?true:false);
					$data[] = $note ;
				}
				$stat = stats($data) ;
				//$stat = ( $chapitreLu == true ? $stat['count']:$stat);
				CloseTableTracking($stat);
				BR();
			}
		}
	}

	CloseMyWindow()	;
	footer()		;
	ClosePageHtml()	;
?>