Jottyfan 2022-10-22 19:19:17 +02:00
parent 796624eebd
commit 2126f4de62
7 changed files with 188 additions and 60 deletions

View File

@ -42,6 +42,30 @@ public class BookingBean implements Serializable {
private Boolean accept; private Boolean accept;
private String subscriber; private String subscriber;
public Boolean isFemale() {
return EnumSex.female.equals(sex);
}
public Boolean isMale() {
return EnumSex.male.equals(sex);
}
public Boolean isTeacher() {
return EnumCamprole.teacher.equals(camprole);
}
public Boolean isStudent() {
return EnumCamprole.student.equals(camprole);
}
public Boolean isDirector() {
return EnumCamprole.director.equals(camprole);
}
public Boolean isFeeder() {
return EnumCamprole.feeder.equals(camprole);
}
/** /**
* @return the forename * @return the forename
*/ */

View File

@ -9,6 +9,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
/** /**
* *
@ -36,9 +38,16 @@ public class IndexController extends CommonController {
public String dashboard(Model model) { public String dashboard(Model model) {
super.setupSession(model, request); super.setupSession(model, request);
model.addAttribute("mybookings", service.getBookingsOf(super.getCurrentUser(request))); model.addAttribute("mybookings", service.getBookingsOf(super.getCurrentUser(request)));
model.addAttribute("bookingBean", new BookingBean());
return "/dashboard"; return "/dashboard";
} }
@PostMapping("/dashboard/update")
public String updateBooking(Model model, @ModelAttribute BookingBean bean) {
service.update(bean);
return dashboard(model);
}
@GetMapping("/logout") @GetMapping("/logout")
public String getLogout(HttpServletRequest request) throws ServletException { public String getLogout(HttpServletRequest request) throws ServletException {
request.logout(); request.logout();

View File

@ -14,11 +14,13 @@ import org.jooq.Condition;
import org.jooq.DSLContext; import org.jooq.DSLContext;
import org.jooq.Record; import org.jooq.Record;
import org.jooq.SelectConditionStep; import org.jooq.SelectConditionStep;
import org.jooq.UpdateConditionStep;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import de.jottyfan.camporganizer.db.jooq.tables.TProfile; import de.jottyfan.camporganizer.db.jooq.tables.TProfile;
import de.jottyfan.camporganizer.db.jooq.tables.records.TPersonRecord;
import de.jottyfan.camporganizer.db.jooq.tables.records.VCampRecord; import de.jottyfan.camporganizer.db.jooq.tables.records.VCampRecord;
/** /**
@ -126,4 +128,28 @@ public class IndexGateway {
} }
return list; return list;
} }
/**
* update defined fields of the bean
*
* @param bean the bean
* @return number of affected database rows; should be 1
*/
public Integer update(BookingBean bean) {
UpdateConditionStep<TPersonRecord> sql = jooq
// @formatter:off
.update(T_PERSON)
.set(T_PERSON.FORENAME, bean.getForename())
.set(T_PERSON.SURNAME, bean.getSurname())
.set(T_PERSON.STREET, bean.getStreet())
.set(T_PERSON.ZIP, bean.getZip())
.set(T_PERSON.CITY, bean.getCity())
.set(T_PERSON.PHONE, bean.getPhone())
.set(T_PERSON.EMAIL, bean.getEmail())
.set(T_PERSON.COMMENT, bean.getComment())
.where(T_PERSON.PK.eq(bean.getPk()));
// @formatter:on
LOGGER.debug(sql.toString());
return sql.execute();
}
} }

View File

@ -36,7 +36,23 @@ public class IndexService {
return list; return list;
} }
/**
* get all bookings that the user can see
*
* @param username the name of the user
* @return a list of beans
*/
public List<BookingBean> getBookingsOf(String username) { public List<BookingBean> getBookingsOf(String username) {
return gateway.getAllBookings(username); return gateway.getAllBookings(username);
} }
/**
* update defined contents of the bean
*
* @param bean the bean
* @return true or false
*/
public Boolean update(BookingBean bean) {
return gateway.update(bean) == 1;
}
} }

View File

@ -185,23 +185,33 @@ body {
padding: 8px; padding: 8px;
margin-right: 12px; margin-right: 12px;
border-radius: 6px; border-radius: 6px;
min-width: 32px; min-width: 30px;
min-height: 30px;
text-align: center; text-align: center;
} }
.framed-green { .framed-green {
background: linear-gradient(to bottom right, lime, darkgreen); background: linear-gradient(to bottom right, lime, darkgreen);
color: white; color: white;
border: 1px solid green;
} }
.framed-red { .framed-red {
background: linear-gradient(to bottom right, red, darkred); background: linear-gradient(to bottom right, red, darkred);
color: white; color: white;
border: 1px solid red;
} }
.framed-orange { .framed-orange {
background: linear-gradient(to bottom right, orange, #bf6c06); background: linear-gradient(to bottom right, orange, #bf6c06);
color: white; color: white;
border: 1px solid orange;
}
.framed-white {
background: white;
color: black;
border: 1px solid black;
} }
.nomaxwidth { .nomaxwidth {

View File

@ -14,70 +14,113 @@
</header> </header>
<content> <content>
<div class="mainpage"> <div class="mainpage">
<script type="text/javascript">
function mark(e) {
$(e).css("background", "orange");
}
</script>
<div class="accordion" id="acc"> <div class="accordion" id="acc">
<div class="accordion-item" th:each="b : ${mybookings}"> <div class="accordion-item" th:each="b : ${mybookings}">
<h2 class="accordion-header" th:id="'acc-head-' + ${b.pk}"> <h2 class="accordion-header" th:id="'acc-head-' + ${b.pk}">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" th:data-bs-target="'#acc-body-' + ${b.pk}" aria-expanded="true" <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" th:data-bs-target="'#acc-body-' + ${b.pk}" aria-expanded="true"
th:aria-controls="'#acc-body-' + ${b.pk}"> th:aria-controls="'#acc-body-' + ${b.pk}">
<i class="fas fa-check framed framed-green" th:if="${b.accept}"></i> <i class="fas fa-check framed framed-green" th:if="${b.accept}"></i> <i class="fas fa-ban framed framed-red" th:if="${b.accept} == false"></i> <i
<i class="fas fa-ban framed framed-red" th:if="${b.accept} == false"></i> class="fas fa-question framed framed-orange" th:if="${b.accept} == null"></i> <span
<i class="fas fa-question framed framed-orange" th:if="${b.accept} == null"></i> th:text="${b.forename + ' ' + b.surname + ' an ' + b.campName + ' ' + #numbers.formatInteger(b.year, 4)}" style="font-weight: bolder"></span>&nbsp;in&nbsp;<span
<span th:text="${b.forename + ' ' + b.surname + ' an ' + b.campName + ' ' + #numbers.formatInteger(b.year, 4)}" style="font-weight: bolder"></span>&nbsp;in&nbsp;<span
th:text="${b.locationName}"></span> th:text="${b.locationName}"></span>
</button> </button>
</h2> </h2>
<div th:id="'acc-body-' + ${b.pk}" class="accordion-collapse collapse" th:aria-labelledby="'acc-head-' + ${b.pk}"> <div th:id="'acc-body-' + ${b.pk}" class="accordion-collapse collapse" th:aria-labelledby="'acc-head-' + ${b.pk}">
<div class="accordion-body"> <div class="accordion-body">
<div class="card">
<div class="card-header">Freizeitdaten</div>
<div class="card-body">
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-sm-12"> <div class="col-sm-2">Ort:</div>
<h3>Freizeitdaten</h3> <div class="col-sm-10">
</div>
<div class="col-sm-4">Ort:</div>
<div class="col-sm-8">
<a th:href="${b.url}" target="_blank" th:text="${b.locationName}"></a> <a th:href="${b.url}" target="_blank" th:text="${b.locationName}"></a>
</div> </div>
<div class="col-sm-4">Zeit:</div> <div class="col-sm-2">Zeit:</div>
<div class="col-sm-8"> <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> <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>
<div class="col-sm-4">Preis:</div> <div class="col-sm-2">Preis:</div>
<div class="col-sm-8" th:text="${b.price} + ' €'"></div> <div class="col-sm-10" th:text="${b.price}"></div>
<div class="col-sm-4">Ferien:</div> <div class="col-sm-2">Ferien:</div>
<div class="col-sm-8" th:text="${b.countries}"></div> <div class="col-sm-10" th:text="${b.countries}"></div>
</div> </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="container">
<div class="row"> <div class="row mb-2">
<div class="col-sm-12"> <div class="col-sm-2">Rolle:</div>
<h3>Teilnehmerdaten</h3> <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>
</div> </div>
<div class="col-sm-4">Rolle:</div> <div class="row mb-2">
<span class="col-sm-8" th:text="${b.camprole}"></span> <div class="col-sm-2">Geschlecht:</div>
<div class="col-sm-4">ID:</div> <span class="col-sm-10">
<span class="col-sm-8" th:text="${b.pk}"></span> <span th:if="${b.isMale()}">männlich</span>
<div class="col-sm-4">Vorname:</div> <span th:if="${b.isFemale()}">weiblich</span>
<span class="col-sm-8" th:text="${b.forename}"></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>
<div class="col-sm-4">Nachname:</div> </span>
<span class="col-sm-8" th:text="${b.surname}"></span> </div>
<div class="col-sm-4">Straße:</div> <div class="row mb-2">
<span class="col-sm-8" th:text="${b.street}"></span> <div class="col-sm-2">Vorname:</div>
<div class="col-sm-4">PLZ:</div> <span class="col-sm-10"><input type="text" class="form-control" th:value="*{forename}" name="forename" onchange="mark(this)" /></span>
<span class="col-sm-8" th:text="${b.zip}"></span> </div>
<div class="col-sm-4">Ort:</div> <div class="row mb-2">
<span class="col-sm-8" th:text="${b.city}"></span> <div class="col-sm-2">Nachname:</div>
<div class="col-sm-4">Telefon:</div> <span class="col-sm-10"><input type="text" class="form-control" th:value="*{surname}" name="surname" onchange="mark(this)" /></span>
<span class="col-sm-8" th:text="${b.phone}"></span> </div>
<div class="col-sm-4">Geburtstag:</div> <div class="row mb-2">
<span class="col-sm-8" th:text="${#temporals.format(b.birthdate, 'dd.MM.yyyy')}"></span> <div class="col-sm-2">Straße:</div>
<div class="col-sm-4">E-Mail:</div> <span class="col-sm-10"><input type="text" class="form-control" th:value="*{street}" name="street" onchange="mark(this)" /></span>
<span class="col-sm-8" th:text="${b.email}"></span> </div>
<div class="col-sm-4">Geschlecht:</div> <div class="row mb-2">
<span class="col-sm-8" th:text="${b.sex}"></span> <div class="col-sm-2">PLZ:</div>
<div class="col-sm-4">Foto-Einverständnis:</div> <span class="col-sm-10"><input type="text" class="form-control" th:value="*{zip}" name="zip" onchange="mark(this)" /></span>
<span class="col-sm-8" th:text="${b.consentCatalogPhoto}"></span> </div>
<div class="col-sm-4">Kommentar:</div> <div class="row mb-2">
<span class="col-sm-8" th:text="${b.comment}"></span> <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-2">Foto-Einverständnis:</div>
<span class="col-sm-10" th:text="${b.consentCatalogPhoto ? 'ja' : 'nein'}"></span>
</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-10">
<input type="submit" class="btn btn-primary" value="Änderungen übernehmen" />
</div>
</div>
</div>
</form>
</div> </div>
</div> </div>
<div class="alert alert-primary" th:if="${b.created != null}"> <div class="alert alert-primary" th:if="${b.created != null}">