added post form for marking order as delivered

This commit is contained in:
Hendrik Schutter 2020-06-05 17:37:19 +02:00
parent 5e05100d21
commit c1b9588189
5 changed files with 43 additions and 6 deletions

View File

@ -0,0 +1,7 @@
package org.hso.ecommerce.action.warehouse;
public class StoreSupplierOrderAction {
//TODO add delivery date and warehouse booking
}

View File

@ -19,7 +19,9 @@ import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.view.RedirectView;
@Controller
@RequestMapping("/intern/")
@ -83,6 +85,7 @@ public class SupplierIndexController {
return "intern/suppliers/id";
}
public class UImodelSuppliers {
long id;

View File

@ -4,6 +4,7 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import org.hso.ecommerce.entities.supplier.SupplierOrder;
import org.hso.ecommerce.repos.supplier.SupplierOrderRepository;
@ -11,7 +12,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.view.RedirectView;
@Controller
@RequestMapping("/intern/")
@ -22,7 +26,7 @@ public class SupplierOrderController {
@GetMapping("supplierOrders")
public String listSuppliers(Model model) {
List<UImodelSupplierOrder> totals = new ArrayList<UImodelSupplierOrder>();
for (SupplierOrder orders : supplierOrderRepository.findAll()) {
@ -34,6 +38,23 @@ public class SupplierOrderController {
return "intern/supplierOrders/index";
}
@PostMapping("/supplierOrders/store/{id}")
public RedirectView storeOrder(@PathVariable(required = true) String id) {
long supplierOrderID = Long.parseLong(id);
Optional<SupplierOrder> order = supplierOrderRepository.findById(supplierOrderID);
if (order.isPresent()) {
//TODO call action
System.out.println("Order is present\n");
}
return new RedirectView("../../supplierOrders/");
}
public class UImodelSupplierOrder {
long id;
String dateOrder;
@ -116,7 +137,7 @@ public class SupplierOrderController {
public void setSupplierName(String supplierName) {
this.supplierName = supplierName;
}
public UImodelSupplierOrder(SupplierOrder order) {
this.id = order.id;
this.supplierName = order.supplier.name;

View File

@ -53,11 +53,14 @@
<td><span th:text="${order.price_total}"></span></td>
<td>
<div th:if="${order.arrived}">
<a th:href="@{/intern/warehouse/todo}" class="button smaller">Angekommen</a>
Angekommen
</div>
<!-- ELSE -->
<div th:unless="${order.arrived}">
Unterwegs
Unterwegs <br>
<form class="detailgrid" action="#" th:action="@{/intern/supplierOrders/store/{id}(id = ${order.id})}" method="POST">
<input class="button smaller" type="submit" value="Eingang verbuchen" />
</form>
</div>
</td>
</tr>

View File

@ -50,11 +50,14 @@
<td><span th:text="${order.price_total}"></span></td>
<td>
<div th:if="${order.arrived}">
<a th:href="@{/intern/warehouse/todo}" class="button smaller">Angekommen</a>
Angekommen
</div>
<!-- ELSE -->
<div th:unless="${order.arrived}">
Unterwegs
Unterwegs <br>
<form class="detailgrid" action="#" th:action="@{/intern/supplierOrders/store/{id}(id = ${order.id})}" method="POST">
<input class="button smaller" type="submit" value="Eingang verbuchen" />
</form>
</div>
</td>
</tr>