<?
include("fonctions_edt.php3");
include("../BarreDeMenu.php3");
include("../date.php3");
include("../Session/security.php");
// Entete
buildHeader("Emploi du temps étudiant",true);
// Verification de la session
$autorisation_list[0]=0; // Administrateur
$autorisation_list[1]=2; // Etudiant
$autorisation_list[2]=3; // Gestionnaire
$user_type = validateSession($id_session);
if ($user_type == -1 || !security($id_session,$autorisation_list)) print("Accès refusé");
else
{
// Barre de menu
buildMenuBar($id_session,$user_type,"index.php3",false);
// Ouverture de la connexion avec la base de donnees
$connection = openConnection($databaseName);
// *************** DECLARATION DES CONSTANTES **************
$first_time = "08:00:00";
$last_time = "20:00:00";
$first_time2 = 8;
$last_time2 = 20;
$jour_de_la_semaine = array("Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi","Dimanche");
// Determination du id_user a l'aide du id_session
$user_id = getUserID($id_session);
$connection = openConnection("emploi_du_temps");
// *************** VERIFICATION DES DONNEES ***************
$request = "SELECT etudiant.nom, etudiant.prenom, promotion.libelle, diplome.libelle FROM etudiant, promotion, inscrit, diplome WHERE etudiant.id_etudiant = $user_id AND inscrit.id_etudiant = etudiant.id_etudiant AND inscrit.id_promotion = promotion.id_promotion AND promotion.id_diplome = diplome.id_diplome";
$result = mysql_query($request,$connection);
// *************** AUCUN ETUDIANT NE CORRESPOND AUX CRITERES DU FORMULAIRE ***************
if (mysql_num_rows($result) == 0)
print("<H3>Aucun étudiant ne correspond à ces critères</H3>\n");
// *************** L'ETUDIANT EXISTE ***************
else
{
$un_etudiant = mysql_fetch_row($result);
// Bouton pour acceder a l'emploi du temps de la semaine suivante et precedente + Titre
print("<FORM name=form1 ACTION=\"EmploiEtudiant.php3\">\n");
print(" <input type=\"hidden\" name=\"login\" value=\"$login\">\n");
print(" <input type=\"hidden\" name=\"id_session\" value=\"$id_session\">\n");
print(" <input type=\"hidden\" name=\"user_type\" value=\"$user_type\">\n");
print(" <input type=\"hidden\" name=\"user_id\" value=\"$user_id\">\n");
print(" <input type=\"hidden\" name=\"display\" value=\"$display\">\n");
print(" <input type=\"hidden\" name=\"ma_semaine\">\n");
print(" <table border=0 cellspacing=1 cellpading=0 align=center>\n");
print(" <tr valign=middle align=center>\n");
print(" <td width=40><input type=\"image\" border=0 src=\"../img/PreviousButton.gif\" alt=\"Précédent\" OnClick=\"ma_semaine.value=".($ma_semaine==1?52:$ma_semaine-1)."; submit();\"></td>\n");
print(" <td valign=\"middle\"><H3>$un_etudiant[3] $un_etudiant[2] - Semaine $ma_semaine</H3></td>\n");
print(" <td width=40><input type=\"image\" border=0 src=\"../img/NextButton.gif\" alt=\"Suivant\" OnClick=\"ma_semaine.value=".($ma_semaine==52?1:$ma_semaine+1)."; submit();\"></td>\n");
print(" </tr>\n");
print(" </table>\n");
print("</FORM>\n");
// *************** ASSOCIATION D'UNE COULEUR A CHAQUE MATIERE ***************
$request = mysql_query("SELECT * FROM appartient");
if (mysql_num_rows($request) > 0) {
$request = "SELECT DISTINCT(matiere.id_matiere)
FROM matiere,inscrit,suiviparpromotion
WHERE
(inscrit.id_etudiant = $user_id
AND suiviparpromotion.id_promotion = inscrit.id_promotion
AND matiere.id_matiere = suiviparpromotion.id_matiere)
UNION
SELECT DISTINCT(matiere.id_matiere)
FROM matiere,appartient,suivipargroupe
WHERE (appartient.id_etudiant = $user_id
AND suivipargroupe.id_groupe = appartient.id_groupe
AND matiere.id_matiere = suivipargroupe.id_matiere)
ORDER BY matiere";
}
else
$request = "SELECT DISTINCT(matiere.id_matiere)
FROM matiere,inscrit,suiviparpromotion
WHERE
(inscrit.id_etudiant = $user_id
AND suiviparpromotion.id_promotion = inscrit.id_promotion
AND matiere.id_matiere = suiviparpromotion.id_matiere)";
$result = mysql_query($request);
$color = array("00","66","99","FF");
$color_number = count($color);
$red=0;$blue=0;$green=0;
while ($une_matiere = mysql_fetch_row($result) )
{
$couleur_matiere[$une_matiere[0]] = $color[$red].$color[$green].$color[$blue];
if ($blue < $color_number - 1) $blue++;
else {
if ($green < $color_number - 1 ) {
$green++;
$blue = 0;
}
else {
if ($red < $color_number - 1) {
$red++;
$blue = 0;
$green = 0;
}
}
}
}
// *************** INFORMATION SUR LA DATE ***************
$sem_actu = weekToDay($ma_semaine,$connection);
// *************** DEBUT DE L'EMPLOI DU TEMPS ***************
print("<TABLE ALIGN=\"center\" CELLSPACING=\"0\" class=\"emploi\">\n");
// *************** INSERTION DE LA BARRE DES HEURES DU DEBUT ***************
barre_des_heures($first_time2,$last_time2,7.0);
barre_du_bas($first_time2,$last_time2,5.0);
// *************** PARCOURS DES DIFFERENTS JOURS DE LA SEMAINE ***************
for ($index = 0;$index < 6;$index++)
{
// *************** INSERTION DE LA BARRE DES HEURES INTERMEDIAIRE ***************
if ($index == 2 || $index == 4)
{
barre_du_haut($first_time2,$last_time2,5.0);
barre_des_heures($first_time2,$last_time2,7.0);
barre_du_bas($first_time2,$last_time2,5.0);
}
// *************** MISE A JOUR DE LA FIN DU COURS PRECEDENT ***************
$fin_cours_precedent = $first_time;
// *************** INSERTION DES INFORMATIONS DANS LA PREMIERE CELLULE ***************
$premier = mysql_query("SELECT FROM_DAYS($sem_actu)",$connection);
$result_prem = mysql_fetch_row($premier);
$essai = transformation_date($sem_actu);
print("<TR ALIGN=\"CENTER\" class=\"emploi\"");
print("<TD COLSPAN=\"2\" class=\"joursemaine\">\n");
print("$jour_de_la_semaine[$index] $essai");
print("</TD>\n");
// *************** REQUETE SUR LA BASE ***************
/* Ne marche pas. F. Nolot
Si une matière est défini pour tous les groupes et que pour un groupe particulier, rien n'est encore programmé,
alors dans l'affichage de l'emploi du temps,
aucune matière ne s'affiche. Solution : requete UNION
Le champs id_type_seance semble toujours être différent de -1*/
/* $request = "SELECT distinct(p.id_planifie), p.jour_semaine, p.heure_debut, p.heure_fin, p.id_matiere, m.nom, t.type, p.id_professeur, p.id_salle
FROM planifie p, planifiepromotion pp, inscrit i, planifiegroupe pg, appartient a, matiere m, typeseance t
WHERE
p.jour_semaine = ".($index+1)." AND p.semaine = $ma_semaine
AND
((i.id_etudiant = $user_id AND pp.id_promotion = i.id_promotion AND p.id_planifie = pp.id_planifie)
OR
(a.id_etudiant = $user_id AND pg.id_groupe = a.id_groupe AND p.id_planifie = pg.id_planifie ))
AND m.id_matiere = p.id_matiere
AND (t.id_type_seance = p.id_type_seance OR p.id_type_seance = -1)
ORDER BY p.heure_debut"; */
$request = "SELECT distinct(p.id_planifie), p.jour_semaine, p.heure_debut, p.heure_fin, p.id_matiere, m.nom, t.type, p.id_professeur, p.id_salle
FROM planifie p, planifiepromotion pp, inscrit i, matiere m, typeseance t
WHERE
p.jour_semaine = ".($index+1)." AND p.semaine = $ma_semaine
AND
i.id_etudiant = $user_id AND pp.id_promotion = i.id_promotion AND p.id_planifie = pp.id_planifie
AND m.id_matiere = p.id_matiere
AND t.id_type_seance = p.id_type_seance
UNION
SELECT distinct(p.id_planifie), p.jour_semaine, p.heure_debut, p.heure_fin, p.id_matiere, m.nom, t.type, p.id_professeur, p.id_salle
FROM planifie p, planifiegroupe pg, inscrit i, appartient a, matiere m, typeseance t
WHERE
p.jour_semaine = ".($index+1)." AND p.semaine = $ma_semaine
AND a.id_etudiant = $user_id AND pg.id_groupe = a.id_groupe AND p.id_planifie = pg.id_planifie
AND m.id_matiere = p.id_matiere
AND t.id_type_seance = p.id_type_seance
ORDER BY p.heure_debut
";
$result = mysql_query($request);
// Nombre de cours programmes dans la journee
$nb = mysql_num_rows($result);
// Y a-t-il des cours de programmer dans la journee ?
if ($nb == 0)
{
$found = false;
$requete_jours_feries = mysql_query("SELECT * FROM vacances");
// *************** ON PARCOURT LA LISTE DES JOURS FERIES ***************
while($un_jour = mysql_fetch_row($requete_jours_feries))
{
$req_jour_debut=mysql_query("SELECT to_days(\"$un_jour[1]\")");
$req_jour_fin=mysql_query("SELECT to_days(\"$un_jour[2]\")");
$trans1=mysql_fetch_row($req_jour_debut);
$trans2=mysql_fetch_row($req_jour_fin);
if($sem_actu>=$trans1[0] && $sem_actu<=$trans2[0])
{
print("<TD COLSPAN=\"48\" class=\"edtvacances\">VACANCES</TD>");
$found = true;
break;
}
}
// *************** CE N'EST PAS UN JOUR FERIE ***************
if ($found) print("<TD ALIGN=\"CENTER\" COLSPAN=\"48\"></td>");
}
// *************** IL Y A AU MOINS UN COURS ***************
else
{
$fin_cours_precedent = $first_time;
// *************** PARCOURS DE LA LISTE DES COURS ***************
while ($un_cours = mysql_fetch_row($result))
{
// *************** HEURE ET MINUTE DU DEBUT DU PROCHAIN COURS ***************
$h = explode(":",$un_cours[2]);
$debut_cours_heure = $h[0];
$debut_cours_minute = $h[1];
// *************** HEURE ET MINUTE DE LA FIN DU PROCHAIN COURS ***************
$h = explode(":",$un_cours[3]);
$fin_cours_heure=$h[0];
$fin_cours_minute=$h[1];
// *************** HEURE ET MINUTE DE LA FIN DU COURS PRECEDENT ***************
$h = explode(":",$fin_cours_precedent);
$fin_cours_precedent_heure = $h[0];
$fin_cours_precedent_minute = $h[1];
// *************** MISE A JOUR DE LA FIN DU COURS PRECEDENT ***************
$fin_cours_precedent = $un_cours[3];
// *************** LE PROCHAIN COURS NE COINCIDE PAS AVEC LA FIN DU PRECEDENT ***************
if ($debut_cours_heure != $fin_cours_precedent_heure || $debut_cours_minute != $fin_cours_precedent_minute)
{
$intervalle_heure = $debut_cours_heure - $fin_cours_precedent_heure;
$intervalle_minute = $debut_cours_minute - $fin_cours_precedent_minute;
$taille_cellule_vide = $intervalle_heure*4 + $intervalle_minute / 15;
print("<TD COLSPAN=\"$taille_cellule_vide\"> </TD>\n");
}
// *************** DETERMINATION DE LA TAILLE DE LA CELLULE DU COURS ***************
$taille_cellule = ($fin_cours_heure-$debut_cours_heure)*4+($fin_cours_minute-$debut_cours_minute)/60*4;
// *************** DETERMINATION DE LA COULEUR DE LA MATIERE ***************
$color = $couleur_matiere[$un_cours[4]];
// *************** INSCRIPTION DES INFORMATIONS DU COURS DANS LA CELLULE ***************
if ($un_cours[6] == "Examen") print("<TD COLSPAN=\"$taille_cellule\" class=\"examen\">");
else
{
print("<TD COLSPAN=\"$taille_cellule\" class=\"matiere\" style=\"border-color: #$color;\">");
}
print("$un_cours[5] - $un_cours[6]");
// Un professeur est associe a ce cours
if ($un_cours[7] != -1)
{
$request = "SELECT initiales FROM professeur WHERE id_professeur = ".$un_cours[7];
$result_professeur = mysql_query($request,$connection);
$un_prof = mysql_fetch_row($result_professeur);
print("<BR>$un_prof[0]");
}
// Une salle est associee a ce cours
if ($un_cours[8] != -1)
{
$request = "SELECT numero FROM salle WHERE id_salle = ".$un_cours[8];
$result_salle = mysql_query($request,$connection);
$une_salle = mysql_fetch_row($result_salle);
print("<BR>$une_salle[0]");
}
print("</TD>\n");
}
}
// *************** ON PASSE AU JOUR SUIVANT ***************
$sem_actu++;
print("</TR>\n");
}
// *************** INSERTION DE LA BARRE DES HEURES DE LA FIN ***************
barre_du_haut($first_time2,$last_time2,5.0);
barre_des_heures($first_time2,$last_time2,7.0);
}
print("</TABLE>\n");
}
buildEndOfPage();
?>