Location: PHPKode > projects > EmploiNet : a timetable web manager > EmploiNet/v0.8.0/edt/ModifRapide/modifie_echange.php3
<?
		// ***************************************************************************************************
	    // ************************ Permutation de cours entre plusieurs promotions **************************
	    // ***************************************************************************************************
			// Variables
	        $x_jour = array("Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi");
			$nom_promo[1]="";
			$nom_promo[2]="";
			$nom_groupe[1]="";
			$nom_groupe[2]="";
	 
	        print("<table align=center border=0 cellspacing=0 cellpading=0 width=700 bgcolor=\"#ffcc33\">\n");
	        print("<tr>\n");
			if(!isset($id_promotion[1]) || $id_promotion[1]==-1)
			{
				print("<td width=233>&nbsp</td>\n");
				print("<td width=233 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 width=233>&nbsp</td>\n");
			}
			else
			{
				print("<td width=233 align=right><a href=\"choix_modif.php3?id_session=$id_session&user_type=$user_type&user_id=$user_id\">Autres modifications</a></td>\n");
				print("<td width=233>&nbsp</td>\n");
				print("<td width=233 align=left><a href=\"javascript:document.form1.etat.value='echange2';document.form1.choice.value=0;document.form1.submit();\">Afficher</a></td>\n");
			}
	        print("</tr>\n");
			print("  </table>\n");	
			print("<table>\n");
			print("<tr>\n");
			print("<td nowrap   ><font size=3><i>Promotion 1 :</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[1]\" width=200 OnChange=\"document.form1.choice.value=-7; document.form1.submit();\">\n");
			if(!isset($id_promotion[1]) || $id_promotion[1]==-1)
				print(" <option value=-1 selected>&nbsp;");
			for ($i=0;$i<$index_max;$i++) 
			{
				$a_record = mysql_fetch_array($result);
				$found = false;
				$j = 0;
				if($id_promotion[1]==$a_record["id_promotion"])
				{
					print(" <option value=".$a_record["id_promotion"]." selected>");
					$nom_promo[1]=$a_record["L1"]." ".$a_record["L2"];
				}
				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[1]\" size=1 width=200 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[1]
						  AND groupe.id_groupe = t0.id_groupe 
						  ORDER BY nom";
/*			$request = "SELECT g.id_groupe,g.nom,g.type 
			            FROM groupe g, associer a, promotion p
						WHERE a.id_groupe=g.id_groupe
						  AND a.id_promotion=p.id_promotion
						  AND p.id_promotion=$id_promotion[1]
	       			    ORDER BY g.nom";*/
			$result = mysql_query($request);
			while ($un_groupe=mysql_fetch_row($result))
			{
				if($un_groupe[0]==$id_groupe[1])
				{
					print(" <option value=".$un_groupe[0]." selected>");
					$nom_groupe[1]=$un_groupe[1]." (".$un_groupe[2].")";
				}
				else
					print(" <option value=".$un_groupe[0]." >");
					print($un_groupe[1]."</option>\n");
			}
			if(!isset($id_groupe[1]) || $id_groupe[1]==-1)
				print(" <option value=-1 selected>");
			else
				print(" <option value=-1 >");
			print("</option>");
			print(" </select>\n");
			print(" </td>\n");
			print(" <td nowrap ><font size=3><i>Semaine :</i></font></td>\n");
			print(" <td>\n");
			print(" <select tabindex=-1 name=\"s_semaine[1]\" size=1 width=200 OnChange=\"document.form1.choice.value = 0; document.form1.submit();\">\n");
			if (isset($id_promotion[1]))
			{
				$request1 = "SELECT numero_semaine_debut
								FROM periode 
								WHERE id_promotion = $id_promotion[1]
								  AND numero=1";
				$result1 = mysql_query($request1);
				$val1=mysql_fetch_array($result1);
				$request2="SELECT sum(nb_semaines) 
							from periode 
							where id_promotion=$id_promotion[1]";
				$result2=mysql_query($request2);
				$val2=mysql_fetch_array($result2);
				$total=$val1[0]+$val2[0];
				if (!isset($s_semaine[1]) || $s_semaine[1]==-1) 
					print("<option value=-1 ></option>");
				for ($i = $val1[0];$i <= $total; $i++)
				{
					$s = ($i>52)?$i-52:$i;
					if ($s_semaine[1] == $s) 
						print("<option value=$s selected>$s");
					else 
						print("<option value=$s>$s");
					print("</option>\n");
				}
			}
			print("</select>\n");
			print("</td>\n");
			print(" <td nowrap ><font size=3><i>Jour :</i></font></td>\n");
			print(" <td>\n");
			print(" <select tabindex=-1 name=\"s_jour[1]\" size=1 width=200 OnChange=\"document.form1.choice.value = 0; document.form1.submit();\">\n");
			if(!isset($s_jour[1]) || $s_jour[1]==-1)
					print("<option value=-1>\n");
			for($i=1;$i<7;$i++)
			{
				if($s_jour[1]==$i)
					print("<option value=$i selected>$x_jour[$i]");
				else 
					print("<option value=$i>$x_jour[$i]");
				print("\n");
			}
			print("</td>\n");
			print("</tr>\n");
			$index=2;			
			while(isset($id_promotion[$index-1]) && $id_promotion[$index-1]!=-1)
			{
				$nb=$index-1;
				print("<tr>");
				mysql_data_seek($result,0);
				print("<td nowrap   ><font size=3><i>Promotion $index :</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[$index]\" width=200 OnChange=\"document.form1.choice.value=-7; document.form1.submit();\">\n");
				for ($i=0;$i<$index_max;$i++) 
				{
					$a_record = mysql_fetch_array($result);
					$found = false;
					$j = 0;
					if($id_promotion[$index]==$a_record["id_promotion"])
					{
						print(" <option value=".$a_record["id_promotion"]." selected>");
						$nom_promo[$index]=$a_record["L1"]." ".$a_record["L2"];
					}
					else
						print(" <option value=".$a_record["id_promotion"].">");
					print($a_record["L1"]." ".$a_record["L2"]);
					print("\n");
				}
				if (isset($id_promotion[$index]) && $id_promotion[$index]!=-1)
					print(" <option value=-1></option>\n");
				else
					print(" <option value=-1 selected></option>\n");
				print(" </select>\n");
				print(" </td>\n");
				if (isset($id_promotion[$index]) && $id_promotion[$index]!=-1)
				{				
					print(" <td nowrap><font size=3><i>Groupe : </i></font></td>\n");
					print(" <td >\n");
					print(" <select tabindex=-1 name=\"id_groupe[$index]\" size=1 width=200 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[$index]
						  AND groupe.id_groupe = t0.id_groupe 
						  ORDER BY nom";
/*				$request = "SELECT g.id_groupe,g.nom,g.type 
					            FROM groupe g, associer a, promotion p
								WHERE a.id_groupe=g.id_groupe
								  AND a.id_promotion=p.id_promotion
								  AND p.id_promotion=$id_promotion[$index]
			       			    ORDER BY g.nom";*/
					$result = mysql_query($request);
					while ($un_groupe=mysql_fetch_array($result))
					{
						if($un_groupe["id_groupe"]==$id_groupe[$index])
						{
							print(" <option value=".$un_groupe["id_groupe"]." selected>");
							$nom_groupe[$index]=$un_groupe["nom"];
						}
						else

							print(" <option value=".$un_groupe["id_groupe"]." >");
						print($un_groupe["nom"]."\n");
					}
					if(!isset($id_groupe[$index]) || $id_groupe[$index]==-1)
						print(" <option value=-1 selected>\n");
					else
						print(" <option value=-1 >\n");
					print("</option>");
					print(" </select>\n");
					print(" </td>\n");
				print(" <td nowrap ><font size=3><i>Semaine :</i></font></td>\n");
				print(" <td>\n");
				print(" <select tabindex=-1 name=\"s_semaine[$index]\" size=1 width=200 OnChange=\"document.form1.choice.value = 0; document.form1.submit();\">\n");
				if (isset($id_promotion[$index]))
				{
					$request1 = "SELECT numero_semaine_debut
									FROM periode 
									WHERE id_promotion = $id_promotion[$index]
									  AND numero=1";
					$result1 = mysql_query($request1);
					$val1=mysql_fetch_array($result1);
					$request2="SELECT sum(nb_semaines) 
								from periode 
								where id_promotion=$id_promotion[$index]";
					$result2=mysql_query($request2);
					$val2=mysql_fetch_array($result2);
					$total=$val1[0]+$val2[0];
					if (!isset($s_semaine[$index]) || $s_semaine[$index]==-1) 
						print("<option value=-1 >");
					for ($i = $val1[0];$i <= $total; $i++)
					{
						$s = ($i>52)?$i-52:$i;
						if ($s_semaine[$index] == $s) 
							print("<option value=$s selected>$s\n");
						else 
							print("<option value=$s>$s\n");
						print("</option>\n");
					}
				}
				print("</select>\n");
				print("</td>\n");
				print(" <td nowrap ><font size=3><i>Jour :</i></font></td>\n");
				print(" <td>\n");
				print(" <select tabindex=-1 name=\"s_jour[$index]\" size=1 width=200 OnChange=\"document.form1.choice.value = 0; document.form1.submit();\">\n");
				if(!isset($s_jour[$index]) || $s_jour[$index]==-1)
						print("<option value=-1>&nbsp;");
				for($i=1;$i<7;$i++)
				{
					if($s_jour[$index]==$i)
						print("<option value=$i selected>$x_jour[$i]");
					else 
						print("<option value=$i>$x_jour[$i]");
					print("\n");
				}
				if(isset($id_promotion[$index]))
					print("<option value=-1>\n");
				print("</td>\n");
				}			
				print("</tr>\n");	
				$index++;
			}	
			print("</table>\n");	
			if (isset($id_promotion[1]) && isset($s_semaine[1]) && $s_semaine[1]!=-1)
			{
				print("<p align=center><b><i>Choisissez les cours que vous voulez déplacer...</i></b>\n");
			    print("<p><table width=700 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&eacute;lection</td>\n");
				print("<td bgcolor=#C0C0C0><b>Mati&egrave;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&eacute;but</td>\n");
		        print("<td bgcolor=#C0C0C0><b>Heure fin</td>\n");
		        print("<td bgcolor=#C0C0C0><b>Jour</td>\n");
				print("</tr>\n");
				print("<script language=\"JavaScript\">\n");
				print(" document.form1.tableau1.value=''\n;");
				print("</script>\n\n");
				$nb_cours=0;
				for($i=1;$i<=$nb;$i++)
				{	  
					if ($id_groupe[$i]!=-1)
					{
						$request = "SELECT distinct(p.id_planifie)
									FROM planifie p,planifiegroupe pg
									WHERE p.semaine=$s_semaine[$i] 
									  AND pg.id_groupe = $id_groupe[$i] AND pg.id_planifie = p.id_planifie
									 UNION
									 SELECT distinct(p.id_planifie)
									FROM planifie p, planifiepromotion pp
									WHERE p.semaine=$s_semaine[$i] AND
									 pp.id_promotion = $id_promotion[$i] AND pp.id_planifie = p.id_planifie";
					}

					else
					{
						$request = "SELECT distinct(p.id_planifie)
	   								FROM planifie p,planifiepromotion pp
									WHERE p.semaine=$s_semaine[$i] 
									  AND pp.id_promotion = $id_promotion[$i]
									  AND pp.id_planifie = p.id_planifie";
					}
				if($s_jour[$i]!=-1)					
				$request=$request." AND p.jour_semaine=$s_jour[$i]";
				$result = mysql_query($request);
					$nb_cours=$nb_cours+mysql_num_rows($result);
				}
				$i=0;
				while(isset($id_promotion[$i+1]) && $id_promotion[$i+1]!=-1)
				{	 
					$i++;
					if ($id_groupe[$i]!=-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[$i] 
								  AND (pg.id_groupe = $id_groupe[$i] 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[$i]
								  AND pp.id_promotion=$id_promotion[$i]
								  AND pp.id_planifie=p.id_planifie 
								  AND p.id_matiere=m.id_matiere";
				}
									
					if($s_jour[$i]!=-1)
						$request=$request." AND p.jour_semaine=$s_jour[$i]";
					$request=$request." ORDER BY p.jour_semaine";
					$result = mysql_query($request);
					$nb_result=mysql_num_rows($result);
					print("<tr><td colspan=9 align=center bgcolor=#CAD4EC>\n");
					print("<b>$nom_promo[$i]</b>\n");
					if(isset($id_groupe[$i]) && $id_groupe[$i]!=-1)
						print("<b>  ---  $nom_groupe[$i]</b>\n");
					print("</td></tr>\n");
					if($nb_result>0)
					{
						// Affichage de tous les 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");
						}
					}
					else
					{
						print("<tr align=center><td colspan=9 ><b><i>Aucun cours</i></b></td></tr>\n");
					}
				}			
				print("</table>\n");
			}
	        print("</form>\n");
?>
Return current item: EmploiNet : a timetable web manager