Browse Source

CareTaker, Officer and Counter Login creation page added in HQ

master
KaNi-04 4 months ago
parent
commit
e2de83cd69
  1. 2
      jwtToken.txt
  2. 27
      src/main/java/com/gcc/communityHall/component/JwtUtil.java
  3. 408
      src/main/java/com/gcc/communityHall/controller/CareTakerAPIController.java
  4. 286
      src/main/java/com/gcc/communityHall/controller/CareTakerController.java
  5. 27
      src/main/java/com/gcc/communityHall/controller/CounterController.java
  6. 437
      src/main/java/com/gcc/communityHall/controller/HeadquartersController.java
  7. 108
      src/main/java/com/gcc/communityHall/controller/OfficerController.java
  8. 52
      src/main/java/com/gcc/communityHall/controller/UserAPIController.java
  9. 70
      src/main/java/com/gcc/communityHall/entity/Login.java
  10. 103
      src/main/java/com/gcc/communityHall/entity/LoginHallId.java
  11. 3120
      src/main/java/com/gcc/communityHall/repository/BookingDetailsRepository.java
  12. 113
      src/main/java/com/gcc/communityHall/repository/HallDetailsRepository.java
  13. 25
      src/main/java/com/gcc/communityHall/repository/LoginHallIdRepository.java
  14. 82
      src/main/java/com/gcc/communityHall/repository/LoginRepository.java
  15. 28
      src/main/java/com/gcc/communityHall/repository/PaymentsRepository.java
  16. 5
      src/main/java/com/gcc/communityHall/service/Impl/BookingServiceImpl.java
  17. 124
      src/main/java/com/gcc/communityHall/service/Impl/PaymentsServiceImpl.java
  18. 6
      src/main/resources/templates/fragments/headquartersMenu.html
  19. 6
      src/main/resources/templates/fragments/menuOfficer.html
  20. 1543
      src/main/resources/templates/headquarters/login-creation.html
  21. 121
      src/main/resources/templates/user/viewhistory.html
  22. 13
      src/test/java/com/gcc/communityHall/CommunityHallApplicationTests.java

2
jwtToken.txt

@ -1 +1 @@
eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyVHlwZSI6ImFkbWluIiwiaGFsbElkIjoxLCJtb2JpbGVOdW1iZXIiOjgzNDQ5NzkyOTIsImVtcGxveWVlSWQiOiIxIiwiem9uZSI6IjAwIiwiZXhwIjoxNzczMTIyNTkxfQ.6cTw68Q9NsMgdKLtP7D1k0I_6PJQ62mFIOItwtpYz7o7FNC_Kf0qRzulFguzgnPpdvSwXF2v2w_PqIXte7eIMg
eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyVHlwZSI6ImhlYWRxdWFydGVycyIsImhhbGxJZCI6MywiaGFsbElkcyI6IjMiLCJtb2JpbGVOdW1iZXIiOjEyMzQ1Njc4OTEsImVtcGxveWVlSWQiOiI2Iiwiem9uZSI6IjAwIiwiZXhwIjoxNzgxNTA2NDEwfQ.GsMmYYsPT_S2rsgB_q1hFaX-2uu3Z1HvKwijAbA1Ck5ruG9Q2JaV_ZGZGic-Jl0LLRUPHi5Xs_6jCvfg6UbiNA

27
src/main/java/com/gcc/communityHall/component/JwtUtil.java

@ -11,6 +11,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@Component
public class JwtUtil {
@ -23,23 +25,32 @@ public class JwtUtil {
@PostConstruct
public void init() {
// System.out.println("jwtSecret: " + jwtSecret);
// System.out.println("jwtExpirationMs: " + jwtExpirationMs);
// System.out.println("jwtSecret: " + jwtSecret);
// System.out.println("jwtExpirationMs: " + jwtExpirationMs);
}
public String generateToken(String userType, int hallId, long mobileNumber, String employeeId, String zone) {
public String generateToken(String userType, int hallId, List<Integer> hallIds, long mobileNumber,
String employeeId, String zone) {
try {
//System.out.println("generate token here");
String token= Jwts.builder()
// Build effective hall IDs: prefer hallIds list if non-empty, otherwise fall
// back to single hallId
List<Integer> effectiveHallIds = (hallIds != null && !hallIds.isEmpty())
? hallIds
: (hallId != 0 ? List.of(hallId) : List.of());
String hallIdsStr = effectiveHallIds.stream()
.map(String::valueOf)
.collect(Collectors.joining(","));
String token = Jwts.builder()
.claim("userType", userType)
.claim("hallId", hallId)
.claim("hallIds", hallIdsStr)
.claim("mobileNumber", mobileNumber)
.claim("employeeId", employeeId)
.claim("zone", zone)
.setExpiration(new Date(System.currentTimeMillis() + jwtExpirationMs))
.signWith(SignatureAlgorithm.HS512, jwtSecret)
.compact();
//System.out.println("Generated JWT Token: " + token);
// System.out.println("Generated JWT Token: " + token);
return token;
} catch (Exception e) {
System.err.println("Failed to generate JWT token: " + e.getMessage());
@ -49,9 +60,9 @@ public class JwtUtil {
}
public boolean validateToken(String token) {
//System.out.println("validation starts");
// System.out.println("validation starts");
try {
//System.out.println("inside validation try");
// System.out.println("inside validation try");
Claims claims = Jwts.parser().setSigningKey(jwtSecret).parseClaimsJws(token).getBody();
return !isTokenExpired(claims);
} catch (ExpiredJwtException e) {

408
src/main/java/com/gcc/communityHall/controller/CareTakerAPIController.java

@ -48,156 +48,86 @@ import lombok.AllArgsConstructor;
//@RestController
//@RequestMapping("/careTaker/api")
@Tag(
name = "CRUD REST APIs for CareTaker in CommunityHall",
description = "CRUD REST APIs in CommunityHall to CREATE, UPDATE, FETCH AND DELETE Booking details"
)
@Tag(name = "CRUD REST APIs for CareTaker in CommunityHall", description = "CRUD REST APIs in CommunityHall to CREATE, UPDATE, FETCH AND DELETE Booking details")
@RestController
@RequestMapping("/communityhall/careTaker/api")
@AllArgsConstructor
@Validated
public class CareTakerAPIController {
@Autowired
private UserSession userSession;
@Autowired
private BookingService bookingService;
@Autowired
private LoginRepository loginrepo;
@Autowired
private JwtUtil jwtUtil;
@Autowired
private BookingDetailsRepository bookingRepository;
@Autowired
private ApplicationLogsRepository applicationLogsRepository;
@Autowired
private HttpSession session;
@Autowired
private AppConfig appConfig;
@Operation(
summary = "Retrieving the User Details by bookingId REST API",
description = "REST API for Retrieving the User Details by bookingId"
)
@ApiResponses({
@ApiResponse(
responseCode = "200",
description = "HTTP Status OK",
content = @Content(
mediaType = "application/json",
schema = @Schema(implementation = Users.class)
)
),
@ApiResponse(
responseCode = "500",
description = "Internal Server Error",
content = @Content(
mediaType = "application/json",
schema = @Schema(implementation = ErrorResponseDto.class),
examples = @ExampleObject(value = "{ \"path\": \"/viewuserDetails\", \"status\": 500, \"error\": \"Internal Server Error\", \"timestamp\": \"2024-06-22T05:47:04.347+00:00\" }")
)
)
})
@GetMapping("/viewuserDetails")
public ResponseEntity<?> getUserDetailsByBookingId(@RequestParam("bookingId") int bookingId) {
BookingDetails bookingDetails = bookingService.getBookingsById(bookingId);
Users user = bookingDetails.getUsers();
return ResponseEntity.ok(bookingDetails);
}
@Operation(
summary = "Saving the Eb Details REST API",
description = "REST API for Saving the EB Details"
)
@ApiResponses({
@ApiResponse(
responseCode = "200",
description = "HTTP Status OK",
content = @Content(
mediaType = "application/json",
examples = @ExampleObject(value = "{ \"message\": \"EB details saved successfully\" }")
)
),
@ApiResponse(
responseCode = "500",
description = "Internal Server Error",
content = @Content(
mediaType = "application/json",
schema = @Schema(implementation = ErrorResponseDto.class),
examples = @ExampleObject(value = "{ \"path\": \"/saveEbDetails\", \"status\": 500, \"error\": \"Internal Server Error\", \"timestamp\": \"2024-06-22T05:47:04.347+00:00\" }")
)
)
})
@PostMapping(path = "/saveEbDetails")
public ResponseEntity<?> saveEbDetails(@RequestParam int bookingId, @RequestParam double startingReading , @RequestParam(required = false) MultipartFile startingReadingimage) {
BookingDetails bd=bookingService.saveebdetails(bookingId,startingReading,startingReadingimage);
String adminname = (String) session.getAttribute("usertype");
Integer loginid = (Integer) session.getAttribute("id");
ApplicationLogs logs=new ApplicationLogs();
logs.setComments("Action by " + adminname);
logs.setLoginId(loginid);
logs.setBookingId(bookingId);
logs.setLogType("saving EB StartingReading:-"+startingReading);
InetAddress inetAddress;
try {
inetAddress = InetAddress.getLocalHost();
String hostname = InetAddress.getLocalHost().getHostName();
logs.setIpaddress(inetAddress.getHostAddress());
logs.setSystemName(hostname);
} catch (UnknownHostException e) {
e.printStackTrace();
}
applicationLogsRepository.save(logs);
return ResponseEntity.ok(bookingService.updateBookingDetails(bd));
}
@Operation(
summary = "Checking the MobileNo and PIN REST API",
description = "REST API for Checking the Mobile No and PIN"
)
@Autowired
private UserSession userSession;
@Autowired
private BookingService bookingService;
@Autowired
private LoginRepository loginrepo;
@Autowired
private JwtUtil jwtUtil;
@Autowired
private BookingDetailsRepository bookingRepository;
@Autowired
private ApplicationLogsRepository applicationLogsRepository;
@Autowired
private HttpSession session;
@Autowired
private AppConfig appConfig;
@Operation(summary = "Retrieving the User Details by bookingId REST API", description = "REST API for Retrieving the User Details by bookingId")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "HTTP Status OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Users.class)
)),
@ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponseDto.class), examples = @ExampleObject(value = "{ \"path\": \"/viewuserDetails\", \"status\": 500, \"error\": \"Internal Server Error\", \"timestamp\": \"2024-06-22T05:47:04.347+00:00\" }")))
})
@GetMapping("/viewuserDetails")
public ResponseEntity<?> getUserDetailsByBookingId(@RequestParam("bookingId") int bookingId) {
BookingDetails bookingDetails = bookingService.getBookingsById(bookingId);
Users user = bookingDetails.getUsers();
return ResponseEntity.ok(bookingDetails);
}
@Operation(summary = "Saving the Eb Details REST API", description = "REST API for Saving the EB Details")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "HTTP Status OK", content = @Content(mediaType = "application/json", examples = @ExampleObject(value = "{ \"message\": \"EB details saved successfully\" }"))),
@ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponseDto.class), examples = @ExampleObject(value = "{ \"path\": \"/saveEbDetails\", \"status\": 500, \"error\": \"Internal Server Error\", \"timestamp\": \"2024-06-22T05:47:04.347+00:00\" }")))
})
@PostMapping(path = "/saveEbDetails")
public ResponseEntity<?> saveEbDetails(@RequestParam int bookingId, @RequestParam double startingReading,
@RequestParam(required = false) MultipartFile startingReadingimage) {
BookingDetails bd = bookingService.saveebdetails(bookingId, startingReading, startingReadingimage);
String adminname = (String) session.getAttribute("usertype");
Integer loginid = (Integer) session.getAttribute("id");
ApplicationLogs logs = new ApplicationLogs();
logs.setComments("Action by " + adminname);
logs.setLoginId(loginid);
logs.setBookingId(bookingId);
logs.setLogType("saving EB StartingReading:-" + startingReading);
InetAddress inetAddress;
try {
inetAddress = InetAddress.getLocalHost();
String hostname = InetAddress.getLocalHost().getHostName();
logs.setIpaddress(inetAddress.getHostAddress());
logs.setSystemName(hostname);
} catch (UnknownHostException e) {
e.printStackTrace();
}
applicationLogsRepository.save(logs);
return ResponseEntity.ok(bookingService.updateBookingDetails(bd));
}
@Operation(summary = "Checking the MobileNo and PIN REST API", description = "REST API for Checking the Mobile No and PIN")
@ApiResponses({
@ApiResponse(
responseCode = "200",
description = "HTTP Status OK",
content = @Content(
mediaType = "text/plain",
examples = @ExampleObject(value = "{ \"usertype\" }")
)
),
@ApiResponse(
responseCode = "417",
description = "Expectation Failed",
content = @Content(
mediaType = "application/json",
examples = @ExampleObject(value = "{ \"error\": \"Invalid mobile number or PIN\" }")
)
),
@ApiResponse(
responseCode = "400",
description = "Bad Request",
content = @Content(
mediaType = "application/json",
examples = @ExampleObject(value = "{ \"mobileNo\": \"Mobile number must be 10 digits\" }")
)
),
@ApiResponse(
responseCode = "500",
description = "Internal Server Error",
content = @Content(
mediaType = "application/json",
schema = @Schema(implementation = ErrorResponseDto.class),
examples = @ExampleObject(value = "{ \"path\": \"/checkLogin\", \"status\": 500, \"error\": \"Internal Server Error\", \"timestamp\": \"2024-06-22T05:47:04.347+00:00\" }")
)
)
@ApiResponse(responseCode = "200", description = "HTTP Status OK", content = @Content(mediaType = "text/plain", examples = @ExampleObject(value = "{ \"usertype\" }"))),
@ApiResponse(responseCode = "417", description = "Expectation Failed", content = @Content(mediaType = "application/json", examples = @ExampleObject(value = "{ \"error\": \"Invalid mobile number or PIN\" }"))),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = "application/json", examples = @ExampleObject(value = "{ \"mobileNo\": \"Mobile number must be 10 digits\" }"))),
@ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponseDto.class), examples = @ExampleObject(value = "{ \"path\": \"/checkLogin\", \"status\": 500, \"error\": \"Internal Server Error\", \"timestamp\": \"2024-06-22T05:47:04.347+00:00\" }")))
})
@GetMapping("/checkLogin")
public ResponseEntity<?> checkLogin(
@ -205,26 +135,35 @@ public class CareTakerAPIController {
@RequestParam String pin, HttpSession session) {
try {
// System.out.println("careTaker API Controller\nCounter Id: "+userSession.getCounter()+"\nCounter Name: "+userSession.getCounterName());
// System.out.println("careTaker API Controller\nCounter Id:
// "+userSession.getCounter()+"\nCounter Name: "+userSession.getCounterName());
// Fetch login details from the repository
Login login = loginrepo.findByMobileNoAndPin(Long.parseLong(mobileNo), pin);
if (login != null) {
// System.out.println("Login successful for mobile number: " + mobileNo);
// System.out.println("Login successful for mobile number: " + mobileNo);
// Generate JWT token if login is successful
String token = jwtUtil.generateToken(
login.getUserType(),
login.getHallId(),
login.getHallIds(),
login.getMobileNumber(),
login.getEmployeeId(),
login.getZone()
);
//System.out.println("Generated JWT Token: " + token);
login.getZone());
// System.out.println("Generated JWT Token: " + token);
// Store JWT token and user information in session
session.setAttribute("jwtToken", token);
session.setAttribute("id", login.getId());
session.setAttribute("hall_id", login.getHallId());
// Store multi-hall IDs: prefer hallIds list if assigned, else derive from
// single hallId
List<Integer> effectiveHallIds = (login.getHallIds() != null && !login.getHallIds().isEmpty())
? login.getHallIds()
: (login.getHallId() != 0 ? java.util.Arrays.asList(login.getHallId())
: new java.util.ArrayList<>());
System.out.println("effectiveHallIds.." + effectiveHallIds);
session.setAttribute("hall_ids", effectiveHallIds);
session.setAttribute("mobileno", login.getMobileNumber());
session.setAttribute("usertype", login.getUserType());
session.setAttribute("employeeId", login.getEmployeeId());
@ -232,27 +171,28 @@ public class CareTakerAPIController {
InetAddress inetAddress = InetAddress.getLocalHost();
String hostname = InetAddress.getLocalHost().getHostName();
System.out.println("Hostname: " + hostname);
ApplicationLogs logs=new ApplicationLogs();
logs.setComments("login as "+login.getName());
ApplicationLogs logs = new ApplicationLogs();
logs.setComments("login as " + login.getName());
logs.setLoginId(login.getId());
logs.setIpaddress(inetAddress.getHostAddress());
logs.setSystemName(hostname);
applicationLogsRepository.save(logs);
applicationLogsRepository.save(logs);
userSession.setCounter(login.getEmployeeId());
userSession.setCounterName(login.getName());
userSession.setCounter(login.getEmployeeId());
userSession.setCounterName(login.getName());
Map<String, Object> response = new HashMap<>();
response.put("userType", login.getUserType());
response.put("counterName", login.getName()); // Send Counter Name
response.put("token", token);
Map<String, Object> response = new HashMap<>();
response.put("userType", login.getUserType());
response.put("counterName", login.getName()); // Send Counter Name
response.put("token", token);
// Write the token to a file
try (FileWriter fileWriter = new FileWriter("jwtToken.txt")) {
fileWriter.write(token);
} catch (IOException e) {
e.printStackTrace();
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to store token in file");
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body("Failed to store token in file");
}
// Return successful response with user type
@ -271,93 +211,87 @@ public class CareTakerAPIController {
}
}
@Operation(
summary = "Process EB Details and Damage REST API",
description = "REST API for saving the EB Details and Damage"
)
@ApiResponses({
@ApiResponse(
responseCode = "200",
description = "HTTP Status OK",
content = @Content(
mediaType = "text/plain",
examples = @ExampleObject(value = "EB details and damage processed successfully")
)
),
@ApiResponse(
responseCode = "500",
description = "Internal Server Error",
content = @Content(
mediaType = "application/json",
schema = @Schema(implementation = ErrorResponseDto.class),
examples = @ExampleObject(value = "{ \"path\": \"/processEbDetailsAndDamage\", \"status\": 500, \"error\": \"Internal Server Error\", \"timestamp\": \"2024-06-22T05:47:04.347+00:00\" }")
)
)
})
@PostMapping(path = "/processEbDetailsAndDamage")
public ResponseEntity<?> processEbDetailsAndDamage(
@RequestParam("bookingId") int bookingId,
@RequestParam("ebId") int ebId,
@RequestParam("startingReading") double startingReading,
@RequestParam("endingReading") double endingReading,
@RequestParam("usedUnit") float usedUnit,
@RequestParam("ebAmount") double ebAmount,
@RequestParam(name ="assetName",required = false) String assetNames[],
@RequestParam(name ="comments",required = false) String comments[],
@RequestParam(name ="quantity",required = false) int quantities[],
@RequestParam(name ="assetAmount",required = false) Double assetAmounts[],
@RequestParam(name ="assetImage",required = false) MultipartFile assetImages[]) {
String processEbDetailsAndDamage = bookingService.processEbDetailsAndDamage(bookingId, ebId, startingReading, endingReading, usedUnit, ebAmount, assetNames, comments, quantities, assetAmounts, assetImages);
String adminname = (String) session.getAttribute("usertype");
Integer loginid = (Integer) session.getAttribute("id");
ApplicationLogs logs=new ApplicationLogs();
logs.setComments("Action by " + adminname);
logs.setLoginId(loginid);
logs.setBookingId(bookingId);
logs.setLogType("Saving the SettlementDetails");
InetAddress inetAddress;
try {
inetAddress = InetAddress.getLocalHost();
String hostname = InetAddress.getLocalHost().getHostName();
logs.setIpaddress(inetAddress.getHostAddress());
logs.setSystemName(hostname);
} catch (UnknownHostException e) {
e.printStackTrace();
}
applicationLogsRepository.save(logs);
return ResponseEntity.ok(processEbDetailsAndDamage);
}
@Operation(summary = "Process EB Details and Damage REST API", description = "REST API for saving the EB Details and Damage")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "HTTP Status OK", content = @Content(mediaType = "text/plain", examples = @ExampleObject(value = "EB details and damage processed successfully"))),
@ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponseDto.class), examples = @ExampleObject(value = "{ \"path\": \"/processEbDetailsAndDamage\", \"status\": 500, \"error\": \"Internal Server Error\", \"timestamp\": \"2024-06-22T05:47:04.347+00:00\" }")))
})
@PostMapping(path = "/processEbDetailsAndDamage")
public ResponseEntity<?> processEbDetailsAndDamage(
@RequestParam("bookingId") int bookingId,
@RequestParam("ebId") int ebId,
@RequestParam("startingReading") double startingReading,
@RequestParam("endingReading") double endingReading,
@RequestParam("usedUnit") float usedUnit,
@RequestParam("ebAmount") double ebAmount,
@RequestParam(name = "assetName", required = false) String assetNames[],
@RequestParam(name = "comments", required = false) String comments[],
@RequestParam(name = "quantity", required = false) int quantities[],
@RequestParam(name = "assetAmount", required = false) Double assetAmounts[],
@RequestParam(name = "assetImage", required = false) MultipartFile assetImages[]) {
String processEbDetailsAndDamage = bookingService.processEbDetailsAndDamage(bookingId, ebId, startingReading,
endingReading, usedUnit, ebAmount, assetNames, comments, quantities, assetAmounts, assetImages);
String adminname = (String) session.getAttribute("usertype");
Integer loginid = (Integer) session.getAttribute("id");
ApplicationLogs logs = new ApplicationLogs();
logs.setComments("Action by " + adminname);
logs.setLoginId(loginid);
logs.setBookingId(bookingId);
logs.setLogType("Saving the SettlementDetails");
InetAddress inetAddress;
try {
inetAddress = InetAddress.getLocalHost();
String hostname = InetAddress.getLocalHost().getHostName();
logs.setIpaddress(inetAddress.getHostAddress());
logs.setSystemName(hostname);
} catch (UnknownHostException e) {
e.printStackTrace();
}
applicationLogsRepository.save(logs);
return ResponseEntity.ok(processEbDetailsAndDamage);
}
@GetMapping("/settlementlist")
public List<BookingDetails> getApprovedBookingsWithSettlement(int hallId) {
return bookingRepository.getSettlementList(hallId);
public List<BookingDetails> getApprovedBookingsWithSettlement() {
// Use multi-hall IDs from session if available, else fall back to single
// hall_id
@SuppressWarnings("unchecked")
List<Integer> hallIds = (List<Integer>) session.getAttribute("hall_ids");
if (hallIds != null && !hallIds.isEmpty()) {
return bookingRepository.getSettlementListByHallIds(hallIds);
}
// Fallback: single hall_id
Integer singleHallId = (Integer) session.getAttribute("hall_id");
if (singleHallId != null && singleHallId != 0) {
return bookingRepository.getSettlementList(singleHallId);
}
return java.util.Collections.emptyList();
}
@GetMapping(value = "/checkofficialMobileExits")
public String checkMobileExits(HttpServletRequest request, @RequestParam String phone) {
//System.out.println("correction in pin"+phone);
Login mod= loginrepo.checkUserbyMobile(Long.parseLong(phone));
//System.out.println(mod);
if(mod!=null){
return "success";
}
else {
return "error";
}
// System.out.println("correction in pin"+phone);
Login mod = loginrepo.checkUserbyMobile(Long.parseLong(phone));
// System.out.println(mod);
if (mod != null) {
return "success";
} else {
return "error";
}
}
@GetMapping(value = "/updatePIN")
public String updatePIN(long phone, String pin) {
Login mod= loginrepo.checkUserbyMobile(phone);
mod.setPassword(pin);
loginrepo.save(mod);
return "Success";
Login mod = loginrepo.checkUserbyMobile(phone);
mod.setPassword(pin);
loginrepo.save(mod);
return "Success";
}
@GetMapping(value = "/resetPIN")
public String resetPIN(@RequestParam long resetpinmobilenumber, @RequestParam String oldpin, @RequestParam String newpin) {
public String resetPIN(@RequestParam long resetpinmobilenumber, @RequestParam String oldpin,
@RequestParam String newpin) {
Login mod = loginrepo.checkUserbyMobile(resetpinmobilenumber);
if (mod != null && mod.getPassword().equals(oldpin)) {
@ -390,7 +324,7 @@ public class CareTakerAPIController {
return bookingService.getSettlementApprovedList();
}
@GetMapping("/settlement-list")
@GetMapping("/settlement-list")
public ResponseEntity<List<BookingDetails>> getSettlementList() {
List<BookingDetails> settlementList = bookingRepository.getSettlementsList();
@ -410,19 +344,21 @@ public class CareTakerAPIController {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
}
}
@GetMapping("/generateQRCode")
public ResponseEntity<String> generateQRCodeForUser(@RequestParam("bookingId") Long bookingId) {
try {
// Base URL and full URL construction
String baseUrl = appConfig.getFullUrl(); // Base URL
// String fullUrl = baseUrl + "/getuserbyid?registerId=" + registerId; // Full URL
// String fullUrl = baseUrl + "/getuserbyid?registerId=" + registerId; // Full
// URL
// Log the generated full URL for debugging
System.out.println("Generated Full URL for QR Code: " + baseUrl);
// Generate the QR code with the full URL
String qrCodeImage = QRCodeGenerator.generateQRCode(baseUrl, bookingId);
String dataUri = qrCodeImage; // Encode QR code image as Base64
String dataUri = qrCodeImage; // Encode QR code image as Base64
// Return the QR code image as a Base64 string
return ResponseEntity.ok(dataUri);

286
src/main/java/com/gcc/communityHall/controller/CareTakerController.java

@ -21,145 +21,151 @@ import jakarta.servlet.http.HttpSession;
@Controller
@RequestMapping("/communityhall/caretaker")
public class CareTakerController {
@Autowired
private AppConfig appConfig;
@Autowired
private BookingDetailsRepository bookingDetailsRepo;
@Autowired
private BookingService bookingService;
@Autowired
private BookingDetailsRepository bookingRepository;
@Autowired
private HallDetailsRepository hallDetailsRepository;
@GetMapping("/dashboard")
public String viewdashboardPage(Model model,HttpSession session) {
// model.addAttribute("session", session);
String caretakerName = (String) session.getAttribute("usertype");
if(caretakerName!=null) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
int hall_id = (int) session.getAttribute("hall_id");
String hallName = hallDetailsRepository.findHallNameById(hall_id);
List<Map<String, Object>> getmounthcount = bookingDetailsRepo.getCartakermounthcount(hall_id);
List<Map<String, Object>> count = bookingDetailsRepo.getcartakecount(hall_id);
Map<String, Object> map = count.get(0);
model.addAttribute("mounthcount",getmounthcount);
//System.out.println( map.get("approved_count")!=null?map.get("approved_count"):1);
model.addAttribute("APPROVED", map.get("approved_count"));
model.addAttribute("REJECTED", map.get("rejected_count"));
model.addAttribute("COMPLETED", map.get("completed_count"));
model.addAttribute("CANCELED", map.get("CANCELED"));
model.addAttribute("PAYMENT_FAILURE", map.get("PAYMENT_FAILURE"));
model.addAttribute("GCC_BLOCKED", map.get("GCC_BLOCKED"));
model.addAttribute("caretakerName", caretakerName);
model.addAttribute("hallName", hallName);
return "caretaker/dashboard";
}else {
session.invalidate();
return "redirect:/communityhall/login";
}
}
@GetMapping("/settlementlist")
public String viewSettlementList(Model model,HttpSession session) {
String caretakerName = (String) session.getAttribute("usertype");
if(caretakerName!=null) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
Integer hallid = (Integer) session.getAttribute("hall_id");
List<BookingDetails> settlemetList = bookingRepository.getSettlementList(hallid);
model.addAttribute("caretakerName", caretakerName);
model.addAttribute("settlemetList", settlemetList);
return "caretaker/settlementlist";
}else {
session.invalidate();
return "redirect:/communityhall/login";
}
}
@GetMapping("/present-booking")
public String viewPresent(Model model, HttpSession session) {
String caretakerName = (String) session.getAttribute("usertype");
if(caretakerName!=null) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
Integer hallid = (Integer) session.getAttribute("hall_id");
List<BookingDetails> bookings = bookingService.getPresentsEventsByUserId(hallid);
model.addAttribute("caretakerName", caretakerName);
model.addAttribute("hallid", hallid);
model.addAttribute("bookings", bookings);
return "caretaker/present-booking";
}else {
session.invalidate();
return "redirect:/communityhall/login";
}
}
@GetMapping("/past-booking")
public String viewPast(Model model,HttpSession session) {
String caretakerName = (String) session.getAttribute("usertype");
if(caretakerName!=null) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
Integer hallid = (Integer) session.getAttribute("hall_id");
// Assuming you have a service class to handle business logic
List<BookingDetails> pastBookings = bookingService.getPastsEventsByUserId(hallid);
model.addAttribute("caretakerName", caretakerName);
model.addAttribute("hallid", hallid);
model.addAttribute("pastBookings", pastBookings);
return "caretaker/past-booking";
}else {
session.invalidate();
return "redirect:/communityhall/login";
}
}
@GetMapping("/future-booking")
public String viewFuture(Model model,HttpSession session) {
String caretakerName = (String) session.getAttribute("usertype");
if(caretakerName!=null) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
Integer hallid = (Integer) session.getAttribute("hall_id");
// Assuming you have a service class to handle business logic
List<BookingDetails> futureBookings = bookingService.getFuturesEventsByUserId(hallid);
model.addAttribute("caretakerName", caretakerName);
model.addAttribute("hallid", hallid);
model.addAttribute("futureBookings", futureBookings);
return "caretaker/future-booking";
}else {
session.invalidate();
return "redirect:/communityhall/login";
}
}
@GetMapping("/caretakerpage")
public String viewcaretakerpage(Model model,HttpSession session,@RequestParam("bookingId") int bookingId) {
String caretakerName = (String) session.getAttribute("usertype");
if(caretakerName!=null) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("caretakerName", caretakerName);
model.addAttribute("title","caretaker");
model.addAttribute("baseURL", appConfig.getBaseUrl());
BookingDetails booking = bookingService.getBookingsById(bookingId);
model.addAttribute("booking",booking);
return "caretaker/caretakerpage";
}else {
session.invalidate();
return "redirect:/communityhall/login";
}
}
@GetMapping("/logout")
public String viewLogout(Model model,HttpSession session) {
session.invalidate();
return "redirect:/communityhall/login";
}
@Autowired
private AppConfig appConfig;
@Autowired
private BookingDetailsRepository bookingDetailsRepo;
@Autowired
private BookingService bookingService;
@Autowired
private BookingDetailsRepository bookingRepository;
@Autowired
private HallDetailsRepository hallDetailsRepository;
@GetMapping("/dashboard")
public String viewdashboardPage(Model model, HttpSession session) {
// model.addAttribute("session", session);
String caretakerName = (String) session.getAttribute("usertype");
if (caretakerName != null && "caretaker".equals(caretakerName)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
int hall_id = (int) session.getAttribute("hall_id");
String hallName = hallDetailsRepository.findHallNameById(hall_id);
List<Map<String, Object>> getmounthcount = bookingDetailsRepo.getCartakermounthcount(hall_id);
List<Map<String, Object>> count = bookingDetailsRepo.getcartakecount(hall_id);
Map<String, Object> map = count.get(0);
model.addAttribute("mounthcount", getmounthcount);
// System.out.println(
// map.get("approved_count")!=null?map.get("approved_count"):1);
model.addAttribute("APPROVED", map.get("approved_count"));
model.addAttribute("REJECTED", map.get("rejected_count"));
model.addAttribute("COMPLETED", map.get("completed_count"));
model.addAttribute("CANCELED", map.get("CANCELED"));
model.addAttribute("PAYMENT_FAILURE", map.get("PAYMENT_FAILURE"));
model.addAttribute("GCC_BLOCKED", map.get("GCC_BLOCKED"));
model.addAttribute("caretakerName", caretakerName);
model.addAttribute("hallName", hallName);
return "caretaker/dashboard";
} else {
session.invalidate();
return "redirect:/communityhall/login";
}
}
@GetMapping("/settlementlist")
public String viewSettlementList(Model model, HttpSession session) {
String caretakerName = (String) session.getAttribute("usertype");
if (caretakerName != null && "caretaker".equals(caretakerName)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
Integer hallid = (Integer) session.getAttribute("hall_id");
List<BookingDetails> settlemetList = bookingRepository.getSettlementList(hallid);
model.addAttribute("caretakerName", caretakerName);
model.addAttribute("settlemetList", settlemetList);
return "caretaker/settlementlist";
} else {
session.invalidate();
return "redirect:/communityhall/login";
}
}
@GetMapping("/present-booking")
public String viewPresent(Model model, HttpSession session) {
String caretakerName = (String) session.getAttribute("usertype");
if (caretakerName != null && "caretaker".equals(caretakerName)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
Integer hallid = (Integer) session.getAttribute("hall_id");
List<BookingDetails> bookings = bookingService.getPresentsEventsByUserId(hallid);
model.addAttribute("caretakerName", caretakerName);
model.addAttribute("hallid", hallid);
model.addAttribute("bookings", bookings);
return "caretaker/present-booking";
} else {
session.invalidate();
return "redirect:/communityhall/login";
}
}
@GetMapping("/past-booking")
public String viewPast(Model model, HttpSession session) {
String caretakerName = (String) session.getAttribute("usertype");
if (caretakerName != null && "caretaker".equals(caretakerName)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
Integer hallid = (Integer) session.getAttribute("hall_id");
// Assuming you have a service class to handle business logic
List<BookingDetails> pastBookings = bookingService.getPastsEventsByUserId(hallid);
model.addAttribute("caretakerName", caretakerName);
model.addAttribute("hallid", hallid);
model.addAttribute("pastBookings", pastBookings);
return "caretaker/past-booking";
} else {
session.invalidate();
return "redirect:/communityhall/login";
}
}
@GetMapping("/future-booking")
public String viewFuture(Model model, HttpSession session) {
String caretakerName = (String) session.getAttribute("usertype");
if (caretakerName != null && "caretaker".equals(caretakerName)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
Integer hallid = (Integer) session.getAttribute("hall_id");
// Assuming you have a service class to handle business logic
List<BookingDetails> futureBookings = bookingService.getFuturesEventsByUserId(hallid);
model.addAttribute("caretakerName", caretakerName);
model.addAttribute("hallid", hallid);
model.addAttribute("futureBookings", futureBookings);
return "caretaker/future-booking";
} else {
session.invalidate();
return "redirect:/communityhall/login";
}
}
@GetMapping("/caretakerpage")
public String viewcaretakerpage(Model model, HttpSession session, @RequestParam("bookingId") int bookingId) {
String caretakerName = (String) session.getAttribute("usertype");
if (caretakerName != null && "caretaker".equals(caretakerName)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("caretakerName", caretakerName);
model.addAttribute("title", "caretaker");
model.addAttribute("baseURL", appConfig.getBaseUrl());
BookingDetails booking = bookingService.getBookingsById(bookingId);
model.addAttribute("booking", booking);
return "caretaker/caretakerpage";
} else {
session.invalidate();
return "redirect:/communityhall/login";
}
}
@GetMapping("/logout")
public String viewLogout(Model model, HttpSession session) {
session.invalidate();
return "redirect:/communityhall/login";
}
}

27
src/main/java/com/gcc/communityHall/controller/CounterController.java

@ -66,12 +66,12 @@ public class CounterController {
@Autowired
private ApplicationLogsRepository applicationLogsRepository;
@GetMapping(value = {"", "/", "/counterbooking"})
@GetMapping(value = { "", "/", "/counterbooking" })
public String viewcounter(Model model, HttpSession session) {
System.out.println("viewcounter");
String countername = (String) session.getAttribute("usertype");
System.out.println("serverDate....."+ LocalDate.now().toString());
model.addAttribute("serverDate", LocalDate.now().toString()); //for server date
System.out.println("serverDate....." + LocalDate.now().toString());
model.addAttribute("serverDate", LocalDate.now().toString()); // for server date
model.addAttribute("countername", countername);
return "counter/counter-booking";
}
@ -139,34 +139,35 @@ public class CounterController {
userSession.setDispayName(null);
userSession.setCounter(null);
userSession.setCounterName(null);
// return "redirect:/communityhall/login";
// return "redirect:/communityhall/login";
return "redirect:/communityhall/user/dashboard";
}
// newly added for counter login
// newly added for counter login
@GetMapping("/verifyLogin")
public ResponseEntity<?> verifyLogin(
@RequestParam("username") String username,
@RequestParam("password") String password,
Model model, HttpSession session) {
System.out.println("username: "+username+"\n"+"password: "+password);
System.out.println("username: " + username + "\n" + "password: " + password);
try {
Login login = loginRepository.findByUsernameAndPass(username, password);
System.out.println("counter controller\nCounter Id: "+userSession.getCounter()+"\nCounter Name: "+userSession.getCounterName());
System.out.println("counter controller\nCounter Id: " + userSession.getCounter() + "\nCounter Name: "
+ userSession.getCounterName());
if (login != null) {
// System.out.println("Login successful for mobile number: " + mobileNo);
System.out.println("Login successful for mobile number: " + login.getMobileNumber());
// Generate JWT token if login is successful
String token = jwtUtil.generateToken(
login.getUserType(),
login.getHallId(),
login.getHallIds(),
login.getMobileNumber(),
login.getEmployeeId(),
login.getZone()
);
//System.out.println("Generated JWT Token: " + token);
login.getZone());
// System.out.println("Generated JWT Token: " + token);
// Store JWT token and user information in session
session.setAttribute("jwtToken", token);
@ -205,7 +206,8 @@ public class CounterController {
fileWriter.write(token);
} catch (IOException e) {
e.printStackTrace();
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to store token in file");
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body("Failed to store token in file");
}
// Return successful response with user type
@ -225,4 +227,3 @@ public class CounterController {
}
}

437
src/main/java/com/gcc/communityHall/controller/HeadquartersController.java

@ -8,20 +8,27 @@ import java.util.stream.Collectors;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.gcc.communityHall.entity.GccBlockingDate;
import com.gcc.communityHall.entity.Login;
import com.gcc.communityHall.entity.LoginHallId;
import com.gcc.communityHall.others.AppConfig;
import com.gcc.communityHall.repository.GccBlockingDateRepository;
import com.gcc.communityHall.repository.LoginHallIdRepository;
import com.gcc.communityHall.repository.LoginRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.gcc.communityHall.entity.BookingDetails;
import com.gcc.communityHall.entity.Users;
import com.gcc.communityHall.repository.BookingDetailsRepository;
import com.gcc.communityHall.repository.HallDetailsRepository;
import com.gcc.communityHall.repository.UsersRepository;
import com.gcc.communityHall.service.BookingService;
import com.gcc.communityHall.service.HallDetailService;
@ -29,6 +36,7 @@ import com.gcc.communityHall.service.ReasonMasterService;
import com.gcc.communityHall.service.UserService;
import jakarta.servlet.http.HttpSession;
import jakarta.transaction.Transactional;
@Controller
@RequestMapping("/communityhall/headquarters")
@ -57,13 +65,22 @@ public class HeadquartersController {
@Autowired
private AppConfig appConfig;
@Autowired
private LoginRepository loginRepository;
@Autowired
private LoginHallIdRepository loginHallIdRepository;
@Autowired
private HallDetailsRepository hallDetailsRepository;
@GetMapping("/dashboard")
public String viewDashboard(
@RequestParam(required = false, defaultValue = "all zones") String zone,
Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if (headquartersname != null) {
if (headquartersname != null && "headquarters".equals(headquartersname)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
List<Map<String, Object>> getMonthCount = bookingDetailsRepository.getAllAdminmonthcount(zone);
@ -88,11 +105,10 @@ public class HeadquartersController {
}
}
@GetMapping("/Reports")
public String viewReports(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if (headquartersname != null) {
if (headquartersname != null && "headquarters".equals(headquartersname)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("headquartersname", headquartersname);
@ -106,7 +122,7 @@ public class HeadquartersController {
@GetMapping("/getReport")
public String getReports(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if (headquartersname != null) {
if (headquartersname != null && "headquarters".equals(headquartersname)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("headquartersname", headquartersname);
@ -120,7 +136,7 @@ public class HeadquartersController {
@GetMapping("/approval-history")
public String viewApproval(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if (headquartersname != null) {
if (headquartersname != null && "headquarters".equals(headquartersname)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("headquartersname", headquartersname);
@ -139,7 +155,7 @@ public class HeadquartersController {
@GetMapping("/user-approved")
public String viewUserApproved(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if (headquartersname != null) {
if (headquartersname != null && "headquarters".equals(headquartersname)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("headquartersname", headquartersname);
@ -158,7 +174,7 @@ public class HeadquartersController {
@GetMapping("/user-reject")
public String viewUserReject(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if (headquartersname != null) {
if (headquartersname != null && "headquarters".equals(headquartersname)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("headquartersname", headquartersname);
@ -176,48 +192,60 @@ public class HeadquartersController {
@PostMapping("/getReport")
public String generateReport(Model model,
@RequestParam(name = "FromDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) String fromDate,
@RequestParam(name = "ToDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) String toDate,
@RequestParam(name = "request") String request,
@RequestParam(name = "userstatus", required = false) String userstatus,
@RequestParam(name = "usertype", required = false) String usertype,
@RequestParam(name = "bookingStatus", required = false) String bookingStatus,
@RequestParam(name = "refundStatus", required = false) String refundStatus,
@RequestParam(name = "paymentStatus", required = false) String paymentStatus,
@RequestParam(name = "filterby", required = false) String filterby,
@RequestParam(name = "zone1", required = false, defaultValue = "ALL") String zone,
@RequestParam(name = "division1", required = false, defaultValue = "ALL") String division,
@RequestParam(name = "hall1", required = false) Integer hallid,
@RequestParam(name = "basedon", required = false) String basedon,
@RequestParam(name = "bookingId", required = false) Long bookingId,
@RequestParam(name = "reporttype", required = false) String reporttype,
@RequestParam(name = "counterId", required = false) String counterId, HttpSession session) throws JsonProcessingException {
@RequestParam(name = "FromDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) String fromDate,
@RequestParam(name = "ToDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) String toDate,
@RequestParam(name = "request") String request,
@RequestParam(name = "userstatus", required = false) String userstatus,
@RequestParam(name = "usertype", required = false) String usertype,
@RequestParam(name = "bookingStatus", required = false) String bookingStatus,
@RequestParam(name = "refundStatus", required = false) String refundStatus,
@RequestParam(name = "paymentStatus", required = false) String paymentStatus,
@RequestParam(name = "filterby", required = false) String filterby,
@RequestParam(name = "zone1", required = false, defaultValue = "ALL") String zone,
@RequestParam(name = "division1", required = false, defaultValue = "ALL") String division,
@RequestParam(name = "hall1", required = false) Integer hallid,
@RequestParam(name = "basedon", required = false) String basedon,
@RequestParam(name = "bookingId", required = false) Long bookingId,
@RequestParam(name = "reporttype", required = false) String reporttype,
@RequestParam(name = "counterId", required = false) String counterId, HttpSession session)
throws JsonProcessingException {
String headquartersname = (String) session.getAttribute("usertype");
if (headquartersname != null) {
if (headquartersname != null && "headquarters".equals(headquartersname)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
List<Users> userList = handleUserRequest(request, fromDate, toDate, userstatus, usertype);
List<Object[]> bookingList = handleBookingRequest(request, fromDate, toDate, bookingStatus, filterby, bookingId, zone, division, hallid);
List<BookingDetails> bookingSettlementList = handleBookingSettlementRequest(request, fromDate, toDate, refundStatus, filterby);
//List<Object[]> paymentList = request.equals("3") ? bookingService.getAllPaymentsDetails(fromDate, toDate,zone,division,hallid) : new ArrayList<>();
List<Object[]> bookingList = handleBookingRequest(request, fromDate, toDate, bookingStatus, filterby,
bookingId, zone, division, hallid);
List<BookingDetails> bookingSettlementList = handleBookingSettlementRequest(request, fromDate, toDate,
refundStatus, filterby);
// List<Object[]> paymentList = request.equals("3") ?
// bookingService.getAllPaymentsDetails(fromDate, toDate,zone,division,hallid) :
// new ArrayList<>();
List<Object[]> paymentList = new ArrayList<>();
List<Object[]> extrapaymentList = new ArrayList<>();
if (request.equals("3")) {
if (paymentStatus == null || paymentStatus.isEmpty()) {
paymentList = bookingService.getAllPaymentsDetails(fromDate, toDate, null, zone, division, hallid);
} else {
paymentList = bookingService.getAllPaymentsDetails(fromDate, toDate, paymentStatus, zone, division, hallid);
paymentList = bookingService.getAllPaymentsDetails(fromDate, toDate, paymentStatus, zone, division,
hallid);
}
}
if (request.equals("8")) {
if (paymentStatus == null || paymentStatus.isEmpty()) {
extrapaymentList = bookingService.getAllExtraPaymentsDetails(fromDate, toDate, null, zone, division, hallid);
extrapaymentList = bookingService.getAllExtraPaymentsDetails(fromDate, toDate, null, zone, division,
hallid);
} else {
extrapaymentList = bookingService.getAllExtraPaymentsDetails(fromDate, toDate, paymentStatus, zone, division, hallid);
extrapaymentList = bookingService.getAllExtraPaymentsDetails(fromDate, toDate, paymentStatus, zone,
division, hallid);
}
}
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<Object[]> userbookingList = request.equals("4")
? bookingService.getBookingUserDetailsReport(fromDate, toDate)
: new ArrayList<>();
// List<Object[]> hallbookingList = request.equals("5") ?
// bookingService.getBookingHallDetailsReport(fromDate, toDate) : new
// ArrayList<>();
// In your controller method
// Fetch booking count by zone
List<Object[]> totalcount = new ArrayList<>();
@ -227,13 +255,13 @@ public class HeadquartersController {
totalcount = bookingDetailsRepository.countBookingsByZone();
// Format zone data
totalcount = totalcount.stream()
.map(data -> new Object[]{"Zone-" + data[0], data[1]})
.map(data -> new Object[] { "Zone-" + data[0], data[1] })
.collect(Collectors.toList());
} else if ("division".equals(basedon)) {
totalcount = bookingDetailsRepository.countBookingsByDivisions();
// Format division data
totalcount = totalcount.stream()
.map(data -> new Object[]{"Division-" + data[0], data[1]})
.map(data -> new Object[] { "Division-" + data[0], data[1] })
.collect(Collectors.toList());
}
@ -244,22 +272,24 @@ public class HeadquartersController {
model.addAttribute("basedon", basedon);
model.addAttribute("totalcount", totalcount);
model.addAttribute("totalBookings", totalBookings);
List<Object[]> hallbookingList = handleBookingHallDetailsReportRequest(request, fromDate, toDate, filterby, zone, division, hallid);
List<Object[]> hallbookingList = handleBookingHallDetailsReportRequest(request, fromDate, toDate, filterby,
zone, division, hallid);
if ("9".equals(request)) {
if("abstract".equals(reporttype)){
if ("abstract".equals(reporttype)) {
List<Object[]> counterBookingList = new ArrayList<>();
counterBookingList = bookingService.getCounterWiseBookingCount(fromDate, toDate);
model.addAttribute("counterBookingList", counterBookingList);
System.out.println("counterBookingList.." + counterBookingList);
List<Object[]> hallBookingByCounter = bookingService.getHallWiseBookingDetails(fromDate, toDate, counterId);
List<Object[]> hallBookingByCounter = bookingService.getHallWiseBookingDetails(fromDate, toDate,
counterId);
// Convert to JSON for JS usage
String hallBookingJson = new ObjectMapper().writeValueAsString(hallBookingByCounter);
model.addAttribute("hallBookingJson", hallBookingJson);
List<Object[]> hallBookingDetails = bookingService.getBookingDetailsForAllHalls(fromDate, toDate, counterId, hallid);
List<Object[]> hallBookingDetails = bookingService.getBookingDetailsForAllHalls(fromDate, toDate,
counterId, hallid);
String hallBookingDetailsJson = new ObjectMapper().writeValueAsString(hallBookingDetails);
model.addAttribute("hallBookingDetailsJson", hallBookingDetailsJson);
@ -300,7 +330,8 @@ public class HeadquartersController {
}
}
private List<Object[]> handleBookingHallDetailsReportRequest(String request, String fromDate, String toDate, String filterby, String zone, String division, Integer hallid) {
private List<Object[]> handleBookingHallDetailsReportRequest(String request, String fromDate, String toDate,
String filterby, String zone, String division, Integer hallid) {
if (!request.equals("5")) {
return new ArrayList<>();
}
@ -321,7 +352,8 @@ public class HeadquartersController {
return new ArrayList<>();
}
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")) {
return new ArrayList<>();
}
@ -337,8 +369,8 @@ public class HeadquartersController {
return userService.getAllUsers(fromDate, toDate);
}
private List<Object[]> handleBookingRequest(String request, String fromDate, String toDate, String bookingStatus, String filterby, Long bookingId, String zone, String division, Integer hallid) {
private List<Object[]> handleBookingRequest(String request, String fromDate, String toDate, String bookingStatus,
String filterby, Long bookingId, String zone, String division, Integer hallid) {
if (!request.equals("2")) {
return new ArrayList<>();
}
@ -349,10 +381,12 @@ public class HeadquartersController {
return bookingDetailsRepo.getAllBookingDetailsWithBookingId(fromDate, toDate, bookingId);
}
if (bookingId != null && !bookingStatus.isEmpty()) {
return bookingDetailsRepo.getAllBookingDetailsWithBookingIdwithbookingStatus(fromDate, toDate, bookingId, bookingStatus);
return bookingDetailsRepo.getAllBookingDetailsWithBookingIdwithbookingStatus(fromDate, toDate, bookingId,
bookingStatus);
}
if (bookingId == null && filterby.isEmpty() && !bookingStatus.isEmpty()) {
return bookingService.getBookingDetailsByBookingDateWithStatus(fromDate, toDate, bookingStatus, zone, division, hallid);
return bookingService.getBookingDetailsByBookingDateWithStatus(fromDate, toDate, bookingStatus, zone,
division, hallid);
}
if (!filterby.isEmpty()) {
@ -360,7 +394,8 @@ public class HeadquartersController {
if (bookingStatus.isEmpty()) {
return bookingService.getBookingDetailsByBookingDate(fromDate, toDate, zone, division, hallid);
} else {
return bookingService.getBookingDetailsByBookingDateWithStatus(fromDate, toDate, bookingStatus, zone, division, hallid);
return bookingService.getBookingDetailsByBookingDateWithStatus(fromDate, toDate, bookingStatus,
zone, division, hallid);
}
}
@ -368,7 +403,8 @@ public class HeadquartersController {
if (bookingStatus.isEmpty()) {
return bookingService.getBookingDetailsByEventDate(fromDate, toDate, zone, division, hallid);
} else {
return bookingService.getBookingDetailsByEventDateWithStatus(fromDate, toDate, bookingStatus, zone, division, hallid);
return bookingService.getBookingDetailsByEventDateWithStatus(fromDate, toDate, bookingStatus, zone,
division, hallid);
}
}
@ -377,8 +413,8 @@ public class HeadquartersController {
return new ArrayList<>();
}
private List<BookingDetails> handleBookingSettlementRequest(String request, String fromDate, String toDate, String refundStatus, String filterby) {
private List<BookingDetails> handleBookingSettlementRequest(String request, String fromDate, String toDate,
String refundStatus, String filterby) {
if (!request.equals("6")) {
return new ArrayList<>();
}
@ -394,7 +430,8 @@ public class HeadquartersController {
if (refundStatus.isEmpty()) {
return bookingService.getAllBookingsettlementDetailsByBookingDate(fromDate, toDate);
} else {
return bookingService.getAllBookingsettlementDetailsByBookingDateWithStatus(fromDate, toDate, refundStatus);
return bookingService.getAllBookingsettlementDetailsByBookingDateWithStatus(fromDate, toDate,
refundStatus);
}
}
@ -402,7 +439,8 @@ public class HeadquartersController {
if (refundStatus.isEmpty()) {
return bookingService.getAllBookingsettlementDetailsByEventDate(fromDate, toDate);
} else {
return bookingService.getAllBookingsettlementDetailsByEventDateWithStatus(fromDate, toDate, refundStatus);
return bookingService.getAllBookingsettlementDetailsByEventDateWithStatus(fromDate, toDate,
refundStatus);
}
}
@ -415,7 +453,7 @@ public class HeadquartersController {
@GetMapping("/ongoingevents")
public String viewRecentevents(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if (headquartersname != null) {
if (headquartersname != null && "headquarters".equals(headquartersname)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
List<BookingDetails> presenteventslist = bookingDetailsRepository.findPresentBookingList();
@ -436,13 +474,14 @@ public class HeadquartersController {
@GetMapping("/booking-list")
public String viewBookingList(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if (headquartersname != null) {
if (headquartersname != null && "headquarters".equals(headquartersname)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("headquartersname", headquartersname);
List<BookingDetails> bookingList = bookingDetailsRepository.getAllApprovedList();
model.addAttribute("bookingList", bookingList);
return "headquarters/booking-list"; // Assuming "officer/rejected-booking-list" is the name of your HTML template
return "headquarters/booking-list"; // Assuming "officer/rejected-booking-list" is the name of your HTML
// template
} else {
session.invalidate(); // Invalidate the session to clear all session attributes
return "redirect:/communityhall/login";
@ -452,7 +491,7 @@ public class HeadquartersController {
@GetMapping("/rejected-list")
public String viewRejectedBookings(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if (headquartersname != null) {
if (headquartersname != null && "headquarters".equals(headquartersname)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("headquartersname", headquartersname);
@ -469,7 +508,7 @@ public class HeadquartersController {
@GetMapping("/bookingwaitinglist")
public String viewWaitingBookings(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if (headquartersname != null) {
if (headquartersname != null && "headquarters".equals(headquartersname)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("headquartersname", headquartersname);
@ -486,7 +525,7 @@ public class HeadquartersController {
@GetMapping("/settlement-approved")
public String viewSettlementMaster(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if (headquartersname != null) {
if (headquartersname != null && "headquarters".equals(headquartersname)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
List<BookingDetails> approvedSettlements = bookingDetailsRepository.findAllWithApprovedRefundStatus();
@ -508,7 +547,7 @@ public class HeadquartersController {
@GetMapping("/settlement-initiatedlist")
public String viewSettlementInitiatedMaster(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if (headquartersname != null) {
if (headquartersname != null && "headquarters".equals(headquartersname)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
List<BookingDetails> settlement = bookingDetailsRepository.findByBookingDetailsRefundStatus();
@ -529,21 +568,21 @@ public class HeadquartersController {
@GetMapping("/settlement-list")
public String settlementPendingList(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if (headquartersname != null) {
if (headquartersname != null && "headquarters".equals(headquartersname)) {
model.addAttribute("headquartersname", headquartersname);
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("title", "settlement Pending");
String zone = (String) session.getAttribute("zone");
model.addAttribute("zone", zone);
//ak
List<BookingDetails> settlementIntiated = bookingDetailsRepository.findSettlementInitiatedPending();
// ak
List<BookingDetails> settlementIntiated = bookingDetailsRepository.findSettlementInitiatedPending();
List<BookingDetails> settlement = bookingDetailsRepository.findAllSettlementPending();
List<BookingDetails> cancelledbookings = bookingDetailsRepository.findAllSettlementCancelledList();
List<BookingDetails> rejectedbookings = bookingDetailsRepository.findAllSettlementRejectedList();
model.addAttribute("settlementlist", settlement);
//AK
model.addAttribute("settlementIntiated", settlementIntiated);
// AK
model.addAttribute("settlementIntiated", settlementIntiated);
model.addAttribute("cancelledbookings", cancelledbookings);
model.addAttribute("rejectedbookings", rejectedbookings);
return "headquarters/settlement-list";
@ -556,7 +595,7 @@ public class HeadquartersController {
@GetMapping("/refundfailed-list")
public String RefundFailedList(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if (headquartersname != null) {
if (headquartersname != null && "headquarters".equals(headquartersname)) {
model.addAttribute("headquartersname", headquartersname);
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
@ -564,8 +603,10 @@ public class HeadquartersController {
String zone = (String) session.getAttribute("zone");
model.addAttribute("zone", zone);
List<BookingDetails> settlementrefundfailed = bookingDetailsRepository.findAllSettlementRefundFailed();
List<BookingDetails> refundfailedcancelledbookings = bookingDetailsRepository.findAllRefundFaileCancelledList();
List<BookingDetails> refundfailedrejectedbookings = bookingDetailsRepository.findAllRefundFaileRejectedList();
List<BookingDetails> refundfailedcancelledbookings = bookingDetailsRepository
.findAllRefundFaileCancelledList();
List<BookingDetails> refundfailedrejectedbookings = bookingDetailsRepository
.findAllRefundFaileRejectedList();
model.addAttribute("settlementrefundfailed", settlementrefundfailed);
model.addAttribute("refundfailedcancelledbookings", refundfailedcancelledbookings);
model.addAttribute("refundfailedrejectedbookings", refundfailedrejectedbookings);
@ -579,7 +620,7 @@ public class HeadquartersController {
@GetMapping("/settlement-completedlist")
public String viewSettlementcompletedMaster(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if (headquartersname != null) {
if (headquartersname != null && "headquarters".equals(headquartersname)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
List<BookingDetails> completedlist = bookingDetailsRepository.findSettlementCompletedList();
@ -600,7 +641,7 @@ public class HeadquartersController {
@GetMapping("/settlementlist")
public String viewSettlementList(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if (headquartersname != null) {
if (headquartersname != null && "headquarters".equals(headquartersname)) {
List<BookingDetails> settlemetList = bookingDetailsRepository.getAllSettlementList();
model.addAttribute("headquartersname", headquartersname);
model.addAttribute("settlemetList", settlemetList);
@ -614,7 +655,7 @@ public class HeadquartersController {
@GetMapping("/headquarterspage")
public String viewcaretaker(Model model, HttpSession session, @RequestParam("bookingId") int bookingId) {
String caretakerName = (String) session.getAttribute("usertype");
if (caretakerName != null) {
if (caretakerName != null && "headquarters".equals(caretakerName)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("caretakerName", caretakerName);
@ -632,7 +673,7 @@ public class HeadquartersController {
@GetMapping("/settlement-reject")
public String settlementRejectedList(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if (headquartersname != null) {
if (headquartersname != null && "headquarters".equals(headquartersname)) {
List<BookingDetails> settlement = bookingDetailsRepository.findAllSettlementRejected();
model.addAttribute("headquartersname", headquartersname);
model.addAttribute("title", "Settlement Rejected");
@ -653,7 +694,7 @@ public class HeadquartersController {
@GetMapping("/Gccblocking")
public String viewGccBlocking(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if (headquartersname != null) {
if (headquartersname != null && "headquarters".equals(headquartersname)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("headquartersname", headquartersname);
@ -703,7 +744,7 @@ public class HeadquartersController {
@GetMapping("/viewUploadNoc")
public String viewUploadNoc(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if (headquartersname != null) {
if (headquartersname != null && "headquarters".equals(headquartersname)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("headquartersname", headquartersname);
@ -720,5 +761,255 @@ public class HeadquartersController {
}
}
}
// Newly added by kani for care-take and officer login creation 11/06/2026
@GetMapping("/login-creation")
public String viewLoginCreation(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if (headquartersname != null && "headquarters".equals(headquartersname)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("headquartersname", headquartersname);
// Fetch existing active non-admin logins (returns projection, not full entity)
List<Map<String, Object>> loginList = loginRepository.findActiveLogins();
model.addAttribute("loginList", loginList);
// Fetch hall details for the modal dropdown
List<Map<String, Object>> hallList = hallDetailsRepository.getAllHalls();
model.addAttribute("hallList", hallList);
return "headquarters/login-creation";
} else {
session.invalidate();
return "redirect:/communityhall/login";
}
}
@PostMapping("/login-creation/save")
@ResponseBody
@Transactional
public Map<String, Object> saveLoginCreation(
@RequestParam("mobileNumber") long mobileNumber,
@RequestParam("name") String name,
@RequestParam("password") String password,
@RequestParam("userType") String userType,
@RequestParam("zone") String zone,
@RequestParam(value = "hallIds", required = false) List<Integer> hallIds,
HttpSession session) {
Map<String, Object> response = new HashMap<>();
String headquartersname = (String) session.getAttribute("usertype");
if (headquartersname == null && "headquarters".equals(headquartersname)) {
response.put("status", "error");
response.put("message", "Session expired. Please log in again.");
return response;
}
try {
/* -------- Duplicate hall check for counter / caretaker -------- */
boolean isSingleMode = "counter".equals(userType) || "caretaker".equals(userType);
boolean isMulitpleMode = "officer".equals(userType);
if (isSingleMode && hallIds != null && !hallIds.isEmpty()) {
int hallId = hallIds.get(0);
int existingCount = loginRepository.countActiveLoginsByHallId(hallId, userType);
if (existingCount > 0) {
// Fetch hall name for a clear message
String hallName = hallId + "";
try {
String fetched = hallDetailsRepository.findHallNameById(hallId);
if (fetched != null && !fetched.isBlank())
hallName = fetched;
} catch (Exception ignored) {
}
response.put("status", "error");
response.put("message", "A login already exists for hall \"" + hallName
+ "\". Only one counter/caretaker login is allowed per hall.");
return response;
}
}
/* -------- Duplicate hall check for officer -------- */
if (isMulitpleMode && hallIds != null && !hallIds.isEmpty()) {
int existingCount = loginRepository.getActiveLoginsByHallIds(hallIds, userType);
if (existingCount > 0) {
response.put("status", "error");
response.put("message",
"A login already exists for the selected hall(s). Only one officer login is allowed per hall.");
return response;
}
}
Login login = new Login();
login.setMobileNumber(mobileNumber);
login.setName(name);
login.setPassword(password);
login.setUserType(userType);
login.setZone(zone);
login.setActive(true);
login.setDelete(false);
if (hallIds == null || hallIds.isEmpty()) {
// HQ may have no hall assigned
loginRepository.save(login);
} else if (hallIds.size() == 1) {
// Single hall: store directly in login.hallId
login.setHallId(hallIds.get(0));
loginRepository.save(login);
} else {
// Multiple halls: store first in hallId, rest in login_hall_ids
login.setHallId(hallIds.get(0));
Login savedLogin = loginRepository.save(login);
for (int hallId : hallIds) {
LoginHallId loginHallId = new LoginHallId(savedLogin, hallId);
loginHallIdRepository.save(loginHallId);
}
}
response.put("status", "success");
response.put("message", "Login created successfully.");
} catch (Exception e) {
response.put("status", "error");
response.put("message", "Error creating login: " + e.getMessage());
}
return response;
}
@PostMapping("/login-creation/delete/{id}")
@ResponseBody
@Transactional
public Map<String, Object> deleteLogin(@PathVariable("id") int id, HttpSession session) {
Map<String, Object> response = new HashMap<>();
String headquartersname = (String) session.getAttribute("usertype");
if (headquartersname == null && "headquarters".equals(headquartersname)) {
response.put("status", "error");
response.put("message", "Session expired. Please log in again.");
return response;
}
try {
Login login = loginRepository.findLoginById(id);
if (login == null) {
response.put("status", "error");
response.put("message", "Login not found.");
return response;
}
// Soft delete: set is_active = 0, is_delete = 1
login.setActive(false);
login.setDelete(true);
loginRepository.save(login);
// Also soft-delete any related login_hall_ids
loginHallIdRepository.softDeleteByLoginId(id);
response.put("status", "success");
response.put("message", "Login deleted successfully.");
} catch (Exception e) {
response.put("status", "error");
response.put("message", "Error deleting login: " + e.getMessage());
}
return response;
}
@GetMapping("/login-creation/check-mobile")
@ResponseBody
public Map<String, Object> checkMobileExists(@RequestParam("mobileNumber") long mobileNumber, HttpSession session) {
Map<String, Object> response = new HashMap<>();
try {
int count = loginRepository.countByMobileNumber(mobileNumber);
response.put("exists", count > 0);
} catch (Exception e) {
response.put("exists", false);
response.put("error", e.getMessage());
}
return response;
}
@GetMapping("/login-creation/halls-by-zone")
@ResponseBody
public List<Map<String, Object>> getHallsByZone(@RequestParam("zone") String zone, HttpSession session) {
try {
return hallDetailsRepository.getHallsByZone(zone);
} catch (Exception e) {
return new java.util.ArrayList<>();
}
}
@GetMapping("/login-creation/get-login-halls")
@ResponseBody
public Map<String, Object> getLoginHalls(@RequestParam("loginId") int loginId, HttpSession session) {
Map<String, Object> response = new HashMap<>();
try {
Login login = loginRepository.findLoginById(loginId);
if (login == null) {
response.put("status", "error");
response.put("message", "Login not found.");
return response;
}
// Collect all assigned hall IDs
java.util.List<Integer> assignedHallIds = new java.util.ArrayList<>();
if (login.getHallId() != 0) {
assignedHallIds.add(login.getHallId());
}
loginHallIdRepository.findActiveByLoginId(loginId).forEach(lh -> assignedHallIds.add(lh.getHallId()));
response.put("status", "success");
response.put("loginId", loginId);
response.put("name", login.getName());
response.put("zone", login.getZone());
response.put("userType", login.getUserType());
response.put("assignedHallIds", assignedHallIds);
// Also return all halls for the zone
response.put("hallsForZone", hallDetailsRepository.getHallsByZone(login.getZone()));
} catch (Exception e) {
response.put("status", "error");
response.put("message", "Error fetching login halls: " + e.getMessage());
}
return response;
}
@PostMapping("/login-creation/update-halls")
@ResponseBody
@Transactional
public Map<String, Object> updateLoginHalls(
@RequestParam("loginId") int loginId,
@RequestParam("hallIds") java.util.List<Integer> hallIds,
HttpSession session) {
Map<String, Object> response = new HashMap<>();
try {
Login login = loginRepository.findLoginById(loginId);
if (login == null) {
response.put("status", "error");
response.put("message", "Login not found.");
return response;
}
if (hallIds == null || hallIds.isEmpty()) {
response.put("status", "error");
response.put("message", "At least one hall must be selected.");
return response;
}
// Clear all existing login_hall_ids rows for this login
loginHallIdRepository.softDeleteByLoginId(loginId);
if (hallIds.size() == 1) {
// Single hall: store in login.hall_id only
login.setHallId(hallIds.get(0));
loginRepository.save(login);
} else {
// Multiple halls: first goes to login.hall_id, rest to login_hall_ids
login.setHallId(hallIds.get(0));
loginRepository.save(login);
for (int i = 1; i < hallIds.size(); i++) {
LoginHallId lh = new LoginHallId(login, hallIds.get(i));
loginHallIdRepository.save(lh);
}
}
response.put("status", "success");
response.put("message", "Hall assignment updated successfully.");
} catch (Exception e) {
response.put("status", "error");
response.put("message", "Error updating halls: " + e.getMessage());
}
return response;
}
}

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

@ -80,13 +80,17 @@ public class OfficerController {
@GetMapping("/officer-dashboard")
public String viewDashboard(Model model, HttpSession session) {
String officername = (String) session.getAttribute("usertype");
if (officername != null) {
if (officername != null && "officer".equals(officername)) {
String zone = (String) session.getAttribute("zone");
model.addAttribute("officername", officername);
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
List<Integer> hallIds = (List<Integer>) session.getAttribute("hall_ids");
System.out.println("HallIds in officer Dashboard: " + hallIds.toString());
model.addAttribute("mobileno", mobileno);
model.addAttribute("zone", zone);
model.addAttribute("hallIds", hallIds);
return "officer/officer-dashboard";
} else {
@ -98,15 +102,18 @@ public class OfficerController {
@GetMapping("/booking-pending")
public String viewhall(Model model, HttpSession session) {
String officername = (String) session.getAttribute("usertype");
if (officername != null) {
if (officername != null && "officer".equals(officername)) {
model.addAttribute("officername", officername);
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("title", "pending bookings");
model.addAttribute("baseURL", appConfig.getBaseUrl());
String zone = (String) session.getAttribute("zone");
List<Integer> hallIds = (List<Integer>) session.getAttribute("hall_ids");
model.addAttribute("zone", zone);
List<BookingDetails> pendingbooking = bookingDetailsRepository.getPendingOrPaymentFailureBookings(zone);
model.addAttribute("hallIds", hallIds);
List<BookingDetails> pendingbooking = bookingDetailsRepository.getPendingOrPaymentFailureBookings(zone,
hallIds);
model.addAttribute("pendingbooking", pendingbooking);
return "officer/booking-pending";
} else {
@ -118,16 +125,18 @@ public class OfficerController {
@GetMapping("/payment-list")
public String viewPayment(Model model, HttpSession session) {
String officername = (String) session.getAttribute("usertype");
if (officername != null) {
if (officername != null && "officer".equals(officername)) {
model.addAttribute("officername", officername);
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("title", "paymentlist");
model.addAttribute("baseURL", appConfig.getBaseUrl());
String zone = (String) session.getAttribute("zone");
List<Integer> hallIds = (List<Integer>) session.getAttribute("hall_ids");
model.addAttribute("zone", zone);
model.addAttribute("hallIds", hallIds);
// System.out.println(zone);
List<Payments> pay = paymentsRepository.getPaymentListByzone(zone);
List<Payments> pay = paymentsRepository.getPaymentListByzoneandHall(zone, hallIds);
model.addAttribute("paymentlist", pay);
return "officer/payment-list";
} else {
@ -139,15 +148,17 @@ public class OfficerController {
@GetMapping("/bookingwaitinglist")
public String viewWaitingBookings(Model model, HttpSession session) {
String officername = (String) session.getAttribute("usertype");
if (officername != null) {
if (officername != null && "officer".equals(officername)) {
model.addAttribute("officername", officername);
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("title", "bookinglist");
model.addAttribute("baseURL", appConfig.getBaseUrl());
String zone = (String) session.getAttribute("zone");
List<Integer> hallIds = (List<Integer>) session.getAttribute("hall_ids");
model.addAttribute("zone", zone);
List<BookingDetails> bookingList = bookingDetailsRepository.getWaitinglist(zone);
model.addAttribute("hallIds", hallIds);
List<BookingDetails> bookingList = bookingDetailsRepository.getWaitinglist(zone, hallIds);
model.addAttribute("bookingList", bookingList);
return "officer/booking-list"; // Assuming "officer/rejected-booking-list" is the name of your HTML template
} else {
@ -159,15 +170,17 @@ public class OfficerController {
@GetMapping("/booking-list")
public String viewBookingList(Model model, HttpSession session) {
String officername = (String) session.getAttribute("usertype");
if (officername != null) {
if (officername != null && "officer".equals(officername)) {
model.addAttribute("officername", officername);
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("title", "bookinglist");
model.addAttribute("baseURL", appConfig.getBaseUrl());
String zone = (String) session.getAttribute("zone");
List<Integer> hallIds = (List<Integer>) session.getAttribute("hall_ids");
model.addAttribute("zone", zone);
List<BookingDetails> bookingList = bookingDetailsRepository.getApprovedlist(zone);
model.addAttribute("hallIds", hallIds);
List<BookingDetails> bookingList = bookingDetailsRepository.getApprovedlist(zone, hallIds);
model.addAttribute("bookingList", bookingList);
return "officer/booking-list"; // Assuming "officer/rejected-booking-list" is the name of your HTML template
} else {
@ -179,15 +192,17 @@ public class OfficerController {
@GetMapping("/rejected-list")
public String viewRejectedBookings(Model model, HttpSession session) {
String officername = (String) session.getAttribute("usertype");
if (officername != null) {
if (officername != null && "officer".equals(officername)) {
model.addAttribute("officername", officername);
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("title", "rejectedlist");
model.addAttribute("baseURL", appConfig.getBaseUrl());
String zone = (String) session.getAttribute("zone");
List<Integer> hallIds = (List<Integer>) session.getAttribute("hall_ids");
model.addAttribute("zone", zone);
List<BookingDetails> rejectedBookings = bookingDetailsRepository.getrejectedlist(zone);
model.addAttribute("hallIds", hallIds);
List<BookingDetails> rejectedBookings = bookingDetailsRepository.getrejectedlist(zone, hallIds);
model.addAttribute("rejectedBookings", rejectedBookings);
return "officer/rejected-list";
@ -200,21 +215,23 @@ public class OfficerController {
@GetMapping("/settlement-list")
public String settlementPendingList(Model model, HttpSession session) {
String officername = (String) session.getAttribute("usertype");
if (officername != null) {
if (officername != null && "officer".equals(officername)) {
model.addAttribute("officername", officername);
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("title", "settlement Pending");
model.addAttribute("baseURL", appConfig.getBaseUrl());
String zone = (String) session.getAttribute("zone");
List<Integer> hallIds = (List<Integer>) session.getAttribute("hall_ids");
model.addAttribute("zone", zone);
model.addAttribute("hallIds", hallIds);
System.out.println("Zone: " + zone);
List<BookingDetails> settlement = bookingDetailsRepository.findSettlementPendingByZone(zone);
List<BookingDetails> settlement = bookingDetailsRepository.findSettlementPendingByZone(zone, hallIds);
// ak
List<BookingDetails> settlementIntiated = bookingDetailsRepository
.findSettlementInitiatedPendingByZone(zone);
List<BookingDetails> cancelledbookings = bookingDetailsRepository.findCancelledListByZone(zone);
List<BookingDetails> rejectedbookings = bookingDetailsRepository.findRejectedListByZone(zone);
.findSettlementInitiatedPendingByZone(zone, hallIds);
List<BookingDetails> cancelledbookings = bookingDetailsRepository.findCancelledListByZone(zone, hallIds);
List<BookingDetails> rejectedbookings = bookingDetailsRepository.findRejectedListByZone(zone, hallIds);
model.addAttribute("settlementlist", settlement);
// AK
model.addAttribute("settlementIntiated", settlementIntiated);
@ -231,20 +248,22 @@ public class OfficerController {
@GetMapping("/refundfailed-list")
public String RefundFailedList(Model model, HttpSession session) {
String officername = (String) session.getAttribute("usertype");
if (officername != null) {
if (officername != null && "officer".equals(officername)) {
model.addAttribute("officername", officername);
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("title", "settlementapproved");
model.addAttribute("baseURL", appConfig.getBaseUrl());
String zone = (String) session.getAttribute("zone");
List<Integer> hallIds = (List<Integer>) session.getAttribute("hall_ids");
model.addAttribute("zone", zone);
model.addAttribute("hallIds", hallIds);
List<BookingDetails> settlementrefundfailed = bookingDetailsRepository
.findSettlementRefundFailedByZone(zone);
.findSettlementRefundFailedByZone(zone, hallIds);
List<BookingDetails> refundfailedcancelledbookings = bookingDetailsRepository
.findRefundFaileCancelledListByZone(zone);
.findRefundFaileCancelledListByZone(zone, hallIds);
List<BookingDetails> refundfailedrejectedbookings = bookingDetailsRepository
.findRefundFaileRejectedListByZone(zone);
.findRefundFaileRejectedListByZone(zone, hallIds);
model.addAttribute("settlementrefundfailed", settlementrefundfailed);
model.addAttribute("refundfailedcancelledbookings", refundfailedcancelledbookings);
model.addAttribute("refundfailedrejectedbookings", refundfailedrejectedbookings);
@ -258,19 +277,21 @@ public class OfficerController {
@GetMapping("/settlement-approved")
public String settlementApprovedList(Model model, HttpSession session) {
String officername = (String) session.getAttribute("usertype");
if (officername != null) {
if (officername != null && "officer".equals(officername)) {
model.addAttribute("officername", officername);
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("title", "settlementapproved");
model.addAttribute("baseURL", appConfig.getBaseUrl());
String zone = (String) session.getAttribute("zone");
List<Integer> hallIds = (List<Integer>) session.getAttribute("hall_ids");
model.addAttribute("zone", zone);
List<BookingDetails> settlement = bookingDetailsRepository.findSettlementApprovedByZone(zone);
model.addAttribute("hallIds", hallIds);
List<BookingDetails> settlement = bookingDetailsRepository.findSettlementApprovedByZone(zone, hallIds);
List<BookingDetails> approvedcancelledbookings = bookingDetailsRepository
.findapprovedCancelledListByZone(zone);
.findapprovedCancelledListByZone(zone, hallIds);
List<BookingDetails> approvedrejectedbookings = bookingDetailsRepository
.findapprovedRejectedListByZone(zone);
.findapprovedRejectedListByZone(zone, hallIds);
model.addAttribute("approvedSettlementlist", settlement);
model.addAttribute("approvedcancelledbookings", approvedcancelledbookings);
model.addAttribute("approvedrejectedbookings", approvedrejectedbookings);
@ -284,15 +305,17 @@ public class OfficerController {
@GetMapping("/settlement-reject")
public String settlementRejectedList(Model model, HttpSession session) {
String officername = (String) session.getAttribute("usertype");
if (officername != null) {
if (officername != null && "officer".equals(officername)) {
model.addAttribute("officername", officername);
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("title", "settlement rejected");
model.addAttribute("baseURL", appConfig.getBaseUrl());
String zone = (String) session.getAttribute("zone");
List<Integer> hallIds = (List<Integer>) session.getAttribute("hall_ids");
model.addAttribute("zone", zone);
List<BookingDetails> settlement = bookingDetailsRepository.findSettlementRejectedByZone(zone);
model.addAttribute("hallIds", hallIds);
List<BookingDetails> settlement = bookingDetailsRepository.findSettlementRejectedByZone(zone, hallIds);
model.addAttribute("rejectSettlementlist", settlement);
return "officer/settlement-reject";
} else {
@ -304,16 +327,19 @@ public class OfficerController {
@GetMapping("/settlement-completedlist")
public String viewSettlementcompletedMaster(Model model, HttpSession session) {
String officername = (String) session.getAttribute("usertype");
if (officername != null) {
if (officername != null && "officer".equals(officername)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
String zone = (String) session.getAttribute("zone");
List<Integer> hallIds = (List<Integer>) session.getAttribute("hall_ids");
model.addAttribute("zone", zone);
List<BookingDetails> completedlist = bookingDetailsRepository.findSettlementCompletedListbyzone(zone);
model.addAttribute("hallIds", hallIds);
List<BookingDetails> completedlist = bookingDetailsRepository
.findSettlementCompletedListbyzone(zone, hallIds);
List<BookingDetails> cancelledcompletedlist = bookingDetailsRepository
.findCancelledCompletedListbyzone(zone);
.findCancelledCompletedListbyzone(zone, hallIds);
List<BookingDetails> rejectedcompletedlist = bookingDetailsRepository
.findRejectedSettlementCompletedListbyzone(zone);
.findRejectedSettlementCompletedListbyzone(zone, hallIds);
model.addAttribute("title", "settlement initiate");
model.addAttribute("officername", officername);
model.addAttribute("completedlist", completedlist);
@ -329,12 +355,14 @@ public class OfficerController {
@GetMapping("/reports")
public String viewReports(Model model, HttpSession session) {
String officername = (String) session.getAttribute("usertype");
if (officername != null) {
if (officername != null && "officer".equals(officername)) {
String zone = (String) session.getAttribute("zone");
List<Integer> hallIds = (List<Integer>) session.getAttribute("hall_ids");
model.addAttribute("officername", officername);
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("zone", zone);
model.addAttribute("hallIds", hallIds);
List<HallDetails> hallnames = hallDetailsService.getHallNames();
model.addAttribute("hallnames", hallnames);
return "officer/report";
@ -347,12 +375,14 @@ public class OfficerController {
@GetMapping("/getReport")
public String viewgetReports(Model model, HttpSession session) {
String officername = (String) session.getAttribute("usertype");
if (officername != null) {
if (officername != null && "officer".equals(officername)) {
String zone = (String) session.getAttribute("zone");
List<Integer> hallIds = (List<Integer>) session.getAttribute("hall_ids");
model.addAttribute("officername", officername);
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("zone", zone);
model.addAttribute("hallIds", hallIds);
List<HallDetails> hallnames = hallDetailsService.getHallNames();
model.addAttribute("hallnames", hallnames);
return "officer/report";
@ -372,9 +402,11 @@ public class OfficerController {
@RequestParam(name = "refundStatus", required = false) String refundStatus,
@RequestParam(name = "hallname", required = false, defaultValue = "0") Integer hallId) {
String officername = (String) session.getAttribute("usertype");
if (officername != null) {
if (officername != null && "officer".equals(officername)) {
String zone = (String) session.getAttribute("zone");
List<Integer> hallIds = (List<Integer>) session.getAttribute("hall_ids");
model.addAttribute("zone", zone);
model.addAttribute("hallIds", hallIds);
model.addAttribute("officername", officername);
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
@ -519,14 +551,16 @@ public class OfficerController {
@GetMapping("/counter-refund")
public String counterRefundList(Model model, HttpSession session) {
String officername = (String) session.getAttribute("usertype");
if (officername != null) {
if (officername != null && "officer".equals(officername)) {
model.addAttribute("officername", officername);
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("title", "settlement rejected");
model.addAttribute("baseURL", appConfig.getBaseUrl());
String zone = (String) session.getAttribute("zone");
List<Integer> hallIds = (List<Integer>) session.getAttribute("hall_ids");
model.addAttribute("zone", zone);
model.addAttribute("hallIds", hallIds);
List<CounterRefundList> counterRefund = counterRefundListRepository.findCounterRefundList(zone);
model.addAttribute("counterRefund", counterRefund);
return "officer/counter-refund";
@ -547,10 +581,12 @@ public class OfficerController {
@GetMapping("/Gccblocking")
public String viewGccBlocking(Model model, HttpSession session) {
String officername = (String) session.getAttribute("usertype");
if (officername != null) {
if (officername != null && "officer".equals(officername)) {
long mobileno = (long) session.getAttribute("mobileno");
List<Integer> accesshallIds = (List<Integer>) session.getAttribute("hall_ids");
model.addAttribute("mobileno", mobileno);
model.addAttribute("officername", officername);
model.addAttribute("hallIds", accesshallIds);
// Fetch all blocked GCC dates
List<GccBlockingDate> gccBlocked = blockingDateRepository.findAllBlocked();

52
src/main/java/com/gcc/communityHall/controller/UserAPIController.java

@ -224,8 +224,8 @@ public class UserAPIController {
// System.out.println(purpose);
// System.out.print("\n MobileNo---:"+mobileNo);
Random rand = new Random();
int otp = rand.nextInt(90000) + 10000;
// int otp = 11111;
// int otp = rand.nextInt(90000) + 10000;
int otp = 11111;
System.out.print("\n otp---:" + otp);
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd-MMM-yyyy%20HH:mm");
LocalDateTime now = LocalDateTime.now();
@ -238,29 +238,31 @@ public class UserAPIController {
System.out.println(urlString);
System.out.println("\n urlString---: " + urlString);
String bodyMessage = "" + otp;
try {
RestTemplate restTemplate = new RestTemplate();
String Response = restTemplate.getForObject(urlString, String.class);
bodyMessage = Response;
SmsSender sms = new SmsSender();
sms.setPhone(MobileNo);
sms.setCdate(new Date());
sms.setBodyMsg(bodyMessage);
sms.setPurpose(purpose);
smsSenderRepository.save(sms);
String whatsappMsg =
"https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to="
+ MobileNo
+
"&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Welcome+to+GCC%21+%0A%0AYour+OTP+for+GCC+Community+Centre+is+"
+ otp + "+.";
String sendMsg = whatsappMsgServiceImpl.sendMsg(whatsappMsg);
System.out.println("sendwhatsuprepsosne====" + sendMsg);
} catch (Exception e) {
// System.out.print("ERROR in Sending---: "+e);
bodyMessage = "Error";
}
/*
* try {
* RestTemplate restTemplate = new RestTemplate();
* String Response = restTemplate.getForObject(urlString, String.class);
* bodyMessage = Response;
* SmsSender sms = new SmsSender();
* sms.setPhone(MobileNo);
* sms.setCdate(new Date());
* sms.setBodyMsg(bodyMessage);
* sms.setPurpose(purpose);
* smsSenderRepository.save(sms);
*
* String whatsappMsg =
* "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to="
* + MobileNo
* +
* "&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Welcome+to+GCC%21+%0A%0AYour+OTP+for+GCC+Community+Centre+is+"
* + otp + "+.";
* String sendMsg = whatsappMsgServiceImpl.sendMsg(whatsappMsg);
* System.out.println("sendwhatsuprepsosne====" + sendMsg);
* } catch (Exception e) {
* // System.out.print("ERROR in Sending---: "+e);
* bodyMessage = "Error";
* }
*/
HttpSession session = request.getSession();
session.setAttribute("otp", otp);
return bodyMessage;

70
src/main/java/com/gcc/communityHall/entity/Login.java

@ -1,17 +1,29 @@
package com.gcc.communityHall.entity;
import jakarta.persistence.CascadeType;
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.OneToMany;
import java.util.ArrayList;
import java.util.List;
@Entity
public class Login {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private int hallId;
@OneToMany(mappedBy = "login", cascade = CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval = true)
private List<LoginHallId> loginHallIds = new ArrayList<>();
private String name;
private long mobileNumber;
private String password;
@ -19,6 +31,14 @@ public class Login {
private String userType;
private String zone;
@Column(name = "is_active", nullable = false, columnDefinition = "TINYINT(1) DEFAULT 1")
private boolean isActive = true;
@Column(name = "is_delete", nullable = false, columnDefinition = "TINYINT(1) DEFAULT 0")
private boolean isDelete = false;
// ---- Getters & Setters ----
public int getId() {
return id;
}
@ -35,6 +55,27 @@ public class Login {
this.hallId = hallId;
}
public List<LoginHallId> getLoginHallIds() {
return loginHallIds;
}
public void setLoginHallIds(List<LoginHallId> loginHallIds) {
this.loginHallIds = loginHallIds;
}
/**
* Convenience method: returns only the active, non-deleted hall IDs.
*/
public List<Integer> getHallIds() {
List<Integer> ids = new ArrayList<>();
for (LoginHallId lhid : loginHallIds) {
if (lhid.isActive() && !lhid.isDelete()) {
ids.add(lhid.getHallId());
}
}
return ids;
}
public String getName() {
return name;
}
@ -75,12 +116,27 @@ public class Login {
this.userType = userType;
}
public String getZone() {
return zone;
}
public String getZone() {
return zone;
}
public void setZone(String zone) {
this.zone = zone;
}
public boolean isActive() {
return isActive;
}
public void setActive(boolean isActive) {
this.isActive = isActive;
}
public void setZone(String zone) {
this.zone = zone;
}
public boolean isDelete() {
return isDelete;
}
public void setDelete(boolean isDelete) {
this.isDelete = isDelete;
}
}

103
src/main/java/com/gcc/communityHall/entity/LoginHallId.java

@ -0,0 +1,103 @@
package com.gcc.communityHall.entity;
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;
import org.hibernate.annotations.CreationTimestamp;
import java.time.LocalDateTime;
@Entity
@Table(name = "login_hall_ids")
public class LoginHallId {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private int id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "login_id", nullable = false)
private Login login;
@Column(name = "hall_id", nullable = false)
private int hallId;
@Column(name = "is_active", nullable = false, columnDefinition = "TINYINT(1) DEFAULT 1")
private boolean isActive = true;
@Column(name = "is_delete", nullable = false, columnDefinition = "TINYINT(1) DEFAULT 0")
private boolean isDelete = false;
@CreationTimestamp
@Column(name = "cdate", updatable = false, columnDefinition = "DATETIME DEFAULT CURRENT_TIMESTAMP")
private LocalDateTime cdate;
// ---- Constructors ----
public LoginHallId() {
}
public LoginHallId(Login login, int hallId) {
this.login = login;
this.hallId = hallId;
this.isActive = true;
this.isDelete = false;
}
// ---- Getters & Setters ----
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public Login getLogin() {
return login;
}
public void setLogin(Login login) {
this.login = login;
}
public int getHallId() {
return hallId;
}
public void setHallId(int hallId) {
this.hallId = hallId;
}
public boolean isActive() {
return isActive;
}
public void setActive(boolean isActive) {
this.isActive = isActive;
}
public boolean isDelete() {
return isDelete;
}
public void setDelete(boolean isDelete) {
this.isDelete = isDelete;
}
public LocalDateTime getCdate() {
return cdate;
}
public void setCdate(LocalDateTime cdate) {
this.cdate = cdate;
}
}

3120
src/main/java/com/gcc/communityHall/repository/BookingDetailsRepository.java
File diff suppressed because it is too large
View File

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

@ -1,6 +1,5 @@
package com.gcc.communityHall.repository;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -13,31 +12,35 @@ import org.springframework.stereotype.Repository;
import com.gcc.communityHall.entity.HallDetails;
@Repository
public interface HallDetailsRepository extends JpaRepository<HallDetails,Integer> {
@Query(value= "select id from halldetails", nativeQuery=true)
public interface HallDetailsRepository extends JpaRepository<HallDetails, Integer> {
@Query(value = "select id from halldetails", nativeQuery = true)
List<String> getHallAvailablity();
@Query(value = "SELECT * FROM hall_details where hall_id NOT IN (:groupByHallIdToRemov) ",nativeQuery = true)
List<HallDetails> removeHallById(Set<Integer> groupByHallIdToRemov);
@Query(value = "SELECT * FROM hall_details where hall_id NOT IN (:groupByHallIdToRemov) ", nativeQuery = true)
List<HallDetails> removeHallById(Set<Integer> groupByHallIdToRemov);
@Query("SELECT h FROM HallDetails h WHERE h.division = :division ")
List<HallDetails> findByDivision(@Param("division") String division);
@Query("SELECT h FROM HallDetails h WHERE h.zone = :zone ")
List<HallDetails> findByZone(@Param("zone") String zone);
@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);
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();
@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);
@Query(value = "SELECT hall_id, hall_name FROM hall_details where is_active = 1 ", nativeQuery = true)
List<Map<String, Object>> getAllHalls();
@Query(value = "SELECT hall_id, hall_name FROM hall_details WHERE zone = :zone and is_active = 1 ", nativeQuery = true)
@Query(value = "SELECT division,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);
@Query(value = "SELECT hall_id AS hallId, hall_name AS hallName FROM hall_details WHERE zone IN (:zones) and is_active = 1 ", nativeQuery = true)
@ -46,10 +49,9 @@ public interface HallDetailsRepository extends JpaRepository<HallDetails,Integer
@Query(value = "SELECT * FROM hall_details WHERE is_active = 1 order by hall_name asc", nativeQuery = true)
List<HallDetails> findActiveHalls();
// admin dashboard
//admin dashboard
@Query(nativeQuery = true, value ="SELECT SUM(CASE WHEN b.booking_status = 'APPROVED' THEN 1 ELSE 0 END) AS approvedCount,\r\n"
@Query(nativeQuery = true, value = "SELECT SUM(CASE WHEN b.booking_status = 'APPROVED' THEN 1 ELSE 0 END) AS approvedCount,\r\n"
+ "SUM(CASE WHEN b.booking_status = 'REJECTED' THEN 1 ELSE 0 END) AS rejectedCount,\r\n"
+ "SUM(CASE WHEN b.booking_status = 'COMPLETED' THEN 1 ELSE 0 END) AS completedCount, \r\n"
+ "SUM(CASE WHEN b.booking_status = 'CANCELED' THEN 1 ELSE 0 END) AS canceledCount, \r\n"
@ -59,57 +61,60 @@ public interface HallDetailsRepository extends JpaRepository<HallDetails,Integer
+ "FROM hall_details h LEFT JOIN booking_details b ON b.hall_details_hall_id = h.hall_id WHERE h.zone = :zone AND b.booking_status!='PENDING'")
Map<String, Object> getTotalBookingsAndAmountReceivedByZone(@Param("zone") String zone);
@Query(nativeQuery = true, value ="SELECT h.hall_id AS hall_id, h.zone AS zonename,h.division AS division, h.hall_name AS hallName, " +
"SUM(CASE WHEN b.booking_status = 'APPROVED' THEN 1 ELSE 0 END) AS approvedCount, " +
"SUM(CASE WHEN b.booking_status = 'REJECTED' THEN 1 ELSE 0 END) AS rejectedCount, " +
"SUM(CASE WHEN b.booking_status = 'COMPLETED' THEN 1 ELSE 0 END) AS completedCount, " +
"SUM(CASE WHEN b.booking_status = 'CANCELED' THEN 1 ELSE 0 END) AS canceledCount, " +
"SUM(CASE WHEN b.booking_status = 'PAYMENT_FAILURE' THEN 1 ELSE 0 END) AS paymentFailureCount, " +
"SUM(CASE WHEN b.booking_status = 'GCC_BLOCKED' THEN 1 ELSE 0 END) AS gccBlockedCount, " +
"COUNT(b.booking_status) AS totalBookings, " +
"SUM(CASE WHEN b.amount_received IS NULL THEN 0 ELSE b.amount_received END) AS totalAmount " +
"FROM hall_details h LEFT JOIN booking_details b ON b.hall_details_hall_id = h.hall_id WHERE h.zone = :zone AND b.booking_status!='PENDING' "+
"GROUP BY h.hall_id,h.zone,h.division,h.hall_name")
@Query(nativeQuery = true, value = "SELECT h.hall_id AS hall_id, h.zone AS zonename,h.division AS division, h.hall_name AS hallName, "
+
"SUM(CASE WHEN b.booking_status = 'APPROVED' THEN 1 ELSE 0 END) AS approvedCount, " +
"SUM(CASE WHEN b.booking_status = 'REJECTED' THEN 1 ELSE 0 END) AS rejectedCount, " +
"SUM(CASE WHEN b.booking_status = 'COMPLETED' THEN 1 ELSE 0 END) AS completedCount, " +
"SUM(CASE WHEN b.booking_status = 'CANCELED' THEN 1 ELSE 0 END) AS canceledCount, " +
"SUM(CASE WHEN b.booking_status = 'PAYMENT_FAILURE' THEN 1 ELSE 0 END) AS paymentFailureCount, " +
"SUM(CASE WHEN b.booking_status = 'GCC_BLOCKED' THEN 1 ELSE 0 END) AS gccBlockedCount, " +
"COUNT(b.booking_status) AS totalBookings, " +
"SUM(CASE WHEN b.amount_received IS NULL THEN 0 ELSE b.amount_received END) AS totalAmount " +
"FROM hall_details h LEFT JOIN booking_details b ON b.hall_details_hall_id = h.hall_id WHERE h.zone = :zone AND b.booking_status!='PENDING' "
+
"GROUP BY h.hall_id,h.zone,h.division,h.hall_name")
List<Map<String, Object>> getHallDetailsByZone(@Param("zone") String zone);
@Query(value = "SELECT zone,division,hall_id,hall_name FROM hall_details where is_active = 1 ",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();
// officer dashboard
//officer dashboard
@Query(nativeQuery = true, value ="SELECT SUM(CASE WHEN b.booking_status = 'APPROVED' THEN 1 ELSE 0 END) AS approvedCount,\r\n"
+ "SUM(CASE WHEN b.booking_status = 'REJECTED' THEN 1 ELSE 0 END) AS rejectedCount,\r\n"
+ "SUM(CASE WHEN b.booking_status = 'COMPLETED' THEN 1 ELSE 0 END) AS completedCount, \r\n"
+ "SUM(CASE WHEN b.booking_status = 'CANCELED' THEN 1 ELSE 0 END) AS canceledCount, \r\n"
+ "SUM(CASE WHEN b.booking_status = 'PAYMENT_FAILURE' THEN 1 ELSE 0 END) AS paymentFailureCount, \r\n"
+ "SUM(CASE WHEN b.booking_status = 'GCC_BLOCKED' THEN 1 ELSE 0 END) AS gccBlockedCount,\r\n"
+ "COUNT(b.booking_status) AS totalBooking, SUM( CASE WHEN b.amount_received IS NULL THEN 0 ELSE b.amount_received END ) AS amountReceived \r\n"
+ "FROM hall_details h LEFT JOIN booking_details b ON b.hall_details_hall_id = h.hall_id WHERE h.zone = :zone AND b.booking_status!='PENDING'")
Map<String, Object> getTotalCountsForOfficer(@Param("zone") String zone);
@Query(nativeQuery = true, value ="SELECT h.hall_id AS hall_id, h.zone AS zonename,h.division AS division, h.hall_name AS hallName, " +
"SUM(CASE WHEN b.booking_status = 'APPROVED' THEN 1 ELSE 0 END) AS approvedCount, " +
"SUM(CASE WHEN b.booking_status = 'REJECTED' THEN 1 ELSE 0 END) AS rejectedCount, " +
"SUM(CASE WHEN b.booking_status = 'COMPLETED' THEN 1 ELSE 0 END) AS completedCount, " +
"SUM(CASE WHEN b.booking_status = 'CANCELED' THEN 1 ELSE 0 END) AS canceledCount, " +
"SUM(CASE WHEN b.booking_status = 'PAYMENT_FAILURE' THEN 1 ELSE 0 END) AS paymentFailureCount, " +
"SUM(CASE WHEN b.booking_status = 'GCC_BLOCKED' THEN 1 ELSE 0 END) AS gccBlockedCount, " +
"COUNT(b.booking_status) AS totalBookings, " +
"SUM(CASE WHEN b.amount_received IS NULL THEN 0 ELSE b.amount_received END) AS totalAmount " +
"FROM hall_details h LEFT JOIN booking_details b ON b.hall_details_hall_id = h.hall_id WHERE h.zone = :zone AND b.booking_status!='PENDING' "+
"GROUP BY h.hall_id,h.zone,h.division,h.hall_name")
List<Map<String, Object>> getHallCountsForOfficer(@Param("zone") String zone);
@Query(nativeQuery = true, value = "SELECT SUM(CASE WHEN b.booking_status = 'APPROVED' THEN 1 ELSE 0 END) AS approvedCount,\r\n"
+ "SUM(CASE WHEN b.booking_status = 'REJECTED' THEN 1 ELSE 0 END) AS rejectedCount,\r\n"
+ "SUM(CASE WHEN b.booking_status = 'COMPLETED' THEN 1 ELSE 0 END) AS completedCount, \r\n"
+ "SUM(CASE WHEN b.booking_status = 'CANCELED' THEN 1 ELSE 0 END) AS canceledCount, \r\n"
+ "SUM(CASE WHEN b.booking_status = 'PAYMENT_FAILURE' THEN 1 ELSE 0 END) AS paymentFailureCount, \r\n"
+ "SUM(CASE WHEN b.booking_status = 'GCC_BLOCKED' THEN 1 ELSE 0 END) AS gccBlockedCount,\r\n"
+ "COUNT(b.booking_status) AS totalBooking, SUM( CASE WHEN b.amount_received IS NULL THEN 0 ELSE b.amount_received END ) AS amountReceived \r\n"
+ "FROM hall_details h LEFT JOIN booking_details b ON b.hall_details_hall_id = h.hall_id WHERE h.zone = :zone AND b.booking_status!='PENDING'")
Map<String, Object> getTotalCountsForOfficer(@Param("zone") String zone);
@Query(nativeQuery = true, value = "SELECT h.hall_id AS hall_id, h.zone AS zonename,h.division AS division, h.hall_name AS hallName, "
+
"SUM(CASE WHEN b.booking_status = 'APPROVED' THEN 1 ELSE 0 END) AS approvedCount, " +
"SUM(CASE WHEN b.booking_status = 'REJECTED' THEN 1 ELSE 0 END) AS rejectedCount, " +
"SUM(CASE WHEN b.booking_status = 'COMPLETED' THEN 1 ELSE 0 END) AS completedCount, " +
"SUM(CASE WHEN b.booking_status = 'CANCELED' THEN 1 ELSE 0 END) AS canceledCount, " +
"SUM(CASE WHEN b.booking_status = 'PAYMENT_FAILURE' THEN 1 ELSE 0 END) AS paymentFailureCount, " +
"SUM(CASE WHEN b.booking_status = 'GCC_BLOCKED' THEN 1 ELSE 0 END) AS gccBlockedCount, " +
"COUNT(b.booking_status) AS totalBookings, " +
"SUM(CASE WHEN b.amount_received IS NULL THEN 0 ELSE b.amount_received END) AS totalAmount " +
"FROM hall_details h LEFT JOIN booking_details b ON b.hall_details_hall_id = h.hall_id WHERE h.zone = :zone AND b.booking_status!='PENDING' "
+
"GROUP BY h.hall_id,h.zone,h.division,h.hall_name")
List<Map<String, Object>> getHallCountsForOfficer(@Param("zone") String zone);
@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);
@Query("SELECT DISTINCT h.division FROM HallDetails h WHERE h.zone = :zone ")
List<String> findDistinctDivisionsByZone(@Param("zone") String zone);
@Query("SELECT DISTINCT h.division FROM HallDetails h WHERE h.zone = :zone ")
List<String> findDistinctDivisionsByZone(@Param("zone") String zone);
// Query to get hall names by division
@Query("SELECT h.hallName FROM HallDetails h WHERE h.division = :division and h.isActive = true ")
List<String> findHallsByDivision(@Param("division") String division);
// Query to get hall names by division
@Query("SELECT h.hallName FROM HallDetails h WHERE h.division = :division and h.isActive = true ")
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);

25
src/main/java/com/gcc/communityHall/repository/LoginHallIdRepository.java

@ -0,0 +1,25 @@
package com.gcc.communityHall.repository;
import com.gcc.communityHall.entity.LoginHallId;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface LoginHallIdRepository extends JpaRepository<LoginHallId, Integer> {
@Query(value = "SELECT * FROM login_hall_ids WHERE login_id = :loginId AND is_active = 1 AND is_delete = 0", nativeQuery = true)
List<LoginHallId> findActiveByLoginId(@Param("loginId") int loginId);
@Modifying
@Query(value = "UPDATE login_hall_ids SET is_active = 0, is_delete = 1 WHERE login_id = :loginId", nativeQuery = true)
void softDeleteByLoginId(@Param("loginId") int loginId);
@Modifying
@Query(value = "DELETE FROM login_hall_ids WHERE login_id = :loginId", nativeQuery = true)
void deleteAllByLoginId(@Param("loginId") int loginId);
}

82
src/main/java/com/gcc/communityHall/repository/LoginRepository.java

@ -1,21 +1,95 @@
package com.gcc.communityHall.repository;
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.Login;
import java.util.List;
import java.util.Map;
@Repository
public interface LoginRepository extends JpaRepository<Login, Long> {
@Query(value = "SELECT * FROM login where mobile_number=:mobileNo and password=:pin",nativeQuery = true)
Login findByMobileNoAndPin(long mobileNo, String pin);
@Query(value = "SELECT * FROM login where mobile_number=:mobileNo and password=:pin", nativeQuery = true)
Login findByMobileNoAndPin(long mobileNo, String pin);
@Query(value = "SELECT a FROM Login a WHERE a.mobileNumber = ?1")
Login checkUserbyMobile(long mobileNo);
@Query(value = "SELECT * FROM login where name=:username and password=:pass LIMIT 1",nativeQuery = true)
@Query(value = "SELECT * FROM login where name=:username and password=:pass LIMIT 1", nativeQuery = true)
Login findByUsernameAndPass(String username, String pass);
@Query(value = "SELECT " +
" l.id, " +
" l.name, " +
" l.mobile_number, " +
" l.user_type, " +
" l.zone, " +
" GROUP_CONCAT( " +
" DISTINCT concat(hd.division,'-',hd.hall_id,'-',hd.hall_name) " +
" ORDER BY hd.hall_name " +
" SEPARATOR ', ' " +
" ) AS hall_names " +
"FROM login l " +
"LEFT JOIN ( " +
" SELECT id AS login_id, hall_id " +
" FROM login " +
" WHERE hall_id IS NOT NULL " +
" UNION ALL " +
" SELECT login_id, hall_id " +
" FROM login_hall_ids " +
" WHERE is_active = 1 " +
" AND is_delete = 0 " +
") halls ON l.id = halls.login_id " +
"LEFT JOIN hall_details hd " +
" ON halls.hall_id = hd.hall_id " +
"WHERE l.user_type != 'admin' " +
" AND l.is_active = 1 " +
" AND l.is_delete = 0 " +
"GROUP BY l.id, l.name, l.mobile_number, l.user_type, l.zone " +
"ORDER BY cast(l.zone as unsigned)", nativeQuery = true)
List<Map<String, Object>> findActiveLogins();
@Query(value = "SELECT * FROM login WHERE id = :id", nativeQuery = true)
Login findLoginById(int id);
@Query(value = "SELECT COUNT(*) FROM login WHERE mobile_number = :mobileNo AND is_delete = 0", nativeQuery = true)
int countByMobileNumber(@Param("mobileNo") long mobileNo);
/**
* Returns how many active counter/caretaker logins already own the given hall.
* Checks both login.hall_id and the login_hall_ids join table.
*/
@Query(value = "SELECT COUNT(*) FROM (" +
" SELECT l.id FROM login l " +
" WHERE l.hall_id = :hallId " +
" AND l.user_type = :userType " +
" AND l.is_active = 1 AND l.is_delete = 0 " +
" UNION ALL " +
" SELECT lh.login_id FROM login_hall_ids lh " +
" JOIN login l ON l.id = lh.login_id " +
" WHERE lh.hall_id = :hallId " +
" AND l.user_type = :userType " +
" AND lh.is_active = 1 AND lh.is_delete = 0 " +
" AND l.is_active = 1 AND l.is_delete = 0 " +
") AS dup", nativeQuery = true)
int countActiveLoginsByHallId(@Param("hallId") int hallId, @Param("userType") String userType);
@Query(value = "SELECT COUNT(*) FROM (" +
" SELECT l.id FROM login l " +
" WHERE l.hall_id in (:hallId) " +
" AND l.user_type = :userType " +
" AND l.is_active = 1 AND l.is_delete = 0 " +
" UNION ALL " +
" SELECT lh.login_id FROM login_hall_ids lh " +
" JOIN login l ON l.id = lh.login_id " +
" WHERE lh.hall_id in (:hallId) " +
" AND l.user_type = :userType " +
" AND lh.is_active = 1 AND lh.is_delete = 0 " +
" AND l.is_active = 1 AND l.is_delete = 0 " +
") AS dup", nativeQuery = true)
int getActiveLoginsByHallIds(@Param("hallId") List<Integer> hallIds, @Param("userType") String userType);
}

28
src/main/java/com/gcc/communityHall/repository/PaymentsRepository.java

@ -1,6 +1,5 @@
package com.gcc.communityHall.repository;
import com.gcc.communityHall.entity.Payments;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
@ -12,17 +11,26 @@ import java.util.Optional;
@Repository
public interface PaymentsRepository extends JpaRepository<Payments,Integer> {
public interface PaymentsRepository extends JpaRepository<Payments, Integer> {
@Query(value = "SELECT * FROM payments WHERE payment_status in ('paid') ",nativeQuery = true)
@Query(value = "SELECT * FROM payments WHERE payment_status in ('paid') ", nativeQuery = true)
List<Payments> getPaymentlist();
@Query(value="SELECT p.* "
+ "FROM payments p "
+ "JOIN booking_details b ON p.booking_details_booking_id = b.booking_id "
+ "JOIN hall_details h ON b.hall_details_hall_id = h.hall_id "
+ "WHERE h.zone = :zone", nativeQuery = true)
@Query(value = "SELECT p.* "
+ "FROM payments p "
+ "JOIN booking_details b ON p.booking_details_booking_id = b.booking_id "
+ "JOIN hall_details h ON b.hall_details_hall_id = h.hall_id "
+ "WHERE h.zone = :zone ", nativeQuery = true)
List<Payments> getPaymentListByzone(@Param("zone") String zone);
//List<Payments> findAllWithBookingDetailsAndUsers();
@Query(value = "select * from payments where booking_details_booking_id=?",nativeQuery = true)
@Query(value = "SELECT p.* "
+ "FROM payments p "
+ "JOIN booking_details b ON p.booking_details_booking_id = b.booking_id "
+ "JOIN hall_details h ON b.hall_details_hall_id = h.hall_id "
+ "WHERE h.zone = :zone and h.hall_id in (:hallIds)", nativeQuery = true)
List<Payments> getPaymentListByzoneandHall(@Param("zone") String zone, @Param("hallIds") List<Integer> hallIds);
// List<Payments> findAllWithBookingDetailsAndUsers();
@Query(value = "select * from payments where booking_details_booking_id=?", nativeQuery = true)
Payments findByBookingId(int bookingId);
}

5
src/main/java/com/gcc/communityHall/service/Impl/BookingServiceImpl.java

@ -3,6 +3,8 @@ package com.gcc.communityHall.service.Impl;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
@ -1847,6 +1849,9 @@ public class BookingServiceImpl implements BookingService {
settlement.setDamageAmount(damageAmount);
settlement.setUpdatedId(adminname);
double refundamount = book.getDepositAmount() - (updateEbDetails.getEbAmount() + damageAmount);
BigDecimal roundedAmount = BigDecimal.valueOf(refundamount).setScale(2, RoundingMode.HALF_UP);
refundamount = roundedAmount.doubleValue();
if (refundamount < 0) {
settlement.setRefundedAmount(0);
settlement.setCollectionPending(Math.abs(refundamount));

124
src/main/java/com/gcc/communityHall/service/Impl/PaymentsServiceImpl.java

@ -16,76 +16,76 @@ import com.gcc.communityHall.repository.PaymentsRepository;
import com.gcc.communityHall.service.PaymentsService;
@Service
public class PaymentsServiceImpl implements PaymentsService{
public class PaymentsServiceImpl implements PaymentsService {
private PaymentsRepository paymentsRepository;
private PaymentsRepository paymentsRepository;
@Autowired
public PaymentsServiceImpl(PaymentsRepository paymentsRepository) {
this.paymentsRepository = paymentsRepository;
}
public PaymentsServiceImpl(PaymentsRepository paymentsRepository) {
this.paymentsRepository = paymentsRepository;
}
@Override
public List<Payments> getPaymentsByZone(String zone) {
return paymentsRepository.getPaymentListByzone(zone);
}
@Override
public List<Payments> getPaymentsByZone(String zone) {
return paymentsRepository.getPaymentListByzone(zone);
}
@Override
public List<PaymentsDTO> getAllPaymentDetails() {
// List<Payments> payments = paymentsRepository.findAllWithBookingDetailsAndUsers();
return null;
}
@Override
public List<PaymentsDTO> getAllPaymentDetails() {
// List<Payments> payments =
// paymentsRepository.findAllWithBookingDetailsAndUsers();
return null;
}
private PaymentsDTO convertToDto(Payments payment) {
PaymentsDTO paymentsDTO = new PaymentsDTO();
paymentsDTO.setPaymentId(payment.getPaymentId());
paymentsDTO.setAmountReceived(payment.getAmountReceived());
paymentsDTO.setTransactionId(payment.getTransactionId());
paymentsDTO.setPaymentType(payment.getPaymentType());
paymentsDTO.setPaymentStatus(payment.getPaymentStatus());
paymentsDTO.setCdate(payment.getCdate());
private PaymentsDTO convertToDto(Payments payment) {
PaymentsDTO paymentsDTO = new PaymentsDTO();
paymentsDTO.setPaymentId(payment.getPaymentId());
paymentsDTO.setAmountReceived(payment.getAmountReceived());
paymentsDTO.setTransactionId(payment.getTransactionId());
paymentsDTO.setPaymentType(payment.getPaymentType());
paymentsDTO.setPaymentStatus(payment.getPaymentStatus());
paymentsDTO.setCdate(payment.getCdate());
BookingDetails bookingDetails = payment.getBookingDetails();
BookingDetailsDTO bookingDetailsDTO = new BookingDetailsDTO();
bookingDetailsDTO.setBookingId(bookingDetails.getBookingId());
bookingDetailsDTO.setNoOfDays(bookingDetails.getNoOfDays());
bookingDetailsDTO.setStartDate(bookingDetails.getStartDate());
bookingDetailsDTO.setEndDate(bookingDetails.getEndDate());
bookingDetailsDTO.setStartingSlot(bookingDetails.getStartingSlot());
bookingDetailsDTO.setEndingSlot(bookingDetails.getEndingSlot());
bookingDetailsDTO.setBookingDate(bookingDetails.getBookingDate());
bookingDetailsDTO.setBookingStatus(bookingDetails.getBookingStatus().name());
bookingDetailsDTO.setDepositAmount(bookingDetails.getDepositAmount());
bookingDetailsDTO.setHallAmount(bookingDetails.getHallAmount());
bookingDetailsDTO.setAmountReceived(bookingDetails.getAmountReceived());
bookingDetailsDTO.setGst(bookingDetails.getGst());
bookingDetailsDTO.setApprovedBy(bookingDetails.getApprovedBy());
bookingDetailsDTO.setRefundStatus(bookingDetails.getRefundStatus().name());
bookingDetailsDTO.setUpdatedDate(bookingDetails.getUpdatedDate());
bookingDetailsDTO.setReason(bookingDetails.getReason());
BookingDetails bookingDetails = payment.getBookingDetails();
BookingDetailsDTO bookingDetailsDTO = new BookingDetailsDTO();
bookingDetailsDTO.setBookingId(bookingDetails.getBookingId());
bookingDetailsDTO.setNoOfDays(bookingDetails.getNoOfDays());
bookingDetailsDTO.setStartDate(bookingDetails.getStartDate());
bookingDetailsDTO.setEndDate(bookingDetails.getEndDate());
bookingDetailsDTO.setStartingSlot(bookingDetails.getStartingSlot());
bookingDetailsDTO.setEndingSlot(bookingDetails.getEndingSlot());
bookingDetailsDTO.setBookingDate(bookingDetails.getBookingDate());
bookingDetailsDTO.setBookingStatus(bookingDetails.getBookingStatus().name());
bookingDetailsDTO.setDepositAmount(bookingDetails.getDepositAmount());
bookingDetailsDTO.setHallAmount(bookingDetails.getHallAmount());
bookingDetailsDTO.setAmountReceived(bookingDetails.getAmountReceived());
bookingDetailsDTO.setGst(bookingDetails.getGst());
bookingDetailsDTO.setApprovedBy(bookingDetails.getApprovedBy());
bookingDetailsDTO.setRefundStatus(bookingDetails.getRefundStatus().name());
bookingDetailsDTO.setUpdatedDate(bookingDetails.getUpdatedDate());
bookingDetailsDTO.setReason(bookingDetails.getReason());
Users user = bookingDetails.getUsers();
UsersDTO usersDTO = new UsersDTO();
usersDTO.setUserId(user.getUserId());
usersDTO.setUserStatus(user.getUserstatus().name());
usersDTO.setUserType(user.getUsertype().name());
usersDTO.setName(user.getName());
usersDTO.setMobileNo(user.getMobileNo());
usersDTO.setEmail(user.getEmail());
usersDTO.setDoorNo(user.getDoorNo());
usersDTO.setStreet(user.getStreet());
usersDTO.setArea(user.getArea());
usersDTO.setLocation(user.getLocation());
usersDTO.setPinCode(user.getPinCode());
usersDTO.setProfilephoto(user.getProfilephoto());
usersDTO.setGovernmentId(user.getGovernmentId());
usersDTO.setActive(user.isActive());
usersDTO.setCdate(user.getCdate());
bookingDetailsDTO.setUsers(usersDTO);
paymentsDTO.setBookingDetails(bookingDetailsDTO);
return paymentsDTO;
}
Users user = bookingDetails.getUsers();
UsersDTO usersDTO = new UsersDTO();
usersDTO.setUserId(user.getUserId());
usersDTO.setUserStatus(user.getUserstatus().name());
usersDTO.setUserType(user.getUsertype().name());
usersDTO.setName(user.getName());
usersDTO.setMobileNo(user.getMobileNo());
usersDTO.setEmail(user.getEmail());
usersDTO.setDoorNo(user.getDoorNo());
usersDTO.setStreet(user.getStreet());
usersDTO.setArea(user.getArea());
usersDTO.setLocation(user.getLocation());
usersDTO.setPinCode(user.getPinCode());
usersDTO.setProfilephoto(user.getProfilephoto());
usersDTO.setGovernmentId(user.getGovernmentId());
usersDTO.setActive(user.isActive());
usersDTO.setCdate(user.getCdate());
bookingDetailsDTO.setUsers(usersDTO);
paymentsDTO.setBookingDetails(bookingDetailsDTO);
return paymentsDTO;
}
}

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

@ -24,6 +24,12 @@
<span class="nav-main-link-name">User Rejected List</span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/headquarters/login-creation">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">Login Creation</span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/headquarters/ongoingevents">
<i class="nav-main-link-icon fa fa-location-arrow"></i>

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

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

1543
src/main/resources/templates/headquarters/login-creation.html
File diff suppressed because it is too large
View File

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

@ -2803,6 +2803,47 @@
}
function Reschedule() {
// --- Slot availability check for today's date ---
var startDate = document.getElementById("startDateInput").value;
var startingSlot = document.getElementById("startingSlot").value;
var endingSlot = document.getElementById("endingSlot").value;
var todayDateStr = $("#serverDate").val();
var currentHour = new Date().getHours();
if (startDate === todayDateStr) {
// Morning slot (1) is NOT available after 6 AM
if (startingSlot === "1" && currentHour >= 6) {
Swal.fire({
icon: 'warning',
title: 'Morning Slot Not Available',
text: 'The Morning slot is not available for today as it is already past 6:00 AM. Please select a different date.',
showConfirmButton: true
});
return;
}
// Evening/Afternoon slot (2) is NOT available after 2 PM (14:00)
if (endingSlot === "2" && currentHour >= 14) {
Swal.fire({
icon: 'warning',
title: 'Afternoon Slot Not Available',
text: 'The Afternoon/Evening slot is not available for today as it is already past 2:00 PM. Please select a different date.',
showConfirmButton: true
});
return;
}
// After 2 PM: no slots available at all for today
if (currentHour >= 14) {
Swal.fire({
icon: 'warning',
title: 'No Slots Available',
text: 'No slots are available for today as it is already past 2:00 PM. Please select a future date.',
showConfirmButton: true
});
return;
}
}
// --- End slot availability check ---
// Get mobile number and show OTP modal for verification
$.ajax({
type: "GET",
@ -3038,12 +3079,22 @@
var startDate = document.getElementById("startDateInput").value;
var endDate = document.getElementById("endDateInput").value;
var originalStartDate = document.getElementById("startDatetext").value;
var startingSlot = document.getElementById("startingSlot").value;
var endingSlot = document.getElementById("endingSlot").value;
// Get today's date from server
var todayDateStr = $("#serverDate").val();
var currentHour = new Date().getHours();
// Debug: Log the retrieved dates
console.log('Retrieved dates:', {
startDate: startDate,
endDate: endDate,
originalStartDate: originalStartDate
originalStartDate: originalStartDate,
startingSlot: startingSlot,
endingSlot: endingSlot,
todayDateStr: todayDateStr,
currentHour: currentHour
});
// Check if the rescheduled start date is the same as the original booked start date
@ -3066,6 +3117,42 @@
return;
}
// --- Slot availability check for today's date ---
// If the new start date is today, validate slot against current time
if (startDate === todayDateStr) {
// Morning slot (1) is NOT available after 6 AM
if (startingSlot === "1" && currentHour >= 6) {
Swal.fire({
icon: 'warning',
title: 'Morning Slot Not Available',
text: 'The Morning slot is not available for today as it is already past 6:00 AM. Please select a different date or slot.',
showConfirmButton: true
});
return;
}
// Evening/Afternoon slot (2) is NOT available after 2 PM (14:00)
if (endingSlot === "2" && currentHour >= 14) {
Swal.fire({
icon: 'warning',
title: 'Afternoon Slot Not Available',
text: 'The Afternoon/Evening slot is not available for today as it is already past 2:00 PM. Please select a different date.',
showConfirmButton: true
});
return;
}
// After 2 PM: no slots available at all for today
if (currentHour >= 14) {
Swal.fire({
icon: 'warning',
title: 'No Slots Available',
text: 'No slots are available for today as it is already past 2:00 PM. Please select a future date.',
showConfirmButton: true
});
return;
}
}
// --- End slot availability check ---
// Store the validated dates
rescheduleStartDate = startDate;
rescheduleEndDate = endDate;
@ -3075,39 +3162,7 @@
startDate: rescheduleStartDate,
endDate: rescheduleEndDate,
bookingId: rescheduleBookingId
});
// Proceed with reschedule
proceedWithReschedule();
}

13
src/test/java/com/gcc/communityHall/CommunityHallApplicationTests.java

@ -1,13 +0,0 @@
package com.gcc.communityHall;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class CommunityHallApplicationTests {
@Test
void contextLoads() {
}
}
Loading…
Cancel
Save