This commit is contained in:
		| @@ -12,7 +12,7 @@ import de.jottyfan.camporganizer.db.jooq.enums.EnumCamprole; | ||||
|  * | ||||
|  */ | ||||
| public class BookingBean implements Serializable, Comparable<BookingBean> { | ||||
| 	private static final long serialVersionUID = 2L; | ||||
| 	private static final long serialVersionUID = 3L; | ||||
|  | ||||
| 	private final Integer pkPerson; | ||||
| 	private final LocalDate date; | ||||
| @@ -20,6 +20,7 @@ public class BookingBean implements Serializable, Comparable<BookingBean> { | ||||
| 	private String fullname; | ||||
| 	private String role; | ||||
| 	private LocalDateTime registered; | ||||
| 	private Boolean accept; | ||||
|  | ||||
| 	public BookingBean(Integer pkPerson, LocalDate date, String camp) { | ||||
| 		this.pkPerson = pkPerson; | ||||
| @@ -110,4 +111,12 @@ public class BookingBean implements Serializable, Comparable<BookingBean> { | ||||
| 	public Integer getPkPerson() { | ||||
| 		return pkPerson; | ||||
| 	} | ||||
|  | ||||
| 	public Boolean getAccept() { | ||||
| 		return accept; | ||||
| 	} | ||||
|  | ||||
| 	public void setAccept(Boolean accept) { | ||||
| 		this.accept = accept; | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -20,6 +20,7 @@ import org.jooq.DSLContext; | ||||
| import org.jooq.Name; | ||||
| import org.jooq.Record4; | ||||
| import org.jooq.Record7; | ||||
| import org.jooq.Record8; | ||||
| import org.jooq.SelectHavingStep; | ||||
| import org.jooq.SelectSeekStep1; | ||||
| import org.jooq.impl.DSL; | ||||
| @@ -95,7 +96,7 @@ public class ConfirmationGateway { | ||||
| 	 * get all bookings with condition that this user can manage | ||||
| 	 * | ||||
| 	 * @param currentUser the current user | ||||
| 	 * @param condition the condition e.g. T_PERSON.ACCEPT.isNull() | ||||
| 	 * @param condition   the condition e.g. T_PERSON.ACCEPT.isNull() | ||||
| 	 * @return a list of booking beans; an empty one at least | ||||
| 	 */ | ||||
| 	private List<BookingBean> getListWithCondition(String currentUser, Condition condition) { | ||||
| @@ -163,7 +164,7 @@ public class ConfirmationGateway { | ||||
| 	/** | ||||
| 	 * get the result of the search | ||||
| 	 * | ||||
| 	 * @param needle the needle | ||||
| 	 * @param needle      the needle | ||||
| 	 * @param currentUser the current user | ||||
| 	 * @return a list of found beans; an empty one at least | ||||
| 	 */ | ||||
| @@ -175,9 +176,9 @@ public class ConfirmationGateway { | ||||
| 				.or(V_CAMP.YEAR.cast(String.class).containsIgnoreCase(needle)); | ||||
| 		// @formatter:on | ||||
|  | ||||
| 		SelectSeekStep1<Record7<Integer, String, String, EnumCamprole, String, Double, String>, LocalDateTime> sql = jooq | ||||
| 		SelectSeekStep1<Record8<Integer, String, String, EnumCamprole, String, Double, String, Boolean>, LocalDateTime> sql = jooq | ||||
| 		// @formatter:off | ||||
| 			.select(T_PERSON.PK, T_PERSON.FORENAME, T_PERSON.SURNAME, T_PERSON.CAMPROLE, V_CAMP.NAME, V_CAMP.YEAR, V_CAMP.LOCATION_NAME) | ||||
| 			.select(T_PERSON.PK, T_PERSON.FORENAME, T_PERSON.SURNAME, T_PERSON.CAMPROLE, V_CAMP.NAME, V_CAMP.YEAR, V_CAMP.LOCATION_NAME, T_PERSON.ACCEPT) | ||||
| 			.from(T_PERSON) | ||||
| 			.leftJoin(V_CAMP).on(V_CAMP.PK.eq(T_PERSON.FK_CAMP)) | ||||
| 			.leftJoin(T_CAMPPROFILE).on(T_CAMPPROFILE.FK_CAMP.eq(T_PERSON.FK_CAMP)) | ||||
| @@ -189,16 +190,18 @@ public class ConfirmationGateway { | ||||
| 		// @formatter:on | ||||
| 		LOGGER.debug(sql.toString()); | ||||
| 		List<BookingBean> list = new ArrayList<>(); | ||||
| 		for (Record7<Integer, String, String, EnumCamprole, String, Double, String> r : sql.fetch()) { | ||||
| 		for (Record8<Integer, String, String, EnumCamprole, String, Double, String, Boolean> r : sql.fetch()) { | ||||
| 			Integer pkPerson = r.get(T_PERSON.PK); | ||||
| 			String forename = r.get(T_PERSON.FORENAME); | ||||
| 			String surname = r.get(T_PERSON.SURNAME); | ||||
| 			EnumCamprole role = r.get(T_PERSON.CAMPROLE); | ||||
| 			String campname = r.get(V_CAMP.NAME); | ||||
| 			Double year = r.get(V_CAMP.YEAR); | ||||
| 			Boolean accept = r.get(T_PERSON.ACCEPT); | ||||
| 			BookingBean bean = new BookingBean(pkPerson, null, String.format("%s %4.0f", campname, year)); | ||||
| 			bean.setRole(role == null ? null : role.getLiteral()); | ||||
| 			bean.setFullname(new StringBuilder().append(forename).append(" ").append(surname).toString()); | ||||
| 			bean.setAccept(accept); | ||||
| 			list.add(bean); | ||||
| 		} | ||||
| 		return list; | ||||
|   | ||||
| @@ -53,9 +53,19 @@ public class ConfirmationService implements IConfirmationService { | ||||
|  | ||||
| 	@Override | ||||
| 	public String search(String needle, String linkURL, HttpServletRequest request) { | ||||
| 		StringBuilder buf = new StringBuilder("<table class=\"table table-striped\"><thead><tr><th>Name</th><th>Freizeit</th><th>Rolle</th></tr><tbody>"); | ||||
| 		StringBuilder buf = new StringBuilder( | ||||
| 				"<table class=\"table table-striped\"><thead><tr><th>Dabei</th><th>Name</th><th>Freizeit</th><th>Rolle</th></tr><tbody>"); | ||||
| 		for (BookingBean bean : gateway.getSearchResult(needle, getCurrentUser(request))) { | ||||
| 			buf.append(String.format("<tr><td><a href=\"%s/%d\">%s</a></td><td>%s</td><td>%s</td></tr>", linkURL, bean.getPkPerson(), bean.getFullname(), bean.getCamp(), bean.getRolename())); | ||||
| 			String acceptHtml = ""; | ||||
| 			if (bean.getAccept() == null) { | ||||
| 				acceptHtml = "<i class=\"fas fa-question framed framed-orange\"></i>"; | ||||
| 			} else if (bean.getAccept()) { | ||||
| 				acceptHtml = "<i class=\"fas fa-check framed framed-green\"></i>"; | ||||
| 			} else { | ||||
| 				acceptHtml = "<i class=\"fas fa-ban framed framed-red\"></i>"; | ||||
| 			} | ||||
| 			buf.append(String.format("<tr><td>%s</td><td><a href=\"%s/%d\">%s</a></td><td>%s</td><td>%s</td></tr>", | ||||
| 					acceptHtml, linkURL, bean.getPkPerson(), bean.getFullname(), bean.getCamp(), bean.getRolename())); | ||||
| 		} | ||||
| 		buf.append("</tbody></table>"); | ||||
| 		return buf.toString(); | ||||
|   | ||||
| @@ -140,6 +140,7 @@ public class PersonGateway { | ||||
| 			.set(T_PERSON.EMAIL, bean.getEmail()) | ||||
| 			.set(T_PERSON.COMMENT, bean.getComment()) | ||||
| 			.set(T_PERSON.ACCEPT, bean.getAccept()) | ||||
| 			.set(T_PERSON.CAMPROLE, bean.getCamprole()) | ||||
| 			.where(T_PERSON.PK.eq(bean.getPk())); | ||||
| 		// @formatter:on | ||||
| 		LOGGER.debug(sql.toString()); | ||||
|   | ||||
| @@ -89,7 +89,7 @@ | ||||
| 				<div class="row mb-2"> | ||||
| 					<label for="outputCamprole" class="col-sm-2 col-form-label">Rolle</label> | ||||
| 					<div class="col-sm-10"> | ||||
| 						<select class="outputCamprole form-select locked" th:field="*{camprole}" disabled="disabled"> | ||||
| 						<select class="outputCamprole form-select" th:field="*{camprole}"> | ||||
| 							<option value="student">Teilnehmer</option> | ||||
| 							<option value="teacher">Mitarbeiter</option> | ||||
| 							<option value="director">Leiter</option> | ||||
| @@ -112,11 +112,14 @@ | ||||
| 				<div class="row mb-2"> | ||||
| 					<label for="inputAccept" class="col-sm-2 col-form-label">Status</label> | ||||
| 					<div class="col-sm-10"> | ||||
| 						<select class="form-select" th:field="*{accept}"> | ||||
| 							<option th:value="null">offen</option> | ||||
| 							<option th:value="true">bestätigt</option> | ||||
| 							<option th:value="false">abgelehnt</option> | ||||
| 						</select> | ||||
| 						<div class="form-group"> | ||||
| 								<input type="radio" class="btn-check" id="accept1" name="accept1" value="" th:field="*{accept}" /> | ||||
| 								<label class="btn btn-outline-primary" for="accept1"><i class="fas fa-question"></i> offen</label> | ||||
| 								<input type="radio" class="btn-check" id="accept2" name="accept2" value="true" th:field="*{accept}" /> | ||||
| 								<label class="btn btn-outline-success" for="accept2"><i class="fas fa-check"></i> bestätigt</label> | ||||
| 								<input type="radio" class="btn-check" id="accept3" name="accept3" value="false" th:field="*{accept}" /> | ||||
| 								<label class="btn btn-outline-danger" for="accept3"><i class="fas fa-ban"></i> abgelehnt</label> | ||||
| 						</div> | ||||
| 					</div> | ||||
| 				</div> | ||||
| 				<div class="row mb-2"> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user