<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" layout:decorate="~{template}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
<title>Camp Organizer 2</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
	<th:block layout:fragment="content">
		<div class="mainpage">
			<!-- list of camps -->
			<div class="container">
				<div class="row">
					<div class="col">
						<div style="text-align: center" class="menufont">Hier kannst du dich zu den Freizeiten anmelden:</div>
					</div>
				</div>
				<br />
				<div class="row">
					<div th:replace="~{/fragments/camplist.html::camplist(camps=${camps})}"></div>
				</div>
			</div>
			<br />

			<!-- registrations -->
			<script type="text/javascript">
				function mark(e) {
					$(e).css("background", "orange");
				}
			</script>
			<div class="alert alert-primary menufont" th:if="${mybookings.size() < 1}">Es wurden noch keine Anmeldungen für eine Freizeit hinterlegt.</div>
			<div th:if="${mybookings.size() > 0}" class="menufont" style="text-align: center">Deine bisherigen Anmeldungen:</div>
			<div class="accordion" id="acc" th:if="${mybookings.size() > 0}" style="max-width: 800px; margin-left: auto; margin-right: auto">
				<div class="accordion-item" th:each="b : ${mybookings}">
					<h2 class="accordion-header" th:id="'acc-head-' + ${b.pk}" th:if="${b.pk}">
						<button th:class="'accordion-button collapsed acc_' + ${b.isOver ? 'over' : b.progress}" type="button" data-bs-toggle="collapse" th:data-bs-target="'#acc-body-' + ${b.pk}"
							aria-expanded="true" th:aria-controls="'#acc-body-' + ${b.pk}">
							<i class="fas fa-check framed framed-green" th:if="${b.progress} == 'approved'"></i>
							<i class="fas fa-ban framed framed-red" th:if="${b.progress} == 'rejected'"></i>
							<i class="fas fa-question framed framed-orange" th:if="${b.progress} == 'requested'"></i>
							<i class="fas fa-trash framed framed-pink" th:if="${b.progress} == 'revoked'"></i>
							<span th:text="${b.forename + ' ' + b.surname + ' @ ' + b.campName + ' ' + #numbers.formatInteger(b.year, 4)}" class="headlinefont"></span>
						</button>
					</h2>
					<div th:id="'acc-body-' + ${b.pk}" class="accordion-collapse collapse" th:aria-labelledby="'acc-head-' + ${b.pk}">
						<div class="accordion-body">
							<div class="card">
								<div class="card-header">Freizeitdaten</div>
								<div class="card-body">
									<div class="container">
										<div class="row">
											<div class="col-sm-2">Ort:</div>
											<div class="col-sm-10">
												<a th:href="${b.url}" target="_blank" th:text="${b.locationName}"></a>
											</div>
											<div class="col-sm-2">Zeit:</div>
											<div class="col-sm-10">
												<span th:text="${#temporals.format(b.arrive, 'dd.MM.') + ' - ' + #temporals.format(b.depart, 'dd.MM.yyyy')}" th:if="${b.arrive != null and b.depart != null}"></span>
											</div>
											<div class="col-sm-2">Preis:</div>
											<div class="col-sm-10" th:text="${b.price}"></div>
											<div class="col-sm-2">Ferien:</div>
											<div class="col-sm-10" th:text="${b.countries}"></div>
										</div>
									</div>
								</div>
							</div>
							<div class="card" th:if="${b.progress} == 'approved'">
								<div class="card-header">Dokumente</div>
								<div class="card-body">
									<div class="container">
										<div class="row">
											<div class="col-sm-12 col-md-6 col-lg-4" th:each="d : ${b.documents}">
												<a th:href="@{'/document/' + ${d.pk}}" th:text="${d.name}"></a>
											</div>
										</div>
									</div>
								</div>
							</div>
							<div class="card">
								<div class="card-header">Teilnehmerdaten</div>
								<div class="card-body">
									<form th:action="@{/dashboard/update}" th:object="${b}" method="post">
										<input type="hidden" th:value="*{pk}" name="pk" />
										<div class="container">
											<div class="row mb-2">
												<div class="col-sm-2">Rolle:</div>
												<span class="col-sm-10"> <span th:if="${b.isTeacher()}">Mitarbeiter</span> <span th:if="${b.isStudent()}">Teilnehmer</span> <span th:if="${b.isDirector()}">Leiter</span> <span
													th:if="${b.isFeeder()}">Küchenteam</span> <span th:if="${b.isObserver()}">Mitarbeiterkind</span>
												</span>
											</div>
											<div class="row mb-2">
												<div class="col-sm-2">Geschlecht:</div>
												<span class="col-sm-10"> <span th:if="${b.isMale()}">männlich</span> <span th:if="${b.isFemale()}">weiblich</span> <i class="fas fa-info framed framed-white"
													title="Änderungen am Geschlecht wirken sich auch auf den Anmeldestatus aus. Wenn Du Dein Geschlecht ändern möchtest, lösche bitte diese Anmeldung und leg eine neue an. Dann wird neu entschieden, ob noch ein Platz frei ist."></i>
												</span>
											</div>
											<div class="row mb-2">
												<div class="col-sm-2">Vorname:</div>
												<span class="col-sm-10"><input type="text" class="form-control" th:value="*{forename}" name="forename" onchange="mark(this)" /></span>
											</div>
											<div class="row mb-2">
												<div class="col-sm-2">Nachname:</div>
												<span class="col-sm-10"><input type="text" class="form-control" th:value="*{surname}" name="surname" onchange="mark(this)" /></span>
											</div>
											<div class="row mb-2">
												<div class="col-sm-2">Straße:</div>
												<span class="col-sm-10"><input type="text" class="form-control" th:value="*{street}" name="street" onchange="mark(this)" /></span>
											</div>
											<div class="row mb-2">
												<div class="col-sm-2">PLZ:</div>
												<span class="col-sm-10"><input type="text" class="form-control" th:value="*{zip}" name="zip" onchange="mark(this)" /></span>
											</div>
											<div class="row mb-2">
												<div class="col-sm-2">Ort:</div>
												<span class="col-sm-10"><input type="text" class="form-control" th:value="*{city}" name="city" onchange="mark(this)" /></span>
											</div>
											<div class="row mb-2">
												<div class="col-sm-2">Telefon:</div>
												<span class="col-sm-10"><input type="text" class="form-control" th:value="*{phone}" name="phone" onchange="mark(this)" /></span>
											</div>
											<div class="row mb-2">
												<div class="col-sm-2">Geburtstag:</div>
												<span class="col-sm-10" th:text="${#temporals.format(b.birthdate, 'dd.MM.yyyy')}"></span>
											</div>
											<div class="row mb-2">
												<div class="col-sm-2">E-Mail:</div>
												<span class="col-sm-10"><input type="text" class="form-control" th:value="*{email}" name="email" onchange="mark(this)" /></span>
											</div>
											<div class="row mb-2">
												<div class="col-sm-12">Foto-Einverständnis:&nbsp;
 												  <a th:href="@{/registration/toggleconsent/{id}(id=${b.pk})}" th:if="${!b.consentCatalogPhoto}"><i class="fas fa-ban framed framed-red" ></i></a>
												  <a th:href="@{/registration/toggleconsent/{id}(id=${b.pk})}" th:if="${b.consentCatalogPhoto}"><i class="fas fa-check framed framed-green" ></i></a>
												</div>
											</div>
											<div class="row mb-2">
												<div class="col-sm-2">Kommentar:</div>
												<span class="col-sm-10"><textarea class="form-control" th:text="*{comment}" name="comment" onchange="mark(this)"></textarea></span>
											</div>
											<div class="row mb-2">
												<div class="col-sm-2"></div>
												<div class="col-sm-8">
													<input type="submit" class="btn btn-primary" value="Änderungen übernehmen" />
												</div>
												<div class="col-sm-2" th:if="${b.progress != 'revoked'}">
													<a th:href="@{/registration/revoke/{id}(id=${b.pk})}" class="btn btn-outline-danger" th:if="${!b.isOver}">stornieren</a>
												</div>
												<div class="col-sm-2" th:if="${b.progress == 'revoked'}">
													<a th:href="@{/registration/unrevoke/{id}(id=${b.pk})}" class="btn btn-outline-success" th:if="${!b.isOver}">Stornierung aufheben</a>
												</div>
											</div>
										</div>
									</form>
								</div>
							</div>
							<div class="alert alert-primary" th:if="${b.created != null}">
								angemeldet am <span th:text="${#temporals.format(b.created, 'dd.MM.yyyy')}"></span> von <span th:text="${b.subscriber}"></span>
							</div>
							<div class="alert alert-danger" th:if="${b.progress == 'revoked'}">
								storniert von <span th:text="${b.subscriber}"></span>
							</div>
							<div th:class="'alert alert-' + (${b.progress} == 'approved' ? 'success' : 'danger')" th:if="${#lists.contains({'approved', 'rejected'}, b.progress)}">
								<span th:if="${b.progress} == 'approved'">bestätigt</span>
								<span th:if="${b.progress} == 'rejected'">abgelehnt</span> von <span th:text="${b.registrator}"></span>
							</div>
							<div class="alert alert-warning" th:if="${b.isOver}">Die Freizeit ist bereits vorbei.</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</th:block>
</body>
</html>