1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2024-12-05 02:06:52 +00:00

Calendrier

This commit is contained in:
galaxyoyo 2019-09-12 15:35:16 +02:00
parent 762797142b
commit 416264b53c
5 changed files with 192 additions and 5 deletions

View File

@ -25,6 +25,7 @@ $ROUTES = [];
$ROUTES["^(|accueil|index|accueil\.php|accueil\.html|accueil\.py|index\.php|index\.html|index\.py)$"] = ["server_files/controllers/index.php"];
$ROUTES["^ajouter_equipe$"] = ["server_files/controllers/ajouter_equipe.php"];
$ROUTES["^calendrier$"] = ["server_files/controllers/calendrier.php"];
$ROUTES["^confirmer_mail/([a-z0-9]*)/?$"] = ["server_files/controllers/confirmer_mail.php", "token"];
$ROUTES["^connexion/(confirmation-mail)/?$"] = ["server_files/controllers/connexion.php", "confirmation-mail"];
$ROUTES["^connexion/(mdp_oublie)/?$"] = ["server_files/controllers/connexion.php", "mdp_oublie"];

View File

@ -0,0 +1,79 @@
<?php
if ($_SESSION["role"] != Role::ADMIN)
require_once "server_files/403.php";
$has_error = false;
$error_message = null;
if (isset($_POST["update_calendar"])) {
$update_calendar = new UpdateCalendar($_POST);
try {
$update_calendar->makeVerifications();
$update_calendar->updateCalendar();
} catch (AssertionError $e) {
$has_error = true;
$error_message = $e->getMessage();
}
}
class UpdateCalendar
{
private $date_inscription;
private $time_inscription;
private $date_start_phase1;
private $time_start_phase1;
private $date_end_phase1;
private $time_end_phase1;
private $date_start_phase2;
private $time_start_phase2;
private $date_end_phase2;
private $time_end_phase2;
private $date_start_phase3;
private $time_start_phase3;
private $date_end_phase3;
private $time_end_phase3;
private $date_start_phase4;
private $time_start_phase4;
private $date_end_phase4;
private $time_end_phase4;
public function __construct($data)
{
foreach ($data as $key => $value)
$this->$key = htmlspecialchars($value);
}
public function makeVerifications()
{
ensure(dateWellFormed($this->date_inscription . " " . $this->time_inscription), "La date d'inscription n'est pas bien formée.");
ensure(dateWellFormed($this->date_start_phase1 . " " . $this->time_start_phase1), "La date de début de la phase 1 n'est pas bien formée.");
ensure(dateWellFormed($this->date_end_phase1 . " " . $this->time_end_phase1), "La date de fin de la phase 1 n'est pas bien formée.");
ensure(dateWellFormed($this->date_start_phase2 . " " . $this->time_start_phase2), "La date de début de la phase 2 n'est pas bien formée.");
ensure(dateWellFormed($this->date_end_phase2 . " " . $this->time_end_phase2), "La date de fin de la phase 2 n'est pas bien formée.");
ensure(dateWellFormed($this->date_start_phase3 . " " . $this->time_start_phase3), "La date de début de la phase 3 n'est pas bien formée.");
ensure(dateWellFormed($this->date_end_phase3 . " " . $this->time_end_phase3), "La date de fin de la phase 3 n'est pas bien formée.");
ensure(dateWellFormed($this->date_start_phase4 . " " . $this->time_start_phase4), "La date de début de la phase 4 n'est pas bien formée.");
ensure(dateWellFormed($this->date_end_phase4 . " " . $this->time_end_phase4), "La date de fin de la phase 4 n'est pas bien formée.");
}
public function updateCalendar()
{
global $CONFIG, $URL_BASE;
$CONFIG->setInscriptionDate($this->date_inscription . " " . $this->time_inscription);
$CONFIG->setStartPhase1Date($this->date_start_phase1 . " " . $this->time_start_phase1);
$CONFIG->setEndPhase1Date($this->date_end_phase1 . " " . $this->time_end_phase1);
$CONFIG->setStartPhase2Date($this->date_start_phase2 . " " . $this->time_start_phase2);
$CONFIG->setEndPhase2Date($this->date_end_phase2 . " " . $this->time_end_phase2);
$CONFIG->setStartPhase3Date($this->date_start_phase3 . " " . $this->time_start_phase3);
$CONFIG->setEndPhase3Date($this->date_end_phase3 . " " . $this->time_end_phase3);
$CONFIG->setStartPhase4Date($this->date_start_phase4 . " " . $this->time_start_phase4);
$CONFIG->setEndPhase4Date($this->date_end_phase4 . " " . $this->time_end_phase4);
header("Location: $URL_BASE/problemes");
exit();
}
}
require_once "server_files/views/calendrier.php";

View File

@ -55,7 +55,7 @@ function quitTeam()
else
$DB->exec("UPDATE `teams` SET `encadrant` = NULL WHERE `encadrant` = $user_id;");
$user->setTeamId(null);
for ($i = 1; $i <= 5; ++$i) {
for ($i = 1; $i <= 4; ++$i) {
/** @noinspection SqlResolve */
$DB->exec("UPDATE `teams` SET `participant_$i` = `participant_" . strval($i + 1) . "`, `participant_" . strval($i + 1) . "` = NULL WHERE `participant_$i` IS NULL;");
}

View File

@ -0,0 +1,96 @@
<?php require_once "header.php"; ?>
<form method="post">
<table style="width: 100%;">
<tbody>
<tr>
<td style="width: 30%;">
<label for="date_inscription">Fin des inscriptions :</label>
</td>
<td style="width: 70%;">
<input style="width: 49%;" type="date" id="date_inscription" name="date_inscription" value="<?= substr($CONFIG->getInscriptionDate(), 0, 10) ?>" />
<input style="width: 49%;" type="time" id="time_inscription" name="time_inscription" value="<?= substr($CONFIG->getInscriptionDate(), 11, 5) ?>" />
</td>
</tr>
<tr>
<td style="width: 30%;">
<label for="date_start_phase1">Début de la phase 1 :</label>
</td>
<td style="width: 70%;">
<input style="width: 49%;" type="date" id="date_start_phase1" name="date_start_phase1" value="<?= substr($CONFIG->getStartPhase1Date(), 0, 10) ?>" />
<input style="width: 49%;" type="time" id="time_start_phase1" name="time_start_phase1" value="<?= substr($CONFIG->getStartPhase1Date(), 11, 5) ?>" />
</td>
</tr>
<tr>
<td style="width: 30%;">
<label for="date_end_phase1">Fin de la phase 1 :</label>
</td>
<td style="width: 70%;">
<input style="width: 49%;" type="date" id="date_end_phase1" name="date_end_phase1" value="<?= substr($CONFIG->getEndPhase1Date(), 0, 10) ?>" />
<input style="width: 49%;" type="time" id="time_end_phase1" name="time_end_phase1" value="<?= substr($CONFIG->getEndPhase1Date(), 11, 5) ?>" />
</td>
</tr>
<tr>
<td style="width: 30%;">
<label for="date_start_phase1">Début de la phase 2 :</label>
</td>
<td style="width: 70%;">
<input style="width: 49%;" type="date" id="date_start_phase2" name="date_start_phase2" value="<?= substr($CONFIG->getStartPhase2Date(), 0, 10) ?>" />
<input style="width: 49%;" type="time" id="time_start_phase2" name="time_start_phase2" value="<?= substr($CONFIG->getStartPhase2Date(), 11, 5) ?>" />
</td>
</tr>
<tr>
<td style="width: 30%;">
<label for="date_end_phase1">Fin de la phase 2 :</label>
</td>
<td style="width: 70%;">
<input style="width: 49%;" type="date" id="date_end_phase2" name="date_end_phase2" value="<?= substr($CONFIG->getEndPhase2Date(), 0, 10) ?>" />
<input style="width: 49%;" type="time" id="time_end_phase2" name="time_end_phase2" value="<?= substr($CONFIG->getEndPhase2Date(), 11, 5) ?>" />
</td>
</tr>
<tr>
<td style="width: 30%;">
<label for="date_start_phase1">Début de la phase 3 :</label>
</td>
<td style="width: 70%;">
<input style="width: 49%;" type="date" id="date_start_phase3" name="date_start_phase3" value="<?= substr($CONFIG->getStartPhase3Date(), 0, 10) ?>" />
<input style="width: 49%;" type="time" id="time_start_phase3" name="time_start_phase3" value="<?= substr($CONFIG->getStartPhase3Date(), 11, 5) ?>" />
</td>
</tr>
<tr>
<td style="width: 30%;">
<label for="date_end_phase1">Fin de la phase 3 :</label>
</td>
<td style="width: 70%;">
<input style="width: 49%;" type="date" id="date_end_phase3" name="date_end_phase3" value="<?= substr($CONFIG->getEndPhase3Date(), 0, 10) ?>" />
<input style="width: 49%;" type="time" id="time_end_phase3" name="time_end_phase3" value="<?= substr($CONFIG->getEndPhase3Date(), 11, 5) ?>" />
</td>
</tr>
<tr>
<td style="width: 30%;">
<label for="date_start_phase1">Début de la phase 4 :</label>
</td>
<td style="width: 70%;">
<input style="width: 49%;" type="date" id="date_start_phase4" name="date_start_phase4" value="<?= substr($CONFIG->getStartPhase4Date(), 0, 10) ?>" />
<input style="width: 49%;" type="time" id="time_start_phase4" name="time_start_phase4" value="<?= substr($CONFIG->getStartPhase4Date(), 11, 5) ?>" />
</td>
</tr>
<tr>
<td style="width: 30%;">
<label for="date_end_phase1">Fin de la phase 4 :</label>
</td>
<td style="width: 70%;">
<input style="width: 49%;" type="date" id="date_end_phase4" name="date_end_phase4" value="<?= substr($CONFIG->getEndPhase4Date(), 0, 10) ?>" />
<input style="width: 49%;" type="time" id="time_end_phase4" name="time_end_phase4" value="<?= substr($CONFIG->getEndPhase4Date(), 11, 5) ?>" />
</td>
</tr>
<tr>
<td colspan="2" style="width: 100%;">
<input style="width: 100%;" type="submit" name="update_calendar" value="Mettre à jour le calendrier" />
</td>
</tr>
</tbody>
</table>
</form>
<?php require_once "footer.php";

View File

@ -6,7 +6,6 @@
<thead style="border: 1px solid black">
<tr>
<th style="border: 1px solid black; text-align: center">Problème</th>
<th style="border: 1px solid black; text-align: center">Inscription avant le</th>
</tr>
</thead>
<tbody style="border: 1px solid black">
@ -15,7 +14,6 @@
?>
<tr style="border: 1px solid black">
<td style="border: 1px solid black; text-align: center"><a href="<?= $URL_BASE ?>/probleme/<?= $i ?>"><?= $i ?></a></td>
<td style="border: 1px solid black; text-align: center"><?= formatDate($CONFIG->getInscriptionDate(), true) ?></td>
</tr>
<?php
}
@ -24,9 +22,22 @@
<tfoot style="border: 1px solid black">
<tr>
<th style="border: 1px solid black; text-align: center">Problème</th>
<th style="border: 1px solid black; text-align: center">Inscription avant le</th>
</tr>
</tfoot>
</table>
<?php require_once "footer.php" ?>
<hr />
<h2>Calendrier</h2>
Inscription avant le : <strong><?= formatDate($CONFIG->getInscriptionDate(), true) ?></strong><br />
Phase 1 : Du <strong><?= formatDate($CONFIG->getStartPhase1Date(), true) ?></strong> au <strong><?= formatDate($CONFIG->getEndPhase1Date(), true) ?></strong><br />
Phase 2 : Du <strong><?= formatDate($CONFIG->getStartPhase2Date(), true) ?></strong> au <strong><?= formatDate($CONFIG->getEndPhase2Date(), true) ?></strong><br />
Phase 3 : Du <strong><?= formatDate($CONFIG->getStartPhase3Date(), true) ?></strong> au <strong><?= formatDate($CONFIG->getEndPhase3Date(), true) ?></strong><br />
Phase 4 : Du <strong><?= formatDate($CONFIG->getStartPhase4Date(), true) ?></strong> au <strong><?= formatDate($CONFIG->getEndPhase4Date(), true) ?></strong><br />
<?php if ($_SESSION["role"] == Role::ADMIN) { ?>
<a href="<?= $URL_BASE ?>/calendrier">Modifier le calendrier</a>
<?php }
require_once "footer.php" ?>