diff --git a/src/main/java/com/gcc/communityHall/controller/AdminAPIController.java b/src/main/java/com/gcc/communityHall/controller/AdminAPIController.java index 8b385d74..1a167acb 100644 --- a/src/main/java/com/gcc/communityHall/controller/AdminAPIController.java +++ b/src/main/java/com/gcc/communityHall/controller/AdminAPIController.java @@ -106,267 +106,268 @@ import lombok.AllArgsConstructor; @AllArgsConstructor @Validated public class AdminAPIController { - - @Autowired - private HallDetailsRepository hallDetailsRepository; - - @Autowired - private HallDetailService hallDetailService; - @Autowired - private BookingDetailsRepository bookingDetailsRepository; - - @Autowired - private SettlementService settlementService; - - @Autowired - private SettlementRepository settlementRepository; - - @Autowired - private BookingServiceImpl bookingService; - - @Autowired + + @Autowired + private HallDetailsRepository hallDetailsRepository; + + @Autowired + private HallDetailService hallDetailService; + @Autowired + private BookingDetailsRepository bookingDetailsRepository; + + @Autowired + private SettlementService settlementService; + + @Autowired + private SettlementRepository settlementRepository; + + @Autowired + private BookingServiceImpl bookingService; + + @Autowired private BookingDetailsRepository bookingDetailsRepo; - + @Autowired private DiscountRangeRepository discountRangeRepo; - + @Autowired private GccBlockingDateRepository blockingDateRepository; - + @Autowired private ReasonMasterService reasonMasterService; - + @Autowired private HallDetailService hallService; @Autowired private UserService userService; - + @Autowired private BookingCalendarRepository bookingCalendarRepository; - + @Autowired private UsersRepository userRepository; - + @Autowired private HallImagesRepository hallImagesRepository; - + @Autowired private JwtUtil jwtUtil; - - @Autowired - private AppConfig appConfig; - + + @Autowired + private AppConfig appConfig; + @Autowired private PaymentGatewayServiceImpl paymentGatewayServiceImpl; - + @Autowired private NotificationRepository notificationRepo; - + @Autowired private HttpSession session; - + @Autowired private ApplicationLogsRepository applicationLogsRepository; - + @Operation( - summary = "Update HallDetails REST API", - description = "REST API to update the Hall Details" - ) - @ApiResponses({ - @ApiResponse( - responseCode = "200", - description = "HTTP Status UPDATED", - content = @Content( - mediaType = "text/plain", - schema = @Schema(implementation = HallDetails.class), - examples = @ExampleObject(value = "Hall details updated successfully") - ) - ), - @ApiResponse( - responseCode = "500", - description = "HTTP Status Internal Server Error", - content = @Content( - mediaType = "application/json", - schema = @Schema(implementation = ErrorResponseDto.class), - examples = @ExampleObject( - name = "Internal Server Error Example", - value = "{ \"path\": \"/updateHallDetails\", \"status\": 500, \"error\": \"Internal Server Error\", \"timestamp\": \"2024-06-22T05:47:04.347+00:00\" }" - ) - ) - ) - }) - @PostMapping("/updateHallDetails") - public ResponseEntity updateHallInfo( - @RequestParam("hallId") String hallId, - @RequestParam("zone") String zone, - @RequestParam("division") String division, - @RequestParam("hallName") String hallName, - @RequestParam("doorNo") String doorNo, - @RequestParam("street") String street, - @RequestParam("area") String area, - @RequestParam("pinCode") int pinCode, - @RequestParam("landMark") String landMark, - @RequestParam("latitude") String latitude, - @RequestParam("longitude") String longitude, - @RequestParam("hallInchargeMobno") long hallInchargeMobno, - @RequestParam("hallInchargeName") String hallInchargeName, - @RequestParam("depositAmount") float depositAmount, - @RequestParam("fullDayRent") float fullDayRent, - @RequestParam("halfDayRent") float halfDayRent, - @RequestParam("parkingCapacity") String parkingCapacity, - @RequestParam("seatingCapacity") int seatingCapacity, - @RequestParam(value = "images", required = false) List images, - @RequestParam("ebNumber") String ebNumber, - @RequestParam("ebCostPerUnit") float ebCostPerUnit, - @RequestParam("gst") float gst, - @RequestParam("city") String city, - @RequestParam("isActive") boolean isActive) { - - HallDetails hallDetails = new HallDetails(); - hallDetails.setHallId(Integer.parseInt(hallId)); - hallDetails.setZone(zone); - hallDetails.setDivision(division); - hallDetails.setHallName(hallName); - hallDetails.setDoorNo(doorNo); - hallDetails.setStreet(street); - hallDetails.setArea(area); - hallDetails.setPinCode(pinCode); - hallDetails.setLandMark(landMark); - hallDetails.setLatitude(latitude); - hallDetails.setLongitude(longitude); - hallDetails.setHallInchargeMobno(hallInchargeMobno); - hallDetails.setHallInchargeName(hallInchargeName); - hallDetails.setDepositAmount(depositAmount); - hallDetails.setFullDayRent(fullDayRent); - hallDetails.setHalfDayRent(halfDayRent); - hallDetails.setParkingCapacity(parkingCapacity); - hallDetails.setSeatingCapacity(seatingCapacity); - hallDetails.setEbNumber(ebNumber); - hallDetails.setEbCostPerUnit(ebCostPerUnit); - hallDetails.setGst(gst); - hallDetails.setCity(city); - hallDetails.setActive(isActive); - - hallDetailService.updateHallDetail(hallDetails, images); - 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("Hall Details edit:-"+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); - - return ResponseEntity.ok("Success"); - } - - + summary = "Update HallDetails REST API", + description = "REST API to update the Hall Details" + ) + @ApiResponses({ + @ApiResponse( + responseCode = "200", + description = "HTTP Status UPDATED", + content = @Content( + mediaType = "text/plain", + schema = @Schema(implementation = HallDetails.class), + examples = @ExampleObject(value = "Hall details updated successfully") + ) + ), + @ApiResponse( + responseCode = "500", + description = "HTTP Status Internal Server Error", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = ErrorResponseDto.class), + examples = @ExampleObject( + name = "Internal Server Error Example", + value = "{ \"path\": \"/updateHallDetails\", \"status\": 500, \"error\": \"Internal Server Error\", \"timestamp\": \"2024-06-22T05:47:04.347+00:00\" }" + ) + ) + ) + }) + @PostMapping("/updateHallDetails") + public ResponseEntity updateHallInfo( + @RequestParam("hallId") String hallId, + @RequestParam("zone") String zone, + @RequestParam("division") String division, + @RequestParam("hallName") String hallName, + @RequestParam("doorNo") String doorNo, + @RequestParam("street") String street, + @RequestParam("area") String area, + @RequestParam("pinCode") int pinCode, + @RequestParam("landMark") String landMark, + @RequestParam("latitude") String latitude, + @RequestParam("longitude") String longitude, + @RequestParam("hallInchargeMobno") long hallInchargeMobno, + @RequestParam("hallInchargeName") String hallInchargeName, + @RequestParam("depositAmount") float depositAmount, + @RequestParam("fullDayRent") float fullDayRent, + @RequestParam("halfDayRent") float halfDayRent, + @RequestParam("parkingCapacity") String parkingCapacity, + @RequestParam("seatingCapacity") int seatingCapacity, + @RequestParam(value = "images", required = false) List images, + @RequestParam("ebNumber") String ebNumber, + @RequestParam("ebCostPerUnit") float ebCostPerUnit, + @RequestParam("gst") float gst, + @RequestParam("city") String city, + @RequestParam("isActive") boolean isActive) { + + HallDetails hallDetails = new HallDetails(); + hallDetails.setHallId(Integer.parseInt(hallId)); + hallDetails.setZone(zone); + hallDetails.setDivision(division); + hallDetails.setHallName(hallName); + hallDetails.setDoorNo(doorNo); + hallDetails.setStreet(street); + hallDetails.setArea(area); + hallDetails.setPinCode(pinCode); + hallDetails.setLandMark(landMark); + hallDetails.setLatitude(latitude); + hallDetails.setLongitude(longitude); + hallDetails.setHallInchargeMobno(hallInchargeMobno); + hallDetails.setHallInchargeName(hallInchargeName); + hallDetails.setDepositAmount(depositAmount); + hallDetails.setFullDayRent(fullDayRent); + hallDetails.setHalfDayRent(halfDayRent); + hallDetails.setParkingCapacity(parkingCapacity); + hallDetails.setSeatingCapacity(seatingCapacity); + hallDetails.setEbNumber(ebNumber); + hallDetails.setEbCostPerUnit(ebCostPerUnit); + hallDetails.setGst(gst); + hallDetails.setCity(city); + hallDetails.setActive(isActive); + + hallDetailService.updateHallDetail(hallDetails, images); + 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("Hall Details edit:-" + 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); + + return ResponseEntity.ok("Success"); + } + + @Operation( - summary = "Update Settlement Status REST API", - description = "REST API to update the Settlement Status to INITIATED" - ) - @ApiResponses({ - @ApiResponse( - responseCode = "200", - description = "HTTP Status UPDATED", - content = @Content( - mediaType = "application/json", - schema = @Schema(implementation = Settlement.class), - examples = @ExampleObject( - name = "Settlement Example", - value = "{\"settlementId\": Id, \"Refundstatus\": \"INITIATED\", \"comments\": \"Settlement initiated successfully\"}" - ) - ) - ), - @ApiResponse( - responseCode = "500", - description = "HTTP Status Internal Server Error", - content = @Content( - mediaType = "application/json", - schema = @Schema(implementation = ErrorResponseDto.class), - examples = @ExampleObject( - name = "Internal Server Error Example", - value = "{ \"path\": \"/updateInitiatedSettlementStatus/{settlementId}\", \"status\": 500, \"error\": \"Internal Server Error\", \"timestamp\": \"2024-06-22T05:47:04.347+00:00\" }" - ) - ) - ) - }) - @PostMapping("/updateInitiatedSettlementStatus/{settlementId}") - public ResponseEntity updateInitiatedSettlementStatus( - @PathVariable("settlementId") int settlementId, - @RequestParam("status") BookingDetails.RefundStatus status, - @RequestParam("comments") String comments) { - Settlement updateInitialiseSettlement = settlementService.updateSettlementStatus(settlementId, status, comments); - 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("Settlement Initiation:-"+status); - 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); - if (updateInitialiseSettlement != null) { - return new ResponseEntity<>(updateInitialiseSettlement , HttpStatus.OK); - } else { - return new ResponseEntity<>(HttpStatus.NOT_FOUND); - } - } + summary = "Update Settlement Status REST API", + description = "REST API to update the Settlement Status to INITIATED" + ) + @ApiResponses({ + @ApiResponse( + responseCode = "200", + description = "HTTP Status UPDATED", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Settlement.class), + examples = @ExampleObject( + name = "Settlement Example", + value = "{\"settlementId\": Id, \"Refundstatus\": \"INITIATED\", \"comments\": \"Settlement initiated successfully\"}" + ) + ) + ), + @ApiResponse( + responseCode = "500", + description = "HTTP Status Internal Server Error", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = ErrorResponseDto.class), + examples = @ExampleObject( + name = "Internal Server Error Example", + value = "{ \"path\": \"/updateInitiatedSettlementStatus/{settlementId}\", \"status\": 500, \"error\": \"Internal Server Error\", \"timestamp\": \"2024-06-22T05:47:04.347+00:00\" }" + ) + ) + ) + }) + @PostMapping("/updateInitiatedSettlementStatus/{settlementId}") + public ResponseEntity updateInitiatedSettlementStatus( + @PathVariable("settlementId") int settlementId, + @RequestParam("status") BookingDetails.RefundStatus status, + @RequestParam("comments") String comments) { + Settlement updateInitialiseSettlement = settlementService.updateSettlementStatus(settlementId, status, comments); + 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("Settlement Initiation:-" + status); + 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); + if (updateInitialiseSettlement != null) { + return new ResponseEntity<>(updateInitialiseSettlement, HttpStatus.OK); + } else { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + } + @Operation( - summary = "HallDetails by HallId REST API", - description = "REST API to Retrieving the Hall Details by hallId" - ) - @ApiResponses({ - @ApiResponse( - responseCode = "200", - description = "HTTP Status OK", - content = @Content( - mediaType = "application/json", - schema = @Schema(implementation = HallDetails.class) - ) - ), - @ApiResponse( - responseCode = "400", - description = "Bad Request" - ), - @ApiResponse( - responseCode = "404", - description = "Not Found" - ) - }) - @GetMapping("/getHallDetails/{hallId}") - public ResponseEntity getHallDetails(@PathVariable String hallId) { - int id; - try { - id = Integer.parseInt(hallId); - } catch (NumberFormatException e) { - return ResponseEntity.badRequest().build(); - } - - HallDetails hallDetails = hallDetailsRepository.findHallDetailsById(id); - //System.out.println(hallDetails.isActive()); - if (hallDetails != null) { - return ResponseEntity.ok(hallDetails); - } else { - return ResponseEntity.notFound().build(); - } - } - + summary = "HallDetails by HallId REST API", + description = "REST API to Retrieving the Hall Details by hallId" + ) + @ApiResponses({ + @ApiResponse( + responseCode = "200", + description = "HTTP Status OK", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = HallDetails.class) + ) + ), + @ApiResponse( + responseCode = "400", + description = "Bad Request" + ), + @ApiResponse( + responseCode = "404", + description = "Not Found" + ) + }) + @GetMapping("/getHallDetails/{hallId}") + public ResponseEntity getHallDetails(@PathVariable String hallId) { + int id; + try { + id = Integer.parseInt(hallId); + } catch (NumberFormatException e) { + return ResponseEntity.badRequest().build(); + } + + HallDetails hallDetails = hallDetailsRepository.findHallDetailsById(id); + //System.out.println(hallDetails.isActive()); + if (hallDetails != null) { + return ResponseEntity.ok(hallDetails); + } else { + return ResponseEntity.notFound().build(); + } + } + @Operation( summary = "Saving the DiscountRange REST API", description = "REST API to Saving the Discount Range for usertypes" @@ -375,12 +376,12 @@ public class AdminAPIController { public String saveDiscountrange( @RequestParam String userType, @RequestParam float discountRange, HttpSession session) { - + Optional existingDiscountRanges = discountRangeRepo.findByUsertype(userType); if (!existingDiscountRanges.isEmpty()) { return "waiting"; } - + String adminname = (String) session.getAttribute("usertype"); DiscountRange discount = new DiscountRange(); discount.setUsertype(userType); @@ -389,41 +390,41 @@ public class AdminAPIController { discount.setUpdtedBy(adminname); discount.setIs_active(true); discount.setIs_delete(false); - + discountRangeRepo.save(discount); return "success"; - } - + } + @PostMapping("/savenotification") public String saveNotification( @RequestParam String notification, HttpSession session) { - + String adminname = (String) session.getAttribute("usertype"); Notification newnotification = new Notification(); newnotification.setNotification_description(notification); newnotification.setCdate(LocalDate.now()); newnotification.setCreatedBY(adminname); newnotification.setActive(true); - newnotification.setDelete(false); + newnotification.setDelete(false); notificationRepo.save(newnotification); - Integer loginid = (Integer) session.getAttribute("id"); - ApplicationLogs logs=new ApplicationLogs(); - logs.setComments("Action by " + adminname); - logs.setLoginId(loginid); - logs.setLogType("Added New Notification:-"+newnotification.getNotification_description()); - 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("Added New Notification:-" + newnotification.getNotification_description()); + 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); return "success"; } - + @Operation( summary = " Update the DiscountRange REST API", description = "REST API to Updating the Discount Range for usertypes" @@ -438,88 +439,88 @@ public class AdminAPIController { updatediscount.setUpdtedBy(adminname); updatediscount.setcDate(LocalDate.now()); discountRangeRepo.save(updatediscount); - Integer loginid = (Integer) session.getAttribute("id"); - ApplicationLogs logs=new ApplicationLogs(); - logs.setComments("Action by " + adminname); - logs.setLoginId(loginid); - logs.setLogType("Discount Details Update:-"+updatediscount.getUsertype()); - 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("Discount Details Update:-" + updatediscount.getUsertype()); + 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); return "success"; } else { return "error: Entry with ID " + id + " not found"; } } - - + + @Operation( summary = " Delete the DiscountRange REST API", description = "REST API to Deleting the Discount for usertypes" ) - @DeleteMapping("/deleteById/{id}") - public ResponseEntity deleteDiscountRangeById(@PathVariable int id) { - if (discountRangeRepo.existsById(id)) { - discountRangeRepo.deleteById(id); - 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("Discount Details Delete:-"+id); - 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); - return ResponseEntity.ok("DiscountRange with ID " + id + " deleted successfully."); - } else { - return ResponseEntity.notFound().build(); // Return 404 if the entry does not exist - } - } - - @PostMapping("/deletenotificationById/{id}") - public ResponseEntity deleteNotificationById(@PathVariable int id,HttpSession session) { - Optional notification=notificationRepo.findById(id); - Notification newnotification=notification.get(); - newnotification.setActive(false); - newnotification.setDelete(true); - String adminname = (String) session.getAttribute("usertype"); - newnotification.setUpdatedBy(adminname); - String date = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); - newnotification.setUpdatedDate(date); - notificationRepo.save(newnotification); - Integer loginid = (Integer) session.getAttribute("id"); - ApplicationLogs logs=new ApplicationLogs(); - logs.setComments("Action by " + adminname); - logs.setLoginId(loginid); - logs.setLogType("Detele Notification:-"+newnotification.getNotification_description()); - 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); - return ResponseEntity.ok("Notification with ID " + id + " deleted successfully."); - - } - + @DeleteMapping("/deleteById/{id}") + public ResponseEntity deleteDiscountRangeById(@PathVariable int id) { + if (discountRangeRepo.existsById(id)) { + discountRangeRepo.deleteById(id); + 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("Discount Details Delete:-" + id); + 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); + return ResponseEntity.ok("DiscountRange with ID " + id + " deleted successfully."); + } else { + return ResponseEntity.notFound().build(); // Return 404 if the entry does not exist + } + } + + @PostMapping("/deletenotificationById/{id}") + public ResponseEntity deleteNotificationById(@PathVariable int id, HttpSession session) { + Optional notification = notificationRepo.findById(id); + Notification newnotification = notification.get(); + newnotification.setActive(false); + newnotification.setDelete(true); + String adminname = (String) session.getAttribute("usertype"); + newnotification.setUpdatedBy(adminname); + String date = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); + newnotification.setUpdatedDate(date); + notificationRepo.save(newnotification); + Integer loginid = (Integer) session.getAttribute("id"); + ApplicationLogs logs = new ApplicationLogs(); + logs.setComments("Action by " + adminname); + logs.setLoginId(loginid); + logs.setLogType("Detele Notification:-" + newnotification.getNotification_description()); + 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); + return ResponseEntity.ok("Notification with ID " + id + " deleted successfully."); + + } + @Operation( summary = "Retrieving the Discount Details REST API", description = "REST API to Retrieve the Discount Details for usertypes" @@ -527,30 +528,31 @@ public class AdminAPIController { //Retrieving the Discount Details @GetMapping("/getDiscountDetails") public Optional getDIscountDetails(@RequestParam("id") int id) { - Optional discountdetails =discountRangeRepo.findById(id); - return discountdetails; - } - + Optional discountdetails = discountRangeRepo.findById(id); + return discountdetails; + } + @Operation( summary = "Save Reasons REST API", description = "REST API to save the reasons" ) //saving the Reason @PostMapping("/saveReason") - public ResponseEntity saveReason(@RequestBody ReasonMaster reasaon){ + public ResponseEntity saveReason(@RequestBody ReasonMaster reasaon) { return ResponseEntity.ok(reasonMasterService.saveTheReason(reasaon)); } - + @Operation( summary = "All Reasons REST API", description = "REST API to retrie the allreasons" ) - //retrieving the allreasons + //retrieving the allreasons @GetMapping("/getReasons") @ResponseBody public List getAllReasons() { return reasonMasterService.getAllReasons(); } + @Operation( summary = "Reason Documents by reasonId REST API", description = "REST API to Get the ReasonDocuments By reasonId" @@ -600,7 +602,6 @@ public class AdminAPIController { } - @Operation( summary = " GCC Blocked Booking Details REST API", description = "REST API to get the GCC Blocked BookingDetails" @@ -611,26 +612,25 @@ public class AdminAPIController { @RequestParam("fromDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate fromDate, @RequestParam("toDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate toDate, @RequestParam("hallIds") List hallIds - ) { + ) { //System.out.println("Blocked Events Request - fromDate: " + fromDate + ", toDate: " + toDate + ", hallIds: " + hallIds ); List blockedBookings = bookingService.getBlockedEvents(fromDate, toDate, hallIds); - // List bookingDetails = bookingService.getByBookingId(fromDate,toDate,hallIds,blockingId,bookingId); + // List bookingDetails = bookingService.getByBookingId(fromDate,toDate,hallIds,blockingId,bookingId); if (blockedBookings.isEmpty()) { - // System.out.println("No blocked bookings found."); + // System.out.println("No blocked bookings found."); return ResponseEntity.ok(blockedBookings); } for (GccBlockingDate blockedBooking : blockedBookings) { - // System.out.println("Blocked Event: " + blockedBooking); + // System.out.println("Blocked Event: " + blockedBooking); } return ResponseEntity.ok(blockedBookings); } - @Operation( summary = "UNBLOCK the gcc Blocked Event REST API", description = "REST API to unblocking the Gcc blocked Events for blocking" @@ -650,17 +650,17 @@ public class AdminAPIController { // Get the booking IDs from the blocking date entity String bookingIds = blockingDate.getBookingIds(); String hallIds = blockingDate.getHallId(); - + // Convert the booking IDs to a list of integers List bookingIdList = Arrays.stream(bookingIds.split(",")) - .map(Integer::parseInt) - .collect(Collectors.toList()); + .map(Integer::parseInt) + .collect(Collectors.toList()); // Convert the hall IDs to a list of longs if provided List hallIdList = hallIds != null ? Arrays.stream(hallIds.split(",")) - .map(Long::parseLong) - .collect(Collectors.toList()) - : Collections.emptyList(); + .map(Long::parseLong) + .collect(Collectors.toList()) + : Collections.emptyList(); // Fetch the booking calendar entries within the date range List bookingCalendars = bookingService.getBookedslots(fromDate, endDate, hallIdList); @@ -675,7 +675,7 @@ public class AdminAPIController { bookingslots.setBookingId_2(null); bookingslots.setMorningSlot(false); bookingslots.setEveningSlot(false); - bookingslots.setIs_blocked(false); + bookingslots.setIs_blocked(false); bookingCalendarRepository.save(bookingslots); } @@ -694,20 +694,20 @@ public class AdminAPIController { } 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("Gcc UnBlocking for the Id:-"+blockingDate.getBlockingId()); - 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); + ApplicationLogs logs = new ApplicationLogs(); + logs.setComments("Action by " + adminname); + logs.setLoginId(loginid); + logs.setLogType("Gcc UnBlocking for the Id:-" + blockingDate.getBlockingId()); + 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); return ResponseEntity.ok("Success"); } // @GetMapping("/cancelByid") @@ -806,7 +806,7 @@ public class AdminAPIController { // // return ResponseEntity.ok("Success"); // } - + @Operation( summary = "HAll IMAGES by HallId REST API", description = "REST API to get the hall Images by Hall Id" @@ -816,7 +816,7 @@ public class AdminAPIController { public List getImageDetails(@RequestParam int hallId) { return hallService.getHallImages(hallId); } - + @Operation( summary = "GCC Blocking REST API", description = "REST API to Block the Halls by Admin" @@ -838,30 +838,30 @@ public class AdminAPIController { // Split and convert hall IDs List hallIdsList = Arrays.stream(hallID.split(",")) - .map(Long::parseLong) - .collect(Collectors.toList()); + .map(Long::parseLong) + .collect(Collectors.toList()); // Call the service with descriptions and documents bookingService.cancelAllBookings(fromDate, toDate, hallIdsList, reasonforblocking, selectedBookings, updatedBy, descriptions, documents); 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("Gcc Blocking for the Reason:-"+reasonforblocking); - 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); + ApplicationLogs logs = new ApplicationLogs(); + logs.setComments("Action by " + adminname); + logs.setLoginId(loginid); + logs.setLogType("Gcc Blocking for the Reason:-" + reasonforblocking); + 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); return ResponseEntity.ok("Success"); } - + // @PostMapping("/blockhall") // public ResponseEntity blockHall( // @RequestParam("blockingId") Integer blockingId, @@ -893,10 +893,10 @@ public class AdminAPIController { @GetMapping("/bookingdetailsByuserId") - public List getuserDetails(@RequestParam Integer userId) { - return bookingService.getAllBookingsByUserId(userId); + public List getuserDetails(@RequestParam Integer userId) { + return bookingService.getAllBookingsByUserId(userId); } - + @GetMapping("/settlement-approved") public ResponseEntity> getApprovedSettlements(HttpSession session) { List approvedSettlements = settlementRepository.findByBookingDetailsRefundStatus(RefundStatus.APPROVED); @@ -937,7 +937,7 @@ public class AdminAPIController { // } // } -// @GetMapping("/Gccblocking") + // @GetMapping("/Gccblocking") // public ResponseEntity> getGccBlockingEvents(@RequestParam("hallId") int hallId) { // System.out.println("Received hallId: " + hallId); // @@ -953,12 +953,13 @@ public class AdminAPIController { return ResponseEntity.ok(results); } + @GetMapping("/getblockedbookingdetails") public ResponseEntity>> viewBlockedHallsByHallIdAndReason( @RequestParam String hallIds, @RequestParam int blockingId) { - // System.out.println("Received hallIds: " + hallIds); + // System.out.println("Received hallIds: " + hallIds); //System.out.println("Received blockingId: " + blockingId); List hallIdList; @@ -990,7 +991,7 @@ public class AdminAPIController { if (hallDetailsOpt.isPresent()) { HallDetails hallDetails = hallDetailsOpt.get(); List bookingIds = bookingDetailsRepository.findBookingIdsByHallIdAndBookingDateBetween(hallId, startDate, endDate); - // System.out.println("Booking IDs for hallId " + hallId + ": " + bookingIds); // Add this line + // System.out.println("Booking IDs for hallId " + hallId + ": " + bookingIds); // Add this line Map hallInfo = new HashMap<>(); hallInfo.put("hallName", hallDetails.getHallName()); @@ -1006,7 +1007,7 @@ public class AdminAPIController { return ResponseEntity.ok(result); } - + @GetMapping("/getbookingdetails") public ResponseEntity> getBookingDetails(@RequestParam("bookingId") Long bookingId) { //System.out.println("Received bookingId: " + bookingId); @@ -1020,7 +1021,7 @@ public class AdminAPIController { } } - + @GetMapping("/blockedHallsByHallIdAndReason") @ResponseBody public Map viewBlockedHallsByHallIdAndReason( @@ -1096,12 +1097,12 @@ public class AdminAPIController { // Implement logic to calculate refund return 0.0; } - + //admin dashboard @GetMapping("/bookingstatistics") public ResponseEntity>> getBookingStatistics( - @RequestParam (required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate fromDate, - @RequestParam (required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate toDate, + @RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate fromDate, + @RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate toDate, @RequestParam(required = false, defaultValue = "ALL") String zone, @RequestParam(required = false, defaultValue = "ALL") String division, @RequestParam(required = false, defaultValue = "1000") Integer hallid, @@ -1115,13 +1116,12 @@ public class AdminAPIController { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(Collections.emptyMap()); } } - + @GetMapping("/getHallsDetailsByZone") - public ResponseEntity> getHallsDetailsByZone( @RequestParam String zone) - { - Map hallzones=hallDetailService.getHallsDetailsByZone(zone); + public ResponseEntity> getHallsDetailsByZone(@RequestParam String zone) { + Map hallzones = hallDetailService.getHallsDetailsByZone(zone); // Debug log to verify the response before sending it to the client - // System.out.println("Response from getHallsDetailsByZone: " + hallzones); + // System.out.println("Response from getHallsDetailsByZone: " + hallzones); return ResponseEntity.ok(hallzones); } @@ -1130,7 +1130,7 @@ public class AdminAPIController { List> bookingDetails = bookingService.getBookingDetailsByHallId(hallId); return ResponseEntity.ok(bookingDetails); } - + @PostMapping("/savenewHallImages") public ResponseEntity updateHallImages(@RequestParam("hallId") Integer hallId, @RequestParam("newHallImages") MultipartFile[] newHallImages) { @@ -1145,12 +1145,12 @@ public class AdminAPIController { // hallService.deleteHallImage(hallImageId); // return ResponseEntity.ok().build(); // } - + @PutMapping("/updateHallImage/{hallImageId}") public ResponseEntity> updateHallImage( @PathVariable Integer hallImageId, @RequestParam("hallImage") MultipartFile hallImage) throws IOException { - + try { String newImageUrl = hallService.updateHallImage(hallImageId, hallImage); Map response = new HashMap<>(); @@ -1162,6 +1162,7 @@ public class AdminAPIController { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(Collections.singletonMap("error", "Failed to update image")); } } + @DeleteMapping("/deleteHallImage/{hallImageId}") public ResponseEntity deleteHallImage(@PathVariable Integer hallImageId) { try { @@ -1172,11 +1173,13 @@ public class AdminAPIController { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error deleting image."); } } + @GetMapping("/bookingdetailsByzone") public ResponseEntity> getBookingDetailsByZone(@RequestParam String zone) { List bookingDetails = bookingDetailsRepository.findByZone(zone); return ResponseEntity.ok(bookingDetails); } + @GetMapping("/divisionsByZone") public List getDivisionsByZone(@RequestParam("zoneId") String zoneId) { // Use zoneId instead of zone @@ -1192,6 +1195,7 @@ public class AdminAPIController { } return new ResponseEntity<>(halls, HttpStatus.OK); } + @PostMapping("/manualrefund") public ResponseEntity manualRefund( @RequestParam int bookingId, @@ -1216,7 +1220,7 @@ public class AdminAPIController { return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Code is wrong"); } } - + //gccapps @GetMapping("/viewsettlement-pending") public ResponseEntity> viewSettlementPendingMaster(HttpSession session) { @@ -1232,9 +1236,9 @@ public class AdminAPIController { return ResponseEntity.ok(response); } - -@GetMapping("/viewsettlement-complete") + + @GetMapping("/viewsettlement-complete") public ResponseEntity> viewSettlementcompleteMaster(HttpSession session) { List completedlist = bookingDetailsRepository.findAllwithCompletedRefundStatus(); @@ -1249,7 +1253,7 @@ public class AdminAPIController { return ResponseEntity.ok(response); } - @GetMapping("/viewsettlement-approved") + @GetMapping("/viewsettlement-approved") public ResponseEntity> viewSettlementApprovedMaster(HttpSession session) { List approvedSettlements = bookingDetailsRepository.findAllWithApprovedRefundStatus(); @@ -1264,7 +1268,7 @@ public class AdminAPIController { return ResponseEntity.ok(response); } - + @GetMapping("/viewsettlement-reject") public ResponseEntity> viewSettlementRejectedMaster(HttpSession session) { @@ -1276,7 +1280,7 @@ public class AdminAPIController { return ResponseEntity.ok(response); } -@GetMapping("/viewsettlement-initiated") + @GetMapping("/viewsettlement-initiated") public ResponseEntity> viewSettlementInitiateMaster(HttpSession session) { List settlement = bookingDetailsRepository.findByBookingDetailsRefundStatus(); @@ -1291,213 +1295,214 @@ public class AdminAPIController { return ResponseEntity.ok(response); } -@GetMapping("/user-pending") - public ResponseEntity> viewApproval() { + @GetMapping("/user-pending") + public ResponseEntity> viewApproval() { List pendingList = userRepository.getPendingList(); return new ResponseEntity<>(pendingList, HttpStatus.OK); } - + @GetMapping("/user-approved") public ResponseEntity> viewUserApproved() { List approved = userRepository.getUserApproved(); return new ResponseEntity<>(approved, HttpStatus.OK); } - + @GetMapping("/user-reject") public ResponseEntity> viewUserReject() { List rejected = userRepository.getUserReject(); return new ResponseEntity<>(rejected, HttpStatus.OK); } - + @GetMapping("/halldetailslist") public ResponseEntity> getHallDetailsList() { List list = hallDetailsRepository.findAll(); return ResponseEntity.ok(list); } - + @GetMapping("/discountRange") public ResponseEntity> getAllDiscountRanges() { - List discount= discountRangeRepo.findAll(); - return ResponseEntity.ok(discount); + List discount = discountRangeRepo.findAll(); + return ResponseEntity.ok(discount); + } + + @PostMapping("/getReport") + public ResponseEntity> generateReport( + @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 = "userstatus", required = false) String userstatus, + @RequestParam(name = "usertype", required = false) String usertype, + @RequestParam(name = "bookingStatus", required = false) String bookingStatus, + @RequestParam(name = "refundStatus", required = false) String refundStatus, + @RequestParam(name = "bookingId", required = false) Long bookingId) { + + Map response = new HashMap<>(); + + List userList = handleUserRequest(request, fromDate, toDate, userstatus, usertype); + List bookingList = handleBookingRequest(request, fromDate, toDate, bookingStatus, bookingId); + List bookingSettlementList = handleBookingSettlementRequest(request, fromDate, toDate, refundStatus); + List paymentList = request.equals("3") ? bookingService.getAllPaymentsDetails(fromDate, toDate) : new ArrayList<>(); + List userbookingList = request.equals("4") ? bookingService.getBookingUserDetailsReport(fromDate, toDate) : new ArrayList<>(); + List hallbookingList = request.equals("5") ? bookingService.getBookingHallDetailsReport(fromDate, toDate) : new ArrayList<>(); + + response.put("users", userList); + response.put("bookings", bookingList); + response.put("fromdate", fromDate); + response.put("todate", toDate); + response.put("userstatus", userstatus); + response.put("bookingSettlementList", bookingSettlementList); + response.put("usertype", usertype); + response.put("bookingStatus", bookingStatus); + response.put("refundStatus", refundStatus); + response.put("request", request); + response.put("paymentLists", paymentList); + response.put("userbookingLists", userbookingList); + response.put("hallbookingLists", hallbookingList); + response.put("bookingId", bookingId); + + return new ResponseEntity<>(response, HttpStatus.OK); + } + + private List handleUserRequest(String request, String fromDate, String toDate, String userstatus, String usertype) { + if (!request.equals("1")) { + return new ArrayList<>(); + } + if ((userstatus != null && !userstatus.isEmpty()) && (usertype != null && !usertype.isEmpty())) { + return userService.getAllUsersWithFilters(fromDate, toDate, userstatus, usertype); + } + if (userstatus.isEmpty() && (usertype != null && !usertype.isEmpty())) { + return userService.getAllUsersWithTypeFilters(fromDate, toDate, usertype); + } + if (usertype.isEmpty() && (userstatus != null && !userstatus.isEmpty())) { + return userService.getAllUsersWithStatusFilters(fromDate, toDate, userstatus); + } + return userService.getAllUsers(fromDate, toDate); + } + + private List handleBookingRequest(String request, String fromDate, String toDate, String bookingStatus, Long bookingId) { + if (!request.equals("2")) { + return new ArrayList<>(); + } + if (bookingStatus != null && !bookingStatus.isEmpty()) { + return bookingDetailsRepo.getAllBookingDetailsWithStatus(fromDate, toDate, bookingStatus); + } else if (bookingId != null) { + return bookingDetailsRepo.getAllBookingDetailsWithBookingId(fromDate, toDate, bookingId); + } else { + return bookingDetailsRepo.getAllBookingDetails(fromDate, toDate); + } + } + + private List handleBookingSettlementRequest(String request, String fromDate, String toDate, String refundStatus) { + if (!request.equals("6")) { + return new ArrayList<>(); + } + if (refundStatus != null && !refundStatus.isEmpty()) { + return bookingDetailsRepository.getAllBookingsettlementDetailsWithStatus(fromDate, toDate, refundStatus); + } + return bookingDetailsRepository.getAllBookingsettlementDetails(fromDate, toDate); + } + + @GetMapping("/getHallDetailsById") + public ResponseEntity>> getHallDetailsById(@RequestParam Integer hall_id) { + List> halldetails = bookingService.getHallDetailsForOfficer(hall_id); + return ResponseEntity.ok(halldetails); + } + + + @GetMapping("/listgccblocking") + public ResponseEntity> getGccBlocking() { + + // 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 + } + } + + // Prepare the response data + Map response = new HashMap<>(); + response.put("gccblocked", uniqueGccBlockingDates); + response.put("hallCountMap", hallCountMap); + + return ResponseEntity.ok(response); + } + + @GetMapping("/details") + public ResponseEntity> getUserDetails( + @RequestParam("fromDate") String fromDate, + @RequestParam("toDate") String toDate) { + List userDetails = userRepository.findUserDetailsByBookingDate(fromDate, toDate); + return ResponseEntity.ok(userDetails); + } + + @GetMapping("/getPaymentswithRefunds") + public List getPaymentsWithRefunds(@RequestParam String startDate, @RequestParam String endDate) { + return userRepository.findPaymentsWithRefunds(startDate, endDate); + } + + @GetMapping("/getpaymentswithoutRefunds") + public List getPaymentsWithoutRefunds(@RequestParam String startDate, @RequestParam String endDate) { + return userRepository.findPaymentsWithoutRefunds(startDate, endDate); + } + + @GetMapping("/getRefundDetails") + public List getPaymentsWithRefundsOnly(@RequestParam String startDate, @RequestParam String endDate) { + return userRepository.findPaymentsWithRefundsOnly(startDate, endDate); + } + + @PostMapping("/send") + public ResponseEntity> sendMessage(@RequestBody Map messagePayload) { + String userMessage = messagePayload.get("message"); + + // Process the user message and prepare a response + String response = processMessage(userMessage); + + Map responseBody = new HashMap<>(); + responseBody.put("response", response); + + return ResponseEntity.ok(responseBody); + } + + private String processMessage(String userMessage) { + // Simple logic to return a response, could be more advanced (AI, NLP, etc.) + if (userMessage.toLowerCase().contains("hello")) { + return "Hello! How can I assist you today?"; + } else { + return "Thanks for your message! We will get back to you shortly."; + } + } + + @PostMapping("/uploadnoc") + public ResponseEntity uploadnoc(@RequestParam("nocFile") MultipartFile file, + @RequestParam("bookingid") int bookingId) { + try { + System.out.println("Received file: " + file.getOriginalFilename()); + System.out.println("Booking ID: " + bookingId); + + bookingService.uploadNOCFile(file, bookingId); + return ResponseEntity.ok("File uploaded and saved successfully"); + } catch (Exception e) { + System.err.println("Error during file upload: " + e.getMessage()); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("File upload failed: " + e.getMessage()); + } } - - @PostMapping("/getReport") - public ResponseEntity> generateReport( - @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 = "userstatus", required = false) String userstatus, - @RequestParam(name = "usertype", required = false) String usertype, - @RequestParam(name = "bookingStatus", required = false) String bookingStatus, - @RequestParam(name = "refundStatus", required = false) String refundStatus, - @RequestParam(name = "bookingId", required = false) Long bookingId){ - - Map response = new HashMap<>(); - - List userList = handleUserRequest(request, fromDate, toDate, userstatus, usertype); - List bookingList = handleBookingRequest(request, fromDate, toDate, bookingStatus, bookingId); - List bookingSettlementList = handleBookingSettlementRequest(request, fromDate, toDate, refundStatus); - List paymentList = request.equals("3") ? bookingService.getAllPaymentsDetails(fromDate, toDate) : new ArrayList<>(); - List userbookingList = request.equals("4") ? bookingService.getBookingUserDetailsReport(fromDate, toDate) : new ArrayList<>(); - List hallbookingList = request.equals("5") ? bookingService.getBookingHallDetailsReport(fromDate, toDate) : new ArrayList<>(); - - response.put("users", userList); - response.put("bookings", bookingList); - response.put("fromdate", fromDate); - response.put("todate", toDate); - response.put("userstatus", userstatus); - response.put("bookingSettlementList", bookingSettlementList); - response.put("usertype", usertype); - response.put("bookingStatus", bookingStatus); - response.put("refundStatus", refundStatus); - response.put("request", request); - response.put("paymentLists", paymentList); - response.put("userbookingLists", userbookingList); - response.put("hallbookingLists", hallbookingList); - response.put("bookingId", bookingId); - - return new ResponseEntity<>(response, HttpStatus.OK); - } - - private List handleUserRequest(String request, String fromDate, String toDate, String userstatus, String usertype) { - if (!request.equals("1")) { - return new ArrayList<>(); - } - if ((userstatus != null && !userstatus.isEmpty()) && (usertype != null && !usertype.isEmpty())) { - return userService.getAllUsersWithFilters(fromDate, toDate, userstatus, usertype); - } - if (userstatus.isEmpty() && (usertype != null && !usertype.isEmpty())) { - return userService.getAllUsersWithTypeFilters(fromDate, toDate, usertype); - } - if (usertype.isEmpty() && (userstatus != null && !userstatus.isEmpty())) { - return userService.getAllUsersWithStatusFilters(fromDate, toDate, userstatus); - } - return userService.getAllUsers(fromDate, toDate); - } - - private List handleBookingRequest(String request, String fromDate, String toDate, String bookingStatus, Long bookingId) { - if (!request.equals("2")) { - return new ArrayList<>(); - } - if (bookingStatus != null && !bookingStatus.isEmpty()) { - return bookingDetailsRepo.getAllBookingDetailsWithStatus(fromDate, toDate, bookingStatus); - } else if (bookingId != null){ - return bookingDetailsRepo.getAllBookingDetailsWithBookingId(fromDate, toDate, bookingId); - } else { - return bookingDetailsRepo.getAllBookingDetails(fromDate,toDate); - } - } - - private List handleBookingSettlementRequest(String request, String fromDate, String toDate, String refundStatus) { - if (!request.equals("6")) { - return new ArrayList<>(); - } - if (refundStatus != null && !refundStatus.isEmpty()) { - return bookingDetailsRepository.getAllBookingsettlementDetailsWithStatus(fromDate, toDate, refundStatus); - } - return bookingDetailsRepository.getAllBookingsettlementDetails(fromDate, toDate); - } - - @GetMapping("/getHallDetailsById") - public ResponseEntity>> getHallDetailsById(@RequestParam Integer hall_id) - { - List> halldetails=bookingService.getHallDetailsForOfficer(hall_id); - return ResponseEntity.ok(halldetails); - } - - - @GetMapping("/listgccblocking") - public ResponseEntity> getGccBlocking() { - - // 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 - } - } - - // Prepare the response data - Map response = new HashMap<>(); - response.put("gccblocked", uniqueGccBlockingDates); - response.put("hallCountMap", hallCountMap); - - return ResponseEntity.ok(response); - } - - @GetMapping("/details") - public ResponseEntity> getUserDetails( - @RequestParam("fromDate") String fromDate, - @RequestParam("toDate") String toDate) { - List userDetails = userRepository.findUserDetailsByBookingDate(fromDate, toDate); - return ResponseEntity.ok(userDetails); - } - @GetMapping("/getPaymentswithRefunds") - public List getPaymentsWithRefunds(@RequestParam String startDate, @RequestParam String endDate) { - return userRepository.findPaymentsWithRefunds(startDate, endDate); - } - - @GetMapping("/getpaymentswithoutRefunds") - public List getPaymentsWithoutRefunds(@RequestParam String startDate, @RequestParam String endDate) { - return userRepository.findPaymentsWithoutRefunds(startDate, endDate); - } - - @GetMapping("/getRefundDetails") - public List getPaymentsWithRefundsOnly(@RequestParam String startDate, @RequestParam String endDate) { - return userRepository.findPaymentsWithRefundsOnly(startDate, endDate); - } - @PostMapping("/send") - public ResponseEntity> sendMessage(@RequestBody Map messagePayload) { - String userMessage = messagePayload.get("message"); - - // Process the user message and prepare a response - String response = processMessage(userMessage); - - Map responseBody = new HashMap<>(); - responseBody.put("response", response); - - return ResponseEntity.ok(responseBody); - } - - private String processMessage(String userMessage) { - // Simple logic to return a response, could be more advanced (AI, NLP, etc.) - if (userMessage.toLowerCase().contains("hello")) { - return "Hello! How can I assist you today?"; - } else { - return "Thanks for your message! We will get back to you shortly."; - } - } - - @PostMapping("/uploadnoc") - public ResponseEntity uploadnoc(@RequestParam("nocFile") MultipartFile file, - @RequestParam("bookingid") int bookingId) { - try { - System.out.println("Received file: " + file.getOriginalFilename()); - System.out.println("Booking ID: " + bookingId); - - bookingService.uploadNOCFile(file, bookingId); - return ResponseEntity.ok("File uploaded and saved successfully"); - } catch (Exception e) { - System.err.println("Error during file upload: " + e.getMessage()); - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("File upload failed: " + e.getMessage()); - } - } } diff --git a/src/main/java/com/gcc/communityHall/controller/Admincontroller.java b/src/main/java/com/gcc/communityHall/controller/Admincontroller.java index 699d1ed3..a004d4a1 100644 --- a/src/main/java/com/gcc/communityHall/controller/Admincontroller.java +++ b/src/main/java/com/gcc/communityHall/controller/Admincontroller.java @@ -564,9 +564,11 @@ public class Admincontroller { @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 = "hall1", required = false) Integer hallid, @RequestParam(name = "basedon", required = false) String basedon, - @RequestParam(name = "bookingId", required = false) Long bookingId, HttpSession session) throws JsonProcessingException { + @RequestParam(name = "bookingId", required = false) Long bookingId, + @RequestParam(name = "reporttype", required = false) String reporttype, + @RequestParam(name = "counterId", required = false) String counterId, HttpSession session) throws JsonProcessingException { String adminname = (String) session.getAttribute("usertype"); if (adminname != null) { long mobileno = (long) session.getAttribute("mobileno"); @@ -621,19 +623,31 @@ public class Admincontroller { model.addAttribute("totalBookings", totalBookings); List hallbookingList = handleBookingHallDetailsReportRequest(request, fromDate, toDate, filterby, zone, division, hallid); - List counterBookingList = request.equals("9") ? bookingService.getCounterWiseBookingCount(fromDate, toDate) : new ArrayList<>(); - model.addAttribute("counterBookingList",counterBookingList); - System.out.println("counterBookingList.."+counterBookingList); + if ("9".equals(request)) { + if("abstract".equals(reporttype)){ + List counterBookingList = new ArrayList<>(); + counterBookingList = bookingService.getCounterWiseBookingCount(fromDate, toDate); + model.addAttribute("counterBookingList", counterBookingList); + System.out.println("counterBookingList.." + counterBookingList); - List hallBookingByCounter = bookingService.getHallWiseBookingDetails(fromDate, toDate); - // Convert to JSON for JS usage - String hallBookingJson = new ObjectMapper().writeValueAsString(hallBookingByCounter); - model.addAttribute("hallBookingJson", hallBookingJson); + List hallBookingByCounter = bookingService.getHallWiseBookingDetails(fromDate, toDate, counterId); + // Convert to JSON for JS usage + String hallBookingJson = new ObjectMapper().writeValueAsString(hallBookingByCounter); + model.addAttribute("hallBookingJson", hallBookingJson); - List hallBookingDetails = bookingService.getBookingDetailsForAllHalls(fromDate, toDate); - String hallBookingDetailsJson = new ObjectMapper().writeValueAsString(hallBookingDetails); - model.addAttribute("hallBookingDetailsJson", hallBookingDetailsJson); + List hallBookingDetails = bookingService.getBookingDetailsForAllHalls(fromDate, toDate, counterId, hallid); + String hallBookingDetailsJson = new ObjectMapper().writeValueAsString(hallBookingDetails); + model.addAttribute("hallBookingDetailsJson", hallBookingDetailsJson); + + } else { + List counterBookingList = new ArrayList<>(); + counterBookingList = bookingService.getCounterWiseBookingDetails(fromDate, toDate); + model.addAttribute("counterBookingList", counterBookingList); + } + + model.addAttribute("reporttype", reporttype); + } model.addAttribute("filterby", filterby); model.addAttribute("users", userList); diff --git a/src/main/java/com/gcc/communityHall/controller/HeadquartersController.java b/src/main/java/com/gcc/communityHall/controller/HeadquartersController.java index 8a1615a1..eeb9a12f 100644 --- a/src/main/java/com/gcc/communityHall/controller/HeadquartersController.java +++ b/src/main/java/com/gcc/communityHall/controller/HeadquartersController.java @@ -1,9 +1,12 @@ package com.gcc.communityHall.controller; + import java.util.*; import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collectors; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import com.gcc.communityHall.entity.GccBlockingDate; import com.gcc.communityHall.others.AppConfig; import com.gcc.communityHall.repository.GccBlockingDateRepository; @@ -60,7 +63,7 @@ public class HeadquartersController { Model model, HttpSession session) { String headquartersname = (String) session.getAttribute("usertype"); - if(headquartersname != null) { + if (headquartersname != null) { long mobileno = (long) session.getAttribute("mobileno"); model.addAttribute("mobileno", mobileno); List> getMonthCount = bookingDetailsRepository.getAllAdminmonthcount(zone); @@ -87,86 +90,85 @@ public class HeadquartersController { @GetMapping("/Reports") - public String viewReports(Model model,HttpSession session) - { + public String viewReports(Model model, HttpSession session) { String headquartersname = (String) session.getAttribute("usertype"); - if(headquartersname != null) { + if (headquartersname != null) { long mobileno = (long) session.getAttribute("mobileno"); model.addAttribute("mobileno", mobileno); - model.addAttribute("headquartersname",headquartersname); + model.addAttribute("headquartersname", headquartersname); return "headquarters/reports"; - }else { + } else { session.invalidate(); // Invalidate the session to clear all session attributes return "redirect:/communityhall/login"; } } @GetMapping("/getReport") - public String getReports(Model model,HttpSession session) - { + public String getReports(Model model, HttpSession session) { String headquartersname = (String) session.getAttribute("usertype"); - if(headquartersname != null) { + if (headquartersname != null) { long mobileno = (long) session.getAttribute("mobileno"); model.addAttribute("mobileno", mobileno); - model.addAttribute("headquartersname",headquartersname); + model.addAttribute("headquartersname", headquartersname); return "headquarters/reports"; - }else { + } else { session.invalidate(); // Invalidate the session to clear all session attributes return "redirect:/communityhall/login"; } } + @GetMapping("/approval-history") - public String viewApproval(Model model,HttpSession session) { + public String viewApproval(Model model, HttpSession session) { String headquartersname = (String) session.getAttribute("usertype"); - if(headquartersname != null) { + if (headquartersname != null) { long mobileno = (long) session.getAttribute("mobileno"); model.addAttribute("mobileno", mobileno); model.addAttribute("headquartersname", headquartersname); model.addAttribute("title", "approvalcontrol"); - List Pending=usersRepository.getPendingList(); + List Pending = usersRepository.getPendingList(); String zone = (String) session.getAttribute("zone"); model.addAttribute("zone", zone); - model.addAttribute("pendinglist",Pending); + model.addAttribute("pendinglist", Pending); return "headquarters/approval-history"; - }else { + } 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){ + public String viewUserApproved(Model model, HttpSession session) { String headquartersname = (String) session.getAttribute("usertype"); - if(headquartersname != null) { + if (headquartersname != null) { long mobileno = (long) session.getAttribute("mobileno"); model.addAttribute("mobileno", mobileno); model.addAttribute("headquartersname", headquartersname); - model.addAttribute("title","reasondetails"); - List approved= usersRepository.getUserApproved(); + model.addAttribute("title", "reasondetails"); + List approved = usersRepository.getUserApproved(); String zone = (String) session.getAttribute("zone"); model.addAttribute("zone", zone); - model.addAttribute("approvedlist",approved); + model.addAttribute("approvedlist", approved); return "headquarters/user-approved"; - }else { + } 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){ + public String viewUserReject(Model model, HttpSession session) { String headquartersname = (String) session.getAttribute("usertype"); - if(headquartersname != null) { + if (headquartersname != null) { long mobileno = (long) session.getAttribute("mobileno"); model.addAttribute("mobileno", mobileno); model.addAttribute("headquartersname", headquartersname); - model.addAttribute("title","reasondetails"); - List reject= usersRepository.getUserReject(); + model.addAttribute("title", "reasondetails"); + List reject = usersRepository.getUserReject(); String zone = (String) session.getAttribute("zone"); model.addAttribute("zone", zone); - model.addAttribute("rejectedlist",reject); + model.addAttribute("rejectedlist", reject); return "headquarters/user-reject"; - }else { + } else { session.invalidate(); // Invalidate the session to clear all session attributes return "redirect:/communityhall/login"; } @@ -183,118 +185,140 @@ public class HeadquartersController { @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) Integer hallid, @RequestParam(name = "basedon", required = false) String basedon, - @RequestParam(name = "bookingId", required = false) Long bookingId,HttpSession session) { - String headquartersname = (String) session.getAttribute("usertype"); - if(headquartersname != 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, + @RequestParam(name = "reporttype", required = false) String reporttype, + @RequestParam(name = "counterId", required = false) String counterId, HttpSession session) throws JsonProcessingException { + String headquartersname = (String) session.getAttribute("usertype"); + if (headquartersname != 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); - 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("headquartersname", headquartersname); - - return "headquarters/reports"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes - return "redirect:/communityhall/login"; - } + if ("9".equals(request)) { + if("abstract".equals(reporttype)){ + List counterBookingList = new ArrayList<>(); + counterBookingList = bookingService.getCounterWiseBookingCount(fromDate, toDate); + model.addAttribute("counterBookingList", counterBookingList); + System.out.println("counterBookingList.." + counterBookingList); + + List hallBookingByCounter = bookingService.getHallWiseBookingDetails(fromDate, toDate, counterId); + // Convert to JSON for JS usage + String hallBookingJson = new ObjectMapper().writeValueAsString(hallBookingByCounter); + model.addAttribute("hallBookingJson", hallBookingJson); + + + List hallBookingDetails = bookingService.getBookingDetailsForAllHalls(fromDate, toDate, counterId, hallid); + String hallBookingDetailsJson = new ObjectMapper().writeValueAsString(hallBookingDetails); + model.addAttribute("hallBookingDetailsJson", hallBookingDetailsJson); + + } else { + List counterBookingList = new ArrayList<>(); + counterBookingList = bookingService.getCounterWiseBookingDetails(fromDate, toDate); + model.addAttribute("counterBookingList", counterBookingList); + } + model.addAttribute("reporttype", reporttype); + } + + 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("headquartersname", headquartersname); + + return "headquarters/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 ("2".equals(filterby)) - { - - return bookingService.getBookingHallDetailsReportByEventDate(fromDate, toDate,zone,division,hallid); - - } - - 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 ("2".equals(filterby)) { + + return bookingService.getBookingHallDetailsReportByEventDate(fromDate, toDate, zone, division, hallid); + + } + + return new ArrayList<>(); } private List handleUserRequest(String request, String fromDate, String toDate, String userstatus, String usertype) { @@ -313,282 +337,260 @@ public class HeadquartersController { 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(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 && 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); - } - - } - } - // Handle default or error case - return new ArrayList<>(); + 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.getAllBookingDetailsWithBookingIdwithbookingStatus(fromDate, toDate, bookingId, bookingStatus); + } + 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); + } + + } + } + // 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.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); - } - - } - } - - // Handle default or error case + if (filterby.isEmpty() && refundStatus.isEmpty()) { + return bookingService.getAllBookingsettlementDetailsByBookingDate(fromDate, toDate); + } + 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); + } + + } + } + + // Handle default or error case return new ArrayList<>(); } + @GetMapping("/ongoingevents") - public String viewRecentevents(Model model,HttpSession session) { + public String viewRecentevents(Model model, HttpSession session) { String headquartersname = (String) session.getAttribute("usertype"); - if(headquartersname != null) { + if (headquartersname != 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"); + List presenteventslist = bookingDetailsRepository.findPresentBookingList(); + List pasteventslist = bookingDetailsRepository.findPastEventsList(); + List futureeventslist = bookingDetailsRepository.findFutureEventsList(); + model.addAttribute("title", "settlement initiate"); model.addAttribute("headquartersname", headquartersname); - model.addAttribute("presenteventslist",presenteventslist); - model.addAttribute("pasteventslist",pasteventslist); - model.addAttribute("futureeventslist",futureeventslist); + model.addAttribute("presenteventslist", presenteventslist); + model.addAttribute("pasteventslist", pasteventslist); + model.addAttribute("futureeventslist", futureeventslist); return "headquarters/ongoingevents"; - }else { + } 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 headquartersname = (String) session.getAttribute("usertype"); - if(headquartersname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - model.addAttribute("headquartersname", headquartersname); - List bookingList = bookingDetailsRepository.getAllApprovedList(); - model.addAttribute("bookingList", bookingList); - return "headquarters/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 headquartersname = (String) session.getAttribute("usertype"); + if (headquartersname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + model.addAttribute("headquartersname", headquartersname); + List bookingList = bookingDetailsRepository.getAllApprovedList(); + model.addAttribute("bookingList", bookingList); + return "headquarters/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 headquartersname = (String) session.getAttribute("usertype"); - if(headquartersname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - model.addAttribute("headquartersname", headquartersname); - List rejectedBookings = bookingDetailsRepository.getAllRejectingList(); - model.addAttribute("rejectedBookings", rejectedBookings); - - return "headquarters/rejected-list"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes + public String viewRejectedBookings(Model model, HttpSession session) { + String headquartersname = (String) session.getAttribute("usertype"); + if (headquartersname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + model.addAttribute("headquartersname", headquartersname); + List rejectedBookings = bookingDetailsRepository.getAllRejectingList(); + model.addAttribute("rejectedBookings", rejectedBookings); + + return "headquarters/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 headquartersname = (String) session.getAttribute("usertype"); - if(headquartersname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - model.addAttribute("headquartersname", headquartersname); - List waitingBookings = bookingDetailsRepository.getAllwaitingList(); - model.addAttribute("waitingBookings", waitingBookings); - - return "headquarters/bookingwaiting"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes + public String viewWaitingBookings(Model model, HttpSession session) { + String headquartersname = (String) session.getAttribute("usertype"); + if (headquartersname != null) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + model.addAttribute("headquartersname", headquartersname); + List waitingBookings = bookingDetailsRepository.getAllwaitingList(); + model.addAttribute("waitingBookings", waitingBookings); + + return "headquarters/bookingwaiting"; + } 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 headquartersname = (String) session.getAttribute("usertype"); - if(headquartersname != null) { - long mobileno = (long) session.getAttribute("mobileno"); - model.addAttribute("mobileno", mobileno); - List approvedSettlements = bookingDetailsRepository.findAllWithApprovedRefundStatus(); + if (headquartersname != 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("headquartersname", headquartersname); - model.addAttribute("settlementlist", settlements); - model.addAttribute("approvedcancelledbookings",approvedcancelledbookings); - model.addAttribute("approvedrejectedbookings",approvedrejectedbookings); - return "headquarters/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("headquartersname", headquartersname); + model.addAttribute("settlementlist", settlements); + model.addAttribute("approvedcancelledbookings", approvedcancelledbookings); + model.addAttribute("approvedrejectedbookings", approvedrejectedbookings); + return "headquarters/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 headquartersname = (String) session.getAttribute("usertype"); - if(headquartersname != 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("headquartersname", headquartersname); - model.addAttribute("settlementlist",settlement); - model.addAttribute("Initiatedcancelledbookings",Initiatedcancelledbookings); - model.addAttribute("Initiatedrejectedbookings",Initiatedrejectedbookings); - return "headquarters/settlement-initiate"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes + public String viewSettlementInitiatedMaster(Model model, HttpSession session) { + String headquartersname = (String) session.getAttribute("usertype"); + if (headquartersname != 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("headquartersname", headquartersname); + model.addAttribute("settlementlist", settlement); + model.addAttribute("Initiatedcancelledbookings", Initiatedcancelledbookings); + model.addAttribute("Initiatedrejectedbookings", Initiatedrejectedbookings); + return "headquarters/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 headquartersname = (String) session.getAttribute("usertype"); - if(headquartersname!=null) { - model.addAttribute("headquartersname", headquartersname); - 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 "headquarters/settlement-list"; - }else { - session.invalidate(); - return "redirect:/communityhall/login"; - } -} - + public String settlementPendingList(Model model, HttpSession session) { + String headquartersname = (String) session.getAttribute("usertype"); + if (headquartersname != null) { + model.addAttribute("headquartersname", headquartersname); + 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 "headquarters/settlement-list"; + } else { + session.invalidate(); + return "redirect:/communityhall/login"; + } + } + @GetMapping("/refundfailed-list") -public String RefundFailedList(Model model,HttpSession session) { - String headquartersname = (String) session.getAttribute("usertype"); - if(headquartersname!=null) { - model.addAttribute("headquartersname", headquartersname); - 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 "headquarters/refund-failedlist"; -} -else { - session.invalidate(); - return "redirect:/communityhall/login"; -} -} + public String RefundFailedList(Model model, HttpSession session) { + String headquartersname = (String) session.getAttribute("usertype"); + if (headquartersname != null) { + model.addAttribute("headquartersname", headquartersname); + 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 "headquarters/refund-failedlist"; + } else { + session.invalidate(); + return "redirect:/communityhall/login"; + } + } + @GetMapping("/settlement-completedlist") - public String viewSettlementcompletedMaster(Model model,HttpSession session) { - String headquartersname = (String) session.getAttribute("usertype"); - if(headquartersname != 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("headquartersname", headquartersname); - model.addAttribute("completedlist",completedlist); - model.addAttribute("cancelledcompletedlist",cancelledcompletedlist); - model.addAttribute("rejectedcompletedlist",rejectedcompletedlist); - return "headquarters/settlement-completed"; - }else { - session.invalidate(); // Invalidate the session to clear all session attributes + public String viewSettlementcompletedMaster(Model model, HttpSession session) { + String headquartersname = (String) session.getAttribute("usertype"); + if (headquartersname != 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("headquartersname", headquartersname); + model.addAttribute("completedlist", completedlist); + model.addAttribute("cancelledcompletedlist", cancelledcompletedlist); + model.addAttribute("rejectedcompletedlist", rejectedcompletedlist); + return "headquarters/settlement-completed"; + } else { + session.invalidate(); // Invalidate the session to clear all session attributes return "redirect:/communityhall/login"; - } + } } @GetMapping("/settlementlist") @@ -606,18 +608,18 @@ else { } @GetMapping("/headquarterspage") - public String viewcaretaker(Model model,HttpSession session,@RequestParam("bookingId") int bookingId) { + public String viewcaretaker(Model model, HttpSession session, @RequestParam("bookingId") int bookingId) { String caretakerName = (String) session.getAttribute("usertype"); - if(caretakerName!=null) { + if (caretakerName != null) { long mobileno = (long) session.getAttribute("mobileno"); model.addAttribute("mobileno", mobileno); model.addAttribute("caretakerName", caretakerName); - model.addAttribute("title","caretaker"); + model.addAttribute("title", "caretaker"); model.addAttribute("baseURL", appConfig.getBaseUrl()); BookingDetails booking = bookingService.getBookingsById(bookingId); - model.addAttribute("booking",booking); + model.addAttribute("booking", booking); return "headquarters/headquarterspage"; - }else { + } else { session.invalidate(); return "redirect:/communityhall/login"; } @@ -639,7 +641,7 @@ else { } @GetMapping("/logout") - public String viewLogout(Model model,HttpSession session) { + public String viewLogout(Model model, HttpSession session) { session.invalidate(); return "redirect:/communityhall/login"; } @@ -647,7 +649,7 @@ else { @GetMapping("/Gccblocking") public String viewGccBlocking(Model model, HttpSession session) { String headquartersname = (String) session.getAttribute("usertype"); - if(headquartersname != null) { + if (headquartersname != null) { long mobileno = (long) session.getAttribute("mobileno"); model.addAttribute("mobileno", mobileno); model.addAttribute("headquartersname", headquartersname); @@ -682,7 +684,7 @@ else { model.addAttribute("hallCountMap", hallCountMap); return "headquarters/gccblocking"; - }else { + } else { session.invalidate(); // Invalidate the session to clear all session attributes return "redirect:/communityhall/login"; } diff --git a/src/main/java/com/gcc/communityHall/repository/BookingDetailsRepository.java b/src/main/java/com/gcc/communityHall/repository/BookingDetailsRepository.java index e89b74f6..567f8735 100644 --- a/src/main/java/com/gcc/communityHall/repository/BookingDetailsRepository.java +++ b/src/main/java/com/gcc/communityHall/repository/BookingDetailsRepository.java @@ -1434,14 +1434,20 @@ public interface BookingDetailsRepository extends JpaRepository getAllwaitingNOC(); - @Query(value = "SELECT bd.counter_id, COUNT(*) AS total_count " + - "FROM booking_details bd " + - "WHERE DATE(bd.booking_date) BETWEEN :fromDate AND :toDate " + - "AND bd.counter_id IS NOT NULL " + - "GROUP BY bd.counter_id", nativeQuery = true) - List getCounterWiseBookingCount(@Param("fromDate") String fromDate, @Param("toDate") String toDate); + @Query(value = + "SELECT bd.counter_id, COUNT(*) AS total_count " + + "FROM booking_details bd " + + "WHERE DATE(bd.booking_date) BETWEEN :fromDate AND :toDate " + + "AND bd.booking_status <> 'PENDING' " + + "AND bd.counter_id IS NOT NULL " + + "GROUP BY bd.counter_id", + nativeQuery = true) + List getCounterWiseBookingCount( + @Param("fromDate") String fromDate, + @Param("toDate") String toDate + ); - @Query(value = "SELECT bd.counter_id, h.zone, h. division, h.hall_name, COUNT(*) as total_bookings " + + /*@Query(value = "SELECT bd.counter_id, h.zone, h. division, h.hall_name, COUNT(*) as total_bookings " + "FROM booking_details bd " + "JOIN hall_details h ON h.hall_id = bd.hall_details_hall_id " + "WHERE DATE(bd.booking_date) BETWEEN :fromDate AND :toDate " + @@ -1457,6 +1463,48 @@ public interface BookingDetailsRepository extends JpaRepository getBookingDetailsForAllHalls(@Param("fromDate") String fromDate, @Param("toDate") String toDate); + List getBookingDetailsForAllHalls(@Param("fromDate") String fromDate, @Param("toDate") String toDate);*/ + + @Query(value = + "SELECT bd.counter_id, h.zone, h.division, h.hall_name, COUNT(*) AS total_bookings " + + "FROM booking_details bd " + + "JOIN hall_details h ON h.hall_id = bd.hall_details_hall_id " + + "WHERE DATE(bd.booking_date) BETWEEN :fromDate AND :toDate " + + "AND bd.counter_id IS NOT NULL " + + "AND bd.booking_status <> 'PENDING' " + + "AND (:counterId IS NULL OR bd.counter_id = :counterId) " + + "GROUP BY bd.counter_id, h.zone, h.division, h.hall_name", + nativeQuery = true) + List getHallWiseBookingDetails( + @Param("fromDate") String fromDate, + @Param("toDate") String toDate, + @Param("counterId") String counterId + ); + @Query(value = " SELECT bd.booking_id, h.hall_name, bd.booking_date, bd.start_date, " + + "bd.end_date, bd.starting_slot, bd.ending_slot, bd.no_of_days, bd.reason, " + + "bd.amount_received, bd.hall_amount, bd.deposit_amount, bd.gst, bd.booking_status, " + + "bd.booking_type FROM booking_details bd " + + "JOIN hall_details h ON h.hall_id = bd.hall_details_hall_id " + + "WHERE DATE(bd.booking_date) BETWEEN :fromDate AND :toDate " + + "AND bd.counter_id IS NOT NULL " + + "AND ( :counterId IS NULL OR bd.counter_id = :counterId ) " + + "AND ( :hallid IS NULL OR bd.hall_details_hall_id = :hallid ) " + + "AND bd.booking_status <> 'PENDING' ", nativeQuery = true) + List getBookingDetailsForAllHalls( + @Param("fromDate") String fromDate, + @Param("toDate") String toDate, + @Param("counterId") String counterId, + @Param("hallid") Integer hallid + ); + + @Query(value = " SELECT bd.booking_id, h.hall_name, bd.booking_date, bd.start_date, " + + "bd.end_date, bd.starting_slot, bd.ending_slot, bd.no_of_days, bd.reason, " + + "bd.amount_received, bd.hall_amount, bd.deposit_amount, bd.gst, bd.booking_status, " + + "bd.booking_type, bd.counter_id FROM booking_details bd " + + "JOIN hall_details h ON h.hall_id = bd.hall_details_hall_id " + + "WHERE DATE(bd.booking_date) BETWEEN :fromDate AND :toDate " + + "AND bd.counter_id IS NOT NULL " + + "AND bd.booking_status <> 'PENDING' GROUP BY bd.counter_id, bd.booking_id ", nativeQuery = true) + List getCounterWiseBookingDetails(String fromDate, String toDate); } diff --git a/src/main/java/com/gcc/communityHall/service/BookingService.java b/src/main/java/com/gcc/communityHall/service/BookingService.java index c236e4d6..0ff5a630 100644 --- a/src/main/java/com/gcc/communityHall/service/BookingService.java +++ b/src/main/java/com/gcc/communityHall/service/BookingService.java @@ -207,8 +207,9 @@ public interface BookingService { List getCounterWiseBookingCount(String fromDate, String toDate); - List getHallWiseBookingDetails(String fromDate, String toDate); + List getHallWiseBookingDetails(String fromDate, String toDate, String CounterId); - List getBookingDetailsForAllHalls(String fromDate, String toDate); + List getBookingDetailsForAllHalls(String fromDate, String toDate, String CounterId, Integer hallid); + List getCounterWiseBookingDetails(String fromDate, String toDate); } 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 51e24f66..fd10fb6b 100644 --- a/src/main/java/com/gcc/communityHall/service/Impl/BookingServiceImpl.java +++ b/src/main/java/com/gcc/communityHall/service/Impl/BookingServiceImpl.java @@ -2453,7 +2453,7 @@ public class BookingServiceImpl implements BookingService { return bookingDetailsRepository.getCounterWiseBookingCount(fromDate, toDate); } - @Override + /*@Override public List getHallWiseBookingDetails(String fromDate, String toDate) { return bookingDetailsRepository.getHallWiseBookingDetails(fromDate, toDate); } @@ -2461,6 +2461,21 @@ public class BookingServiceImpl implements BookingService { @Override public List getBookingDetailsForAllHalls(String fromDate, String toDate){ return bookingDetailsRepository.getBookingDetailsForAllHalls(fromDate,toDate); + }*/ + + @Override + public List getHallWiseBookingDetails(String fromDate, String toDate, String counterId) { + return bookingDetailsRepository.getHallWiseBookingDetails(fromDate, toDate,counterId); + } + + @Override + public List getBookingDetailsForAllHalls(String fromDate, String toDate, String counterId,Integer hallid){ + return bookingDetailsRepository.getBookingDetailsForAllHalls(fromDate,toDate,counterId,hallid); + } + + @Override + public List getCounterWiseBookingDetails(String fromDate, String toDate){ + return bookingDetailsRepository.getCounterWiseBookingDetails(fromDate,toDate); } } diff --git a/src/main/resources/templates/admin/reports.html b/src/main/resources/templates/admin/reports.html index 71e8aa28..0344c91c 100644 --- a/src/main/resources/templates/admin/reports.html +++ b/src/main/resources/templates/admin/reports.html @@ -131,7 +131,7 @@ + +

@@ -620,33 +634,89 @@
- - - - - - - - - - - - - - - -
S.NoCounter IDTotal Bookings
- -
+
+ + + + + + + + + + + + + + + +
S.NoCounter IDTotal Bookings
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
S.NoBooking IDHall NameBooking DateStart DateEnd DateStarting SlotEnding SlotNo.of.DaysReason for BookingHall AmountDeposit AmountGStAmount ReceivedBooking StatusBooking TypeCounter IdView
+

+ View +

+
+
@@ -1487,6 +1557,9 @@ } else if (tableId === 'hallDetailsTable') { orientation = 'landscape'; pageSize = 'A3'; + } else if (tableId === 'detailedrequestTable') { + orientation = 'landscape'; + pageSize = 'A3'; } return [{ @@ -1538,7 +1611,7 @@ }); // Tables with custom PDF buttons - ['requestTable9', 'modalBookingTable', 'hallDetailsTable'].forEach(function (tableId) { + ['requestTable9', 'modalBookingTable', 'hallDetailsTable', 'detailedrequestTable'].forEach(function (tableId) { $('#' + tableId).DataTable({ dom: 'Bftip', columnDefs: [{ @@ -1610,7 +1683,7 @@ checkTodateCon(); }); - function checkTodateCon(){ + function checkTodateCon() { var today = new Date(); var sixMonthsLater = new Date(); sixMonthsLater.setMonth(today.getMonth() + 6); @@ -1632,36 +1705,13 @@ } - // document.addEventListener("DOMContentLoaded", function () { - // const form = document.getElementById('myForm'); // Change selector if needed - // var requestValue = document.getElementById("request").value; - // if(requestValue ==="7"){ - // console.log("inside 7"); - // const basedonSelect = document.getElementById('basedon'); - // const errorSpan = document.getElementById('basedonError'); - // - // form.addEventListener("submit", function (event) { - // console.log("basedonSelect.value====="+basedonSelect.value); - // if (basedonSelect.value === "") { - // event.preventDefault(); // Stop form submission - // errorSpan.textContent = "Please select a value."; - // basedonSelect.classList.add("is-invalid"); // Optional: Bootstrap styling - // } - // else { - // errorSpan.textContent = ""; - // basedonSelect.classList.remove("is-invalid"); - // } - // }); - // } - // - // }); - - document.addEventListener("DOMContentLoaded", function () { const form = document.getElementById('myForm'); const basedonSelect = document.getElementById('basedon'); const errorSpan = document.getElementById('basedonError'); const request = document.getElementById('request'); + const reportTypeSelect = document.getElementById('reporttype'); + const reportTypeerror = document.getElementById('reportTypeError'); form.addEventListener("submit", function (event) { const requestValue = request.value; @@ -1678,6 +1728,18 @@ errorSpan.textContent = ""; basedonSelect.classList.remove("is-invalid"); } + } else if (requestValue === "9") { + console.log("inside 9"); + console.log("reportTypeSelect.value=====" + reportTypeSelect.value); + + if (reportTypeSelect.value === "") { + event.preventDefault(); // Stop form submission + reportTypeerror.textContent = "Please select a value."; + reportTypeSelect.classList.add("is-invalid"); + } else { + reportTypeerror.textContent = ""; + reportTypeSelect.classList.remove("is-invalid"); + } } }); @@ -1685,10 +1747,13 @@ this.classList.remove("is-invalid"); document.getElementById("basedonError").textContent = ""; }); + document.getElementById("reporttype").addEventListener("change", function () { + this.classList.remove("is-invalid"); + document.getElementById("reportTypeError").textContent = ""; + }); }); - // Function to manage the display of dropdowns based on the request type function myRequest() { var requestValue = document.getElementById("request").value; @@ -1705,6 +1770,7 @@ document.getElementById("hallContainer").style.display = "none"; document.getElementById("bookingcountbasedonDropdown").style.display = "none"; document.getElementById("paymentInfoDropdown1").style.display = "none"; + document.getElementById("counterreportDropdown").style.display = "none"; // Reset dropdown values @@ -1760,6 +1826,8 @@ document.getElementById("divisionContainer").style.display = "block"; document.getElementById("hallContainer").style.display = "block"; document.getElementById("paymentInfoDropdown1").style.display = "block"; + } else if (requestValue === "9") { + document.getElementById("counterreportDropdown").style.display = "block"; } } @@ -1771,6 +1839,13 @@ }); }); + document.addEventListener("DOMContentLoaded", function () { + document.getElementById("reporttype").addEventListener("change", function () { + const selectedValue = this.value; + document.getElementById("counterreportDropdown").style.display = selectedValue ? "block" : "none"; + }); + }); + // Function to reset date fields function resetDate() { diff --git a/src/main/resources/templates/headquarters/reports.html b/src/main/resources/templates/headquarters/reports.html index ef3bf42b..03795bdb 100644 --- a/src/main/resources/templates/headquarters/reports.html +++ b/src/main/resources/templates/headquarters/reports.html @@ -6,1210 +6,1564 @@ - -