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

View File

@ -1,22 +1,25 @@
<?php
/** @noinspection SqlAggregates */
class Tournament
{
private $id;
private $name;
private $size;
private $place;
private $price;
private $description;
private $date_start, $date_end;
private $date_inscription;
private $date_solutions;
private $date_syntheses;
private $final;
private $organizers = [];
private $year;
private $id;
private $name;
private $size;
private $place;
private $price;
private $description;
private $date_start, $date_end;
private $date_inscription;
private $date_solutions;
private $date_syntheses;
private $final;
private $organizers = [];
private $year;
private function __construct() {}
private function __construct()
{
}
public static function fromId($id)
{
@ -62,7 +65,29 @@ class Tournament
return $tournament;
}
private function fill($data)
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)
{
$this->id = $data["id"];
$this->name = $data["name"];
@ -223,6 +248,22 @@ class Tournament
$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()
{
return $this->organizers;
@ -242,4 +283,55 @@ class Tournament
{
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;
}
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"]);
$team = Team::fromTrigram($trigram);
$tournament = Tournament::fromId($team->getTournamentId());
if ($team === null)
require_once "server_files/404.php";
@ -35,20 +36,17 @@ if (isset($_POST["select"])) {
copy("$LOCAL_PATH/files/$old_id", "$LOCAL_PATH/files/$id");
$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(), $_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;");
$documents_req->execute([$team->getId(), $team->getId()]);
// TODO Télécharger en zip les documents personnels
if ($team->isSelectedForFinal()) {
$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_req->execute([$team->getId(), $FINAL->getId()]);
}
$documents = $tournament->getAllDocuments($team->getId());
$documents_final = null;
$tournament = Tournament::fromId($team->getTournamentId());
if ($team->isSelectedForFinal())
$documents_final = $FINAL->getAllDocuments($team->getId());
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";
}
if ($user === null) {
if ($user === null)
require_once "server_files/404.php";
}
$team = Team::fromId($user->getTeamId());
$tournaments = $user->getOrganizedTournaments();
$documents_req = $DB->query("SELECT * FROM `documents` WHERE `user` = $id;");
$tournaments_req = $DB->query("SELECT `tournament`, `name` FROM `organizers` JOIN `tournaments` ON `tournaments`.`id` = `tournament` WHERE `organizer` = $id ORDER BY `date_start`, `name`;");
if ($team != null) {
$documents = $user->getAllDocuments($team->getTournamentId());
if ($team->isSelectedForFinal())
$documents_final = $user->getAllDocuments($FINAL->getId());
}
require_once "server_files/views/informations.php";

View File

@ -5,7 +5,7 @@ if (isset($_POST["leave_team"])) {
exit();
}
$tournaments_response = $DB->query("SELECT `id`, `name` FROM `tournaments` WHERE `year` = '$YEAR';");
$tournaments = Tournament::getAllTournaments(false, true);
if (isset($_POST["send_document"])) {
$error_message = sendDocument();
@ -19,13 +19,17 @@ if (isset($_POST["request_validation"])) {
}
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"];
$tournament = Tournament::fromId($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;");
$documents_req->execute([$_SESSION["user_id"], $_SESSION[$team->isSelectedForFinal() ? $FINAL->getId() : $tournament->getId()]]);
$documents = $user->getAllDocuments($team->getTournamentId());
if ($team->isSelectedForFinal())
$documents_final = $user->getAllDocuments($FINAL->getId());
}
else
require_once "server_files/403.php";
@ -36,7 +40,7 @@ if (isset($_POST["team_edit"])) {
function sendDocument()
{
global $LOCAL_PATH, $DB;
global $LOCAL_PATH, $DB, $FINAL;
$type = strtoupper(htmlspecialchars($_POST["type"]));
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`)
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;
}

View File

@ -8,18 +8,19 @@ if (!isset($_SESSION["team"]))
* @var Tournament $tournament
*/
$team = $_SESSION["team"];
$tournament = Tournament::fromId($team->isSelectedForFinal() ? $FINAL->getId() : $team->getTournamentId());
$tournament = Tournament::fromId($team->getTournamentId());
if (isset($_POST["send_solution"])) {
$error_message = saveSolution();
}
/** @noinspection SqlAggregates */
$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_req->execute([$team->getId(), $tournament->getId()]);
$solutions = $tournament->getAllSolutions($team->getId());
$solutions_final = null;
if ($team->isSelectedForFinal())
$solutions_final = $FINAL->getAllSolutions($team->getId());
function saveSolution() {
global $LOCAL_PATH, $DB, $team, $tournament;
global $LOCAL_PATH, $DB, $team, $tournament, $FINAL;
try {
$problem = $_POST["problem"];
@ -55,7 +56,7 @@ function saveSolution() {
return "Une erreur est survenue lors de l'envoi du fichier.";
$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;
}

View File

@ -3,16 +3,10 @@
if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN && $_SESSION["role"] != Role::ORGANIZER)
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"])) {
$id = $_POST["tournament"];
$tournament_name = $_POST["tournament_name"];
/** @noinspection SqlAggregates */
$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;");
$tournament = Tournament::fromId($id);
$sols = $tournament->getAllSolutions();
$zip = new ZipArchive();
@ -22,12 +16,12 @@ if (isset($_POST["download_zip"])) {
die("Impossible de créer le fichier zip.");
}
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);
/** @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();
@ -37,7 +31,7 @@ if (isset($_POST["download_zip"])) {
$zip->close();
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)));
readfile($temp);
@ -45,29 +39,7 @@ if (isset($_POST["download_zip"])) {
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) {
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";
require_once "server_files/views/solutions_orga.php";

View File

@ -8,18 +8,19 @@ if (!isset($_SESSION["team"]))
* @var Tournament $tournament
*/
$team = $_SESSION["team"];
$tournament = Tournament::fromId($team->isSelectedForFinal() ? $FINAL->getId() : $team->getTournamentId());
$tournament = Tournament::fromId($team->getTournamentId());
if (isset($_POST["send_synthese"])) {
$error_message = saveSynthese();
if (isset($_POST["send_synthesis"])) {
$error_message = saveSynthesis();
}
/** @noinspection SqlAggregates */
$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_req->execute([$team->getId(), $tournament->getId()]);
$syntheses = $tournament->getAllSyntheses($team->getId());
$syntheses_final = null;
if ($team->isSelectedForFinal())
$syntheses_final = $FINAL->getAllSyntheses($team->getId());
function saveSynthese() {
global $LOCAL_PATH, $DB, $team, $tournament;
function saveSynthesis() {
global $LOCAL_PATH, $DB, $team, $tournament, $FINAL;
$dest = strtoupper(htmlspecialchars($_POST["dest"]));
@ -51,7 +52,7 @@ function saveSynthese() {
return "Une erreur est survenue lors de l'envoi du fichier.";
$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;
}

View File

@ -3,9 +3,8 @@
if (isset($_POST["download_zip"])) {
$id = $_POST["tournament"];
$tournament_name = $_POST["tournament_name"];
/** @noinspection SqlAggregates */
$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;");
$tournament = Tournament::fromId($id);
$syntheses = $tournament->getAllSyntheses();
$zip = new ZipArchive();
@ -15,22 +14,22 @@ if (isset($_POST["download_zip"])) {
die("Impossible de créer le fichier zip.");
}
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);
/** @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();
$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();
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));
readfile($temp);
@ -38,33 +37,7 @@ if (isset($_POST["download_zip"])) {
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 "
. ($_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";
require_once "server_files/views/syntheses_orga.php";

View File

@ -1,9 +1,7 @@
<?php
$tournament_name = htmlspecialchars($_GET["name"]);
$tournament = Tournament::fromName($tournament_name);
$orgas = $tournament->getOrganizers();
if ($tournament === null)
require_once "server_files/404.php";
@ -14,13 +12,8 @@ if (isset($_GET["modifier"]) && $_SESSION["role"] != Role::ADMIN && !$tournament
if (isset($_POST["edit_tournament"])) {
$error_message = updateTournament();
}
if ($tournament->isFinal())
$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';");
$orgas = $tournament->getOrganizers();
$teams = $tournament->getAllTeams();
function updateTournament() {
global $DB, $URL_BASE, $YEAR, $tournament, $orgas;

View File

@ -1,7 +1,5 @@
<?php
$response = $DB->query("SELECT `name`, `date_start`, `date_end`, `date_inscription`, `date_solutions`, `size` FROM `tournaments`
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();
$tournaments = Tournament::getAllTournaments();
require_once "server_files/views/tournois.php";

View File

@ -13,8 +13,8 @@ $id = htmlspecialchars($_GET["file_id"]);
$type = DocumentType::SOLUTION;
$file = Solution::fromId($id);
if ($file === null) {
$type = DocumentType::SYNTHESE;
$file = Synthese::fromId($id);
$type = DocumentType::SYNTHESIS;
$file = Synthesis::fromId($id);
if ($file === null) {
$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()))
require_once "server_files/403.php";
}
else if ($type == DocumentType::SYNTHESE) {
else if ($type == DocumentType::SYNTHESIS) {
$dest = $file->getDest();
$name = "Note de synthèse $trigram pour " . ($dest == DestType::OPPOSANT ? "l'opposant" : "le rapporteur") . ".pdf";

View File

@ -119,4 +119,18 @@ function tournamentExists($name) {
$req = $DB->prepare("SELECT `id` FROM `tournaments` WHERE `name` = ? AND `year` = '$YEAR';");
$req->execute([$name]);
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

@ -1,10 +1,10 @@
<?php require_once "header.php" ?>
<h2>Informations sur l'équipe</h2>
<h2>Informations sur l'équipe</h2>
Nom de l'équipe : <?= $team->getName() ?><br />
Trigramme : <?= $team->getTrigram() ?><br />
Tournoi : <a href="<?= $URL_BASE . "/tournoi/" . $tournament->getName() ?>"><?= $tournament->getName() ?></a><br />
Nom de l'équipe : <?= $team->getName() ?><br/>
Trigramme : <?= $team->getTrigram() ?><br/>
Tournoi : <a href="<?= $URL_BASE . "/tournoi/" . $tournament->getName() ?>"><?= $tournament->getName() ?></a><br/>
<?php
for ($i = 1; $i <= 2; ++$i) {
if ($team->getEncadrants()[$i] == NULL)
@ -26,72 +26,37 @@ if ($team->isSelectedForFinal()) {
}
?>
<hr />
<hr/>
<h2>Autorisations</h2>
<h2>Autorisations</h2>
<?php
while (($data = $documents_req->fetch()) !== false) {
$file_id = $data["file_id"];
$type = $data["type"];
$user_id = $data["user"];
$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 printDocuments($documents) ?>
<form method="POST">
<input style="width: 100%;" type="submit" name="download_zip" value="Télécharger l'archive"/>
</form>
<?php if ($team->isSelectedForFinal()) { ?>
<hr />
<h2>Autorisations pour la finale</h2>
<?php
while (($data = $documents_req->fetch()) !== false) {
$file_id = $data["file_id"];
$type = $data["type"];
$user_id = $data["user"];
$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 />";
}
}
<hr/>
<h2>Autorisations pour la finale</h2>
<?php printDocuments($documents_final) ?>
<form method="POST">
<input style="width: 100%;" type="submit" name="download_zip_final" value="Télécharger l'archive"/>
</form>
<?php } ?>
if ($team->getValidationStatus() == ValidationStatus::WAITING && $_SESSION["role"] == Role::ADMIN) { ?>
<form method="POST">
<input style="width: 100%;" type="submit" name="validate" value="Valider l'équipe" />
</form>
<?php if ($team->getValidationStatus() == ValidationStatus::WAITING && $_SESSION["role"] == Role::ADMIN) { ?>
<form method="POST">
<input style="width: 100%;" type="submit" name="validate" value="Valider l'équipe"/>
</form>
<?php
}
if (!$team->isSelectedForFinal() && isset($_SESSION["user_id"]) && $_SESSION["role"] == Role::ADMIN) { ?>
<form method="POST">
<input style="width: 100%;" type="submit" name="select" value="Sélectionner pour la finale nationale" />
</form>
if (!$team->isSelectedForFinal() && $_SESSION["role"] == Role::ADMIN) { ?>
<hr/>
<form method="POST">
<input style="width: 100%;" type="submit" name="select" value="Sélectionner pour la finale nationale"/>
</form>
<?php } ?>
<?php require_once "footer.php" ?>

View File

@ -13,21 +13,7 @@ Numéro de téléphone : <?= $user->getPhoneNumber() ?><br />
<?php if ($user->getRole() == Role::PARTICIPANT) { ?>
Lycée : <?= $user->getSchool() ?><br />
Classe : <?php switch ($user->getClass()) {
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 />
Classe : <?php SchoolClass::getTranslatedName($user->getClass()) ?><br />
Nom du responsable légal : <?= $user->getResponsibleName() ?><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>
@ -38,34 +24,21 @@ Numéro de téléphone : <?= $user->getPhoneNumber() ?><br />
echo "<hr />";
if ($user->getRole() == Role::ADMIN || $user->getRole() == Role::ORGANIZER) {
while (($tournament_data = $tournaments_req->fetch()) !== false) {
echo "Organise le tournoi <a href=\"$URL_BASE/tournoi/" . $tournament_data["name"] . "\">" . $tournament_data["name"] . "</a><br />";
foreach ($tournaments as $tournament) {
echo "Organise le tournoi <a href=\"$URL_BASE/tournoi/" . $tournament->getName(). "\">" . $tournament->getName() . "</a><br />";
}
}
elseif ($user->getRole() == Role::PARTICIPANT || $user->getRole() == Role::ENCADRANT) { ?>
<h2>Autorisations</h2>
<?php
while (($data = $documents_req->fetch()) !== false) {
$file_id = $data["file_id"];
$type = $data["type"];
$user_id = $data["user"];
$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
printDocuments($documents);
if ($team->isSelectedForFinal()) { ?>
<hr />
<h2>Autorisations pour la finale</h2>
<?php
printDocuments($documents_final);
}
}
require_once "footer.php";

View File

@ -10,11 +10,11 @@ if (isset($error_message)) {
}
?>
<h2>Informations sur l'équipe</h2>
<h2>Informations sur l'équipe</h2>
Nom de l'équipe : <?= $team->getName() ?><br/>
Trigramme : <?= $team->getTrigram() ?><br/>
Tournoi : <a href="<?= $tournament->getName() ?>"><?= $tournament->getName() ?></a><br/>
Nom de l'équipe : <?= $team->getName() ?><br/>
Trigramme : <?= $team->getTrigram() ?><br/>
Tournoi : <a href="<?= $tournament->getName() ?>"><?= $tournament->getName() ?></a><br/>
<?php
for ($i = 1; $i <= 2; ++$i) {
if ($team->getEncadrants()[$i] == NULL)
@ -31,7 +31,7 @@ for ($i = 1; $i <= 6; ++$i) {
echo "Participant $i : <a href=\"$URL_BASE/informations/$id/" . $participant->getFirstName() . " " . $participant->getSurname() . "\">" . $participant->getFirstName() . " " . $participant->getSurname() . "</a><br />";
}
?>
Code d'accès : <strong><?= $team->getAccessCode() ?></strong><br/>
Code d'accès : <strong><?= $team->getAccessCode() ?></strong><br/>
<?php if ($team->isSelectedForFinal()) {
$final_name = $FINAL->getName();
echo "<strong>Équipe sélectionnée pour la <a href=\"$URL_BASE/tournoi/$final_name\">finale nationale</a>.</strong><br />";
@ -39,133 +39,125 @@ Code d'accès : <strong><?= $team->getAccessCode() ?></strong><br/>
<?php if (isset($_GET["modifier"])) { ?>
<form method="POST">
<input type="hidden" name="team_edit" value="true"/>
<table style="width: 100%;">
<tbody>
<tr>
<td style="width: 30%;">
<label for="name">Nom :</label>
</td>
<td style="width: 70%;">
<input style="width: 100%;" type="text" id="name" name="name" value="<?= $team->getName() ?>"/>
</td>
</tr>
<tr>
<td>
<label for="trigram">Trigramme :</label>
</td>
<td>
<input style="width: 100%;" type="text" id="trigram" name="trigram"
value="<?= $team->getTrigram() ?>"/>
</td>
</tr>
<tr>
<td>
<label for="tournament">Tournoi :</label>
</td>
<td>
<select style="width: 100%;" id="tournament" name="tournament">
<form method="POST">
<input type="hidden" name="team_edit" value="true"/>
<table style="width: 100%;">
<tbody>
<tr>
<td style="width: 30%;">
<label for="name">Nom :</label>
</td>
<td style="width: 70%;">
<input style="width: 100%;" type="text" id="name" name="name" value="<?= $team->getName() ?>"/>
</td>
</tr>
<tr>
<td>
<label for="trigram">Trigramme :</label>
</td>
<td>
<input style="width: 100%;" type="text" id="trigram" name="trigram"
value="<?= $team->getTrigram() ?>"/>
</td>
</tr>
<tr>
<td>
<label for="tournament">Tournoi :</label>
</td>
<td>
<select style="width: 100%;" id="tournament" name="tournament">
<?php
while (($data = $tournaments_response->fetch()) !== FALSE) {
echo "<option value=\"" . $data["id"] . "\">" . $data["name"] . "</option>\n";
}
foreach ($tournaments as $tournament)
echo "<option value=\"" . $tournament->getId() . "\">" . $tournament->getName() . "</option>\n";
?>
</select>
</td>
</tr>
<tr>
<td colspan="2">
<input style="width: 100%;" type="submit" value="Modifier l'équipe"/>
</td>
</tr>
</tbody>
</table>
</form>
</select>
</td>
</tr>
<tr>
<td colspan="2">
<input style="width: 100%;" type="submit" value="Modifier l'équipe"/>
</td>
</tr>
</tbody>
</table>
</form>
<?php } else { ?>
<?php if ($_SESSION["team_validation_status"] == ValidationStatus::NOT_READY) { ?>
<!--suppress HtmlUnknownTarget -->
<a href="<?= $URL_BASE ?>/mon_equipe/modifier">Modifier mon équipe</a>
<!--suppress HtmlUnknownTarget -->
<a href="<?= $URL_BASE ?>/mon_equipe/modifier">Modifier mon équipe</a>
<?php } ?>
<hr/>
<h2>Mes autorisations</h2>
<hr/>
<h2>Mes autorisations</h2>
<?php
while (($data = $documents_req->fetch()) !== false) {
$file_id = $data["file_id"];
$type = $data["type"];
$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 : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
printDocuments($documents);
if ($team->isSelectedForFinal()) { ?>
<hr/>
<h2>Mes autorisations pour la finale</h2>
<?php
printDocuments($documents_final);
}
if ($team->getValidationStatus() == ValidationStatus::NOT_READY) { ?>
<form method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="5000000"/>
<table style="width: 100%;">
<tbody>
<tr>
<td>
<label for="type">Type de document :</label>
</td>
<td>
<select style="width: 100%;" id="type" name="type">
<hr />
<form method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="5000000"/>
<table style="width: 100%;">
<tbody>
<tr>
<td>
<label for="type">Type de document :</label>
</td>
<td>
<select style="width: 100%;" id="type" name="type">
<?php if ($_SESSION["user"]->getBirthDate() > strval($YEAR - 18) . substr($tournament->getStartDate(), 4)) { ?>
<option value="parental_consent">Autorisation parentale</option>
<option value="parental_consent">Autorisation parentale</option>
<?php } ?>
<option value="photo_consent">Autorisation de droit à l'image</option>
<option value="sanitary_plug">Fiche sanitaire</option>
</select>
</td>
</tr>
<tr>
<td>
<label for="file">Fichier :</label>
</td>
<td>
<input style="width: 100%;" type="file" id="file" name="document"/>
</td>
</tr>
<tr>
<td colspan="2">
<input style="width: 100%;" type="submit" name="send_document" value="Envoyer le document"/>
</td>
</tr>
</tbody>
</table>
</form>
<option value="photo_consent">Autorisation de droit à l'image</option>
<option value="sanitary_plug">Fiche sanitaire</option>
</select>
</td>
</tr>
<tr>
<td>
<label for="file">Fichier :</label>
</td>
<td>
<input style="width: 100%;" type="file" id="file" name="document"/>
</td>
</tr>
<tr>
<td colspan="2">
<input style="width: 100%;" type="submit" name="send_document" value="Envoyer le document"/>
</td>
</tr>
</tbody>
</table>
</form>
<?php } ?>
<hr/>
<?php if ($team->getValidationStatus() == ValidationStatus::NOT_READY) { ?>
<table style="width: 100%;">
<tr>
<td style="width: 50%;">
<form method="post">
<input style="width: 100%;" type="submit" name="leave_team" value="Quitter l'équipe"/>
</form>
</td>
<hr/>
<table style="width: 100%;">
<tr>
<td style="width: 50%;">
<form method="post">
<input style="width: 100%;" type="submit" name="leave_team" value="Quitter l'équipe"/>
</form>
</td>
<?php
$can_validate = checkCanValidate();
if ($can_validate) { ?>
<td style="width: 50%;">
<form method="post">
<input style="width: 100%;" type="submit" name="request_validation"
value="Demander la validation"/>
</form>
</td>
<td style="width: 50%;">
<form method="post">
<input style="width: 100%;" type="submit" name="request_validation"
value="Demander la validation"/>
</form>
</td>
<?php } ?>
</tr>
</table>
</tr>
</table>
<?php } ?>
<?php } ?>

View File

@ -7,56 +7,70 @@ if (isset($error_message)) {
} else {
echo "<h2>Le fichier a été correctement envoyé !</h2>";
}
}?>
} ?>
<?php if (date("yyyy-mm-dd") < $tournament->getSolutionsDate()) { ?>
<form method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="5000000" />
<table style="width: 100%;">
<tbody>
<tr>
<td>
<label for="problem">Problème :</label>
</td>
<td>
<select style="width: 100%;" id="problem" name="problem">
<form method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="5000000"/>
<table style="width: 100%;">
<tbody>
<tr>
<td>
<label for="problem">Problème :</label>
</td>
<td>
<select style="width: 100%;" id="problem" name="problem">
<?php
for ($i = 1; $i <= 9; ++$i) {
echo "<option value=\"$i\">$i</option>\n";
}
?>
</select>
</td>
</tr>
<tr>
<td>
<label for="file">Fichier :</label>
</td>
<td>
<input type="file" id="file" name="solution" />
</td>
</tr>
<tr>
<td colspan="2">
<input style="width: 100%;" type="submit" name="send_solution" value="Envoyer" />
</td>
</tr>
</tbody>
</table>
</form>
</select>
</td>
</tr>
<tr>
<td>
<label for="file">Fichier :</label>
</td>
<td>
<input type="file" id="file" name="solution"/>
</td>
</tr>
<tr>
<td colspan="2">
<input style="width: 100%;" type="submit" name="send_solution" value="Envoyer"/>
</td>
</tr>
</tbody>
</table>
</form>
<?php } ?>
<hr />
<hr/>
<h2>Solutions soumises :</h2>
<h2>Solutions soumises :</h2>
<?php
while (($data = $solutions_req->fetch()) !== false) {
$file_id = $data["file_id"];
$problem = $data["problem"];
$version = $data["version"];
/** @var Solution $sol */
foreach ($solutions 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 />";
}
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";

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>
<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>
</tr>
</tbody>
@ -54,11 +54,26 @@ if (isset($error_message)) {
<h2>Notes de synthèse soumises :</h2>
<?php
while (($data = $syntheses_req->fetch()) !== false) {
$file_id = $data["file_id"];
$dest = $data["dest"];
$version = $data["version"];
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 />";
/** @var Synthesis $synthesis */
foreach ($syntheses 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 />";
}
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";

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 />";
?>
<?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>
<?php } ?>
@ -60,38 +60,21 @@ if ($tournament->isFinal())
</thead>
<tbody>
<?php
/** @noinspection PhpUndefinedVariableInspection */
while (($team_data = $teams_response->fetch()) != false) {
/** @var Team $team */
foreach ($teams as $team) {
?>
<tr>
<td style="border: 1px solid black; text-align: center">
<?php
if (isset($_SESSION["role"]) && ($_SESSION["role"] == Role::ADMIN || ($_SESSION["role"] == Role::ORGANIZER && in_array($_SESSION["user_id"], $orgas_id))))
echo "<a href=\"$URL_BASE/equipe/" . $team_data["trigram"] . "\">" . $team_data["name"] . "</a>";
if (isset($_SESSION["role"]) && ($_SESSION["role"] == Role::ADMIN || ($_SESSION["role"] == Role::ORGANIZER && $tournament->organize($_SESSION["user_id"]))))
echo "<a href=\"$URL_BASE/equipe/" . $team->getTrigram() . "\">" . $team->getName(). "</a>";
else
echo $team_data["name"];
?>
</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;
}
echo $team->getName();
?>
</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>
<?php
}
@ -140,7 +123,7 @@ else {
<select style="width: 100%;" id="organizer" name="organizer[]" multiple size="4" required>
<?php
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";
}
?>

View File

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