<?php require_once "header.php" ?>

<div class="mt-4 mb-4">
    <h2 class="display-3">
        <?= $problem == 0 ? "Équipes sans problème" : "Problème " . $problem ?>
    </h2>
</div>

<hr/>

<h2>Équipes inscrites <?= $problem > 0 ? "pour ce problème" : "sans problème choisi" ?> :</h2>

<table class="table table-striped table-bordered table-hover">
    <thead>
    <tr>
        <th scope="col">
            Équipe
        </th>
        <th scope="col">
            Trigramme
        </th>
        <th scope="col">
            Date d'inscription
        </th>
        <?php if ($problem > 0) { ?>
            <th scope="col">
                État de validation de l'inscription
            </th>
        <?php } ?>
    </tr>
    </thead>
    <tbody>
	<?php
	/** @var Team $team */
	foreach ($teams as $team) {
		?>
        <tr>
            <th scope="row">
				<?php
				if (isset($_SESSION["role"]) && $_SESSION["role"] == Role::ADMIN)
					echo "<a href=\"/equipe/" . $team->getTrigram() . "\">" . $team->getName() . "</a>";
				else
					echo $team->getName();
				?>
            </th>
            <td><?= $team->getTrigram() ?></td>
            <td><?= formatDate($team->getInscriptionDate()) ?></td>
            <?php if ($problem > 0) { ?>
                <td><?= ValidationStatus::getTranslatedName($team->getValidationStatus()) ?></td>
            <?php } ?>
        </tr>
		<?php
	}
	?>
    </tbody>
    <tfoot>
    <tr>
        <th>
            Équipe
        </th>
        <th>
            Trigramme
        </th>
        <th>
            Date d'inscription
        </th>
        <?php if ($problem > 0) { ?>
            <th>
                État de validation de l'inscription
            </th>
        <?php } ?>
    </tr>
    </tfoot>
</table>

<div class="alert alert-info">
    <a href="mailto:contact@correspondances-maths.fr?<? foreach ($validated_emails as $email) echo "bcc=" . $email . "&" ?>subject=Correspondances de Jeunes Mathématicien·ne·s" target="_blank">Envoyer un mail à toutes les équipes validées</a><br />
    <a href="mailto:contact@correspondances-maths.fr?<? foreach ($not_validated_emails as $email) echo "bcc=" . $email . "&" ?>subject=Correspondances de Jeunes Mathématicien·ne·s" target="_blank">Envoyer un mail à toutes les équipes non validées</a>
</div>

<?php require_once "footer.php" ?>