<?php
/* Classe : Identite
 * Permet de recupérer les informations identitaires des utilisateurs de la plateforme
 */
 include_once('Basededonnees.php');

 class Identite{
 	private $bdd;

 	public function __construct($DB_DATABASE){
 		$database = new Basededonnees($DB_DATABASE);
 		$this->bdd = $database->getBdd();
 	}
   public function getEtudiant($matricule,$idEtablissement){

     $query="SELECT * FROM tabetudiant AS etu
            INNER JOIN tabinscription AS tinscrp ON etu.matricule= tinscrp.matricule
            INNER JOIN academique AS acad ON acad.annee_acad = tinscrp.annee_acad
            INNER JOIN filieres AS f ON f.idFiliere = tinscrp.idFiliere
            INNER JOIN niveauformation AS niveau ON niveau.id= tinscrp.niveauFormation
				    INNER JOIN anneeetude AS a ON a.id= tinscrp.annee
            WHERE etu.matricule=? AND acad.idEtablissement=? AND acad.affiche=?";
     $requete=$this->bdd->prepare($query);
     $requete->execute(array($matricule,$idEtablissement,'YES'));

     $retour= array();
     if($donnees= $requete->fetch()){
       $retour['nom']= $donnees['nom'];
       $retour['prenom']= $donnees['prenom'];
       $retour['cheminPhoto']= 'https://progiciel.geststudent.net/Inscription/'.$donnees['cheminPhoto'];
       $retour['mail']= $donnees['email'];
       $retour['idFiliere']= $donnees['idFiliere'];
       $retour['groupe_academique']= $donnees['annee_etude'].' '.$donnees['niveauFormation'].' '.$donnees['sigleFilieres'];
     }
     return $retour;
  }
}
