feature/supplier_page #52
@ -1,12 +1,10 @@
 | 
				
			|||||||
package org.hso.ecommerce.controller.intern.suppliers;
 | 
					package org.hso.ecommerce.controller.intern.suppliers;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.sql.Timestamp;
 | 
					 | 
				
			||||||
import java.text.SimpleDateFormat;
 | 
					import java.text.SimpleDateFormat;
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
import java.util.Date;
 | 
					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.entities.supplier.SupplierOrder;
 | 
				
			||||||
import org.hso.ecommerce.repos.supplier.SupplierOrderRepository;
 | 
					import org.hso.ecommerce.repos.supplier.SupplierOrderRepository;
 | 
				
			||||||
@ -44,19 +42,17 @@ public class SupplierIndexController {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	@GetMapping("/suppliers/{id}")
 | 
						@GetMapping("/suppliers/{id}")
 | 
				
			||||||
	public String supplierDetail(Model model, @PathVariable String id) {
 | 
						public String supplierDetail(Model model, @PathVariable String id) {
 | 
				
			||||||
		
 | 
					
 | 
				
			||||||
		int supplierId = Integer.parseInt(id);
 | 
							int supplierId = Integer.parseInt(id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		List<UImodelSupplierDetailOrders> orders = new ArrayList<UImodelSupplierDetailOrders>();
 | 
							List<UImodelSupplierDetailOrders> orders = new ArrayList<UImodelSupplierDetailOrders>();
 | 
				
			||||||
		
 | 
					
 | 
				
			||||||
		for (SupplierOrder supplierOrder : supplierOrderRepository.findOrderBySupplierID(supplierId)) {
 | 
							for (SupplierOrder supplierOrder : supplierOrderRepository.findOrderBySupplierID(supplierId)) {
 | 
				
			||||||
			orders.add(new UImodelSupplierDetailOrders(supplierOrder));
 | 
								orders.add(new UImodelSupplierDetailOrders(supplierOrder));
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		UImodelSupplierDetail total = new UImodelSupplierDetail(
 | 
							UImodelSupplierDetail total = new UImodelSupplierDetail(supplierRepository.findSupplierById(supplierId).name,
 | 
				
			||||||
				supplierRepository.findSupplierById(supplierId).name,
 | 
									"42€", orders);
 | 
				
			||||||
				"42€", 
 | 
					 | 
				
			||||||
				orders);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		model.addAttribute("SupplierDetail", total);
 | 
							model.addAttribute("SupplierDetail", total);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -136,7 +132,7 @@ public class SupplierIndexController {
 | 
				
			|||||||
		String priceNetto;
 | 
							String priceNetto;
 | 
				
			||||||
		String quantity;
 | 
							String quantity;
 | 
				
			||||||
		String price_total;
 | 
							String price_total;
 | 
				
			||||||
		String dateArrival;
 | 
							boolean arrived;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public long getId() {
 | 
							public long getId() {
 | 
				
			||||||
			return id;
 | 
								return id;
 | 
				
			||||||
@ -186,14 +182,6 @@ public class SupplierIndexController {
 | 
				
			|||||||
			this.price_total = price_total;
 | 
								this.price_total = price_total;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public String getDateArrival() {
 | 
					 | 
				
			||||||
			return dateArrival;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		public void setDateArrival(String dateArrival) {
 | 
					 | 
				
			||||||
			this.dateArrival = dateArrival;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		public long getArticleId() {
 | 
							public long getArticleId() {
 | 
				
			||||||
			return articleId;
 | 
								return articleId;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@ -202,23 +190,31 @@ public class SupplierIndexController {
 | 
				
			|||||||
			this.articleId = articleId;
 | 
								this.articleId = articleId;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public UImodelSupplierDetailOrders(SupplierOrder order)
 | 
							public boolean isArrived() {
 | 
				
			||||||
		{
 | 
								return arrived;
 | 
				
			||||||
			
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							public void setArrived(boolean arrived) {
 | 
				
			||||||
 | 
								this.arrived = arrived;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							public UImodelSupplierDetailOrders(SupplierOrder order) {
 | 
				
			||||||
			this.id = order.id;
 | 
								this.id = order.id;
 | 
				
			||||||
			this.articleName = order.ordered.title;
 | 
								this.articleName = order.ordered.title;
 | 
				
			||||||
			this.articleId = order.ordered.id;
 | 
								this.articleId = order.ordered.id;
 | 
				
			||||||
			this.priceNetto = String.format("%.2f", ((float) order.pricePerUnitNetCent / 100));
 | 
								this.priceNetto = String.format("%.2f", ((float) order.pricePerUnitNetCent / 100));
 | 
				
			||||||
			this.quantity = String.valueOf(order.numberOfUnits);
 | 
								this.quantity = String.valueOf(order.numberOfUnits);
 | 
				
			||||||
			this.price_total = String.format("%.2f", ((float) order.totalPriceNet / 100));
 | 
								this.price_total = String.format("%.2f", ((float) order.totalPriceNet / 100));
 | 
				
			||||||
			
 | 
					
 | 
				
			||||||
			Date date = new Date();
 | 
								Date date = new Date();
 | 
				
			||||||
			date.setTime(order.created.getTime());
 | 
								date.setTime(order.created.getTime());
 | 
				
			||||||
			this.dateOrder = new SimpleDateFormat("dd.MM.yyyy").format(date);
 | 
								this.dateOrder = new SimpleDateFormat("dd.MM.yyyy").format(date);
 | 
				
			||||||
			date.setTime(order.delivered.getTime());
 | 
					
 | 
				
			||||||
			this.dateArrival = new SimpleDateFormat("dd.MM.yyyy").format(date);
 | 
								if (order.delivered != null) {
 | 
				
			||||||
 | 
									arrived = true;
 | 
				
			||||||
 | 
								} else {
 | 
				
			||||||
 | 
									arrived = false;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -49,8 +49,15 @@
 | 
				
			|||||||
                     <td><span th:text="${order.priceNetto}"></span> €</td>
 | 
					                     <td><span th:text="${order.priceNetto}"></span> €</td>
 | 
				
			||||||
                     <td><span th:text="${order.quantity}"></span></td>
 | 
					                     <td><span th:text="${order.quantity}"></span></td>
 | 
				
			||||||
                     <td><span th:text="${order.price_total}"></span> €</td>
 | 
					                     <td><span th:text="${order.price_total}"></span> €</td>
 | 
				
			||||||
                     <td><span th:text="${order.dateArrival}"></span></td>
 | 
					                     <td>
 | 
				
			||||||
                     <!-- <td>Unterwegs <br/><a th:href="@{/intern/warehouse/todo}" class="button smaller">Angekommen</a></td>  -->
 | 
					                        <div th:if="${order.arrived}">
 | 
				
			||||||
 | 
					                           <a th:href="@{/intern/warehouse/todo}" class="button smaller">Angekommen</a>
 | 
				
			||||||
 | 
					                        </div>
 | 
				
			||||||
 | 
					                        <!-- ELSE -->
 | 
				
			||||||
 | 
					                        <div th:unless="${order.arrived}">
 | 
				
			||||||
 | 
					                           Unterwegs
 | 
				
			||||||
 | 
					                        </div>
 | 
				
			||||||
 | 
					                     </td>
 | 
				
			||||||
                  </tr>
 | 
					                  </tr>
 | 
				
			||||||
               </tbody>
 | 
					               </tbody>
 | 
				
			||||||
            </table>
 | 
					            </table>
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user