Index: src/main/java/com/example/autopartz/controller/HomeController.java
===================================================================
--- src/main/java/com/example/autopartz/controller/HomeController.java	(revision d4b888e8c58f07ca9c34c64e3184cceecd9b65a8)
+++ src/main/java/com/example/autopartz/controller/HomeController.java	(revision 9dcbf444a75f533d0d8f1bfbf8d0603e8dea6f85)
@@ -2,13 +2,14 @@
 
 import com.example.autopartz.model.*;
+import com.example.autopartz.model.DTO.OrderInfo;
+import com.example.autopartz.model.manytomany.OrderContainsPart;
 import com.example.autopartz.model.manytomany.PartIsInStockInWarehouse;
+import com.example.autopartz.model.views.DeliveriesInProgress;
+import com.example.autopartz.model.views.PartsForCarTypeAndCategory;
 import com.example.autopartz.repository.*;
 import com.example.autopartz.service.*;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
@@ -16,4 +17,5 @@
 import javax.servlet.http.HttpSession;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
@@ -32,8 +34,9 @@
     private final OrderService orderService;
     private final UserService userService;
+    private final DeliveriesInProgressRepository deliveriesInProgressRepository;
     private final DeliveryService deliveryService;
     private final PartIsInStockInWarehouseRepository partIsInStockInWarehouseRepository;
     public HomeController(LoginService loginService, PartService partService, PartsForCarTypeAndCategoryRepository partsForCarTypeAndCategoryRepository, CarService carService, CategoryService categoryService, RepairShopReviewSummaryRepository repairShopReviewSummaryRepository, WarehouseRepository warehouseRepository,
-                          OrderContainsPartRepository orderContainsPartRepository, OrderService orderService, UserService userService, DeliveryService deliveryService, PartIsInStockInWarehouseRepository partIsInStockInWarehouseRepository) {
+                          OrderContainsPartRepository orderContainsPartRepository, OrderService orderService, UserService userService, DeliveriesInProgressRepository deliveriesInProgressRepository, DeliveryService deliveryService, PartIsInStockInWarehouseRepository partIsInStockInWarehouseRepository) {
         this.loginService = loginService;
         this.partService = partService;
@@ -46,4 +49,5 @@
         this.orderService = orderService;
         this.userService = userService;
+        this.deliveriesInProgressRepository = deliveriesInProgressRepository;
         this.deliveryService = deliveryService;
         this.partIsInStockInWarehouseRepository = partIsInStockInWarehouseRepository;
@@ -87,5 +91,13 @@
     @GetMapping("/filtered")
     public String getPartsForCarTypeAndCategory(@RequestParam String cartype, @RequestParam String category, Model model){
-        model.addAttribute("filtered", partsForCarTypeAndCategoryRepository.findAllByCartypeAndCategory(cartype,category));
+        List<PartsForCarTypeAndCategory> tmp = partsForCarTypeAndCategoryRepository.findAllByCartypeAndCategory(cartype,category);
+        if(tmp.size()==0){
+            model.addAttribute("hasError",true);
+            model.addAttribute("error","Не постојат такви производи, обидете се повторно");
+        }
+        else {
+            model.addAttribute("hasError",false);
+            model.addAttribute("filtered", tmp);
+        }
         model.addAttribute("bodyContent","filteredParts");
         return "master-template";
@@ -179,3 +191,43 @@
         return "master-template";
     }
+    @GetMapping("myNextDeliveries")
+    public String myNextDeliveries(Model model, HttpServletRequest request){
+        Deliveryman dm = (Deliveryman) userService.findByUsername(request.getRemoteUser());
+        List<DeliveriesInProgress> ldip = deliveriesInProgressRepository.findAllByUserid(dm.getId());
+        if(ldip.size()==0){
+            model.addAttribute("hasError",true);
+            model.addAttribute("error","Сите достави се завршени");
+        }
+        else {
+            model.addAttribute("hasError",false);
+            model.addAttribute("deliveries", deliveriesInProgressRepository.findAllByUserid(dm.getId()));
+        }
+        model.addAttribute("bodyContent","myNextDeliveries");
+        return "master-template";
+    }
+    @PostMapping("/finishDelivery/{id}")
+    public void finishDelivery(@PathVariable Integer id, Model model, HttpServletResponse response){
+        Delivery d = deliveryService.findByOrder(orderService.findById(id));
+        d.setStatus("finished");
+        deliveryService.update(d);
+        try {
+            response.sendRedirect("/myDeliveries");
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+    @GetMapping("/order/{id}")
+    public String getOrderInfo(@PathVariable Integer id, Model model){
+        List<OrderContainsPart> list = orderContainsPartRepository.findAllByOrderid(id);
+        List<OrderInfo> partList = new ArrayList<>();
+        for (int i = 0; i < list.size(); i++) {
+            OrderInfo oi = new OrderInfo(partService.findById(list.get(i).getPartid()).getName(),
+                    list.get(i).getQuantity_order(),partService.findById(list.get(i).getPartid()).getManufacturer().getName());
+            partList.add(oi);
+        }
+        model.addAttribute("parts",partList);
+        model.addAttribute("o",orderService.findById(id));
+        model.addAttribute("bodyContent","orderInfo");
+        return "master-template";
+    }
 }
Index: src/main/java/com/example/autopartz/model/DTO/OrderInfo.java
===================================================================
--- src/main/java/com/example/autopartz/model/DTO/OrderInfo.java	(revision 9dcbf444a75f533d0d8f1bfbf8d0603e8dea6f85)
+++ src/main/java/com/example/autopartz/model/DTO/OrderInfo.java	(revision 9dcbf444a75f533d0d8f1bfbf8d0603e8dea6f85)
@@ -0,0 +1,16 @@
+package com.example.autopartz.model.DTO;
+
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class OrderInfo {
+    String partname;
+    Integer quantity;
+    String manufacturername;
+}
+
Index: src/main/java/com/example/autopartz/model/views/DeliveriesInProgress.java
===================================================================
--- src/main/java/com/example/autopartz/model/views/DeliveriesInProgress.java	(revision 9dcbf444a75f533d0d8f1bfbf8d0603e8dea6f85)
+++ src/main/java/com/example/autopartz/model/views/DeliveriesInProgress.java	(revision 9dcbf444a75f533d0d8f1bfbf8d0603e8dea6f85)
@@ -0,0 +1,35 @@
+package com.example.autopartz.model.views;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+import org.hibernate.annotations.Immutable;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+import javax.persistence.Table;
+import java.io.Serial;
+import java.io.Serializable;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+
+@Entity
+@Getter
+@Setter
+@ToString
+@RequiredArgsConstructor
+@Immutable
+@Table(name = "`deliveries_in_progress`")
+public class DeliveriesInProgress implements Serializable {
+    @Serial
+    private static final long serialVersionUID = 1L;
+    @Id
+    Integer deliveryid;
+    Integer userid;
+    Integer orderid;
+    LocalDateTime datum;
+    String status;
+    String address;
+}
Index: src/main/java/com/example/autopartz/repository/DeliveriesInProgressRepository.java
===================================================================
--- src/main/java/com/example/autopartz/repository/DeliveriesInProgressRepository.java	(revision 9dcbf444a75f533d0d8f1bfbf8d0603e8dea6f85)
+++ src/main/java/com/example/autopartz/repository/DeliveriesInProgressRepository.java	(revision 9dcbf444a75f533d0d8f1bfbf8d0603e8dea6f85)
@@ -0,0 +1,10 @@
+package com.example.autopartz.repository;
+
+import com.example.autopartz.model.views.DeliveriesInProgress;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+import java.util.List;
+
+public interface DeliveriesInProgressRepository extends JpaRepository<DeliveriesInProgress,Integer> {
+    List<DeliveriesInProgress> findAllByUserid(Integer userid);
+}
Index: src/main/java/com/example/autopartz/repository/DeliveryRepository.java
===================================================================
--- src/main/java/com/example/autopartz/repository/DeliveryRepository.java	(revision d4b888e8c58f07ca9c34c64e3184cceecd9b65a8)
+++ src/main/java/com/example/autopartz/repository/DeliveryRepository.java	(revision 9dcbf444a75f533d0d8f1bfbf8d0603e8dea6f85)
@@ -3,4 +3,5 @@
 import com.example.autopartz.model.Delivery;
 import com.example.autopartz.model.Deliveryman;
+import com.example.autopartz.model.Order;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.stereotype.Repository;
@@ -11,3 +12,4 @@
 public interface DeliveryRepository extends JpaRepository<Delivery,Integer> {
     List<Delivery> findAllByDeliveryman(Deliveryman deliveryman);
+    List<Delivery> findAllByOrder(Order order);
 }
Index: src/main/java/com/example/autopartz/service/DeliveryService.java
===================================================================
--- src/main/java/com/example/autopartz/service/DeliveryService.java	(revision d4b888e8c58f07ca9c34c64e3184cceecd9b65a8)
+++ src/main/java/com/example/autopartz/service/DeliveryService.java	(revision 9dcbf444a75f533d0d8f1bfbf8d0603e8dea6f85)
@@ -3,4 +3,5 @@
 import com.example.autopartz.model.Delivery;
 import com.example.autopartz.model.Deliveryman;
+import com.example.autopartz.model.Order;
 
 import java.util.List;
@@ -8,3 +9,6 @@
 public interface DeliveryService {
     List<Delivery> findAllByDeliverer(Deliveryman dm);
+    Delivery findById(Integer id);
+    void update(Delivery d);
+    Delivery findByOrder(Order o);
 }
Index: src/main/java/com/example/autopartz/service/impl/DeliveryServiceImpl.java
===================================================================
--- src/main/java/com/example/autopartz/service/impl/DeliveryServiceImpl.java	(revision d4b888e8c58f07ca9c34c64e3184cceecd9b65a8)
+++ src/main/java/com/example/autopartz/service/impl/DeliveryServiceImpl.java	(revision 9dcbf444a75f533d0d8f1bfbf8d0603e8dea6f85)
@@ -3,4 +3,5 @@
 import com.example.autopartz.model.Delivery;
 import com.example.autopartz.model.Deliveryman;
+import com.example.autopartz.model.Order;
 import com.example.autopartz.repository.DeliveryRepository;
 import com.example.autopartz.service.DeliveryService;
@@ -21,3 +22,18 @@
         return deliveryRepository.findAllByDeliveryman(dm);
     }
+
+    @Override
+    public Delivery findById(Integer id) {
+        return deliveryRepository.findById(id).get();
+    }
+
+    @Override
+    public void update(Delivery d) {
+        deliveryRepository.save(d);
+    }
+
+    @Override
+    public Delivery findByOrder(Order o) {
+        return deliveryRepository.findAllByOrder(o).stream().findFirst().orElseThrow(RuntimeException::new);
+    }
 }
