1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-06-25 18:17:28 +02:00

Génération automatique des fichiers

This commit is contained in:
Yohann D'ANELLO
2020-01-18 17:26:12 +01:00
parent 7d6e899f76
commit 1909dd3835
13 changed files with 544 additions and 4 deletions

View File

@ -0,0 +1,52 @@
<?php
/**
* @var User $user
* @var Team $team
* @var Tournament $tournament
*/
$user = $_SESSION["user"];
$team = $_SESSION["team"];
if (!isset($user) || isset($_GET["blank"]) || $_SESSION["role"] == Role::ORGANIZER || $_SESSION["role"] == Role::ADMIN) {
$tournament = Tournament::fromName($_GET["blank"]);
$majeur = isset($_SESSION["mineur"]) ? 0 : 1;
$tex = file_get_contents("assets/Autorisation_droit_image_" . ($majeur ? "majeur" : "mineur") . ".tex");
if ($tournament == null)
require_once "server_files/403.php";
$tex = preg_replace("#{PARTICIPANT_NAME}#", "\\dotfill .", $tex);
$tex = preg_replace("#{BIRTHDAY}#", "\phantom{232323}/\phantom{232323}/\phantom{232323}", $tex);
$tex = preg_replace("#{ADDRESS}#", "\dotfill .\\\n.\dotfill .", $tex);
}
else {
$tournament = $team->getEffectiveTournament();
$majeur = $user->getBirthDate() > strval($YEAR - 18) . substr($tournament->getStartDate(), 4);
$tex = file_get_contents("assets/Autorisation_droit_image_" . ($majeur ? "majeur" : "mineur") . ".tex");
$tex = preg_replace("#{PARTICIPANT_NAME}#", "\\texttt{" . $user->getFirstName() . " " . $user->getSurname() . "}", $tex);
$tex = preg_replace("#{BIRTHDAY}#", "\\texttt{" . strftime("%d %B %G", strtotime($user->getBirthDate())) . "}", $tex);
$tex = preg_replace("#{ADDRESS}#", "\\texttt{" . $user->getAddress() . ", " . $user->getPostalCode() . ", " . $user->getCity()
. ($user->getCountry() == "France" ? "" : $user->getCountry()) . "}.", $tex);
}
$tex = preg_replace("#{TOURNAMENT_NAME}#", $tournament->getName(), $tex);
$tex = preg_replace("#{PLACE}#", $tournament->getPlace(), $tex);
$tex = preg_replace("#{START_DATE}#", strftime("%d %B", strtotime($tournament->getStartDate())), $tex);
$tex = preg_replace("#{END_DATE}#", strftime("%d %B", strtotime($tournament->getEndDate())), $tex);
$tex = preg_replace("#{YEAR}#", $YEAR, $tex);
shell_exec("mkdir tmp");
file_put_contents("tmp/file.tex", $tex);
shell_exec("pdflatex -synctex=1 -interaction=nonstopmode -shell-escape -output-directory=tmp tmp/file.tex");
header("Content-type: application/pdf");
readfile("tmp/file.pdf");
exit(0);

View File

@ -0,0 +1,44 @@
<?php
$tex = file_get_contents("assets/Autorisation_parentale.tex");
/**
* @var User $user
* @var Team $team
* @var Tournament $tournament
*/
$user = $_SESSION["user"];
$team = $_SESSION["team"];
if (!isset($user) || isset($_GET["blank"]) || $_SESSION["role"] == Role::ORGANIZER || $_SESSION["role"] == Role::ADMIN) {
$tournament = Tournament::fromName($_GET["blank"]);
if ($tournament == null)
require_once "server_files/403.php";
$tex = preg_replace("#{PARTICIPANT_NAME}#", "\\hrulefill", $tex);
$tex = preg_replace("#{BIRTHDAY}#", "\phantom{232323}/\phantom{232323}/\phantom{232323}", $tex);
$tex = preg_replace("#{PRONOUN}#", "Elle/il", $tex);
}
else {
$tournament = $team->getEffectiveTournament();
$tex = preg_replace("#{PARTICIPANT_NAME}#", "\\texttt{" . $user->getFirstName() . " " . $user->getSurname() . "}", $tex);
$tex = preg_replace("#{BIRTHDAY}#", "\\texttt{" . strftime("%d %B %G", strtotime($user->getBirthDate())) . "}", $tex);
$tex = preg_replace("#{PRONOUN}#", $user->getGender() == "M" ? "Il" : "Elle", $tex);
}
$tex = preg_replace("#{TOURNAMENT_NAME}#", $tournament->getName(), $tex);
$tex = preg_replace("#{PLACE}#", $tournament->getPlace(), $tex);
$tex = preg_replace("#{START_DATE}#", strftime("%d %B", strtotime($tournament->getStartDate())), $tex);
$tex = preg_replace("#{END_DATE}#", strftime("%d %B", strtotime($tournament->getEndDate())), $tex);
$tex = preg_replace("#{YEAR}#", $YEAR, $tex);
shell_exec("mkdir tmp");
file_put_contents("tmp/file.tex", $tex);
shell_exec("pdflatex -synctex=1 -interaction=nonstopmode -shell-escape -output-directory=tmp tmp/file.tex");
header("Content-type: application/pdf");
readfile("tmp/file.pdf");
exit(0);

View File

@ -0,0 +1,36 @@
<?php
$tex = file_get_contents("assets/Instructions.tex");
/**
* @var User $user
* @var Team $team
* @var Tournament $tournament
*/
$user = $_SESSION["user"];
$team = $_SESSION["team"];
if (!isset($user) || isset($_GET["blank"]) || $_SESSION["role"] == Role::ORGANIZER || $_SESSION["role"] == Role::ADMIN) {
$tournament = Tournament::fromName($_GET["blank"]);
if ($tournament == null)
require_once "server_files/403.php";
}
else {
$tournament = $team->getEffectiveTournament();
}
$tex = preg_replace("#{TOURNAMENT_NAME}#", $tournament->getName(), $tex);
$tex = preg_replace("#{PLACE}#", $tournament->getPlace(), $tex);
$tex = preg_replace("#{PRICE}#", $tournament->getPrice(), $tex);
$tex = preg_replace("#{END_PAYMENT_DATE}#", strftime("%d %B", strtotime($tournament->getInscriptionDate())), $tex);
$tex = preg_replace("#{YEAR}#", $YEAR, $tex);
shell_exec("mkdir tmp");
file_put_contents("tmp/file.tex", $tex);
shell_exec("pdflatex -synctex=1 -interaction=nonstopmode -shell-escape -output-directory=tmp tmp/file.tex");
header("Content-type: application/pdf");
readfile("tmp/file.pdf");
shell_exec("rm -rf tmp");
exit(0);

View File

@ -206,12 +206,19 @@ if (!$has_error && (isset($my_account) || isset($new_password))) {
<h1 class="display-5">Mes autorisations</h1>
</div>
<?php if ($not_validated) { ?>
<em>Ces documents peut être modifiés tant que l'équipe n'est pas validée.</em>
<div class="alert alert-warning">
Ces documents peut être modifiés tant que l'équipe n'est pas validée. Les fichiers doivent peser au maximum 2 Mo et doivent
être au format PDF.
</div>
<div class="alert alert-info">
<strong>Modèle d'autorisation de droit à l'image :</strong>
<a href="/Autorisation de droit à l'image - majeur.pdf">majeur</a> - <a
href="/Autorisation de droit à l'image - mineur.pdf">mineur</a>
<strong>Modèle de fiche sanitaire :</strong> <a href="/Fiche sanitaire.pdf">Télécharger</a><br />
<?php if ($_SESSION["user"]->getBirthDate() > strval($YEAR - 18) . substr($tournament->getStartDate(), 4)) { ?>
<strong>Modèle d'autorisation parentale :</strong> <a href="/Autorisation parentale.pdf">Télécharger</a>
- <a href="/Autorisation parentale.pdf?blank=<?= $tournament->getName() ?>">Modèle vierge</a><br />
<?php } ?>
<strong>Modèle d'autorisation de droit à l'image :</strong> <a href="/Autorisation de droits à l'image.pdf">Télécharger</a>
- <a href="/Autorisation de droit à l'image.pdf?blank=<?= $tournament->getName() ?>">Modèle vierge</a>
</div>
<?php } ?>
<?php printDocuments($documents); ?>

View File

@ -4,6 +4,10 @@
<h1 class="display-4">Tournoi de <?= $tournament->getName() ?></h1>
</div>
<div class="alert alert-info">
<strong>Instructions :</strong> <a href="/Instructions.pdf?blank=<?= $tournament->getName() ?>">Télécharger</a>
</div>
<div class="alert alert-info">
<strong>Organisateur<?= sizeof($orgas) >= 2 ? 's' : '' ?> :</strong>
<?php