plateforme-corres2math/server_files/views/inscription.php

131 lines
5.7 KiB
PHP
Raw Normal View History

<?php
require_once "header.php";
?>
<div class="mt-4 mb-4">
<h1 class="display-4">Formulaire d'inscription</h1>
</div>
<?php
/** @var NewUser $user */
if (isset($user) && !$has_error) {
?>
<div class="alert alert-success">
Votre inscription est validée ! Merci désormais de confirmer votre boîte mail pour valider votre adresse.
</div>
<?php } else if (isset($_SESSION["user_id"])) { ?>
<div class="alert alert-danger">
Vous êtes déjà connecté !
</div>
<?php } elseif(date("Y-m-d H:i:s") >= $CONFIG->getInscriptionDate()) { ?>
<div class="alert alert-danger">
La date limite d'inscription est dépassée.
</div>
<?php } else { ?>
<form method="POST">
<div class="form-group row">
<label for="role">Rôle :</label>
<select id="role" name="role" onchange="selectRole()" class="custom-select">
<option value="participant"><?= Role::getTranslatedName(Role::PARTICIPANT) ?></option>
<option value="encadrant"><?= Role::getTranslatedName(Role::ENCADRANT) ?></option>
</select>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="surname">Nom :</label>
<input class="form-control" type="text" id="surname" name="surname"
value="<?php if (isset($user)) echo $user->surname ?>" required/>
</div>
<div class="form-group col-md-6">
<label for="first_name">Prénom :</label>
<input class="form-control" type="text" id="first_name" name="first_name"
value="<?php if (isset($user)) echo $user->first_name ?>" required/>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="email">E-mail :</label>
<input class="form-control" type="email" id="email" name="email"
value="<?php if (isset($user)) echo $user->email ?>"
required/>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="password">Mot de passe :</label>
<input class="form-control" type="password" id="password" name="password" required/>
</div>
<div class="form-group col-md-6">
<label for="confirm_password">Confirmer le mot de passe :</label>
<input class="form-control" type="password" id="confirm_password" name="confirm_password" required/>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label id="school_label" for="school">Établissement dans lequel l'élève étudie :</label>
<input class="form-control" type="text" id="school" name="school"
value="<?php if (isset($user)) echo $user->school ?>"/>
</div>
<div class="form-group col-md-6">
<label id="class_label" for="class">Classe :</label>
<select id="class" name="class" class="custom-select">
<option value="terminale"><?= SchoolClass::getTranslatedName(SchoolClass::TERMINALE) ?></option>
<option value="premiere"><?= SchoolClass::getTranslatedName(SchoolClass::PREMIERE) ?></option>
<option value="seconde"><?= SchoolClass::getTranslatedName(SchoolClass::SECONDE) ?></option>
</select>
</div>
</div>
<div class="form-group row">
<label id="description_label" for="description">Description :</label>
<textarea class="form-control" id="description"
name="description"><?php if (isset($user)) echo $user->description ?></textarea>
</div>
<div class="form-row">
<label for="receive_animath_mails">J'accepte de recevoir des mails de la part d'Animath (<em>facultatif</em>) :</label>
<input class="form-control" type="checkbox" id="receive_animath_mails" name="receive_animath_mails"
<?= isset($user) && $user->receive_animath_mails ? "checked" : "" ?> />
</div>
<div class="form-group row">
<input class="btn btn-primary btn-lg btn-block" name="register" type="submit" value="S'inscrire"/>
</div>
</form>
<script>
function selectRole() {
switch (document.getElementById("role").value) {
case "participant":
document.getElementById("school_label").style.display = "block";
document.getElementById("school").style.display = "block";
document.getElementById("class_label").style.display = "block";
document.getElementById("class").style.display = "block";
document.getElementById("description_label").style.display = "none";
document.getElementById("description").style.display = "none";
break;
case "encadrant":
document.getElementById("school_label").style.display = "none";
document.getElementById("school").style.display = "none";
document.getElementById("class_label").style.display = "none";
document.getElementById("class").style.display = "none";
document.getElementById("description_label").style.display = "block";
document.getElementById("description").style.display = "block";
break;
}
}
selectRole();
</script>
<?php } ?>
<?php require_once "footer.php" ?>