Location: PHPKode > projects > EmploiNet : a timetable web manager > EmploiNet/v0.8.0/Administration/gestionnaire.php3
<?
	include("../Session/security.php");
	include("Functions.php3");
	include("Navigation.php3");
	include("../BarreDeMenu.php3");
	include("class_gestionnaire.php3");
// Entete
    buildHeader("Gestionnaire");
// 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,"gestionnaire.php3",false);
// Ouverture de la connexion avec la base de donnees
	    $connection = openConnection($databaseName);

  $G_gestionnaire = new Gestionnaire(-1,"","","","");
  $G_id_promotion;
  $G_nb_inscriptions = 0; 

      function remplir_formulaire($index, $result)
      {
        global $G_gestionnaire;
  	    global $G_nb_inscriptions; 
		global $G_id_promotion;

        if (mysql_data_seek($result,$index))
        {
          $un_gestionnaire = mysql_fetch_array($result);   
          $G_gestionnaire->id_gestionnaire = $un_gestionnaire["id_gestionnaire"];
          $G_gestionnaire->nom = $un_gestionnaire["nom"];
          $G_gestionnaire->prenom = $un_gestionnaire["prenom"];
          $G_gestionnaire->email = $un_gestionnaire["email"];
          $G_gestionnaire->tel = $un_gestionnaire["tel"];

          $result2 = mysql_query("SELECT * FROM gerer WHERE id_gestionnaire=$G_gestionnaire->id_gestionnaire");
          $G_nb_inscriptions = mysql_num_rows($result2); 
          for ($i=0;$i<$G_nb_inscriptions;$i++)
          {
            $une_inscription = mysql_fetch_array($result2);
			$G_id_promotion[$i] = $une_inscription["id_promotion"];
     	  }
        }
        else
          print("Error: mysql_data_seek"); 
      }

      function selectRecords()
      {
        return mysql_query("SELECT * FROM gestionnaire ORDER BY nom");
      }
    
      function deleteRecord($keyValue)
      {
        mysql_query("DELETE FROM gestionnaire WHERE (id_gestionnaire='$keyValue')");
        mysql_query("DELETE FROM gerer WHERE (id_gestionnaire='$keyValue')");
      }

      function modifyRecord($keyValue)
      {
 	    global $nom;
		global $prenom;
		global $email;
		global $tel;
		global $id_promotion;

        mysql_query("UPDATE gestionnaire SET nom='$nom',prenom='$prenom',email='$email',tel='$tel' WHERE id_gestionnaire=$keyValue");
		mysql_query("DELETE FROM gerer WHERE id_gestionnaire=$keyValue");
		$n = count($id_promotion);
		for ($i=0;$i<$n;$i++)
		{
		  mysql_query("INSERT INTO gerer VALUES ($keyValue,".($id_promotion[$i]).")");
		} 
      }

      function newRecord()
      {
      	global $databaseName;
		global $id_gestionnaire;
	    global $nom;
	    global $prenom;
		global $email;
		global $tel;
		global $id_promotion;
		global $G_gestionnaire;

        if ($nom != "" && $prenom != "" && $nom != "- Obligatoire -" && $prenom != "- Obligatoire -")
		{
			$id_gestionnaire = getKeyValue("id_gestionnaire");
			mysql_query("INSERT INTO gestionnaire VALUES('$id_gestionnaire','$nom','$prenom','$email','$tel','','','')");
			$n = count($id_promotion);
			for ($i=0;$i<$n;$i++) mysql_query("INSERT INTO gerer VALUES ($id_gestionnaire,".($id_promotion[$i]).")");
		  
// Creation d'un compte d'acces avec mot de passe
			mysql_select_db("session");
			$login = strtolower(substr($prenom,0,1).$nom);

// Verifie si le login existe deja en tant que gestionnaire
			$result = mysql_query("SELECT * FROM user WHERE login='$login'");
			if (mysql_num_rows($result)>0) mysql_query("INSERT INTO appartient VALUES ('$login',3,$id_gestionnaire)");
			else
			{			
				$password = strtolower($prenom."00");
			    mysql_query("INSERT INTO user VALUES ('$login','$password',3,$id_gestionnaire)");
			    mysql_query("INSERT INTO appartient VALUES ('$login',3,$id_gestionnaire)");
			}
			mysql_select_db($databaseName);
		echo "<script language='javascript'>\n";
        echo "alert(\"Le gestionnaire $prenom $nom est ajouté\");\n";
        echo "</script>\n";
		return -1; 
//			return $id_gestionnaire;
		}
		else
		{
			$G_gestionnaire->nom = "- Obligatoire -";
			$G_gestionnaire->prenom = "- Obligatoire -"; 		  
			return -1;
		}
      }

//***********************************************************************************************
//* Navigation et rechercheId
//***********************************************************************************************

     perform($id_gestionnaire,"id_gestionnaire");

//***********************************************************************************************
//* Fin de la navigation
//***********************************************************************************************

// Formulaire de saisie

      function buildCustomFields()
	  {
	  }

	  $form["Name"]=array("","Nom","Pr&eacute;nom","E-mail","T&eacute;l","G&egrave;re");
	  $form["Type"]=array(0,1,1,1,1,2);
	  $form["FieldName"]=array("id_gestionnaire","nom","prenom","email","tel","id_promotion");
	  $form["Value"]=array($G_gestionnaire->id_gestionnaire,$G_gestionnaire->nom,$G_gestionnaire->prenom,$G_gestionnaire->email,$G_gestionnaire->tel,$G_id_promotion);
	  $form["KeyName"]=array("","","","","","id_promotion");
	  $form["Request"]=array("","","","","","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");
	  $form["Fields"]=array("","","","","",array("L1","L2"));
	  $form["Length"]=array(0,32,32,40,16,5);
	  $form["NewLine"]=array(false,false,true,false,true,false);

	  buildForm("gestionnaire.php3",$form,$id_session,0,$user_type,$user_id,$display);
  }
  buildEndOfPage();
?>    
Return current item: EmploiNet : a timetable web manager