diff --git a/server_files/ajouter_tournoi.php b/server_files/ajouter_tournoi.php
index 829edee..7c73a88 100644
--- a/server_files/ajouter_tournoi.php
+++ b/server_files/ajouter_tournoi.php
@@ -80,12 +80,17 @@ function registerTournament() {
return "Une date est mal formée.";
$description = htmlspecialchars($_POST["description"]);
+
+ $final = isset($_POST["final"]) && $_POST["final"];
+
+ if ($final && $DB->query("SELECT `id` FROM `tournaments` WHERE `final` = true AND `year` = $YEAR;")->fetch() !== false)
+ return "Une finale est déjà enregistrée.";
$req = $DB->prepare("INSERT INTO `tournaments` (`name`, `size`, `place`, `price`, `description`,
- `date_start`, `date_end`, `date_inscription`, `date_solutions`, `date_syntheses`, `year`)
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
+ `date_start`, `date_end`, `date_inscription`, `date_solutions`, `date_syntheses`, `final`, `year`)
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
$req->execute([$name, $size, $place, $price, $description, $date_start, $date_end,
- "$date_inscription $time_inscription", "$date_solutions $time_solutions", "$date_syntheses $time_syntheses", $YEAR]);
+ "$date_inscription $time_inscription", "$date_solutions $time_solutions", "$date_syntheses $time_syntheses", $final, $YEAR]);
$req = $DB->query("SELECT `id` FROM `tournaments` WHERE `name` = '$name' AND `year` = $YEAR;");
$tournament_id = $req->fetch()["id"];
@@ -175,7 +180,8 @@ if (!isset($_SESSION["role"]) or $_SESSION["role"] != "ADMIN") {
diff --git a/server_files/config.php b/server_files/config.php
index c90bb7a..2ee4d36 100644
--- a/server_files/config.php
+++ b/server_files/config.php
@@ -41,11 +41,18 @@ if (isset($_SESSION["user_id"])) {
}
if (isset($_SESSION["user_id"]) && isset($_SESSION["team_id"]) && $_SESSION["team_id"] != NULL) {
- $response = $DB->query("SELECT `tournament`, `validation_status` FROM `teams` WHERE `id` ='" . $_SESSION["team_id"] . "' AND `year` = '$YEAR';");
+ $response = $DB->query("SELECT `tournament`, `validation_status`, `final_selection` FROM `teams` WHERE `id` ='" . $_SESSION["team_id"] . "' AND `year` = '$YEAR';");
$data = $response->fetch();
$_SESSION["tournament_id"] = $data["tournament"];
$_SESSION["team_validation_status"] = $data["validation_status"];
}
+
+ if ((isset($data["final_selection"]) && $data["final_selection"]) || $_SESSION["role"] == "ADMIN" || $_SESSION["role"] == "ORGANIZER") {
+ $response = $DB->query("SELECT `id`, `name` FROM `tournaments` WHERE `final` AND `year` = $YEAR;");
+ $data = $response->fetch();
+ $_SESSION["final_id"] = $data["id"];
+ $_SESSION["final_name"] = $data["name"];
+ }
}
setlocale(LC_ALL, "fr_FR.utf8");
diff --git a/server_files/equipe.php b/server_files/equipe.php
index 5b945b2..60fe63f 100644
--- a/server_files/equipe.php
+++ b/server_files/equipe.php
@@ -10,13 +10,67 @@ if (isset($_POST["validate"])) {
$team_data = $DB->query("SELECT * FROM `teams` WHERE `trigram` = '$trigram' AND `year` = $YEAR;")->fetch();
+if (isset($_POST["select"])) {
+ $DB->exec("UPDATE `teams` SET `final_selection` = true, `validation_status` = 'NOT_READY' WHERE `trigram` = '$trigram' AND `year` = $YEAR;");
+ $team_data["validation_status"] = "NOT_READY";
+ $team_data["final_selection"] = true;
+ $final_id = $_SESSION["final_id"];
+ $team_id = $team_data["id"];
+
+ $sols_req = $DB->prepare("SELECT `file_id`, `problem`, COUNT(`problem`) AS `version` FROM `solutions` WHERE `team` = ? AND `tournament` = ? GROUP BY `problem`, `uploaded_at` ORDER BY `problem`, `uploaded_at` DESC;");
+ $sols_req->execute([$team_data["id"], $team_data["tournament"]]);
+ while (($sol_data = $sols_req->fetch()) !== false) {
+ $old_id = $sol_data["file_id"];
+ $alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
+
+ do {
+ $id = "";
+ for ($i = 0; $i < 64; ++$i) {
+ $id .= $alphabet[rand(0, strlen($alphabet) - 1)];
+ }
+ }
+ while (file_exists("$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`)
+ VALUES (?, ?, ?, ?);");
+ $req->execute([$id, $team_id, $_SESSION["final_id"], $sol_data["problem"]]);
+ }
+
+ $syntheses_req = $DB->prepare("SELECT `file_id`, `dest`, COUNT(`dest`) AS `version` FROM `syntheses` WHERE `team` = ? AND `tournament` = ? GROUP BY `dest`, `uploaded_at` ORDER BY `dest`, `uploaded_at` DESC;");
+ $syntheses_req->execute([$team_data["id"], $team_data["tournament"]]);
+ while (($synthese_data = $syntheses_req->fetch()) !== false) {
+ $old_id = $synthese_data["file_id"];
+ $alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
+
+ do {
+ $id = "";
+ for ($i = 0; $i < 64; ++$i) {
+ $id .= $alphabet[rand(0, strlen($alphabet) - 1)];
+ }
+ }
+ while (file_exists("$LOCAL_PATH/files/$id"));
+
+ copy("$LOCAL_PATH/files/$old_id", "$LOCAL_PATH/files/$id");
+
+ $req = $DB->prepare("INSERT INTO `syntheses`(`file_id`, `team`, `tournament`, `dest`) VALUES (?, ?, ?, ?);");
+ $req->execute([$id, $team_id, $_SESSION["final_id"], $synthese_data["dest"]]);
+ }
+}
+
if ($team_data === false)
include "404.php";
$tournament_data = $DB->query("SELECT `name`, `date_start` FROM `tournaments` WHERE `id` = '" . $team_data["tournament"] . "' AND `year` = '$YEAR';")->fetch();
-$documents_req = $DB->prepare("SELECT `file_id`, `user`, `type`, COUNT(`type`) AS `version` FROM `documents` WHERE `team` = ? GROUP BY `user`, `type` ORDER BY `user`, `type` ASC, MAX(`uploaded_at`) DESC;");
-$documents_req->execute([$team_data["id"]]);
+$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_data["id"], $team_data["tournament"]]);
+
+if ($team_data["final_selection"]) {
+ $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_data["id"], $_SESSION["final_id"]]);
+}
?>
@@ -42,6 +96,10 @@ for ($i = 1; $i <= 6; ++$i) {
$id = $user_data["id"];
echo "Participant $i : " . $user_data["first_name"] . " " . $user_data["surname"] . " ";
}
+if ($team_data["final_selection"]) {
+ $final_name = $_SESSION["final_name"];
+ echo "Équipe sélectionnée pour la finale nationale.";
+}
?>
@@ -72,11 +130,43 @@ while (($data = $documents_req->fetch()) !== false) {
}
?>
-
+
+ Autorisations pour la finale
+ 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 : Télécharger ";
+ }
+}
if ($team_data["validation_status"] == "WAITING" && $_SESSION["role"] == "ADMIN") { ?>
+
+
diff --git a/server_files/mon_equipe.php b/server_files/mon_equipe.php
index b853e37..4553d4e 100644
--- a/server_files/mon_equipe.php
+++ b/server_files/mon_equipe.php
@@ -42,9 +42,9 @@ if (isset($_POST["send_document"])) {
}
if (isset($_POST["request_validation"])) {
- if (!checkCanValidate())
- $error_message = "Votre équipe ne peut pas demander la validation : il manque soit des participants, soit des documents.";
- else {
+ if (!checkCanValidate())
+ $error_message = "Votre équipe ne peut pas demander la validation : il manque soit des participants, soit des documents.";
+ else {
$DB->exec("UPDATE `teams` SET `validation_status` = 'WAITING' WHERE `id` = " . $_SESSION["team_id"] . ";");
$_SESSION["team_validation_status"] = "WAITING";
}
@@ -56,8 +56,8 @@ if (isset($_SESSION["user_id"]) && isset($_SESSION["team_id"])) {
$tournament_data = $DB->query("SELECT `name`, `date_start` FROM `tournaments` WHERE `id` = '" . $team_data["tournament"] . "' AND `year` = '$YEAR';")->fetch();
- $documents_req = $DB->prepare("SELECT `file_id`, `type`, COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? GROUP BY `type`, `uploaded_at` ORDER BY `type`, `uploaded_at` DESC;");
- $documents_req->execute([$_SESSION["user_id"]]);
+ $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[isset($_SESSION["final_id"]) ? "final_id" : "tournament_id"]]);
}
if (isset($_POST["team_edit"])) {
@@ -97,7 +97,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["tournament_id"], $type]);
+ $req->execute([$id, $_SESSION["user_id"], $_SESSION["team_id"], $_SESSION[isset($_SESSION["final_id"]) ? "final_id" : "tournament_id"], $type]);
return false;
}
@@ -143,9 +143,10 @@ function updateTeam()
return false;
}
-function checkCanValidate() {
- global $DB, $team_data, $tournament_data, $YEAR;
- $can_validate = $team_data["validation_status"] == "NOT_READY";
+function checkCanValidate()
+{
+ global $DB, $team_data, $tournament_data, $YEAR;
+ $can_validate = $team_data["validation_status"] == "NOT_READY";
$can_validate &= $team_data["encadrant_1"] != NULL;
$can_validate &= $team_data["participant_4"] != NULL;
for ($i = 1; $i <= 2; ++$i) {
@@ -226,6 +227,10 @@ for ($i = 1; $i <= 6; ++$i) {
}
?>
Code d'accès :
+Équipe sélectionnée pour la finale nationale. ";
+} ?>
@@ -278,28 +283,28 @@ Code d'accès :
Modifier mon équipe
-
- Mes autorisations
- 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 : Télécharger ";
+
+
+ Mes autorisations
+ 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 : Télécharger ";
+ }
+ if ($team_data["validation_status"] == "NOT_READY") { ?>
-
-
-
diff --git a/server_files/solutions.php b/server_files/solutions.php
index 4e4f85f..4699162 100644
--- a/server_files/solutions.php
+++ b/server_files/solutions.php
@@ -9,11 +9,11 @@ if (isset($_POST["send_solution"])) {
$error_message = saveSolution();
}
-$solutions_req = $DB->prepare("SELECT `file_id`, `problem`, COUNT(`problem`) AS `version` FROM `solutions` WHERE `team` = ? GROUP BY `problem`, `uploaded_at` ORDER BY `problem`, `uploaded_at` DESC;");
-$solutions_req->execute([$_SESSION["team_id"]]);
+$solutions_req = $DB->prepare("SELECT `file_id`, `problem`, COUNT(`problem`) AS `version` FROM `solutions` WHERE `team` = ? AND `tournament` = ? GROUP BY `problem`, `uploaded_at` ORDER BY `problem`, `uploaded_at` DESC;");
+$solutions_req->execute([$_SESSION["team_id"], $_SESSION[isset($_SESSION["final_id"]) ? "final_id" : "tournament_id"]]);
$tournament_req = $DB->prepare("SELECT `date_solutions` FROM `tournaments` WHERE `id` = ?;");
-$tournament_req->execute([$_SESSION["tournament_id"]]);
+$tournament_req->execute([$_SESSION[isset($_SESSION["final_id"]) ? "final_id" : "tournament_id"]]);
$tournament_data = $tournament_req->fetch();
function saveSolution() {
@@ -52,8 +52,7 @@ function saveSolution() {
if (!rename($file["tmp_name"], "$LOCAL_PATH/files/$id"))
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, $_SESSION["team_id"], $_SESSION["tournament_id"], $problem]);
return false;
@@ -74,14 +73,14 @@ function saveSolution() {
|