Location: PHPKode > projects > EmploiNet : a timetable web manager > EmploiNet/v0.8.0/Liste/liste_materiel.php
<?  
    
  include("../BarreDeMenu.php3");  
    
  include("../Session/security.php");  
  include("../date.php3");  

	// Entete  
	buildHeader("Liste du matériel"); 
	// Barre de menu  
  	  buildMenuBar($id_session,$user_type,"liste_materiel.php",false);  
    	 // Ouverture de la connexion  
    	 $connection = openConnection($databaseName);  
print ("<br>");
print ("<br>");
print ("Cochez le matériel que vous désirez réserver pour ce crénaux :");
print ("<br>");
//print ("id_planifie = ");print ($id_planifie);
print ("<br>");
print ("<br>");
$request1="SELECT distinct nom,id_materiel FROM materiel";
$result1=mysql_query($request1);
$nb_materiel = mysql_num_rows($result1);
for ($i = 0;$i < $nb_materiel;$i++) 
{
	$un_materiel = mysql_fetch_array($result1); 
  	$id_materiel[$i] = $un_materiel["id_materiel"];
  	$G_materiel[$i]= $un_materiel["nom"];
 }
$choice;
if (isset($choice) && $choice==5)
{

	
	for ($i=0;$i<$nb_materiel;$i++) 
 	{
		
		$request_delete1="DELETE FROM requiert_materiel WHERE id_planifie='$id_planifie'";

		$deselection_salle=mysql_query($request_delete1);
	}




	for ($i=0;$i<$nb_materiel;$i++) 
 	{
		$var="materiel_$i";
		$u=$$var;
		if (isset($$var))
		{
			$insert1="INSERT INTO requiert_materiel VALUES ('$u[0]','$id_planifie')";
			$insertion1=mysql_query($insert1);
		}
	}

}


//REQUETE POUR RECUPERER LES INFOS SUR LE CRENAU Où ON A CLIQUE

$request3="SELECT heure_debut,heure_fin,semaine, jour_semaine FROM planifie 
		WHERE id_planifie='$id_planifie'";

$result3=mysql_query($request3);

$une_info = mysql_fetch_array($result3); 
  				 
$une_heure_debut = $une_info["heure_debut"];

$une_heure_fin = $une_info["heure_fin"];

$une_semaine = $une_info["semaine"];

$un_jour_semaine = $une_info["jour_semaine"];



//REQUETE POUR RECEPURER LES ID_PLANIFIE DES COURS QUI SE DEROULENT AU MEME MOMENT QUE LE NOTRE
$k=0;
//cours qui commencent avt le debut et terminent avant le fin
$request4="SELECT id_planifie FROM planifie p 
		WHERE p.heure_debut<='$une_heure_debut'
		AND p.heure_fin<='$une_heure_fin'
		AND p.heure_fin>'$une_heure_debut'
		AND p.semaine='$une_semaine'
		AND p.jour_semaine='$un_jour_semaine'
		AND p.id_planifie <> '$id_planifie' ";

$result4=mysql_query($request4);

$nb_id_planifie1 = mysql_num_rows($result4);

for ($i = 0;$i < $nb_id_planifie1 ;$i++) 
 {
	$id_planifie1 = mysql_fetch_array($result4);

	$un_id_planifie1[$i] = $id_planifie1["id_planifie"];

	//print ("id_planifie1 ="); print ($un_id_planifie1[$i]);print ("<br>");
	
	$id_planifie_final[$k]=$un_id_planifie1[$i]; $k++;


/*	request_id1_[$i]="SELECT distinct id_materiel FROM requiert_materiel 
		WHERE id_planifie='$id_planifie'
 		AND id_planifie<>'$un_id_planifie1[$i]'";

 	result_id1_[$i]=mysql_query(request_id1_[$i]);*/
 }




//cours qui commencent aprés le debut et terminent après le fin
$request5="SELECT id_planifie FROM planifie p 
		WHERE p.heure_debut>='$une_heure_debut'
		AND p.heure_debut<='$une_heure_fin'
		AND p.heure_fin>'$une_heure_fin'
		AND p.semaine='$une_semaine'
		AND p.jour_semaine='$un_jour_semaine'
		AND p.id_planifie <> '$id_planifie'  ";

$result5=mysql_query($request5);

$nb_id_planifie2 = mysql_num_rows($result5);

for ($i = 0;$i < $nb_id_planifie2;$i++) 
 {
	$id_planifie2 = mysql_fetch_array($result5);

	$un_id_planifie2[$i] = $id_planifie2["id_planifie"];

	//print ("id_planifie2 ="); print ($un_id_planifie2[$i]);print ("<br>");

	$id_planifie_final[$k]=$un_id_planifie2[$i]; $k++;
 }




//cours qui commencent avt le debut et terminent après le fin
$request6="SELECT id_planifie FROM planifie p 
		WHERE p.heure_debut<='$une_heure_debut'
		AND p.heure_fin>='$une_heure_fin'
		AND p.semaine='$une_semaine'
		AND p.jour_semaine='$un_jour_semaine'
		AND p.id_planifie <> '$id_planifie'  ";

$result6=mysql_query($request6);

$nb_id_planifie3 = mysql_num_rows($result6);

for ($i = 0;$i < $nb_id_planifie3 ;$i++) 
 {
	$id_planifie3 = mysql_fetch_array($result6);

	$un_id_planifie3[$i] = $id_planifie3["id_planifie"];

	//print ("id_planifie3 ="); print ($un_id_planifie3[$i]);print ("<br>");

	$id_planifie_final[$k]=$un_id_planifie3[$i]; $k++;
 }









//cours qui commencent après le debut et terminent avant le fin
$request7="SELECT id_planifie FROM planifie p 
		WHERE p.heure_debut>='$une_heure_debut'
		AND p.heure_fin<='$une_heure_fin'
		AND p.semaine='$une_semaine'
		AND p.jour_semaine='$un_jour_semaine'
		AND p.id_planifie <> '$id_planifie'  ";

$result7=mysql_query($request7);

$nb_id_planifie4 = mysql_num_rows($result7);

for ($i = 0;$i < $nb_id_planifie4 ;$i++) 
 {
	$id_planifie4 = mysql_fetch_array($result7);

	$un_id_planifie4[$i] = $id_planifie4["id_planifie"];

	//print ("id_planifie4 ="); print ($un_id_planifie4[$i]);print ("<br>");

	$id_planifie_final[$k]=$un_id_planifie4[$i]; $k++;
 }


/*for ($l=0;$l<count($id_planifie_final);$l++)
{ print ("id_planifie_final[l] = "); print ($id_planifie_final[$l]);print ("<br>"); }*/






//REQUETE POUR SAVOIR QUEL MATERIEL A DEJA ETE RESERVE POUR CE CRENAUX
for ($l=0;$l<count($id_planifie_final);$l++)
{
	$request2="SELECT distinct id_materiel FROM requiert_materiel r 
			WHERE r.id_planifie<>'$id_planifie'
			AND r.id_planifie = $id_planifie_final[$l]";

	$result2=mysql_query($request2);

}
	if($result2) $nb_materiel_select_par_autre = mysql_num_rows($result2);



	for ($j = 0;$j < $nb_materiel_select_par_autre;$j++) 
	 {
		$un_materiel_selectionne_par_autre = mysql_fetch_array($result2); 
  				 
  		$id_materiel_selectionne_par_autre[$j] = $un_materiel_selectionne_par_autre["id_materiel"];

		//print ("Materiel reserve par un autre : "); print ($id_materiel_selectionne_par_autre[$j]);print ("<br>");
 	}


//REQUETE POUR SAVOIR SI ON AVAIT DEJA SELECTIONNE DU MATERIEL AUPARAVANT

	$request8="SELECT distinct id_materiel FROM requiert_materiel r 
			WHERE r.id_planifie='$id_planifie'";

	$result8=mysql_query($request8);

	if($result8) $nb_materiel_selectionne = mysql_num_rows($result8);



	for ($j = 0;$j < $nb_materiel_selectionne;$j++) 
	 {
		$un_materiel_selectionne = mysql_fetch_array($result8); 
  				 
  		$id_materiel_selectionne[$j] = $un_materiel_selectionne["id_materiel"];
 	}




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



 for ($j = 0;$j < $nb_materiel;$j++) 
 {
	$found=false;

	for($l=0;$l<$nb_materiel_selectionne && !$found;$l++){
	
		$found=($id_materiel[$j]==$id_materiel_selectionne[$l]);
	}

	$valid=true;
	


	if ( $nb_materiel_select_par_autre >0)
	{

		for ($k = 0;$k < $nb_materiel_select_par_autre;$k++) 
		 {
			/*print ("k= ");print ($k);print ("<br>");
			print ("id_materiel[$j] = "); print ($id_materiel[$j]);print ("<br>");
			print ("id_materiel_selectionne_par_autre[$k] = "); print ($id_materiel_selectionne_par_autre[$k]);print ("<br>");*/
			$valid= ($id_materiel[$j] != $id_materiel_selectionne_par_autre[$k]);
		}

		if($valid){

			if ($found) 
			{
				print("<input type='checkbox' checked name='materiel_$j' value='$id_materiel[$j]' 					onClick=\"javascript:choice.value=5; submit();\"> $G_materiel[$j]"); 

				print ("<br>");
						
			}

			if (!$found && $valid)
			{	

				print("<input type='checkbox' name='materiel_$j' value='$id_materiel[$j]' 						onClick=\"javascript:choice.value=5; submit();\"> $G_materiel[$j]");

				print ("<br>");

			}
		}
		
		
		
	}

	if ( $nb_materiel_select_par_autre == 0)
	{


		if ($found) 
		{
			print("<input type='checkbox' checked name='materiel_$j' value='$id_materiel[$j]' 						onClick=\"javascript:choice.value=5; submit();\"> $G_materiel[$j]"); 

			print ("<br>");
						
		}

		else
		{	

			print("<input type='checkbox' name='materiel_$j' value='$id_materiel[$j]' 						onClick=\"javascript:choice.value=5; submit();\"> $G_materiel[$j]");

			print ("<br>");

		}
	}




}



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

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

print("</form>");





print("<form name='form2' action='EmploiProfesseur.php3' method=post>\n");



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


print ("	<input type='hidden' name='autorisation_list' value=$autorisation_list");

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

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

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


print("</form>");

    buildEndOfPage();  
?>
Return current item: EmploiNet : a timetable web manager