Location: PHPKode > projects > EmploiNet : a timetable web manager > EmploiNet/v0.8.0/Administration/professeur.php3
<?
    
    include("Functions.php3");
    include("Navigation.php3");
    include("../BarreDeMenu.php3");
    include("class_professeur.php3");
	include("../Session/security.php");

// Entete
    buildHeader("Enseignant");

// 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,"professeur.php3",false);
// Ouverture de la connexion avec la base de donnees
	    $connection = openConnection($databaseName);
		$G_professeur = new Professeur(-1,"","","","",-1,-1,"","",-1,"","","","","");

function remplir_formulaire($index, $result)
      {
		global $G_professeur;
        if (mysql_data_seek($result,$index))
        {
			$un_prof = mysql_fetch_array($result);   
			$G_professeur->id_professeur = $un_prof["id_professeur"];
			$G_professeur->nom = $un_prof["nom"];
			$G_professeur->prenom = $un_prof["prenom"];
			$G_professeur->initiales = $un_prof["initiales"];
			$G_professeur->id_grade = $un_prof["id_grade"];
			$G_professeur->id_departement = $un_prof["id_departement"];
			$G_professeur->cnu = $un_prof["cnu"];
			$G_professeur->titulaire = $un_prof["titulaire"];
			$G_professeur->id_cgu = $un_prof["id_cgu"];
			$G_professeur->pedr = $un_prof["pedr"];
			$G_professeur->adresse = $un_prof["adresse"];
			$G_professeur->code_postal = $un_prof["code_postal"];
			$G_professeur->ville = $un_prof["ville"];
			$G_professeur->email = $un_prof["email"];
			$G_professeur->tel = $un_prof["tel"];
        }
        else
          print("Error: mysql_data_seek"); 
      }

      function selectRecords()
      {
        return mysql_query("SELECT * FROM professeur ORDER BY nom");
	  }

      function deleteRecord($keyValue)
      {
        mysql_query("DELETE FROM professeur WHERE (id_professeur='$keyValue')");
      }

      function modifyRecord($keyValue)
      {
 	    global $nom;
		global $prenom;
		global $initiales;
		global $id_grade;
		global $id_departement;
		global $cnu;
		global $titulaire;
		global $id_cgu;
		global $pedr;
		global $adresse;
		global $code_postal;
		global $ville;
		global $email;
		global $tel;
	    mysql_query("UPDATE professeur SET nom='$nom',prenom='$prenom',initiales='$initiales',id_grade='$id_grade',id_departement='$id_departement',cnu='$cnu',titulaire='$titulaire',id_cgu='$id_cgu',pedr='$pedr',adresse='$adresse',code_postal='$code_postal',ville='$ville',email='$email',tel='$tel' WHERE id_professeur=$keyValue");
      }

      function newRecord()
      {
		global $databaseName;
		global $id_professeur;
	    global $nom;
	    global $prenom;
		global $initiales;
		global $id_grade;
		global $id_departement;
		global $cnu;
		global $titulaire;
		global $id_cgu;
		global $pedr;
		global $adresse;
		global $code_postal;
		global $ville;
		global $email;
		global $tel;
		global $G_professeur;

		if ($nom != "" && $prenom != "" && $nom != "- Obligatoire -" && $prenom != "- Obligatoire -")
		{
			$id_professeur = getKeyValue("id_professeur");
		  	mysql_query("INSERT INTO professeur VALUES('$id_professeur','$nom','$prenom','$initiales','$id_grade','$id_departement','$cnu','$titulaire','$id_cgu','$pedr','$adresse','$code_postal','$ville','$email','$tel')");

// 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',1,$id_professeur)");
			else
			{			
				$password = strtolower($prenom."98");
			    mysql_query("INSERT INTO user VALUES ('$login','$password',1,$id_professeur)");
			    mysql_query("INSERT INTO appartient VALUES ('$login',1,$id_professeur)");
			}
			mysql_select_db($databaseName);
			echo "<script language='javascript'>\n";
        echo "alert(\"L\'enseignant $prenom $nom est ajouté\");\n";
        echo "</script>\n";
		return -1; 
//				  	return $id_professeur;
		}
		else
		{
		  	$G_professeur->nom = "- Obligatoire -";
		  	$G_professeur->prenom = "- Obligatoire -"; 		  
		  	return -1;
		}
      }


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

//* Navigation et rechercheId

//***********************************************************************************************
	  function customPerform()
	  {
	  }
     perform($id_professeur,"id_professeur");

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

//* Fin de la navigation

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

// Formulaire de saisie
      function buildCustomFields()
	  {
	  }
	  $form["Name"]=array("","Nom","Pr&eacute;nom","Initiales","Grade","D&eacute;partement","Section CNU","Titulaire","PEDR","CGU","Adresse","Code postal","Ville","E-mail","T&eacute;l");
	  $form["Type"]=array(0,1,1,1,5,5,1,4,4,5,3,1,1,1,1);
	  $form["FieldName"]=array("id_professeur","nom","prenom","initiales","id_grade","id_departement","cnu","titulaire","pedr","id_cgu","adresse","code_postal","ville","email","tel");
	  $form["Value"]=array($G_professeur->id_professeur,$G_professeur->nom,$G_professeur->prenom,$G_professeur->initiales,$G_professeur->id_grade,$G_professeur->id_departement,$G_professeur->cnu,$G_professeur->titulaire,$G_professeur->pedr,$G_professeur->id_cgu,$G_professeur->adresse,$G_professeur->code_postal,$G_professeur->ville,$G_professeur->email,$G_professeur->tel);
	  $form["KeyName"]=array("","","","","id_grade","id_departement","","","","id_cgu","","","","","");
	  $form["Request"]=array("","","","","SELECT * FROM grade ORDER BY libelle","SELECT * FROM departement ORDER BY libelle","","","","SELECT * FROM cgu ORDER BY libelle","","","","","");
	  $form["Fields"]=array("","","","",array("libelle"),array("libelle"),"","","",array("libelle"),"","","","","");
	  $form["Length"]=array(0,32,32,5,1,1,5,-1,-1,1,32,5,32,40,16);
	  $form["NewLine"]=array(false,false,true,true,true,false,true,false,true,true,true,false,true,false,false);
	  buildForm("professeur.php3",$form,$id_session,0,$user_type,$user_id,$display);
  }
  buildEndOfPage();
?>
Return current item: EmploiNet : a timetable web manager