Location: PHPKode > projects > EmploiNet : a timetable web manager > EmploiNet/v0.8.0/Salle/liste_salles.php
<?  
    
  include("../BarreDeMenu.php3");  
  include("../Session/security.php");  
  include("../date.php3");  
 
  //if (isset($id_promotion[0])) echo $id_promotion[0]; 
 // if (isset($id_groupe)) echo $id_groupe; 
 
  // Entete  
    buildHeader("Liste des salles"); 

    	 	// Ouverture de la connexion  
    	 $connection = openConnection($databaseName);  

    	 //Variables globales
	$une_salle;
	$G_salle_selectionnee;
	$choice;



print ("Promotion :");
print($id_promotion);print("<br>");

print ("Groupe :");
print($id_groupe);print("<br>");

//print ("Matière :");
//print($G_id_matiere);print("<br>");

//print ("Professeur :");
//print ($G_id_professeur);print("<br>");

//print ("Type séance:");
//print ($G_id_type_seance);print("<br>");


//Pour avoir la liste de toutes les salles qui existent

$request1="SELECT id_salle,numero FROM salle";

$result1=mysql_query($request1);

$G_nb_salle = mysql_num_rows($result1);


for ($i = 0;$i < $G_nb_salle;$i++) 
 {
	$une_salle = mysql_fetch_array($result1); 
  				 
   	$G_salle[$i] = $une_salle["numero"]; 

  }


  //Pour avoir la liste des salles du (ou des) type(s) que l'on a sélectionné

$request2 = "SELECT salle.numero,salle.id_salle
	FROM requiert_type_salle,salle
	WHERE requiert_type_salle.id_matiere = '$G_id_matiere'
	AND requiert_type_salle.id_professeur = '$G_id_professeur'
	AND requiert_type_salle.id_type_seance = '$G_id_type_seance'
	AND requiert_type_salle.id_type_salle = salle.id_type_salle";

$result2 = mysql_query($request2);

$G_nb_salles_a_afficher= mysql_num_rows($result2);






for ($l=0;$l<$G_nb_salles_a_afficher;$l++){

	$une_salle_a_afficher = mysql_fetch_array($result2);
 	 
   	$G_salle_a_afficher[$l] = $une_salle_a_afficher["numero"];

	$G_id_salle_a_afficher[$l] = $une_salle_a_afficher["id_salle"];
 }








if (isset($choice) && $choice==1)
{


 	


	$request_delete1="DELETE FROM requiert_salle 
			WHERE id_professeur='$G_id_professeur'
			AND id_matiere='$G_id_matiere'
			AND id_type_seance='$G_id_type_seance'";


	$deselection_salle=mysql_query($request_delete1);


	for($k=0;$k<$G_nb_salles_a_afficher;$k++){
		$var="salle_$k";
		$u=$$var;
		if (isset($$var))
		{
			$request_insert1="INSERT INTO requiert_salle
				VALUES ('$G_id_matiere','$u[0]','$G_id_professeur','$G_id_type_seance')";

			$selection_salle=mysql_query($request_insert1);
		}
	}

}



if (isset($choice) && $choice==2)
{
	

	$request_delete1="DELETE FROM requiert_salle 
			WHERE id_professeur='$G_id_professeur'
			AND id_matiere='$G_id_matiere'
			AND id_type_seance='$G_id_type_seance'";


	$deselection_salle=mysql_query($request_delete1);
}




//Pour avoir la liste des salles que l'on avait déjà selectionnées auparavant

$request3="SELECT id_salle FROM requiert_salle
		WHERE requiert_salle.id_matiere = '$G_id_matiere'
		AND requiert_salle.id_professeur = '$G_id_professeur'
		AND requiert_salle.id_type_seance = '$G_id_type_seance'";
		
$result3=mysql_query($request3);

$G_nb_salle_selectionnees = mysql_num_rows($result3);


for ($j = 0;$j < $G_nb_salle_selectionnees;$j++) 
 {
	$une_salle = mysql_fetch_array($result3); 
  				 
  	$G_id_salle[$j] = $une_salle["id_salle"]; 
 }



print("<form name='form1' action='liste_salles.php' method=post>\n");

	print("      <input type=\"hidden\" name=\"id_session\" value=\"$id_session\">\n");
 
   	print("      <input type=\"hidden\" name=\"choice\" value=\"1\">\n"); 

   	print("      <input type=\"hidden\" name=\"G_id_matiere\" value=\"$G_id_matiere\">\n");

   	print("      <input type=\"hidden\" name=\"G_id_type_salle\" value=\"$G_id_type_salle\">\n");

   	print("      <input type=\"hidden\" name=\"G_id_professeur\" value=\"$G_id_professeur\">\n");

   	print("      <input type=\"hidden\" name=\"G_id_type_seance\" value=\"$G_id_type_seance\">\n");

   	print("      <input type=\"hidden\" name=\"id_promotion\" value=\"$id_promotion\">\n");

   	print("      <input type=\"hidden\" name=\"id_groupe\" value=\"$id_groupe\">\n");

	


for ($i=0 ; $i < $G_nb_salles_a_afficher ; $i++) {

	$found=false;

	

	for($l=0;$l<$G_nb_salle_selectionnees && !$found;$l++){

		 //print ("<br>");
		//print("G_id_salle_a_afficher[i] : ");print ($G_id_salle_a_afficher[$i]); print ("<br>");

		//print("G_id_salle[l] : ");print ($G_id_salle[$l]); print ("<br>");

		$found=($G_id_salle_a_afficher[$i]==$G_id_salle[$l]);
	}	
		

	if ($found) 
	{
		print("<input type='checkbox' checked name='salle_$i' value='$G_id_salle_a_afficher[$i]' onClick=\"javascript:choice.value=1;submit();\"> $G_salle_a_afficher[$i]");

	print ("<br>"); 
						
	}
	else 
	{	

		print("<input type='checkbox' name='salle_$i' value='$G_id_salle_a_afficher[$i]' onClick=\"javascript:choice.value=1;submit();\"> $G_salle_a_afficher[$i]");

	print ("<br>");

	}

}


print ("<br>");print ("<br>");

print("<input type=reset value='Tout effacer' onClick='javascript:choice.value=2;submit();'>");

print("</form>");




print("<form name='form2' action='Planification/reparti_salle.php' method=post>\n");
$id_promotion;
$id_groupe;
$choice;




print("<input type=submit value=\"OK\"> ");


print ("<input type=hidden name=id_session value=$id_session>");

print ("<input type=hidden name=id_promotion value=$id_promotion[0]>");

print ("<input type=hidden name=id_groupe value=$id_groupe>");

print("</form>");
     
    buildEndOfPage();  
?>
Return current item: EmploiNet : a timetable web manager