mirror of
https://github.com/st-tu-dresden-praktikum/swt23w23
synced 2024-07-19 21:04:36 +02:00
Add orderRepositoryIterator in orders.html
This commit is contained in:
parent
dcae05cd24
commit
895b68c028
|
@ -4,6 +4,7 @@ import org.aspectj.weaver.ast.Or;
|
|||
import org.salespointframework.quantity.Quantity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -17,6 +18,7 @@ public class CustomOrder {
|
|||
private Map<String, Quantity> products;
|
||||
private boolean invoiceAvailable;
|
||||
private double totalCost; // this is in €
|
||||
private DateTimeFormatter formatter;
|
||||
|
||||
public CustomOrder(OrderType orderType, LocalDateTime start, LocalDateTime finish, Map<String, Quantity> products, boolean invoiceAvailable, double totalCost) {
|
||||
this.orderType = orderType;
|
||||
|
@ -25,6 +27,7 @@ public class CustomOrder {
|
|||
this.products = products;
|
||||
this.invoiceAvailable = invoiceAvailable;
|
||||
this.totalCost = totalCost;
|
||||
this.formatter = DateTimeFormatter.ofPattern("MM.dd.yyy, HH:mm 'Uhr'");
|
||||
}
|
||||
|
||||
public OrderType getOrderType() {
|
||||
|
@ -35,15 +38,23 @@ public class CustomOrder {
|
|||
return start;
|
||||
}
|
||||
|
||||
public String getFormattedStart() {
|
||||
return start.format(formatter);
|
||||
}
|
||||
|
||||
public LocalDateTime getFinish() {
|
||||
return finish;
|
||||
}
|
||||
|
||||
public String getFormattedFinish() {
|
||||
return finish.format(formatter);
|
||||
}
|
||||
|
||||
public Map<String, Quantity> getProducts() {
|
||||
return products;
|
||||
}
|
||||
|
||||
public boolean isInvoiceAvailable() {
|
||||
public boolean invoiceAvailable() {
|
||||
return invoiceAvailable;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ public class CustomOrderDataInitializer implements DataInitializer {
|
|||
LocalDateTime.of(2023, 12, 5, 18, 0),
|
||||
LocalDateTime.of(2023, 12, 5, 23, 0),
|
||||
products,
|
||||
true,
|
||||
false,
|
||||
2000.0
|
||||
));
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class CustomOrderDataInitializer implements DataInitializer {
|
|||
products.put("Käseplatte", Quantity.of(1000));
|
||||
products.put("Wiener Würstchen", Quantity.of(150));
|
||||
orderRepository.addOrder(new CustomOrder(
|
||||
CustomOrder.OrderType.SUSHI_NIGHT,
|
||||
CustomOrder.OrderType.EVENT_CATERING,
|
||||
LocalDateTime.of(2023, 10, 2, 11, 0),
|
||||
LocalDateTime.of(2023, 10, 3, 8, 0),
|
||||
products,
|
||||
|
|
|
@ -2,6 +2,7 @@ package catering.order;
|
|||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
@ -26,6 +27,6 @@ public class CustomOrderRepository {
|
|||
}
|
||||
|
||||
public Collection<CustomOrder> getOrders() {
|
||||
return this.orders;
|
||||
return new ArrayList<>(this.orders);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import org.springframework.stereotype.Controller;
|
|||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Controller
|
||||
public class OrderController {
|
||||
|
||||
|
@ -15,6 +17,7 @@ public class OrderController {
|
|||
|
||||
@GetMapping("/orders")
|
||||
public String orders(Model model) {
|
||||
model.addAttribute("orders", orderRepository.getOrders());
|
||||
model.addAttribute("total", orderRepository.getOrders().size());
|
||||
return "orders";
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
</div>
|
||||
|
||||
<div>
|
||||
<h1>Auftragsliste</h1>
|
||||
<h1>Auftragsliste</h1>
|
||||
</div>
|
||||
|
||||
<div> <!--th:unless"${cart.empty}"-->
|
||||
|
@ -25,56 +25,49 @@
|
|||
<th>Von</th>
|
||||
<th>Bis</th>
|
||||
<th>Kunde</th>
|
||||
<th>Produkt</th>
|
||||
<th>Produktdetails</th>
|
||||
<th>Rechnung</th>
|
||||
<th>Bezahlt</th>
|
||||
<th>Preis</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<tr> <!--später th:each="cart.products"-->
|
||||
<td>01.10.2024 0:00Uhr</td>
|
||||
<td>30.10.2023 23:59Uhr</td>
|
||||
<td>Hans Käse</td>
|
||||
<tr th:each="order : ${orders}"> <!--später th:each="cart.products"-->
|
||||
<td th:text="${order.getFormattedStart()}">
|
||||
<td th:text="${order.getFormattedFinish()}">
|
||||
<td th:text="BeispielKunde"/>
|
||||
<td>
|
||||
<a href="#productDetails">Mobile Breakfast</a>
|
||||
<a href="#productDetails" th:text="${order.getOrderType()}"/>
|
||||
</td>
|
||||
<td>
|
||||
noch keine Rechnung verfügbar <!--th:if="product.hasBill"-->
|
||||
<div th:if="${order.invoiceAvailable()}">
|
||||
<a href="#invoice">Rechnung</a>
|
||||
</div>
|
||||
<div th:unless="${order.invoiceAvailable()}">
|
||||
<span>Keine Rechnung verfügbar</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>☒</td> <!--von Admin bearbeitbar-->
|
||||
<td>10550,99€</td>
|
||||
<td>
|
||||
<th:block th:text="${order.getTotalCost()}"/>
|
||||
<th:block th:text="€"/>
|
||||
</td>
|
||||
<td> <!--th:if="product.isRemovable"-->
|
||||
<button type="button">Entfernen</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>24.11.2023 10:00Uhr</td>
|
||||
<td>24.11.2023 15:00Uhr</td>
|
||||
<td>Hans Käse</td>
|
||||
<td>
|
||||
<a href="#productDetails">Rent-a-Cook</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="#bill">Rechnung</a> <!--th:if="product.hasBill"-->
|
||||
</td>
|
||||
<td>☑</td>
|
||||
<td>350,99</td>
|
||||
<td> <!--th:if="product.isRemovable"-->
|
||||
<button type="button">Entfernen</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<span>
|
||||
<th:block th:text="Total:"/>
|
||||
<th:block th:text="Insgesamt "/>
|
||||
<th:block th:text="${total}"/>
|
||||
<th:block th:text=" Aufträge"/>
|
||||
</span>
|
||||
</body>
|
||||
|
||||
<footer style="bottom: 0; position: absolute;">
|
||||
<p>© Hannes Wurst @ Mampf GmbH</p>
|
||||
<p>
|
||||
<p>© Hannes Wurst @ Mampf GmbH</p>
|
||||
<p>
|
||||
<a href="mailto:catering@mampf.com">catering@mampf.com</a>
|
||||
</p>
|
||||
</footer>
|
||||
|
|
Loading…
Reference in a new issue