Location: PHPKode > projects > EmploiNet : a timetable web manager > EmploiNet/v0.8.0/gdn/admin_bulletins.php3
<?



	

	include("../BarreDeMenu.php3");

	

	include("../Session/security.php");



// Entete

    buildHeader("Administration des bulletins");



// Verification de la session

	$autorisation_list[0]=0; // Administrateur

	$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,"gdn/admin_bulletins.php3",false);

// Ouverture de la connexion

	    $connection = openConnection($databaseName);

		if (!isset($index)) $index=1;

//***********************************************************************************************

//*  Debut du formulaire

//***********************************************************************************************



    print("<form name=\"form1\" action=\"admin_bulletins.php3\" method=post>\n");



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

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

	print("  <input type=\"hidden\" name=\"choice\" value=\"0\">\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=\"id_typebulletin\" value=\"$id_typebulletin\">\n");

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

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


//***********************************************************************************************

//********						INDEX = 1  : SELECTION DE LA PROMOTION					*********

//***********************************************************************************************

if($index==1){



	// liste des promotions

	$result2 = mysql_query("SELECT id_promotion, sigle FROM promotion ");



	print("  <table align=center border=0 cellspacing=0 cellpading=0 bgcolor=\"#C0C000\">\n");

	print("  <tr>\n");

	print("    <td>\n");

	print("		<font size=3><i>Promotion : </i></font> \n");

	print("    </td>\n");

	print("    <td>\n");

	print("		<SELECT tabindex=-1 NAME=\"promo\" onChange=\"index.value=2;submit();\">  \n");

	if(!isset($promo))  print("	<OPTION SELECTED > </option> \n");

	for($i=0;$i<mysql_num_rows($result2);$i++){

		$temp = mysql_fetch_row($result2);

		if(isset($promo) && $temp[0]==$promo)

			print("	<OPTION SELECTED VALUE=$temp[0]> $temp[1] \n");

		else

			print("	<OPTION VALUE=$temp[0]> $temp[1] \n");

	}

	print("		</SELECT>  \n");

	print("    </td>\n");

	print("  </tr>\n");

	print("  </table> \n");

}



//***********************************************************************************************

//********				INDEX = 2 : LISTE DES BULLETINS ASSOCIES A LA PROMO			*************

//***********************************************************************************************



if($index==2){

	// affichage du nom  de la promotion :

	$result_b = mysql_query("SELECT libelle FROM promotion WHERE id_promotion=$promo ");

	$infos = mysql_fetch_row($result_b);

	print(" <DIV ALIGN=left><I><U>Promotion :</U> $infos[0]</I></DIV><br> \n");

		

		// liste des bulletins :

		$result3 = mysql_query("SELECT DISTINCT id_typebulletin, libelle FROM typebulletin WHERE id_promotion=$promo ");



		print("  <table align=center border=1 cellspacing=0 cellpading=0 width=402> <tr><td>\n");

		print("  <table align=center border=1 cellspacing=0 cellpading=0 width=400>\n");

		print("  <tr>\n");

		print("    <td COLSPAN=2 bgcolor=\"#C0C000\"> <font size=3><b> LES TYPES DE BULLETIN </b></font> </td> \n");

		print("  </tr>\n");

		print("  <tr>\n");

		print("    <td width=220 ><i> &nbsp;Libell&eacute;  </i></td> \n");

		print("    <td width=180 align=center> &nbsp; </td> \n");

		print("  </tr>\n");

		for($i=0;$i<mysql_num_rows($result3);$i++){

			$temp = mysql_fetch_row($result3);

			print("  <tr> \n");

			print("    <td> &nbsp; <a href=\"Javascript:document.form1.index.value=3;document.form1.id_typebulletin.value=$temp[0];document.form1.submit();\"><font face=\"arial\" size=2><b>$temp[1]</b></font></a> </td> \n");

			print("    <td align=center> <font face=\"arial\" size=1><a href=\"Javascript:document.form1.index.value=4;document.form1.choice.value=2;document.form1.id_typebulletin.value=$temp[0];document.form1.submit();\">supprimer</a> </font></td> ");

			print("  </tr>\n");

		}

		print("  <tr>\n");

	    print("    <td> &nbsp; <INPUT type=text name=\"libelle\" size=20>  </td> \n");

		print("    <td align=center> <font face=\"arial\" size=1> <a href=\"Javascript:document.form1.index.value=4;document.form1.choice.value=3;document.form1.submit();\">a j o u t e r</a> </td> \n");

	    print("  </tr>\n");

		print(" </TABLE>	</td></tr></TABLE> <BR> \n");



}// fin index=2





//***********************************************************************************************

//********		INDEX = 4 : MODIFICATION, SUPPRESSION OU AJOUT D'UN BULLETIN		*************

//***********************************************************************************************



if($index==4){

	switch($choice){

		case 2 : //SUPPRESSION D'UN BULLETIN

					mysql_query("DELETE FROM typebulletin WHERE id_typebulletin=$id_typebulletin AND id_promotion=$promo");

					break;

		case 3 : //AJOUT D'UN BULLETIN

					mysql_query("INSERT INTO typebulletin VALUES ('','$libelle','$promo')");

					break;

	}





	print(" <SCRIPT LANGUAGE=javascript> \n");

	print("		document.form1.index.value=\"2\"; \n");		//	IL FAUT RECHARGER LE FORMULAIRE

	print("		document.form1.submit(); \n");

	print(" </SCRIPT> \n");

	print("  \n");





}// fin index=4



	



//***********************************************************************************************

//********		INDEX = 3 : TOUS LES GROUPES DE MATIERES CORRESPONDANT AU BULLETIN		*********

//***********************************************************************************************



if($index==3){



	// affichage du nom  de la promotion et du type de bulletin :

	$result_b = mysql_query("SELECT P.libelle, TB.libelle FROM promotion P, typebulletin TB WHERE P.id_promotion=$promo AND TB.id_promotion=$promo AND TB.id_typebulletin=$id_typebulletin ");

	$infos = mysql_fetch_row($result_b);

	print(" <DIV ALIGN=left><I><U>Promotion :</U> $infos[0]<br><U>Type de Bulletin :</U> $infos[1]</I></DIV><br> \n");





		// liste des groupe de matieres :

		$result3 = mysql_query("SELECT DISTINCT GM.id_groupematiere, GM.numero, GM.intitule, GM.id_groupe FROM groupematiere GM WHERE GM.id_typebulletin=$id_typebulletin ORDER BY GM.numero");



		print("  <table align=center border=1 cellspacing=0 cellpading=0 width=602> <tr><td>\n");

		print("  <table align=center border=1 cellspacing=0 cellpading=0 width=600>\n");

		print("  <tr>\n");

		print("    <td COLSPAN=4 bgcolor=\"#C0C000\"> <font size=3><b> LES GROUPES DE MATIERES ASSOCIES </b></font> </td> \n");

		print("  </tr>\n");

		print("  <tr>\n");

		print("    <td width=50 ><i> &nbsp;Num&eacute;ro  </i></td> \n");

		print("    <td width=200 ><i> &nbsp;Libell&eacute;  </i></td> \n");

		print("    <td width=200 ><i> &nbsp;Concerne  </i></td> \n");

		print("    <td width=150 align=center> &nbsp; </td> \n");

		print("  </tr>\n");

		for($i=0;$i<mysql_num_rows($result3);$i++){

			$temp = mysql_fetch_row($result3);

			print("  <tr> \n");

			print("    <td align=center> <INPUT type=text name=\"numero_$temp[0]\" VALUE=\"$temp[1]\" size=4> </td>");

			print("    <td> &nbsp; <INPUT type=text name=\"intitule_$temp[0]\" VALUE=\"$temp[2]\" size=20> </td> \n");

			if($temp[3]==-1) print("	   <td  align=center> <font face=\"arial\" size=2>&nbsp;toute la promotion</font></td>  \n");

			else{

				$result = mysql_query("SELECT nom FROM groupe WHERE id_groupe=$temp[3] ");

				$data = mysql_fetch_row($result);

				print("	   <td align=center > <font face=\"arial\" size=2>&nbsp;groupe $data[0]</font></td>  \n");

			}

			print("    <td align=center> <font face=\"arial\" size=1><a href=\"Javascript:document.form1.index.value=5;document.form1.choice.value=1;document.form1.id_groupematiere.value=$temp[0];document.form1.submit();\">modifier</a> | <a href=\"Javascript:document.form1.index.value=5;document.form1.choice.value=2;document.form1.id_groupematiere.value=$temp[0];document.form1.submit();\">supprimer</a> </font></td> ");

			print("  </tr>\n");

		}

		print("  <tr>\n");

	    print("    <td> &nbsp; <INPUT type=text name=\"numero\" size=4>  </td> \n");

	    print("    <td> &nbsp; <INPUT type=text name=\"libelle\" size=20>  </td> \n");

			// liste des groupes de la promotion :

			$result = mysql_query("SELECT groupe.id_groupe, groupe.nom FROM groupe, associer WHERE groupe.id_groupe=associer.id_groupe AND associer.id_promotion=$promo");

		    print("    <td align=center> <SELECT name=\"id_groupe\">  \n");

			print("			<OPTION VALUE=\"-1\" SELECTED>toute la promotion");

			for($j=0;$j<mysql_num_rows($result);$j++){

				$data = mysql_fetch_row($result);

				print("			<OPTION VALUE=$data[0]>groupe $data[1] \n");

			}

		print("    <td align=center> <font face=\"arial\" size=1> <a href=\"Javascript:document.form1.index.value=5;document.form1.choice.value=3;document.form1.submit();\">a j o u t e r</a> </td> \n");

	    print("  </tr>\n");

		print(" </TABLE>	</td></tr></TABLE> <BR> \n");



	/**************************************************************************************************************/

	/******							REPARTITION DES MATIERES DANS LES GROUPES							***********/

	/**************************************************************************************************************/

	switch($choice){

		// ajout dans le groupe specifié

		case 4 : if($coefficient!=""){

					mysql_query("INSERT INTO associerMatiereAGroupeMatiere VALUES ('$id_matiere','$id_groupematiere','$coefficient')");

				}

				break;

		// on retire la matiere du groupe :

		case 5 :

				$var = "$" . "id_matiere_" . $id_groupematiere;

				eval( "\$var = \"$var\";" );

				mysql_query("DELETE FROM associerMatiereAGroupeMatiere WHERE id_matiere=$var AND id_groupematiere=$id_groupematiere");

				break;

	}





	//liste des matieres deja reparties dans un groupe :

	$res0 = mysql_query("SELECT AM.id_matiere FROM associerMatiereAGroupeMatiere AM, groupematiere GM WHERE AM.id_groupematiere=GM.id_groupematiere AND GM.id_typebulletin=$id_typebulletin ");



	$liste = "";

	if(mysql_num_rows($res0)!=0){

		for($i=0;$i<mysql_num_rows($res0)-1;$i++){

			$data = mysql_fetch_row($res0);

			$liste .= "'" . $data[0] . "'" . ",";

		}

		$data = mysql_fetch_row($res0);

		$liste .= "'" . $data[0] . "'";

	}

	// liste des matieres de la promotion restant a repartir :

	$query = "SELECT DISTINCT M.id_matiere, M.nom FROM matiere M, suiviparpromotion SPP, groupematiere GRM WHERE SPP.id_matiere=M.id_matiere AND SPP.id_promotion=$promo AND GRM.id_typebulletin=$id_typebulletin ";

	if(mysql_num_rows($res0)!=0) $query.=" AND M.id_matiere NOT IN ($liste)";

	$res1 = mysql_query($query);



	// liste des matieres des groupes restant a repartir :

	$query2 = "SELECT DISTINCT M.id_matiere, M.nom, G.nom FROM matiere M, suivipargroupe SPG, groupematiere GRM, groupe G, associer A WHERE G.id_groupe=A.id_groupe AND SPG.id_matiere=M.id_matiere AND SPG.id_groupe=A.id_groupe AND A.id_promotion=$promo AND GRM.id_typebulletin=$id_typebulletin ";

	if(mysql_num_rows($res0)!=0) $query2.=" AND M.id_matiere NOT IN ($liste)";

	$query2 .= " ORDER BY G.nom ";

	$res2 = mysql_query($query2);



print("<table > \n");

	print(" <tr valign=top><td> \n");



	print("  <table align=center border=1 cellspacing=0 cellpading=0 width=202> <tr><td>\n");

	print("  <table align=center border=1 cellspacing=0 cellpading=0 width=200>\n");

	print(" <tr> \n");

	print("  <td align=center bgcolor=\"#C0C000\"> <i>Mati&egrave;res encore <br>non r&eacute;parties : </i> <br>");

	print("   <select name=\"id_matiere\" size=8> \n");

		for($i=0;$i<mysql_num_rows($res1);$i++){

			$data = mysql_fetch_row($res1);

			print("    <option value=\"$data[0]\">$data[1] \n");

		}

		for($i=0;$i<mysql_num_rows($res2);$i++){

			$data = mysql_fetch_row($res2);

			print("    <option value=\"$data[0]\">$data[1] ($data[2]) \n");

		}

	print("   </select> <br><i>Coeff : </i><input type=text name=coefficient size=8> </td> \n");

	print(" </tr> \n");

	print(" </TABLE>	</td></tr></TABLE> \n");

print(" </td> <td> \n");



	print("  <table align=center border=1 cellspacing=0 cellpading=0 > <tr><td>\n");

	print("  <table align=center border=1 cellspacing=0 cellpading=0 >\n");

	print(" <tr> \n");

		// liste des groupe de matieres :

		$result3 = mysql_query("SELECT DISTINCT GM.id_groupematiere, GM.numero, GM.intitule, GM.id_groupe FROM groupematiere GM WHERE GM.id_typebulletin=$id_typebulletin ORDER BY GM.numero");



	for($i=0;$i<mysql_num_rows($result3);$i++){

		$temp = mysql_fetch_row($result3);

		if($temp[3]==-1) print(" <td align=center width=150> <i> $temp[2] </i> <br> \n");

		else{

			$result = mysql_query("SELECT nom FROM groupe WHERE id_groupe=$temp[3] ");

			$data = mysql_fetch_row($result);

			print("	   <td align=center width=150> <i> $temp[2] ($data[0]) </i> <br> \n");

		}

		$result4 = mysql_query("SELECT M.id_matiere, M.nom, AM.coefficient FROM matiere M, associerMatiereAGroupeMatiere AM WHERE AM.id_groupematiere=$temp[0] AND AM.id_matiere=M.id_matiere");

		print(" <hr><select name=\"id_matiere_$temp[0]\" size=8 > \n");

		for($j=0;$j<mysql_num_rows($result4);$j++){

			$data = mysql_fetch_row($result4);

			print("    <option value=\"$data[0]\">$data[1] ($data[2])\n");

		}

		print(" </select><br> \n");

		print("		<input type=button name=\"Ajouter\" value=\"    +    \" OnClick=\"id_groupematiere.value=$temp[0]; choice.value=4; submit();\">\n");

		print("		<input type=button name=\"Supprimer\" value=\"    -    \" OnClick=\"id_groupematiere.value=$temp[0];choice.value=5; submit();\">\n");

		print(" </td> \n");

	}

	print(" </tr> \n");

	print(" </TABLE>	</td></tr></TABLE> \n");



print(" </td> </tr> \n");

print("</table > \n");



	

}//fin index=3



//***********************************************************************************************

//********		INDEX = 5 : MODIFICATION, SUPPRESSION OU AJOUT D'UN GR DE MATIERES		*********

//***********************************************************************************************



if($index==5){

	switch($choice){

		case 1 : //MODIFICATION D'UN GROUPE DE MATIERES

					$numero = "$" . "numero_" . $id_groupematiere;

					$intitule = "$" . "intitule_" . $id_groupematiere;

					eval( "\$numero = \"$numero\";" );

					eval( "\$intitule = \"$intitule\";" );

					mysql_query("UPDATE groupematiere SET numero='$numero', intitule='$intitule' WHERE id_groupematiere=$id_groupematiere");

					break;

		case 2 : //SUPPRESSION D'UN GROUPE DE MATIERES

					mysql_query("DELETE FROM groupematiere WHERE id_groupematiere=$id_groupematiere ");

					mysql_query("DELETE FROM associerMatiereAGroupeMatiere WHERE id_groupematiere=$id_groupematiere ");

					break;

		case 3 : //AJOUT D'UN GROUPE DE MATIERES

					mysql_query("INSERT INTO groupematiere VALUES ('','$libelle','$id_typebulletin','$id_groupe','$numero')");

					break;

	}





	print(" <SCRIPT LANGUAGE=javascript> \n");

	print("		document.form1.index.value=\"3\"; \n");		//	IL FAUT RECHARGER LE FORMULAIRE

	print("		document.form1.submit(); \n");

	print(" </SCRIPT> \n");

	print("  \n");





}// fin index=5



//***********************************************************************************************

//*  Fin du formulaire

//***********************************************************************************************



	print("</form> \n");



//***********************************************************************************************

//***********************************************************************************************

//***********************************************************************************************

}

	

	buildEndOfPage();	



?>

Return current item: EmploiNet : a timetable web manager