diff --git a/prototype/src/main/java/org/hso/ecommerce/app/RequestController.java b/prototype/src/main/java/org/hso/ecommerce/app/RequestController.java index b49241c..b43478a 100644 --- a/prototype/src/main/java/org/hso/ecommerce/app/RequestController.java +++ b/prototype/src/main/java/org/hso/ecommerce/app/RequestController.java @@ -100,28 +100,6 @@ public class RequestController { return "intern/customerOrders/id"; } - /* - @GetMapping("/intern/suppliers/") - public String internSuppliers() { - return "intern/suppliers/index"; - } - - @GetMapping("/intern/suppliers/{id}") - public String internSuppliersId() { - return "intern/suppliers/id"; - } -*/ - - @GetMapping("/intern/supplierOrders/") - public String internSupplierOrders() { - return "intern/supplierOrders/index"; - } - - @GetMapping("/intern/supplierOrders/{id}") - public String internSupplierOrdersId() { - return "intern/supplierOrders/id"; - } - @GetMapping("/intern/accounting/") public String accounting() { return "intern/accounting/index"; diff --git a/prototype/src/main/java/org/hso/ecommerce/controller/intern/suppliers/SupplierOrderController.java b/prototype/src/main/java/org/hso/ecommerce/controller/intern/suppliers/SupplierOrderController.java index ef3acb4..b659666 100644 --- a/prototype/src/main/java/org/hso/ecommerce/controller/intern/suppliers/SupplierOrderController.java +++ b/prototype/src/main/java/org/hso/ecommerce/controller/intern/suppliers/SupplierOrderController.java @@ -1,8 +1,140 @@ package org.hso.ecommerce.controller.intern.suppliers; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.hso.ecommerce.entities.supplier.SupplierOrder; +import org.hso.ecommerce.repos.supplier.SupplierOrderRepository; +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.RequestMapping; @Controller -//@RequestMapping("...") +@RequestMapping("/intern/") public class SupplierOrderController { + + @Autowired + private final SupplierOrderRepository supplierOrderRepository = null; + + @GetMapping("supplierOrders") + public String listSuppliers(Model model) { + + List totals = new ArrayList(); + + for (SupplierOrder orders : supplierOrderRepository.findAll()) { + totals.add(new UImodelSupplierOrder(orders)); + } + + model.addAttribute("orders", totals); + + return "intern/supplierOrders/index"; + } + + public class UImodelSupplierOrder { + long id; + String dateOrder; + String supplierName; + String articleName; + long articleId; + String priceNetto; + String quantity; + String price_total; + boolean arrived; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getDateOrder() { + return dateOrder; + } + + public void setDateOrder(String dateOrder) { + this.dateOrder = dateOrder; + } + + public String getArticleName() { + return articleName; + } + + public void setArticleName(String articleName) { + this.articleName = articleName; + } + + public String getPriceNetto() { + return priceNetto; + } + + public void setPriceNetto(String priceNetto) { + this.priceNetto = priceNetto; + } + + public String getQuantity() { + return quantity; + } + + public void setQuantity(String quantity) { + this.quantity = quantity; + } + + public String getPrice_total() { + return price_total; + } + + public void setPrice_total(String price_total) { + this.price_total = price_total; + } + + public long getArticleId() { + return articleId; + } + + public void setArticleId(long articleId) { + this.articleId = articleId; + } + + public boolean isArrived() { + return arrived; + } + + public void setArrived(boolean arrived) { + this.arrived = arrived; + } + + public String getSupplierName() { + return supplierName; + } + + public void setSupplierName(String supplierName) { + this.supplierName = supplierName; + } + + public UImodelSupplierOrder(SupplierOrder order) { + this.id = order.id; + this.supplierName = order.supplier.name; + this.articleName = order.ordered.title; + this.articleId = order.ordered.id; + this.priceNetto = String.format("%.2f", ((float) order.pricePerUnitNetCent / 100)); + this.quantity = String.valueOf(order.numberOfUnits); + this.price_total = String.format("%.2f", ((float) order.totalPriceNet / 100)); + + Date date = new Date(); + date.setTime(order.created.getTime()); + this.dateOrder = new SimpleDateFormat("dd.MM.yyyy").format(date); + + if (order.delivered != null) { + arrived = true; + } else { + arrived = false; + } + } + } } diff --git a/prototype/src/main/java/org/hso/ecommerce/repos/supplier/SupplierOrderRepository.java b/prototype/src/main/java/org/hso/ecommerce/repos/supplier/SupplierOrderRepository.java index 73a041c..31c05cf 100644 --- a/prototype/src/main/java/org/hso/ecommerce/repos/supplier/SupplierOrderRepository.java +++ b/prototype/src/main/java/org/hso/ecommerce/repos/supplier/SupplierOrderRepository.java @@ -18,5 +18,8 @@ public interface SupplierOrderRepository extends JpaRepository findOrderBySupplierID(@Param("supplierId") long supplierId); + + @Query("SELECT a FROM SupplierOrder a") + List findAll(); } diff --git a/prototype/src/main/resources/templates/intern/supplierOrders/index.html b/prototype/src/main/resources/templates/intern/supplierOrders/index.html index eafe977..71db072 100644 --- a/prototype/src/main/resources/templates/intern/supplierOrders/index.html +++ b/prototype/src/main/resources/templates/intern/supplierOrders/index.html @@ -1,103 +1,71 @@ - - - - - - Lieferanten Bestellungen - - - - - - - -
- -
-

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
BestellnummerDatumLeiferantArtikelPreis/Stk (Netto)MengeGesamtpreis (Netto)Status
45452019-18-10Cheap AGKamera20,00 EUR10200,00 EURUnterwegs
Angekommen
24552019-18-10Cheap AGKamera20,00 EUR11220,00 EURUnterwegs
Angekommen
12242019-18-10Cheap AGKamera20,00 EUR11220,00 EURAngekommen
45202019-18-10Cheap AGKamera20,00 EUR11220,00 EURAngekommen
45212019-18-10Cheap AGKamera20,00 EUR11220,00 EURAngekommen
-

-
-
-
- - - + + + + Lieferanten Bestellungen + + + + + + +
+ +
+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
BestellnummerDatumLeiferantArtikelPreis/Stk (Netto)MengeGesamtpreis (Netto)Status
+ + +
+ Unterwegs +
+
+

+
+
+ + + \ No newline at end of file