<?php
require_once "header.php";

if (isset($error_message)) {
	if ($error_message !== false) {
		echo "<h2>Erreur : " . $error_message . "</h2>";
	} else {
		echo "<h2>Tournoi de " . htmlspecialchars($_POST["name"]) . " ajouté avec succès !</h2>";
	}
}?>

<form method="POST">
	<input type="hidden" name="submitted" 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" required />
			</td>
		</tr>
		<tr>
			<td>
				<label for="organizer">Organisateur :</label>
			</td>
			<td>
				<select style="width: 100%;" id="organizer" name="organizer[]" multiple size="4" required>
					<?php
					while (($data = $orgas_response->fetch()) !== FALSE) {
						echo "<option value=\"" . $data["id"] . "\">" . $data["first_name"] . " " . $data["surname"] . "</option>\n";
					}
					?>
				</select>
			</td>
		</tr>
		<tr>
			<td>
				<label for="size">Nombre d'équipes :</label>
			</td>
			<td>
				<input style="width: 100%;" type="number" id="size" name="size" min="3" max="12" value="6" required />
			</td>
		</tr>
		<tr>
			<td>
				<label for="place">Lieu :</label>
			</td>
			<td>
				<input style="width: 100%;" type="text" id="place" name="place" required />
			</td>
		</tr>
		<tr>
			<td>
				<label for="price">Prix par participant</label>
			</td>
			<td>
				<input style="width: 100%;" type="number" id="price" name="price" min="0" max="21" value="21" required />
			</td>
		</tr>
		<tr>
			<td>
				<label for="date_start">Dates :</label>
			</td>
			<td>
				Du <input style="width: 45%;" type="date" id="date_start" name="date_start" required /> au <!--suppress HtmlFormInputWithoutLabel -->
				<input style="width: 45%;" type="date" id="date_end" name="date_end" required />
			</td>
		</tr>
		<tr>
			<td>
				<label for="date_inscription">Date limite d'inscription :</label>
			</td>
			<td>
				<input style="width: 49%;" type="date" id="date_inscription" name="date_inscription" required />
				<!--suppress HtmlFormInputWithoutLabel -->
				<input style="width: 49%;" type="time" id="time_inscription" name="time_inscription" required />
			</td>
		</tr>
		<tr>
			<td>
				<label for="date_solutions">Date limite pour rendre les solutions :</label>
			</td>
			<td>
				<input style="width: 49%;" type="date" id="date_solutions" name="date_solutions" required />
				<!--suppress HtmlFormInputWithoutLabel -->
				<input style="width: 49%;" type="time" id="time_solutions" name="time_solutions" required />
			</td>
		</tr>
		<tr>
			<td>
				<label for="date_syntheses">Date limite pour rendre les notes de synthèse :</label>
			</td>
			<td>
				<input style="width: 49%;" type="date" id="date_syntheses" name="date_syntheses" required />
				<!--suppress HtmlFormInputWithoutLabel -->
				<input style="width: 49%;" type="time" id="time_syntheses" name="time_syntheses" required />
			</td>
		</tr>
		<tr>
			<td>
				<label for="description">Description :</label>
			</td>
			<td>
				<textarea style="width: 100%;" name="description" id="description" required></textarea>
			</td>
		</tr>
		<tr>
			<td>
				<label for="final">Ce tournoi est la finale nationale :</label>
			</td>
			<td>
				<input style="width: 100%;" type="checkbox" id="final" name="final" />
			</td>
		</tr>
		<tr>
			<td colspan="2">
				<input style="width: 100%;" type="submit" value="Ajouter un tournoi" />
			</td>
		</tr>
		</tbody>
	</table>
</form>

<?php require_once "footer.php" ?>