Browse Source

Sir p t hall restriction and community hall center list has been changed

master
kanimozhi 7 months ago
parent
commit
9acae63c76
  1. 21
      .classpath
  2. 6
      .gitignore
  3. 2
      jwtToken.txt
  4. 326
      src/main/java/com/gcc/communityHall/controller/AdminAPIController.java
  5. 140
      src/main/java/com/gcc/communityHall/controller/OfficerController.java
  6. 692
      src/main/java/com/gcc/communityHall/controller/UserAPIController.java
  7. 47
      src/main/java/com/gcc/communityHall/controller/UserController.java
  8. 22
      src/main/java/com/gcc/communityHall/dto/EmployeeDetails.java
  9. 25
      src/main/java/com/gcc/communityHall/entity/HallDetails.java
  10. 68
      src/main/java/com/gcc/communityHall/entity/HallReasonRestriction.java
  11. 2
      src/main/java/com/gcc/communityHall/paymentService/scheduler/PaymentStatusScheduler.java
  12. 21
      src/main/java/com/gcc/communityHall/repository/HallDetailsRepository.java
  13. 19
      src/main/java/com/gcc/communityHall/repository/HallReasonRestrictionRepository.java
  14. 1078
      src/main/java/com/gcc/communityHall/service/Impl/BookingServiceImpl.java
  15. 46
      src/main/java/com/gcc/communityHall/service/Impl/CounterServiceImpl.java
  16. 47
      src/main/resources/templates/admin/gccblocking.html
  17. 106
      src/main/resources/templates/counter/counter-booking.html
  18. 6
      src/main/resources/templates/fragments/menuOfficer.html
  19. 43
      src/main/resources/templates/headquarters/gccblocking.html
  20. 1412
      src/main/resources/templates/officer/gccblocking.html
  21. 2
      src/main/resources/templates/user/communityHallList.html
  22. 158
      src/main/resources/templates/user/hallbookingform.html
  23. 1
      src/main/resources/templates/user/viewhallform.html
  24. 68
      src/main/resources/templates/user/viewhistory.html

21
.classpath

@ -29,15 +29,6 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="test" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"> <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
@ -48,6 +39,18 @@
<classpathentry kind="src" path="target/generated-sources/annotations"> <classpathentry kind="src" path="target/generated-sources/annotations">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="output" path="target/classes"/> <classpathentry kind="output" path="target/classes"/>

6
.gitignore

@ -1 +1,7 @@
/target/ /target/
target/classes/
.classpath
/communityHallDocuments/
target/classes/application-dev.properties
target/classes/application-prod.properties

2
jwtToken.txt

@ -1 +1 @@
eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyVHlwZSI6ImFkbWluIiwiaGFsbElkIjoxLCJtb2JpbGVOdW1iZXIiOjgzNDQ5NzkyOTIsImVtcGxveWVlSWQiOiIxIiwiem9uZSI6IjAwIiwiZXhwIjoxNzYyODYwNzk0fQ.ltHuRFZWZqHUvUki5jbMcGTDbU2JyOWU5cgMFbVrp_8KMag9HVtHQ9iSFGUyIMUe_T08b58_BG9ZtrtM8rHo9Q
eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyVHlwZSI6ImFkbWluIiwiaGFsbElkIjoxLCJtb2JpbGVOdW1iZXIiOjgzNDQ5NzkyOTIsImVtcGxveWVlSWQiOiIxIiwiem9uZSI6IjAwIiwiZXhwIjoxNzczMTIyNTkxfQ.6cTw68Q9NsMgdKLtP7D1k0I_6PJQ62mFIOItwtpYz7o7FNC_Kf0qRzulFguzgnPpdvSwXF2v2w_PqIXte7eIMg

326
src/main/java/com/gcc/communityHall/controller/AdminAPIController.java

@ -71,6 +71,7 @@ import com.gcc.communityHall.repository.DiscountRangeRepository;
import com.gcc.communityHall.repository.GccBlockingDateRepository; import com.gcc.communityHall.repository.GccBlockingDateRepository;
import com.gcc.communityHall.repository.GccBlockingHistoryRepository; import com.gcc.communityHall.repository.GccBlockingHistoryRepository;
import com.gcc.communityHall.repository.HallDetailsRepository; import com.gcc.communityHall.repository.HallDetailsRepository;
import com.gcc.communityHall.repository.HallReasonRestrictionRepository;
import com.gcc.communityHall.repository.HallImagesRepository; import com.gcc.communityHall.repository.HallImagesRepository;
import com.gcc.communityHall.repository.NotificationRepository; import com.gcc.communityHall.repository.NotificationRepository;
import com.gcc.communityHall.repository.ReasonMasterRepository; import com.gcc.communityHall.repository.ReasonMasterRepository;
@ -97,10 +98,7 @@ import lombok.AllArgsConstructor;
//@RestController //@RestController
//@RequestMapping("/admin/api") //@RequestMapping("/admin/api")
@Tag(
name = "CRUD REST APIs for Admin in CommunityHall",
description = "CRUD REST APIs in CommunityHall to CREATE, UPDATE, FETCH AND DELETE Booking details"
)
@Tag(name = "CRUD REST APIs for Admin in CommunityHall", description = "CRUD REST APIs in CommunityHall to CREATE, UPDATE, FETCH AND DELETE Booking details")
@RestController @RestController
@RequestMapping("/communityhall/admin/api") @RequestMapping("/communityhall/admin/api")
@AllArgsConstructor @AllArgsConstructor
@ -168,32 +166,13 @@ public class AdminAPIController {
@Autowired @Autowired
private ApplicationLogsRepository applicationLogsRepository; private ApplicationLogsRepository applicationLogsRepository;
@Operation(
summary = "Update HallDetails REST API",
description = "REST API to update the Hall Details"
)
@Autowired
private HallReasonRestrictionRepository hallReasonRestrictionRepository;
@Operation(summary = "Update HallDetails REST API", description = "REST API to update the Hall Details")
@ApiResponses({ @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\" }"
)
)
)
@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") @PostMapping("/updateHallDetails")
public ResponseEntity<String> updateHallInfo( public ResponseEntity<String> updateHallInfo(
@ -270,43 +249,18 @@ public class AdminAPIController {
return ResponseEntity.ok("Success"); return ResponseEntity.ok("Success");
} }
@Operation(
summary = "Update Settlement Status REST API",
description = "REST API to update the Settlement Status to INITIATED"
)
@Operation(summary = "Update Settlement Status REST API", description = "REST API to update the Settlement Status to INITIATED")
@ApiResponses({ @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\" }"
)
)
)
@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}") @PostMapping("/updateInitiatedSettlementStatus/{settlementId}")
public ResponseEntity<Settlement> updateInitiatedSettlementStatus( public ResponseEntity<Settlement> updateInitiatedSettlementStatus(
@PathVariable("settlementId") int settlementId, @PathVariable("settlementId") int settlementId,
@RequestParam("status") BookingDetails.RefundStatus status, @RequestParam("status") BookingDetails.RefundStatus status,
@RequestParam("comments") String comments) { @RequestParam("comments") String comments) {
Settlement updateInitialiseSettlement = settlementService.updateSettlementStatus(settlementId, status, comments);
Settlement updateInitialiseSettlement = settlementService.updateSettlementStatus(settlementId, status,
comments);
String adminname = (String) session.getAttribute("usertype"); String adminname = (String) session.getAttribute("usertype");
Integer loginid = (Integer) session.getAttribute("id"); Integer loginid = (Integer) session.getAttribute("id");
ApplicationLogs logs = new ApplicationLogs(); ApplicationLogs logs = new ApplicationLogs();
@ -330,27 +284,11 @@ public class AdminAPIController {
} }
} }
@Operation(
summary = "HallDetails by HallId REST API",
description = "REST API to Retrieving the Hall Details by hallId"
)
@Operation(summary = "HallDetails by HallId REST API", description = "REST API to Retrieving the Hall Details by hallId")
@ApiResponses({ @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"
)
@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}") @GetMapping("/getHallDetails/{hallId}")
public ResponseEntity<HallDetails> getHallDetails(@PathVariable String hallId) { public ResponseEntity<HallDetails> getHallDetails(@PathVariable String hallId) {
@ -370,10 +308,7 @@ public class AdminAPIController {
} }
} }
@Operation(
summary = "Saving the DiscountRange REST API",
description = "REST API to Saving the Discount Range for usertypes"
)
@Operation(summary = "Saving the DiscountRange REST API", description = "REST API to Saving the Discount Range for usertypes")
@PostMapping("/savediscountrange") @PostMapping("/savediscountrange")
public String saveDiscountrange( public String saveDiscountrange(
@RequestParam String userType, @RequestParam String userType,
@ -427,12 +362,10 @@ public class AdminAPIController {
return "success"; return "success";
} }
@Operation(
summary = " Update the DiscountRange REST API",
description = "REST API to Updating the Discount Range for usertypes"
)
@Operation(summary = " Update the DiscountRange REST API", description = "REST API to Updating the Discount Range for usertypes")
@PutMapping("/updateById/{id}") @PutMapping("/updateById/{id}")
public String updateDiscountRangeById(@PathVariable int id, @RequestParam float discountRange, HttpSession session) {
public String updateDiscountRangeById(@PathVariable int id, @RequestParam float discountRange,
HttpSession session) {
String adminname = (String) session.getAttribute("usertype"); String adminname = (String) session.getAttribute("usertype");
Optional<DiscountRange> existingDiscount = discountRangeRepo.findById(id); Optional<DiscountRange> existingDiscount = discountRangeRepo.findById(id);
if (existingDiscount.isPresent()) { if (existingDiscount.isPresent()) {
@ -462,11 +395,7 @@ public class AdminAPIController {
} }
} }
@Operation(
summary = " Delete the DiscountRange REST API",
description = "REST API to Deleting the Discount for usertypes"
)
@Operation(summary = " Delete the DiscountRange REST API", description = "REST API to Deleting the Discount for usertypes")
@DeleteMapping("/deleteById/{id}") @DeleteMapping("/deleteById/{id}")
public ResponseEntity<String> deleteDiscountRangeById(@PathVariable int id) { public ResponseEntity<String> deleteDiscountRangeById(@PathVariable int id) {
if (discountRangeRepo.existsById(id)) { if (discountRangeRepo.existsById(id)) {
@ -523,10 +452,7 @@ public class AdminAPIController {
} }
@Operation(
summary = "Retrieving the Discount Details REST API",
description = "REST API to Retrieve the Discount Details for usertypes"
)
@Operation(summary = "Retrieving the Discount Details REST API", description = "REST API to Retrieve the Discount Details for usertypes")
// Retrieving the Discount Details // Retrieving the Discount Details
@GetMapping("/getDiscountDetails") @GetMapping("/getDiscountDetails")
public Optional<DiscountRange> getDIscountDetails(@RequestParam("id") int id) { public Optional<DiscountRange> getDIscountDetails(@RequestParam("id") int id) {
@ -534,20 +460,14 @@ public class AdminAPIController {
return discountdetails; return discountdetails;
} }
@Operation(
summary = "Save Reasons REST API",
description = "REST API to save the reasons"
)
@Operation(summary = "Save Reasons REST API", description = "REST API to save the reasons")
// saving the Reason // saving the Reason
@PostMapping("/saveReason") @PostMapping("/saveReason")
public ResponseEntity<?> saveReason(@RequestBody ReasonMaster reasaon) { public ResponseEntity<?> saveReason(@RequestBody ReasonMaster reasaon) {
return ResponseEntity.ok(reasonMasterService.saveTheReason(reasaon)); return ResponseEntity.ok(reasonMasterService.saveTheReason(reasaon));
} }
@Operation(
summary = "All Reasons REST API",
description = "REST API to retrie the allreasons"
)
@Operation(summary = "All Reasons REST API", description = "REST API to retrie the allreasons")
// retrieving the allreasons // retrieving the allreasons
@GetMapping("/getReasons") @GetMapping("/getReasons")
@ResponseBody @ResponseBody
@ -555,33 +475,49 @@ public class AdminAPIController {
return reasonMasterService.getAllReasons(); return reasonMasterService.getAllReasons();
} }
@Operation(
summary = "Reason Documents by reasonId REST API",
description = "REST API to Get the ReasonDocuments By reasonId"
)
// retrieving allowed reasons for a specific hall (filtered by restriction)
@GetMapping("/getAllowedReasons")
@ResponseBody
public List<ReasonMaster> getAllowedReasons(@RequestParam int hallId) {
HallDetails hallDetails = hallDetailsRepository.findHallDetailsById(hallId);
if (hallDetails != null && hallDetails.isReasonRestricted()) {
List<Integer> allowedReasonIds = hallReasonRestrictionRepository.findReasonIdsByHallId(hallId);
if (!allowedReasonIds.isEmpty()) {
List<ReasonMaster> allReasons = reasonMasterService.getAllReasons();
return allReasons.stream()
.filter(r -> allowedReasonIds.contains(r.getReasonId()))
.collect(java.util.stream.Collectors.toList());
}
}
return reasonMasterService.getAllReasons();
}
@Operation(summary = "Reason Documents by reasonId REST API", description = "REST API to Get the ReasonDocuments By reasonId")
// Getting ReasonDocuments By reasonId // Getting ReasonDocuments By reasonId
@GetMapping("/getReasonDocumentDetails") @GetMapping("/getReasonDocumentDetails")
public List<ReasonDocumentMaster> getReasonDocumentDetails(@RequestParam int reasonId) { public List<ReasonDocumentMaster> getReasonDocumentDetails(@RequestParam int reasonId) {
return reasonMasterService.getReasonDocumentDetailsByReasonId(reasonId); return reasonMasterService.getReasonDocumentDetailsByReasonId(reasonId);
} }
@Operation(
summary = "Booking Details by Fromdate,toDate and HallId REST API",
description = "REST API to get the Booking Details by Fromdate,toDate and HallId for GccBlokcing"
)
@Operation(summary = "Booking Details by Fromdate,toDate and HallId REST API", description = "REST API to get the Booking Details by Fromdate,toDate and HallId for GccBlokcing")
// @GetMapping("/filter") // @GetMapping("/filter")
// public ResponseEntity<List<BookingResponseDTO>> getFilteredBookings( // public ResponseEntity<List<BookingResponseDTO>> getFilteredBookings(
// @RequestParam("fromDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate fromDate,
// @RequestParam("toDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate toDate,
// @RequestParam("fromDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate
// fromDate,
// @RequestParam("toDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate
// toDate,
// @RequestParam("hallIds") List<Long> hallIds) { // @RequestParam("hallIds") List<Long> hallIds) {
// //
// List<BookingDetails> bookings = bookingService.getFilteredBookings(fromDate, toDate, hallIds);
// List<BookingDetails> bookings = bookingService.getFilteredBookings(fromDate,
// toDate, hallIds);
// //
// List<BookingResponseDTO> responses = new ArrayList<>(); // List<BookingResponseDTO> responses = new ArrayList<>();
// for (BookingDetails bookingDetails : bookings) { // for (BookingDetails bookingDetails : bookings) {
// // Fetch GccBlockingDate records for each bookingId // // Fetch GccBlockingDate records for each bookingId
// List<GccBlockingDate> gccBlockedList = blockingDateRepository.getByBookingId(bookingDetails.getBookingId());
// Integer blockingId = gccBlockedList.isEmpty() ? null : gccBlockedList.get(0).getBlockingId();
// List<GccBlockingDate> gccBlockedList =
// blockingDateRepository.getByBookingId(bookingDetails.getBookingId());
// Integer blockingId = gccBlockedList.isEmpty() ? null :
// gccBlockedList.get(0).getBlockingId();
// responses.add(new BookingResponseDTO(bookingDetails, blockingId)); // responses.add(new BookingResponseDTO(bookingDetails, blockingId));
// } // }
// //
@ -594,7 +530,8 @@ public class AdminAPIController {
@RequestParam("hallIds") List<Long> hallIds) { @RequestParam("hallIds") List<Long> hallIds) {
List<BookingDetails> bookings = bookingService.getFilteredBookings(fromDate, toDate, hallIds); List<BookingDetails> bookings = bookingService.getFilteredBookings(fromDate, toDate, hallIds);
List<GccBlockingDate> gccBlockedList = blockingDateRepository.findByFromDateAndToDateBetweenAndHallIdIn(fromDate, toDate, hallIds);
List<GccBlockingDate> gccBlockedList = blockingDateRepository
.findByFromDateAndToDateBetweenAndHallIdIn(fromDate, toDate, hallIds);
Map<String, Object> response = new HashMap<>(); Map<String, Object> response = new HashMap<>();
response.put("bookings", bookings); response.put("bookings", bookings);
@ -603,22 +540,19 @@ public class AdminAPIController {
return ResponseEntity.ok(response); return ResponseEntity.ok(response);
} }
@Operation(
summary = " GCC Blocked Booking Details REST API",
description = "REST API to get the GCC Blocked BookingDetails"
)
@Operation(summary = " GCC Blocked Booking Details REST API", description = "REST API to get the GCC Blocked BookingDetails")
// retrieving the GCC Blocked BookingDetails // retrieving the GCC Blocked BookingDetails
@GetMapping("/blockedevents") @GetMapping("/blockedevents")
public ResponseEntity<List<GccBlockingDate>> getBlockedEvents( public ResponseEntity<List<GccBlockingDate>> getBlockedEvents(
@RequestParam("fromDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate fromDate, @RequestParam("fromDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate fromDate,
@RequestParam("toDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate toDate, @RequestParam("toDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate toDate,
@RequestParam("hallIds") List<Long> hallIds
) {
//System.out.println("Blocked Events Request - fromDate: " + fromDate + ", toDate: " + toDate + ", hallIds: " + hallIds );
@RequestParam("hallIds") List<Long> hallIds) {
// System.out.println("Blocked Events Request - fromDate: " + fromDate + ",
// toDate: " + toDate + ", hallIds: " + hallIds );
List<GccBlockingDate> blockedBookings = bookingService.getBlockedEvents(fromDate, toDate, hallIds); List<GccBlockingDate> blockedBookings = bookingService.getBlockedEvents(fromDate, toDate, hallIds);
// List<BookingDetails> bookingDetails = bookingService.getByBookingId(fromDate,toDate,hallIds,blockingId,bookingId);
// List<BookingDetails> bookingDetails =
// bookingService.getByBookingId(fromDate,toDate,hallIds,blockingId,bookingId);
if (blockedBookings.isEmpty()) { if (blockedBookings.isEmpty()) {
// System.out.println("No blocked bookings found."); // System.out.println("No blocked bookings found.");
@ -632,11 +566,7 @@ public class AdminAPIController {
return ResponseEntity.ok(blockedBookings); return ResponseEntity.ok(blockedBookings);
} }
@Operation(
summary = "UNBLOCK the gcc Blocked Event REST API",
description = "REST API to unblocking the Gcc blocked Events for blocking"
)
@Operation(summary = "UNBLOCK the gcc Blocked Event REST API", description = "REST API to unblocking the Gcc blocked Events for blocking")
@GetMapping("/cancelByid") @GetMapping("/cancelByid")
public ResponseEntity<String> cancellationById(@RequestParam int blockingId, public ResponseEntity<String> cancellationById(@RequestParam int blockingId,
@RequestParam("fromDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate fromDate, @RequestParam("fromDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate fromDate,
@ -668,7 +598,8 @@ public class AdminAPIController {
List<BookingCalendar> bookingCalendars = bookingService.getBookedslots(fromDate, endDate, hallIdList); List<BookingCalendar> bookingCalendars = bookingService.getBookedslots(fromDate, endDate, hallIdList);
if (bookingCalendars.isEmpty()) { if (bookingCalendars.isEmpty()) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("No booking slots found for the given date range and hall IDs.");
return ResponseEntity.status(HttpStatus.NOT_FOUND)
.body("No booking slots found for the given date range and hall IDs.");
} }
// Iterate over bookingCalendars and update them as needed // Iterate over bookingCalendars and update them as needed
@ -716,8 +647,10 @@ public class AdminAPIController {
// public ResponseEntity<String> cancellationById( // public ResponseEntity<String> cancellationById(
// @RequestParam int blockingId, // @RequestParam int blockingId,
// @RequestParam int bookingId, // @RequestParam int bookingId,
// @RequestParam("fromDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate fromDate,
// @RequestParam("endDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endDate,
// @RequestParam("fromDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate
// fromDate,
// @RequestParam("endDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate
// endDate,
// @RequestParam(value = "hallId", required = false) List<Long> hallId) { // @RequestParam(value = "hallId", required = false) List<Long> hallId) {
// //
// System.out.println("Received blockingId: " + blockingId); // System.out.println("Received blockingId: " + blockingId);
@ -726,19 +659,23 @@ public class AdminAPIController {
// System.out.println("Received hallId: " + hallId); // System.out.println("Received hallId: " + hallId);
// //
// // Retrieve blocking date // // Retrieve blocking date
// GccBlockingDate blockingDate = blockingDateRepository.findById(blockingId).orElse(null);
// GccBlockingDate blockingDate =
// blockingDateRepository.findById(blockingId).orElse(null);
// //
// if (blockingDate == null) { // if (blockingDate == null) {
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body("Blocking ID not found.");
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body("Blocking ID not
// found.");
// } // }
// //
// if (hallId != null && bookingId > 0) { // if (hallId != null && bookingId > 0) {
// // Specific bookingId and hallId selected // // Specific bookingId and hallId selected
// //
// // Retrieve and update booking calendar // // Retrieve and update booking calendar
// List<BookingCalendar> bookingCalendar = bookingService.getBookedslots(fromDate, endDate, hallId);
// List<BookingCalendar> bookingCalendar =
// bookingService.getBookedslots(fromDate, endDate, hallId);
// if (bookingCalendar.isEmpty()) { // if (bookingCalendar.isEmpty()) {
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body("No booking slots found for the given date and hall ID.");
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body("No booking slots
// found for the given date and hall ID.");
// } // }
// //
// BookingCalendar bookingSlots = bookingCalendar.get(0); // BookingCalendar bookingSlots = bookingCalendar.get(0);
@ -752,7 +689,8 @@ public class AdminAPIController {
// hallIdList.remove(hallId.toString()); // hallIdList.remove(hallId.toString());
// String updatedHallIds = String.join(",", hallIdList); // String updatedHallIds = String.join(",", hallIdList);
// //
// List<String> bookingIdList = Arrays.asList(blockingDate.getBookingIds().split(","));
// List<String> bookingIdList =
// Arrays.asList(blockingDate.getBookingIds().split(","));
// bookingIdList.remove(Integer.toString(bookingId)); // bookingIdList.remove(Integer.toString(bookingId));
// String updatedBookingIds = String.join(",", bookingIdList); // String updatedBookingIds = String.join(",", bookingIdList);
// //
@ -782,7 +720,8 @@ public class AdminAPIController {
// } else { // } else {
// // All halls and bookings selected // // All halls and bookings selected
// // Retrieve and clear all bookings for the date range // // Retrieve and clear all bookings for the date range
// List<BookingCalendar> bookingCalendars = bookingService.getBookedslots(fromDate,endDate,hallId);
// List<BookingCalendar> bookingCalendars =
// bookingService.getBookedslots(fromDate,endDate,hallId);
// for (BookingCalendar bookingCalendar : bookingCalendars) { // for (BookingCalendar bookingCalendar : bookingCalendars) {
// bookingCalendar.setBookingId_1(null); // bookingCalendar.setBookingId_1(null);
// bookingCalendar.setBookingId_2(null); // bookingCalendar.setBookingId_2(null);
@ -809,20 +748,14 @@ public class AdminAPIController {
// return ResponseEntity.ok("Success"); // return ResponseEntity.ok("Success");
// } // }
@Operation(
summary = "HAll IMAGES by HallId REST API",
description = "REST API to get the hall Images by Hall Id"
)
@Operation(summary = "HAll IMAGES by HallId REST API", description = "REST API to get the hall Images by Hall Id")
// retrieving Hall Images by Hallid // retrieving Hall Images by Hallid
@GetMapping("/getImageById") @GetMapping("/getImageById")
public List<HallImages> getImageDetails(@RequestParam int hallId) { public List<HallImages> getImageDetails(@RequestParam int hallId) {
return hallService.getHallImages(hallId); return hallService.getHallImages(hallId);
} }
@Operation(
summary = "GCC Blocking REST API",
description = "REST API to Block the Halls by Admin"
)
@Operation(summary = "GCC Blocking REST API", description = "REST API to Block the Halls by Admin")
// GccBlocking Api // GccBlocking Api
@PostMapping("/cancelAll") @PostMapping("/cancelAll")
public ResponseEntity<String> cancelAllBookings( public ResponseEntity<String> cancelAllBookings(
@ -844,7 +777,8 @@ public class AdminAPIController {
.collect(Collectors.toList()); .collect(Collectors.toList());
// Call the service with descriptions and documents // Call the service with descriptions and documents
bookingService.cancelAllBookings(fromDate, toDate, hallIdsList, reasonforblocking, selectedBookings, updatedBy, descriptions, documents);
bookingService.cancelAllBookings(fromDate, toDate, hallIdsList, reasonforblocking, selectedBookings, updatedBy,
descriptions, documents);
String adminname = (String) session.getAttribute("usertype"); String adminname = (String) session.getAttribute("usertype");
Integer loginid = (Integer) session.getAttribute("id"); Integer loginid = (Integer) session.getAttribute("id");
ApplicationLogs logs = new ApplicationLogs(); ApplicationLogs logs = new ApplicationLogs();
@ -867,12 +801,15 @@ public class AdminAPIController {
// @PostMapping("/blockhall") // @PostMapping("/blockhall")
// public ResponseEntity<String> blockHall( // public ResponseEntity<String> blockHall(
// @RequestParam("blockingId") Integer blockingId, // @RequestParam("blockingId") Integer blockingId,
// @RequestParam("hallID") String hallID, // Ensure this matches the parameter name used in AJAX
// @RequestParam(value = "selectedBookings", required = false) List<String> selectedBookings,
// @RequestParam("hallID") String hallID, // Ensure this matches the parameter
// name used in AJAX
// @RequestParam(value = "selectedBookings", required = false) List<String>
// selectedBookings,
// HttpSession session) { // HttpSession session) {
// //
// String updatedBy = (String) session.getAttribute("employeeId"); // String updatedBy = (String) session.getAttribute("employeeId");
// Optional<GccBlockingDate> gccblocking = blockingDateRepository.findById(blockingId);
// Optional<GccBlockingDate> gccblocking =
// blockingDateRepository.findById(blockingId);
// GccBlockingDate gccblockingdata = gccblocking.get(); // GccBlockingDate gccblockingdata = gccblocking.get();
// //
// // Convert startDate and endDate to String // // Convert startDate and endDate to String
@ -888,12 +825,13 @@ public class AdminAPIController {
// System.out.println("selected BookingIds: " + selectedBookings); // System.out.println("selected BookingIds: " + selectedBookings);
// //
// // Pass the formatted date strings // // Pass the formatted date strings
// bookingService.cancelAllBookings(startDateString, endDateString, hallIdsList, gccblockingdata.getDepartment(), gccblockingdata.getBlockingReason(), selectedBookings, updatedBy);
// bookingService.cancelAllBookings(startDateString, endDateString, hallIdsList,
// gccblockingdata.getDepartment(), gccblockingdata.getBlockingReason(),
// selectedBookings, updatedBy);
// //
// return ResponseEntity.ok("Success"); // return ResponseEntity.ok("Success");
// } // }
@GetMapping("/bookingdetailsByuserId") @GetMapping("/bookingdetailsByuserId")
public List<BookingDetails> getuserDetails(@RequestParam Integer userId) { public List<BookingDetails> getuserDetails(@RequestParam Integer userId) {
return bookingService.getAllBookingsByUserId(userId); return bookingService.getAllBookingsByUserId(userId);
@ -901,11 +839,14 @@ public class AdminAPIController {
@GetMapping("/settlement-approved") @GetMapping("/settlement-approved")
public ResponseEntity<List<Settlement>> getApprovedSettlements(HttpSession session) { public ResponseEntity<List<Settlement>> getApprovedSettlements(HttpSession session) {
List<Settlement> approvedSettlements = settlementRepository.findByBookingDetailsRefundStatus(RefundStatus.APPROVED);
List<Settlement> approvedSettlements = settlementRepository
.findByBookingDetailsRefundStatus(RefundStatus.APPROVED);
return ResponseEntity.ok(approvedSettlements); return ResponseEntity.ok(approvedSettlements);
} }
// @PostMapping("/complete-refund") // @PostMapping("/complete-refund")
// public ResponseEntity<String> completeRefund(@RequestBody List<String> bookingIds, HttpSession session, HttpServletResponse response) throws IOException {
// public ResponseEntity<String> completeRefund(@RequestBody List<String>
// bookingIds, HttpSession session, HttpServletResponse response) throws
// IOException {
// String token = (String) session.getAttribute("jwtToken"); // String token = (String) session.getAttribute("jwtToken");
// //System.out.println("tokensssssssss" + token); // //System.out.println("tokensssssssss" + token);
// //
@ -919,28 +860,34 @@ public class AdminAPIController {
// //
// if (!bookids.isEmpty()) { // if (!bookids.isEmpty()) {
// // Prepare and return error response if there are errors // // Prepare and return error response if there are errors
// StringBuilder errorResponse = new StringBuilder("Errors processing refund for IDs: ");
// StringBuilder errorResponse = new StringBuilder("Errors processing refund for
// IDs: ");
// for (String bookId : bookids) { // for (String bookId : bookids) {
// errorResponse.append(bookId).append(", "); // errorResponse.append(bookId).append(", ");
// } // }
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(errorResponse.toString());
// return
// ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(errorResponse.toString());
// } // }
// //
// return ResponseEntity.ok("Refund completed successfully"); // return ResponseEntity.ok("Refund completed successfully");
// } catch (Exception e) { // } catch (Exception e) {
// e.printStackTrace(); // e.printStackTrace();
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error processing refund: " + e.getMessage());
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error
// processing refund: " + e.getMessage());
// } // }
// } else { // } else {
// // Token is invalid or not present, redirect to login // // Token is invalid or not present, redirect to login
// session.invalidate(); // Invalidate the session to clear all session attributes
// session.invalidate(); // Invalidate the session to clear all session
// attributes
// response.sendRedirect("/login"); // Redirect to the login page // response.sendRedirect("/login"); // Redirect to the login page
// return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); // Return HTTP 401 Unauthorized
// return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); // Return HTTP
// 401 Unauthorized
// } // }
// } // }
// @GetMapping("/Gccblocking") // @GetMapping("/Gccblocking")
// public ResponseEntity<List<Object>> getGccBlockingEvents(@RequestParam("hallId") int hallId) {
// public ResponseEntity<List<Object>>
// getGccBlockingEvents(@RequestParam("hallId") int hallId) {
// System.out.println("Received hallId: " + hallId); // System.out.println("Received hallId: " + hallId);
// //
// List<Object> results = bookingService.getGccBlockingEvents(hallId); // List<Object> results = bookingService.getGccBlockingEvents(hallId);
@ -992,8 +939,10 @@ public class AdminAPIController {
if (hallDetailsOpt.isPresent()) { if (hallDetailsOpt.isPresent()) {
HallDetails hallDetails = hallDetailsOpt.get(); HallDetails hallDetails = hallDetailsOpt.get();
List<Integer> bookingIds = bookingDetailsRepository.findBookingIdsByHallIdAndBookingDateBetween(hallId, startDate, endDate);
// System.out.println("Booking IDs for hallId " + hallId + ": " + bookingIds); // Add this line
List<Integer> bookingIds = bookingDetailsRepository.findBookingIdsByHallIdAndBookingDateBetween(hallId,
startDate, endDate);
// System.out.println("Booking IDs for hallId " + hallId + ": " + bookingIds);
// // Add this line
Map<String, Object> hallInfo = new HashMap<>(); Map<String, Object> hallInfo = new HashMap<>();
hallInfo.put("hallName", hallDetails.getHallName()); hallInfo.put("hallName", hallDetails.getHallName());
@ -1023,7 +972,6 @@ public class AdminAPIController {
} }
} }
@GetMapping("/blockedHallsByHallIdAndReason") @GetMapping("/blockedHallsByHallIdAndReason")
@ResponseBody @ResponseBody
public Map<String, Object> viewBlockedHallsByHallIdAndReason( public Map<String, Object> viewBlockedHallsByHallIdAndReason(
@ -1032,11 +980,13 @@ public class AdminAPIController {
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Date startDate, @RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Date startDate,
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Date endDate) { @RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Date endDate) {
List<GccBlockingDate> blockedHalls = blockingDateRepository.findByBlockingReasonAndDateRange(blockingReason, startDate, endDate);
List<GccBlockingDate> blockedHalls = blockingDateRepository.findByBlockingReasonAndDateRange(blockingReason,
startDate, endDate);
// Ensure distinct by hallId and other keys // Ensure distinct by hallId and other keys
List<GccBlockingDate> uniqueGccBlockingDates = blockedHalls.stream() List<GccBlockingDate> uniqueGccBlockingDates = blockedHalls.stream()
.filter(distinctByKey(g -> Arrays.asList(g.getHallId(), g.getBlockingReason(), g.getStartDate(), g.getEndDate())))
.filter(distinctByKey(
g -> Arrays.asList(g.getHallId(), g.getBlockingReason(), g.getStartDate(), g.getEndDate())))
.collect(Collectors.toList()); .collect(Collectors.toList());
// Prepare response data // Prepare response data
@ -1083,7 +1033,6 @@ public class AdminAPIController {
return response; return response;
} }
// Utility method to ensure distinct by a key // Utility method to ensure distinct by a key
private static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) { private static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
Set<Object> seen = new HashSet<>(); Set<Object> seen = new HashSet<>();
@ -1092,7 +1041,8 @@ public class AdminAPIController {
// Method to calculate number of bookings // Method to calculate number of bookings
private int calculateBookings(HallDetails hall, GccBlockingDate blockedHall) { private int calculateBookings(HallDetails hall, GccBlockingDate blockedHall) {
return blockingDateRepository.countBlockedBookings(hall.getHallId(), blockedHall.getStartDate(), blockedHall.getEndDate());
return blockingDateRepository.countBlockedBookings(hall.getHallId(), blockedHall.getStartDate(),
blockedHall.getEndDate());
} }
private double calculateRefund(HallDetails hall, GccBlockingDate blockedHall) { private double calculateRefund(HallDetails hall, GccBlockingDate blockedHall) {
@ -1111,7 +1061,8 @@ public class AdminAPIController {
@RequestParam(required = false, defaultValue = "ALL") String userType) { @RequestParam(required = false, defaultValue = "ALL") String userType) {
try { try {
Map<String, Map<String, Integer>> statistics = bookingService.getBookingStatistics(fromDate, toDate, zone, division, hallid, userType);
Map<String, Map<String, Integer>> statistics = bookingService.getBookingStatistics(fromDate, toDate, zone,
division, hallid, userType);
return ResponseEntity.ok(statistics); return ResponseEntity.ok(statistics);
} catch (Exception e) { } catch (Exception e) {
// Log the exception and return an appropriate error response // Log the exception and return an appropriate error response
@ -1161,7 +1112,8 @@ public class AdminAPIController {
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(Collections.singletonMap("error", e.getMessage())); return ResponseEntity.status(HttpStatus.NOT_FOUND).body(Collections.singletonMap("error", e.getMessage()));
} catch (IOException e) { } catch (IOException e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(Collections.singletonMap("error", "Failed to update image"));
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(Collections.singletonMap("error", "Failed to update image"));
} }
} }
@ -1239,7 +1191,6 @@ public class AdminAPIController {
return ResponseEntity.ok(response); return ResponseEntity.ok(response);
} }
@GetMapping("/viewsettlement-complete") @GetMapping("/viewsettlement-complete")
public ResponseEntity<Map<String, Object>> viewSettlementcompleteMaster(HttpSession session) { public ResponseEntity<Map<String, Object>> viewSettlementcompleteMaster(HttpSession session) {
@ -1342,10 +1293,16 @@ public class AdminAPIController {
List<Users> userList = handleUserRequest(request, fromDate, toDate, userstatus, usertype); List<Users> userList = handleUserRequest(request, fromDate, toDate, userstatus, usertype);
List<Object[]> bookingList = handleBookingRequest(request, fromDate, toDate, bookingStatus, bookingId); List<Object[]> bookingList = handleBookingRequest(request, fromDate, toDate, bookingStatus, bookingId);
List<BookingDetails> bookingSettlementList = handleBookingSettlementRequest(request, fromDate, toDate, refundStatus);
List<Object[]> paymentList = request.equals("3") ? bookingService.getAllPaymentsDetails(fromDate, toDate) : new ArrayList<>();
List<Object[]> userbookingList = request.equals("4") ? bookingService.getBookingUserDetailsReport(fromDate, toDate) : new ArrayList<>();
List<Object[]> hallbookingList = request.equals("5") ? bookingService.getBookingHallDetailsReport(fromDate, toDate) : new ArrayList<>();
List<BookingDetails> bookingSettlementList = handleBookingSettlementRequest(request, fromDate, toDate,
refundStatus);
List<Object[]> paymentList = request.equals("3") ? bookingService.getAllPaymentsDetails(fromDate, toDate)
: new ArrayList<>();
List<Object[]> userbookingList = request.equals("4")
? bookingService.getBookingUserDetailsReport(fromDate, toDate)
: new ArrayList<>();
List<Object[]> hallbookingList = request.equals("5")
? bookingService.getBookingHallDetailsReport(fromDate, toDate)
: new ArrayList<>();
response.put("users", userList); response.put("users", userList);
response.put("bookings", bookingList); response.put("bookings", bookingList);
@ -1365,7 +1322,8 @@ public class AdminAPIController {
return new ResponseEntity<>(response, HttpStatus.OK); return new ResponseEntity<>(response, HttpStatus.OK);
} }
private List<Users> handleUserRequest(String request, String fromDate, String toDate, String userstatus, String usertype) {
private List<Users> handleUserRequest(String request, String fromDate, String toDate, String userstatus,
String usertype) {
if (!request.equals("1")) { if (!request.equals("1")) {
return new ArrayList<>(); return new ArrayList<>();
} }
@ -1381,7 +1339,8 @@ public class AdminAPIController {
return userService.getAllUsers(fromDate, toDate); return userService.getAllUsers(fromDate, toDate);
} }
private List<Object[]> handleBookingRequest(String request, String fromDate, String toDate, String bookingStatus, Long bookingId) {
private List<Object[]> handleBookingRequest(String request, String fromDate, String toDate, String bookingStatus,
Long bookingId) {
if (!request.equals("2")) { if (!request.equals("2")) {
return new ArrayList<>(); return new ArrayList<>();
} }
@ -1394,7 +1353,8 @@ public class AdminAPIController {
} }
} }
private List<BookingDetails> handleBookingSettlementRequest(String request, String fromDate, String toDate, String refundStatus) {
private List<BookingDetails> handleBookingSettlementRequest(String request, String fromDate, String toDate,
String refundStatus) {
if (!request.equals("6")) { if (!request.equals("6")) {
return new ArrayList<>(); return new ArrayList<>();
} }
@ -1410,7 +1370,6 @@ public class AdminAPIController {
return ResponseEntity.ok(halldetails); return ResponseEntity.ok(halldetails);
} }
@GetMapping("/listgccblocking") @GetMapping("/listgccblocking")
public ResponseEntity<Map<String, Object>> getGccBlocking() { public ResponseEntity<Map<String, Object>> getGccBlocking() {
@ -1504,7 +1463,8 @@ public class AdminAPIController {
return ResponseEntity.ok("File uploaded and saved successfully"); return ResponseEntity.ok("File uploaded and saved successfully");
} catch (Exception e) { } catch (Exception e) {
System.err.println("Error during file upload: " + e.getMessage()); System.err.println("Error during file upload: " + e.getMessage());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("File upload failed: " + e.getMessage());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body("File upload failed: " + e.getMessage());
} }
} }
} }

140
src/main/java/com/gcc/communityHall/controller/OfficerController.java

@ -1,8 +1,15 @@
package com.gcc.communityHall.controller; package com.gcc.communityHall.controller;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
@ -16,6 +23,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import com.gcc.communityHall.entity.BookingDetails; import com.gcc.communityHall.entity.BookingDetails;
import com.gcc.communityHall.entity.BookingDetails.RefundStatus; import com.gcc.communityHall.entity.BookingDetails.RefundStatus;
import com.gcc.communityHall.entity.CounterRefundList; import com.gcc.communityHall.entity.CounterRefundList;
import com.gcc.communityHall.entity.GccBlockingDate;
import com.gcc.communityHall.entity.HallDetails; import com.gcc.communityHall.entity.HallDetails;
import com.gcc.communityHall.entity.Payments; import com.gcc.communityHall.entity.Payments;
import com.gcc.communityHall.entity.Settlement; import com.gcc.communityHall.entity.Settlement;
@ -23,6 +31,7 @@ import com.gcc.communityHall.entity.Users;
import com.gcc.communityHall.others.AppConfig; import com.gcc.communityHall.others.AppConfig;
import com.gcc.communityHall.repository.BookingDetailsRepository; import com.gcc.communityHall.repository.BookingDetailsRepository;
import com.gcc.communityHall.repository.CounterRefundListRepository; import com.gcc.communityHall.repository.CounterRefundListRepository;
import com.gcc.communityHall.repository.GccBlockingDateRepository;
import com.gcc.communityHall.repository.HallDetailsRepository; import com.gcc.communityHall.repository.HallDetailsRepository;
import com.gcc.communityHall.repository.PaymentsRepository; import com.gcc.communityHall.repository.PaymentsRepository;
import com.gcc.communityHall.repository.SettlementRepository; import com.gcc.communityHall.repository.SettlementRepository;
@ -58,6 +67,8 @@ public class OfficerController {
@Autowired @Autowired
private HallDetailService hallDetailsService; private HallDetailService hallDetailsService;
@Autowired
private GccBlockingDateRepository blockingDateRepository;
@GetMapping("/login") @GetMapping("/login")
public String viewLoginPage(Model model) { public String viewLoginPage(Model model) {
@ -186,7 +197,6 @@ public class OfficerController {
} }
} }
@GetMapping("/settlement-list") @GetMapping("/settlement-list")
public String settlementPendingList(Model model, HttpSession session) { public String settlementPendingList(Model model, HttpSession session) {
String officername = (String) session.getAttribute("usertype"); String officername = (String) session.getAttribute("usertype");
@ -201,7 +211,8 @@ public class OfficerController {
System.out.println("Zone: " + zone); System.out.println("Zone: " + zone);
List<BookingDetails> settlement = bookingDetailsRepository.findSettlementPendingByZone(zone); List<BookingDetails> settlement = bookingDetailsRepository.findSettlementPendingByZone(zone);
// ak // ak
List<BookingDetails> settlementIntiated = bookingDetailsRepository.findSettlementInitiatedPendingByZone(zone);
List<BookingDetails> settlementIntiated = bookingDetailsRepository
.findSettlementInitiatedPendingByZone(zone);
List<BookingDetails> cancelledbookings = bookingDetailsRepository.findCancelledListByZone(zone); List<BookingDetails> cancelledbookings = bookingDetailsRepository.findCancelledListByZone(zone);
List<BookingDetails> rejectedbookings = bookingDetailsRepository.findRejectedListByZone(zone); List<BookingDetails> rejectedbookings = bookingDetailsRepository.findRejectedListByZone(zone);
model.addAttribute("settlementlist", settlement); model.addAttribute("settlementlist", settlement);
@ -228,9 +239,12 @@ public class OfficerController {
model.addAttribute("baseURL", appConfig.getBaseUrl()); model.addAttribute("baseURL", appConfig.getBaseUrl());
String zone = (String) session.getAttribute("zone"); String zone = (String) session.getAttribute("zone");
model.addAttribute("zone", zone); model.addAttribute("zone", zone);
List<BookingDetails> settlementrefundfailed = bookingDetailsRepository.findSettlementRefundFailedByZone(zone);
List<BookingDetails> refundfailedcancelledbookings = bookingDetailsRepository.findRefundFaileCancelledListByZone(zone);
List<BookingDetails> refundfailedrejectedbookings = bookingDetailsRepository.findRefundFaileRejectedListByZone(zone);
List<BookingDetails> settlementrefundfailed = bookingDetailsRepository
.findSettlementRefundFailedByZone(zone);
List<BookingDetails> refundfailedcancelledbookings = bookingDetailsRepository
.findRefundFaileCancelledListByZone(zone);
List<BookingDetails> refundfailedrejectedbookings = bookingDetailsRepository
.findRefundFaileRejectedListByZone(zone);
model.addAttribute("settlementrefundfailed", settlementrefundfailed); model.addAttribute("settlementrefundfailed", settlementrefundfailed);
model.addAttribute("refundfailedcancelledbookings", refundfailedcancelledbookings); model.addAttribute("refundfailedcancelledbookings", refundfailedcancelledbookings);
model.addAttribute("refundfailedrejectedbookings", refundfailedrejectedbookings); model.addAttribute("refundfailedrejectedbookings", refundfailedrejectedbookings);
@ -253,8 +267,10 @@ public class OfficerController {
String zone = (String) session.getAttribute("zone"); String zone = (String) session.getAttribute("zone");
model.addAttribute("zone", zone); model.addAttribute("zone", zone);
List<BookingDetails> settlement = bookingDetailsRepository.findSettlementApprovedByZone(zone); List<BookingDetails> settlement = bookingDetailsRepository.findSettlementApprovedByZone(zone);
List<BookingDetails> approvedcancelledbookings = bookingDetailsRepository.findapprovedCancelledListByZone(zone);
List<BookingDetails> approvedrejectedbookings = bookingDetailsRepository.findapprovedRejectedListByZone(zone);
List<BookingDetails> approvedcancelledbookings = bookingDetailsRepository
.findapprovedCancelledListByZone(zone);
List<BookingDetails> approvedrejectedbookings = bookingDetailsRepository
.findapprovedRejectedListByZone(zone);
model.addAttribute("approvedSettlementlist", settlement); model.addAttribute("approvedSettlementlist", settlement);
model.addAttribute("approvedcancelledbookings", approvedcancelledbookings); model.addAttribute("approvedcancelledbookings", approvedcancelledbookings);
model.addAttribute("approvedrejectedbookings", approvedrejectedbookings); model.addAttribute("approvedrejectedbookings", approvedrejectedbookings);
@ -294,8 +310,10 @@ public class OfficerController {
String zone = (String) session.getAttribute("zone"); String zone = (String) session.getAttribute("zone");
model.addAttribute("zone", zone); model.addAttribute("zone", zone);
List<BookingDetails> completedlist = bookingDetailsRepository.findSettlementCompletedListbyzone(zone); List<BookingDetails> completedlist = bookingDetailsRepository.findSettlementCompletedListbyzone(zone);
List<BookingDetails> cancelledcompletedlist = bookingDetailsRepository.findCancelledCompletedListbyzone(zone);
List<BookingDetails> rejectedcompletedlist = bookingDetailsRepository.findRejectedSettlementCompletedListbyzone(zone);
List<BookingDetails> cancelledcompletedlist = bookingDetailsRepository
.findCancelledCompletedListbyzone(zone);
List<BookingDetails> rejectedcompletedlist = bookingDetailsRepository
.findRejectedSettlementCompletedListbyzone(zone);
model.addAttribute("title", "settlement initiate"); model.addAttribute("title", "settlement initiate");
model.addAttribute("officername", officername); model.addAttribute("officername", officername);
model.addAttribute("completedlist", completedlist); model.addAttribute("completedlist", completedlist);
@ -362,10 +380,15 @@ public class OfficerController {
model.addAttribute("mobileno", mobileno); model.addAttribute("mobileno", mobileno);
List<HallDetails> hallnames = hallDetailsService.getHallNamesbyzone(zone); List<HallDetails> hallnames = hallDetailsService.getHallNamesbyzone(zone);
model.addAttribute("hallnames", hallnames); model.addAttribute("hallnames", hallnames);
List<BookingDetails> bookingList = handleBookingRequest(request, fromDate, toDate, bookingStatus, zone, filterby);
List<BookingDetails> bookingSettlementList = handleBookingSettlementRequest(request, fromDate, toDate, refundStatus, zone, filterby);
List<Object[]> paymentList = request.equals("3") ? bookingService.getAllPaymentsDetailsByZone(fromDate, toDate, zone) : new ArrayList<>();
List<Object[]> hallbookingList = handleHallBookingRequest(request, fromDate, toDate, zone, hallId, filterby);
List<BookingDetails> bookingList = handleBookingRequest(request, fromDate, toDate, bookingStatus, zone,
filterby);
List<BookingDetails> bookingSettlementList = handleBookingSettlementRequest(request, fromDate, toDate,
refundStatus, zone, filterby);
List<Object[]> paymentList = request.equals("3")
? bookingService.getAllPaymentsDetailsByZone(fromDate, toDate, zone)
: new ArrayList<>();
List<Object[]> hallbookingList = handleHallBookingRequest(request, fromDate, toDate, zone, hallId,
filterby);
model.addAttribute("bookings", bookingList); model.addAttribute("bookings", bookingList);
model.addAttribute("bookingSettlementList", bookingSettlementList); model.addAttribute("bookingSettlementList", bookingSettlementList);
model.addAttribute("bookingStatus", bookingStatus); model.addAttribute("bookingStatus", bookingStatus);
@ -384,8 +407,8 @@ public class OfficerController {
} }
} }
private List<BookingDetails> handleBookingRequest(String request, String fromDate, String toDate, String bookingStatus, String zone, String filterby) {
private List<BookingDetails> handleBookingRequest(String request, String fromDate, String toDate,
String bookingStatus, String zone, String filterby) {
if (!request.equals("1")) { if (!request.equals("1")) {
return new ArrayList<>(); return new ArrayList<>();
} }
@ -393,7 +416,8 @@ public class OfficerController {
return bookingService.getAllBookingDetailsBookingDateByZone(fromDate, toDate, zone); return bookingService.getAllBookingDetailsBookingDateByZone(fromDate, toDate, zone);
} }
if (filterby.isEmpty() && !bookingStatus.isEmpty()) { if (filterby.isEmpty() && !bookingStatus.isEmpty()) {
return bookingService.getAllBookingDetailsBookingDateByZoneWithStatus(fromDate, toDate, zone, bookingStatus);
return bookingService.getAllBookingDetailsBookingDateByZoneWithStatus(fromDate, toDate, zone,
bookingStatus);
} }
if (!filterby.isEmpty()) { if (!filterby.isEmpty()) {
@ -401,7 +425,8 @@ public class OfficerController {
if (bookingStatus.isEmpty()) { if (bookingStatus.isEmpty()) {
return bookingService.getAllBookingDetailsBookingDateByZone(fromDate, toDate, zone); return bookingService.getAllBookingDetailsBookingDateByZone(fromDate, toDate, zone);
} else { } else {
return bookingService.getAllBookingDetailsBookingDateByZoneWithStatus(fromDate, toDate, zone, bookingStatus);
return bookingService.getAllBookingDetailsBookingDateByZoneWithStatus(fromDate, toDate, zone,
bookingStatus);
} }
@ -410,7 +435,8 @@ public class OfficerController {
if (bookingStatus.isEmpty()) { if (bookingStatus.isEmpty()) {
return bookingService.getAllBookingDetailsEventDateByZone(fromDate, toDate, zone); return bookingService.getAllBookingDetailsEventDateByZone(fromDate, toDate, zone);
} else { } else {
return bookingService.getAllBookingDetailsEventDateByZoneWithStatus(fromDate, toDate, zone, bookingStatus);
return bookingService.getAllBookingDetailsEventDateByZoneWithStatus(fromDate, toDate, zone,
bookingStatus);
} }
} }
@ -419,7 +445,8 @@ public class OfficerController {
return new ArrayList<>(); return new ArrayList<>();
} }
private List<BookingDetails> handleBookingSettlementRequest(String request, String fromDate, String toDate, String refundStatus, String zone, String filterby) {
private List<BookingDetails> handleBookingSettlementRequest(String request, String fromDate, String toDate,
String refundStatus, String zone, String filterby) {
if (!request.equals("2")) { if (!request.equals("2")) {
return new ArrayList<>(); return new ArrayList<>();
} }
@ -427,7 +454,8 @@ public class OfficerController {
return bookingService.getAllBookingsettlementDetailsByZoneByBookingDate(fromDate, toDate, zone); return bookingService.getAllBookingsettlementDetailsByZoneByBookingDate(fromDate, toDate, zone);
} }
if ((refundStatus != null && !refundStatus.isEmpty()) && filterby.isEmpty()) { if ((refundStatus != null && !refundStatus.isEmpty()) && filterby.isEmpty()) {
return bookingService.getAllBookingsettlementDetailsByZoneByBookingDateWithStatus(fromDate, toDate, zone, refundStatus);
return bookingService.getAllBookingsettlementDetailsByZoneByBookingDateWithStatus(fromDate, toDate, zone,
refundStatus);
} }
if (!filterby.isEmpty()) { if (!filterby.isEmpty()) {
@ -435,7 +463,8 @@ public class OfficerController {
if (refundStatus.isEmpty() || refundStatus == null) { if (refundStatus.isEmpty() || refundStatus == null) {
return bookingService.getAllBookingsettlementDetailsByZoneByBookingDate(fromDate, toDate, zone); return bookingService.getAllBookingsettlementDetailsByZoneByBookingDate(fromDate, toDate, zone);
} else { } else {
return bookingService.getAllBookingsettlementDetailsByZoneByBookingDateWithStatus(fromDate, toDate, zone, refundStatus);
return bookingService.getAllBookingsettlementDetailsByZoneByBookingDateWithStatus(fromDate, toDate,
zone, refundStatus);
} }
} }
@ -443,18 +472,19 @@ public class OfficerController {
if (refundStatus.isEmpty() || refundStatus == null) { if (refundStatus.isEmpty() || refundStatus == null) {
return bookingService.getAllBookingsettlementDetailsByZoneByEventDate(fromDate, toDate, zone); return bookingService.getAllBookingsettlementDetailsByZoneByEventDate(fromDate, toDate, zone);
} else { } else {
return bookingService.getAllBookingsettlementDetailsByZoneByEventDateWithStatus(fromDate, toDate, zone, refundStatus);
return bookingService.getAllBookingsettlementDetailsByZoneByEventDateWithStatus(fromDate, toDate,
zone, refundStatus);
} }
} }
} }
return new ArrayList<>(); return new ArrayList<>();
} }
private List<Object[]> handleHallBookingRequest(String request, String fromDate, String toDate, String zone, Integer hallId, String filterby) {
private List<Object[]> handleHallBookingRequest(String request, String fromDate, String toDate, String zone,
Integer hallId, String filterby) {
if (!request.equals("4")) { if (!request.equals("4")) {
return new ArrayList<>(); return new ArrayList<>();
} }
@ -462,19 +492,22 @@ public class OfficerController {
return bookingService.getBookingHallDetailsReportByZoneByBookingDate(fromDate, toDate, zone); return bookingService.getBookingHallDetailsReportByZoneByBookingDate(fromDate, toDate, zone);
} }
if (filterby.isEmpty() && hallId != 0) { if (filterby.isEmpty() && hallId != 0) {
return bookingService.getBookingHallDetailsReportByZoneByBookingDateHallname(fromDate, toDate, zone, hallId);
return bookingService.getBookingHallDetailsReportByZoneByBookingDateHallname(fromDate, toDate, zone,
hallId);
} }
if (!filterby.isEmpty()) { if (!filterby.isEmpty()) {
if ("1".equals(filterby)) { if ("1".equals(filterby)) {
if (hallId != 0) { if (hallId != 0) {
return bookingService.getBookingHallDetailsReportByZoneByBookingDateHallname(fromDate, toDate, zone, hallId);
return bookingService.getBookingHallDetailsReportByZoneByBookingDateHallname(fromDate, toDate, zone,
hallId);
} else { } else {
return bookingService.getBookingHallDetailsReportByZoneByBookingDate(fromDate, toDate, zone); return bookingService.getBookingHallDetailsReportByZoneByBookingDate(fromDate, toDate, zone);
} }
} }
if ("2".equals(filterby)) { if ("2".equals(filterby)) {
if (hallId != 0) { if (hallId != 0) {
return bookingService.getBookingHallDetailsReportByZoneByEventDateHallname(fromDate, toDate, zone, hallId);
return bookingService.getBookingHallDetailsReportByZoneByEventDateHallname(fromDate, toDate, zone,
hallId);
} else { } else {
return bookingService.getBookingHallDetailsReportByZoneByEventDate(fromDate, toDate, zone); return bookingService.getBookingHallDetailsReportByZoneByEventDate(fromDate, toDate, zone);
} }
@ -483,7 +516,6 @@ public class OfficerController {
return new ArrayList<>(); return new ArrayList<>();
} }
@GetMapping("/counter-refund") @GetMapping("/counter-refund")
public String counterRefundList(Model model, HttpSession session) { public String counterRefundList(Model model, HttpSession session) {
String officername = (String) session.getAttribute("usertype"); String officername = (String) session.getAttribute("usertype");
@ -509,4 +541,56 @@ public class OfficerController {
session.invalidate(); session.invalidate();
return "redirect:/communityhall/login"; return "redirect:/communityhall/login";
} }
// Newly added for zone level block
@GetMapping("/Gccblocking")
public String viewGccBlocking(Model model, HttpSession session) {
String officername = (String) session.getAttribute("usertype");
if (officername != null) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("officername", officername);
// Fetch all blocked GCC dates
List<GccBlockingDate> gccBlocked = blockingDateRepository.findAllBlocked();
// Ensure distinct by hallId, blockingReason, startDate, and endDate
List<GccBlockingDate> 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<Integer, Integer> hallCountMap = new HashMap<>();
for (GccBlockingDate blockedDate : uniqueGccBlockingDates) {
// Parse and count unique hall IDs
String hallIds = blockedDate.getHallId();
if (hallIds != null && !hallIds.isEmpty()) {
Set<String> uniqueHallIds = new HashSet<>(Arrays.asList(hallIds.split(",")));
int hallCount = uniqueHallIds.size();
hallCountMap.put(blockedDate.getBlockingId(), hallCount);
} else {
hallCountMap.put(blockedDate.getBlockingId(), 0); // No halls blocked
}
}
// Add attributes to the model for the view
model.addAttribute("gccblocked", uniqueGccBlockingDates);
model.addAttribute("hallCountMap", hallCountMap);
return "officer/gccblocking";
} else {
session.invalidate(); // Invalidate the session to clear all session attributes
return "redirect:/communityhall/login";
}
}
// Utility method to ensure distinct by a key
private static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
Set<Object> seen = new HashSet<>();
return t -> seen.add(keyExtractor.apply(t));
}
} }

692
src/main/java/com/gcc/communityHall/controller/UserAPIController.java
File diff suppressed because it is too large
View File

47
src/main/java/com/gcc/communityHall/controller/UserController.java

@ -2,6 +2,7 @@ package com.gcc.communityHall.controller;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -350,31 +351,63 @@ public class UserController {
@RequestParam(name = "bookingStatus", required = false) String bookingStatus) { @RequestParam(name = "bookingStatus", required = false) String bookingStatus) {
Integer userId = userSession.getUserId(); Integer userId = userSession.getUserId();
// Extract booking_ref_id per booking
Map<Integer, String> refIdMap = new HashMap<>();
model.addAttribute("userName", userSession.getDispayName()); model.addAttribute("userName", userSession.getDispayName());
model.addAttribute("counter", userSession.getCounter()); model.addAttribute("counter", userSession.getCounter());
model.addAttribute("counterName", userSession.getCounterName()); model.addAttribute("counterName", userSession.getCounterName());
// Fetch all past bookings // Fetch all past bookings
// List<Map<String, Object>> bookingPast =
// bookingService.getAllBookingEventsByUserId(userId);
// if (!bookingPast.isEmpty() || bookingPast.size() == 0) {
// for (Map<String, Object> row : bookingPast) {
// Integer bookingId = (Integer) row.get("booking_id");
// String refId = (String) row.get("booking_ref_id"); // <-- coming from SQL
// if (bookingId != null && refId != null) {
// refIdMap.put(bookingId, refId);
// }
// }
// System.out.println("Row keys: " + bookingPast.get(0).keySet());
// System.out.println("RefId Map123: " + refIdMap);
// }
// model.addAttribute("userBookingspast", bookingPast);
// model.addAttribute("bookingRefIds", refIdMap); // <-- SENT TO FRONTEND
// model.addAttribute("serverDate", LocalDate.now().toString());
List<Map<String, Object>> bookingPast = bookingService.getAllBookingEventsByUserId(userId); List<Map<String, Object>> bookingPast = bookingService.getAllBookingEventsByUserId(userId);
// Extract booking_ref_id per booking
Map<Integer, String> refIdMap = new HashMap<>();
if (bookingPast != null && !bookingPast.isEmpty()) {
for (Map<String, Object> row : bookingPast) { for (Map<String, Object> row : bookingPast) {
Integer bookingId = (Integer) row.get("booking_id");
String refId = (String) row.get("booking_ref_id"); // <-- coming from SQL
Integer bookingId = row.get("booking_id") != null
? ((Number) row.get("booking_id")).intValue()
: null;
String refId = row.get("booking_ref_id") != null
? row.get("booking_ref_id").toString()
: null;
if (bookingId != null && refId != null) { if (bookingId != null && refId != null) {
refIdMap.put(bookingId, refId); refIdMap.put(bookingId, refId);
} }
} }
System.out.println("Row keys: " + bookingPast.get(0).keySet()); System.out.println("Row keys: " + bookingPast.get(0).keySet());
System.out.println("RefId Map123: " + refIdMap);
System.out.println("RefId Map: " + refIdMap);
} else {
System.out.println("No past bookings found for userId: " + userId);
}
model.addAttribute("userBookingspast", bookingPast);
model.addAttribute("bookingRefIds", refIdMap); // <-- SENT TO FRONTEND
model.addAttribute("userBookingspast", bookingPast != null ? bookingPast : Collections.emptyList());
model.addAttribute("bookingRefIds", refIdMap);
model.addAttribute("serverDate", LocalDate.now().toString()); model.addAttribute("serverDate", LocalDate.now().toString());
return "user/viewhistory"; return "user/viewhistory";

22
src/main/java/com/gcc/communityHall/dto/EmployeeDetails.java

@ -13,6 +13,12 @@ public class EmployeeDetails {
@JsonProperty("Designation") @JsonProperty("Designation")
private String Designation; private String Designation;
@JsonProperty("Code")
private String Code;
@JsonProperty("RetirementDate")
private String RetirementDate;
public String getName() { public String getName() {
return name; return name;
} }
@ -37,6 +43,22 @@ public class EmployeeDetails {
Designation = designation; Designation = designation;
} }
public String getCode() {
return Code;
}
public void setCode(String code) {
Designation = code;
}
public String getRetirmentDate() {
return RetirementDate;
}
public void setRetirementDate(String retirementDate) {
RetirementDate = retirementDate;
}
} }

25
src/main/java/com/gcc/communityHall/entity/HallDetails.java

@ -4,6 +4,8 @@ import java.time.LocalDate;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.CascadeType; import jakarta.persistence.CascadeType;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
@ -85,6 +87,29 @@ public class HallDetails {
private float SGEdiscount; private float SGEdiscount;
private float CGEdiscount; private float CGEdiscount;
@Column(name = "is_reason_restricted", nullable = false, columnDefinition = "BOOLEAN DEFAULT false")
private boolean isReasonRestricted = false;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "hallDetails")
@JsonIgnore
private List<HallReasonRestriction> hallReasonRestrictions;
public boolean isReasonRestricted() {
return isReasonRestricted;
}
public void setReasonRestricted(boolean isReasonRestricted) {
this.isReasonRestricted = isReasonRestricted;
}
public List<HallReasonRestriction> getHallReasonRestrictions() {
return hallReasonRestrictions;
}
public void setHallReasonRestrictions(List<HallReasonRestriction> hallReasonRestrictions) {
this.hallReasonRestrictions = hallReasonRestrictions;
}
public int getHallId() { public int getHallId() {
return hallId; return hallId;
} }

68
src/main/java/com/gcc/communityHall/entity/HallReasonRestriction.java

@ -0,0 +1,68 @@
package com.gcc.communityHall.entity;
import java.time.LocalDate;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
@Entity
@Table(name = "hall_reason_restriction")
public class HallReasonRestriction {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "hall_id", nullable = false)
@JsonIgnore
private HallDetails hallDetails;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "reason_id", nullable = false)
private ReasonMaster reasonMaster;
@Column(name = "created_date")
private LocalDate createdDate = LocalDate.now();
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public HallDetails getHallDetails() {
return hallDetails;
}
public void setHallDetails(HallDetails hallDetails) {
this.hallDetails = hallDetails;
}
public ReasonMaster getReasonMaster() {
return reasonMaster;
}
public void setReasonMaster(ReasonMaster reasonMaster) {
this.reasonMaster = reasonMaster;
}
public LocalDate getCreatedDate() {
return createdDate;
}
public void setCreatedDate(LocalDate createdDate) {
this.createdDate = createdDate;
}
}

2
src/main/java/com/gcc/communityHall/paymentService/scheduler/PaymentStatusScheduler.java

@ -71,7 +71,7 @@ public class PaymentStatusScheduler {
// @Scheduled(cron = "0 0 0 * * ?", zone = "Asia/Kolkata") //executed at 12:00 AM // @Scheduled(cron = "0 0 0 * * ?", zone = "Asia/Kolkata") //executed at 12:00 AM
// @Scheduled(fixedRate = 900000) // @Scheduled(fixedRate = 900000)
@Scheduled(fixedRate = 30000)
@Scheduled(fixedRate = 60000)
public void fetchAndSavePaymentStatus() { public void fetchAndSavePaymentStatus() {
// System.out.println("Fetching Payment Status...At 12:00 AM IST"); // System.out.println("Fetching Payment Status...At 12:00 AM IST");
System.out.println("Fetching Payment Status...At 15 min Testing"); System.out.println("Fetching Payment Status...At 15 min Testing");

21
src/main/java/com/gcc/communityHall/repository/HallDetailsRepository.java

@ -25,19 +25,22 @@ public interface HallDetailsRepository extends JpaRepository<HallDetails,Integer
@Query("SELECT h FROM HallDetails h WHERE h.id = :hallId ") @Query("SELECT h FROM HallDetails h WHERE h.id = :hallId ")
HallDetails findHallDetailsById(@Param("hallId") int hallId); HallDetails findHallDetailsById(@Param("hallId") int hallId);
@Query("SELECT h FROM HallDetails h WHERE h.id = :hallId and h.isActive = true ")
HallDetails findHallActiveDetailsById(@Param("hallId") int hallId);
@Query(value = "SELECT zone,division FROM hall_details ",nativeQuery = true ) @Query(value = "SELECT zone,division FROM hall_details ",nativeQuery = true )
List<Map<String, Object>> getZoneAndDivision(); List<Map<String, Object>> getZoneAndDivision();
@Query(value = "SELECT DISTINCT division FROM hall_details where zone=:zone ",nativeQuery = true ) @Query(value = "SELECT DISTINCT division FROM hall_details where zone=:zone ",nativeQuery = true )
List<Map<String, Object>> getDivision(String zone); List<Map<String, Object>> getDivision(String zone);
@Query(value = "SELECT hall_id, hall_name FROM hall_details", nativeQuery = true)
@Query(value = "SELECT hall_id, hall_name FROM hall_details where is_active = 1 ", nativeQuery = true)
List<Map<String, Object>> getAllHalls(); List<Map<String, Object>> getAllHalls();
@Query(value = "SELECT hall_id, hall_name FROM hall_details WHERE zone = :zone", nativeQuery = true)
@Query(value = "SELECT hall_id, hall_name FROM hall_details WHERE zone = :zone and is_active = 1 ", nativeQuery = true)
List<Map<String, Object>> getHallsByZone(@Param("zone") String zone); List<Map<String, Object>> getHallsByZone(@Param("zone") String zone);
@Query(value = "SELECT hall_id AS hallId, hall_name AS hallName FROM hall_details WHERE zone IN (:zones)", nativeQuery = true)
@Query(value = "SELECT hall_id AS hallId, hall_name AS hallName FROM hall_details WHERE zone IN (:zones) and is_active = 1 ", nativeQuery = true)
List<Map<String, Object>> getHallsByZones(@Param("zones") List<String> zones); List<Map<String, Object>> getHallsByZones(@Param("zones") List<String> zones);
@Query(value = "SELECT * FROM hall_details WHERE is_active = 1 order by hall_name asc", nativeQuery = true) @Query(value = "SELECT * FROM hall_details WHERE is_active = 1 order by hall_name asc", nativeQuery = true)
@ -69,7 +72,7 @@ public interface HallDetailsRepository extends JpaRepository<HallDetails,Integer
"GROUP BY h.hall_id,h.zone,h.division,h.hall_name") "GROUP BY h.hall_id,h.zone,h.division,h.hall_name")
List<Map<String, Object>> getHallDetailsByZone(@Param("zone") String zone); List<Map<String, Object>> getHallDetailsByZone(@Param("zone") String zone);
@Query(value = "SELECT zone,division,hall_id,hall_name FROM hall_details ",nativeQuery = true )
@Query(value = "SELECT zone,division,hall_id,hall_name FROM hall_details where is_active = 1 ",nativeQuery = true )
List<Map<String, Object>> getZonesAndDivisions(); List<Map<String, Object>> getZonesAndDivisions();
@ -98,13 +101,19 @@ public interface HallDetailsRepository extends JpaRepository<HallDetails,Integer
"GROUP BY h.hall_id,h.zone,h.division,h.hall_name") "GROUP BY h.hall_id,h.zone,h.division,h.hall_name")
List<Map<String, Object>> getHallCountsForOfficer(@Param("zone") String zone); List<Map<String, Object>> getHallCountsForOfficer(@Param("zone") String zone);
@Query(value = "SELECT hall_name FROM hall_details WHERE hall_id = :hall_id", nativeQuery = true)
@Query(value = "SELECT hall_name FROM hall_details WHERE hall_id = :hall_id and is_active = 1 ", nativeQuery = true)
String findHallNameById(@Param("hall_id") int hallId); String findHallNameById(@Param("hall_id") int hallId);
@Query("SELECT DISTINCT h.division FROM HallDetails h WHERE h.zone = :zone ") @Query("SELECT DISTINCT h.division FROM HallDetails h WHERE h.zone = :zone ")
List<String> findDistinctDivisionsByZone(@Param("zone") String zone); List<String> findDistinctDivisionsByZone(@Param("zone") String zone);
// Query to get hall names by division // Query to get hall names by division
@Query("SELECT h.hallName FROM HallDetails h WHERE h.division = :division")
@Query("SELECT h.hallName FROM HallDetails h WHERE h.division = :division and h.isActive = true ")
List<String> findHallsByDivision(@Param("division") String division); List<String> findHallsByDivision(@Param("division") String division);
@Query("SELECT h FROM HallDetails h WHERE h.division = :division and h.isActive = true ")
List<HallDetails> findActiveHallsByDivision(@Param("division") String division);
@Query("SELECT h FROM HallDetails h WHERE h.zone = :zone and h.isActive = true ")
List<HallDetails> findActiveHallsByZone(@Param("zone") String zone);
} }

19
src/main/java/com/gcc/communityHall/repository/HallReasonRestrictionRepository.java

@ -0,0 +1,19 @@
package com.gcc.communityHall.repository;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import com.gcc.communityHall.entity.HallReasonRestriction;
@Repository
public interface HallReasonRestrictionRepository extends JpaRepository<HallReasonRestriction, Integer> {
List<HallReasonRestriction> findByHallDetails_HallId(int hallId);
@Query("SELECT r.reasonMaster.reasonId FROM HallReasonRestriction r WHERE r.hallDetails.hallId = :hallId")
List<Integer> findReasonIdsByHallId(@Param("hallId") int hallId);
}

1078
src/main/java/com/gcc/communityHall/service/Impl/BookingServiceImpl.java
File diff suppressed because it is too large
View File

46
src/main/java/com/gcc/communityHall/service/Impl/CounterServiceImpl.java

@ -35,6 +35,7 @@ import com.gcc.communityHall.repository.BookingDocumentsRepository;
import com.gcc.communityHall.repository.CounterDetailsRepository; import com.gcc.communityHall.repository.CounterDetailsRepository;
import com.gcc.communityHall.repository.CounterRefundListRepository; import com.gcc.communityHall.repository.CounterRefundListRepository;
import com.gcc.communityHall.repository.HallDetailsRepository; import com.gcc.communityHall.repository.HallDetailsRepository;
import com.gcc.communityHall.repository.HallReasonRestrictionRepository;
import com.gcc.communityHall.repository.HallImagesRepository; import com.gcc.communityHall.repository.HallImagesRepository;
import com.gcc.communityHall.service.CounterService; import com.gcc.communityHall.service.CounterService;
import com.gcc.communityHall.service.DiscountRangeService; import com.gcc.communityHall.service.DiscountRangeService;
@ -62,6 +63,8 @@ public class CounterServiceImpl implements CounterService {
@Autowired @Autowired
private DiscountRangeService discountRangeService; private DiscountRangeService discountRangeService;
@Autowired
private HallReasonRestrictionRepository hallReasonRestrictionRepository;
@Autowired @Autowired
private UserService userService; private UserService userService;
@ -95,7 +98,8 @@ public class CounterServiceImpl implements CounterService {
} }
@Override @Override
public CounterDetails saveCounterDetails(String bankName, int bankAccNo, int ddNumber, double amountReceived, MultipartFile counterddphoto, int bookingId) {
public CounterDetails saveCounterDetails(String bankName, int bankAccNo, int ddNumber, double amountReceived,
MultipartFile counterddphoto, int bookingId) {
BookingDetails bookingDetails = bookingDetailsRepository.findById(bookingId) BookingDetails bookingDetails = bookingDetailsRepository.findById(bookingId)
.orElseThrow(() -> new RuntimeException("Booking not found")); .orElseThrow(() -> new RuntimeException("Booking not found"));
@ -130,15 +134,26 @@ public class CounterServiceImpl implements CounterService {
return counterdetails.orElse(null); return counterdetails.orElse(null);
} }
@Override @Override
public Map<String, Object> saveCounterBooking(Map<String, Object> formData) { public Map<String, Object> saveCounterBooking(Map<String, Object> formData) {
Map<String, Object> response = new HashMap<>(); Map<String, Object> response = new HashMap<>();
BookingDetails bookingDetails = new BookingDetails(); BookingDetails bookingDetails = new BookingDetails();
ReasonMaster reasonMaster = reasonMasterService.getReasonById(Integer.parseInt(formData.get("reasonId").toString()));
ReasonMaster reasonMaster = reasonMasterService
.getReasonById(Integer.parseInt(formData.get("reasonId").toString()));
HallDetails hallDetails = hallDetailService.getHallById(Integer.parseInt(formData.get("hallId").toString())); HallDetails hallDetails = hallDetailService.getHallById(Integer.parseInt(formData.get("hallId").toString()));
Users user = userService.getUserById(userSession.getUserId()); Users user = userService.getUserById(userSession.getUserId());
// Validate reason restriction for this hall
if (hallDetails != null && hallDetails.isReasonRestricted()) {
java.util.List<Integer> allowedReasonIds = hallReasonRestrictionRepository
.findReasonIdsByHallId(hallDetails.getHallId());
if (!allowedReasonIds.isEmpty() && !allowedReasonIds.contains(reasonMaster.getReasonId())) {
response.put("status", "reason_restricted");
return response;
}
}
String bookingId = formData.get("bookingId").toString(); String bookingId = formData.get("bookingId").toString();
if (bookingId != null && bookingId.equals("0")) { if (bookingId != null && bookingId.equals("0")) {
bookingDetails = new BookingDetails(); bookingDetails = new BookingDetails();
@ -170,7 +185,8 @@ public class CounterServiceImpl implements CounterService {
double hallAmount = calcHallAmount(hallDetails, daysrange, startingSlot, endingSlot); double hallAmount = calcHallAmount(hallDetails, daysrange, startingSlot, endingSlot);
double discountAmount = 0; double discountAmount = 0;
String usertype = user.getUsertype().toString(); String usertype = user.getUsertype().toString();
if (usertype.equals("COUNCILLOR") || usertype.equals("PENSIONER") || usertype.equals("GCC_EMPLOYEE") || usertype.equals("PUBLIC")) {
if (usertype.equals("COUNCILLOR") || usertype.equals("PENSIONER") || usertype.equals("GCC_EMPLOYEE")
|| usertype.equals("PUBLIC")) {
discountAmount = (hallAmount * discount) / 100; discountAmount = (hallAmount * discount) / 100;
} }
hallAmount = hallAmount - discountAmount; hallAmount = hallAmount - discountAmount;
@ -179,15 +195,16 @@ public class CounterServiceImpl implements CounterService {
double totalAmount = hallAmount + gstAmount + bookingDetails.getDepositAmount(); double totalAmount = hallAmount + gstAmount + bookingDetails.getDepositAmount();
// BigDecimal roundedTotalAmount = new BigDecimal(totalAmount).setScale(0, RoundingMode.HALF_UP); // Round to nearest whole number
// BigDecimal roundedTotalAmount = new BigDecimal(totalAmount).setScale(0,
// RoundingMode.HALF_UP); // Round to nearest whole number
// Ensure two decimal places for display // Ensure two decimal places for display
// String formattedTotalAmount = String.format("%.2f", roundedTotalAmount.doubleValue());
// String formattedTotalAmount = String.format("%.2f",
// roundedTotalAmount.doubleValue());
// Print the result // Print the result
// System.out.println("Total Amount: " + formattedTotalAmount); // System.out.println("Total Amount: " + formattedTotalAmount);
bookingDetails.setHallAmount(hallAmount); bookingDetails.setHallAmount(hallAmount);
bookingDetails.setGst(gstAmount); bookingDetails.setGst(gstAmount);
bookingDetails.setNoOfDays(days); bookingDetails.setNoOfDays(days);
@ -201,7 +218,6 @@ public class CounterServiceImpl implements CounterService {
bookingDetails.setRefundStatus(BookingDetails.RefundStatus.WAITING); bookingDetails.setRefundStatus(BookingDetails.RefundStatus.WAITING);
bookingDetails.setBookingtype(BookingDetails.BookingType.OFFLINE); bookingDetails.setBookingtype(BookingDetails.BookingType.OFFLINE);
bookingDetails = bookingDetailsRepository.save(bookingDetails); bookingDetails = bookingDetailsRepository.save(bookingDetails);
response.put("bookingId", bookingDetails.getBookingId()); response.put("bookingId", bookingDetails.getBookingId());
@ -236,8 +252,10 @@ public class CounterServiceImpl implements CounterService {
if (reasonDocMaster.isAddDocumentField()) { if (reasonDocMaster.isAddDocumentField()) {
MultipartFile file = (MultipartFile) formData.get(reasonDocMaster.getDocFieldName()); MultipartFile file = (MultipartFile) formData.get(reasonDocMaster.getDocFieldName());
String fileName = bookingDetails.getBookingId() + "_" + file.getOriginalFilename(); String fileName = bookingDetails.getBookingId() + "_" + file.getOriginalFilename();
String filePath = uploadDirectory + "/" + reasonMaster.getReason().toLowerCase() + "/" + fileName;
bookingDocument.setBookingDocUrl(serverPath + "images/" + reasonMaster.getReason().toLowerCase() + "/" + fileName);
String filePath = uploadDirectory + "/" + reasonMaster.getReason().toLowerCase() + "/"
+ fileName;
bookingDocument.setBookingDocUrl(
serverPath + "images/" + reasonMaster.getReason().toLowerCase() + "/" + fileName);
bookingDocument.setDocumentName(file.getOriginalFilename()); bookingDocument.setDocumentName(file.getOriginalFilename());
bookingDocument.setDocumentType(file.getContentType()); bookingDocument.setDocumentType(file.getContentType());
try (FileOutputStream fos = new FileOutputStream(filePath)) { try (FileOutputStream fos = new FileOutputStream(filePath)) {
@ -261,7 +279,8 @@ public class CounterServiceImpl implements CounterService {
if (days == 1 && startingSlot == 1 && endingSlot == 2) { // full day if (days == 1 && startingSlot == 1 && endingSlot == 2) { // full day
hallAmount = hallDetails.getFullDayRent(); hallAmount = hallDetails.getFullDayRent();
} else if (days == 1 && (startingSlot == 1 && endingSlot == 1) || (startingSlot == 2 && endingSlot == 2)) { // half day
} else if (days == 1 && (startingSlot == 1 && endingSlot == 1) || (startingSlot == 2 && endingSlot == 2)) { // half
// day
hallAmount = hallDetails.getHalfDayRent(); hallAmount = hallDetails.getHalfDayRent();
} else if (days > 1) { } else if (days > 1) {
if (startingSlot == 2 && endingSlot == 1) { if (startingSlot == 2 && endingSlot == 1) {
@ -288,13 +307,13 @@ public class CounterServiceImpl implements CounterService {
return null; return null;
} }
public CounterRefundList saveCancellation(int counterId, MultipartFile letterdocs, String reason) throws IOException {
public CounterRefundList saveCancellation(int counterId, MultipartFile letterdocs, String reason)
throws IOException {
CounterRefundList counterRefundList = new CounterRefundList(); CounterRefundList counterRefundList = new CounterRefundList();
counterRefundList.setInitialisationStatus(CounterRefundList.InitialisationStatus.INITIATED); counterRefundList.setInitialisationStatus(CounterRefundList.InitialisationStatus.INITIATED);
counterRefundList.setReasonforCancelling(reason); counterRefundList.setReasonforCancelling(reason);
if (letterdocs != null && !letterdocs.isEmpty()) { if (letterdocs != null && !letterdocs.isEmpty()) {
try { try {
@ -312,7 +331,6 @@ public class CounterServiceImpl implements CounterService {
} }
} }
CounterDetails counterDetails = new CounterDetails(); CounterDetails counterDetails = new CounterDetails();
counterDetails.setCounterId(counterId); counterDetails.setCounterId(counterId);
counterRefundList.setCounterDetails(counterDetails); counterRefundList.setCounterDetails(counterDetails);

47
src/main/resources/templates/admin/gccblocking.html

@ -319,11 +319,11 @@
<div class="row"> <div class="row">
<div class="col-sm"> <div class="col-sm">
<label for="fromDate">From Date:</label> <label for="fromDate">From Date:</label>
<input type="date" class="form-control" id="fromDate" name="fromDate">
<input type="date" class="form-control" id="fromDate" name="fromDate" required>
</div> </div>
<div class="col-sm"> <div class="col-sm">
<label for="toDate">To Date:</label> <label for="toDate">To Date:</label>
<input type="date" class="form-control" id="toDate" name="toDate">
<input type="date" class="form-control" id="toDate" name="toDate" required>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
@ -338,7 +338,7 @@
<div class="col-sm-4"> <div class="col-sm-4">
<label for="uploadDocument0">Upload document</label> <label for="uploadDocument0">Upload document</label>
<input type="file" class="form-control uploadDocument" id="uploadDocument0" <input type="file" class="form-control uploadDocument" id="uploadDocument0"
name="document">
name="document" required>
</div> </div>
<div class="col-sm-4"> <div class="col-sm-4">
<label for="description0">Description</label> <label for="description0">Description</label>
@ -771,6 +771,12 @@
var toDate = $("#toDate").val(); var toDate = $("#toDate").val();
var reasonForBlocking = $("#reasonforBlocking").val(); var reasonForBlocking = $("#reasonforBlocking").val();
var uploadDocument = document.getElementById('uploadDocument0');
if (!uploadDocument.files || uploadDocument.files.length === 0) {
Swal.fire('Error!', 'Please upload a document.', 'error');
return;
}
// Validate required inputs // Validate required inputs
if (!reasonForBlocking.trim()) { if (!reasonForBlocking.trim()) {
Swal.fire({ Swal.fire({
@ -791,14 +797,14 @@
var allCheckboxes = $("#bookingTableBody input[type='checkbox']"); // Get all checkboxes var allCheckboxes = $("#bookingTableBody input[type='checkbox']"); // Get all checkboxes
var selectedCheckboxes = $("#bookingTableBody input[type='checkbox']:checked"); // Get all checked checkboxes var selectedCheckboxes = $("#bookingTableBody input[type='checkbox']:checked"); // Get all checked checkboxes
if (allCheckboxes.length !== selectedCheckboxes.length) {
/* if (allCheckboxes.length !== selectedCheckboxes.length) {
Swal.fire({ Swal.fire({
icon: "warning", icon: "warning",
title: "Incomplete Selection", title: "Incomplete Selection",
text: "Please select all checkboxes before blocking.", text: "Please select all checkboxes before blocking.",
}); });
return; // Stop further execution return; // Stop further execution
}
}*/
// Get selected checkboxes and their values and additional values // Get selected checkboxes and their values and additional values
var selectedBookings = Array.from(document.querySelectorAll('#bookingTableBody input[type="checkbox"]:checked')) var selectedBookings = Array.from(document.querySelectorAll('#bookingTableBody input[type="checkbox"]:checked'))
@ -997,6 +1003,9 @@
function getBlockedevents() { function getBlockedevents() {
var selectedZones = Array.from(document.querySelectorAll('#zoneSelectOptions input[type="checkbox"]:checked'))
.map(cb => cb.value);
var selectedHalls = Array.from(document.querySelectorAll('#hallSelectOptions input[type="checkbox"]:checked')) var selectedHalls = Array.from(document.querySelectorAll('#hallSelectOptions input[type="checkbox"]:checked'))
.map(cb => cb.value) .map(cb => cb.value)
.filter(value => !isNaN(value)); // Filter out non-numeric values .filter(value => !isNaN(value)); // Filter out non-numeric values
@ -1004,13 +1013,29 @@
var fromDate = $("#fromDate").val(); var fromDate = $("#fromDate").val();
var toDate = $("#toDate").val(); var toDate = $("#toDate").val();
var reasonforBlocking = $("#reasonforBlocking").val(); var reasonforBlocking = $("#reasonforBlocking").val();
if (!reasonforBlocking) {
Swal.fire(
'Error!',
'Reason For Blocking is required.',
'error'
);
// Validate all mandatory fields
if (!selectedZones || selectedZones.length === 0) {
Swal.fire('Error!', 'Please select at least one Zone.', 'error');
return;
} }
if (!selectedHalls || selectedHalls.length === 0) {
Swal.fire('Error!', 'Please select at least one Hall.', 'error');
return;
}
if (!fromDate) {
Swal.fire('Error!', 'From Date is required.', 'error');
return;
}
if (!toDate) {
Swal.fire('Error!', 'To Date is required.', 'error');
return;
}
if (!reasonforBlocking || !reasonforBlocking.trim()) {
Swal.fire('Error!', 'Reason For Blocking is required.', 'error');
return;
}
$.ajax({ $.ajax({
url: '/communityhall/admin/api/blockedevents', url: '/communityhall/admin/api/blockedevents',
type: 'GET', type: 'GET',

106
src/main/resources/templates/counter/counter-booking.html

@ -1057,9 +1057,8 @@
<label for="mobileno">Aadhar Number:<span <label for="mobileno">Aadhar Number:<span
class="required-field">*</span></label> class="required-field">*</span></label>
<input type="text" class="form-control" id="aadharnumber" <input type="text" class="form-control" id="aadharnumber"
name="aadharnumber"
placeholder="Aadhar No" minlength="12" maxlength="12"
pattern="[0-9]{12}"
name="aadharnumber" placeholder="Aadhar No" minlength="12"
maxlength="12" pattern="[0-9]{12}"
onkeypress="return event.charCode >= 48 && event.charCode <= 57" onkeypress="return event.charCode >= 48 && event.charCode <= 57"
required> required>
</div> </div>
@ -1322,12 +1321,9 @@
<p>Zone: <span id="zone"></span></p> <p>Zone: <span id="zone"></span></p>
<p>Address: <span id="address"></span></p> <p>Address: <span id="address"></span></p>
<p>Landmark: <span id="landmark"></span></p> <p>Landmark: <span id="landmark"></span></p>
<p>Total Area: <span
id="hallareainsqft"></span></p>
<p>Seating Capacity: <span
id="seatingCapacity"></span></p>
<p>Parking Capacity: <span
id="parkingCapacity"></span></p>
<p>Total Area: <span id="hallareainsqft"></span></p>
<p>Seating Capacity: <span id="seatingCapacity"></span></p>
<p>Parking Capacity: <span id="parkingCapacity"></span></p>
<input type="hidden" id="statichallId"> <input type="hidden" id="statichallId">
</div> </div>
</div> </div>
@ -1353,21 +1349,15 @@
<div id="amountDetails"> <div id="amountDetails">
<br> <br>
<h6><b>Amount Details:</b></h6> <h6><b>Amount Details:</b></h6>
<p>Security Deposit: Rs <span
id="rentAmount"></span></p>
<p>Full Day Rent: Rs <span
id="fullDayAmount"></span></p>
<p>Half Day Rent: Rs <span
id="halfDayAmount"></span></p>
<p>Security Deposit: Rs <span id="rentAmount"></span></p>
<p>Full Day Rent: Rs <span id="fullDayAmount"></span></p>
<p>Half Day Rent: Rs <span id="halfDayAmount"></span></p>
<p>GST: <span id="gst"></span>%</p> <p>GST: <span id="gst"></span>%</p>
<p>EB for 1 Unit:* Rs <span
id="ebunit"></span></p>
<p>CareTaker Number: <span
id="caretakerNumber"></span></p>
<input type="hidden" id="depositAmount"
name="depositamount" value="100">
<input type="hidden" id="hallamount"
name="hallamount" value="100">
<p>EB for 1 Unit:* Rs <span id="ebunit"></span></p>
<p>CareTaker Number: <span id="caretakerNumber"></span></p>
<input type="hidden" id="depositAmount" name="depositamount"
value="100">
<input type="hidden" id="hallamount" name="hallamount" value="100">
</div> </div>
</div> </div>
</div> </div>
@ -1428,8 +1418,7 @@
</span> </span>
</div> </div>
<div class="col col-lg-2 col-sm-2 col-md-2"> <div class="col col-lg-2 col-sm-2 col-md-2">
<button type="button"
class="btn btn-primary btn-square-md"
<button type="button" class="btn btn-primary btn-square-md"
style="background-color: blue"></button> style="background-color: blue"></button>
<p style="margin-left:-1px;">Gcc <p style="margin-left:-1px;">Gcc
Blocked</p> Blocked</p>
@ -1500,8 +1489,7 @@
</div>--> </div>-->
<div class="col-sm-4 col-lg-6 col-md-4"> <div class="col-sm-4 col-lg-6 col-md-4">
<label>Relationship of the Functionary:*</label> <label>Relationship of the Functionary:*</label>
<select id="relation" name="relation"
class="form-control"
<select id="relation" name="relation" class="form-control"
onchange="validateForm()" required> onchange="validateForm()" required>
<option value="0">Select</option> <option value="0">Select</option>
<option value="self">Self</option> <option value="self">Self</option>
@ -1519,9 +1507,8 @@
<div class="col-sm-4 col-lg-6 col-md-4"> <div class="col-sm-4 col-lg-6 col-md-4">
<label>Reason for <label>Reason for
Booking:*</label> Booking:*</label>
<select type="text" class="form-control"
id="reasonforbooking" name="reasonId"
required>
<select type="text" class="form-control" id="reasonforbooking"
name="reasonId" required>
</select> </select>
</div> </div>
<br> <br>
@ -1533,16 +1520,13 @@
<div class="col-sm-4 col-lg-6 col-md-4"> <div class="col-sm-4 col-lg-6 col-md-4">
<label for="startDateInput">Start Date:*</label> <label for="startDateInput">Start Date:*</label>
<!-- Input field for start date --> <!-- Input field for start date -->
<input type="text" id="startDateInput"
name="startDate"
class="date-input form-control"
style="background-color:white" readonly
<input type="text" id="startDateInput" name="startDate"
class="date-input form-control" style="background-color:white" readonly
required> required>
</div> </div>
<div class="col-sm-4 col-lg-6 col-md-4"> <div class="col-sm-4 col-lg-6 col-md-4">
<label for="endDateInput">End Date:*</label> <label for="endDateInput">End Date:*</label>
<select id="endDateInput" name="endDate"
class="form-control" disabled>
<select id="endDateInput" name="endDate" class="form-control" disabled>
<option value="0">Select</option> <option value="0">Select</option>
</select> </select>
</div> </div>
@ -1550,17 +1534,14 @@
<br> <br>
<br> <br>
<br> <br>
<input type="hidden" id="numDaysCount" val=""
name="days">
<input type="hidden" id="noofdaysbetweenstartend"
val="" name="daysrange">
<input type="hidden" id="numDaysCount" val="" name="days">
<input type="hidden" id="noofdaysbetweenstartend" val="" name="daysrange">
<div class="col-sm-4 col-lg-6 col-md-4"> <div class="col-sm-4 col-lg-6 col-md-4">
<label for="startPeriodDropdown">Start <label for="startPeriodDropdown">Start
Period:*</label> Period:*</label>
<select id="startPeriodDropdown"
name="startingSlot" class="form-control"
<select id="startPeriodDropdown" name="startingSlot" class="form-control"
required> required>
<option value="0">Select</option> <option value="0">Select</option>
<option value="1">Morning (6:00 <option value="1">Morning (6:00
@ -1574,8 +1555,8 @@
<div class="col-sm-4 col-lg-6 col-md-4"> <div class="col-sm-4 col-lg-6 col-md-4">
<label>End <label>End
Period:*</label> Period:*</label>
<select id="endPeriodDropdown" name="endingSlot"
class="form-control" required>
<select id="endPeriodDropdown" name="endingSlot" class="form-control"
required>
<option value="0">Select</option> <option value="0">Select</option>
<option value="1">Afternoon (2:00 <option value="1">Afternoon (2:00
PM) PM)
@ -1593,8 +1574,7 @@
<div class="col-sm-4 col-lg-6 col-md-4"> <div class="col-sm-4 col-lg-6 col-md-4">
<label for="numDaysCountDisplay">Selected <label for="numDaysCountDisplay">Selected
Slots:</label> Slots:</label>
<textarea type="text" id="numDaysCountDisplay"
class="form-control" readonly
<textarea type="text" id="numDaysCountDisplay" class="form-control" readonly
style="background-color:white"></textarea> style="background-color:white"></textarea>
</div> </div>
<div class="col-sm-4 col-lg-6 col-md-4"> <div class="col-sm-4 col-lg-6 col-md-4">
@ -1605,21 +1585,17 @@
</div> </div>
<br> <br>
<div class="row"> <div class="row">
<div
class="col-md-12 col-lg-12 col-sm-12 text-center">
<div class="col-md-12 col-lg-12 col-sm-12 text-center">
<!-- Center align the button --> <!-- Center align the button -->
<button type="button"
class="btn btn-primary prev-step"
<button type="button" class="btn btn-primary prev-step"
style="background-color: #016d6f; color: white;float: left;"> style="background-color: #016d6f; color: white;float: left;">
Previous Previous
</button> </button>
<button type="button"
class="btn btn-warning reset-step"
<button type="button" class="btn btn-warning reset-step"
style=" background-color: orangered; color: white; margin: auto;"> style=" background-color: orangered; color: white; margin: auto;">
Reset Reset
</button> </button>
<button type="button"
class="btn btn-primary next-step"
<button type="button" class="btn btn-primary next-step"
style="background-color: #016d6f; color: white; float: right;"> style="background-color: #016d6f; color: white; float: right;">
Next Next
</button> </button>
@ -1882,7 +1858,8 @@
<b>No <b>No
Objection Certificate from the Police Department</b> concerned Objection Certificate from the Police Department</b> concerned
jurisdiction jurisdiction
of the community hall.</td>
of the community hall.
</td>
</tr> </tr>
<tr> <tr>
<td>7</td> <td>7</td>
@ -2387,10 +2364,15 @@
}); });
}*/ }*/
function fetchReasonsAndPopulateDropdown() {
// Make an AJAX call to fetch all reasons
function fetchReasonsAndPopulateDropdown(hallId) {
// Build URL: use getAllowedReasons if hallId is provided, otherwise getReasons
var apiUrl = '/communityhall/admin/api/getReasons';
if (hallId && hallId != '0' && hallId != '') {
apiUrl = '/communityhall/admin/api/getAllowedReasons?hallId=' + hallId;
}
// Make an AJAX call to fetch reasons
$.ajax({ $.ajax({
url: '/communityhall/admin/api/getReasons',
url: apiUrl,
type: 'GET', type: 'GET',
dataType: 'json' dataType: 'json'
}) })
@ -2399,6 +2381,11 @@
reasonDropdown.empty(); reasonDropdown.empty();
reasonDropdown.append($('<option selected value="0"></option>').text('Select a reason')); reasonDropdown.append($('<option selected value="0"></option>').text('Select a reason'));
// Clear previous metadata
reasonMaxData.clear();
reasonLabelData.clear();
reasoncode.clear();
// Populate the dropdown and store reason metadata // Populate the dropdown and store reason metadata
$.each(data, function (index, reason) { $.each(data, function (index, reason) {
reasonDropdown.append($('<option></option>').attr('value', reason.reasonId).text(reason.reason)); reasonDropdown.append($('<option></option>').attr('value', reason.reasonId).text(reason.reason));
@ -2827,6 +2814,9 @@
$('#ebunit').html('<strong>' + response.ebCostPerUnit + '</strong>'); $('#ebunit').html('<strong>' + response.ebCostPerUnit + '</strong>');
$('#statichallId').val(response.hallId); $('#statichallId').val(response.hallId);
// Refresh the reason dropdown based on the selected hall's restrictions
fetchReasonsAndPopulateDropdown(response.hallId);
// Set hall images // Set hall images
var carouselInner = $('#hallImagesCarousel .carousel-inner'); var carouselInner = $('#hallImagesCarousel .carousel-inner');
carouselInner.empty(); // Clear existing images carouselInner.empty(); // Clear existing images

6
src/main/resources/templates/fragments/menuOfficer.html

@ -60,6 +60,12 @@
<span class="nav-main-link-name">Payment List</span> <span class="nav-main-link-name">Payment List</span>
</a> </a>
</li> </li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/headquarters/Gccblocking">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">Gcc Blocking</span>
</a>
</li>
<li class="nav-main-item"> <li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/officer/reports"> <a class="nav-main-link" href="/communityhall/officer/reports">
<i class="nav-main-link-icon fa fa-location-arrow"></i> <i class="nav-main-link-icon fa fa-location-arrow"></i>

43
src/main/resources/templates/headquarters/gccblocking.html

@ -319,11 +319,11 @@
<div class="row"> <div class="row">
<div class="col-sm"> <div class="col-sm">
<label for="fromDate">From Date:</label> <label for="fromDate">From Date:</label>
<input type="date" class="form-control" id="fromDate" name="fromDate">
<input type="date" class="form-control" id="fromDate" name="fromDate" required>
</div> </div>
<div class="col-sm"> <div class="col-sm">
<label for="toDate">To Date:</label> <label for="toDate">To Date:</label>
<input type="date" class="form-control" id="toDate" name="toDate">
<input type="date" class="form-control" id="toDate" name="toDate" required>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
@ -338,7 +338,7 @@
<div class="col-sm-4"> <div class="col-sm-4">
<label for="uploadDocument0">Upload document</label> <label for="uploadDocument0">Upload document</label>
<input type="file" class="form-control uploadDocument" id="uploadDocument0" <input type="file" class="form-control uploadDocument" id="uploadDocument0"
name="document">
name="document" required>
</div> </div>
<div class="col-sm-4"> <div class="col-sm-4">
<label for="description0">Description</label> <label for="description0">Description</label>
@ -773,6 +773,12 @@
var toDate = $("#toDate").val(); var toDate = $("#toDate").val();
var reasonForBlocking = $("#reasonforBlocking").val(); var reasonForBlocking = $("#reasonforBlocking").val();
var uploadDocument = document.getElementById('uploadDocument0');
if (!uploadDocument.files || uploadDocument.files.length === 0) {
Swal.fire('Error!', 'Please upload a document.', 'error');
return;
}
// Validate required inputs // Validate required inputs
if (!reasonForBlocking.trim()) { if (!reasonForBlocking.trim()) {
Swal.fire({ Swal.fire({
@ -999,6 +1005,9 @@
function getBlockedevents() { function getBlockedevents() {
var selectedZones = Array.from(document.querySelectorAll('#zoneSelectOptions input[type="checkbox"]:checked'))
.map(cb => cb.value);
var selectedHalls = Array.from(document.querySelectorAll('#hallSelectOptions input[type="checkbox"]:checked')) var selectedHalls = Array.from(document.querySelectorAll('#hallSelectOptions input[type="checkbox"]:checked'))
.map(cb => cb.value) .map(cb => cb.value)
.filter(value => !isNaN(value)); // Filter out non-numeric values .filter(value => !isNaN(value)); // Filter out non-numeric values
@ -1006,13 +1015,29 @@
var fromDate = $("#fromDate").val(); var fromDate = $("#fromDate").val();
var toDate = $("#toDate").val(); var toDate = $("#toDate").val();
var reasonforBlocking = $("#reasonforBlocking").val(); var reasonforBlocking = $("#reasonforBlocking").val();
if (!reasonforBlocking) {
Swal.fire(
'Error!',
'Reason For Blocking is required.',
'error'
);
// Validate all mandatory fields
if (!selectedZones || selectedZones.length === 0) {
Swal.fire('Error!', 'Please select at least one Zone.', 'error');
return;
} }
if (!selectedHalls || selectedHalls.length === 0) {
Swal.fire('Error!', 'Please select at least one Hall.', 'error');
return;
}
if (!fromDate) {
Swal.fire('Error!', 'From Date is required.', 'error');
return;
}
if (!toDate) {
Swal.fire('Error!', 'To Date is required.', 'error');
return;
}
if (!reasonforBlocking || !reasonforBlocking.trim()) {
Swal.fire('Error!', 'Reason For Blocking is required.', 'error');
return;
}
$.ajax({ $.ajax({
url: '/communityhall/admin/api/blockedevents', url: '/communityhall/admin/api/blockedevents',
type: 'GET', type: 'GET',

1412
src/main/resources/templates/officer/gccblocking.html
File diff suppressed because it is too large
View File

2
src/main/resources/templates/user/communityHallList.html

@ -183,7 +183,7 @@
<div id="listContent" style="display: none;"> <div id="listContent" style="display: none;">
<h4>List of Community Centers</h4> <h4>List of Community Centers</h4>
<iframe src="media/images/Community_Centers_list.pdf"
<iframe src="https://gccservices.in/communityhall/images/webfiles/Community_Centers_list.pdf"
width="100%" height="600px"></iframe> width="100%" height="600px"></iframe>
</div> </div>
<div id="map" style="display:none"> <div id="map" style="display:none">

158
src/main/resources/templates/user/hallbookingform.html

@ -1924,10 +1924,15 @@
displayStep(3); displayStep(3);
}); });
function fetchReasonsAndPopulateDropdown() {
// Make an AJAX call to fetch all reasons
function fetchReasonsAndPopulateDropdown(hallId) {
// Build URL: use getAllowedReasons if hallId is provided, otherwise getReasons
var apiUrl = '/communityhall/admin/api/getReasons';
if (hallId && hallId != '0' && hallId != '') {
apiUrl = '/communityhall/admin/api/getAllowedReasons?hallId=' + hallId;
}
// Make an AJAX call to fetch reasons
$.ajax({ $.ajax({
url: '/communityhall/admin/api/getReasons',
url: apiUrl,
type: 'GET', type: 'GET',
dataType: 'json' dataType: 'json'
}) })
@ -1936,6 +1941,11 @@
reasonDropdown.empty(); reasonDropdown.empty();
reasonDropdown.append($('<option selected value="0"></option>').text('Select a reason')); reasonDropdown.append($('<option selected value="0"></option>').text('Select a reason'));
// Clear previous metadata
reasonMaxData.clear();
reasonLabelData.clear();
reasoncode.clear();
// Populate the dropdown and store reason metadata // Populate the dropdown and store reason metadata
$.each(data, function (index, reason) { $.each(data, function (index, reason) {
reasonDropdown.append($('<option></option>').attr('value', reason.reasonId).text(reason.reason)); reasonDropdown.append($('<option></option>').attr('value', reason.reasonId).text(reason.reason));
@ -2677,7 +2687,10 @@
type: 'GET', type: 'GET',
url: '/communityhall/user/api/gethalldetails/' + hallId, url: '/communityhall/user/api/gethalldetails/' + hallId,
success: function (response) { success: function (response) {
// console.log(response);
console.log("hall response: " + response);
if (response) {
// Display the container // Display the container
$('#hallDetailsContainer').show(); $('#hallDetailsContainer').show();
@ -2698,6 +2711,9 @@
$('#ebunit').html('<strong>' + response.ebCostPerUnit + '</strong>'); $('#ebunit').html('<strong>' + response.ebCostPerUnit + '</strong>');
$('#statichallId').val(response.hallId); $('#statichallId').val(response.hallId);
// Refresh the reason dropdown based on the selected hall's restrictions
fetchReasonsAndPopulateDropdown(response.hallId);
// Set hall images // Set hall images
var carouselInner = $('#hallImagesCarousel .carousel-inner'); var carouselInner = $('#hallImagesCarousel .carousel-inner');
carouselInner.empty(); // Clear existing images carouselInner.empty(); // Clear existing images
@ -2740,10 +2756,24 @@
$('#zoneStep3').text(response.zone); $('#zoneStep3').text(response.zone);
$('#divisionStep2').text(response.division); $('#divisionStep2').text(response.division);
$('#divisionStep3').text(response.division); $('#divisionStep3').text(response.division);
}
else {
// Hide the container if no response
$('#hallDetailsContainer').hide();
Swal.fire({
icon: 'error',
title: 'Not Found!',
text: "Hall Details Not Found for the selected Hall.",
})
}
}, },
error: function (xhr, status, error) { error: function (xhr, status, error) {
// alert("Error fetching hall details. Please try again later. Error: " + error);
window.location.href = "/communityhall/";
console.error('Error fetching hall details:', error); console.error('Error fetching hall details:', error);
} }
}); });
} }
@ -3407,68 +3437,68 @@
timerElement.innerHTML = "Timer Stopped"; // Optionally update the message timerElement.innerHTML = "Timer Stopped"; // Optionally update the message
} }
(function () {
function block(e) {
e.preventDefault();
e.stopPropagation();
return false;
}
// Disable right‑click
window.addEventListener('contextmenu', block, true);
// 2) Disable drag (images/text) — optional
// window.addEventListener('dragstart', block, true);
// 3) Disable common DevTools / view‑source shortcuts
window.addEventListener('keydown', function (e) {
// Normalize: e.key is a string like 'F12' or 'I'; keyCode is a number (deprecated but useful for older browsers)
var key = e.key;
var code = e.keyCode || e.which;
// F12 (DevTools)
if (key === 'F12' || code === 123) return block(e);
// Ctrl+Shift+I/J/C (DevTools / Inspect / Console)
if (e.ctrlKey && e.shiftKey && (key === 'I' || key === 'J' || key === 'C' || code === 73 || code === 74 || code === 67)) return block(e);
// Ctrl+U (view source)
if (e.ctrlKey && (key === 'u' || key === 'U' || code === 85)) return block(e);
// Ctrl+S (save page)
if (e.ctrlKey && (key === 's' || key === 'S' || code === 83)) return block(e);
// Firefox specific shortcuts
// Ctrl+Shift+K opens Web Console
if (e.ctrlKey && e.shiftKey && (key === 'K' || code === 75)) return block(e);
// Ctrl+Shift+E opens Network Monitor
if (e.ctrlKey && e.shiftKey && (key === 'E' || code === 69)) return block(e);
}, true);
let threshold = 160;
setInterval(function () {
if (window.outerHeight - window.innerHeight > threshold ||
window.outerWidth - window.innerWidth > threshold) {
document.body.innerHTML = "<h1 style='color:red;text-align:center;margin-top:20%'>DevTools detected. Page disabled.</h1>";
}
}, 500);
})();
// (function () {
function showToast(msg) {
var toast = document.getElementById("toast");
toast.textContent = msg;
toast.className = "show";
setTimeout(function () {
toast.className = toast.className.replace("show", "");
}, 2500);
}
// function block(e) {
// e.preventDefault();
// e.stopPropagation();
// return false;
// }
// // Disable right‑click
// window.addEventListener('contextmenu', block, true);
// // 2) Disable drag (images/text) — optional
// // window.addEventListener('dragstart', block, true);
// // 3) Disable common DevTools / view‑source shortcuts
// window.addEventListener('keydown', function (e) {
// // Normalize: e.key is a string like 'F12' or 'I'; keyCode is a number (deprecated but useful for older browsers)
// var key = e.key;
// var code = e.keyCode || e.which;
// // F12 (DevTools)
// if (key === 'F12' || code === 123) return block(e);
// // Ctrl+Shift+I/J/C (DevTools / Inspect / Console)
// if (e.ctrlKey && e.shiftKey && (key === 'I' || key === 'J' || key === 'C' || code === 73 || code === 74 || code === 67)) return block(e);
// // Ctrl+U (view source)
// if (e.ctrlKey && (key === 'u' || key === 'U' || code === 85)) return block(e);
// // Ctrl+S (save page)
// if (e.ctrlKey && (key === 's' || key === 'S' || code === 83)) return block(e);
// // Firefox specific shortcuts
// // Ctrl+Shift+K opens Web Console
// if (e.ctrlKey && e.shiftKey && (key === 'K' || code === 75)) return block(e);
// // Ctrl+Shift+E opens Network Monitor
// if (e.ctrlKey && e.shiftKey && (key === 'E' || code === 69)) return block(e);
// }, true);
// let threshold = 160;
// setInterval(function () {
// if (window.outerHeight - window.innerHeight > threshold ||
// window.outerWidth - window.innerWidth > threshold) {
// document.body.innerHTML = "<h1 style='color:red;text-align:center;margin-top:20%'>DevTools detected. Page disabled.</h1>";
// }
// }, 500);
// })();
// function showToast(msg) {
// var toast = document.getElementById("toast");
// toast.textContent = msg;
// toast.className = "show";
// setTimeout(function () {
// toast.className = toast.className.replace("show", "");
// }, 2500);
// }
$(document).on("contextmenu",
"#ui-datepicker-div td, #ui-datepicker-div a, #ui-datepicker-div .ui-datepicker-title", function (e) {
e.preventDefault();
showToast("Right-click disabled");
return false;
});
// $(document).on("contextmenu",
// "#ui-datepicker-div td, #ui-datepicker-div a, #ui-datepicker-div .ui-datepicker-title", function (e) {
// e.preventDefault();
// showToast("Right-click disabled");
// return false;
// });
</script> </script>
</body> </body>

1
src/main/resources/templates/user/viewhallform.html

@ -1380,6 +1380,7 @@
}, },
error: function (xhr, status, error) { error: function (xhr, status, error) {
window.location.href = "/communityhall/";
console.error('Error fetching hall details:', error); console.error('Error fetching hall details:', error);
} }
}); });

68
src/main/resources/templates/user/viewhistory.html

@ -1514,8 +1514,12 @@
<div class="mb-3 text-center"> <div class="mb-3 text-center">
<div id="rescheduleResendContainer"> <div id="rescheduleResendContainer">
<p class="mb-0">Didn't receive OTP?</p> <p class="mb-0">Didn't receive OTP?</p>
<p class="mb-0 text-info" id="rescheduleResendLink">Please wait..<span
id="rescheduleCountdown">60</span>s</p>
<!-- <p class="mb-0 text-info" id="rescheduleResendLink">Please wait..<span
id="rescheduleCountdown">60</span>s</p> -->
<p class="mb-0 text-info">
<span id="rescheduleResendText">Please wait..</span>
<span id="rescheduleCountdown">60</span>s
</p>
</div> </div>
</div> </div>
</div> </div>
@ -2836,6 +2840,9 @@
}); });
} }
var rescheduleTimer = null;
var RESCHEDULE_TIME = 60;
function sendRescheduleOTP(mobileNumber) { function sendRescheduleOTP(mobileNumber) {
$.ajax({ $.ajax({
type: "GET", type: "GET",
@ -2859,29 +2866,56 @@
}); });
} }
// function startRescheduleCountdown() {
// var resendTimeout;
// var resendLink = $("#rescheduleResendLink");
// $("#rescheduleResendLink").html('<a href="#" id="rescheduleResendLink" class="text-info" onclick="return resendRescheduleOTP();">Resend OTP</a>');
// var countdown = $("#rescheduleCountdown");
// function startCountdown() {
// var timeleft = 60;
// countdown.text(timeleft);
// resendTimeout = setInterval(function () {
// timeleft--;
// countdown.text(timeleft);
// if (timeleft <= 0) {
// clearInterval(resendTimeout);
// $("#rescheduleResendLink").html('<a href="#" id="rescheduleResendLink" class="text-info" onclick="return sendRescheduleOTP(' + rescheduleMobileNumber + ');">Resend OTP</a>');
// }
// }, 1000);
// }
// startCountdown();
// }
function startRescheduleCountdown() { function startRescheduleCountdown() {
var resendTimeout;
var resendLink = $("#rescheduleResendLink");
$("#rescheduleResendLink").html('<a href="#" id="rescheduleResendLink" class="text-info" onclick="return resendRescheduleOTP();">Resend OTP</a>');
var countdown = $("#rescheduleCountdown");
function startCountdown() {
var timeleft = 60;
countdown.text(timeleft);
clearInterval(rescheduleTimer); // prevent multiple timers
var timeLeft = RESCHEDULE_TIME;
$("#rescheduleResendText").text("Please wait..");
$("#rescheduleCountdown").text(timeLeft);
resendTimeout = setInterval(function () {
timeleft--;
countdown.text(timeleft);
rescheduleTimer = setInterval(function () {
if (timeleft <= 0) {
clearInterval(resendTimeout);
$("#rescheduleResendLink").html('<a href="#" id="rescheduleResendLink" class="text-info" onclick="return sendRescheduleOTP(' + rescheduleMobileNumber + ');">Resend OTP</a>');
timeLeft--;
$("#rescheduleCountdown").text(timeLeft);
if (timeLeft <= 0) {
clearInterval(rescheduleTimer);
$("#rescheduleResendText").html(
'<a href="#" class="text-info" onclick="sendRescheduleOTP(' + rescheduleMobileNumber + '); return false;">Resend OTP</a>'
);
$("#rescheduleCountdown").text('');
} }
}, 1000); }, 1000);
} }
startCountdown();
}
function resendRescheduleOTP() { function resendRescheduleOTP() {
if (rescheduleMobileNumber) { if (rescheduleMobileNumber) {

Loading…
Cancel
Save