feature/supplier_page #52
							
								
								
									
										3
									
								
								prototype/scripts/addsupplierorders.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								prototype/scripts/addsupplierorders.sql
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					INSERT INTO supplier_orders ("created", "delivered", "number_of_units", "price_per_unit_net_cent", "total_price_net", "ordered_id", "supplier_id") 
 | 
				
			||||||
 | 
					VALUES ('0', '0', '42', '42', '42', '1', '1');
 | 
				
			||||||
@ -1,9 +1,15 @@
 | 
				
			|||||||
package org.hso.ecommerce.controller.intern.suppliers;
 | 
					package org.hso.ecommerce.controller.intern.suppliers;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.sql.Timestamp;
 | 
				
			||||||
 | 
					import java.text.SimpleDateFormat;
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.Date;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.hso.ecommerce.entities.supplier.ArticleOffer;
 | 
				
			||||||
import org.hso.ecommerce.entities.supplier.Supplier;
 | 
					import org.hso.ecommerce.entities.supplier.Supplier;
 | 
				
			||||||
 | 
					import org.hso.ecommerce.entities.supplier.SupplierOrder;
 | 
				
			||||||
 | 
					import org.hso.ecommerce.repos.supplier.SupplierOrderRepository;
 | 
				
			||||||
import org.hso.ecommerce.repos.supplier.SupplierRepository;
 | 
					import org.hso.ecommerce.repos.supplier.SupplierRepository;
 | 
				
			||||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
					import org.springframework.beans.factory.annotation.Autowired;
 | 
				
			||||||
import org.springframework.stereotype.Controller;
 | 
					import org.springframework.stereotype.Controller;
 | 
				
			||||||
@ -19,6 +25,9 @@ public class SupplierIndexController {
 | 
				
			|||||||
	@Autowired
 | 
						@Autowired
 | 
				
			||||||
	private final SupplierRepository supplierRepository = null;
 | 
						private final SupplierRepository supplierRepository = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Autowired
 | 
				
			||||||
 | 
						private final SupplierOrderRepository supplierOrderRepository = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@GetMapping("suppliers")
 | 
						@GetMapping("suppliers")
 | 
				
			||||||
	public String listSuppliers(Model model) {
 | 
						public String listSuppliers(Model model) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -34,17 +43,20 @@ public class SupplierIndexController {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@GetMapping("/suppliers/{id}")
 | 
						@GetMapping("/suppliers/{id}")
 | 
				
			||||||
	public String internListedArticlesId(Model model, @PathVariable String id) {
 | 
						public String supplierDetail(Model model, @PathVariable String id) {
 | 
				
			||||||
 | 
							
 | 
				
			||||||
		System.out.println("hEre!");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		int supplierId = Integer.parseInt(id);
 | 
							int supplierId = Integer.parseInt(id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		UImodelSupplierDetailOrders orders = new UImodelSupplierDetailOrders(supplierId, "01.01.1970", "orderd article",
 | 
							List<UImodelSupplierDetailOrders> orders = new ArrayList<UImodelSupplierDetailOrders>();
 | 
				
			||||||
				"netto €", "42", "total €", "31.12.1970");
 | 
							
 | 
				
			||||||
 | 
							for (SupplierOrder supplierOrder : supplierOrderRepository.findOrderBySupplierID(supplierId)) {
 | 
				
			||||||
 | 
								orders.add(new UImodelSupplierDetailOrders(supplierOrder));
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		UImodelSupplierDetail total = new UImodelSupplierDetail(supplierRepository.findSupplierById(supplierId).name,
 | 
							UImodelSupplierDetail total = new UImodelSupplierDetail(
 | 
				
			||||||
				"42€", orders);
 | 
									supplierRepository.findSupplierById(supplierId).name,
 | 
				
			||||||
 | 
									"42€", 
 | 
				
			||||||
 | 
									orders);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		model.addAttribute("SupplierDetail", total);
 | 
							model.addAttribute("SupplierDetail", total);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -82,7 +94,7 @@ public class SupplierIndexController {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		String name;
 | 
							String name;
 | 
				
			||||||
		String balance;
 | 
							String balance;
 | 
				
			||||||
		UImodelSupplierDetailOrders orders;
 | 
							List<UImodelSupplierDetailOrders> orders;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public String getName() {
 | 
							public String getName() {
 | 
				
			||||||
			return name;
 | 
								return name;
 | 
				
			||||||
@ -100,15 +112,15 @@ public class SupplierIndexController {
 | 
				
			|||||||
			this.balance = balance;
 | 
								this.balance = balance;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public UImodelSupplierDetailOrders getOrders() {
 | 
							public List<UImodelSupplierDetailOrders> getOrders() {
 | 
				
			||||||
			return orders;
 | 
								return orders;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public void setOrders(UImodelSupplierDetailOrders orders) {
 | 
							public void setOrders(List<UImodelSupplierDetailOrders> orders) {
 | 
				
			||||||
			this.orders = orders;
 | 
								this.orders = orders;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public UImodelSupplierDetail(String name, String balance, UImodelSupplierDetailOrders orders) {
 | 
							public UImodelSupplierDetail(String name, String balance, List<UImodelSupplierDetailOrders> orders) {
 | 
				
			||||||
			this.name = name;
 | 
								this.name = name;
 | 
				
			||||||
			this.balance = balance;
 | 
								this.balance = balance;
 | 
				
			||||||
			this.orders = orders;
 | 
								this.orders = orders;
 | 
				
			||||||
@ -120,6 +132,7 @@ public class SupplierIndexController {
 | 
				
			|||||||
		long id;
 | 
							long id;
 | 
				
			||||||
		String dateOrder;
 | 
							String dateOrder;
 | 
				
			||||||
		String articleName;
 | 
							String articleName;
 | 
				
			||||||
 | 
							long articleId;
 | 
				
			||||||
		String priceNetto;
 | 
							String priceNetto;
 | 
				
			||||||
		String quantity;
 | 
							String quantity;
 | 
				
			||||||
		String price_total;
 | 
							String price_total;
 | 
				
			||||||
@ -181,15 +194,29 @@ public class SupplierIndexController {
 | 
				
			|||||||
			this.dateArrival = dateArrival;
 | 
								this.dateArrival = dateArrival;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public UImodelSupplierDetailOrders(long id, String dateOrder, String articleName, String priceNetto,
 | 
							public long getArticleId() {
 | 
				
			||||||
				String quantity, String price_total, String dateArrival) {
 | 
								return articleId;
 | 
				
			||||||
			this.id = id;
 | 
							}
 | 
				
			||||||
			this.dateOrder = dateOrder;
 | 
					
 | 
				
			||||||
			this.articleName = articleName;
 | 
							public void setArticleId(long articleId) {
 | 
				
			||||||
			this.priceNetto = priceNetto;
 | 
								this.articleId = articleId;
 | 
				
			||||||
			this.quantity = quantity;
 | 
							}
 | 
				
			||||||
			this.price_total = price_total;
 | 
					
 | 
				
			||||||
			this.dateArrival = dateArrival;
 | 
							public UImodelSupplierDetailOrders(SupplierOrder order)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								this.id = order.id;
 | 
				
			||||||
 | 
								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);
 | 
				
			||||||
 | 
								date.setTime(order.delivered.getTime());
 | 
				
			||||||
 | 
								this.dateArrival = new SimpleDateFormat("dd.MM.yyyy").format(date);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,8 +1,11 @@
 | 
				
			|||||||
package org.hso.ecommerce.repos.supplier;
 | 
					package org.hso.ecommerce.repos.supplier;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.hso.ecommerce.entities.supplier.SupplierOrder;
 | 
					import org.hso.ecommerce.entities.supplier.SupplierOrder;
 | 
				
			||||||
import org.springframework.data.jpa.repository.JpaRepository;
 | 
					import org.springframework.data.jpa.repository.JpaRepository;
 | 
				
			||||||
import org.springframework.data.jpa.repository.Query;
 | 
					import org.springframework.data.jpa.repository.Query;
 | 
				
			||||||
 | 
					import org.springframework.data.repository.query.Param;
 | 
				
			||||||
import org.springframework.stereotype.Repository;
 | 
					import org.springframework.stereotype.Repository;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Repository
 | 
					@Repository
 | 
				
			||||||
@ -11,4 +14,9 @@ public interface SupplierOrderRepository extends JpaRepository<SupplierOrder, Lo
 | 
				
			|||||||
    @Query("SELECT SUM(so.numberOfUnits) FROM SupplierOrder so JOIN so.ordered ao WHERE ao.articleNumber = :articleNumber AND so.delivered IS NULL")
 | 
					    @Query("SELECT SUM(so.numberOfUnits) FROM SupplierOrder so JOIN so.ordered ao WHERE ao.articleNumber = :articleNumber AND so.delivered IS NULL")
 | 
				
			||||||
    Integer countUndeliveredReorders(String articleNumber);
 | 
					    Integer countUndeliveredReorders(String articleNumber);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
| 
						
							
	
	
	
	
	
	
	
	 | 
				|||||||
 | 
						@Query(value = "SELECT * FROM supplier_orders as a WHERE a.supplier_id = :supplierId", nativeQuery = true)
 | 
				
			||||||
 | 
						List<SupplierOrder> findOrderBySupplierID(@Param("supplierId") long supplierId);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,85 +1,87 @@
 | 
				
			|||||||
<!DOCTYPE html>
 | 
					<!DOCTYPE html>
 | 
				
			||||||
<html lang="de" dir="ltr" xmlns:th="http://www.thymeleaf.org">
 | 
					<html lang="de" dir="ltr" xmlns:th="http://www.thymeleaf.org">
 | 
				
			||||||
 | 
					   <head>
 | 
				
			||||||
<head>
 | 
					      <meta charset="utf-8">
 | 
				
			||||||
    <meta charset="utf-8">
 | 
					      <meta name="viewport" content="width=device-width, initial-scale=0.75, user-scalable=no">
 | 
				
			||||||
    <meta name="viewport" content="width=device-width, initial-scale=0.75, user-scalable=no">
 | 
					      <title>Lieferanten Details</title>
 | 
				
			||||||
 | 
					      <script th:src="@{/js/filterTable.js}"></script>
 | 
				
			||||||
    <title>Lieferanten Details</title>
 | 
					      <link rel="stylesheet" th:href="@{/css/ecom.css}"/>
 | 
				
			||||||
    <script th:src="@{/js/filterTable.js}"></script>
 | 
					   </head>
 | 
				
			||||||
    <link rel="stylesheet" th:href="@{/css/ecom.css}"/>
 | 
					   <body>
 | 
				
			||||||
</head>
 | 
					      <nav th:replace="fragments/header :: header">Header</nav>
 | 
				
			||||||
 | 
					      <div class="sidebar-layout content-width">
 | 
				
			||||||
<body>
 | 
					         <nav></nav>
 | 
				
			||||||
<nav th:replace="fragments/header :: header">Header</nav>
 | 
					         <div>
 | 
				
			||||||
<div class="sidebar-layout content-width">
 | 
					            <h1>Lieferant <span th:text="${SupplierDetail.name}"></span></h1>
 | 
				
			||||||
    <nav></nav>
 | 
					            <script th:src="@{/js/back.js}"></script>
 | 
				
			||||||
    <div>
 | 
					            <div class="back" data-group="intern" data-insert="true"></div>
 | 
				
			||||||
        <h1>Lieferant <span th:text="${SupplierDetail.name}"></span></h1>
 | 
					         </div>
 | 
				
			||||||
        <script th:src="@{/js/back.js}"></script>
 | 
					      </div>
 | 
				
			||||||
        <div class="back" data-group="intern" data-insert="true"></div>
 | 
					      <main class="sidebar-layout content-width">
 | 
				
			||||||
    </div>
 | 
					         <nav th:replace="fragments/intern :: sidebar"></nav>
 | 
				
			||||||
</div>
 | 
					         <div class="content-width">
 | 
				
			||||||
<main class="sidebar-layout content-width">
 | 
					            <h2>Bestellungen</h2>
 | 
				
			||||||
    <nav th:replace="fragments/intern :: sidebar"></nav>
 | 
					            <p>
 | 
				
			||||||
    <div class="content-width">
 | 
					            <table id="main-table">
 | 
				
			||||||
        <h2>Bestellungen</h2>
 | 
					               <tr>
 | 
				
			||||||
        <p>
 | 
					                  <th colspan="9">
 | 
				
			||||||
        <table id="main-table">
 | 
					                     <input type="text" placeholder="Filtern" class="smaller jsFilterTable full-width"
 | 
				
			||||||
            <tr>
 | 
					                        data-target-id="main-table"></input>
 | 
				
			||||||
| 
							
							
								
									
	
	
	
	
	
	
	
	 
				
					
						Seil0
						commented  
			
		
 `</input>` kann weg 
			
			
		 | 
					|||||||
                <th colspan="9">
 | 
					                  </th>
 | 
				
			||||||
                    <input type="text" placeholder="Filtern" class="smaller jsFilterTable full-width"
 | 
					               </tr>
 | 
				
			||||||
                           data-target-id="main-table"></input>
 | 
					               <thead>
 | 
				
			||||||
                </th>
 | 
					                  <tr>
 | 
				
			||||||
            </tr>
 | 
					                     <th>Bestellnummer</th>
 | 
				
			||||||
            <tr>
 | 
					                     <th>Datum</th>
 | 
				
			||||||
                <th>Bestellnummer</th>
 | 
					                     <th>Artikel</th>
 | 
				
			||||||
                <th>Datum</th>
 | 
					                     <th>Preis/Stk (Netto)</th>
 | 
				
			||||||
                <th>Artikel</th>
 | 
					                     <th>Menge</th>
 | 
				
			||||||
                <th>Preis/Stk (Netto)</th>
 | 
					                     <th>Gesamtpreis (Netto)</th>
 | 
				
			||||||
                <th>Menge</th>
 | 
					                     <th>Status</th>
 | 
				
			||||||
                <th>Gesamtpreis (Netto)</th>
 | 
					                  </tr>
 | 
				
			||||||
                <th>Status</th>
 | 
					               </thead>
 | 
				
			||||||
            </tr>
 | 
					               <tbody>
 | 
				
			||||||
            <tr>
 | 
					                  <tr>
 | 
				
			||||||
                <td>4545</td>
 | 
					                  <tr th:each="order : ${SupplierDetail.orders}">
 | 
				
			||||||
                <td>2019-18-10</td>
 | 
					                     <td><span th:text="${order.id}"></span></td>
 | 
				
			||||||
                <td><a th:href="@{/intern/listedArticles/45015}">Kamera</a></td>
 | 
					                     <td><span th:text="${order.dateOrder}"></span></td>
 | 
				
			||||||
                <td>20,00 EUR</td>
 | 
					                     <td><a th:href="@{/intern/articles/{id}(id = ${order.articleId})}" class="button smaller" th:text="${order.articleName}"></a></td>
 | 
				
			||||||
                <td>10</td>
 | 
					                     <td><span th:text="${order.priceNetto}"></span> €</td>
 | 
				
			||||||
                <td>200,00 EUR</td>
 | 
					                     <td><span th:text="${order.quantity}"></span></td>
 | 
				
			||||||
                <td>Unterwegs <br/><a th:href="@{/intern/warehouse/todo}" class="button smaller">Angekommen</a></td>
 | 
					                     <td><span th:text="${order.price_total}"></span> €</td>
 | 
				
			||||||
            </tr>
 | 
					                     <td><span th:text="${order.dateArrival}"></span></td>
 | 
				
			||||||
        </table>
 | 
					                     <!-- <td>Unterwegs <br/><a th:href="@{/intern/warehouse/todo}" class="button smaller">Angekommen</a></td>  -->
 | 
				
			||||||
        </p>
 | 
					                  </tr>
 | 
				
			||||||
        <h2>Buchungen</h2>
 | 
					               </tbody>
 | 
				
			||||||
        <div>
 | 
					            </table>
 | 
				
			||||||
            <h4> Kontostand </h4>
 | 
					            </p>
 | 
				
			||||||
            <h3> -100,00 EUR </h3>
 | 
					            <h2>Buchungen</h2>
 | 
				
			||||||
        </div>
 | 
					            <div>
 | 
				
			||||||
        <p>
 | 
					               <h4> Kontostand </h4>
 | 
				
			||||||
        <table id="main-table">
 | 
					               <h3><span th:text="${SupplierDetail.balance}"></span></h3>
 | 
				
			||||||
            <tr>
 | 
					            </div>
 | 
				
			||||||
                <th>Zeitpunkt</th>
 | 
					            <p>
 | 
				
			||||||
                <th>Betrag</th>
 | 
					            <table id="main-table">
 | 
				
			||||||
                <th>Von</th>
 | 
					               <tr>
 | 
				
			||||||
                <th>Kontostand</th>
 | 
					                  <th>Zeitpunkt</th>
 | 
				
			||||||
                <th>Grund</th>
 | 
					                  <th>Betrag</th>
 | 
				
			||||||
                <th>Referenz</th>
 | 
					                  <th>Von</th>
 | 
				
			||||||
            </tr>
 | 
					                  <th>Kontostand</th>
 | 
				
			||||||
            <tr>
 | 
					                  <th>Grund</th>
 | 
				
			||||||
                <td>10.09.2019 13:45</td>
 | 
					                  <th>Referenz</th>
 | 
				
			||||||
                <td>100,00 EUR</td>
 | 
					               </tr>
 | 
				
			||||||
                <td><a th:href="@{/intern/accounting/main}">Hauptkonto</a></td>
 | 
					               <tr>
 | 
				
			||||||
| 
							
							
								
									
	
	
	
	
	
	
	
	 
				
					
						Seil0
						commented  
			
		Die ID ist doppelt vergeben. Die ID ist doppelt vergeben. 
			
			
		 | 
					|||||||
                <td>-100,00 EUR</td>
 | 
					                  <td>10.09.2019 13:45</td>
 | 
				
			||||||
                <td>Lieferanten-Bestellung</td>
 | 
					                  <td>100,00 EUR</td>
 | 
				
			||||||
                <td><a th:href="@{/intern/supplierOrders/#q=4520}">2504</a></td>
 | 
					                  <td><a th:href="@{/intern/accounting/main}">Hauptkonto</a></td>
 | 
				
			||||||
            </tr>
 | 
					                  <td>-100,00 EUR</td>
 | 
				
			||||||
        </table>
 | 
					                  <td>Lieferanten-Bestellung</td>
 | 
				
			||||||
        </p>
 | 
					                  <td><a th:href="@{/intern/supplierOrders/#q=4520}">2504</a></td>
 | 
				
			||||||
    </div>
 | 
					               </tr>
 | 
				
			||||||
</main>
 | 
					            </table>
 | 
				
			||||||
<footer th:replace="fragments/footer :: footer"></footer>
 | 
					            </p>
 | 
				
			||||||
</body>
 | 
					         </div>
 | 
				
			||||||
 | 
					      </main>
 | 
				
			||||||
</html>
 | 
					      <footer th:replace="fragments/footer :: footer"></footer>
 | 
				
			||||||
 | 
					   </body>
 | 
				
			||||||
 | 
					</html>
 | 
				
			||||||
		Reference in New Issue
	
	Block a user
	
Eine Leerzeile zu viel.