<?
// ***************************************************************************************************
// ***************************** Permutation de promotion pour un cours ******************************
// ***************************************************************************************************
$n = count($id_promotion);
$x_jour = array("Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi");
print("<table align=center border=0 cellspacing=0 cellpading=0 width=700 bgcolor=\"#ffcc33\">\n");
print("<tr>\n");
// Liste des promotions
print(" <td valign=top width=100 nowrap rowspan=2><font size=3><i>Promotion :</i></font></td>\n");
print(" <td width=250 rowspan=2 valign=top>\n");
include("../../Liste/liste_promotion.php");
print(" </td>\n");
// Liste des groupes associes a la promotion selectionnee
print(" <td valign=top width=100 nowrap><font size=3><i>Groupe :</i></font></td>\n");
print(" <td valign=top width=250>\n");
include("../../Liste/liste_groupe.php");
print(" </td>\n");
print(" </tr>\n");
// Periode
print(" <tr>\n");
print(" <td valign=top width=100 nowrap><font size=3><i>Période :</i></font></td>\n");
print(" <td valign=top width=250>\n");
include("../../Liste/liste_periode.php");
print(" </td>\n");
print(" </tr>\n");
// Semaine
print(" <tr>\n");
print(" <td colspan=2 align=center>\n");
include("../../Liste/liste_semaine.php");
print(" </td>\n");
print(" <td><font size=3><i>Jour :</i></font></td>\n");
print("<td><select tabindex=-1 name=\"s_jour\" OnChange=\"document.form1.choice.value = 0; document.form1.submit();\">\n");
print("<option value=-1> </option>");
for($i=1;$i<7;$i++)
{
if($s_jour==$i)
print("<option value=$i selected>$x_jour[$i]");
else
print("<option value=$i>$x_jour[$i]");
print("</option>\n");
}
print("</select></td>\n");
print("</tr>\n");
print(" <tr>\n");
if(isset($id_promotion[0]) && isset($s_semaine) && isset($id_periode))
{
print("<td colspan=\"2\" align=center><a href=\"choix_modif.php3?id_session=$id_session&user_type=$user_type&user_id=$user_id\">Autres modifications</a></td>\n");
print("<td colspan=\"2\" align=center><a href=\"javascript:document.form1.choice.value=6;document.form1.submit();\">Mise à jour</a></td>\n");
}
else
{
print("<td colspan=\"4\" align=center><a href=\"choix_modif.php3?id_session=$id_session&user_type=$user_type&user_id=$user_id\">Autres modifications</a></td>\n");
}
print(" </tr>");
print("</table><br>\n");
// Si la promotion et la semaine ont été sélectionnées
if(isset($id_promotion) && isset($s_semaine) && $id_promotion!=-1 && $s_semaine!=-1)
{
// Variables
$x_jour = array("Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi");
$NombreDeNiveau=0;
if ($id_groupe!=-1) // Un groupe est sélectionné
{
$request = "SELECT distinct(p.id_planifie), m.nom as nom_matiere, p.id_type_seance, p.id_professeur, p.id_salle, p.heure_debut, p.heure_fin, p.jour_semaine
FROM planifie p,matiere m,planifiegroupe pg
WHERE p.semaine=$s_semaine
AND (pg.id_groupe = $id_groupe AND pg.id_planifie = p.id_planifie)
AND p.id_matiere=m.id_matiere";
}
else // Aucun groupe n'est sélectionné
{
$request = "SELECT distinct(p.id_planifie), m.nom as nom_matiere, p.id_type_seance, p.id_professeur, p.id_salle, p.heure_debut, p.heure_fin, p.jour_semaine
FROM planifie p,matiere m,planifiepromotion pp
WHERE p.semaine=$s_semaine
AND pp.id_promotion=$id_promotion[0]
AND pp.id_planifie=p.id_planifie
AND p.id_matiere=m.id_matiere";
}
if($s_jour!=-1)
$request=$request." AND p.jour_semaine=".$s_jour;
$request=$request." ORDER BY p.jour_semaine";
$result = mysql_query($request);
$nb=mysql_num_rows($result);
print("<script language=\"JavaScript\">\n");
print("document.form1.tableau1.value=''\n;");
print("</script>\n\n");
// Il y a un cours de prévu dans cette semaine (et ce jour)
if($nb>0)
{
// Tableau
print("<p><table width=620 border=1 CELLSPACING=0 align=center bordercolor=black >\n");
print("<tr align=center>\n");
print("<td bgcolor=#C0C0C0><b>-</td>\n");
print("<td bgcolor=#C0C0C0><b>Sélection</td>\n");
print("<td bgcolor=#C0C0C0><b>Matière</td>\n");
print("<td bgcolor=#C0C0C0><b>Type</td>\n");
print("<td bgcolor=#C0C0C0><b>Professeur</td>\n");
print("<td bgcolor=#C0C0C0><b>Salle</td>\n");
print("<td bgcolor=#C0C0C0><b>Heure début</td>\n");
print("<td bgcolor=#C0C0C0><b>Heure fin</td>\n");
print("<td bgcolor=#C0C0C0><b>Jour</td>\n");
print("</tr>\n");
// Affichage du tableau de cours
while ($un_cours=mysql_fetch_array($result))
{
$NombreDeNiveau ++;
$request_type="SELECT t.type FROM typeseance t WHERE t.id_type_seance=".$un_cours[2];
$result_type=mysql_query($request_type);
$un_type=mysql_fetch_row($result_type);
$nb_type=mysql_num_rows($result_type);
$request_professeur="SELECT p.nom FROM professeur p WHERE p.id_professeur=".$un_cours["id_professeur"];
$result_professeur=mysql_query($request_professeur);
$un_prof=mysql_fetch_row($result_professeur);
$nb_prof=mysql_num_rows($result_professeur);
$request_salle="SELECT s.numero FROM salle s WHERE s.id_salle=".$un_cours["id_salle"];
$result_salle=mysql_query($request_salle);
$une_salle=mysql_fetch_row($result_salle);
$nb_salle=mysql_num_rows($result_salle);
print("<script language=\"JavaScript\">\n");
print(" document.form1.tableau1.value='0'+document.form1.tableau1.value\n;");
print("</script>\n\n");
print("<tr align=center>\n");
print("<td bgcolor=#C0C0C0> $NombreDeNiveau </td>\n");
print("<td> <a href=\"javascript:changerImage('ImageSelection$NombreDeNiveau');modifierChaineMult($NombreDeNiveau-1,$nb);\" ><IMG SRC=\"img/ellipse.gif\" NAME=\"ImageSelection$NombreDeNiveau\" border=0 border=no></a> </td>\n");
print("<input type=\"hidden\" name=\"ValId[$NombreDeNiveau]\" value=\"$un_cours[0]\">\n");
print("<td>".$un_cours["nom_matiere"]."</td>\n");
print("<input type=\"hidden\" name=\"NomMat[$NombreDeNiveau]\" value=".$un_cours["nom_matiere"].">\n");
if ($nb_type==0)
{
print("<td>/</td>\n");
print("<input type=\"hidden\" name=\"type[$NombreDeNiveau]\" value=-1>\n");
}
else
{
print("<td>".$un_type[0]."</td>\n");
print("<input type=\"hidden\" name=\"type[$NombreDeNiveau]\" value=".$un_cours[2].">\n");
}
if ($nb_prof==0)
{
print("<td>/</td>\n");
print("<input type=\"hidden\" name=\"prof[$NombreDeNiveau]\" value=-1>\n");
}
else
{
print("<td>".$un_prof[0]."</td>\n");
print("<input type=\"hidden\" name=\"prof[$NombreDeNiveau]\" value=".$un_cours["id_professeur"].">\n");
}
if ($nb_salle==0)
print("<td>/</td>\n");
else
print("<td>".$une_salle[0]."</td>\n");
print("<td>".$un_cours["heure_debut"]."</td>\n");
print("<input type=\"hidden\" name=\"heure_deb[$NombreDeNiveau]\" value=".$un_cours["heure_debut"].">\n");
print("<td>".$un_cours["heure_fin"]."</td>\n");
print("<input type=\"hidden\" name=\"heure_fin[$NombreDeNiveau]\" value=".$un_cours["heure_fin"].">\n");
print("<td>".$x_jour[$un_cours["jour_semaine"]]."</td>\n");
print("<input type=\"hidden\" name=\"jour[$NombreDeNiveau]\" value=".$un_cours["jour_semaine"].">\n");
print("</tr>\n");
}
print("</table>\n");
print("<p align=center><b><i>Choisissez le(s) cours à modifier... puis indiquez la promotion (et le groupe) de remplacement</i></b>\n");
print("<p><table align=center>\n");
print("<tr>\n");
print("<td nowrap ><font size=3><i>Promotion :</i></font></td>\n");
print("<td >\n");
$result = mysql_query("SELECT id_promotion,diplome.libelle as L1,promotion.libelle as L2 FROM promotion,diplome WHERE promotion.id_diplome=diplome.id_diplome ORDER BY diplome.libelle");
$index_max = mysql_num_rows($result);
print(" <select name=\"id_promotion_sub\" OnChange=\"document.form1.choice.value=0; document.form1.submit();\">\n");
if(!isset($id_promotion_sub) || $id_promotion_sub==-1)
print(" <option value=-1 selected> </option>");
for ($i=0;$i<$index_max;$i++)
{
$a_record = mysql_fetch_array($result);
$found = false;
$j = 0;
if($id_promotion_sub==$a_record["id_promotion"])
print(" <option value=".$a_record["id_promotion"]." selected>");
else
print(" <option value=".$a_record["id_promotion"].">");
print($a_record["L1"]." ".$a_record["L2"]);
print("</option>\n");
}
print(" </select>\n");
print(" </td>\n");
print(" <td nowrap><font size=3><i>Groupe :</i></font></td>\n");
print(" <td >\n");
print(" <select tabindex=-1 name=\"id_groupe_sub\" OnChange=\"document.form1.choice.value = 0; document.form1.submit();\">\n");
$request = "SELECT groupe.id_groupe,groupe.nom,groupe.id_type_groupe
FROM groupe,associer as t0
WHERE t0.id_promotion = $id_promotion_sub
AND groupe.id_groupe = t0.id_groupe
ORDER BY nom";
$result = mysql_query($request);
while ($un_groupe=mysql_fetch_row($result))
{
if($un_groupe[0]==$id_groupe_sub)
print(" <option value=".$un_groupe[0]." selected>");
else
print(" <option value=".$un_groupe[0]." >");
if ( $un_groupe[2] == -1 )
print($un_groupe[1]." (Tous)");
else {
$typegroupe=mysql_query("SELECT typegroupe.libelle FROM typegroupe
WHERE typegroupe.id_type_groupe = $un_groupe[2]");
$typegroupelibelle = mysql_fetch_row($typegroupe);
print($un_groupe[1]." (".$typegroupelibelle[0].")");
}
print("</option>\n");
}
if(!isset($id_groupe_sub) || $id_groupe_sub==-1)
print(" <option value=-1 selected>");
else
print(" <option value=-1 >");
print("</option>\n");
print(" </select>\n");
print(" </td>\n");
print("</tr>\n");
print("</table>\n");
}
// Pas de cours de prévu
else
print("<h2 align=center><b>Aucun cours n'est prévu pour cette semaine</b></h2>\n");
}
print("</form>\n");
?>