mirror of
https://github.com/st-tu-dresden-praktikum/swt23w23
synced 2024-07-19 21:04:36 +02:00
Add calender to OrderController
calender can't count orders per day
This commit is contained in:
parent
24e4ce63dc
commit
397027a650
|
@ -1,15 +1,15 @@
|
||||||
package catering.order;
|
package catering.order;
|
||||||
|
|
||||||
import org.salespointframework.quantity.Quantity;
|
|
||||||
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.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class OrderController {
|
public class OrderController {
|
||||||
|
|
||||||
|
@ -88,4 +88,40 @@ public class OrderController {
|
||||||
|
|
||||||
return "redirect:/event";
|
return "redirect:/event";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/orders/calender")
|
||||||
|
public String calender(Model model) {
|
||||||
|
LocalDate startDate = LocalDate.now();
|
||||||
|
|
||||||
|
ArrayList<ArrayList<ArrayList<String>>> weeksOfMonth = new ArrayList<ArrayList<ArrayList<String>>>(4);
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
ArrayList<LocalDate> datesOfTheWeek = new ArrayList<LocalDate>(7);
|
||||||
|
LocalDate startOfWeek = startDate.plusDays(7*i);
|
||||||
|
LocalDate endOfWeekDate = startOfWeek.plusDays(6);
|
||||||
|
for (LocalDate date = startOfWeek; !date.isAfter(endOfWeekDate); date = date.plusDays(1)) {
|
||||||
|
datesOfTheWeek.add(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList<ArrayList<String>> week_to_add_to_month = new ArrayList<ArrayList<String>>(7);
|
||||||
|
for (LocalDate date : datesOfTheWeek) {
|
||||||
|
ArrayList<String> x = new ArrayList<String>(2);
|
||||||
|
x.add(Integer.toString(date.getDayOfMonth()));
|
||||||
|
x.add("#OrdersToday");
|
||||||
|
week_to_add_to_month.add(x);
|
||||||
|
}
|
||||||
|
//datesOfTheWeek.clear();
|
||||||
|
weeksOfMonth.add(week_to_add_to_month);
|
||||||
|
}
|
||||||
|
|
||||||
|
// calender header with names of week
|
||||||
|
LocalDate endOfWeekDate = startDate.plusDays(6);
|
||||||
|
ArrayList<String> dayNames = new ArrayList<String>(7);
|
||||||
|
for (LocalDate date = startDate; !date.isAfter(endOfWeekDate); date = date.plusDays(1)) {
|
||||||
|
dayNames.add(date.getDayOfWeek().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
model.addAttribute("weeksOfMonth", weeksOfMonth);
|
||||||
|
model.addAttribute("dayNames", dayNames);
|
||||||
|
return "orders_calender";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,13 @@
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
|
||||||
|
|
||||||
<link th:href="@{/resources/css/style.css}" rel="stylesheet"
|
<!--<link th:href="@{/resources/css/style.css}" rel="stylesheet"-->
|
||||||
href="../static/resources/css/style.css" type="text/css"/>
|
<!--href="../static/resources/css/style.css" type="text/css"/>-->
|
||||||
|
|
||||||
<title th:text="${#strings.isEmpty(title)} ? #{home.title} : ${title}">Catering</title>
|
<title th:text="${#strings.isEmpty(title)} ? #{home.title} : ${title}">Catering</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="ui container">
|
<div>
|
||||||
<header>
|
<header>
|
||||||
<h1 th:text="${#strings.isEmpty(title)} ? #{home.title} : ${title}">Catering</h1>
|
<h1 th:text="${#strings.isEmpty(title)} ? #{home.title} : ${title}">Catering</h1>
|
||||||
</header>
|
</header>
|
||||||
|
|
85
src/main/resources/templates/orders_calender.html
Normal file
85
src/main/resources/templates/orders_calender.html
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org"
|
||||||
|
xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
|
||||||
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||||
|
layout:decorate="~{layout.html(title=calender_of_orders)}">
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
background: white;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
th,
|
||||||
|
td {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<section layout:fragment="content">
|
||||||
|
<!-- class="ui celled table"-->
|
||||||
|
<table bgcolor="lightgrey" align="center"
|
||||||
|
cellspacing="21" cellpadding="21">
|
||||||
|
|
||||||
|
<!-- The tr tag is used to enter
|
||||||
|
rows in the table -->
|
||||||
|
|
||||||
|
<!-- It is used to give the heading to the
|
||||||
|
table. We can give the heading to the
|
||||||
|
top and bottom of the table -->
|
||||||
|
|
||||||
|
<caption align="top">
|
||||||
|
<!-- Here we have used the attribute
|
||||||
|
that is style and we have colored
|
||||||
|
the sentence to make it better
|
||||||
|
depending on the web page-->
|
||||||
|
</caption>
|
||||||
|
|
||||||
|
<!-- Here th stands for the heading of the
|
||||||
|
table that comes in the first row-->
|
||||||
|
|
||||||
|
<!-- The text in this table header tag will
|
||||||
|
appear as bold and is center aligned-->
|
||||||
|
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<!-- Here we have applied inline style
|
||||||
|
to make it more attractive-->
|
||||||
|
<th th:each="dayName : ${dayNames}" style="color: white; background: purple;"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="header"
|
||||||
|
th:text="${dayName}"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<tr th:each="week : ${weeksOfMonth}">
|
||||||
|
<td th:each="day : ${week}">
|
||||||
|
<div class="content">
|
||||||
|
<div
|
||||||
|
class="header"
|
||||||
|
th:text="${day.get(0)}"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<a
|
||||||
|
class="description"
|
||||||
|
th:text="${day.get(1)}"
|
||||||
|
>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</section>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
<!--th:href="@{/orders/{id}(id=${day.id})}"-->
|
Loading…
Reference in a new issue