From 4ce39f12512fbaf98bebcf2b19bfd511cd6dba2f Mon Sep 17 00:00:00 2001 From: kanimozhi <136799210+KaNi-04@users.noreply.github.com> Date: Sat, 26 Apr 2025 11:02:10 +0530 Subject: [PATCH] Following changes are implemented 1. Admin login --> In Transaction response report temp transactions will be visible 2. Settlement Pending List --> If any error/issue occurs during settlement it will be moved to Refund Failed List 3. Admin Reports --> i) Users -> User Id added in ascending order ii) Users Booking List --> User Id added in ascending order iii) Hall Booking List --> Hall Id added in total bookings in descending order 4. Cancel Booking Enabled for booking status Waiting for NOC and Waiting for NOC Approval. 5. Booking Id added for Waiting for NOC and Waiting for NOC Approval --- .../controller/Admincontroller.java | 1278 ++++++++--------- .../controller/UserAPIController.java | 8 +- .../TransactionResponseRepository.java | 10 +- .../repository/BookingDetailsRepository.java | 36 +- .../communityHall/service/BookingService.java | 254 ++-- .../service/Impl/BookingServiceImpl.java | 64 +- src/main/resources/application-dev.properties | 5 +- .../resources/application-prod.properties | 3 +- .../templates/admin/bookingwaiting.html | 2 + .../resources/templates/admin/reports.html | 7 +- .../templates/admin/viewUploadNoc.html | 2 + .../headquarters/bookingwaiting.html | 2 + .../templates/headquarters/reports.html | 6 + .../templates/headquarters/viewUploadNoc.html | 2 + .../resources/templates/officiallogin.html | 27 +- .../templates/user/calculatehallamount.html | 26 + .../resources/templates/user/viewhistory.html | 18 + 17 files changed, 953 insertions(+), 797 deletions(-) diff --git a/src/main/java/com/gcc/communityHall/controller/Admincontroller.java b/src/main/java/com/gcc/communityHall/controller/Admincontroller.java index 3c2607e3..550e9699 100644 --- a/src/main/java/com/gcc/communityHall/controller/Admincontroller.java +++ b/src/main/java/com/gcc/communityHall/controller/Admincontroller.java @@ -1,4 +1,5 @@ package com.gcc.communityHall.controller; + import java.net.InetAddress; import java.net.UnknownHostException; import java.util.ArrayList; @@ -71,21 +72,21 @@ public class Admincontroller { @Autowired private UsersRepository usersRepository; - + @Autowired private BookingService bookingService; - + @Autowired private UserService userService; - @Autowired - private BookingDetailsRepository bookingDetailsRepository; - + @Autowired + private BookingDetailsRepository bookingDetailsRepository; + @Autowired private HallDetailsRepository hallDetailsRepo; - + @Autowired private DiscountRangeRepository discountRangeRepo; - + @Autowired private GccBlockingDateRepository blockingDateRepository; @@ -94,34 +95,34 @@ public class Admincontroller { @Autowired private AppConfig appConfig; - + @Autowired private JwtUtil jwtUtil; - + @Autowired private NotificationRepository notificationRepository; - + @Autowired private ApplicationLogsRepository applicationLogsRepository; - + @Autowired private TransactionResponseRepository transactionResponseRepository; - + @GetMapping("/dashboard") public String viewDashboard( @RequestParam(required = false, defaultValue = "all zones") String zone, Model model, HttpSession session) { - String token = (String) session.getAttribute("jwtToken"); - // System.out.println("tokensssssssss"+token); + String token = (String) session.getAttribute("jwtToken"); + // System.out.println("tokensssssssss"+token); // Validate JWT token if (token != null && jwtUtil.validateToken(token)) { - //System.out.println("tokennnnnnnnnnnnnnns"+token); + //System.out.println("tokennnnnnnnnnnnnnns"+token); // Token is valid, proceed with dashboard logic String adminName = (String) session.getAttribute("usertype"); - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); List> getMonthCount = bookingDetailsRepository.getAllAdminmonthcount(zone); List> count = bookingDetailsRepository.getAdmincount(zone); Map map = count.get(0); @@ -146,247 +147,246 @@ public class Admincontroller { @GetMapping("/Reports") - public String viewReports(Model model,HttpSession session) - { - String adminname = (String) session.getAttribute("usertype"); - if(adminname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - return "admin/reports"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes - return "redirect:/communityhall/login"; - } + public String viewReports(Model model, HttpSession session) { + String adminname = (String) session.getAttribute("usertype"); + if (adminname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + return "admin/reports"; + } else { + session.invalidate(); // Invalidate the session to clear all session attributes + return "redirect:/communityhall/login"; + } } - + @GetMapping("/getReport") - public String getReports(Model model,HttpSession session) - { - String adminname = (String) session.getAttribute("usertype"); - if(adminname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - return "admin/reports"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes - return "redirect:/communityhall/login"; - } + public String getReports(Model model, HttpSession session) { + String adminname = (String) session.getAttribute("usertype"); + if (adminname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + return "admin/reports"; + } else { + session.invalidate(); // Invalidate the session to clear all session attributes + return "redirect:/communityhall/login"; + } } - - + + @GetMapping("/HallDetails") - public String viewHallDetails(Model model,HttpSession session) - { - String adminname = (String) session.getAttribute("usertype"); - if(adminname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - return "admin/halldetailslist"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes - return "redirect:/communityhall/login"; -} - + public String viewHallDetails(Model model, HttpSession session) { + String adminname = (String) session.getAttribute("usertype"); + if (adminname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + return "admin/halldetailslist"; + } else { + session.invalidate(); // Invalidate the session to clear all session attributes + return "redirect:/communityhall/login"; + } + } + @GetMapping("/halldetailslist") - public String viewhalldetailsList(Model model,HttpSession session) { - List list=hallDetailsRepo.findAll(); - String adminname = (String) session.getAttribute("usertype"); - if(adminname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - model.addAttribute("adminname", adminname); - model.addAttribute("halllist", list); - return "admin/halldetailslist"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes - return "redirect:/communityhall/login"; - } - + public String viewhalldetailsList(Model model, HttpSession session) { + List list = hallDetailsRepo.findAll(); + String adminname = (String) session.getAttribute("usertype"); + if (adminname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + model.addAttribute("adminname", adminname); + model.addAttribute("halllist", list); + return "admin/halldetailslist"; + } else { + session.invalidate(); // Invalidate the session to clear all session attributes + return "redirect:/communityhall/login"; + } + } - + @GetMapping("/settlement-approved") public String viewSettlementMaster(Model model, HttpSession session) { String adminname = (String) session.getAttribute("usertype"); - if(adminname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - List approvedSettlements = bookingDetailsRepository.findAllWithApprovedRefundStatus(); + if (adminname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + List approvedSettlements = bookingDetailsRepository.findAllWithApprovedRefundStatus(); List settlements = new ArrayList<>(); - settlements.addAll(approvedSettlements); - List approvedcancelledbookings=bookingDetailsRepository.findCancelledList(); - List approvedrejectedbookings=bookingDetailsRepository.findRejectedList(); - model.addAttribute("adminname", adminname); - model.addAttribute("settlementlist", settlements); - model.addAttribute("approvedcancelledbookings",approvedcancelledbookings); - model.addAttribute("approvedrejectedbookings",approvedrejectedbookings); - return "admin/settlement-approved"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes + settlements.addAll(approvedSettlements); + List approvedcancelledbookings = bookingDetailsRepository.findCancelledList(); + List approvedrejectedbookings = bookingDetailsRepository.findRejectedList(); + model.addAttribute("adminname", adminname); + model.addAttribute("settlementlist", settlements); + model.addAttribute("approvedcancelledbookings", approvedcancelledbookings); + model.addAttribute("approvedrejectedbookings", approvedrejectedbookings); + return "admin/settlement-approved"; + } else { + session.invalidate(); // Invalidate the session to clear all session attributes return "redirect:/communityhall/login"; } } @GetMapping("/settlement-initiatedlist") - public String viewSettlementInitiatedMaster(Model model,HttpSession session) { - String adminname = (String) session.getAttribute("usertype"); - if(adminname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - List settlement=bookingDetailsRepository.findByBookingDetailsRefundStatus(); - List Initiatedcancelledbookings=bookingDetailsRepository.findInitiatedCancelledList(); - List Initiatedrejectedbookings=bookingDetailsRepository.findInitiatedRejectedList(); - model.addAttribute("title","settlement initiate"); - model.addAttribute("adminname", adminname); - model.addAttribute("settlementlist",settlement); - model.addAttribute("Initiatedcancelledbookings",Initiatedcancelledbookings); - model.addAttribute("Initiatedrejectedbookings",Initiatedrejectedbookings); - return "admin/settlement-initiate"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes + public String viewSettlementInitiatedMaster(Model model, HttpSession session) { + String adminname = (String) session.getAttribute("usertype"); + if (adminname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + List settlement = bookingDetailsRepository.findByBookingDetailsRefundStatus(); + List Initiatedcancelledbookings = bookingDetailsRepository.findInitiatedCancelledList(); + List Initiatedrejectedbookings = bookingDetailsRepository.findInitiatedRejectedList(); + model.addAttribute("title", "settlement initiate"); + model.addAttribute("adminname", adminname); + model.addAttribute("settlementlist", settlement); + model.addAttribute("Initiatedcancelledbookings", Initiatedcancelledbookings); + model.addAttribute("Initiatedrejectedbookings", Initiatedrejectedbookings); + return "admin/settlement-initiate"; + } else { + session.invalidate(); // Invalidate the session to clear all session attributes return "redirect:/communityhall/login"; - } + } } - + @GetMapping("/settlement-list") - public String settlementPendingList(Model model,HttpSession session) { - String adminname = (String) session.getAttribute("usertype"); - if(adminname!=null) { - model.addAttribute("adminname", adminname); - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - model.addAttribute("title","settlement Pending"); - String zone = (String) session.getAttribute("zone"); - model.addAttribute("zone", zone); - List settlement=bookingDetailsRepository.findAllSettlementPending(); - List cancelledbookings=bookingDetailsRepository.findAllSettlementCancelledList(); - List rejectedbookings=bookingDetailsRepository.findAllSettlementRejectedList(); - model.addAttribute("settlementlist",settlement); - model.addAttribute("cancelledbookings",cancelledbookings); - model.addAttribute("rejectedbookings",rejectedbookings); - return "admin/settlement-list"; - }else { - session.invalidate(); - return "redirect:/communityhall/login"; - } -} - + public String settlementPendingList(Model model, HttpSession session) { + String adminname = (String) session.getAttribute("usertype"); + if (adminname != null) { + model.addAttribute("adminname", adminname); + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + model.addAttribute("title", "settlement Pending"); + String zone = (String) session.getAttribute("zone"); + model.addAttribute("zone", zone); + List settlement = bookingDetailsRepository.findAllSettlementPending(); + List cancelledbookings = bookingDetailsRepository.findAllSettlementCancelledList(); + List rejectedbookings = bookingDetailsRepository.findAllSettlementRejectedList(); + model.addAttribute("settlementlist", settlement); + model.addAttribute("cancelledbookings", cancelledbookings); + model.addAttribute("rejectedbookings", rejectedbookings); + return "admin/settlement-list"; + } else { + session.invalidate(); + return "redirect:/communityhall/login"; + } + } + @GetMapping("/refundfailed-list") -public String RefundFailedList(Model model,HttpSession session) { - String adminname = (String) session.getAttribute("usertype"); - if(adminname!=null) { - model.addAttribute("adminname", adminname); - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - model.addAttribute("title","settlementapproved"); - String zone = (String) session.getAttribute("zone"); - model.addAttribute("zone", zone); - List settlementrefundfailed=bookingDetailsRepository.findAllSettlementRefundFailed(); - List refundfailedcancelledbookings=bookingDetailsRepository.findAllRefundFaileCancelledList(); - List refundfailedrejectedbookings=bookingDetailsRepository.findAllRefundFaileRejectedList(); - model.addAttribute("settlementrefundfailed",settlementrefundfailed); - model.addAttribute("refundfailedcancelledbookings",refundfailedcancelledbookings); - model.addAttribute("refundfailedrejectedbookings",refundfailedrejectedbookings); - return "admin/refund-failedlist"; -} -else { - session.invalidate(); - return "redirect:/communityhall/login"; -} -} + public String RefundFailedList(Model model, HttpSession session) { + String adminname = (String) session.getAttribute("usertype"); + if (adminname != null) { + model.addAttribute("adminname", adminname); + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + model.addAttribute("title", "settlementapproved"); + String zone = (String) session.getAttribute("zone"); + model.addAttribute("zone", zone); + List settlementrefundfailed = bookingDetailsRepository.findAllSettlementRefundFailed(); + List refundfailedcancelledbookings = bookingDetailsRepository.findAllRefundFaileCancelledList(); + List refundfailedrejectedbookings = bookingDetailsRepository.findAllRefundFaileRejectedList(); + model.addAttribute("settlementrefundfailed", settlementrefundfailed); + model.addAttribute("refundfailedcancelledbookings", refundfailedcancelledbookings); + model.addAttribute("refundfailedrejectedbookings", refundfailedrejectedbookings); + return "admin/refund-failedlist"; + } else { + session.invalidate(); + return "redirect:/communityhall/login"; + } + } + @GetMapping("/settlement-completedlist") - public String viewSettlementcompletedMaster(Model model,HttpSession session) { - String adminname = (String) session.getAttribute("usertype"); - if(adminname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - List completedlist=bookingDetailsRepository.findSettlementCompletedList(); - List cancelledcompletedlist=bookingDetailsRepository.findCancelledCompletedList(); - List rejectedcompletedlist=bookingDetailsRepository.findRejectedSettlementCompletedList(); - model.addAttribute("title","settlement initiate"); - model.addAttribute("adminname", adminname); - model.addAttribute("completedlist",completedlist); - model.addAttribute("cancelledcompletedlist",cancelledcompletedlist); - model.addAttribute("rejectedcompletedlist",rejectedcompletedlist); - return "admin/settlement-completed"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes + public String viewSettlementcompletedMaster(Model model, HttpSession session) { + String adminname = (String) session.getAttribute("usertype"); + if (adminname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + List completedlist = bookingDetailsRepository.findSettlementCompletedList(); + List cancelledcompletedlist = bookingDetailsRepository.findCancelledCompletedList(); + List rejectedcompletedlist = bookingDetailsRepository.findRejectedSettlementCompletedList(); + model.addAttribute("title", "settlement initiate"); + model.addAttribute("adminname", adminname); + model.addAttribute("completedlist", completedlist); + model.addAttribute("cancelledcompletedlist", cancelledcompletedlist); + model.addAttribute("rejectedcompletedlist", rejectedcompletedlist); + return "admin/settlement-completed"; + } else { + session.invalidate(); // Invalidate the session to clear all session attributes return "redirect:/communityhall/login"; - } + } } + @GetMapping("/ReasonMaster") - public String viewreasonMaster(Model model,HttpSession session) { - String adminname = (String) session.getAttribute("usertype"); - if(adminname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - model.addAttribute("adminname", adminname); - return "admin/reasonmaster"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes - return "redirect:/communityhall/login"; - } -} + public String viewreasonMaster(Model model, HttpSession session) { + String adminname = (String) session.getAttribute("usertype"); + if (adminname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + model.addAttribute("adminname", adminname); + return "admin/reasonmaster"; + } else { + session.invalidate(); // Invalidate the session to clear all session attributes + return "redirect:/communityhall/login"; + } + } + @GetMapping("/userdeactive") - public String viewuserDetails(Model model,HttpSession session) { - String adminname = (String) session.getAttribute("usertype"); - if(adminname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - model.addAttribute("adminname", adminname); - return "admin/userdetails"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes - return "redirect:/communityhall/login"; - } + public String viewuserDetails(Model model, HttpSession session) { + String adminname = (String) session.getAttribute("usertype"); + if (adminname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + model.addAttribute("adminname", adminname); + return "admin/userdetails"; + } else { + session.invalidate(); // Invalidate the session to clear all session attributes + return "redirect:/communityhall/login"; + } } + @GetMapping("/Gccblocking") public String viewGccBlocking(Model model, HttpSession session) { String adminname = (String) session.getAttribute("usertype"); - if(adminname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - model.addAttribute("adminname", adminname); - // Fetch all blocked GCC dates - List gccBlocked = blockingDateRepository.findAllBlocked(); - - // Ensure distinct by hallId, blockingReason, startDate, and endDate - List uniqueGccBlockingDates = gccBlocked.stream() - .filter(distinctByKey(g -> Arrays.asList( - g.getHallId(), - g.getBlockingReason(), - g.getStartDate(), - g.getEndDate()))) - .collect(Collectors.toList()); - - // Map to store the count of blocked halls for each GccBlockingDate - Map hallCountMap = new HashMap<>(); - for (GccBlockingDate blockedDate : uniqueGccBlockingDates) { - // Parse and count unique hall IDs - String hallIds = blockedDate.getHallId(); - if (hallIds != null && !hallIds.isEmpty()) { - Set uniqueHallIds = new HashSet<>(Arrays.asList(hallIds.split(","))); - int hallCount = uniqueHallIds.size(); - hallCountMap.put(blockedDate.getBlockingId(), hallCount); - } else { - hallCountMap.put(blockedDate.getBlockingId(), 0); // No halls blocked + if (adminname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + model.addAttribute("adminname", adminname); + // Fetch all blocked GCC dates + List gccBlocked = blockingDateRepository.findAllBlocked(); + + // Ensure distinct by hallId, blockingReason, startDate, and endDate + List uniqueGccBlockingDates = gccBlocked.stream() + .filter(distinctByKey(g -> Arrays.asList( + g.getHallId(), + g.getBlockingReason(), + g.getStartDate(), + g.getEndDate()))) + .collect(Collectors.toList()); + + // Map to store the count of blocked halls for each GccBlockingDate + Map hallCountMap = new HashMap<>(); + for (GccBlockingDate blockedDate : uniqueGccBlockingDates) { + // Parse and count unique hall IDs + String hallIds = blockedDate.getHallId(); + if (hallIds != null && !hallIds.isEmpty()) { + Set uniqueHallIds = new HashSet<>(Arrays.asList(hallIds.split(","))); + int hallCount = uniqueHallIds.size(); + hallCountMap.put(blockedDate.getBlockingId(), hallCount); + } else { + hallCountMap.put(blockedDate.getBlockingId(), 0); // No halls blocked + } } - } - // Add attributes to the model for the view - model.addAttribute("gccblocked", uniqueGccBlockingDates); - model.addAttribute("hallCountMap", hallCountMap); + // Add attributes to the model for the view + model.addAttribute("gccblocked", uniqueGccBlockingDates); + model.addAttribute("hallCountMap", hallCountMap); - return "admin/gccblocking"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes - return "redirect:/communityhall/login"; - } + return "admin/gccblocking"; + } else { + session.invalidate(); // Invalidate the session to clear all session attributes + return "redirect:/communityhall/login"; + } } - - // Utility method to ensure distinct by a key private static Predicate distinctByKey(Function keyExtractor) { Set seen = new HashSet<>(); @@ -417,136 +417,138 @@ else { @RequestParam(required = false) String longitude, @RequestParam String hallInchargeName, @RequestParam long hallInchargeNo, - @RequestParam("hallImages") MultipartFile[] hallImages,HttpSession session) { - String updatedId = (String) session.getAttribute("employeeId"); + @RequestParam("hallImages") MultipartFile[] hallImages, HttpSession session) { + String updatedId = (String) session.getAttribute("employeeId"); hallDetailService.saveHall(hallName, depositAmount, halfDayAmt, fullDayAmt, gst, hallArea, ebNumber, ebCostPerUnit, parkingCapacity, seatingCapacity, doorNo, street, area, zone, division, landMark, city, pinCode, latitude, longitude, hallInchargeName, hallInchargeNo, updatedId, hallImages); String adminname = (String) session.getAttribute("usertype"); - Integer loginid = (Integer) session.getAttribute("id"); - ApplicationLogs logs=new ApplicationLogs(); - logs.setComments("Action by " + adminname); - logs.setLoginId(loginid); - logs.setLogType("Adding New Hall:-"+hallName); - InetAddress inetAddress; - try { - inetAddress = InetAddress.getLocalHost(); - String hostname = InetAddress.getLocalHost().getHostName(); - logs.setIpaddress(inetAddress.getHostAddress()); - logs.setSystemName(hostname); - } catch (UnknownHostException e) { - e.printStackTrace(); - } - applicationLogsRepository.save(logs); + Integer loginid = (Integer) session.getAttribute("id"); + ApplicationLogs logs = new ApplicationLogs(); + logs.setComments("Action by " + adminname); + logs.setLoginId(loginid); + logs.setLogType("Adding New Hall:-" + hallName); + InetAddress inetAddress; + try { + inetAddress = InetAddress.getLocalHost(); + String hostname = InetAddress.getLocalHost().getHostName(); + logs.setIpaddress(inetAddress.getHostAddress()); + logs.setSystemName(hostname); + } catch (UnknownHostException e) { + e.printStackTrace(); + } + applicationLogsRepository.save(logs); // Redirect to a success page or return a ModelAndView as per your application flow return "redirect:/communityhall/admin/halldetailslist"; } + @GetMapping("/approval-history") - public String viewApproval(Model model,HttpSession session) { - String adminname = (String) session.getAttribute("usertype"); - if(adminname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - model.addAttribute("adminname", adminname); - model.addAttribute("adminname", adminname); - model.addAttribute("title", "approvalcontrol"); - List Pending=usersRepository.getPendingList(); - String zone = (String) session.getAttribute("zone"); - model.addAttribute("zone", zone); - model.addAttribute("pendinglist",Pending); - return "admin/approval-history"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes + public String viewApproval(Model model, HttpSession session) { + String adminname = (String) session.getAttribute("usertype"); + if (adminname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + model.addAttribute("adminname", adminname); + model.addAttribute("adminname", adminname); + model.addAttribute("title", "approvalcontrol"); + List Pending = usersRepository.getPendingList(); + String zone = (String) session.getAttribute("zone"); + model.addAttribute("zone", zone); + model.addAttribute("pendinglist", Pending); + return "admin/approval-history"; + } else { + session.invalidate(); // Invalidate the session to clear all session attributes return "redirect:/communityhall/login"; - } + } } @GetMapping("/user-approved") - public String viewUserApproved(Model model,HttpSession session){ - String adminname = (String) session.getAttribute("usertype"); - if(adminname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - model.addAttribute("adminname", adminname); - model.addAttribute("title","reasondetails"); - List approved= usersRepository.getUserApproved(); - String zone = (String) session.getAttribute("zone"); - model.addAttribute("zone", zone); - model.addAttribute("approvedlist",approved); - return "admin/user-approved"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes - return "redirect:/communityhall/login"; - } + public String viewUserApproved(Model model, HttpSession session) { + String adminname = (String) session.getAttribute("usertype"); + if (adminname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + model.addAttribute("adminname", adminname); + model.addAttribute("title", "reasondetails"); + List approved = usersRepository.getUserApproved(); + String zone = (String) session.getAttribute("zone"); + model.addAttribute("zone", zone); + model.addAttribute("approvedlist", approved); + return "admin/user-approved"; + } else { + session.invalidate(); // Invalidate the session to clear all session attributes + return "redirect:/communityhall/login"; + } } @GetMapping("/user-reject") - public String viewUserReject(Model model,HttpSession session){ - String adminname = (String) session.getAttribute("usertype"); - if(adminname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - model.addAttribute("adminname", adminname); - model.addAttribute("title","reasondetails"); - List reject= usersRepository.getUserReject(); - String zone = (String) session.getAttribute("zone"); - model.addAttribute("zone", zone); - model.addAttribute("rejectedlist",reject); - return "admin/user-reject"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes - return "redirect:/communityhall/login"; - } + public String viewUserReject(Model model, HttpSession session) { + String adminname = (String) session.getAttribute("usertype"); + if (adminname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + model.addAttribute("adminname", adminname); + model.addAttribute("title", "reasondetails"); + List reject = usersRepository.getUserReject(); + String zone = (String) session.getAttribute("zone"); + model.addAttribute("zone", zone); + model.addAttribute("rejectedlist", reject); + return "admin/user-reject"; + } else { + session.invalidate(); // Invalidate the session to clear all session attributes + return "redirect:/communityhall/login"; + } } + @GetMapping("/booking-list") - public String viewBookingList(Model model,HttpSession session) { - String adminname = (String) session.getAttribute("usertype"); - if(adminname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - model.addAttribute("adminname", adminname); - List bookingList = bookingDetailsRepository.getAllApprovedList(); - model.addAttribute("bookingList", bookingList); - return "admin/booking-list"; // Assuming "officer/rejected-booking-list" is the name of your HTML template - }else { - session.invalidate(); // Invalidate the session to clear all session attributes + public String viewBookingList(Model model, HttpSession session) { + String adminname = (String) session.getAttribute("usertype"); + if (adminname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + model.addAttribute("adminname", adminname); + List bookingList = bookingDetailsRepository.getAllApprovedList(); + model.addAttribute("bookingList", bookingList); + return "admin/booking-list"; // Assuming "officer/rejected-booking-list" is the name of your HTML template + } else { + session.invalidate(); // Invalidate the session to clear all session attributes return "redirect:/communityhall/login"; - } + } } @GetMapping("/rejected-list") - public String viewRejectedBookings(Model model,HttpSession session) { - String adminname = (String) session.getAttribute("usertype"); - if(adminname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - model.addAttribute("adminname", adminname); - List rejectedBookings = bookingDetailsRepository.getAllRejectingList(); - model.addAttribute("rejectedBookings", rejectedBookings); - - return "admin/rejected-list"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes + public String viewRejectedBookings(Model model, HttpSession session) { + String adminname = (String) session.getAttribute("usertype"); + if (adminname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + model.addAttribute("adminname", adminname); + List rejectedBookings = bookingDetailsRepository.getAllRejectingList(); + model.addAttribute("rejectedBookings", rejectedBookings); + + return "admin/rejected-list"; + } else { + session.invalidate(); // Invalidate the session to clear all session attributes return "redirect:/communityhall/login"; - } + } } - + @GetMapping("/bookingwaitinglist") - public String viewWaitingBookings(Model model,HttpSession session) { - String adminname = (String) session.getAttribute("usertype"); - if(adminname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - model.addAttribute("adminname", adminname); - List waitingBookings = bookingDetailsRepository.getAllwaitingList(); - model.addAttribute("waitingBookings", waitingBookings); - - return "admin/bookingwaiting"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes + public String viewWaitingBookings(Model model, HttpSession session) { + String adminname = (String) session.getAttribute("usertype"); + if (adminname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + model.addAttribute("adminname", adminname); + List waitingBookings = bookingDetailsRepository.getAllwaitingList(); + model.addAttribute("waitingBookings", waitingBookings); + + return "admin/bookingwaiting"; + } else { + session.invalidate(); // Invalidate the session to clear all session attributes return "redirect:/communityhall/login"; - } - } - + } + } + @PostMapping("/getReport") public String generateReport(Model model, @RequestParam(name = "FromDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) String fromDate, @@ -558,118 +560,114 @@ else { @RequestParam(name = "refundStatus", required = false) String refundStatus, @RequestParam(name = "paymentStatus", required = false) String paymentStatus, @RequestParam(name = "filterby", required = false) String filterby, - @RequestParam(name = "zone1",required = false, defaultValue = "ALL") String zone, - @RequestParam(name = "division1",required = false, defaultValue = "ALL") String division, - @RequestParam(name = "hall1",required = false, defaultValue = "1000") Integer hallid, + @RequestParam(name = "zone1", required = false, defaultValue = "ALL") String zone, + @RequestParam(name = "division1", required = false, defaultValue = "ALL") String division, + @RequestParam(name = "hall1", required = false, defaultValue = "1000") Integer hallid, @RequestParam(name = "basedon", required = false) String basedon, - @RequestParam(name = "bookingId", required = false) Long bookingId,HttpSession session) { - String adminname = (String) session.getAttribute("usertype"); - if(adminname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - List userList = handleUserRequest(request, fromDate, toDate, userstatus, usertype); - List bookingList = handleBookingRequest(request, fromDate, toDate, bookingStatus, filterby,bookingId,zone,division,hallid); - List bookingSettlementList = handleBookingSettlementRequest(request, fromDate, toDate, refundStatus,filterby); - //List paymentList = request.equals("3") ? bookingService.getAllPaymentsDetails(fromDate, toDate,zone,division,hallid) : new ArrayList<>(); - List paymentList = new ArrayList<>(); - List extrapaymentList = new ArrayList<>(); - if (request.equals("3")) { - if (paymentStatus == null || paymentStatus.isEmpty()) { - paymentList = bookingService.getAllPaymentsDetails(fromDate, toDate, null,zone,division,hallid); - } else { - paymentList = bookingService.getAllPaymentsDetails(fromDate, toDate, paymentStatus,zone,division,hallid); + @RequestParam(name = "bookingId", required = false) Long bookingId, HttpSession session) { + String adminname = (String) session.getAttribute("usertype"); + if (adminname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + List userList = handleUserRequest(request, fromDate, toDate, userstatus, usertype); + List bookingList = handleBookingRequest(request, fromDate, toDate, bookingStatus, filterby, bookingId, zone, division, hallid); + List bookingSettlementList = handleBookingSettlementRequest(request, fromDate, toDate, refundStatus, filterby); + //List paymentList = request.equals("3") ? bookingService.getAllPaymentsDetails(fromDate, toDate,zone,division,hallid) : new ArrayList<>(); + List paymentList = new ArrayList<>(); + List extrapaymentList = new ArrayList<>(); + if (request.equals("3")) { + if (paymentStatus == null || paymentStatus.isEmpty()) { + paymentList = bookingService.getAllPaymentsDetails(fromDate, toDate, null, zone, division, hallid); + } else { + paymentList = bookingService.getAllPaymentsDetails(fromDate, toDate, paymentStatus, zone, division, hallid); + } } - } - if (request.equals("8")) { - if (paymentStatus == null || paymentStatus.isEmpty()) { - extrapaymentList = bookingService.getAllExtraPaymentsDetails(fromDate, toDate, null,zone,division,hallid); - } else { - extrapaymentList = bookingService.getAllExtraPaymentsDetails(fromDate, toDate, paymentStatus,zone,division,hallid); + if (request.equals("8")) { + if (paymentStatus == null || paymentStatus.isEmpty()) { + extrapaymentList = bookingService.getAllExtraPaymentsDetails(fromDate, toDate, null, zone, division, hallid); + } else { + extrapaymentList = bookingService.getAllExtraPaymentsDetails(fromDate, toDate, paymentStatus, zone, division, hallid); + } } - } - List userbookingList = request.equals("4") ? bookingService.getBookingUserDetailsReport(fromDate, toDate) : new ArrayList<>(); - //List hallbookingList = request.equals("5") ? bookingService.getBookingHallDetailsReport(fromDate, toDate) : new ArrayList<>(); - // In your controller method - // Fetch booking count by zone - List totalcount = new ArrayList<>(); - int totalBookings = 0; - if ("7".equals(request)) { - if ("zone".equals(basedon)) { - totalcount = bookingDetailsRepository.countBookingsByZone(); - // Format zone data - totalcount = totalcount.stream() - .map(data -> new Object[] { "Zone-" + data[0], data[1] }) - .collect(Collectors.toList()); - } else if ("division".equals(basedon)) { - totalcount = bookingDetailsRepository.countBookingsByDivisions(); - // Format division data - totalcount = totalcount.stream() - .map(data -> new Object[] { "Division-" + data[0], data[1] }) - .collect(Collectors.toList()); + List userbookingList = request.equals("4") ? bookingService.getBookingUserDetailsReport(fromDate, toDate) : new ArrayList<>(); + //List hallbookingList = request.equals("5") ? bookingService.getBookingHallDetailsReport(fromDate, toDate) : new ArrayList<>(); + // In your controller method + // Fetch booking count by zone + List totalcount = new ArrayList<>(); + int totalBookings = 0; + if ("7".equals(request)) { + if ("zone".equals(basedon)) { + totalcount = bookingDetailsRepository.countBookingsByZone(); + // Format zone data + totalcount = totalcount.stream() + .map(data -> new Object[]{"Zone-" + data[0], data[1]}) + .collect(Collectors.toList()); + } else if ("division".equals(basedon)) { + totalcount = bookingDetailsRepository.countBookingsByDivisions(); + // Format division data + totalcount = totalcount.stream() + .map(data -> new Object[]{"Division-" + data[0], data[1]}) + .collect(Collectors.toList()); + } + + totalBookings = totalcount.stream() + .mapToInt(data -> ((Number) data[1]).intValue()) + .sum(); } + model.addAttribute("basedon", basedon); + model.addAttribute("totalcount", totalcount); + model.addAttribute("totalBookings", totalBookings); + List hallbookingList = handleBookingHallDetailsReportRequest(request, fromDate, toDate, filterby, zone, division, hallid); + + + model.addAttribute("filterby", filterby); + model.addAttribute("users", userList); + model.addAttribute("bookings", bookingList); + model.addAttribute("fromdate", fromDate); + model.addAttribute("todate", toDate); + model.addAttribute("userstatus", userstatus); + model.addAttribute("bookingSettlementList", bookingSettlementList); + model.addAttribute("usertype", usertype); + model.addAttribute("bookingStatus", bookingStatus); + model.addAttribute("refundStatus", refundStatus); + model.addAttribute("paymentStatus", paymentStatus); + model.addAttribute("request", request); + model.addAttribute("paymentLists", paymentList); + model.addAttribute("extrapaymentLists", extrapaymentList); + model.addAttribute("userbookingLists", userbookingList); + model.addAttribute("hallbookingLists", hallbookingList); + model.addAttribute("bookingId", bookingId); + model.addAttribute("zone1", zone); + model.addAttribute("division1", division); + model.addAttribute("hall1", hallid); + model.addAttribute("adminname", adminname); - totalBookings = totalcount.stream() - .mapToInt(data -> ((Number) data[1]).intValue()) - .sum(); + return "admin/reports"; + } else { + session.invalidate(); // Invalidate the session to clear all session attributes + return "redirect:/communityhall/login"; } - model.addAttribute("basedon", basedon); - model.addAttribute("totalcount", totalcount); - model.addAttribute("totalBookings", totalBookings); - List hallbookingList = handleBookingHallDetailsReportRequest(request, fromDate, toDate, filterby,zone,division,hallid); - - - model.addAttribute("filterby", filterby); - model.addAttribute("users", userList); - model.addAttribute("bookings", bookingList); - model.addAttribute("fromdate", fromDate); - model.addAttribute("todate", toDate); - model.addAttribute("userstatus", userstatus); - model.addAttribute("bookingSettlementList", bookingSettlementList); - model.addAttribute("usertype", usertype); - model.addAttribute("bookingStatus", bookingStatus); - model.addAttribute("refundStatus", refundStatus); - model.addAttribute("paymentStatus", paymentStatus); - model.addAttribute("request", request); - model.addAttribute("paymentLists", paymentList); - model.addAttribute("extrapaymentLists", extrapaymentList); - model.addAttribute("userbookingLists", userbookingList); - model.addAttribute("hallbookingLists", hallbookingList); - model.addAttribute("bookingId", bookingId); - model.addAttribute("zone1", zone); - model.addAttribute("division1", division); - model.addAttribute("hall1", hallid); - model.addAttribute("adminname", adminname); - - return "admin/reports"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes - return "redirect:/communityhall/login"; } - } - - private List handleBookingHallDetailsReportRequest(String request, String fromDate, String toDate,String filterby,String zone,String division,Integer hallid) - { - if (!request.equals("5")) { + + private List handleBookingHallDetailsReportRequest(String request, String fromDate, String toDate, String filterby, String zone, String division, Integer hallid) { + if (!request.equals("5")) { return new ArrayList<>(); } - if(filterby.isEmpty()) - { - return bookingService.getBookingHallDetailsReportByBookingDate(fromDate, toDate,zone,division,hallid); - } - if ("1".equals(filterby)) - { - - return bookingService.getBookingHallDetailsReportByBookingDate(fromDate, toDate,zone,division,hallid); - + if (filterby.isEmpty()) { + return bookingService.getBookingHallDetailsReportByBookingDate(fromDate, toDate, zone, division, hallid); + } + if ("1".equals(filterby)) { + + return bookingService.getBookingHallDetailsReportByBookingDate(fromDate, toDate, zone, division, hallid); + } - if ("2".equals(filterby)) - { - - return bookingService.getBookingHallDetailsReportByEventDate(fromDate, toDate,zone,division,hallid); - + if ("2".equals(filterby)) { + + return bookingService.getBookingHallDetailsReportByEventDate(fromDate, toDate, zone, division, hallid); + } - - return new ArrayList<>(); + + return new ArrayList<>(); } private List handleUserRequest(String request, String fromDate, String toDate, String userstatus, String usertype) { @@ -688,170 +686,148 @@ else { return userService.getAllUsers(fromDate, toDate); } - - - private List handleBookingRequest(String request, String fromDate, String toDate, String bookingStatus, String filterby,Long bookingId,String zone,String division,Integer hallid) { + + private List handleBookingRequest(String request, String fromDate, String toDate, String bookingStatus, String filterby, Long bookingId, String zone, String division, Integer hallid) { if (!request.equals("2")) { return new ArrayList<>(); } - if(filterby.isEmpty() && bookingStatus.isEmpty() && bookingId == null) - { - return bookingService.getBookingDetailsByBookingDate(fromDate, toDate,zone,division,hallid); + if (filterby.isEmpty() && bookingStatus.isEmpty() && bookingId == null) { + return bookingService.getBookingDetailsByBookingDate(fromDate, toDate, zone, division, hallid); } - if(bookingId!=null && bookingStatus.isEmpty()) - { - return bookingDetailsRepo.getAllBookingDetailsWithBookingId(fromDate, toDate, bookingId); + if (bookingId != null && bookingStatus.isEmpty()) { + return bookingDetailsRepo.getAllBookingDetailsWithBookingId(fromDate, toDate, bookingId); } - if(bookingId!=null && !bookingStatus.isEmpty()) - { - return bookingDetailsRepo.getAllBookingDetailsWithBookingIdwithbookingStatus(fromDate, toDate, bookingId,bookingStatus); + if (bookingId != null && !bookingStatus.isEmpty()) { + return bookingDetailsRepo.getAllBookingDetailsWithBookingIdwithbookingStatus(fromDate, toDate, bookingId, bookingStatus); } - if(bookingId==null && filterby.isEmpty() && !bookingStatus.isEmpty()) - { - return bookingService.getBookingDetailsByBookingDateWithStatus(fromDate, toDate, bookingStatus,zone,division,hallid); + if (bookingId == null && filterby.isEmpty() && !bookingStatus.isEmpty()) { + return bookingService.getBookingDetailsByBookingDateWithStatus(fromDate, toDate, bookingStatus, zone, division, hallid); } - if(!filterby.isEmpty()) - { - - if ("1".equals(filterby)) - { - if(bookingStatus.isEmpty()) - { - return bookingService.getBookingDetailsByBookingDate(fromDate, toDate,zone,division,hallid); - } - else - { - return bookingService.getBookingDetailsByBookingDateWithStatus(fromDate, toDate, bookingStatus,zone,division,hallid); - } - - } - if ("2".equals(filterby)) - { - if(bookingStatus.isEmpty()) - { - return bookingService.getBookingDetailsByEventDate(fromDate, toDate,zone,division,hallid); - } - else { - return bookingService.getBookingDetailsByEventDateWithStatus(fromDate, toDate, bookingStatus,zone,division,hallid); - } - - } + if (!filterby.isEmpty()) { + + if ("1".equals(filterby)) { + if (bookingStatus.isEmpty()) { + return bookingService.getBookingDetailsByBookingDate(fromDate, toDate, zone, division, hallid); + } else { + return bookingService.getBookingDetailsByBookingDateWithStatus(fromDate, toDate, bookingStatus, zone, division, hallid); + } + + } + if ("2".equals(filterby)) { + if (bookingStatus.isEmpty()) { + return bookingService.getBookingDetailsByEventDate(fromDate, toDate, zone, division, hallid); + } else { + return bookingService.getBookingDetailsByEventDateWithStatus(fromDate, toDate, bookingStatus, zone, division, hallid); + } + + } } - // Handle default or error case - return new ArrayList<>(); + // Handle default or error case + return new ArrayList<>(); } - - + + private List handleBookingSettlementRequest(String request, String fromDate, String toDate, String refundStatus, String filterby) { if (!request.equals("6")) { return new ArrayList<>(); } - if(filterby.isEmpty() && refundStatus.isEmpty()) - { - return bookingService.getAllBookingsettlementDetailsByBookingDate(fromDate, toDate); + if (filterby.isEmpty() && refundStatus.isEmpty()) { + return bookingService.getAllBookingsettlementDetailsByBookingDate(fromDate, toDate); } - if(filterby.isEmpty() && !refundStatus.isEmpty()) - { - return bookingService.getAllBookingsettlementDetailsByBookingDateWithStatus(fromDate, toDate, refundStatus); + if (filterby.isEmpty() && !refundStatus.isEmpty()) { + return bookingService.getAllBookingsettlementDetailsByBookingDateWithStatus(fromDate, toDate, refundStatus); } - if(!filterby.isEmpty()) - { - - if ("1".equals(filterby)) - { - if(refundStatus.isEmpty()) - { - return bookingService.getAllBookingsettlementDetailsByBookingDate(fromDate, toDate); - } - else - { - return bookingService.getAllBookingsettlementDetailsByBookingDateWithStatus(fromDate, toDate, refundStatus); - } - - } - if ("2".equals(filterby)) - { - if(refundStatus.isEmpty()) - { - return bookingService.getAllBookingsettlementDetailsByEventDate(fromDate, toDate); - } - else { - return bookingService.getAllBookingsettlementDetailsByEventDateWithStatus(fromDate, toDate, refundStatus); - } - - } + if (!filterby.isEmpty()) { + + if ("1".equals(filterby)) { + if (refundStatus.isEmpty()) { + return bookingService.getAllBookingsettlementDetailsByBookingDate(fromDate, toDate); + } else { + return bookingService.getAllBookingsettlementDetailsByBookingDateWithStatus(fromDate, toDate, refundStatus); + } + + } + if ("2".equals(filterby)) { + if (refundStatus.isEmpty()) { + return bookingService.getAllBookingsettlementDetailsByEventDate(fromDate, toDate); + } else { + return bookingService.getAllBookingsettlementDetailsByEventDateWithStatus(fromDate, toDate, refundStatus); + } + + } } - - // Handle default or error case + + // Handle default or error case return new ArrayList<>(); } @GetMapping("/DiscountRange") - public String viewDiscountRange(Model model,HttpSession session) { - String adminname = (String) session.getAttribute("usertype"); - if(adminname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - List discountRanges = discountRangeRepo.findAll(); - - model.addAttribute("discountRanges", discountRanges); - model.addAttribute("adminname", adminname); - return "admin/discountrange"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes + public String viewDiscountRange(Model model, HttpSession session) { + String adminname = (String) session.getAttribute("usertype"); + if (adminname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + List discountRanges = discountRangeRepo.findAll(); + + model.addAttribute("discountRanges", discountRanges); + model.addAttribute("adminname", adminname); + return "admin/discountrange"; + } else { + session.invalidate(); // Invalidate the session to clear all session attributes return "redirect:/communityhall/login"; - } + } } - + @GetMapping("/ongoingevents") - public String viewRecentevents(Model model,HttpSession session) { - String adminname = (String) session.getAttribute("usertype"); - if(adminname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - List presenteventslist=bookingDetailsRepository.findPresentBookingList(); - List pasteventslist=bookingDetailsRepository.findPastEventsList(); - List futureeventslist=bookingDetailsRepository.findFutureEventsList(); - model.addAttribute("title","settlement initiate"); - model.addAttribute("adminname", adminname); - model.addAttribute("presenteventslist",presenteventslist); - model.addAttribute("pasteventslist",pasteventslist); - model.addAttribute("futureeventslist",futureeventslist); - return "admin/ongoingevents"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes + public String viewRecentevents(Model model, HttpSession session) { + String adminname = (String) session.getAttribute("usertype"); + if (adminname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + List presenteventslist = bookingDetailsRepository.findPresentBookingList(); + List pasteventslist = bookingDetailsRepository.findPastEventsList(); + List futureeventslist = bookingDetailsRepository.findFutureEventsList(); + model.addAttribute("title", "settlement initiate"); + model.addAttribute("adminname", adminname); + model.addAttribute("presenteventslist", presenteventslist); + model.addAttribute("pasteventslist", pasteventslist); + model.addAttribute("futureeventslist", futureeventslist); + return "admin/ongoingevents"; + } else { + session.invalidate(); // Invalidate the session to clear all session attributes return "redirect:/communityhall/login"; - } - } - + } + } + @GetMapping("/manualrefund") - public String viewManualRefund(Model model,HttpSession session) { - String adminname = (String) session.getAttribute("usertype"); - if(adminname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - model.addAttribute("adminname", adminname); - return "admin/manualrefund"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes + public String viewManualRefund(Model model, HttpSession session) { + String adminname = (String) session.getAttribute("usertype"); + if (adminname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + model.addAttribute("adminname", adminname); + return "admin/manualrefund"; + } else { + session.invalidate(); // Invalidate the session to clear all session attributes return "redirect:/communityhall/login"; - } + } } - + @GetMapping("/developer") - public String viewDeveloper(Model model,HttpSession session) { - String adminname = (String) session.getAttribute("usertype"); - if(adminname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - model.addAttribute("adminname", adminname); - return "admin/developer"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes + public String viewDeveloper(Model model, HttpSession session) { + String adminname = (String) session.getAttribute("usertype"); + if (adminname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + model.addAttribute("adminname", adminname); + return "admin/developer"; + } else { + session.invalidate(); // Invalidate the session to clear all session attributes return "redirect:/communityhall/login"; - } + } } -// @GetMapping("/getDeveloperdetails") + + // @GetMapping("/getDeveloperdetails") // public String getDetails(Model model,HttpSession session) // { // String adminname = (String) session.getAttribute("usertype"); @@ -864,43 +840,43 @@ else { // return "redirect:/communityhall/login"; // } // } -@PostMapping("/getDeveloperdetails") -public String generatedetails(Model model, - @RequestParam(name = "FromDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) String fromDate, - @RequestParam(name = "ToDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) String toDate, - @RequestParam(name = "request") String request, - @RequestParam(name = "bookingId", required = false) Long bookingId, - @RequestParam(name = "hallId", required = false) Long hallId, - @RequestParam(name = "hallName",required = false)String hallName,HttpSession session) { - - - String adminname = (String) session.getAttribute("usertype"); - if(adminname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - List TransactionResponse = new ArrayList<>(); - if (request.equals("1")) { - if (bookingId == null && hallId == null) { - TransactionResponse = bookingService.getTransactionresponse(fromDate, toDate, null, null); - } else if (bookingId != null && hallId == null) { - TransactionResponse = bookingService.getTransactionresponse(fromDate, toDate, bookingId, null); - } else if (bookingId == null && hallId != null) { - TransactionResponse = bookingService.getTransactionresponse(fromDate, toDate, null, hallId); - } else { - TransactionResponse = bookingService.getTransactionresponse(fromDate, toDate, bookingId, hallId); + @PostMapping("/getDeveloperdetails") + public String generatedetails(Model model, + @RequestParam(name = "FromDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) String fromDate, + @RequestParam(name = "ToDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) String toDate, + @RequestParam(name = "request") String request, + @RequestParam(name = "bookingId", required = false) Long bookingId, + @RequestParam(name = "hallId", required = false) Long hallId, + @RequestParam(name = "hallName", required = false) String hallName, HttpSession session) { + + + String adminname = (String) session.getAttribute("usertype"); + if (adminname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + List TransactionResponse = new ArrayList<>(); + if (request.equals("1")) { + if (bookingId == null && hallId == null) { + TransactionResponse = bookingService.getTransactionresponse(fromDate, toDate, null, null); + } else if (bookingId != null && hallId == null) { + TransactionResponse = bookingService.getTransactionresponse(fromDate, toDate, bookingId, null); + } else if (bookingId == null && hallId != null) { + TransactionResponse = bookingService.getTransactionresponse(fromDate, toDate, null, hallId); + } else { + TransactionResponse = bookingService.getTransactionresponse(fromDate, toDate, bookingId, hallId); + } } - } - List RefundResponse = new ArrayList<>(); - if (request.equals("2")) { - if (bookingId == null) { - RefundResponse = bookingService.getRefundResponse(fromDate,toDate,null); - } else { - RefundResponse = bookingService.getRefundResponse(fromDate, toDate,bookingId); + List RefundResponse = new ArrayList<>(); + if (request.equals("2")) { + if (bookingId == null) { + RefundResponse = bookingService.getRefundResponse(fromDate, toDate, null); + } else { + RefundResponse = bookingService.getRefundResponse(fromDate, toDate, bookingId); + } } - } - List BookingCalendar = new ArrayList<>(); - if (request.equals("3")) { - System.out.println("outside"); + List BookingCalendar = new ArrayList<>(); + if (request.equals("3")) { + System.out.println("outside"); // if (hallName.isEmpty()) { // System.out.println("check1"); // // Fetch all details for the given date range @@ -910,57 +886,57 @@ public String generatedetails(Model model, // // Fetch filtered details based on hallName // BookingCalendar = bookingService.getBookingCalendarDetails(fromDate, toDate, hallName); // } - BookingCalendar = bookingService.getBookingCalendarDetails(fromDate, toDate,bookingId,hallName); - } + BookingCalendar = bookingService.getBookingCalendarDetails(fromDate, toDate, bookingId, hallName); + } - model.addAttribute("fromdate", fromDate); - model.addAttribute("todate", toDate); - model.addAttribute("request", request); - model.addAttribute("TransactionResponse", TransactionResponse); - model.addAttribute("RefundResponse", RefundResponse); - model.addAttribute("BookingCalendar", BookingCalendar); - model.addAttribute("bookingId", bookingId); - model.addAttribute("hallId", hallId); - model.addAttribute("hallName", hallName); - model.addAttribute("adminname", adminname); - - return "admin/developer"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes - return "redirect:/communityhall/login"; + model.addAttribute("fromdate", fromDate); + model.addAttribute("todate", toDate); + model.addAttribute("request", request); + model.addAttribute("TransactionResponse", TransactionResponse); + model.addAttribute("RefundResponse", RefundResponse); + model.addAttribute("BookingCalendar", BookingCalendar); + model.addAttribute("bookingId", bookingId); + model.addAttribute("hallId", hallId); + model.addAttribute("hallName", hallName); + model.addAttribute("adminname", adminname); + + return "admin/developer"; + } else { + session.invalidate(); // Invalidate the session to clear all session attributes + return "redirect:/communityhall/login"; + } } -} - + @GetMapping("/notification") - public String viewNotificationPage(Model model,HttpSession session) { - String adminname = (String) session.getAttribute("usertype"); - if(adminname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - List newnotifications=notificationRepository.findActivenotifications(); - model.addAttribute("newnotifications", newnotifications); - model.addAttribute("mobileno", mobileno); - model.addAttribute("adminname", adminname); - return "admin/notification"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes + public String viewNotificationPage(Model model, HttpSession session) { + String adminname = (String) session.getAttribute("usertype"); + if (adminname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + List newnotifications = notificationRepository.findActivenotifications(); + model.addAttribute("newnotifications", newnotifications); + model.addAttribute("mobileno", mobileno); + model.addAttribute("adminname", adminname); + return "admin/notification"; + } else { + session.invalidate(); // Invalidate the session to clear all session attributes return "redirect:/communityhall/login"; - } + } } - + @GetMapping("/raisesettlement") - public String viewcaretakerpage(Model model,HttpSession session,@RequestParam("bookingId") int bookingId) { - String adminname = (String) session.getAttribute("usertype"); - if(adminname!=null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - model.addAttribute("adminname", adminname); - BookingDetails booking = bookingService.getBookingsById(bookingId); - model.addAttribute("booking",booking); - return "admin/caretakerpage"; - }else { - session.invalidate(); - return "redirect:/communityhall/login"; - } + public String viewcaretakerpage(Model model, HttpSession session, @RequestParam("bookingId") int bookingId) { + String adminname = (String) session.getAttribute("usertype"); + if (adminname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + model.addAttribute("adminname", adminname); + BookingDetails booking = bookingService.getBookingsById(bookingId); + model.addAttribute("booking", booking); + return "admin/caretakerpage"; + } else { + session.invalidate(); + return "redirect:/communityhall/login"; + } } @GetMapping("/settlementlist") @@ -977,18 +953,18 @@ public String generatedetails(Model model, } @GetMapping("/adminpage") - public String viewcaretaker(Model model,HttpSession session,@RequestParam("bookingId") int bookingId) { + public String viewcaretaker(Model model, HttpSession session, @RequestParam("bookingId") int bookingId) { String adminname = (String) session.getAttribute("usertype"); - if(adminname!=null) { + if (adminname != null) { long mobileno = (long) session.getAttribute("mobileno"); model.addAttribute("mobileno", mobileno); model.addAttribute("adminname", adminname); - model.addAttribute("title","Admin"); + model.addAttribute("title", "Admin"); model.addAttribute("baseURL", appConfig.getBaseUrl()); BookingDetails booking = bookingService.getBookingsById(bookingId); - model.addAttribute("booking",booking); + model.addAttribute("booking", booking); return "admin/adminpage"; - }else { + } else { session.invalidate(); return "redirect:/communityhall/login"; } @@ -1010,8 +986,8 @@ public String generatedetails(Model model, @GetMapping("/logout") - public String viewLogout(Model model,HttpSession session) { - session.invalidate(); + public String viewLogout(Model model, HttpSession session) { + session.invalidate(); return "redirect:/communityhall/login"; } diff --git a/src/main/java/com/gcc/communityHall/controller/UserAPIController.java b/src/main/java/com/gcc/communityHall/controller/UserAPIController.java index 4ca9d5a6..9cc89dbc 100644 --- a/src/main/java/com/gcc/communityHall/controller/UserAPIController.java +++ b/src/main/java/com/gcc/communityHall/controller/UserAPIController.java @@ -238,8 +238,8 @@ public class UserAPIController { //System.out.println(purpose); //System.out.print("\n MobileNo---:"+mobileNo); Random rand = new Random(); - int otp = rand.nextInt(90000) + 10000; -// int otp = 11111; +// int otp = rand.nextInt(90000) + 10000; + int otp = 11111; System.out.print("\n otp---:"+otp); DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd-MMM-yyyy%20HH:mm"); LocalDateTime now = LocalDateTime.now(); @@ -250,7 +250,7 @@ public class UserAPIController { System.out.println(urlString); System.out.println("\n urlString---: "+urlString); String bodyMessage = ""+otp; - try { + /*try { RestTemplate restTemplate = new RestTemplate(); String Response = restTemplate.getForObject(urlString, String.class); bodyMessage=Response; @@ -267,7 +267,7 @@ public class UserAPIController { } catch (Exception e) { // System.out.print("ERROR in Sending---: "+e); bodyMessage = "Error"; - } + }*/ HttpSession session = request.getSession(); session.setAttribute("otp", otp); diff --git a/src/main/java/com/gcc/communityHall/paymentService/repository/TransactionResponseRepository.java b/src/main/java/com/gcc/communityHall/paymentService/repository/TransactionResponseRepository.java index 34c840a4..3ef7b23f 100644 --- a/src/main/java/com/gcc/communityHall/paymentService/repository/TransactionResponseRepository.java +++ b/src/main/java/com/gcc/communityHall/paymentService/repository/TransactionResponseRepository.java @@ -27,13 +27,15 @@ public interface TransactionResponseRepository extends JpaRepository findByBookingIdAndTxansactionIdAndStatusCode(int bookingId,String txansactionId, String statusCode); - @Query(value = "SELECT tr.booking_id, tr.hall_id, tr.amount, tr.status_code, tr.txansaction_id, tr.user_id, p.payment_status " + + @Query(value = "SELECT tr.booking_id, tr.hall_id, tr.amount, tr.status_code, tr.txansaction_id, tr.user_id " + +// ", p.payment_status " + "FROM transaction_response tr " + "JOIN hall_details hd ON tr.hall_id = hd.hall_id " + - "LEFT JOIN payments p ON tr.booking_id = p.booking_details_booking_id " + +// "LEFT JOIN payments p ON tr.booking_id = p.booking_details_booking_id " + "LEFT JOIN booking_details bd ON tr.booking_id = bd.booking_id " + - "WHERE DATE(STR_TO_DATE(tr.date, '%d-%m-%Y %H:%i:%s')) >= STR_TO_DATE(:fromDate, '%Y-%m-%d') " + - "AND DATE(STR_TO_DATE(tr.date, '%d-%m-%Y %H:%i:%s')) <= STR_TO_DATE(:toDate, '%Y-%m-%d') " + + "WHERE DATE(STR_TO_DATE(tr.cdate, '%Y-%m-%d')) >= STR_TO_DATE(:fromDate, '%Y-%m-%d') " + +// "WHERE DATE(STR_TO_DATE(tr.cdate, '%d-%m-%Y %H:%i:%s')) >= STR_TO_DATE(:fromDate, '%Y-%m-%d') " + + "AND DATE(STR_TO_DATE(tr.cdate, '%Y-%m-%d')) <= STR_TO_DATE(:toDate, '%Y-%m-%d') " + "AND (:bookingId IS NULL OR tr.booking_id = :bookingId) " + "AND (:hallId IS NULL OR tr.hall_id = :hallId)", nativeQuery = true) List getTransactionResponseByBookingId(@Param("fromDate") String fromDate, diff --git a/src/main/java/com/gcc/communityHall/repository/BookingDetailsRepository.java b/src/main/java/com/gcc/communityHall/repository/BookingDetailsRepository.java index 321b1baa..6f544ced 100644 --- a/src/main/java/com/gcc/communityHall/repository/BookingDetailsRepository.java +++ b/src/main/java/com/gcc/communityHall/repository/BookingDetailsRepository.java @@ -115,7 +115,7 @@ public interface BookingDetailsRepository extends JpaRepository getBookingUserDetailsReport(@Param("fromDate") String fromDate, @Param("toDate") String toDate); @@ -179,7 +179,7 @@ public interface BookingDetailsRepository extends JpaRepository= :fromDate " + "AND DATE(bd.booking_date) <= :toDate " + - "AND (:bookingStatus IS NULL OR bd.booking_status = :bookingStatus) ", + "AND (:bookingStatus IS NULL OR bd.booking_status = :bookingStatus) order by bd.booking_id asc ", nativeQuery = true) List getAllBookingDetailsWithStatus(@Param("fromDate") String fromDate, @Param("toDate") String toDate, @@ -194,7 +194,7 @@ public interface BookingDetailsRepository extends JpaRepository= :fromDate " + "AND DATE(bd.booking_date) <= :toDate " + - "AND (:bookingId IS NULL OR bd.booking_id = :bookingId)", + "AND (:bookingId IS NULL OR bd.booking_id = :bookingId) order by bd.booking_id asc", nativeQuery = true) List getAllBookingDetailsWithBookingId(@Param("fromDate") String fromDate, @Param("toDate") String toDate, @@ -210,7 +210,7 @@ public interface BookingDetailsRepository extends JpaRepository= :fromDate " + "AND DATE(bd.booking_date) <= :toDate " + "AND (:bookingId IS NULL OR bd.booking_id = :bookingId)" + - "AND (:bookingStatus IS NULL OR bd.booking_status = :bookingStatus)", + "AND (:bookingStatus IS NULL OR bd.booking_status = :bookingStatus) order by bd.booking_id asc", nativeQuery = true) List getAllBookingDetailsWithBookingIdwithbookingStatus(@Param("fromDate") String fromDate, @Param("toDate") String toDate, @@ -225,7 +225,7 @@ public interface BookingDetailsRepository extends JpaRepository= :fromDate " + - "AND DATE(bd.booking_date) <= :toDate ", + "AND DATE(bd.booking_date) <= :toDate order by bd.booking_id asc", nativeQuery = true) List getAllBookingDetails(@Param("fromDate") String fromDate, @Param("toDate") String toDate); @@ -322,6 +322,7 @@ public interface BookingDetailsRepository extends JpaRepository CURDATE() THEN 'Reschedule'\r\n" + " WHEN bd.reason IN ('State Govt Event','Central Govt Event','Commericial & Others') AND bd.booking_status='APPROVED' THEN 'noaction'" + " ELSE 'Future' \r\n" @@ -1161,7 +1162,7 @@ public interface BookingDetailsRepository extends JpaRepository getBookingDetailsByBookingDate(@Param("fromDate") String fromDate, @Param("toDate") String toDate, @Param("zone") String zone, @Param("division") String division, @Param("hallid") Integer hallid); @@ -1177,7 +1178,7 @@ public interface BookingDetailsRepository extends JpaRepository getBookingDetailsByBookingDateWithStatus(@Param("fromDate") String fromDate, @Param("toDate") String toDate, @Param("bookingStatus") String bookingStatus, @Param("zone") String zone, @Param("division") String division, @Param("hallid") Integer hallid); @@ -1195,7 +1196,7 @@ public interface BookingDetailsRepository extends JpaRepository getBookingDetailsByEventDate(@Param("fromDate") String fromDate, @Param("toDate") String toDate, @Param("zone") String zone, @Param("division") String division, @Param("hallid") Integer hallid); @@ -1211,7 +1212,7 @@ public interface BookingDetailsRepository extends JpaRepository getBookingDetailsByEventDateWithStatus(@Param("fromDate") String fromDate, @Param("toDate") String toDate, @Param("bookingStatus") String bookingStatus, @Param("zone") String zone, @Param("division") String division, @Param("hallid") Integer hallid); @@ -1226,7 +1227,7 @@ public interface BookingDetailsRepository extends JpaRepository getAllPaymentsDetails(@Param("fromDate") String fromDate, @Param("toDate") String toDate, @Param("paymentStatus") String paymentStatus, @Param("zone") String zone, @Param("division") String division, @Param("hallid") Integer hallid); @@ -1240,7 +1241,7 @@ public interface BookingDetailsRepository extends JpaRepository getAllExtraPaymentsDetails(@Param("fromDate") String fromDate, @Param("toDate") String toDate, @Param("paymentStatus") String paymentStatus, @Param("zone") String zone, @Param("division") String division, @Param("hallid") Integer hallid); @@ -1256,7 +1257,8 @@ public interface BookingDetailsRepository extends JpaRepository getBookingHallDetailsReportByBookingDate(@Param("fromDate") String fromDate, @Param("toDate") String toDate, @Param("zone") String zone, @Param("division") String division, @Param("hallid") Integer hallid); @@ -1309,7 +1311,7 @@ public interface BookingDetailsRepository extends JpaRepository= :fromDate " + - "AND DATE(bd.booking_date) <= :toDate ", nativeQuery = true) + "AND DATE(bd.booking_date) <= :toDate order by bd.booking_id asc ", nativeQuery = true) List getAllBookingsettlementDetailsByBookingDate(@Param("fromDate") String fromDate, @Param("toDate") String toDate); @Query(value = "SELECT bd.*, hd.hall_name, us.name, us.usertype " + @@ -1319,7 +1321,7 @@ public interface BookingDetailsRepository extends JpaRepository= :fromDate " + "AND DATE(bd.booking_date) <= :toDate " + - "AND (:refundStatus IS NULL OR bd.refund_status = :refundStatus) ", nativeQuery = true) + "AND (:refundStatus IS NULL OR bd.refund_status = :refundStatus) order by bd.booking_id asc", nativeQuery = true) List getAllBookingsettlementDetailsByBookingDateWithStatus(@Param("fromDate") String fromDate, @Param("toDate") String toDate, @Param("refundStatus") String refundStatus); @Query(value = "SELECT bd.*, hd.hall_name, us.name, us.usertype " + @@ -1328,7 +1330,7 @@ public interface BookingDetailsRepository extends JpaRepository= :fromDate " + - "AND DATE(bd.end_date) <= :toDate ", nativeQuery = true) + "AND DATE(bd.end_date) <= :toDate order by bd.booking_id asc", nativeQuery = true) List getAllBookingsettlementDetailsByEventDate(@Param("fromDate") String fromDate, @Param("toDate") String toDate); @Query(value = "SELECT bd.*, hd.hall_name, us.name, us.usertype " + @@ -1338,7 +1340,7 @@ public interface BookingDetailsRepository extends JpaRepository= :fromDate " + "AND DATE(bd.end_date) <= :toDate " + - "AND (:refundStatus IS NULL OR bd.refund_status = :refundStatus) ", nativeQuery = true) + "AND (:refundStatus IS NULL OR bd.refund_status = :refundStatus) order by bd.booking_id asc", nativeQuery = true) List getAllBookingsettlementDetailsByEventDateWithStatus(@Param("fromDate") String fromDate, @Param("toDate") String toDate, @Param("refundStatus") String refundStatus); // In BookingDetailsRepository.java diff --git a/src/main/java/com/gcc/communityHall/service/BookingService.java b/src/main/java/com/gcc/communityHall/service/BookingService.java index 9aba87d7..64d518d1 100644 --- a/src/main/java/com/gcc/communityHall/service/BookingService.java +++ b/src/main/java/com/gcc/communityHall/service/BookingService.java @@ -19,137 +19,187 @@ import com.gcc.communityHall.entity.GccBlockingDate; public interface BookingService { BookingDetails getBookingsById(int BookingId); + BookingDetails updateBookingDetails(BookingDetails bd); - public String confirmTheDateAndSlot(String fromDate, String toDate, int days, int fromStartingSlot, int fromEndingSlot, int toStartingSlot, int toEndingSlot, int bookingId,int userId); - public Map saveBookingDetails(Map formData); + public String confirmTheDateAndSlot(String fromDate, String toDate, int days, int fromStartingSlot, int fromEndingSlot, int toStartingSlot, int toEndingSlot, int bookingId, int userId); + + public Map saveBookingDetails(Map formData); + + public BookingDetails updateBookingStatustoGCCBlocked(BookingDetails bookingDetails); - public BookingDetails updateBookingStatustoGCCBlocked(BookingDetails bookingDetails); + public BookingDetails updateBookingStatus(int bookingId, BookingDetails.BookingStatus status, String comments); - public BookingDetails updateBookingStatus(int bookingId, BookingDetails.BookingStatus status, String comments); - public BookingDetails updateBookingStatusById( int bookingId, BookingDetails.BookingStatus status,String comments); - public EbDetails updateEbDetails(int bookingId,double startUnit,double endUnit,char status); + public BookingDetails updateBookingStatusById(int bookingId, BookingDetails.BookingStatus status, String comments); + + public EbDetails updateEbDetails(int bookingId, double startUnit, double endUnit, char status); //typeOfCancel depends { } - String cancelBooking(int bookingId,BookingDetails.BookingStatus currentStatus,String comments); + String cancelBooking(int bookingId, BookingDetails.BookingStatus currentStatus, String comments); + public String confirmBooking(int bookingId); - - public BookingDetails getBookingDetailsWithSettlement(int settlementId); + public BookingDetails getBookingDetailsWithSettlement(int settlementId); //sreeja List getPresentsEventsByUserId(Integer hallId); + List getPastsEventsByUserId(Integer hallId); - List getFuturesEventsByUserId(Integer hallId); - List getSettlementList(Integer hallId); - public List getFilteredBookings(LocalDate fromDate, LocalDate toDate, List hallIds); - public List getPastData(int hall_id) ; - public String processEbDetailsAndDamage( + List getFuturesEventsByUserId(Integer hallId); + + List getSettlementList(Integer hallId); + + public List getFilteredBookings(LocalDate fromDate, LocalDate toDate, List hallIds); + + public List getPastData(int hall_id); + + public String processEbDetailsAndDamage( int bookingId, int ebId, double startingReading, double endingReading, - float usedUnit,double ebAmount, - String assetNames[], String comments[], int quantities[],Double assetAmounts[],MultipartFile assetImages[]); + float usedUnit, double ebAmount, + String assetNames[], String comments[], int quantities[], Double assetAmounts[], MultipartFile assetImages[]); + + public int checkUserBookinglimitation(int userId); - public int checkUserBookinglimitation(int userId); - List getAllBookingsByUserId(Integer userId); - List> getAllBookingEventsByUserId(Integer userId); - - + List getAllBookingsByUserId(Integer userId); - - //List getAllBookingDetailsWithStatus(String fromDate, String toDate, String bookingStatus); - - //List getAllPaymentsDetails( String fromDate, String toDate); + List> getAllBookingEventsByUserId(Integer userId); - List getBookingUserDetailsReport(String fromDate, String toDate); + + //List getAllBookingDetailsWithStatus(String fromDate, String toDate, String bookingStatus); + + //List getAllPaymentsDetails( String fromDate, String toDate); + + List getBookingUserDetailsReport(String fromDate, String toDate); List getBookingHallDetailsReport(String fromDate, String toDate); - List getBlockedEvents(LocalDate fromDate, LocalDate toDate, List hallIds); - List> getOfflineBookings(); - List getBookedslots(LocalDate fromDate,LocalDate endDate, List hallIdList); - BookingDetails updateCancelledBookingStatus(int bookingId, BookingStatus status, String comments); - BookingDetails updateRefundStatus(int bookingId, RefundStatus status); - - //officer service - List getAllBookingDetailsByZone(String fromDate, String toDate,String zone); - - List getAllBookingDetailsByZoneWithStatus(String fromDate, String toDate, String zone,String bookingStatus); - - List getAllPaymentsDetailsByZone (String fromDate, String toDate,String zone); - - List getBookingHallDetailsReportByZone(String fromDate, String toDate,String zone); - Optional updateBookingDatesAndCalendar(int bookingId, String startDate, String endDate); - List getBookingHallDetailsReportByZone1(String fromDate, String toDate,String zone, Integer hallId); - List getGccBlockingEvents(String hallId); - int getBlockedHallCount(String blockingReason, Date startDate, Date endDate); - @Transactional - void cancelAllBookings(String fromDate, String toDate, List hallIdsList, - String reasonforblocking, List selectedBookings, String updatedBy,String[] descriptions,MultipartFile[] documents); - List findBookingDetailsByBookingId(Long bookingId); - - //admin dashboard - Map> getBookingStatistics(LocalDate fromDate, LocalDate toDate, String zone, String division,Integer hallid, String userType); - - public List> getBookingDetailsByHallId(int hallId); - - //officer dashboard - Map> getOfficerDashboard(LocalDate fromDate, LocalDate toDate, String zone, String division,Integer hallid, String userType); - - List> getHallDetailsForOfficer(Integer hallIid); - //List getAllPaymentsDetails(String fromDate, String toDate, String paymentStatus); - //admin reports - - List getBookingDetailsByBookingDate(String fromDate,String toDate,String zone,String division,Integer hallid); - List getBookingDetailsByEventDate(String fromDate,String toDate,String zone,String division,Integer hallid); - List getBookingDetailsByBookingDateWithStatus(String fromDate,String toDate,String bookingStatus,String zone,String division,Integer hallid); - List getBookingDetailsByEventDateWithStatus(String fromDate,String toDate,String bookingStatus,String zone,String division,Integer hallid); - List getAllPaymentsDetails( String fromDate, String toDate,String paymentStatus,String zone, String division, Integer hallid); -List getBookingHallDetailsReportByBookingDate( String fromDate, String toDate,String zone,String division,Integer hallid); - List getBookingHallDetailsReportByEventDate(String fromDate, String toDate,String zone,String division,Integer hallid); - - List getAllBookingsettlementDetailsByBookingDate(String fromDate, String toDate); - List getAllBookingsettlementDetailsByBookingDateWithStatus( String fromDate, String toDate, String refundStatus); - List getAllBookingsettlementDetailsByEventDate( String fromDate, String toDate); - List getAllBookingsettlementDetailsByEventDateWithStatus( String fromDate, String toDate, String refundStatus); - List getAllBookingDetailsBookingDateByZone( String fromDate, String toDate, String zone); - List getAllBookingDetailsEventDateByZone( String fromDate, String toDate, String zone); - List getAllBookingDetailsBookingDateByZoneWithStatus( String fromDate, String toDate, String zone, String bookingStatus); - List getAllBookingDetailsEventDateByZoneWithStatus( String fromDate, String toDate, String zone, String bookingStatus); -List getAllBookingsettlementDetailsByZoneByBookingDate(String fromDate, String toDate, String zone); - List getAllBookingsettlementDetailsByZoneByEventDate(String fromDate, String toDate, String zone); - List getAllBookingsettlementDetailsByZoneByBookingDateWithStatus(String fromDate, String toDate, String zone, String refundStatus); - List getAllBookingsettlementDetailsByZoneByEventDateWithStatus(String fromDate, String toDate, String zone, String refundStatus); -List getBookingHallDetailsReportByZoneByBookingDate(String fromDate, String toDate, String zone); - List getBookingHallDetailsReportByZoneByEventDate(String fromDate, String toDate, String zone); + + List getBlockedEvents(LocalDate fromDate, LocalDate toDate, List hallIds); + + List> getOfflineBookings(); + + List getBookedslots(LocalDate fromDate, LocalDate endDate, List hallIdList); + + BookingDetails updateCancelledBookingStatus(int bookingId, BookingStatus status, String comments); + + BookingDetails updateRefundStatus(int bookingId, RefundStatus status); + + //officer service + List getAllBookingDetailsByZone(String fromDate, String toDate, String zone); + + List getAllBookingDetailsByZoneWithStatus(String fromDate, String toDate, String zone, String bookingStatus); + + List getAllPaymentsDetailsByZone(String fromDate, String toDate, String zone); + + List getBookingHallDetailsReportByZone(String fromDate, String toDate, String zone); + + Optional updateBookingDatesAndCalendar(int bookingId, String startDate, String endDate); + + List getBookingHallDetailsReportByZone1(String fromDate, String toDate, String zone, Integer hallId); + + List getGccBlockingEvents(String hallId); + + int getBlockedHallCount(String blockingReason, Date startDate, Date endDate); + + @Transactional + void cancelAllBookings(String fromDate, String toDate, List hallIdsList, + String reasonforblocking, List selectedBookings, String updatedBy, String[] descriptions, MultipartFile[] documents); + + List findBookingDetailsByBookingId(Long bookingId); + + //admin dashboard + Map> getBookingStatistics(LocalDate fromDate, LocalDate toDate, String zone, String division, Integer hallid, String userType); + + public List> getBookingDetailsByHallId(int hallId); + + //officer dashboard + Map> getOfficerDashboard(LocalDate fromDate, LocalDate toDate, String zone, String division, Integer hallid, String userType); + + List> getHallDetailsForOfficer(Integer hallIid); + //List getAllPaymentsDetails(String fromDate, String toDate, String paymentStatus); + //admin reports + + List getBookingDetailsByBookingDate(String fromDate, String toDate, String zone, String division, Integer hallid); + + List getBookingDetailsByEventDate(String fromDate, String toDate, String zone, String division, Integer hallid); + + List getBookingDetailsByBookingDateWithStatus(String fromDate, String toDate, String bookingStatus, String zone, String division, Integer hallid); + + List getBookingDetailsByEventDateWithStatus(String fromDate, String toDate, String bookingStatus, String zone, String division, Integer hallid); + + List getAllPaymentsDetails(String fromDate, String toDate, String paymentStatus, String zone, String division, Integer hallid); + + List getBookingHallDetailsReportByBookingDate(String fromDate, String toDate, String zone, String division, Integer hallid); + + List getBookingHallDetailsReportByEventDate(String fromDate, String toDate, String zone, String division, Integer hallid); + + List getAllBookingsettlementDetailsByBookingDate(String fromDate, String toDate); + + List getAllBookingsettlementDetailsByBookingDateWithStatus(String fromDate, String toDate, String refundStatus); + + List getAllBookingsettlementDetailsByEventDate(String fromDate, String toDate); + + List getAllBookingsettlementDetailsByEventDateWithStatus(String fromDate, String toDate, String refundStatus); + + List getAllBookingDetailsBookingDateByZone(String fromDate, String toDate, String zone); + + List getAllBookingDetailsEventDateByZone(String fromDate, String toDate, String zone); + + List getAllBookingDetailsBookingDateByZoneWithStatus(String fromDate, String toDate, String zone, String bookingStatus); + + List getAllBookingDetailsEventDateByZoneWithStatus(String fromDate, String toDate, String zone, String bookingStatus); + + List getAllBookingsettlementDetailsByZoneByBookingDate(String fromDate, String toDate, String zone); + + List getAllBookingsettlementDetailsByZoneByEventDate(String fromDate, String toDate, String zone); + + List getAllBookingsettlementDetailsByZoneByBookingDateWithStatus(String fromDate, String toDate, String zone, String refundStatus); + + List getAllBookingsettlementDetailsByZoneByEventDateWithStatus(String fromDate, String toDate, String zone, String refundStatus); + + List getBookingHallDetailsReportByZoneByBookingDate(String fromDate, String toDate, String zone); + + List getBookingHallDetailsReportByZoneByEventDate(String fromDate, String toDate, String zone); + List getBookingHallDetailsReportByZoneByBookingDateHallname(String fromDate, String toDate, String zone, Integer hallId); + List getBookingHallDetailsReportByZoneByEventDateHallname(String fromDate, String toDate, String zone, Integer hallId); - BookingDetails saveebdetails(int bookingId, double startingReading, MultipartFile startingReadingimage); - String confirmStateBooking(int bookingId); - String uploadNOCFile(MultipartFile file, int bookingId); - - //gccapps - List getApprovedBookingDetails(); - List getRejectedBookingDetails(); + BookingDetails saveebdetails(int bookingId, double startingReading, MultipartFile startingReadingimage); + + String confirmStateBooking(int bookingId); + + String uploadNOCFile(MultipartFile file, int bookingId); + + //gccapps + List getApprovedBookingDetails(); + + List getRejectedBookingDetails(); + + List getAllPaymentsDetails(String fromDate, String toDate); + + List getPastsEvents(); + + List getPresentsEvents(); + + List getFuturesEvents(); + + List getSettlementApprovedList(); + + List> getHallDetails(Integer hall_id); - List getAllPaymentsDetails( String fromDate, String toDate); - List getPastsEvents(); + List getWaitingforNOCapproval(); - List getPresentsEvents(); + List getAllExtraPaymentsDetails(String fromDate, String toDate, String paymentStatus, String zone, String division, Integer hallid); - List getFuturesEvents(); + //developer + List getTransactionresponse(String fromDate, String toDate, Long bookingId, Long hallId); -List getSettlementApprovedList(); + List getRefundResponse(String fromDate, String toDate, Long bookingId); -List> getHallDetails( Integer hall_id); -List getWaitingforNOCapproval(); -List getAllExtraPaymentsDetails( String fromDate, String toDate,String paymentStatus,String zone, String division, Integer hallid); -//developer -List getTransactionresponse(String fromDate, String toDate, Long bookingId,Long hallId); -List getRefundResponse(String fromDate, String toDate, Long bookingId); -List getBookingCalendarDetails(String fromDate, String toDate, Long bookingId,String hallName); + List getBookingCalendarDetails(String fromDate, String toDate, Long bookingId, String hallName); List getBookingsByDateAndHall(String bookingDate, Long hallId); } diff --git a/src/main/java/com/gcc/communityHall/service/Impl/BookingServiceImpl.java b/src/main/java/com/gcc/communityHall/service/Impl/BookingServiceImpl.java index bc541346..8be32ef8 100644 --- a/src/main/java/com/gcc/communityHall/service/Impl/BookingServiceImpl.java +++ b/src/main/java/com/gcc/communityHall/service/Impl/BookingServiceImpl.java @@ -326,7 +326,12 @@ public class BookingServiceImpl implements BookingService { bookingCalendarRepository.save(bookingCalendar); i++; } - String reason = bookingDetails.getReason(); + + String statusMessage = processBookingStatusAndSendMessages(bookingDetails); + + return statusMessage; + + /*String reason = bookingDetails.getReason(); ReasonMaster reasondetails = reasonMasterRepository.findByReason(reason); String reasoncode = reasondetails.getReasoncode(); if (reasoncode == null) { @@ -348,8 +353,9 @@ public class BookingServiceImpl implements BookingService { whatsappMsgServiceImpl.sendMsg(whatsupmsg); whatsappMsgServiceImpl.sendSMS(urlString); return "Booking confirmed successfully"; - } + }*/ } catch (Exception e) { + e.printStackTrace(); bookingFailure(bookingDetails, 2); // System.out.println(bookingDetails.getBookingStatus()+","+bookingDetails.getRefundStatus()+","+bookingDetails.getComments()); return "redirect:/communityhall/user/acknowledgement?bookingId=" + bookingDetails.getBookingId(); @@ -357,6 +363,58 @@ public class BookingServiceImpl implements BookingService { } + @Transactional + public String processBookingStatusAndSendMessages(BookingDetails bookingDetails) { + try{ + String reason = bookingDetails.getReason(); + ReasonMaster reasonDetails = reasonMasterRepository.findByReason(reason); + String reasonCode = (reasonDetails != null && reasonDetails.getReasoncode() != null) ? reasonDetails.getReasoncode() : ""; + + String bookingconfirmationmsg, urlString, whatsupmsg; + + if (reasonCode.equals("CGE") || reasonCode.equals("CAO") || reasonCode.equals("SGE")) { + updateBookingStatusById(bookingDetails.getBookingId(), BookingDetails.BookingStatus.WAITING_FOR_NOC, "Waiting For NOC Documents"); + + bookingconfirmationmsg = "Your booking ID " + bookingDetails.getBookingId() + " on " + bookingDetails.getBookingDate() + " has been confirmed successfully. Thanks for using GCC Community Hall Booking System."; + + urlString = "https://tmegov.onex-aura.com/api/sms?key=pfTEYN6H&to=" + bookingDetails.getUsers().getMobileNo() + + "&from=GCCCRP&body=" + bookingconfirmationmsg + "&entityid=1401572690000011081&templateid=1407172346459428987"; + + whatsupmsg = "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to=" + + bookingDetails.getUsers().getMobileNo() + + "&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Your+booking+with+ID+" + + bookingDetails.getBookingId() + "+on+" + bookingDetails.getBookingDate() + + "+has+been+successfully+confirmed.+%0AThanks+for+using+GCC+Community+Hall+Booking+System."; + + whatsappMsgServiceImpl.sendMsg(whatsupmsg); + whatsappMsgServiceImpl.sendSMS(urlString); + return "Waiting For NOC Documents"; + + } else { + updateBookingStatusById(bookingDetails.getBookingId(), BookingDetails.BookingStatus.APPROVED, "Booking Confirmed Successfully"); + + bookingconfirmationmsg = "Your booking ID " + bookingDetails.getBookingId() + " on " + bookingDetails.getStartDate() + " has been confirmed successfully. Thanks for using GCC Community Hall Booking System."; + + urlString = "https://tmegov.onex-aura.com/api/sms?key=pfTEYN6H&to=" + bookingDetails.getUsers().getMobileNo() + + "&from=GCCCRP&body=" + bookingconfirmationmsg + "&entityid=1401572690000011081&templateid=1407172346459428987"; + + whatsupmsg = "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to=" + + bookingDetails.getUsers().getMobileNo() + + "&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Your+booking+with+ID+" + + bookingDetails.getBookingId() + "+on+" + bookingDetails.getStartDate() + + "+has+been+successfully+confirmed.+%0AThanks+for+using+GCC+Community+Hall+Booking+System."; + + whatsappMsgServiceImpl.sendMsg(whatsupmsg); + whatsappMsgServiceImpl.sendSMS(urlString); + return "Booking confirmed successfully"; + } + }catch (Exception e){ + e.printStackTrace(); + return "error"; + } + } + + @Override @Transactional public String confirmStateBooking(int bookingId) { @@ -590,7 +648,7 @@ public class BookingServiceImpl implements BookingService { if (user != null) { bookingDetails.setUsers(user); - if(counterId!=null){ + if (counterId != null) { bookingDetails.setCounterId(counterId); } if (hallDetails != null) { diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index b5443d00..5918bf49 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -1,6 +1,7 @@ spring.application.name=communityHall spring.datasource.url=jdbc:mysql://127.0.0.1:3306/testcommunityhall +#spring.datasource.url=jdbc:mysql://127.0.0.1:3306/communityhall_13032025 spring.datasource.username=root spring.datasource.password=root @@ -35,7 +36,7 @@ spring.servlet.multipart.max-request-size=10MB spring.jpa.driverClassName= com.mysql.cj.jdbc.Driver -employee.api.url=https://erp.chennaic orporation.gov.in/pgr/external/mobileservice +employee.api.url=https://erp.chennaicorporation.gov.in/pgr/external/mobileservice app.erpUrl=https://erp.chennaicorporation.gov.in/pgr/external/mobileservice? server.address=0.0.0.0 @@ -70,4 +71,4 @@ app.getOtpUrl=https://tmegov.onex-aura.com/api/sms? app.manualRefundCode=8520 app.fullUrl=http://localhost:8080 -app.commErpUrl=http://coc-staging.egovernments.org:9980/pgr/external/mobileservice \ No newline at end of file +app.commErpUrl=http://coc-staging.egovernments.org:9980/pgr/external/mobileservice diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties index d4c093ce..48ce50f2 100644 --- a/src/main/resources/application-prod.properties +++ b/src/main/resources/application-prod.properties @@ -52,4 +52,5 @@ app.getOtpUrl=https://tmegov.onex-aura.com/api/sms? app.manualRefundCode=8520 -app.fullUrl=https://gccservices.chennaicorporation.gov.in/communityhall \ No newline at end of file +app.fullUrl=https://gccservices.chennaicorporation.gov.in/communityhall +app.commErpUrl=https://erp.chennaicorporation.gov.in/pgr/external/mobileservice \ No newline at end of file diff --git a/src/main/resources/templates/admin/bookingwaiting.html b/src/main/resources/templates/admin/bookingwaiting.html index 576f1dd3..43385406 100644 --- a/src/main/resources/templates/admin/bookingwaiting.html +++ b/src/main/resources/templates/admin/bookingwaiting.html @@ -51,6 +51,7 @@ S.No + Booking Id Zone Division Hall Name @@ -66,6 +67,7 @@ + diff --git a/src/main/resources/templates/admin/reports.html b/src/main/resources/templates/admin/reports.html index 91f804b8..14813d86 100644 --- a/src/main/resources/templates/admin/reports.html +++ b/src/main/resources/templates/admin/reports.html @@ -292,6 +292,7 @@ S.No + User Id Name Mobile Address @@ -302,6 +303,7 @@ 0 + - S.No + User Id Name Mobile Address @@ -471,6 +473,7 @@ 0 + @@ -487,6 +490,7 @@ S.No + Hall Id Hall Name Zone/Division Caretaker Name @@ -503,6 +507,7 @@ 0 + diff --git a/src/main/resources/templates/admin/viewUploadNoc.html b/src/main/resources/templates/admin/viewUploadNoc.html index 5bca75e9..e4fc3284 100644 --- a/src/main/resources/templates/admin/viewUploadNoc.html +++ b/src/main/resources/templates/admin/viewUploadNoc.html @@ -57,6 +57,7 @@ S.No + Booking Id Zone Division Hall Name @@ -72,6 +73,7 @@ + diff --git a/src/main/resources/templates/headquarters/bookingwaiting.html b/src/main/resources/templates/headquarters/bookingwaiting.html index 3ddaeaba..97bd1889 100644 --- a/src/main/resources/templates/headquarters/bookingwaiting.html +++ b/src/main/resources/templates/headquarters/bookingwaiting.html @@ -51,6 +51,7 @@ S.No + Booking Id Zone Division Hall Name @@ -66,6 +67,7 @@ + diff --git a/src/main/resources/templates/headquarters/reports.html b/src/main/resources/templates/headquarters/reports.html index 52ba48d5..63e04e6a 100644 --- a/src/main/resources/templates/headquarters/reports.html +++ b/src/main/resources/templates/headquarters/reports.html @@ -291,6 +291,7 @@ S.No + User Id Name Mobile Address @@ -301,6 +302,7 @@ 0 + S.No + User Id Name Mobile Address @@ -427,6 +430,7 @@ 0 + @@ -443,6 +447,7 @@ S.No + Hall Id Hall Name Zone/Division Caretaker Name @@ -459,6 +464,7 @@ 0 + diff --git a/src/main/resources/templates/headquarters/viewUploadNoc.html b/src/main/resources/templates/headquarters/viewUploadNoc.html index f3e34275..61f8f1dc 100644 --- a/src/main/resources/templates/headquarters/viewUploadNoc.html +++ b/src/main/resources/templates/headquarters/viewUploadNoc.html @@ -57,6 +57,7 @@ S.No + Booking Id Zone Division Hall Name @@ -72,6 +73,7 @@ + diff --git a/src/main/resources/templates/officiallogin.html b/src/main/resources/templates/officiallogin.html index 44025d41..86c140ad 100644 --- a/src/main/resources/templates/officiallogin.html +++ b/src/main/resources/templates/officiallogin.html @@ -135,7 +135,8 @@
-
@@ -276,7 +277,7 @@