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