1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2024-12-26 06:22:22 +00:00

Améliorations du code

This commit is contained in:
Yohann 2019-09-08 01:35:05 +02:00 committed by galaxyoyo
parent 3cc66ef783
commit a25ec69ae9
23 changed files with 558 additions and 457 deletions

View File

@ -8,6 +8,7 @@ class Document
private $tournament_id; private $tournament_id;
private $type; private $type;
private $uploaded_at; private $uploaded_at;
private $version;
private function __construct() {} private function __construct() {}
@ -21,9 +22,14 @@ class Document
if ($data === false) if ($data === false)
return null; return null;
$user = new Document(); return self::fromData($data);
$user->fill($data); }
return $user;
public static function fromData($data)
{
$doc = new Document();
$doc->fill($data);
return $doc;
} }
private function fill($data) private function fill($data)
@ -34,6 +40,7 @@ class Document
$this->tournament_id = $data["tournament"]; $this->tournament_id = $data["tournament"];
$this->type = DocumentType::fromName($data["type"]); $this->type = DocumentType::fromName($data["type"]);
$this->uploaded_at = $data["uploaded_at"]; $this->uploaded_at = $data["uploaded_at"];
$this->version = isset($data["version"]) ? $data["version"] : 1;
} }
public function getFileId() public function getFileId()
@ -65,6 +72,11 @@ class Document
{ {
return $this->uploaded_at; return $this->uploaded_at;
} }
public function getVersion()
{
return $this->version;
}
} }
class Solution class Solution
@ -74,6 +86,7 @@ class Solution
private $tournament_id; private $tournament_id;
private $problem; private $problem;
private $uploaded_at; private $uploaded_at;
private $version;
private function __construct() {} private function __construct() {}
@ -87,9 +100,14 @@ class Solution
if ($data === false) if ($data === false)
return null; return null;
$user = new Solution(); return self::fromData($data);
$user->fill($data); }
return $user;
public static function fromData($data)
{
$sol = new Solution();
$sol->fill($data);
return $sol;
} }
private function fill($data) private function fill($data)
@ -99,6 +117,7 @@ class Solution
$this->tournament_id = $data["tournament"]; $this->tournament_id = $data["tournament"];
$this->problem = $data["problem"]; $this->problem = $data["problem"];
$this->uploaded_at = $data["uploaded_at"]; $this->uploaded_at = $data["uploaded_at"];
$this->version = isset($data["version"]) ? $data["version"] : 1;
} }
public function getFileId() public function getFileId()
@ -125,15 +144,21 @@ class Solution
{ {
return $this->uploaded_at; return $this->uploaded_at;
} }
public function getVersion()
{
return $this->version;
}
} }
class Synthese class Synthesis
{ {
private $file_id; private $file_id;
private $team_id; private $team_id;
private $tournament_id; private $tournament_id;
private $dest; private $dest;
private $uploaded_at; private $uploaded_at;
private $version;
private function __construct() {} private function __construct() {}
@ -147,9 +172,14 @@ class Synthese
if ($data === false) if ($data === false)
return null; return null;
$user = new Synthese(); return self::fromData($data);
$user->fill($data); }
return $user;
public static function fromData($data)
{
$synthese = new Synthesis();
$synthese->fill($data);
return $synthese;
} }
private function fill($data) private function fill($data)
@ -159,6 +189,7 @@ class Synthese
$this->tournament_id = $data["tournament"]; $this->tournament_id = $data["tournament"];
$this->dest = DestType::fromName($data["dest"]); $this->dest = DestType::fromName($data["dest"]);
$this->uploaded_at = $data["uploaded_at"]; $this->uploaded_at = $data["uploaded_at"];
$this->version = isset($data["version"]) ? $data["version"] : 1;
} }
public function getFileId() public function getFileId()
@ -185,6 +216,11 @@ class Synthese
{ {
return $this->uploaded_at; return $this->uploaded_at;
} }
public function getVersion()
{
return $this->version;
}
} }
class DestType class DestType
@ -233,7 +269,7 @@ class DocumentType
const PHOTO_CONSENT = 1; const PHOTO_CONSENT = 1;
const SANITARY_PLUG = 2; const SANITARY_PLUG = 2;
const SOLUTION = 3; const SOLUTION = 3;
const SYNTHESE = 4; const SYNTHESIS = 4;
public static function getTranslatedName($type) { public static function getTranslatedName($type) {
switch ($type) { switch ($type) {
@ -261,7 +297,7 @@ class DocumentType
case self::SOLUTION: case self::SOLUTION:
return "SOLUTION"; return "SOLUTION";
default: default:
return "SYNTHESE"; return "SYNTHESIS";
} }
} }
@ -276,7 +312,7 @@ class DocumentType
case "SOLUTION": case "SOLUTION":
return self::SOLUTION; return self::SOLUTION;
default: default:
return self::SYNTHESE; return self::SYNTHESIS;
} }
} }
} }

View File

@ -1,5 +1,6 @@
<?php <?php
/** @noinspection SqlAggregates */
class Tournament class Tournament
{ {
private $id; private $id;
@ -16,7 +17,9 @@ class Tournament
private $organizers = []; private $organizers = [];
private $year; private $year;
private function __construct() {} private function __construct()
{
}
public static function fromId($id) public static function fromId($id)
{ {
@ -62,6 +65,28 @@ class Tournament
return $tournament; return $tournament;
} }
public static function getAllTournaments($include_final = true, $only_future = false)
{
global $DB, $YEAR;
$sql = "SELECT * FROM `tournaments` WHERE ";
if (!$include_final)
$sql .= "`final` = 0 AND ";
if ($only_future)
$sql .= "`date_start` > CURRENT_DATE AND ";
$sql .= "`year` = $YEAR ORDER BY `date_start`, `name`;";
$req = $DB->query($sql);
$tournaments = [];
while (($data = $req->fetch()) !== false) {
$tournament = new Tournament();
$tournament->fill($data);
$tournaments[] = $tournament;
}
return $tournaments;
}
private function fill($data) private function fill($data)
{ {
$this->id = $data["id"]; $this->id = $data["id"];
@ -223,6 +248,22 @@ class Tournament
$DB->prepare("UPDATE `tournaments` SET `final` = ? WHERE `id` = ?;")->execute([$final, $this->id]); $DB->prepare("UPDATE `tournaments` SET `final` = ? WHERE `id` = ?;")->execute([$final, $this->id]);
} }
public function getAllTeams()
{
global $DB, $YEAR;
if ($this->final)
$req = $DB->query("SELECT `id` FROM `teams` WHERE `final_selection` AND `year` = $YEAR;");
else
$req = $DB->query("SELECT `id` FROM `teams` WHERE `tournament` = $this->id AND `year` = $YEAR;");
$teams = [];
while (($data = $req->fetch()) !== false)
$teams[] = Team::fromId($data["id"]);
return $teams;
}
public function getOrganizers() public function getOrganizers()
{ {
return $this->organizers; return $this->organizers;
@ -242,4 +283,55 @@ class Tournament
{ {
return $this->year; return $this->year;
} }
public function getAllDocuments($team_id = -1)
{
global $DB;
$req = $DB->query("SELECT * FROM `documents` AS `t1` "
. "INNER JOIN (SELECT `user`, `type`, `tournament`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `documents` GROUP BY `tournament`, `team`, `type`) `t2` "
. "ON `t1`.`user` = `t2`.`user` AND `t1`.`type` = `t2`.`type` AND `t1`.`tournament` = `t2`.`tournament` "
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`tournament` = $this->id " . ($team_id == -1 ? "" : "AND `t1`.`team` = $team_id") . " ORDER BY `t1`.`team`, `t1`.`type`;");
$docs = [];
while (($data = $req->fetch()) !== false)
$docs[] = Document::fromData($data);
return $docs;
}
public function getAllSolutions($team_id = -1)
{
global $DB;
$req = $DB->query("SELECT * FROM `solutions` AS `t1` "
. "INNER JOIN (SELECT `team`, `problem`, `tournament`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `solutions` GROUP BY `tournament`, `team`, `problem`) `t2` "
. "ON `t1`.`team` = `t2`.`team` AND `t1`.`problem` = `t2`.`problem` AND `t1`.`tournament` = `t2`.`tournament` "
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`tournament` = $this->id " . ($team_id == -1 ? "" : "AND `t1`.`team` = $team_id") . " ORDER BY `t1`.`team`, `t1`.`problem`;");
$sols = [];
while (($data = $req->fetch()) !== false)
$sols[] = Solution::fromData($data);
return $sols;
}
public function getAllSyntheses($team_id = -1)
{
global $DB;
$req = $DB->query("SELECT * FROM `syntheses` AS `t1` "
. "INNER JOIN (SELECT `team`, `dest`, `tournament`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `syntheses` GROUP BY `tournament`, `team`, `dest`) `t2` "
. "ON `t1`.`team` = `t2`.`team` AND `t1`.`dest` = `t2`.`dest` AND `t1`.`tournament` = `t2`.`tournament` "
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`tournament` = $this->id " . ($team_id == -1 ? "" : "AND `t1`.`team` = $team_id") . " ORDER BY `t1`.`team`, `t1`.`dest`;");
$syntheses = [];
while (($data = $req->fetch()) !== false)
$syntheses[] = Synthesis::fromData($data);
return $syntheses;
}
} }

View File

@ -359,4 +359,33 @@ class User
{ {
return $this->inscription_date; return $this->inscription_date;
} }
public function getAllDocuments($tournament_id)
{
global $DB;
$req = $DB->query("SELECT * FROM `documents` AS `t1` "
. "INNER JOIN (SELECT `user`, `type`, `tournament`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `documents` GROUP BY `tournament`, `type`) `t2` "
. "ON `t1`.`user` = `t2`.`user` AND `t1`.`type` = `t2`.`type` AND `t1`.`tournament` = `t2`.`tournament` "
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`tournament` = $tournament_id AND `t1`.`user` = $this->id ORDER BY `t1`.`type`;");
$docs = [];
while (($data = $req->fetch()) !== false)
$docs[] = Document::fromData($data);
return $docs;
}
public function getOrganizedTournaments()
{
global $DB;
$req = $DB->query("SELECT `tournament` FROM `organizers` JOIN `tournaments` ON `tournaments`.`id` = `tournament` WHERE `organizer` = $this->id ORDER BY `date_start`, `name`;");
$tournaments = [];
while (($data = $req->fetch()) !== false)
$tournaments[] = Tournament::fromId($data["tournament"]);
return $tournaments;
}
} }

View File

@ -6,6 +6,7 @@ if (!isset($_SESSION["user_id"]) || $_SESSION["role"] != Role::ORGANIZER && $_SE
$trigram = htmlspecialchars($_GET["trigram"]); $trigram = htmlspecialchars($_GET["trigram"]);
$team = Team::fromTrigram($trigram); $team = Team::fromTrigram($trigram);
$tournament = Tournament::fromId($team->getTournamentId());
if ($team === null) if ($team === null)
require_once "server_files/404.php"; require_once "server_files/404.php";
@ -35,20 +36,17 @@ if (isset($_POST["select"])) {
copy("$LOCAL_PATH/files/$old_id", "$LOCAL_PATH/files/$id"); copy("$LOCAL_PATH/files/$old_id", "$LOCAL_PATH/files/$id");
$req = $DB->prepare("INSERT INTO `solutions`(`file_id`, `team`, `tournament`, `problem`) $req = $DB->prepare("INSERT INTO `solutions`(`file_id`, `team`, `tournament`, `problem`) VALUES (?, ?, ?, ?);");
VALUES (?, ?, ?, ?);");
$req->execute([$id, $team->getId(), $_SESSION["final_id"], $sol_data["problem"]]); $req->execute([$id, $team->getId(), $_SESSION["final_id"], $sol_data["problem"]]);
} }
} }
$documents_req = $DB->prepare("SELECT `file_id`, `user`, `type`, COUNT(`type`) AS `version` FROM `documents` WHERE `team` = ? AND `tournament` = ? GROUP BY `user`, `type` ORDER BY `user`, `type` ASC, MAX(`uploaded_at`) DESC;"); // TODO Télécharger en zip les documents personnels
$documents_req->execute([$team->getId(), $team->getId()]);
if ($team->isSelectedForFinal()) { $documents = $tournament->getAllDocuments($team->getId());
$documents_final_req = $DB->prepare("SELECT `file_id`, `user`, `type`, COUNT(`type`) AS `version` FROM `documents` WHERE `team` = ? AND `tournament` != ? GROUP BY `user`, `type` ORDER BY `user`, `type` ASC, MAX(`uploaded_at`) DESC;"); $documents_final = null;
$documents_final_req->execute([$team->getId(), $FINAL->getId()]);
}
$tournament = Tournament::fromId($team->getTournamentId()); if ($team->isSelectedForFinal())
$documents_final = $FINAL->getAllDocuments($team->getId());
require_once "server_files/views/equipe.php"; require_once "server_files/views/equipe.php";

View File

@ -11,13 +11,16 @@ if ($_SESSION["role"] != Role::ORGANIZER && $_SESSION["role"] != Role::ADMIN) {
require_once "server_files/403.php"; require_once "server_files/403.php";
} }
if ($user === null) { if ($user === null)
require_once "server_files/404.php"; require_once "server_files/404.php";
}
$team = Team::fromId($user->getTeamId()); $team = Team::fromId($user->getTeamId());
$tournaments = $user->getOrganizedTournaments();
$documents_req = $DB->query("SELECT * FROM `documents` WHERE `user` = $id;"); if ($team != null) {
$tournaments_req = $DB->query("SELECT `tournament`, `name` FROM `organizers` JOIN `tournaments` ON `tournaments`.`id` = `tournament` WHERE `organizer` = $id ORDER BY `date_start`, `name`;"); $documents = $user->getAllDocuments($team->getTournamentId());
if ($team->isSelectedForFinal())
$documents_final = $user->getAllDocuments($FINAL->getId());
}
require_once "server_files/views/informations.php"; require_once "server_files/views/informations.php";

View File

@ -5,7 +5,7 @@ if (isset($_POST["leave_team"])) {
exit(); exit();
} }
$tournaments_response = $DB->query("SELECT `id`, `name` FROM `tournaments` WHERE `year` = '$YEAR';"); $tournaments = Tournament::getAllTournaments(false, true);
if (isset($_POST["send_document"])) { if (isset($_POST["send_document"])) {
$error_message = sendDocument(); $error_message = sendDocument();
@ -19,13 +19,17 @@ if (isset($_POST["request_validation"])) {
} }
if (isset($_SESSION["user_id"]) && isset($_SESSION["team"]) && $_SESSION["team"] !== null) { if (isset($_SESSION["user_id"]) && isset($_SESSION["team"]) && $_SESSION["team"] !== null) {
/** @var Team $team */ /**
* @var User $user
* @var Team $team
*/
$user = $_SESSION["user"];
$team = $_SESSION["team"]; $team = $_SESSION["team"];
$tournament = Tournament::fromId($team->getTournamentId()); $tournament = Tournament::fromId($team->getTournamentId());
$documents = $user->getAllDocuments($team->getTournamentId());
$documents_req = $DB->prepare("SELECT `file_id`, `type`, COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? AND `tournament` = ? GROUP BY `type`, `uploaded_at` ORDER BY `type`, `uploaded_at` DESC;"); if ($team->isSelectedForFinal())
$documents_req->execute([$_SESSION["user_id"], $_SESSION[$team->isSelectedForFinal() ? $FINAL->getId() : $tournament->getId()]]); $documents_final = $user->getAllDocuments($FINAL->getId());
} }
else else
require_once "server_files/403.php"; require_once "server_files/403.php";
@ -36,7 +40,7 @@ if (isset($_POST["team_edit"])) {
function sendDocument() function sendDocument()
{ {
global $LOCAL_PATH, $DB; global $LOCAL_PATH, $DB, $FINAL;
$type = strtoupper(htmlspecialchars($_POST["type"])); $type = strtoupper(htmlspecialchars($_POST["type"]));
if (!isset($type) || ($type != "PARENTAL_CONSENT" && $type != "PHOTO_CONSENT" && $type != "SANITARY_PLUG")) if (!isset($type) || ($type != "PARENTAL_CONSENT" && $type != "PHOTO_CONSENT" && $type != "SANITARY_PLUG"))
@ -67,7 +71,7 @@ function sendDocument()
$req = $DB->prepare("INSERT INTO `documents`(`file_id`, `user`, `team`, `tournament`, `type`) $req = $DB->prepare("INSERT INTO `documents`(`file_id`, `user`, `team`, `tournament`, `type`)
VALUES (?, ?, ?, ?, ?);"); VALUES (?, ?, ?, ?, ?);");
$req->execute([$id, $_SESSION["user_id"], $_SESSION["team_id"], $_SESSION[isset($_SESSION["final_id"]) ? "final_id" : "tournament_id"], $type]); $req->execute([$id, $_SESSION["user_id"], $_SESSION["team"]->getId(), $_SESSION["team"]->isSelectedForFinal() ? $FINAL->getId() : $_SESSION["team"]->getTournamentId(), $type]);
return false; return false;
} }

View File

@ -8,18 +8,19 @@ if (!isset($_SESSION["team"]))
* @var Tournament $tournament * @var Tournament $tournament
*/ */
$team = $_SESSION["team"]; $team = $_SESSION["team"];
$tournament = Tournament::fromId($team->isSelectedForFinal() ? $FINAL->getId() : $team->getTournamentId()); $tournament = Tournament::fromId($team->getTournamentId());
if (isset($_POST["send_solution"])) { if (isset($_POST["send_solution"])) {
$error_message = saveSolution(); $error_message = saveSolution();
} }
/** @noinspection SqlAggregates */ $solutions = $tournament->getAllSolutions($team->getId());
$solutions_req = $DB->prepare("SELECT `file_id`, `problem`, COUNT(`problem`) AS `version` FROM `solutions` WHERE `team` = ? AND `tournament` = ? GROUP BY `problem` ORDER BY `problem`, `uploaded_at` DESC;"); $solutions_final = null;
$solutions_req->execute([$team->getId(), $tournament->getId()]); if ($team->isSelectedForFinal())
$solutions_final = $FINAL->getAllSolutions($team->getId());
function saveSolution() { function saveSolution() {
global $LOCAL_PATH, $DB, $team, $tournament; global $LOCAL_PATH, $DB, $team, $tournament, $FINAL;
try { try {
$problem = $_POST["problem"]; $problem = $_POST["problem"];
@ -55,7 +56,7 @@ function saveSolution() {
return "Une erreur est survenue lors de l'envoi du fichier."; return "Une erreur est survenue lors de l'envoi du fichier.";
$req = $DB->prepare("INSERT INTO `solutions`(`file_id`, `team`, `tournament`, `problem`) VALUES (?, ?, ?, ?);"); $req = $DB->prepare("INSERT INTO `solutions`(`file_id`, `team`, `tournament`, `problem`) VALUES (?, ?, ?, ?);");
$req->execute([$id, $team->getId(), $tournament->getId(), $problem]); $req->execute([$id, $team->getId(), $team->isSelectedForFinal() ? $FINAL->getId() : $tournament->getId(), $problem]);
return false; return false;
} }

View File

@ -3,16 +3,10 @@
if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN && $_SESSION["role"] != Role::ORGANIZER) if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN && $_SESSION["role"] != Role::ORGANIZER)
require_once "server_files/403.php"; require_once "server_files/403.php";
/** @noinspection SqlAggregates */
$req = $DB->query("SELECT `tournaments`.`id`, `name` FROM `tournaments` JOIN `organizers` ON `tournament` = `tournaments`.`id` WHERE "
. ($_SESSION["role"] == Role::ADMIN ? "" : "`organizer` = '" . $_SESSION["user_id"] . "' AND ")
. "`year` = $YEAR GROUP BY `tournament` ORDER BY `name`;");
if (isset($_POST["download_zip"])) { if (isset($_POST["download_zip"])) {
$id = $_POST["tournament"]; $id = $_POST["tournament"];
$tournament_name = $_POST["tournament_name"]; $tournament = Tournament::fromId($id);
/** @noinspection SqlAggregates */ $sols = $tournament->getAllSolutions();
$files_req = $DB->query("SELECT *, COUNT(`problem`) AS `version` FROM `solutions` WHERE `tournament` = '$id' GROUP BY `team`, `problem` ORDER BY `team`, `problem`, `uploaded_at` DESC;");
$zip = new ZipArchive(); $zip = new ZipArchive();
@ -22,12 +16,12 @@ if (isset($_POST["download_zip"])) {
die("Impossible de créer le fichier zip."); die("Impossible de créer le fichier zip.");
} }
while (($data_file = $files_req->fetch()) !== false) { /** @var Solution $sol */
$file_id = $data_file["file_id"]; foreach ($sols as $sol) {
$problem = $data_file["problem"]; $file_id = $sol->getFileId();
$version = $data_file["version"]; $problem = $sol->getProblem();
$team_id = $data_file["team"]; $version = $sol->getVersion();
$team = Team::fromId($team_id); $team = Team::fromId($sol->getTeamId());
$team_name = $team->getName(); $team_name = $team->getName();
$team_trigram = $team->getTrigram(); $team_trigram = $team->getTrigram();
@ -37,7 +31,7 @@ if (isset($_POST["download_zip"])) {
$zip->close(); $zip->close();
header("Content-Type: application/zip"); header("Content-Type: application/zip");
header("Content-Disposition: attachment; filename=\"Solutions du tournoi de $tournament_name.zip\""); header("Content-Disposition: attachment; filename=\"Solutions du tournoi de " . $tournament->getName() . ".zip\"");
header("Content-Length: " . strval(filesize($temp))); header("Content-Length: " . strval(filesize($temp)));
readfile($temp); readfile($temp);
@ -45,29 +39,7 @@ if (isset($_POST["download_zip"])) {
exit(); exit();
} }
require_once "server_files/views/header.php"; $user = $_SESSION["user"];
$tournaments = $_SESSION["role"] == Role::ADMIN ? Tournament::getAllTournaments() : $user->getOrganizedTournaments();
while (($data_tournament = $req->fetch()) !== false) { require_once "server_files/views/solutions_orga.php";
echo "<h1>Tournoi de " . $data_tournament["name"] . "</h1>\n";
$id = $data_tournament["id"];
/** @noinspection SqlAggregates */
$files_req = $DB->query("SELECT *, COUNT(`problem`) AS `version` FROM `solutions` WHERE `tournament` = '$id' GROUP BY `team` ORDER BY `team`, `problem`, `uploaded_at` DESC;");
while (($data_file = $files_req->fetch()) !== false) {
$file_id = $data_file["file_id"];
$problem = $data_file["problem"];
$version = $data_file["version"];
$team_id = $data_file["team"];
$team = Team::fromId($team_id);
$team_name = $team->getName();
$team_trigram = $team->getTrigram();
echo "Problème n°$problem de l'équipe $team_name ($team_trigram), version $version : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
}
echo "<form method=\"POST\">\n";
echo "<input type=\"hidden\" name=\"tournament\" value=\"$id\" />\n";
echo "<input type=\"hidden\" name=\"tournament_name\" value=\"" . $data_tournament["name"] . "\" />\n";
echo "<input style=\"width: 100%\" type=\"submit\" name=\"download_zip\" value=\"Télécharger l'archive\" />\n";
echo "</form><hr />\n";
}
require_once "server_files/views/footer.php";

View File

@ -8,18 +8,19 @@ if (!isset($_SESSION["team"]))
* @var Tournament $tournament * @var Tournament $tournament
*/ */
$team = $_SESSION["team"]; $team = $_SESSION["team"];
$tournament = Tournament::fromId($team->isSelectedForFinal() ? $FINAL->getId() : $team->getTournamentId()); $tournament = Tournament::fromId($team->getTournamentId());
if (isset($_POST["send_synthese"])) { if (isset($_POST["send_synthesis"])) {
$error_message = saveSynthese(); $error_message = saveSynthesis();
} }
/** @noinspection SqlAggregates */ $syntheses = $tournament->getAllSyntheses($team->getId());
$syntheses_req = $DB->prepare("SELECT `file_id`, `dest`, COUNT(`dest`) AS `version` FROM `syntheses` WHERE `team` = ? AND `tournament` = ? GROUP BY `dest` ORDER BY `dest`, `uploaded_at` DESC;"); $syntheses_final = null;
$syntheses_req->execute([$team->getId(), $tournament->getId()]); if ($team->isSelectedForFinal())
$syntheses_final = $FINAL->getAllSyntheses($team->getId());
function saveSynthese() { function saveSynthesis() {
global $LOCAL_PATH, $DB, $team, $tournament; global $LOCAL_PATH, $DB, $team, $tournament, $FINAL;
$dest = strtoupper(htmlspecialchars($_POST["dest"])); $dest = strtoupper(htmlspecialchars($_POST["dest"]));
@ -51,7 +52,7 @@ function saveSynthese() {
return "Une erreur est survenue lors de l'envoi du fichier."; return "Une erreur est survenue lors de l'envoi du fichier.";
$req = $DB->prepare("INSERT INTO `syntheses`(`file_id`, `team`, `tournament`, `dest`) VALUES (?, ?, ?, ?);"); $req = $DB->prepare("INSERT INTO `syntheses`(`file_id`, `team`, `tournament`, `dest`) VALUES (?, ?, ?, ?);");
$req->execute([$id, $team->getId(), $tournament->getId(), $dest]); $req->execute([$id, $team->getId(), $team->isSelectedForFinal() ? $FINAL->getId() : $tournament->getId(), $dest]);
return false; return false;
} }

View File

@ -3,9 +3,8 @@
if (isset($_POST["download_zip"])) { if (isset($_POST["download_zip"])) {
$id = $_POST["tournament"]; $id = $_POST["tournament"];
$tournament_name = $_POST["tournament_name"]; $tournament = Tournament::fromId($id);
/** @noinspection SqlAggregates */ $syntheses = $tournament->getAllSyntheses();
$files_req = $DB->query("SELECT *, COUNT(`dest`) AS `version` FROM `syntheses` WHERE `tournament` = '$id' GROUP BY `team`, `dest` ORDER BY `team`, `dest`, `uploaded_at` DESC;");
$zip = new ZipArchive(); $zip = new ZipArchive();
@ -15,22 +14,22 @@ if (isset($_POST["download_zip"])) {
die("Impossible de créer le fichier zip."); die("Impossible de créer le fichier zip.");
} }
while (($data_file = $files_req->fetch()) !== false) { /** @var Synthesis $synthesis */
$file_id = $data_file["file_id"]; foreach ($syntheses as $synthesis) {
$dest = $data_file["dest"]; $file_id = $synthesis->getFileId();
$version = $data_file["version"]; $dest = $synthesis->getDest();
$team_id = $data_file["team"]; $version = $synthesis->getVersion();
$team = Team::fromId($team_id); $team = Team::fromId($synthesis->getTeamId());
$team_name = $team->getName(); $team_name = $team->getName();
$team_trigram = $team->getTrigram(); $team_trigram = $team->getTrigram();
$zip->addFile("$LOCAL_PATH/files/$file_id", "Note de synthèse $team_trigram pour " . ($dest == "OPPOSANT" ? "l'opposant" : "le rapporteur") . ".pdf"); $zip->addFile("$LOCAL_PATH/files/$file_id", "Note de synthèse $team_trigram pour " . ($dest == DestType::OPPOSANT ? "l'opposant" : "le rapporteur") . ".pdf");
} }
$zip->close(); $zip->close();
header("Content-Type: application/zip"); header("Content-Type: application/zip");
header("Content-Disposition: attachment; filename=\"Notes de syntèses du tournoi de $tournament_name.zip\""); header("Content-Disposition: attachment; filename=\"Notes de syntèses du tournoi de " . $tournament->getName() . ".zip\"");
header("Content-Length: " . filesize($temp)); header("Content-Length: " . filesize($temp));
readfile($temp); readfile($temp);
@ -38,33 +37,7 @@ if (isset($_POST["download_zip"])) {
exit(); exit();
} }
require_once "server_files/views/header.php"; $user = $_SESSION["user"];
$tournaments = $_SESSION["role"] == Role::ADMIN ? Tournament::getAllTournaments() : $user->getOrganizedTournaments();
$req = $DB->query("SELECT `tournaments`.`id`, `name` FROM `tournaments` JOIN `organizers` ON `tournament` = `tournaments`.`id` WHERE " require_once "server_files/views/syntheses_orga.php";
. ($_SESSION["role"] == Role::ADMIN ? "" : "`organizer` = '" . $_SESSION["user_id"] . "' AND ")
. "`year` = $YEAR GROUP BY `tournament`, `name` ORDER BY `name`;");
while (($data_tournament = $req->fetch()) !== false) {
echo "<h1>Tournoi de " . $data_tournament["name"] . "</h1>\n";
$id = $data_tournament["id"];
$files_req = $DB->query("SELECT *, COUNT(`dest`) AS `version` FROM `syntheses` WHERE `tournament` = '$id' GROUP BY `team`, `dest`, `uploaded_at` ORDER BY `team`, `dest`, `uploaded_at` DESC;");
while (($data_file = $files_req->fetch()) !== false) {
$file_id = $data_file["file_id"];
$dest = $data_file["dest"];
$version = $data_file["version"];
$team_id = $data_file["team"];
$team = Team::fromId($team_id);
$team_name = $team->getName();
$team_trigram = $team->getTrigram();
echo "Note de synthèse de l'équipe $team_name ($team_trigram) pour " . ($dest == "OPPOSANT" ? "l'opposant" : "le rapporteur")
. ", version $version : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
}
echo "<form method=\"POST\">\n";
echo "<input type=\"hidden\" name=\"tournament\" value=\"$id\" />\n";
echo "<input type=\"hidden\" name=\"tournament_name\" value=\"" . $data_tournament["name"] . "\" />\n";
echo "<input style=\"width: 100%\" type=\"submit\" name=\"download_zip\" value=\"Télécharger l'archive\" />\n";
echo "</form><hr />\n";
}
require_once "server_files/views/footer.php";

View File

@ -1,9 +1,7 @@
<?php <?php
$tournament_name = htmlspecialchars($_GET["name"]); $tournament_name = htmlspecialchars($_GET["name"]);
$tournament = Tournament::fromName($tournament_name); $tournament = Tournament::fromName($tournament_name);
$orgas = $tournament->getOrganizers();
if ($tournament === null) if ($tournament === null)
require_once "server_files/404.php"; require_once "server_files/404.php";
@ -14,13 +12,8 @@ if (isset($_GET["modifier"]) && $_SESSION["role"] != Role::ADMIN && !$tournament
if (isset($_POST["edit_tournament"])) { if (isset($_POST["edit_tournament"])) {
$error_message = updateTournament(); $error_message = updateTournament();
} }
$orgas = $tournament->getOrganizers();
if ($tournament->isFinal()) $teams = $tournament->getAllTeams();
$teams_response = $DB->query("SELECT `id`, `name`, `trigram`, `inscription_date`, `validation_status` FROM `teams` WHERE `final_selection` AND `year` = $YEAR;");
else
$teams_response = $DB->query("SELECT `id`, `name`, `trigram`, `inscription_date`, `validation_status` FROM `teams` WHERE `tournament` = " . $tournament->getId() . " AND `year` = $YEAR;");
$orgas_response = $DB->query("SELECT `id`, `surname`, `first_name` FROM `users` WHERE (`role` = 'ORGANIZER' OR `role` = 'ADMIN') AND `year` = '$YEAR';");
function updateTournament() { function updateTournament() {
global $DB, $URL_BASE, $YEAR, $tournament, $orgas; global $DB, $URL_BASE, $YEAR, $tournament, $orgas;

View File

@ -1,7 +1,5 @@
<?php <?php
$response = $DB->query("SELECT `name`, `date_start`, `date_end`, `date_inscription`, `date_solutions`, `size` FROM `tournaments` $tournaments = Tournament::getAllTournaments();
WHERE `year` = '$YEAR' AND `final` = false ORDER BY `date_start`, `name`;");
$final_data = $DB->query("SELECT `name`, `date_start`, `date_end`, `date_solutions`, `size` FROM `tournaments` WHERE `final` AND `year` = $YEAR;")->fetch();
require_once "server_files/views/tournois.php"; require_once "server_files/views/tournois.php";

View File

@ -13,8 +13,8 @@ $id = htmlspecialchars($_GET["file_id"]);
$type = DocumentType::SOLUTION; $type = DocumentType::SOLUTION;
$file = Solution::fromId($id); $file = Solution::fromId($id);
if ($file === null) { if ($file === null) {
$type = DocumentType::SYNTHESE; $type = DocumentType::SYNTHESIS;
$file = Synthese::fromId($id); $file = Synthesis::fromId($id);
if ($file === null) { if ($file === null) {
$file = Document::fromId($id); $file = Document::fromId($id);
@ -37,7 +37,7 @@ if ($file !== null) {
if (($_SESSION["role"] == Role::PARTICIPANT || $_SESSION["role"] == Role::ENCADRANT) && (!isset($_SESSION["team"]) || $_SESSION["team"]->getId() != $team->getId())) if (($_SESSION["role"] == Role::PARTICIPANT || $_SESSION["role"] == Role::ENCADRANT) && (!isset($_SESSION["team"]) || $_SESSION["team"]->getId() != $team->getId()))
require_once "server_files/403.php"; require_once "server_files/403.php";
} }
else if ($type == DocumentType::SYNTHESE) { else if ($type == DocumentType::SYNTHESIS) {
$dest = $file->getDest(); $dest = $file->getDest();
$name = "Note de synthèse $trigram pour " . ($dest == DestType::OPPOSANT ? "l'opposant" : "le rapporteur") . ".pdf"; $name = "Note de synthèse $trigram pour " . ($dest == DestType::OPPOSANT ? "l'opposant" : "le rapporteur") . ".pdf";

View File

@ -120,3 +120,17 @@ function tournamentExists($name) {
$req->execute([$name]); $req->execute([$name]);
return $req->fetch(); return $req->fetch();
} }
function printDocuments($documents) {
global $URL_BASE;
foreach ($documents as $document) {
$file_id = $document->getFileId();
$user = User::fromId($document->getUserId());
$surname = $user->getSurname();
$first_name = $user->getFirstName();
$name = DocumentType::getTranslatedName($document->getType());
$version = $document->getVersion();
echo "$name de $first_name $surname (version $version) : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
}
}

View File

@ -30,65 +30,30 @@ if ($team->isSelectedForFinal()) {
<h2>Autorisations</h2> <h2>Autorisations</h2>
<?php <?php printDocuments($documents) ?>
while (($data = $documents_req->fetch()) !== false) {
$file_id = $data["file_id"]; <form method="POST">
$type = $data["type"]; <input style="width: 100%;" type="submit" name="download_zip" value="Télécharger l'archive"/>
$user_id = $data["user"]; </form>
$user_data = $DB->query("SELECT `surname`, `first_name` FROM `users` WHERE `id` = '$user_id';")->fetch();
$surname = $user_data["surname"];
$first_name = $user_data["first_name"];
$version = $data["version"];
switch ($data["type"]) {
case "PARENTAL_CONSENT":
$name = "Autorisation parentale";
break;
case "PHOTO_CONSENT":
$name = "Autorisation de droit à l'image";
break;
case "SANITARY_PLUG":
$name = "Fiche sanitaire";
break;
}
echo "$name de $first_name $surname : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
}
?>
<?php if ($team->isSelectedForFinal()) { ?> <?php if ($team->isSelectedForFinal()) { ?>
<hr/> <hr/>
<h2>Autorisations pour la finale</h2> <h2>Autorisations pour la finale</h2>
<?php <?php printDocuments($documents_final) ?>
while (($data = $documents_req->fetch()) !== false) { <form method="POST">
$file_id = $data["file_id"]; <input style="width: 100%;" type="submit" name="download_zip_final" value="Télécharger l'archive"/>
$type = $data["type"]; </form>
$user_id = $data["user"]; <?php } ?>
$user_data = $DB->query("SELECT `surname`, `first_name` FROM `users` WHERE `id` = '$user_id';")->fetch();
$surname = $user_data["surname"];
$first_name = $user_data["first_name"];
$version = $data["version"];
switch ($data["type"]) {
case "PARENTAL_CONSENT":
$name = "Autorisation parentale";
break;
case "PHOTO_CONSENT":
$name = "Autorisation de droit à l'image";
break;
case "SANITARY_PLUG":
$name = "Fiche sanitaire";
break;
}
echo "$name de $first_name $surname : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
}
}
if ($team->getValidationStatus() == ValidationStatus::WAITING && $_SESSION["role"] == Role::ADMIN) { ?> <?php if ($team->getValidationStatus() == ValidationStatus::WAITING && $_SESSION["role"] == Role::ADMIN) { ?>
<form method="POST"> <form method="POST">
<input style="width: 100%;" type="submit" name="validate" value="Valider l'équipe"/> <input style="width: 100%;" type="submit" name="validate" value="Valider l'équipe"/>
</form> </form>
<?php <?php
} }
if (!$team->isSelectedForFinal() && isset($_SESSION["user_id"]) && $_SESSION["role"] == Role::ADMIN) { ?> if (!$team->isSelectedForFinal() && $_SESSION["role"] == Role::ADMIN) { ?>
<hr/>
<form method="POST"> <form method="POST">
<input style="width: 100%;" type="submit" name="select" value="Sélectionner pour la finale nationale"/> <input style="width: 100%;" type="submit" name="select" value="Sélectionner pour la finale nationale"/>
</form> </form>

View File

@ -13,21 +13,7 @@ Numéro de téléphone : <?= $user->getPhoneNumber() ?><br />
<?php if ($user->getRole() == Role::PARTICIPANT) { ?> <?php if ($user->getRole() == Role::PARTICIPANT) { ?>
Lycée : <?= $user->getSchool() ?><br /> Lycée : <?= $user->getSchool() ?><br />
Classe : <?php switch ($user->getClass()) { Classe : <?php SchoolClass::getTranslatedName($user->getClass()) ?><br />
case "TERMINALE":
echo "Terminale";
break;
case "PREMIERE":
echo "Première";
break;
case "SECONDE":
echo "Seconde ou avant";
break;
default:
echo "A hacké le site";
break;
}
?><br />
Nom du responsable légal : <?= $user->getResponsibleName() ?><br /> Nom du responsable légal : <?= $user->getResponsibleName() ?><br />
Numéro de téléphone du responsable légal : <?= $user->getResponsiblePhone() ?><br /> Numéro de téléphone du responsable légal : <?= $user->getResponsiblePhone() ?><br />
Adresse e-mail du responsable légal : <a href="mailto:<?= $user->getResponsibleEmail() ?>"><?= $user->getResponsibleEmail() ?></a> Adresse e-mail du responsable légal : <a href="mailto:<?= $user->getResponsibleEmail() ?>"><?= $user->getResponsibleEmail() ?></a>
@ -38,33 +24,20 @@ Numéro de téléphone : <?= $user->getPhoneNumber() ?><br />
echo "<hr />"; echo "<hr />";
if ($user->getRole() == Role::ADMIN || $user->getRole() == Role::ORGANIZER) { if ($user->getRole() == Role::ADMIN || $user->getRole() == Role::ORGANIZER) {
while (($tournament_data = $tournaments_req->fetch()) !== false) { foreach ($tournaments as $tournament) {
echo "Organise le tournoi <a href=\"$URL_BASE/tournoi/" . $tournament_data["name"] . "\">" . $tournament_data["name"] . "</a><br />"; echo "Organise le tournoi <a href=\"$URL_BASE/tournoi/" . $tournament->getName(). "\">" . $tournament->getName() . "</a><br />";
} }
} }
elseif ($user->getRole() == Role::PARTICIPANT || $user->getRole() == Role::ENCADRANT) { ?> elseif ($user->getRole() == Role::PARTICIPANT || $user->getRole() == Role::ENCADRANT) { ?>
<h2>Autorisations</h2> <h2>Autorisations</h2>
<?php <?php
while (($data = $documents_req->fetch()) !== false) { printDocuments($documents);
$file_id = $data["file_id"];
$type = $data["type"]; if ($team->isSelectedForFinal()) { ?>
$user_id = $data["user"]; <hr />
$user_data = $DB->query("SELECT `surname`, `first_name` FROM `users` WHERE `id` = '$user_id';")->fetch(); <h2>Autorisations pour la finale</h2>
$surname = $user_data["surname"]; <?php
$first_name = $user_data["first_name"]; printDocuments($documents_final);
$version = $data["version"];
switch ($data["type"]) {
case "PARENTAL_CONSENT":
$name = "Autorisation parentale";
break;
case "PHOTO_CONSENT":
$name = "Autorisation de droit à l'image";
break;
case "SANITARY_PLUG":
$name = "Fiche sanitaire";
break;
}
echo "$name de $first_name $surname : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
} }
} }

View File

@ -67,9 +67,8 @@ Code d'accès : <strong><?= $team->getAccessCode() ?></strong><br/>
<td> <td>
<select style="width: 100%;" id="tournament" name="tournament"> <select style="width: 100%;" id="tournament" name="tournament">
<?php <?php
while (($data = $tournaments_response->fetch()) !== FALSE) { foreach ($tournaments as $tournament)
echo "<option value=\"" . $data["id"] . "\">" . $data["name"] . "</option>\n"; echo "<option value=\"" . $tournament->getId() . "\">" . $tournament->getName() . "</option>\n";
}
?> ?>
</select> </select>
</td> </td>
@ -92,24 +91,17 @@ Code d'accès : <strong><?= $team->getAccessCode() ?></strong><br/>
<hr/> <hr/>
<h2>Mes autorisations</h2> <h2>Mes autorisations</h2>
<?php <?php
while (($data = $documents_req->fetch()) !== false) { printDocuments($documents);
$file_id = $data["file_id"];
$type = $data["type"]; if ($team->isSelectedForFinal()) { ?>
$version = $data["version"]; <hr/>
switch ($data["type"]) { <h2>Mes autorisations pour la finale</h2>
case "PARENTAL_CONSENT": <?php
$name = "Autorisation parentale"; printDocuments($documents_final);
break;
case "PHOTO_CONSENT":
$name = "Autorisation de droit à l'image";
break;
case "SANITARY_PLUG":
$name = "Fiche sanitaire";
break;
}
echo "$name : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
} }
if ($team->getValidationStatus() == ValidationStatus::NOT_READY) { ?> if ($team->getValidationStatus() == ValidationStatus::NOT_READY) { ?>
<hr />
<form method="post" enctype="multipart/form-data"> <form method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="5000000"/> <input type="hidden" name="MAX_FILE_SIZE" value="5000000"/>
<table style="width: 100%;"> <table style="width: 100%;">
@ -145,8 +137,8 @@ Code d'accès : <strong><?= $team->getAccessCode() ?></strong><br/>
</table> </table>
</form> </form>
<?php } ?> <?php } ?>
<hr/>
<?php if ($team->getValidationStatus() == ValidationStatus::NOT_READY) { ?> <?php if ($team->getValidationStatus() == ValidationStatus::NOT_READY) { ?>
<hr/>
<table style="width: 100%;"> <table style="width: 100%;">
<tr> <tr>
<td style="width: 50%;"> <td style="width: 50%;">

View File

@ -51,12 +51,26 @@ if (isset($error_message)) {
<h2>Solutions soumises :</h2> <h2>Solutions soumises :</h2>
<?php <?php
while (($data = $solutions_req->fetch()) !== false) { /** @var Solution $sol */
$file_id = $data["file_id"]; foreach ($solutions as $sol) {
$problem = $data["problem"]; $file_id = $sol->getFileId();
$version = $data["version"]; $problem = $sol->getProblem();
$version = $sol->getVersion();
echo "Problème $problem (Version $version) : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />"; echo "Problème $problem (Version $version) : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
} }
if ($team->isSelectedForFinal()) { ?>
<hr/>
<h2>Solutions soumises pour la finale :</h2>
<?php
/** @var Solution $sol */
foreach ($solutions_final as $sol) {
$file_id = $sol->getFileId();
$problem = $sol->getProblem();
$version = $sol->getVersion();
echo "Problème $problem (Version $version) : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
}
}
require_once "footer.php"; require_once "footer.php";

View File

@ -0,0 +1,25 @@
<?php
require_once "server_files/views/header.php";
foreach ($tournaments as $tournament) {
echo "<h1>Tournoi de " . $tournament->getName() . "</h1>\n";
$sols = $tournament->getAllSolutions();
/** @var Solution $sol */
foreach ($sols as $sol) {
$file_id = $sol->getFileId();
$problem = $sol->getProblem();
$version = $sol->getVersion();
$team = Team::fromId($sol->getTeamId());
$team_name = $team->getName();
$team_trigram = $team->getTrigram();
echo "Problème n°$problem de l'équipe $team_name ($team_trigram), version $version : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
}
echo "<form method=\"POST\">\n";
echo "<input type=\"hidden\" name=\"tournament\" value=\"" . $tournament->getId() . "\" />\n";
echo "<input style=\"width: 100%\" type=\"submit\" name=\"download_zip\" value=\"Télécharger l'archive\" />\n";
echo "</form><hr />\n";
}
require_once "server_files/views/footer.php";

View File

@ -41,7 +41,7 @@ if (isset($error_message)) {
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<input style="width: 100%;" type="submit" name="send_synthese" value="Envoyer" /> <input style="width: 100%;" type="submit" name="send_synthesis" value="Envoyer" />
</td> </td>
</tr> </tr>
</tbody> </tbody>
@ -54,11 +54,26 @@ if (isset($error_message)) {
<h2>Notes de synthèse soumises :</h2> <h2>Notes de synthèse soumises :</h2>
<?php <?php
while (($data = $syntheses_req->fetch()) !== false) { /** @var Synthesis $synthesis */
$file_id = $data["file_id"]; foreach ($syntheses as $synthesis) {
$dest = $data["dest"]; $file_id = $synthesis->getFileId();
$version = $data["version"]; $dest = $synthesis->getDest();
echo "Note de synthèse pour " . ($dest == "OPPOSANT" ? "l'opposant" : "le rapporteur") . " (Version $version) : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />"; $version = $synthesis->getVersion();
echo "Note de synthèse pour " . ($dest == DestType::OPPOSANT ? "l'opposant" : "le rapporteur") . " (version $version) : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
}
if ($team->isSelectedForFinal()) { ?>
<hr/>
<h2>Notes de synthèse soumises pour la finale :</h2>
<?php
/** @var Synthesis $sol */
foreach ($syntheses_final as $synthesis) {
$file_id = $synthesis->getFileId();
$dest = $synthesis->getDest();
$version = $synthesis->getVersion();
echo "Note de synthèse pour " . ($dest == DestType::OPPOSANT ? "l'opposant" : "le rapporteur") . " (version $version) : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
}
} }
require_once "footer.php"; require_once "footer.php";

View File

@ -0,0 +1,27 @@
<?php
require_once "server_files/views/header.php";
/** @var Tournament $tournament */
foreach ($tournaments as $tournament) {
echo "<h1>Tournoi de " . $tournament->getName() . "</h1>\n";
$syntheses = $tournament->getAllSyntheses();
/** @var Synthesis $synthesis */
foreach ($syntheses as $synthesis) {
$file_id = $synthesis->getFileId();
$dest = $synthesis->getDest();
$version = $synthesis->getVersion();
$team = Team::fromId($synthesis->getTeamId());
$team_name = $team->getName();
$team_trigram = $team->getTrigram();
echo "Note de synthèse de l'équipe $team_name ($team_trigram) pour " . ($dest == DestType::OPPOSANT ? "l'opposant" : "le rapporteur")
. ", version $version : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
}
echo "<form method=\"POST\">\n";
echo "<input type=\"hidden\" name=\"tournament\" value=\"" . $tournament->getId() . "\" />\n";
echo "<input style=\"width: 100%\" type=\"submit\" name=\"download_zip\" value=\"Télécharger l'archive\" />\n";
echo "</form><hr />\n";
}
require_once "server_files/views/footer.php";

View File

@ -31,7 +31,7 @@ if ($tournament->isFinal())
echo "<strong>Ce tournoi est la finale nationale du TFJM² 2020.</strong><br />"; echo "<strong>Ce tournoi est la finale nationale du TFJM² 2020.</strong><br />";
?> ?>
<?php if (!isset($_GET["modifier"]) && ($_SESSION["role"] == Role::ADMIN || $_SESSION["role"] == Role::ORGANIZER && in_array($_SESSION["user_id"], $orgas_id))) { ?> <?php if (!isset($_GET["modifier"]) && ($_SESSION["role"] == Role::ADMIN || $_SESSION["role"] == Role::ORGANIZER && $tournament->organize($_SESSION["user_id"]))) { ?>
<a href="<?= $URL_BASE ?>/tournoi/<?= $tournament->getName() ?>/modifier">Éditer le tournoi</a> <a href="<?= $URL_BASE ?>/tournoi/<?= $tournament->getName() ?>/modifier">Éditer le tournoi</a>
<?php } ?> <?php } ?>
@ -60,38 +60,21 @@ if ($tournament->isFinal())
</thead> </thead>
<tbody> <tbody>
<?php <?php
/** @noinspection PhpUndefinedVariableInspection */ /** @var Team $team */
while (($team_data = $teams_response->fetch()) != false) { foreach ($teams as $team) {
?> ?>
<tr> <tr>
<td style="border: 1px solid black; text-align: center"> <td style="border: 1px solid black; text-align: center">
<?php <?php
if (isset($_SESSION["role"]) && ($_SESSION["role"] == Role::ADMIN || ($_SESSION["role"] == Role::ORGANIZER && in_array($_SESSION["user_id"], $orgas_id)))) if (isset($_SESSION["role"]) && ($_SESSION["role"] == Role::ADMIN || ($_SESSION["role"] == Role::ORGANIZER && $tournament->organize($_SESSION["user_id"]))))
echo "<a href=\"$URL_BASE/equipe/" . $team_data["trigram"] . "\">" . $team_data["name"] . "</a>"; echo "<a href=\"$URL_BASE/equipe/" . $team->getTrigram() . "\">" . $team->getName(). "</a>";
else else
echo $team_data["name"]; echo $team->getName();
?>
</td>
<td style="border: 1px solid black; text-align: center"><?= $team_data["trigram"] ?></td>
<td style="border: 1px solid black; text-align: center"><?= formatDate($team_data["inscription_date"]) ?></td>
<td style="border: 1px solid black; text-align: center">
<?php
switch (ValidationStatus::fromName($team_data["validation_status"])) {
case ValidationStatus::NOT_READY:
echo "Inscription non terminée";
break;
case ValidationStatus::WAITING:
echo "En attente de validation";
break;
case ValidationStatus::VALIDATED:
echo "Inscription validée";
break;
default:
echo "Statut inconnu";
break;
}
?> ?>
</td> </td>
<td style="border: 1px solid black; text-align: center"><?= $team->getTrigram() ?></td>
<td style="border: 1px solid black; text-align: center"><?= formatDate($team->getInscriptionDate()) ?></td>
<td style="border: 1px solid black; text-align: center"><?= ValidationStatus::getTranslatedName($team->getValidationStatus()) ?></td>
</tr> </tr>
<?php <?php
} }
@ -140,7 +123,7 @@ else {
<select style="width: 100%;" id="organizer" name="organizer[]" multiple size="4" required> <select style="width: 100%;" id="organizer" name="organizer[]" multiple size="4" required>
<?php <?php
while (($orga_data = $orgas_response->fetch()) !== FALSE) { while (($orga_data = $orgas_response->fetch()) !== FALSE) {
echo "<option value=\"" . $orga_data["id"] . "\" " . (in_array($orga_data["id"], $orgas_id) ? "selected" : "") echo "<option value=\"" . $orga_data["id"] . "\" " . ($tournament->organize($_SESSION["user_id"]) ? "selected" : "")
. ">" . $orga_data["first_name"] . " " . $orga_data["surname"] . "</option>\n"; . ">" . $orga_data["first_name"] . " " . $orga_data["surname"] . "</option>\n";
} }
?> ?>

View File

@ -5,7 +5,7 @@
<table style="border: 1px solid black; width: 100%"> <table style="border: 1px solid black; width: 100%">
<thead style="border: 1px solid black"> <thead style="border: 1px solid black">
<tr> <tr>
<th style="border: 1px solid black; text-align: center">Lieu</th> <th style="border: 1px solid black; text-align: center">Nom</th>
<th style="border: 1px solid black; text-align: center">Dates</th> <th style="border: 1px solid black; text-align: center">Dates</th>
<th style="border: 1px solid black; text-align: center">Inscription avant le</th> <th style="border: 1px solid black; text-align: center">Inscription avant le</th>
<th style="border: 1px solid black; text-align: center">Date de rendu des solutions</th> <th style="border: 1px solid black; text-align: center">Date de rendu des solutions</th>
@ -14,29 +14,22 @@
</thead> </thead>
<tbody style="border: 1px solid black"> <tbody style="border: 1px solid black">
<?php <?php
while (($data = $response->fetch()) !== FALSE) { foreach ($tournaments as $tournament) {
?> ?>
<tr style="border: 1px solid black"> <tr style="border: 1px solid black">
<td style="border: 1px solid black; text-align: center"><a href="<?= $URL_BASE ?>/tournoi/<?= $data["name"] ?>"><?= $data["name"] ?></a></td> <td style="border: 1px solid black; text-align: center"><a href="<?= $URL_BASE ?>/tournoi/<?= $tournament->getName() ?>"><?= $tournament->getName() ?></a></td>
<td style="border: 1px solid black; text-align: center">Du <?= formatDate($data["date_start"]) ?> au <?= formatDate($data["date_end"]) ?></td> <td style="border: 1px solid black; text-align: center">Du <?= formatDate($tournament->getStartDate()) ?> au <?= formatDate($tournament->getEndDate()) ?></td>
<td style="border: 1px solid black; text-align: center"><?= formatDate($data["date_inscription"]) ?></td> <td style="border: 1px solid black; text-align: center"><?= formatDate($tournament->getSolutionsDate()) ?></td>
<td style="border: 1px solid black; text-align: center"><?= formatDate($data["date_solutions"]) ?></td> <td style="border: 1px solid black; text-align: center"><?= formatDate($tournament->getSynthesesDate()) ?></td>
<td style="border: 1px solid black; text-align: center"><?= $data["size"] ?></td> <td style="border: 1px solid black; text-align: center"><?= $tournament->getSize() ?></td>
</tr> </tr>
<?php <?php
} }
?> ?>
<tr style="border: 1px solid black">
<td style="border: 1px solid black; text-align: center"><a href="<?= $URL_BASE ?>/tournoi/<?= $final_data["name"] ?>"><?= $final_data["name"] ?></a></td>
<td colspan="2" style="border: 1px solid black; text-align: center">Du <?= formatDate($final_data["date_start"]) ?> au <?= formatDate($final_data["date_end"]) ?></td>
<!-- <td style="border: 1px solid black; text-align: center"><?= formatDate($final_data["date_inscription"]) ?></td> -->
<td style="border: 1px solid black; text-align: center"><?= formatDate($final_data["date_solutions"]) ?></td>
<td style="border: 1px solid black; text-align: center"><?= $final_data["size"] ?></td>
</tr>
</tbody> </tbody>
<tfoot style="border: 1px solid black"> <tfoot style="border: 1px solid black">
<tr> <tr>
<th style="border: 1px solid black; text-align: center">Lieu</th> <th style="border: 1px solid black; text-align: center">Nom</th>
<th style="border: 1px solid black; text-align: center">Dates</th> <th style="border: 1px solid black; text-align: center">Dates</th>
<th style="border: 1px solid black; text-align: center">Inscription avant le</th> <th style="border: 1px solid black; text-align: center">Inscription avant le</th>
<th style="border: 1px solid black; text-align: center">Date de rendu des solutions</th> <th style="border: 1px solid black; text-align: center">Date de rendu des solutions</th>