query("SELECT *, COUNT(`dest`) AS `version` FROM `syntheses` WHERE `tournament` = '$id' GROUP BY `team`, `dest`, `uploaded_at` ORDER BY `team`, `dest`, `uploaded_at` DESC;"); $zip = new ZipArchive(); $temp = tempnam("tmp", "tfjm-"); if ($zip->open($temp, ZipArchive::CREATE) !== true) { 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_data = $DB->query("SELECT `name`, `trigram` FROM `teams` WHERE `id` = '$team_id' AND `year` = $YEAR;")->fetch(); $team_name = $team_data["name"]; $team_trigram = $team_data["trigram"]; $zip->addFile("$LOCAL_PATH/files/$file_id", "Note de synthèse $team_trigram pour " . ($dest == "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-Length: " . strval(filesize($temp) + 1)); readfile($temp); exit(); } ?> query("SELECT `tournaments`.`id`, `name` FROM `tournaments` JOIN `organizers` ON `tournament` = `tournaments`.`id` WHERE " . ($_SESSION["role"] == "ADMIN" ? "" : "`organizer` = '" . $_SESSION["user_id"] . "' AND ") . "`year` = $YEAR GROUP BY `tournament`, `name` ORDER BY `name`;"); while (($data_tournament = $req->fetch()) !== false) { echo "