mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2024-12-26 04:22:23 +00:00
Restructuration de la page d'inscription
This commit is contained in:
parent
25a31b7f40
commit
b8dfe1a607
@ -2,12 +2,13 @@
|
|||||||
|
|
||||||
require_once "server_files/config.php";
|
require_once "server_files/config.php";
|
||||||
|
|
||||||
require_once "server_files/model.php";
|
|
||||||
require_once "server_files/classes/Role.php";
|
require_once "server_files/classes/Role.php";
|
||||||
|
require_once "server_files/classes/SchoolClass.php";
|
||||||
require_once "server_files/classes/Team.php";
|
require_once "server_files/classes/Team.php";
|
||||||
require_once "server_files/classes/Tournament.php";
|
require_once "server_files/classes/Tournament.php";
|
||||||
require_once "server_files/classes/User.php";
|
require_once "server_files/classes/User.php";
|
||||||
require_once "server_files/classes/ValidationStatus.php";
|
require_once "server_files/classes/ValidationStatus.php";
|
||||||
|
require_once "server_files/model.php";
|
||||||
|
|
||||||
loadUserValues();
|
loadUserValues();
|
||||||
|
|
||||||
|
41
server_files/classes/SchoolClass.php
Normal file
41
server_files/classes/SchoolClass.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class SchoolClass
|
||||||
|
{
|
||||||
|
const SECONDE = 0;
|
||||||
|
const PREMIERE = 1;
|
||||||
|
const TERMINALE = 2;
|
||||||
|
|
||||||
|
public static function getTranslatedName($class) {
|
||||||
|
switch ($class) {
|
||||||
|
case self::SECONDE:
|
||||||
|
return "Seconde ou inférieur";
|
||||||
|
case self::PREMIERE:
|
||||||
|
return "Première";
|
||||||
|
default:
|
||||||
|
return "Terminale";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getName($class) {
|
||||||
|
switch ($class) {
|
||||||
|
case self::SECONDE:
|
||||||
|
return "SECONDE";
|
||||||
|
case self::PREMIERE:
|
||||||
|
return "PREMIERE";
|
||||||
|
default:
|
||||||
|
return "TERMINALE";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function fromName($name) {
|
||||||
|
switch ($name) {
|
||||||
|
case "SECONDE":
|
||||||
|
return self::SECONDE;
|
||||||
|
case "PREMIERE":
|
||||||
|
return self::PREMIERE;
|
||||||
|
default:
|
||||||
|
return self::TERMINALE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -74,7 +74,7 @@ class User
|
|||||||
$this->country = $data["country"];
|
$this->country = $data["country"];
|
||||||
$this->phone_number = $data["phone_number"];
|
$this->phone_number = $data["phone_number"];
|
||||||
$this->school = $data["school"];
|
$this->school = $data["school"];
|
||||||
$this->class = $data["class"];
|
$this->class = SchoolClass::fromName($data["class"]);
|
||||||
$this->responsible_name = $data["responsible_name"];
|
$this->responsible_name = $data["responsible_name"];
|
||||||
$this->responsible_phone = $data["responsible_phone"];
|
$this->responsible_phone = $data["responsible_phone"];
|
||||||
$this->responsible_email = $data["responsible_email"];
|
$this->responsible_email = $data["responsible_email"];
|
||||||
@ -250,7 +250,7 @@ class User
|
|||||||
{
|
{
|
||||||
global $DB;
|
global $DB;
|
||||||
$this->class = $class;
|
$this->class = $class;
|
||||||
$DB->prepare("UPDATE `users` SET `class` = ? WHERE `id` = ?;")->execute([$class, $this->getId()]);
|
$DB->prepare("UPDATE `users` SET `class` = ? WHERE `id` = ?;")->execute([SchoolClass::getName($class), $this->getId()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getResponsibleName()
|
public function getResponsibleName()
|
||||||
|
@ -1,129 +1,98 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
$has_error = false;
|
||||||
|
$error_message = null;
|
||||||
|
|
||||||
if (isset($_POST["submitted"])) {
|
if (isset($_POST["submitted"])) {
|
||||||
$error_message = register();
|
$user = new NewUser($_POST);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$user->makeVerifications();
|
||||||
|
$user->register();
|
||||||
|
} catch (AssertionError $e) {
|
||||||
|
$has_error = true;
|
||||||
|
$error_message = $e->getMessage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function register() {
|
class NewUser
|
||||||
global $DB, $YEAR, $URL_BASE, $MAIL_ADDRESS;
|
{
|
||||||
global $email, $firstname, $surname, $birth_date, $gender, $address, $postal_code, $city, $country, $phone_number, $role, $school, $class, $responsible_name, $responsible_phone, $responsible_email;
|
public $email = null;
|
||||||
|
public $first_name = null;
|
||||||
|
public $surname = null;
|
||||||
|
public $birth_date = null;
|
||||||
|
public $gender = null;
|
||||||
|
public $address = "";
|
||||||
|
public $postal_code = null;
|
||||||
|
public $city = "";
|
||||||
|
public $country = null;
|
||||||
|
public $phone_number = null;
|
||||||
|
public $role = null;
|
||||||
|
public $school = null;
|
||||||
|
public $class = null;
|
||||||
|
public $responsible_name = null;
|
||||||
|
public $responsible_phone = null;
|
||||||
|
public $responsible_email = null;
|
||||||
|
public $description = null;
|
||||||
|
public $confirm_email_token = null;
|
||||||
|
private $password = null;
|
||||||
|
private $confirm_password = null;
|
||||||
|
|
||||||
$email = strtolower(htmlspecialchars($_POST["email"]));
|
public function __construct($data)
|
||||||
|
{
|
||||||
|
|
||||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL))
|
foreach ($data as $key => $value)
|
||||||
return "L'email entrée est invalide.";
|
$this->$key = htmlspecialchars($value);
|
||||||
|
}
|
||||||
|
|
||||||
$result = $DB->query("SELECT `email` FROM `users` WHERE `email` = '" . $email . "' AND `year` = '$YEAR';");
|
public function makeVerifications()
|
||||||
if ($result->fetch())
|
{
|
||||||
return "Un compte existe déjà avec cette adresse e-mail.";
|
global $DB, $YEAR;
|
||||||
|
|
||||||
$password = htmlspecialchars($_POST["password"]);
|
ensure(filter_var($this->email, FILTER_VALIDATE_EMAIL), "L'adresse e-mail entrée est invalide.");
|
||||||
if (strlen($password) < 8)
|
ensure(!$DB->query("SELECT `email` FROM `users` WHERE `email` = '" . $this->email . "' AND `year` = '$YEAR';")->fetch(), "Un compte existe déjà avec cette adresse e-mail.");
|
||||||
return "Le mot de passe doit comporter au moins 8 caractères.";
|
ensure(strlen($this->password) >= 8, "Le mot de passe doit comporter au moins 8 caractères.");
|
||||||
if ($password != $_POST["confirm_password"])
|
ensure($this->password == $this->confirm_password, "Les deux mots de passe sont différents.");
|
||||||
return "Les deux mots de passe sont différents.";
|
ensure($this->surname != "", "Le nom de famille est obligatoire.");
|
||||||
|
ensure($this->first_name != "", "Le prénom est obligatoire.");
|
||||||
|
ensure(date_parse_from_format("yyyy-mm-dd", $this->birth_date) !== false, "La date de naissance est invalide.");
|
||||||
|
ensure($this->birth_date < $YEAR . "-01-01", "Vous devez être né.");
|
||||||
|
ensure($this->gender == "M" || $this->gender == "F", "Le sexe indiqué est invalide.");
|
||||||
|
ensure(preg_match("#^[0-9]{4}[0-9]?$#", $this->postal_code) && intval($this->postal_code) >= 01000 && intval($this->postal_code) <= 95999, "Le code postal est invalide.");
|
||||||
|
if ($this->country == "")
|
||||||
|
$this->country = "France";
|
||||||
|
ensure(strlen($this->phone_number) >= 10, "Le numéro de téléphone est invalide.");
|
||||||
|
$this->role = Role::fromName(strtoupper($this->role));
|
||||||
|
|
||||||
$password = password_hash($password, PASSWORD_BCRYPT);
|
if ($this->role == Role::PARTICIPANT) {
|
||||||
|
$this->class = SchoolClass::fromName(strtoupper($this->class));
|
||||||
|
if ($this->birth_date > strval($YEAR - 18) . "04-01") {
|
||||||
|
ensure($this->responsible_name != "", "Veuillez spécifier un responsable légal.");
|
||||||
|
ensure(strlen($this->responsible_phone) >= 10, "Veuillez rentrer le numéro de téléphone de votre responsable légal.");
|
||||||
|
ensure(filter_var($this->responsible_email, FILTER_VALIDATE_EMAIL), "Veuillez spécifier un responsable légal.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$surname = strtoupper(htmlspecialchars($_POST["surname"]));
|
$this->confirm_email_token = uniqid();
|
||||||
if (!isset($surname) || $surname == "")
|
|
||||||
return "Le nom de famille est obligatoire.";
|
|
||||||
|
|
||||||
$firstname = htmlspecialchars($_POST["firstname"]);
|
throw new AssertionError("erreur");
|
||||||
if (!isset($surname) || $surname == "")
|
}
|
||||||
return "Le prénom est obligatoire.";
|
|
||||||
|
|
||||||
$birth_date = date_parse_from_format("yyyy-mm-dd", htmlspecialchars($_POST["birth_date"]));
|
public function register()
|
||||||
|
{
|
||||||
|
global $DB, $YEAR, $URL_BASE, $MAIL_ADDRESS;
|
||||||
|
|
||||||
if ($birth_date === FALSE)
|
$req = $DB->prepare("INSERT INTO `users`(`email`, `pwd_hash`, `confirm_email`, `surname`, `first_name`, `birth_date`, `gender`,
|
||||||
return "La date de naissance est invalide.";
|
|
||||||
|
|
||||||
if (htmlspecialchars($_POST["birth_date"]) >= $YEAR . "-01-01")
|
|
||||||
return "Vous devez avoir un âge strictement positif. Date de naissance rentrée : " . htmlspecialchars($_POST["birth_date"]);
|
|
||||||
|
|
||||||
$gender = htmlspecialchars($_POST["gender"]);
|
|
||||||
|
|
||||||
if (!isset($gender) || ($gender != "M" && $gender != "F"))
|
|
||||||
return "Le sexe indiqué est invalide.";
|
|
||||||
|
|
||||||
$address = htmlspecialchars($_POST["address"]);
|
|
||||||
|
|
||||||
if (!isset($address))
|
|
||||||
$address = "";
|
|
||||||
|
|
||||||
try {
|
|
||||||
$postal_code = intval($_POST["postal_code"]);
|
|
||||||
if ($postal_code < 1000 || $postal_code > 95999)
|
|
||||||
return "Le code postal est invalide.";
|
|
||||||
}
|
|
||||||
catch (Exception $ex) {
|
|
||||||
return "Le code postal n'est pas un nombre valide.";
|
|
||||||
}
|
|
||||||
|
|
||||||
$city = htmlspecialchars($_POST["city"]);
|
|
||||||
|
|
||||||
if (!isset($city))
|
|
||||||
$city = "";
|
|
||||||
|
|
||||||
$country = htmlspecialchars($_POST["country"]);
|
|
||||||
|
|
||||||
if (!isset($country))
|
|
||||||
$country = "France";
|
|
||||||
|
|
||||||
$phone_number = htmlspecialchars($_POST["phone_number"]);
|
|
||||||
|
|
||||||
if (!isset($phone_number) || $phone_number == "")
|
|
||||||
return "Vous devez renseigner un numéro de téléphone.";
|
|
||||||
|
|
||||||
$role = htmlspecialchars($_POST["role"]);
|
|
||||||
|
|
||||||
if (!isset($role) || ($role != "participant" && $role != "encadrant"))
|
|
||||||
return "Le rôle entré n'est pas valide.";
|
|
||||||
|
|
||||||
$role = strtoupper($role);
|
|
||||||
|
|
||||||
$school = htmlspecialchars($_POST["school"]);
|
|
||||||
$class = strtoupper(htmlspecialchars($_POST["class"]));
|
|
||||||
$responsible_name = htmlspecialchars($_POST["responsible_name"]);
|
|
||||||
$responsible_phone = htmlspecialchars($_POST["responsible_phone"]);
|
|
||||||
$responsible_email = htmlspecialchars($_POST["responsible_email"]);
|
|
||||||
|
|
||||||
if ($role == "ENCADRANT") {
|
|
||||||
$school = NULL;
|
|
||||||
$class = NULL;
|
|
||||||
$responsible_name = NULL;
|
|
||||||
$responsible_phone = NULL;
|
|
||||||
$responsible_email = NULL;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (!isset($class) && $class != "TERMINALE" && $class != "PREMIERE" && $class != "SECONDE")
|
|
||||||
return "La classe spécifiée est invalide. Merci de ne pas créer vos propres requêtes.";
|
|
||||||
|
|
||||||
if ((!isset($responsible_name) || $responsible_name == "") && $birth_date > strval($YEAR - 18) . "-05-01")
|
|
||||||
return "Veuillez spécifier un nom de responsable légal.";
|
|
||||||
|
|
||||||
if ((!isset($responsible_phone) || $responsible_phone == "") && (!isset($responsible_email) || !filter_var($responsible_email, FILTER_VALIDATE_EMAIL))
|
|
||||||
&& $birth_date > strval($YEAR - 18) . "-05-01")
|
|
||||||
return "Veuillez préciser au moins le numéro de téléphone ou l'addresse e-mail de votre responsable légal.";
|
|
||||||
}
|
|
||||||
|
|
||||||
$description = $_POST["description"];
|
|
||||||
|
|
||||||
if ($role == "PARTICIPANT")
|
|
||||||
$description = NULL;
|
|
||||||
|
|
||||||
$confirm_email_uid = uniqid();
|
|
||||||
|
|
||||||
$req = $DB->prepare("INSERT INTO `users`(`email`, `pwd_hash`, `confirm_email`, `surname`, `first_name`, `birth_date`, `gender`,
|
|
||||||
`address`, `postal_code`, `city`, `country`, `phone_number`, `school`, `class`, `role`, `description`, `year`)
|
`address`, `postal_code`, `city`, `country`, `phone_number`, `school`, `class`, `role`, `description`, `year`)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
|
||||||
$req->execute([$email, $password, $confirm_email_uid, $surname, $firstname, $_POST["birth_date"], $gender, $address, $postal_code,
|
$req->execute([$this->email, password_hash($this->password, PASSWORD_BCRYPT), $this->confirm_email_token, $this->surname, $this->first_name, $this->birth_date, $this->gender, $this->address,
|
||||||
$city, $country, $phone_number, $school, $class, $role, $description, $YEAR]);
|
$this->postal_code, $this->city, $this->country, $this->phone_number, $this->school, SchoolClass::getName($this->class), Role::getName($this->role), $this->description, $YEAR]);
|
||||||
|
|
||||||
$msg = "Merci pour votre inscription au TFJM² $YEAR ! Veuillez désormais confirmer votre adresse mail en cliquant ici : $URL_BASE/confirmer_mail/$confirm_email_uid";
|
// TODO Mieux gérer l'envoi des mails avec une classe à part
|
||||||
mail($email, "Inscription au TFJM² $YEAR", $msg, "From: $MAIL_ADDRESS\r\n");
|
|
||||||
|
|
||||||
return false;
|
$msg = "Merci pour votre inscription au TFJM² $YEAR ! Veuillez désormais confirmer votre adresse mail en cliquant ici : $URL_BASE/confirmer_mail/" . $this->confirm_email_token;
|
||||||
|
mail($this->email, "Inscription au TFJM² $YEAR", $msg, "From: $MAIL_ADDRESS\r\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once "server_files/views/inscription.php";
|
require_once "server_files/views/inscription.php";
|
||||||
|
@ -95,3 +95,8 @@ function quitTeam() {
|
|||||||
$_SESSION["team"] = null;
|
$_SESSION["team"] = null;
|
||||||
unset($_SESSION["team"]);
|
unset($_SESSION["team"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ensure($bool, $error_msg = "") {
|
||||||
|
if (!$bool)
|
||||||
|
throw new AssertionError($error_msg);
|
||||||
|
}
|
@ -1,149 +1,177 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once "header.php";
|
require_once "header.php";
|
||||||
|
|
||||||
if (isset($error_message) && $error_message)
|
if ($has_error)
|
||||||
echo "<h2>Erreur : " . $error_message . "</h2>";
|
echo "<h2>Erreur : " . $error_message . "</h2>";
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if (isset($error_message) && $error_message === FALSE) {
|
/** @var NewUser $user */
|
||||||
|
if (isset($user) && !$has_error) {
|
||||||
?>
|
?>
|
||||||
Votre inscription est validée ! Merci désormais de confirmer votre boîte mail pour valider votre adresse.
|
Votre inscription est validée ! Merci désormais de confirmer votre boîte mail pour valider votre adresse.
|
||||||
<?php } else if (isset($_SESSION["user_id"])) { ?>
|
<?php } else if (isset($_SESSION["user_id"])) { ?>
|
||||||
<h2>Vous êtes déjà connecté !</h2>
|
<h2>Vous êtes déjà connecté !</h2>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
|
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
<input type="hidden" name="submitted" value="true" />
|
<input type="hidden" name="submitted" value="true"/>
|
||||||
<table style="width: 100%;">
|
<table style="width: 100%;">
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width: 30%;"><label for="email">E-mail :</label></td>
|
<td style="width: 30%;"><label for="email">E-mail :</label></td>
|
||||||
<td style="width: 70%;"><input style="width: 100%;" type="email" id="email" name="email" value="<?php if (isset($_POST["email"])) echo $_POST["email"] ?>" required /></td>
|
<td style="width: 70%;"><input style="width: 100%;" type="email" id="email" name="email"
|
||||||
</tr>
|
value="<?php if (isset($user)) echo $user->email ?>"
|
||||||
<tr>
|
required/></td>
|
||||||
<td><label for="password">Mot de passe :</label></td>
|
</tr>
|
||||||
<td><input style="width: 100%;" type="password" id="password" name="password" required /></td>
|
<tr>
|
||||||
</tr>
|
<td><label for="password">Mot de passe :</label></td>
|
||||||
<tr>
|
<td><input style="width: 100%;" type="password" id="password" name="password" required/></td>
|
||||||
<td><label for="confirm_password">Confirmer le mot de passe :</label></td>
|
</tr>
|
||||||
<td><input style="width: 100%;" type="password" id="confirm_password" name="confirm_password" required /></td>
|
<tr>
|
||||||
</tr>
|
<td><label for="confirm_password">Confirmer le mot de passe :</label></td>
|
||||||
<tr>
|
<td><input style="width: 100%;" type="password" id="confirm_password" name="confirm_password" required/>
|
||||||
<td><label for="surname">Nom :</label></td>
|
</td>
|
||||||
<td><input style="width: 100%;" type="text" id="surname" name="surname" value="<?php if (isset($_POST["surname"])) echo $_POST["surname"] ?>" required /></td>
|
</tr>
|
||||||
</tr>
|
<tr>
|
||||||
<tr>
|
<td><label for="surname">Nom :</label></td>
|
||||||
<td><label for="firstname">Prénom :</label></td>
|
<td><input style="width: 100%;" type="text" id="surname" name="surname"
|
||||||
<td><input style="width: 100%;" type="text" id="firstname" name="firstname" value="<?php if (isset($_POST["firstname"])) echo $_POST["firstname"] ?>" required /></td>
|
value="<?php if (isset($user)) echo $user->surname ?>" required/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><label for="birth_date">Date de naissance :</label></td>
|
<td><label for="first_name">Prénom :</label></td>
|
||||||
<td><input style="width: 100%;" type="date" id="birth_date" name="birth_date" value="<?php if (isset($_POST["birth_date"])) echo $_POST["birth-date"] ?>" required /></td>
|
<td><input style="width: 100%;" type="text" id="first_name" name="first_name"
|
||||||
</tr>
|
value="<?php if (isset($user)) echo $user->first_name ?>" required/></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td><label for="gender">Sexe :</label></td>
|
<tr>
|
||||||
<td><input type="radio" id="male" name="gender" value="M" required <?= isset($_POST["gender"]) && $_POST["gender"] == "M" ? "checked" : "" ?> /><label for="male">Homme</label>
|
<td><label for="birth_date">Date de naissance :</label></td>
|
||||||
<input type="radio" id="female" name="gender" value="F" required <?= isset($_POST["gender"]) && $_POST["gender"] == "F" ? "checked" : "" ?> /><label for="female">Femme</label></td>
|
<td><input style="width: 100%;" type="date" id="birth_date" name="birth_date"
|
||||||
</tr>
|
value="<?php if (isset($user)) echo $user->birth_date ?>" required/></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td><label for="address">Adresse :</label></td>
|
<tr>
|
||||||
<td><input style="width: 100%;" type="text" id="address" name="address" value="<?php if (isset($_POST["address"])) echo $_POST["address"] ?>" /></td>
|
<td><label for="gender">Sexe :</label></td>
|
||||||
</tr>
|
<td><input type="radio" id="male" name="gender" value="M"
|
||||||
<tr>
|
required <?= isset($_POST["gender"]) && $_POST["gender"] == "M" ? "checked" : "" ?> /><label
|
||||||
<td><label for="postal_code">Code postal :</label></td>
|
for="male">Homme</label>
|
||||||
<td><input style="width: 100%;" type="number" id="postal_code" name="postal_code" value="<?php if (isset($_POST["postal_code"])) echo $_POST["postal_code"] ?>" min="1000" max="95999" required /></td>
|
<input type="radio" id="female" name="gender" value="F"
|
||||||
</tr>
|
required <?= isset($_POST["gender"]) && $_POST["gender"] == "F" ? "checked" : "" ?> /><label
|
||||||
<tr>
|
for="female">Femme</label></td>
|
||||||
<td><label for="city">Ville :</label></td>
|
</tr>
|
||||||
<td><input style="width: 100%;" type="text" id="city" name="city" value="<?php if (isset($_POST["city"])) echo $_POST["city"] ?>" /></td>
|
<tr>
|
||||||
</tr>
|
<td><label for="address">Adresse :</label></td>
|
||||||
<tr>
|
<td><input style="width: 100%;" type="text" id="address" name="address"
|
||||||
<td><label for="country">Pays :</label></td>
|
value="<?php if (isset($user)) echo $user->address ?>"/></td>
|
||||||
<td><input style="width: 100%;" type="text" id="country" name="country" value="<?= isset($_POST["country"]) ? $_POST["country"] : "France" ?>" required /></td>
|
</tr>
|
||||||
</tr>
|
<tr>
|
||||||
<tr>
|
<td><label for="postal_code">Code postal :</label></td>
|
||||||
<td><label for="phone_number">Numéro de téléphone :</label></td>
|
<td><input style="width: 100%;" type="number" id="postal_code" name="postal_code"
|
||||||
<td><input style="width: 100%;" type="text" id="phone_number" name="phone_number" value="<?php if (isset($_POST["phone_number"])) echo $_POST["phone_number"] ?>" /></td>
|
value="<?php if (isset($user)) echo $user->postal_code ?>" min="1000"
|
||||||
</tr>
|
max="95999" required/></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td><label for="role">Rôle :</label></td>
|
<tr>
|
||||||
<td><select style="width: 100%;" id="role" name="role" onchange="selectRole()">
|
<td><label for="city">Ville :</label></td>
|
||||||
<option value="participant">Participant</option>
|
<td><input style="width: 100%;" type="text" id="city" name="city"
|
||||||
<option value="encadrant">Encadrant</option>
|
value="<?php if (isset($user)) echo $user->city ?>"/></td>
|
||||||
</select></td>
|
</tr>
|
||||||
</tr>
|
<tr>
|
||||||
<tr>
|
<td><label for="country">Pays :</label></td>
|
||||||
<td><label id="school_label" for="school">Établissement dans lequel l'élève étudie :</label></td>
|
<td><input style="width: 100%;" type="text" id="country" name="country"
|
||||||
<td><input style="width: 100%;" type="text" id="school" name="school" value="<?php if (isset($_POST["school"])) echo $_POST["school"] ?>" /></td>
|
value="<?= isset($user) ? $user->country : "France" ?>" required/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><label id="class_label" for="class">Classe :</label></td>
|
<td><label for="phone_number">Numéro de téléphone :</label></td>
|
||||||
<td><select style="width: 100%;" id="class" name="class">
|
<td><input style="width: 100%;" type="text" id="phone_number" name="phone_number"
|
||||||
<option value="terminale">Terminale</option>
|
value="<?php if (isset($user)) echo $user->phone_number ?>"/></td>
|
||||||
<option value="premiere">Première</option>
|
</tr>
|
||||||
<option value="seconde">Seconde ou inférieur</option>
|
<tr>
|
||||||
</select></td>
|
<td><label for="role">Rôle :</label></td>
|
||||||
</tr>
|
<td><select style="width: 100%;" id="role" name="role" onchange="selectRole()">
|
||||||
<tr>
|
<option value="participant"><?= Role::getTranslatedName(Role::PARTICIPANT) ?></option>
|
||||||
<td><label id="responsible_name_label" for="responsible_name">Nom du responsable légal :</label></td>
|
<option value="encadrant"><?= Role::getTranslatedName(Role::ENCADRANT) ?></option>
|
||||||
<td><input style="width: 100%;" type="text" id="responsible_name" name="responsible_name" value="<?php if (isset($_POST["responsible_name"])) echo $_POST["responsible_name"] ?>" /></td>
|
</select></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><label id="responsible_phone_label" for="responsible_phone">Téléphone du responsable légal :</label></td>
|
<td><label id="school_label" for="school">Établissement dans lequel l'élève étudie :</label></td>
|
||||||
<td><input style="width: 100%;" type="text" id="responsible_phone" name="responsible_phone" value="<?php if (isset($_POST["responsible_phone"])) echo $_POST["responsible_phone"] ?>" /></td>
|
<td><input style="width: 100%;" type="text" id="school" name="school"
|
||||||
</tr>
|
value="<?php if (isset($user)) echo $user->school ?>"/></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td><label id="responsible_email_label" for="responsible_email">Email du responsable légal :</label></td>
|
<tr>
|
||||||
<td><input style="width: 100%;" type="text" id="responsible_email" name="responsible_email" value="<?php if (isset($_POST["responsible_email"])) echo $_POST["responsible_email"] ?>" /></td>
|
<td><label id="class_label" for="class">Classe :</label></td>
|
||||||
</tr>
|
<td><select style="width: 100%;" id="class" name="class">
|
||||||
<tr>
|
<option value="terminale"><?= SchoolClass::getTranslatedName(SchoolClass::TERMINALE) ?></option>
|
||||||
<td><label id="description_label" for="description">Description :</label></td>
|
<option value="premiere"><?= SchoolClass::getTranslatedName(SchoolClass::PREMIERE) ?></option>
|
||||||
<td><textarea style="width: 100%;" id="description" name="description"><?php if (isset($_POST["description"])) echo $_POST["description"] ?></textarea></td>
|
<option value="seconde"><?= SchoolClass::getTranslatedName(SchoolClass::SECONDE) ?></option>
|
||||||
</tr>
|
</select></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td colspan="2"><input style="width: 100%;" type="submit" value="S'inscrire" /></td>
|
<tr>
|
||||||
</tr>
|
<td><label id="responsible_name_label" for="responsible_name">Nom du responsable légal :</label></td>
|
||||||
</table>
|
<td><input style="width: 100%;" type="text" id="responsible_name" name="responsible_name"
|
||||||
</form>
|
value="<?php if (isset($user)) echo $user->responsible_name ?>"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label id="responsible_phone_label" for="responsible_phone">Téléphone du responsable légal :</label>
|
||||||
|
</td>
|
||||||
|
<td><input style="width: 100%;" type="text" id="responsible_phone" name="responsible_phone"
|
||||||
|
value="<?php if (isset($user)) echo $user->responsible_phone ?>"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label id="responsible_email_label" for="responsible_email">Email du responsable légal :</label>
|
||||||
|
</td>
|
||||||
|
<td><input style="width: 100%;" type="text" id="responsible_email" name="responsible_email"
|
||||||
|
value="<?php if (isset($user)) echo $user->responsible_email ?>"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label id="description_label" for="description">Description :</label></td>
|
||||||
|
<td><textarea style="width: 100%;" id="description"
|
||||||
|
name="description"><?php if (isset($user)) echo $user->description ?></textarea>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><input style="width: 100%;" type="submit" value="S'inscrire"/></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function selectRole() {
|
function selectRole() {
|
||||||
switch (document.getElementById("role").value) {
|
switch (document.getElementById("role").value) {
|
||||||
case "participant":
|
case "participant":
|
||||||
document.getElementById("school_label").style.display = "block";
|
document.getElementById("school_label").style.display = "block";
|
||||||
document.getElementById("school").style.display = "block";
|
document.getElementById("school").style.display = "block";
|
||||||
document.getElementById("school").require = "true";
|
document.getElementById("school").require = "true";
|
||||||
document.getElementById("class_label").style.display = "block";
|
document.getElementById("class_label").style.display = "block";
|
||||||
document.getElementById("class").style.display = "block";
|
document.getElementById("class").style.display = "block";
|
||||||
document.getElementById("responsible_name_label").style.display = "block";
|
document.getElementById("responsible_name_label").style.display = "block";
|
||||||
document.getElementById("responsible_name").style.display = "block";
|
document.getElementById("responsible_name").style.display = "block";
|
||||||
document.getElementById("responsible_phone_label").style.display = "block";
|
document.getElementById("responsible_phone_label").style.display = "block";
|
||||||
document.getElementById("responsible_phone").style.display = "block";
|
document.getElementById("responsible_phone").style.display = "block";
|
||||||
document.getElementById("responsible_email_label").style.display = "block";
|
document.getElementById("responsible_email_label").style.display = "block";
|
||||||
document.getElementById("responsible_email").style.display = "block";
|
document.getElementById("responsible_email").style.display = "block";
|
||||||
document.getElementById("description_label").style.display = "none";
|
document.getElementById("description_label").style.display = "none";
|
||||||
document.getElementById("description").style.display = "none";
|
document.getElementById("description").style.display = "none";
|
||||||
break;
|
break;
|
||||||
case "encadrant":
|
case "encadrant":
|
||||||
document.getElementById("school_label").style.display = "none";
|
document.getElementById("school_label").style.display = "none";
|
||||||
document.getElementById("school").style.display = "none";
|
document.getElementById("school").style.display = "none";
|
||||||
document.getElementById("school").require = "false";
|
document.getElementById("school").require = "false";
|
||||||
document.getElementById("class_label").style.display = "none";
|
document.getElementById("class_label").style.display = "none";
|
||||||
document.getElementById("class").style.display = "none";
|
document.getElementById("class").style.display = "none";
|
||||||
document.getElementById("responsible_name_label").style.display = "none";
|
document.getElementById("responsible_name_label").style.display = "none";
|
||||||
document.getElementById("responsible_name").style.display = "none";
|
document.getElementById("responsible_name").style.display = "none";
|
||||||
document.getElementById("responsible_phone_label").style.display = "none";
|
document.getElementById("responsible_phone_label").style.display = "none";
|
||||||
document.getElementById("responsible_phone").style.display = "none";
|
document.getElementById("responsible_phone").style.display = "none";
|
||||||
document.getElementById("responsible_email_label").style.display = "none";
|
document.getElementById("responsible_email_label").style.display = "none";
|
||||||
document.getElementById("responsible_email").style.display = "none";
|
document.getElementById("responsible_email").style.display = "none";
|
||||||
document.getElementById("description_label").style.display = "block";
|
document.getElementById("description_label").style.display = "block";
|
||||||
document.getElementById("description").style.display = "block";
|
document.getElementById("description").style.display = "block";
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
selectRole();
|
selectRole();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
|
@ -98,9 +98,9 @@ if (isset($error_message) && $error_message === FALSE) {
|
|||||||
<tr>
|
<tr>
|
||||||
<td><label for="class">Classe :</label></td>
|
<td><label for="class">Classe :</label></td>
|
||||||
<td><select style="width: 100%" id="class" name="class">
|
<td><select style="width: 100%" id="class" name="class">
|
||||||
<option value="terminale" <?php if ($user->getClass() == "TERMINALE") echo "selected" ?>>Terminale</option>
|
<option value="terminale" <?php if ($user->getClass() == SchoolClass::TERMINALE) echo "selected" ?>><?= SchoolClass::getTranslatedName(SchoolClass::TERMINALE) ?></option>
|
||||||
<option value="premiere" <?php if ($user->getClass() == "PREMIERE") echo "selected" ?>>Première</option>
|
<option value="premiere" <?php if ($user->getClass() == SchoolClass::PREMIERE) echo "selected" ?>><?= SchoolClass::getTranslatedName(SchoolClass::PREMIERE) ?></option>
|
||||||
<option value="seconde" <?php if ($user->getClass() == "SECONDE") echo "selected" ?>>Seconde ou inférieur</option>
|
<option value="seconde" <?php if ($user->getClass() == SchoolClass::SECONDE) echo "selected" ?>><?= SchoolClass::getTranslatedName(SchoolClass::SECONDE) ?></option>
|
||||||
</select></td>
|
</select></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
Loading…
Reference in New Issue
Block a user