Location: PHPKode > projects > EmploiNet : a timetable web manager > EmploiNet/v0.8.0/projet/validerProjet.php
<?

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

include("../Session/security.php");
print("<HTML><HEAD>\n
<TITLE>Projet</TITLE>\n
</HEAD>\n
<BODY>\n");
// Verification de la session
$autorisation_list[0]=0; // administrateur
$autorisation_list[1]=3; // gestionnaire
$user_type = validateSession($id_session);
if ($user_type == -1 || !security($id_session,$autorisation_list)) print("Accès refusé");
else {
  // Entete
  buildHeader("Validation des projets");

  // Barre de menu
  print("<FONT SIZE=2><I>\n");
  print("<A HREF='../index.php?id_session=$id_session'>Menu</A><BR>\n");
  print("</I></FONT>\n");

// Determination du user_id
  $user_id = getUserID($id_session);
 
// connection à la table emploi_du_temps
  openConnection($databaseName);
  
//*****************************************
// Choisir la promotion
  print("<FORM METHOD=POST ACTION=\"validerprojet.php\">\n");
  print("<INPUT TYPE=HIDDEN NAME=\"id_session\" VALUE=$id_session>\n");
  print("  <table align=center border=0 cellspacing=0 cellpading=0 width=700 bgcolor=\"#C0C000\">\n");
// Liste des promotions
  print("        <tr>\n");
  print("          <td valign=top width=100 nowrap rowspan=3><font size=3><i>Promotion :</i></font></td>\n");
  print("          <td width=250 rowspan=3 valign=top>\n");
  if ($user_type==3) $result = mysql_query("SELECT distinct(promotion.id_promotion),diplome.libelle as L1,promotion.libelle as L2 FROM promotion,diplome,gerer WHERE gerer.id_gestionnaire=$user_id AND promotion.id_promotion=gerer.id_promotion AND diplome.id_diplome=promotion.id_diplome ORDER BY diplome.libelle");
  else $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); 
  if ($user_type==3 && $index_max == 1) {
    $a_record = mysql_fetch_array($result);
    $id_promotion=$a_record["id_promotion"];
    print($a_record["L1"]." ".$a_record["L2"]);
    print("\n");
  }
  else {
    print("          <select name=\"id_promotion\" size=1 width=200 OnChange=\"submit();\">\n");
    if (!isset($id_promotion)) print("          <option selected>");
    for ($i=0;$i<$index_max;$i++) {
      $a_record = mysql_fetch_array($result);
      if ($id_promotion==$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("\n");
    }
  
    print("          </select>\n");
  }
  print("          </td>\n");
  print("        </tr>\n");
  print("      </table>\n");
  print("  </FORM>\n");
//**
//*****************************************
	  
  if (isset($id_promotion)) {
  
    if(isset($num_proj_supp)) {
      mysql_query("delete from validerprojet where num_proj='$num_proj_supp'");
    }
  
    if(isset($num_proj)&&isset($id_groupeetudiant)&&($num_proj!=0)) {
    
      $requeteSecu1=mysql_query("select * from validerprojet where id_groupeetudiant=$id_groupeetudiant");
      $test1=mysql_num_rows($requeteSecu1);
      
      $requeteSecu2=mysql_query("select * from validerprojet where num_proj=$num_proj");
      $test2=mysql_num_rows($requeteSecu2);
      
      if(!$test1&&!$test2) {
        $r=mysql_query("insert into validerprojet values ('$id_groupeetudiant','$num_proj')");
        if(!$r) {
          $raison="echec de la validation";
        }
      }
      else {
        $r=0;
        if($test1) {
          $raison="Ce groupe a déjà un projet";
        }
        else {
          $raison="Ce projet est déjà pris";
        }
      }
      echo "<script language='javascript'>\n";
      if($r) {
        echo "alert('Validation acceptée !!')\n";
      }
      else {
        echo "alert('".$raison." !!')\n";
      }
      echo "</script>\n"; 
    }
  
    print("
    <script language='javascript'>
      function valider(id,num) {
        document.form1.id_groupeetudiant.value=id;
        document.form1.num_proj.value=num;
        document.form1.submit();
      }
      function annuler(num) {
        document.form1.num_proj_supp.value=num;
        document.form1.submit();
      }
    </script>\n");
        
    echo "<form name=form1 method=post action='validerprojet.php'>\n";
    print("
    <input type=hidden name=id_session value='$id_session'>
    <input type=hidden name=num_proj_supp>
    <input type=hidden name=id_promotion value='$id_promotion'>
    <input type=hidden name=id_session value='$id_session'>
    <input type=hidden name=id_groupeetudiant>
    <input type=hidden name=num_proj>\n");
    
    
    $requete=mysql_query("select nom,prenom,p.* from projet p,professeur pr where pr.id_professeur=p. id_professeur and id_promotion=$id_promotion order by num_proj");
    $nb=mysql_num_rows($requete);
    for($i=0;$i<$nb;$i++) {               // pour un projet
      $projet=mysql_fetch_array($requete);
      $requeteTest=mysql_query("select * from validerprojet where num_proj=".$projet["num_proj"]);
      $test=mysql_num_rows($requeteTest);
      if($test>0) {
        echo "<i><font face='Baskerville Old Face' color='#000000'>Le projet : <a href='javascript:annuler(".$projet["num_proj"].");'>".$projet["descriptif"]."</a> est maintenant pris par un groupe!!</font></i>\n";
      }
      else {
        $requete1=mysql_query("select id_groupeetudiant as id from associerchoixprojet a,projet p where p.num_proj=a.num_proj and p.num_proj=".$projet["num_proj"]." order by preferenceChoix");
        $nbG=mysql_num_rows($requete1);
        if($nbG>0) {
          echo "<i><font face='Baskerville Old Face' color='#000000'><u>Pour le projet</u> : ".$projet["descriptif"].", $nbG groupe(s) l'ont parmi leurs choix. Ce projet requiert ".$projet["nb_etudiant"]." étudiant(s)</font></i>\n";
          echo "<br><br><table align=center cellpadding=5 border=2 bordercolor=black width=600>\n";
          echo "<tr><th align=center>Groupe</th><th>Choix n°</th align=center><th>&nbsp;</th></tr>\n";
          for($k=0;$k<$nbG;$k++) {          //  pour un groupe
            echo "<tr>\n";
            $unGroupe=mysql_fetch_array($requete1);
            $requete2=mysql_query("select preferenceChoix as pc from associerchoixprojet where id_groupeetudiant=".$unGroupe["id"]." and num_proj=".$projet["num_proj"]);
            $pc=mysql_fetch_array($requete2);
            $requete3=mysql_query("select nom,prenom from etudiant where id_groupeetudiant=".$unGroupe["id"]);
            $nbE=mysql_num_rows($requete3);
            echo "<td>";
            for ($j=0;$j<$nbE;$j++) {
              $un_etudiant=mysql_fetch_array($requete3);
              echo $un_etudiant["nom"]." ".$un_etudiant["prenom"]."<br>\n"; 
            }          
            echo "</td>\n";
            echo "<td align=center>".$pc["pc"]."</td>\n";
            echo "<td align='center'><a href='javascript:valider(".$unGroupe["id"].",".$projet["num_proj"].");'>valider</a></td>\n";
            echo "</tr>\n";
          }
          echo "</table>\n";        
        }
        else {
          echo "<i><font face='Baskerville Old Face' color='#000000'>Aucun groupe n'a choisi le projet : ".$projet["descriptif"]." !!</font></i>\n"; 
        }
      }
      echo "<br><br><hr align=center width=60%><br>\n";
    }
    echo "</form>\n";		
  }
}
buildEndOfPage();
print("
</body>
</BODY>
</HTML>");


?>
Return current item: EmploiNet : a timetable web manager