You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
4.7 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. package com.gcc.communityHall.controller;
  2. import java.util.HashMap;
  3. import java.util.List;
  4. import java.util.Map;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.http.ResponseEntity;
  7. import org.springframework.stereotype.Controller;
  8. import org.springframework.ui.Model;
  9. import org.springframework.web.bind.annotation.GetMapping;
  10. import org.springframework.web.bind.annotation.ModelAttribute;
  11. import org.springframework.web.bind.annotation.PostMapping;
  12. import org.springframework.web.bind.annotation.RequestBody;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.RequestParam;
  15. import org.springframework.web.multipart.MultipartFile;
  16. import com.gcc.communityHall.entity.BookingDetails;
  17. import com.gcc.communityHall.entity.BookingDetails.BookingStatus;
  18. import com.gcc.communityHall.entity.CounterDetails;
  19. import com.gcc.communityHall.entity.CounterRefundList;
  20. import com.gcc.communityHall.entity.Users;
  21. import com.gcc.communityHall.others.UserSession;
  22. import com.gcc.communityHall.repository.BookingDetailsRepository;
  23. import com.gcc.communityHall.repository.CounterDetailsRepository;
  24. import com.gcc.communityHall.repository.CounterRefundListRepository;
  25. import com.gcc.communityHall.service.BookingService;
  26. import com.gcc.communityHall.service.CounterService;
  27. import com.gcc.communityHall.service.UserService;
  28. import jakarta.servlet.http.HttpSession;
  29. @Controller
  30. @RequestMapping("/counter")
  31. public class CounterController {
  32. @Autowired
  33. private UserSession userSession;
  34. @Autowired
  35. private CounterDetailsRepository counterRepo;
  36. @Autowired
  37. private CounterService counterservice;
  38. @Autowired
  39. private BookingService bookser;
  40. @Autowired
  41. private UserService userService;
  42. @Autowired
  43. private BookingDetailsRepository bookingDetailsRepository;
  44. @Autowired
  45. private CounterRefundListRepository counterRefundRepository;
  46. @GetMapping(value = {"","/","/counterbooking"})
  47. public String viewcounter(Model model,HttpSession session) {
  48. System.out.println("viewcounter");
  49. String countername=(String) session.getAttribute("usertype");
  50. model.addAttribute("countername", countername);
  51. return "counter/counter-booking";
  52. }
  53. @GetMapping("/counterdetailslist")
  54. public String viewcounterlist(Model model,HttpSession session) {
  55. List<CounterDetails> counterlist= counterRepo.findAll();
  56. String countername=(String) session.getAttribute("usertype");
  57. model.addAttribute("countername", countername);
  58. model.addAttribute("counterlist", counterlist);
  59. return "counter/counter-list";
  60. }
  61. @PostMapping("/saveDDdetails")
  62. public String saveDD(
  63. @RequestParam String bankName,
  64. @RequestParam int bankAccNo,
  65. @RequestParam int ddNumber,
  66. @RequestParam double amountReceived,
  67. @RequestParam MultipartFile counterddphoto,
  68. @RequestParam int bookingId) {
  69. // Call the service method and pass the bookingId along with other parameters
  70. String confirmBooking = bookser.confirmBooking(bookingId);
  71. BookingDetails booking=new BookingDetails();
  72. booking.setBookingStatus(BookingStatus.APPROVED);
  73. if (confirmBooking.equals("Booking confirmed successfully")) {
  74. // Perform additional actions if needed
  75. }
  76. bookingDetailsRepository.save(booking);
  77. counterservice.saveCounterDetails(bankName, bankAccNo, ddNumber, amountReceived, counterddphoto, bookingId);
  78. return "redirect:/counter/counterdetailslist";
  79. }
  80. @GetMapping("/bookinglist")
  81. public String viewbookingpage(Model model,HttpSession session)
  82. {
  83. List<Map<String, Object>> bookinglists= bookser.getOfflineBookings();
  84. model.addAttribute("bookinglist",bookinglists);
  85. String countername=(String) session.getAttribute("usertype");
  86. model.addAttribute("countername", countername);
  87. return "counter/viewhistory";
  88. }
  89. @GetMapping("/refundinitialisation")
  90. public String viewrefund(Model model,HttpSession session) {
  91. List<CounterRefundList> counterRefundLists = counterRefundRepository.findAll();
  92. model.addAttribute("counterRefundLists", counterRefundLists);
  93. String countername=(String) session.getAttribute("usertype");
  94. model.addAttribute("countername", countername);
  95. return "counter/refund-initialisation";
  96. }
  97. @GetMapping("/calculateamount")
  98. public String viewCalculate(Model model){
  99. return "counter/calculate-hall-amount";
  100. }
  101. @GetMapping("/logout")
  102. public String viewLogout(Model model,HttpSession session) {
  103. session.invalidate();
  104. return "redirect:/communityhall/login";
  105. }
  106. }