Browse Source

Sysout removed and CRO Login newly created

master
KaNi-04 2 months ago
parent
commit
270046d60e
  1. 2
      src/main/java/com/gcc/communityHall/controller/AdminAPIController.java
  2. 12
      src/main/java/com/gcc/communityHall/controller/Admincontroller.java
  3. 61
      src/main/java/com/gcc/communityHall/controller/CROAPIController.java
  4. 80
      src/main/java/com/gcc/communityHall/controller/CROController.java
  5. 6
      src/main/java/com/gcc/communityHall/controller/CareTakerAPIController.java
  6. 16
      src/main/java/com/gcc/communityHall/controller/CounterController.java
  7. 21
      src/main/java/com/gcc/communityHall/controller/HQAPIController.java
  8. 6
      src/main/java/com/gcc/communityHall/controller/HeadquartersController.java
  9. 12
      src/main/java/com/gcc/communityHall/controller/OfficerAPIController.java
  10. 8
      src/main/java/com/gcc/communityHall/controller/OfficerController.java
  11. 147
      src/main/java/com/gcc/communityHall/controller/UserAPIController.java
  12. 18
      src/main/java/com/gcc/communityHall/controller/UserController.java
  13. 53
      src/main/java/com/gcc/communityHall/controller/apicontroller.java
  14. 83
      src/main/java/com/gcc/communityHall/entity/BookingHistory.java
  15. 8
      src/main/java/com/gcc/communityHall/paymentService/controller/PaymentAPIController.java
  16. 780
      src/main/java/com/gcc/communityHall/paymentService/controller/PaymentController.java
  17. 3
      src/main/java/com/gcc/communityHall/repository/BookingDetailsRepository.java
  18. 90
      src/main/java/com/gcc/communityHall/service/Impl/BookingServiceImpl.java
  19. 74
      src/main/java/com/gcc/communityHall/service/Impl/SettlementServiceImpl.java
  20. 23
      src/main/java/com/gcc/communityHall/service/Impl/UserServiceImpl.java
  21. 2139
      src/main/resources/templates/cro/booking-list.html
  22. 0
      src/main/resources/templates/cro/booking-status.html
  23. 0
      src/main/resources/templates/cro/noc-details.html
  24. 2
      src/main/resources/templates/fragments/adminMenu.html
  25. 199
      src/main/resources/templates/fragments/croMenu.html
  26. 46
      src/main/resources/templates/fragments/head-cro.html
  27. 98
      src/main/resources/templates/fragments/header-cro.html
  28. 4
      src/main/resources/templates/fragments/loginhead.html
  29. 163
      src/main/resources/templates/fragments/loginscript.html
  30. 13
      src/main/resources/templates/fragments/nav-cro.html
  31. 3
      src/main/resources/templates/officiallogin.html
  32. 64
      src/main/resources/templates/user/viewhistory.html

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

@ -1505,8 +1505,6 @@ public class AdminAPIController {
public ResponseEntity<String> uploadnoc(@RequestParam("nocFile") MultipartFile file,
@RequestParam("bookingid") int bookingId) {
try {
System.out.println("Received file: " + file.getOriginalFilename());
System.out.println("Booking ID: " + bookingId);
bookingService.uploadNOCFile(file, bookingId);
return ResponseEntity.ok("File uploaded and saved successfully");

12
src/main/java/com/gcc/communityHall/controller/Admincontroller.java

@ -278,7 +278,7 @@ public class Admincontroller {
model.addAttribute("settlementIntiated", settlementIntiated);
model.addAttribute("cancelledbookings", cancelledbookings);
model.addAttribute("rejectedbookings", rejectedbookings);
System.out.println("Settlement List: " + settlement);
// System.out.println("Settlement List: " + settlement);
return "admin/settlement-list";
} else {
session.invalidate();
@ -675,7 +675,7 @@ public class Admincontroller {
List<Object[]> counterBookingList = new ArrayList<>();
counterBookingList = bookingService.getCounterWiseBookingCount(fromDate, toDate);
model.addAttribute("counterBookingList", counterBookingList);
System.out.println("counterBookingList.." + counterBookingList);
// System.out.println("counterBookingList.." + counterBookingList);
List<Object[]> hallBookingByCounter = bookingService.getHallWiseBookingDetails(fromDate, toDate,
counterId);
@ -716,7 +716,7 @@ public class Admincontroller {
if ("11".equals(request)) {
// Fetch Settlement Initiated Report details
List<Object[]> settlementInitiatedList = bookingService.getSettlementInitiatedReport(fromDate, toDate);
System.out.println("settlementInitatedList" + settlementInitiatedList);
// System.out.println("settlementInitatedList" + settlementInitiatedList);
// Add the list to the model
model.addAttribute("settlementInitiatedList", settlementInitiatedList);
@ -743,7 +743,7 @@ public class Admincontroller {
model.addAttribute("division1", division);
model.addAttribute("hall1", hallid);
model.addAttribute("adminname", adminname);
System.out.println("request" + request);
// System.out.println("request" + request);
return "admin/reports";
} else {
@ -987,7 +987,7 @@ public class Admincontroller {
}
List<Object[]> BookingCalendar = new ArrayList<>();
if (request.equals("3")) {
System.out.println("outside");
// System.out.println("outside");
// if (hallName.isEmpty()) {
// System.out.println("check1");
// // Fetch all details for the given date range
@ -1113,7 +1113,7 @@ public class Admincontroller {
// Fetch waiting bookings
List<BookingDetails> waitingBookings = bookingDetailsRepository.getAllwaitingNOC();
System.out.println("Waiting Bookings: " + waitingBookings.size());
// System.out.println("Waiting Bookings: " + waitingBookings.size());
model.addAttribute("waitingBookings", waitingBookings);
return "admin/viewUploadNoc";

61
src/main/java/com/gcc/communityHall/controller/CROAPIController.java

@ -0,0 +1,61 @@
package com.gcc.communityHall.controller;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.gcc.communityHall.entity.BookingDetails;
import com.gcc.communityHall.service.BookingService;
import jakarta.servlet.http.HttpSession;
@RestController
@RequestMapping("/communityhall/cro/api")
public class CROAPIController {
@Autowired
private BookingService bookingService;
/**
* Get booking details by booking ID.
* Used by the CRO booking-list page to search and display
* full booking info for a given booking ID.
*
* @param bookingId the booking ID to search for
* @return the BookingDetails or 404 if not found
*/
@GetMapping("/getBookingById")
public ResponseEntity<?> getBookingById(@RequestParam("bookingId") int bookingId) {
BookingDetails bookingDetails = bookingService.getBookingsById(bookingId);
if (bookingDetails != null) {
return ResponseEntity.ok(bookingDetails);
} else {
return ResponseEntity.notFound().build();
}
}
/**
* Returns the currently logged-in CRO's mobile number from the HTTP session.
* Used by the CRO reschedule flow to send OTP to the CRO (not the user).
*
* @param session the current HTTP session
* @return JSON { "mobileNumber": <number> } or 401 if not authenticated
*/
@GetMapping("/getCROMobileNumber")
public ResponseEntity<?> getCROMobileNumber(HttpSession session) {
Object mobile = session.getAttribute("mobileno");
if (mobile == null) {
return ResponseEntity.status(401).body("CRO session not found");
}
Map<String, Object> response = new HashMap<>();
response.put("mobileNumber", mobile);
return ResponseEntity.ok(response);
}
}

80
src/main/java/com/gcc/communityHall/controller/CROController.java

@ -0,0 +1,80 @@
package com.gcc.communityHall.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.gcc.communityHall.entity.BookingDetails;
import com.gcc.communityHall.repository.BookingDetailsRepository;
import jakarta.servlet.http.HttpSession;
@Controller
@RequestMapping("/communityhall/cro")
public class CROController {
@Autowired
private BookingDetailsRepository bookingDetailsRepository;
@GetMapping("/booking-list")
public String viewBookingList(Model model, HttpSession session) {
String croname = (String) session.getAttribute("usertype");
// System.out.println("croname..." + croname);
if (croname != null && "cro".equals(croname)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("croname", croname);
List<BookingDetails> bookingList = bookingDetailsRepository.getApprovedBookingListforReschedule();
model.addAttribute("bookingList", bookingList);
return "cro/booking-list";
} else {
session.invalidate(); // Invalidate the session to clear all session attributes
return "redirect:/communityhall/login";
}
}
@GetMapping("/booking-status")
public String viewBookingStatus(Model model, HttpSession session) {
String croname = (String) session.getAttribute("usertype");
// System.out.println("croname..." + croname);
if (croname != null && "cro".equals(croname)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("croname", croname);
List<BookingDetails> bookingList = bookingDetailsRepository.getApprovedBookingListforReschedule();
model.addAttribute("bookingList", bookingList);
return "cro/booking-status";
} else {
session.invalidate(); // Invalidate the session to clear all session attributes
return "redirect:/communityhall/login";
}
}
@GetMapping("/nocdetails")
public String viewNOCDetails(Model model, HttpSession session) {
String croname = (String) session.getAttribute("usertype");
// System.out.println("croname..." + croname);
if (croname != null && "cro".equals(croname)) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("croname", croname);
List<BookingDetails> bookingList = bookingDetailsRepository.getApprovedBookingListforReschedule();
model.addAttribute("bookingList", bookingList);
return "cro/noc-details";
} else {
session.invalidate(); // Invalidate the session to clear all session attributes
return "redirect:/communityhall/login";
}
}
@GetMapping("/logout")
public String viewLogout(Model model, HttpSession session) {
session.invalidate();
return "redirect:/communityhall/login";
}
}

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

@ -162,7 +162,7 @@ public class CareTakerAPIController {
? login.getHallIds()
: (login.getHallId() != 0 ? java.util.Arrays.asList(login.getHallId())
: new java.util.ArrayList<>());
System.out.println("effectiveHallIds.." + effectiveHallIds);
// System.out.println("effectiveHallIds.." + effectiveHallIds);
session.setAttribute("hall_ids", effectiveHallIds);
session.setAttribute("mobileno", login.getMobileNumber());
session.setAttribute("usertype", login.getUserType());
@ -170,7 +170,7 @@ public class CareTakerAPIController {
session.setAttribute("zone", login.getZone());
InetAddress inetAddress = InetAddress.getLocalHost();
String hostname = InetAddress.getLocalHost().getHostName();
System.out.println("Hostname: " + hostname);
// System.out.println("Hostname: " + hostname);
ApplicationLogs logs = new ApplicationLogs();
logs.setComments("login as " + login.getName());
logs.setLoginId(login.getId());
@ -354,7 +354,7 @@ public class CareTakerAPIController {
// URL
// Log the generated full URL for debugging
System.out.println("Generated Full URL for QR Code: " + baseUrl);
// System.out.println("Generated Full URL for QR Code: " + baseUrl);
// Generate the QR code with the full URL
String qrCodeImage = QRCodeGenerator.generateQRCode(baseUrl, bookingId);

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

@ -68,9 +68,9 @@ public class CounterController {
@GetMapping(value = { "", "/", "/counterbooking" })
public String viewcounter(Model model, HttpSession session) {
System.out.println("viewcounter");
// System.out.println("viewcounter");
String countername = (String) session.getAttribute("usertype");
System.out.println("serverDate....." + LocalDate.now().toString());
// System.out.println("serverDate....." + LocalDate.now().toString());
model.addAttribute("serverDate", LocalDate.now().toString()); // for server date
model.addAttribute("countername", countername);
return "counter/counter-booking";
@ -149,15 +149,17 @@ public class CounterController {
@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: " + login.getMobileNumber());
// System.out.println("Login successful for mobile number: " +
// login.getMobileNumber());
// Generate JWT token if login is successful
String token = jwtUtil.generateToken(
@ -184,7 +186,7 @@ public class CounterController {
InetAddress inetAddress = InetAddress.getLocalHost();
String hostname = InetAddress.getLocalHost().getHostName();
System.out.println("Hostname: " + hostname);
// System.out.println("Hostname: " + hostname);
ApplicationLogs logs = new ApplicationLogs();
logs.setComments("login as " + login.getName());

21
src/main/java/com/gcc/communityHall/controller/HQAPIController.java

@ -809,9 +809,12 @@ public class HQAPIController {
.map(Long::parseLong)
.collect(Collectors.toList());
System.out.println("fromDate " + fromDate + "\n toDate " + toDate + "\n hallID " + hallID
+ "\n reasonforblocking " + reasonforblocking + "\n selectedBookings " + selectedBookings
+ "\n descriptions " + descriptions + "\n documents " + documents + "\n updatedBy " + updatedBy);
// System.out.println("fromDate " + fromDate + "\n toDate " + toDate + "\n
// hallID " + hallID
// + "\n reasonforblocking " + reasonforblocking + "\n selectedBookings " +
// selectedBookings
// + "\n descriptions " + descriptions + "\n documents " + documents + "\n
// updatedBy " + updatedBy);
// Call the service with descriptions and documents
bookingService.cancelAllBookings(fromDate, toDate, hallIdsList, reasonforblocking, selectedBookings, updatedBy,
@ -1493,8 +1496,8 @@ public class HQAPIController {
public ResponseEntity<String> uploadnoc(@RequestParam("nocFile") MultipartFile file,
@RequestParam("bookingid") int bookingId) {
try {
System.out.println("Received file: " + file.getOriginalFilename());
System.out.println("Booking ID: " + bookingId);
// System.out.println("Received file: " + file.getOriginalFilename());
// System.out.println("Booking ID: " + bookingId);
bookingService.uploadNOCFile(file, bookingId);
return ResponseEntity.ok("File uploaded and saved successfully");
@ -1516,16 +1519,16 @@ public class HQAPIController {
Map<String, Object> response = new HashMap<>();
try {
System.out.println("settlementId1: " + bookingId);
System.out.println("status" + status);
System.out.println("comments" + comments);
// System.out.println("settlementId1: " + bookingId);
// System.out.println("status" + status);
// System.out.println("comments" + comments);
// Update settlement status
Settlement updateSettlement = settlementService.updateSettlementStatus(bookingId, status, comments);
if (updateSettlement == null) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
System.out.println("updateSettlement12" + updateSettlement);
// System.out.println("updateSettlement12" + updateSettlement);
// ak
// Set approvedFlag and approvedFlagDate
updateSettlement.setApprovedFlag(1);

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

@ -325,7 +325,7 @@ public class HeadquartersController {
List<Object[]> counterBookingList = new ArrayList<>();
counterBookingList = bookingService.getCounterWiseBookingCount(fromDate, toDate);
model.addAttribute("counterBookingList", counterBookingList);
System.out.println("counterBookingList.." + counterBookingList);
// System.out.println("counterBookingList.." + counterBookingList);
List<Object[]> hallBookingByCounter = bookingService.getHallWiseBookingDetails(fromDate, toDate,
counterId);
@ -811,7 +811,7 @@ public class HeadquartersController {
// Fetch waiting bookings
List<BookingDetails> waitingBookings = bookingDetailsRepository.getAllwaitingNOC();
System.out.println("Waiting Bookings: " + waitingBookings.size());
// System.out.println("Waiting Bookings: " + waitingBookings.size());
model.addAttribute("waitingBookings", waitingBookings);
return "headquarters/viewUploadNoc";
@ -1265,6 +1265,8 @@ public class HeadquartersController {
bookingHistory.setCdate(new Date());
bookingHistory.setStartDate(booking.getStartDate());
bookingHistory.setEndDate(booking.getEndDate());
bookingHistory.setStartingSlot(booking.getStartingSlot());
bookingHistory.setEndingSlot(booking.getEndingSlot());
bookingHistory.setBookingDetails(booking);
bookingHistoryRepository.save(bookingHistory);

12
src/main/java/com/gcc/communityHall/controller/OfficerAPIController.java

@ -141,7 +141,7 @@ public class OfficerAPIController {
@RequestParam String settlementsid) {
BookingDetails bookingDetails = bookingServiceImpl
.getBookingDetailsWithSettlement(Integer.parseInt(settlementsid));
System.out.println("bookingDetails:12 " + bookingDetails);
// System.out.println("bookingDetails:12 " + bookingDetails);
return ResponseEntity.ok(bookingDetails);
}
@ -209,16 +209,16 @@ public class OfficerAPIController {
Map<String, Object> response = new HashMap<>();
try {
System.out.println("settlementId1: " + settlementId);
System.out.println("status" + status);
System.out.println("comments" + comments);
// System.out.println("settlementId1: " + settlementId);
// System.out.println("status" + status);
// System.out.println("comments" + comments);
// Update settlement status
Settlement updateSettlement = settlementService.updateSettlementStatus(settlementId, status, comments);
if (updateSettlement == null) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
System.out.println("updateSettlement12" + updateSettlement);
// System.out.println("updateSettlement12" + updateSettlement);
// ak
// Set approvedFlag and approvedFlagDate
updateSettlement.setApprovedFlag(1);
@ -698,7 +698,7 @@ public class OfficerAPIController {
@RequestParam(value = "document", required = false) MultipartFile[] documents, // Handle documents
HttpSession session) {
System.out.println("selectedBookings...." + selectedBookings);
// System.out.println("selectedBookings...." + selectedBookings);
// Your existing logic
String updatedBy = (String) session.getAttribute("employeeId");

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

@ -86,7 +86,7 @@ public class OfficerController {
long mobileno = (long) session.getAttribute("mobileno");
List<Integer> hallIds = (List<Integer>) session.getAttribute("hall_ids");
System.out.println("HallIds in officer Dashboard: " + hallIds.toString());
// System.out.println("HallIds in officer Dashboard: " + hallIds.toString());
model.addAttribute("mobileno", mobileno);
model.addAttribute("zone", zone);
@ -225,7 +225,7 @@ public class OfficerController {
List<Integer> hallIds = (List<Integer>) session.getAttribute("hall_ids");
model.addAttribute("zone", zone);
model.addAttribute("hallIds", hallIds);
System.out.println("Zone: " + zone);
// System.out.println("Zone: " + zone);
List<BookingDetails> settlement = bookingDetailsRepository.findSettlementPendingByZone(zone, hallIds);
// ak
List<BookingDetails> settlementIntiated = bookingDetailsRepository
@ -237,7 +237,7 @@ public class OfficerController {
model.addAttribute("settlementIntiated", settlementIntiated);
model.addAttribute("cancelledbookings", cancelledbookings);
model.addAttribute("rejectedbookings", rejectedbookings);
System.out.println("settlementIntiated" + settlementIntiated);
// System.out.println("settlementIntiated" + settlementIntiated);
return "officer/settlement-list";
} else {
session.invalidate();
@ -642,7 +642,7 @@ public class OfficerController {
List<Integer> hallIds = (List<Integer>) session.getAttribute("hall_ids");
model.addAttribute("zone", zone);
model.addAttribute("hallIds", hallIds);
System.out.println("zone" + zone + "\nhallIds.." + hallIds);
// System.out.println("zone" + zone + "\nhallIds.." + hallIds);
return "officer/gccblocking-new";
} else {
session.invalidate();

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

@ -50,6 +50,7 @@ import com.gcc.communityHall.dto.FamilyPensionerDetails;
import com.gcc.communityHall.dto.FamilyPensionerDetailsResponse;
import com.gcc.communityHall.dto.PensionerDetails;
import com.gcc.communityHall.dto.PensionerDetailsResponse;
import com.gcc.communityHall.entity.ApplicationLogs;
import com.gcc.communityHall.entity.BookingCalendar;
import com.gcc.communityHall.entity.BookingDetails;
import com.gcc.communityHall.entity.Counsellordetails;
@ -74,6 +75,7 @@ import com.gcc.communityHall.paymentService.entity.TransactionResponse;
import com.gcc.communityHall.paymentService.refund.DTO.TransactionRefundResponse;
import com.gcc.communityHall.paymentService.repository.TransRefundResRepository;
import com.gcc.communityHall.paymentService.service.PaymentGatewayServiceImpl;
import com.gcc.communityHall.repository.ApplicationLogsRepository;
import com.gcc.communityHall.repository.BookingCalendarRepository;
import com.gcc.communityHall.repository.BookingDetailsRepository;
import com.gcc.communityHall.repository.BookingHistoryRepository;
@ -171,6 +173,9 @@ public class UserAPIController {
@Autowired
private TransRefundResRepository transRefundResRepository;
@Autowired
private ApplicationLogsRepository applicationLogsRepository;
@Autowired
public UserAPIController(@Value("${file.upload.directory}") String uploadDirectory) {
this.uploadDirectory = uploadDirectory;
@ -187,10 +192,11 @@ public class UserAPIController {
// Optional<HallDetails> hallDetails = hallDetailsRepository.findById(hallId);
// return hallDetails.map(ResponseEntity::ok)
// .orElseGet(() -> ResponseEntity.status(404).body(null));
System.out.println("User is viewing hall Details for hall Id: " + hallId);
HallDetails hallDetails = hallDetailsRepository.findHallActiveDetailsById(hallId);
System.out.println("hallDetails.." + hallDetails);
// System.out.println("hallDetails.." + hallDetails);
if (hallDetails != null) {
return ResponseEntity.ok(hallDetails);
@ -203,6 +209,7 @@ public class UserAPIController {
@GetMapping("/gethallnames")
public ResponseEntity<List<HallDetails>> getHallNames() {
System.out.println("Calling hallnames API");
List<HallDetails> hallDetailsList = hallDetailsRepository.findActiveHalls();
List<HallDetails> hallDataList = new ArrayList<>();
for (HallDetails hallDetails : hallDetailsList) {
@ -219,6 +226,7 @@ public class UserAPIController {
// SendOTP
@GetMapping(value = "/sendOTP")
public String sendOtp(HttpServletRequest request, @RequestParam Long mobileNo, @RequestParam String purpose) {
System.out.println("Calling Send OTP API for Mob No: " + mobileNo);
Long MobileNo = mobileNo;
// System.out.println(purpose);
@ -235,7 +243,7 @@ public class UserAPIController {
String urlString = "https://tmegov.onex-aura.com/api/sms?key=pfTEYN6H&to=" + mobileNo
+ "&from=GCCCRP&body=Welcome to GCC! Your OTP for GCC Community Centre booking is " + otp
+ "&entityid=1401572690000011081&templateid=1407172346444550398";
System.out.println(urlString);
// System.out.println(urlString);
System.out.println("\n urlString---: " + urlString);
String bodyMessage = "" + otp;
@ -271,14 +279,15 @@ public class UserAPIController {
// VerifyOTP
@GetMapping(value = "/verifyOTP")
public String verifyOtp(HttpServletRequest request, @RequestParam String otp, @RequestParam long mobileNo) {
System.out.println("Calling Verify OTP API");
HttpSession session = request.getSession();
try {
Integer session_otp = (Integer) session.getAttribute("otp");
System.out.println("session_otp---:" + session_otp);
// System.out.println("session_otp---:" + session_otp);
Integer entered_otp = Integer.parseInt(otp);
if (session_otp != null && session_otp.equals(entered_otp)) {
System.out.println("Entered OTP Correct user API");
// System.out.println("Entered OTP Correct user API");
Users user = userservice.findByMobileno(mobileNo);
if (user != null) {
userSession.setMobileno(user.getMobileNo());
@ -292,7 +301,7 @@ public class UserAPIController {
return "Success";
} else {
System.out.println("Incorrect OTP. Please enter correct OTPs.");
// System.out.println("Incorrect OTP. Please enter correct OTPs.");
session.setAttribute("user", "");
session.setAttribute("mobileNo", "");
session.setAttribute("id", "");
@ -310,6 +319,7 @@ public class UserAPIController {
@GetMapping(value = "/verifyofficialOTP")
public String verifyOtp(HttpServletRequest request, @RequestParam String otp) {
System.out.println("Calling Verify Official login OTP API");
HttpSession session = request.getSession();
try {
Integer session_otp = (Integer) session.getAttribute("otp");
@ -338,6 +348,7 @@ public class UserAPIController {
// Validating User with the mobileno
@GetMapping(value = "/checkMobileExits")
public String checkMobileExits(@RequestParam long mobileno) {
System.out.println("Calling Check Mobile Exits API");
try {
Users form = userservice.findByMobileno(mobileno);
if (form != null) {
@ -359,6 +370,7 @@ public class UserAPIController {
// Counsellor Mobile no Validation
@GetMapping(value = "/checkCounsellorMobileExits")
public ResponseEntity<String> checkCounsellorMobileExits(@RequestParam long mobileno) {
System.out.println("Calling Check Counsellor Mobile Exits API");
// Find the counsellor by the provided mobile number
Counsellordetails counsellor = userservice.findByMobile(mobileno); // This checks both mobileNo1 and mobileNo2
// in the counsellor table
@ -382,6 +394,7 @@ public class UserAPIController {
@GetMapping("/checkEmployee")
public Map<String, Boolean> checkEmployee(@RequestParam String id) {
System.out.println("Calling Check GCC Employee API");
boolean isRegistered = usersRepository.existsByGovernmentId(id);
Map<String, Boolean> response = new HashMap<>();
response.put("isRegistered", isRegistered);
@ -392,6 +405,7 @@ public class UserAPIController {
// retrieving the zone
@GetMapping(value = "/getZone")
public List<Map<String, Object>> getZone() {
System.out.println("Calling Get Zone API in the User end");
return hallDetailsRepository.getZoneAndDivision();
}
@ -399,6 +413,7 @@ public class UserAPIController {
// retrieving the zones by hall
@GetMapping(value = "/hallsbyzone")
public List<Map<String, Object>> getHallsByZone(@RequestParam(required = false) String zones) {
System.out.println("Calling Halls By Zone API in the User end");
if (zones == null || zones.isEmpty()) {
return hallDetailsRepository.getAllHalls();
} else {
@ -411,6 +426,7 @@ public class UserAPIController {
// Getting the Past Data from the Calendar
@GetMapping("/getPastData")
public List<Map<String, Object>> getPastData(@RequestParam("hall_id") int hall_id) {
System.out.println("Calling Past Data from the booking Calendar Hall API in the User end");
List<Map<String, Object>> data = bookingService.getPastData(hall_id);
if (data != null) {
return data;
@ -422,6 +438,7 @@ public class UserAPIController {
// retrieving the Pensioner Details From ERP
@GetMapping("/PensionerDetail")
public PensionerDetailsResponse getPensionerDetails(@RequestParam("pensionerId") String pensionerId) {
System.out.println("Calling Pensioner Detail API in the User end");
// System.out.println(pensionerId);
RestTemplate restTemplate = new RestTemplate();
String url = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=getPensionerDetailsList&pensionerId="
@ -454,6 +471,7 @@ public class UserAPIController {
@Operation(summary = "Employee Details ERP REST API", description = "REST API to retrieving the Employee Details From ERP")
@GetMapping("/EmployeeDetails")
public EmployeeDetailsResponse getEmployeeDetails(@RequestParam("employeeId") Long employeeId) {
System.out.println("Calling Employee Details API in the User end");
// System.out.println("Employee ID:"+employeeId);
RestTemplate restTemplate = new RestTemplate();
String url = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=getEmployeeDetail&EmployeeID="
@ -487,6 +505,7 @@ public class UserAPIController {
// retrieving the FamilyPensionerDetails Details From ERP
@GetMapping("/FamilyPensionerDetail")
public FamilyPensionerDetailsResponse getFamilyPensionerDetails(@RequestParam("id") Long id) {
System.out.println("Calling Family Pensioner Detail API in the User end");
RestTemplate restTemplate = new RestTemplate();
String url = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=getFamPensionerDetailsList&familPensionId="
+ id;
@ -517,6 +536,7 @@ public class UserAPIController {
// retrieving the All Hall Details coordinates
@GetMapping("/getallhallcoordinates")
public List<Map<String, Object>> getAllHallCoordinates() {
System.out.println("Calling All Hall Coordinates API in the User end");
List<HallDetails> allHallDetails = hallDetailsRepository.findActiveHalls();
return allHallDetails.stream().map(this::extractRequiredDetails).collect(Collectors.toList());
}
@ -546,6 +566,7 @@ public class UserAPIController {
// Booking Limitation & UserStatus pending
@GetMapping("/bookingLimit")
public String CheckbookingLimitation(Model model) {
System.out.println("Calling Booking Limitation API in the User end");
int userId = userSession.getUserId();
Users userById = userService.getUserById(userId);
if (userById != null && userById.getUserstatus() == Users.userStatus.PENDING) {
@ -566,6 +587,7 @@ public class UserAPIController {
@Operation(summary = "Counter Booikng Limit REST API", description = "REST API to check the Counter Booking Limitation")
@GetMapping("/counterbookinglimit")
public String checkCounterBookingLimitation(@RequestParam long mobileNo) {
System.out.println("Calling Counter Booking Limitation API in the User end");
Users user = userService.getUserDetailsByMobileNo(mobileNo);
if (user == null) {
@ -590,6 +612,7 @@ public class UserAPIController {
// UserStatus pending
@GetMapping("/checkuserstatus")
public String checkUserStatus(@RequestParam long mobileNo) {
System.out.println("Calling User Status Pending API in the User end");
Users user = userService.getUserDetailsByMobileNo(mobileNo); // Assuming you have a method to retrieve a user by
// mobile number
if (user != null && user.getUserstatus() == Users.userStatus.PENDING) {
@ -605,6 +628,7 @@ public class UserAPIController {
// Getting Username and Mobileno from userSession
@GetMapping("/getUsername")
public ResponseEntity<Map<String, Object>> checkUsername() {
System.out.println("Calling Username and Mobileno from userSession API in the User end");
Map<String, Object> userDetails = new HashMap<>();
userDetails.put("displayName", userSession.getDispayName());
userDetails.put("mobileNo", userSession.getMobileno());
@ -615,6 +639,7 @@ public class UserAPIController {
@GetMapping(value = "/getZonehalls")
public List<Map<String, Object>> getZonehalls() {
System.out.println("Calling Zone Halls API in the User end");
return hallDetailsRepository.getZonesAndDivisions();
}
@ -623,6 +648,7 @@ public class UserAPIController {
@GetMapping(value = "/getZoneNo")
public String getZoneNo() {
System.out.println("Calling Zone No API in the User end");
String urlString = appConfig.getErpUrl() + "serviceId=getZones";
ResponseEntity<String> response = null;
RestTemplate restTemplate = new RestTemplate();
@ -645,6 +671,7 @@ public class UserAPIController {
// Rest Api From ERP for getting Divisions
@GetMapping(value = "/getDiv")
public String getDiv(@RequestParam String zoneId) {
System.out.println("Calling Division API in the User end");
String urlString = appConfig.getErpUrl() + "serviceId=getWards&Zoneid=" + zoneId + "";
ResponseEntity<String> response = null;
RestTemplate restTemplate = new RestTemplate();
@ -668,12 +695,14 @@ public class UserAPIController {
// retrieving the Halls By Division
@GetMapping("/hallsbydivision")
public List<HallDetails> getHallsByDivision(@RequestParam("division") String division) {
System.out.println("Calling Halls By Division API in the User end");
return hallDetailsRepository.findActiveHallsByDivision(division);
}
@Operation(summary = "HAlls By zone ERP REST API", description = "REST API to get the HAlls by zone")
@GetMapping("/findhallsbyzone")
public List<HallDetails> getHallsByzone(@RequestParam("zone") String zone) {
System.out.println("Calling Halls By zone API in the User end");
return hallDetailsRepository.findActiveHallsByZone(zone);
}
@ -682,6 +711,7 @@ public class UserAPIController {
@GetMapping("/viewAllBookingDetails")
public ResponseEntity<?> getUserDetailsByBookingId(@RequestParam("bookingId") int bookingId) {
System.out.println("Calling Booking Details By bookingId API in the User end");
LocalDateTime rescheduledUpdatedDate = null;
BookingDetails bookingDetails = bookingService.getBookingsById(bookingId);
@ -748,6 +778,7 @@ public class UserAPIController {
// retrieving the User Details by Mobileno for Counter
@GetMapping("/getUserDetails")
public ResponseEntity<?> getUserDetailsByMobileNo(@RequestParam("mobileNo") long mobileNo) {
System.out.println("Calling Counter User Details API in the User end");
try {
// Call service method to retrieve user details by mobile number
Users userDetails = userService.getUserDetailsByMobileNo(mobileNo);
@ -785,6 +816,8 @@ public class UserAPIController {
@RequestParam("uploadLetter") MultipartFile uploadLetter,
@RequestParam("reason") String reason) throws IOException {
System.out.println("Calling Counter Booking Cancellation by Letter and Reason API in the User end");
// System.out.println("Received counterId: " + counterId);
// System.out.println("Received file: " + uploadLetter.getOriginalFilename());
@ -862,6 +895,8 @@ public class UserAPIController {
@RequestParam(value = "email", required = false) String email,
@RequestParam(value = "profilephoto", required = false) MultipartFile profilephoto) {
System.out.println("Calling Updating the User Details Mobileno Validation API in the User end");
Users userDetails = new Users();
userDetails.setUserId(userId);
userDetails.setName(name);
@ -909,6 +944,9 @@ public class UserAPIController {
// Retrive user details for counter
@GetMapping("/getuserforcounter")
public ResponseEntity<?> getCounterUserById(@RequestParam int userId) {
System.out.println("Calling Counter User Details API in the User end");
if (userId == 0) {
userId = userSession.getUserId();
// System.out.println("User ID retrieved from session: " + userId);
@ -927,6 +965,9 @@ public class UserAPIController {
// retrieving User Details
@GetMapping("/getUser")
public ResponseEntity<?> getUserByID(@RequestParam int userId) {
System.out.println("Calling User Details API in the User end");
if (userId == 0) {
userId = userSession.getUserId();
}
@ -962,6 +1003,9 @@ public class UserAPIController {
// APi for Saving the Booking Details
@PostMapping(path = "/saveTheRequest2", consumes = { "multipart/form-data" })
public ResponseEntity<?> saveTheBookingDetails2(HttpServletRequest request) {
System.out.println("Calling Saving the Booking Details API in the User end (Step3 to Step4)");
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, Object> bookingDetails = splitFormData(multipartRequest);
Map<String, Object> saveBookingDetails = bookingService.saveBookingDetails(bookingDetails);
@ -998,6 +1042,7 @@ public class UserAPIController {
// retrieving the Booking Details BY Booking ID
@GetMapping("/getBooking")
public ResponseEntity<?> getBookingByID(@RequestParam int bookingId) {
System.out.println("Calling Retrieving the Booking Details by BookingId API in the User end");
return ResponseEntity.ok(bookingService.getBookingsById(bookingId));
}
@ -1008,6 +1053,7 @@ public class UserAPIController {
public ResponseEntity<?> cancelBooking(@RequestParam int bookingId,
@RequestParam BookingDetails.BookingStatus status,
@RequestParam String comments) {
System.out.println("Calling User Booking Cancelling by BookingId API in the User end");
log.info("Received request to cancel booking with ID: {}");
log.info("Status: {}, Comments: {}");
Optional<BookingDetails> bookings = bookingDetailsRepository.findById(bookingId);
@ -1047,6 +1093,7 @@ public class UserAPIController {
@GetMapping("/FamilyPensionerDetails")
@ResponseBody // Ensure Spring treats the returned object as the response body
public Map<String, Object> getFamilyPensionerDetails(HttpServletRequest request, @RequestParam("id") Long id) {
System.out.println("Calling Checking Family Pensioner Details from ERP API in the User end");
String purpose = "Checking Pensioner";
RestTemplate restTemplate = new RestTemplate();
String url = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=getFamPensionerDetailsList&familPensionId="
@ -1089,6 +1136,7 @@ public class UserAPIController {
@GetMapping("/gccemployee")
@ResponseBody // Ensure Spring treats the returned object as the response body
public Map<String, Object> getGccEmployee(HttpServletRequest request, @RequestParam("id") Long id) {
System.out.println("Calling GCC Employee Details ERP REST API in the User end");
String purpose = "Checking GccEmployee";
RestTemplate restTemplate = new RestTemplate();
String url = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=getEmployeeDetail&EmployeeID="
@ -1134,6 +1182,7 @@ public class UserAPIController {
@GetMapping("/PensionerDetails")
@ResponseBody
public Map<String, Object> getPensionerDetails(HttpServletRequest request, @RequestParam("id") Long id) {
System.out.println("Calling Pensioner Details ERP REST API in the User end");
String purpose = "Checking Employee";
RestTemplate restTemplate = new RestTemplate();
String url = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=getPensionerDetailsList&pensionerId="
@ -1191,6 +1240,9 @@ public class UserAPIController {
@RequestParam("starting") String starting,
@RequestParam("ending") String ending,
@RequestParam(name = "hallId", required = false) String hallId) {
System.out.println(
"Calling Hall Checking Availability API in the User end. fromDate: " + fromDate + " toDate: " + toDate
+ " starting: " + starting + " ending: " + ending + " hallId: " + hallId);
List<BookingCalendar> data = new ArrayList<>();
HashSet<Integer> removeHallId = new HashSet<Integer>();
int hallIdd = 0;
@ -1331,12 +1383,88 @@ public class UserAPIController {
@RequestParam String startDate,
@RequestParam String endDate,
@RequestParam(required = false, defaultValue = "0") int startingSlot,
@RequestParam(required = false, defaultValue = "0") int endingSlot) {
@RequestParam(required = false, defaultValue = "0") int endingSlot,
HttpServletRequest request,
HttpSession session) {
System.out.println(
"Calling Reschedule Booking Dates API in the User end. bookingId: " + bookingId + " startDate: "
+ startDate
+ " endDate: " + endDate + " startingSlot: " + startingSlot + " endingSlot: " + endingSlot);
try {
Optional<String> updateResult = bookingService.updateBookingDatesAndCalendar(
bookingId, startDate, endDate, startingSlot, endingSlot);
if (updateResult.isPresent()) {
if (updateResult.get().equals("Booking dates updated successfully.")) {
// Log the reschedule action in ApplicationLogs
try {
ApplicationLogs log = new ApplicationLogs();
log.setBookingId(bookingId);
log.setLogType("RESCHEDULE_BOOKING");
log.setCdate(new Date());
int actorUserId = 0;
String actorType = "USER";
String sessionUserType = session != null ? (String) session.getAttribute("usertype") : null;
Object sessionIdObj = session != null ? session.getAttribute("id") : null;
if (sessionUserType != null && sessionUserType.equalsIgnoreCase("cro")) {
actorType = "CRO";
if (sessionIdObj instanceof Integer) {
actorUserId = (Integer) sessionIdObj;
} else if (sessionIdObj != null) {
try {
actorUserId = Integer.parseInt(sessionIdObj.toString());
} catch (Exception ignored) {
}
}
} else if (userSession != null && userSession.getUserId() != null
&& userSession.getUserId() != 0) {
actorUserId = userSession.getUserId();
if (userSession.getUserType() != null && !userSession.getUserType().trim().isEmpty()) {
actorType = userSession.getUserType().toUpperCase();
}
} else if (sessionIdObj != null) {
try {
actorUserId = Integer.parseInt(sessionIdObj.toString());
if (sessionUserType != null && !sessionUserType.trim().isEmpty()) {
actorType = sessionUserType.toUpperCase();
}
} catch (Exception ignored) {
}
}
// Fallback to Citizen userId from BookingDetails if not resolved from session
if (actorUserId == 0) {
Optional<BookingDetails> bdOpt = bookingDetailsRepository.findById(bookingId);
if (bdOpt.isPresent() && bdOpt.get().getUsers() != null) {
actorUserId = bdOpt.get().getUsers().getUserId();
}
}
log.setLoginId(actorUserId);
String startSlotStr = startingSlot == 1 ? "Morning"
: (startingSlot == 2 ? "Evening" : "Slot " + startingSlot);
String endSlotStr = endingSlot == 1 ? "Morning"
: (endingSlot == 2 ? "Evening" : "Slot " + endingSlot);
log.setComments("Booking rescheduled by " + actorType + " (User ID: " + actorUserId
+ "). New Dates: " + startDate + " (" + startSlotStr + ") to " + endDate + " ("
+ endSlotStr + ")");
if (request != null) {
String clientIp = request.getHeader("X-Forwarded-For");
if (clientIp == null || clientIp.isEmpty() || "unknown".equalsIgnoreCase(clientIp)) {
clientIp = request.getRemoteAddr();
}
log.setIpaddress(clientIp);
log.setSystemName(request.getRemoteHost());
}
applicationLogsRepository.save(log);
} catch (Exception logEx) {
logEx.printStackTrace();
}
return new ResponseEntity<>(updateResult.get(), HttpStatus.OK);
} else {
// Any other message is treated as an error
@ -1353,6 +1481,7 @@ public class UserAPIController {
@GetMapping("/trackBooking")
public List<Map<String, Object>> getTrackingDetails(@RequestParam int bookingId) {
System.out.println("Calling Tracking Details API in the User end. bookingId: " + bookingId);
Optional<BookingDetails> booking = bookingDetailsRepository.findById(bookingId);
List<Map<String, Object>> trackingDetails = new ArrayList<>();
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
@ -1664,6 +1793,9 @@ public class UserAPIController {
@RequestParam(value = "endPeriod", required = false) String endPeriod,
@RequestParam(value = "reasonforBooking", required = false) String reasonforBooking,
@RequestParam int hallId) {
System.out.println("Calling calculate hall amount API in the User end. numDays: " + numDays + " startPeriod: "
+ startPeriod + " endPeriod: " + endPeriod + " reasonforBooking: " + reasonforBooking + " hallId: "
+ hallId);
Optional<HallDetails> hallDetailsOpt = hallDetailsRepository.findById(hallId);
@ -1804,6 +1936,7 @@ public class UserAPIController {
@GetMapping("/getTransactionDetails")
public Map<String, Object> getTransactionDetails(@RequestParam String userId) {
System.out.println("Calling getTransactionDetails API in the User end. userId: " + userId);
// Fetch all transaction details for the user
List<TransactionResponse> transactions = PaymentGatewayServiceImpl.getTransactionResponseByuserId(userId);
@ -1815,7 +1948,7 @@ public class UserAPIController {
response.put("refundDetails", refundDetails);
System.out.println("Response: " + response);
// System.out.println("Response: " + response);
return response;
}

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

@ -66,6 +66,8 @@ public class UserController {
@GetMapping(value = { "", "/", "/dashboard", "/index" })
public String viewDashboard(Model model) {
System.out.println("User in dashboard / index Page");
List<HallDetails> halls = hallDetailsRepository.findActiveHalls();
List<HallDetails> hallnames = hallDetailsService.getHallNames();
for (HallDetails hall : halls) {
@ -105,6 +107,7 @@ public class UserController {
@RequestParam(name = "zone", required = false) String zone,
Model model) {
System.out.println("User Checking availability for hall Id:" + hallId);
List<Notification> newnotification = notificationRepository.findActivenotifications();
// Create a string to concatenate all notifications descriptions
@ -228,6 +231,8 @@ public class UserController {
@PostMapping("/newregistrationform")
public String showRegistrationForm(@ModelAttribute("newform") Users newform, Model model) {
System.out.println("New User Registration Page");
Users user = userService.user(newform);
userSession.setMobileno(user.getMobileNo());
userSession.setDispayName(user.getName());
@ -263,7 +268,7 @@ public class UserController {
@GetMapping("/hallbookingform")
public String viewform(Model model) {
String username = userSession.getDispayName();
// System.out.println("server Date22....."+LocalDate.now().toString());
System.out.println("User in Hall Booking Form Page");
model.addAttribute("serverDate", LocalDate.now().toString()); // for server date
model.addAttribute("userName", username);
model.addAttribute("counter", userSession.getCounter());
@ -274,6 +279,7 @@ public class UserController {
@GetMapping("/acknowledgementwithoutrefid")
public String viewakowledgement(Model model, int bookingId) {
System.out.println("User in Acknowledgement without Ref ID Page");
BookingDetails bookingsDetails = bookingService.getBookingsById(bookingId);
model.addAttribute("bookingsDetails", bookingsDetails); // Add single BookingDetails object
model.addAttribute("userName", userSession.getDispayName());
@ -284,6 +290,7 @@ public class UserController {
@GetMapping("/acknowledgement")
public String viewAcknowledgement(@RequestParam("ref_id") String refId, Model model) {
System.out.println("User in Acknowledgement with Ref ID Page");
// Fetch booking using booking_ref_id
BookingDetails bookingsDetails = bookingService.getBookingByRefId(refId);
@ -350,6 +357,8 @@ public class UserController {
public String viewBookingDetails(Model model,
@RequestParam(name = "bookingStatus", required = false) String bookingStatus) {
System.out.println("User in View History Page");
Integer userId = userSession.getUserId();
// Extract booking_ref_id per booking
Map<Integer, String> refIdMap = new HashMap<>();
@ -400,8 +409,6 @@ public class UserController {
}
}
System.out.println("Row keys: " + bookingPast.get(0).keySet());
System.out.println("RefId Map: " + refIdMap);
} else {
System.out.println("No past bookings found for userId: " + userId);
}
@ -415,6 +422,7 @@ public class UserController {
@GetMapping("/CommunityHallList")
public String viewhalllist(Model model) {
System.out.println("User in View Hall List Page");
model.addAttribute("userName", userSession.getDispayName());
model.addAttribute("counter", userSession.getCounter());
model.addAttribute("counterName", userSession.getCounterName());
@ -423,6 +431,7 @@ public class UserController {
@GetMapping("/hallAmountCalculation")
public String viewCalculate(Model model) {
System.out.println("User in Calculate Hall Amount Page");
model.addAttribute("userName", userSession.getDispayName());
model.addAttribute("counter", userSession.getCounter());
model.addAttribute("counterName", userSession.getCounterName());
@ -431,6 +440,7 @@ public class UserController {
@GetMapping("/collectionpending")
public String viewCollectionpending(Model model, int bookingId) {
System.out.println("User in Collection Pending Page");
BookingDetails bookingsDetails = bookingService.getBookingsById(bookingId);
model.addAttribute("bookingsDetails", bookingsDetails); // Add single BookingDetails object
model.addAttribute("userName", userSession.getDispayName());
@ -439,6 +449,7 @@ public class UserController {
@GetMapping("/collectionpendingacknowledgement")
public String viewCollectionpendingAck(Model model, int bookingId) {
System.out.println("User in Collection Pending Acknowledgement Page");
BookingDetails bookingsDetails = bookingService.getBookingsById(bookingId);
model.addAttribute("bookingsDetails", bookingsDetails); // Add single BookingDetails object
model.addAttribute("userName", userSession.getDispayName());
@ -447,6 +458,7 @@ public class UserController {
@GetMapping("/viewhallform")
public String viewhallform(Model model) {
System.out.println("User in View Hall Form Page");
String username = userSession.getDispayName();
model.addAttribute("userName", username);
model.addAttribute("serverDate", LocalDate.now().toString()); // for server date

53
src/main/java/com/gcc/communityHall/controller/apicontroller.java

@ -19,34 +19,41 @@ public class apicontroller {
WhatsappMsgServiceImpl whatsappMsgServiceImpl;
@GetMapping("/systemname")
public String getUsername() {
String systemName=System.getProperty("user.name");
System.out.println("System.name:-"+systemName);
public String getUsername() {
String systemName = System.getProperty("user.name");
// System.out.println("System.name:-"+systemName);
long mobile = 7989346866L;
int bookingId= 1;
int bookingId = 1;
double refundAmt = 1000;
String settlementrefundsms="Your refund amount of Rs. "+refundAmt+" for Booking ID "+bookingId+" has been initiated. The amount will be credited to your account within 3 to 15 days. Thanks for using the GCC Community Hall Booking System.";
String settlementrefundurlString ="https://tmegov.onex-aura.com/api/sms?key=pfTEYN6H&to="+mobile+"&from=GCCCRP&body="+settlementrefundsms+"&entityid=1401572690000011081&templateid=1407172346804951524";
String settlementrefundwhatsupmsg="https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to="+mobile+"&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Your+refund+of+Rs.+"+refundAmt+"+for+Booking+ID+"+bookingId+"+has+been+initiated.+%0AThe+amount+will+be+credited+to+your+account+within+3+to+15+days.";
whatsappMsgServiceImpl.sendMsg(settlementrefundwhatsupmsg);
whatsappMsgServiceImpl.sendSMS(settlementrefundurlString.trim());
System.out.println(settlementrefundurlString);
return systemName;
}
String settlementrefundsms = "Your refund amount of Rs. " + refundAmt + " for Booking ID " + bookingId
+ " has been initiated. The amount will be credited to your account within 3 to 15 days. Thanks for using the GCC Community Hall Booking System.";
String settlementrefundurlString = "https://tmegov.onex-aura.com/api/sms?key=pfTEYN6H&to=" + mobile
+ "&from=GCCCRP&body=" + settlementrefundsms
+ "&entityid=1401572690000011081&templateid=1407172346804951524";
String settlementrefundwhatsupmsg = "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to="
+ mobile + "&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Your+refund+of+Rs.+" + refundAmt
+ "+for+Booking+ID+" + bookingId
+ "+has+been+initiated.+%0AThe+amount+will+be+credited+to+your+account+within+3+to+15+days.";
whatsappMsgServiceImpl.sendMsg(settlementrefundwhatsupmsg);
whatsappMsgServiceImpl.sendSMS(settlementrefundurlString.trim());
// System.out.println(settlementrefundurlString);
return systemName;
}
@GetMapping("/systemnamesss")
public String getUsernamess() throws UnknownHostException {
// Get the local host (your computer)
InetAddress inetAddress = InetAddress.getLocalHost();
// Print the system IP address
System.out.println("System IP Address: " + inetAddress.getHostAddress());
try {
String hostname = java.net.InetAddress.getLocalHost().getHostName();
System.out.println("Hostname: " + hostname);
} catch (UnknownHostException e) {
e.printStackTrace();
}
// Get the local host (your computer)
InetAddress inetAddress = InetAddress.getLocalHost();
// Print the system IP address
// System.out.println("System IP Address: " + inetAddress.getHostAddress());
try {
String hostname = java.net.InetAddress.getLocalHost().getHostName();
// System.out.println("Hostname: " + hostname);
} catch (UnknownHostException e) {
e.printStackTrace();
}
return inetAddress.getHostAddress();
}

83
src/main/java/com/gcc/communityHall/entity/BookingHistory.java

@ -24,29 +24,40 @@ public class BookingHistory {
private Date cdate;
public enum BookingStatus {
PENDING, APPROVED, REJECTED, CANCELED, PAYMENT_FAILURE,GCC_BLOCKED,COMPLETED ,WAITING_FOR_NOC , WAITING_FOR_NOC_APPROVAL
PENDING, APPROVED, REJECTED, CANCELED, PAYMENT_FAILURE, GCC_BLOCKED, COMPLETED, WAITING_FOR_NOC,
WAITING_FOR_NOC_APPROVAL
}
@Column(name="booking_status")
@Column(name = "booking_status")
@Enumerated(EnumType.STRING)
private BookingDetails.BookingStatus bookingStatus;
public enum RefundStatus {
APPROVED, WAITING, INITIATED, REJECTED, COMPLETED, NA
APPROVED, WAITING, INITIATED, REJECTED, COMPLETED, NA
}
@Column(name="refund_status")
@Column(name = "refund_status")
@Enumerated(EnumType.STRING)
private BookingDetails.RefundStatus refundStatus;
private String comments;
private String updatedBy;
@Column(name="start_date")
private String updatedBy;
@Column(name = "start_date")
private String startDate;
@Column(name="end_date")
@Column(name = "end_date")
private String endDate;
/*@ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
@JsonIgnore
private BookingDetails bookingDetails;*/
@Column(name = "starting_slot")
private int startingSlot;
@Column(name = "ending_slot")
private int endingSlot;
/*
* @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
*
* @JsonIgnore
* private BookingDetails bookingDetails;
*/
@ManyToOne(fetch = FetchType.EAGER)
@JsonIgnore
@ -100,27 +111,43 @@ public class BookingHistory {
this.bookingDetails = bookingDetails;
}
public String getStartDate() {
return startDate;
}
public String getStartDate() {
return startDate;
}
public void setStartDate(String startDate) {
this.startDate = startDate;
}
public String getEndDate() {
return endDate;
}
public void setEndDate(String endDate) {
this.endDate = endDate;
}
public void setStartDate(String startDate) {
this.startDate = startDate;
}
public int getStartingSlot() {
return startingSlot;
}
public String getEndDate() {
return endDate;
}
public void setStartingSlot(int startingSlot) {
this.startingSlot = startingSlot;
}
public void setEndDate(String endDate) {
this.endDate = endDate;
}
public int getEndingSlot() {
return endingSlot;
}
public BookingDetails.RefundStatus getRefundStatus() {
return refundStatus;
}
public void setEndingSlot(int endingSlot) {
this.endingSlot = endingSlot;
}
public BookingDetails.RefundStatus getRefundStatus() {
return refundStatus;
}
public void setRefundStatus(BookingDetails.RefundStatus refundStatus) {
this.refundStatus = refundStatus;
}
public void setRefundStatus(BookingDetails.RefundStatus refundStatus) {
this.refundStatus = refundStatus;
}
}

8
src/main/java/com/gcc/communityHall/paymentService/controller/PaymentAPIController.java

@ -136,8 +136,7 @@ public class PaymentAPIController {
@PostMapping(value = { "/payment-request" })
public HashMap<String, Object> startPayment(int userId, int bookingId) throws NoSuchAlgorithmException {
// System.out.println("I entered payment Service......"+bookingId+ "User Id :-
// "+userId);
System.out.println("User entered payment Service......" + bookingId + "User Id :- " + userId);
HashMap<String, Object> hs = new HashMap<>();
Optional<BookingDetails> findById = bookRepo.findById(bookingId);
@ -271,8 +270,7 @@ public class PaymentAPIController {
@PostMapping(value = { "/additionaldamage-payment-request" })
public HashMap<String, Object> startextraPayment(int userId, int bookingId) throws NoSuchAlgorithmException {
// System.out.println("I entered payment Service......"+bookingId+ "User Id :-
// "+userId);
System.out.println("User entered Additional Damage payment Service......" + bookingId + "User Id :- " + userId);
HashMap<String, Object> hs = new HashMap<>();
Optional<BookingDetails> findById = bookRepo.findById(bookingId);
@ -309,7 +307,7 @@ public class PaymentAPIController {
String encryptedtoken = this.paymentService.getToken(merchantId + "|", txnId + "|", totalAmt + "|", "|",
consumerId + "|", consumerMobileNo + "|", consumerEmailId + "|", "|", "|", "|", "|", "|", "|", "|",
"|", "|", this.paymentConfig.getEncryptionKey());
System.out.println(totalAmt);
// System.out.println(totalAmt);
hs.put("txansactionId", txnId);
hs.put("token", encryptedtoken);
hs.put("amount", totalAmt);

780
src/main/java/com/gcc/communityHall/paymentService/controller/PaymentController.java

@ -41,11 +41,10 @@ import com.gcc.communityHall.service.UserService;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;
@Controller
@RequestMapping("/communityhall/payment")
public class PaymentController {
//ak
// ak
@Autowired
private EncryptionUtil encryptionUtil;
@ -73,143 +72,34 @@ public class PaymentController {
@Autowired
private AppConfig appConfig;
// @Autowired
// private ErpPostDataRepository erpPostDataRepository;
// @Autowired
// private ErpPostDataRepository erpPostDataRepository;
@Autowired
private PaymentsService paymentsService;
//ak
@PostMapping(value = "/response")
public String response(Model model, @RequestParam(required = false) String msg) throws NoSuchAlgorithmException {
String salt = this.paymentConfig.getEncryptionKey();
String confirmToken = "";
String status = this.paymentConfig.getTransactionSuccessCode();
String[] res = msg.split("\\|");
String c = "";
TransactionResponse response = this.paymentService.getTransactionResponseByTxansactionId(res[3], "temp");
Payments payment = new Payments();
payment.setTransactionId(response.getTxansactionId());
double amount = 0;
// ------------------ PAYMENT STRING PROCESSING ------------------
for (int i = 0; i < res.length; i++) {
if (i == res.length - 1) {
c = c + salt;
confirmToken = res[i];
} else if (res[i].isEmpty()) {
c = c + "|";
} else if (res[i].equals("NA")) {
c = c + "NA|";
} else {
c = c + res[i] + "|";
}
if (i == 5) {
response.setTpslTxnId(res[i]);
response.setAmount(res[6]);
response.setTxansactionId(res[3]);
response.setDate(res[8]);
}
}
int bookingId = response.getBookingId();
try {
amount = Double.parseDouble(response.getAmount());
} catch (Exception e) {}
payment.setAmountReceived(amount);
payment.setPaymentStatus("Not Completed");
BookingDetails bookingsDetails = bookser.getBookingsById(bookingId); // JPA fetch
payment.setBookingDetails(bookingsDetails);
response.setResponse(msg);
response.setStatusCode(res[0]);
bookingsDetails.setPayments(payment);
payment.setCdate(new Date());
// save transaction response
transactionResRepo.save(response);
// =============================================================
// CASE 1: FAILURE - AMOUNT MISMATCH
// =============================================================
if (bookingsDetails.getAmountReceived() != amount) {
if(paymentService.generateToken(c).equals(confirmToken) && status.equals(res[0])){
payment.setPaymentStatus("Success");
bookingsDetails.setPayments(payment);
paymentRepo.save(payment);
// booking failure logic
bookser.bookingFailure(bookingsDetails, 1);
}
// Fetch OR Generate booking_ref_id
String refId = bookser.getBookingRefIdByBookingId(bookingId);
// encrypt bookingId (coworkspace logic)
String encryptedId = encryptionUtil.encrypt(String.valueOf(bookingId));
model.addAttribute("ref_id", refId);
model.addAttribute("encryptedId", encryptedId);
return "redirect:/communityhall/user/acknowledgement?ref_id=" + refId;
}
// =============================================================
// CASE 2: SUCCESS FLOW
// =============================================================
if (paymentService.generateToken(c).equals(confirmToken) && status.equals(res[0])) {
payment.setPaymentStatus("Success");
bookingsDetails.setPayments(payment);
paymentRepo.save(payment);
try {
bookser.confirmBooking(bookingId);
} catch (Exception e) {
// ignore
}
}
// 🔥 Fetch OR Generate booking_ref_id
String refId = bookser.getBookingRefIdByBookingId(bookingId);
// 🔐 Encrypt bookingId
String encryptedId = encryptionUtil.encrypt(String.valueOf(bookingId));
model.addAttribute("ref_id", refId);
model.addAttribute("encryptedId", encryptedId);
return "redirect:/communityhall/user/acknowledgement?ref_id=" + refId;
}
/* @PostMapping(value = "/response")
// ak
@PostMapping(value = "/response")
public String response(Model model, @RequestParam(required = false) String msg) throws NoSuchAlgorithmException {
String salt = this.paymentConfig.getEncryptionKey();
System.out.println("Payment Response receiving from Payment Gateway...");
String salt = this.paymentConfig.getEncryptionKey();
String confirmToken = "";
String status = this.paymentConfig.getTransactionSuccessCode();
String s = new String(msg);
String c = new String();
String res[] = s.split("\\|");
String[] res = msg.split("\\|");
String c = "";
TransactionResponse response = this.paymentService.getTransactionResponseByTxansactionId(res[3], "temp");
Payments payment = new Payments();
payment.setTransactionId(response.getTxansactionId());
double amount = 0;
// ------------------ PAYMENT STRING PROCESSING ------------------
for (int i = 0; i < res.length; i++) {
if (i == res.length - 1) {
c = c + salt;
confirmToken = res[i];
@ -225,178 +115,331 @@ public String response(Model model, @RequestParam(required = false) String msg)
response.setTpslTxnId(res[i]);
response.setAmount(res[6]);
response.setTxansactionId(res[3]);
//String[] tDate = res[8].split(" ");
response.setDate(res[8]);
}
}
int bookingId = response.getBookingId();
try {
amount = Double.parseDouble(response.getAmount());
} catch (Exception e) {
// TODO: handle exception
//System.out.println("payment Controller lineNo-67");
}
payment.setAmountReceived(amount);
payment.setPaymentStatus("Not Completed");
BookingDetails bookingsDetails = bookser.getBookingsById(bookingId);
BookingDetails bookingsDetails = bookser.getBookingsById(bookingId); // JPA fetch
payment.setBookingDetails(bookingsDetails);
response.setResponse(msg);
response.setStatusCode(res[0]);
bookingsDetails.setPayments(payment);
payment.setCdate(new Date());
System.out.println("bookingsDetails.getAmountReceived().." + bookingsDetails.getAmountReceived());
System.out.println("amount: " + amount);
// save transaction response
transactionResRepo.save(response);
TransactionResponse save = transactionResRepo.save(response);
// =============================================================
// CASE 1: FAILURE - AMOUNT MISMATCH
// =============================================================
if (bookingsDetails.getAmountReceived() != amount) {
if (bookingsDetails.getAmountReceived() != amount) { // Reject booking if the amount is incorrect
if(paymentService.generateToken(c).equals(confirmToken) && status.equals(res[0])){
if (paymentService.generateToken(c).equals(confirmToken) && status.equals(res[0])) {
payment.setPaymentStatus("Success");
bookingsDetails.setPayments(payment);
paymentRepo.save(payment);
// booking failure logic
bookser.bookingFailure(bookingsDetails, 1);
}
//ak
// Fetch OR Generate booking_ref_id
String refId = bookser.getBookingRefIdByBookingId(bookingId);
// encrypt bookingId (coworkspace logic)
String encryptedId = encryptionUtil.encrypt(String.valueOf(bookingId));
model.addAttribute("bookingsDetails", bookingsDetails);
return "redirect:/communityhall/user/acknowledgement?bookingId=" + bookingsDetails.getBookingId();
}
model.addAttribute("ref_id", refId);
model.addAttribute("encryptedId", encryptedId);
return "redirect:/communityhall/user/acknowledgement?ref_id=" + refId;
}
// =============================================================
// CASE 2: SUCCESS FLOW
// =============================================================
if (paymentService.generateToken(c).equals(confirmToken) && status.equals(res[0])) {
payment.setPaymentStatus("Success");
bookingsDetails.setPayments(payment);
try {
String confirmBooking = bookser.confirmBooking(response.getBookingId());
}catch (Exception e){
// return "redirect:/communityhall/user/acknowledgement?bookingId=" + bookingsDetails.getBookingId();
paymentRepo.save(payment);
try {
bookser.confirmBooking(bookingId);
} catch (Exception e) {
// ignore
}
// postDataToERP(payment, response); // post payment details to ERP
// System.out.println("\n confirmBooking:- paymentController 111"+confirmBooking+"\n");
// if(confirmBooking.equals("Booking confirmed successfully")) {
// //bookser.updateBookingStatusById(bookingsDetails.getBookingId(), BookingDetails.BookingStatus.APPROVED, "confirm");
// // String bookingconfimationsms = "Your booking with ID "+bookingsDetails.getBookingId()+" on" +bookingsDetails.getBookingId()+" has been successfully confirmed. Thanks for using GCC Community Hall Booking System.";
// }else if(confirmBooking.equals("Slot occupied")) {
//// System.out.println("Slot occupied line 115");
//// BookingDetails crrSts = bookser.updateBookingStatusById(bookingsDetails.getBookingId(), BookingDetails.BookingStatus.REFUNDED, "slot occupied Refund will happen shortly");
//// System.out.println("BookingDetails:-"+crrSts.getBookingStatus());
// }
// else if(confirmBooking.equals("Error confirming booking")) {
// bookser.updateBookingStatusById(bookingsDetails.getBookingId(), BookingDetails.BookingStatus.PENDING, "Error");
//
// }
}
// System.out.println(response.toString());
model.addAttribute("bookingsDetails", bookingsDetails); // Add single BookingDetails object
//System.out.println(save.toString());
paymentRepo.save(payment);
return "redirect:/communityhall/user/acknowledgement?bookingId=" + bookingsDetails.getBookingId();
}*/
/*public void postDataToERP(Payments payment, TransactionResponse res) {
RestTemplate restTemplate = new RestTemplate();
erpPostData erpData = new erpPostData();
SimpleDateFormat outputFormat = new SimpleDateFormat("dd/MM/yyyy");
String txDate = outputFormat.format(payment.getCdate());
String assesNo = LocalDate.now().getYear() + "/COMM/" + res.getBookingId();
Map<String, Object> data = new TreeMap<>();
*//*static mandatory input to be sent *//*
data.put("serviceId", "getOtherCollection");
data.put("COLLECTION_TYPE", "Community Hall");
data.put("TOTALTRANSACTIONCODE", "450310000");
// /end of static/
// /unique data to be send/
data.put("ASSESSMENTNO", assesNo);
data.put("UNIQUERECEIPTID", res.getBookingId());
data.put("TRANSACTIONNO", payment.getTransactionId());
data.put("TRANSACTIONREFNO", res.getTpslTxnId());
data.put("TRANSACTIONDATE", txDate); //payment date format dd/mm/yyyy -> 19/02/2025
data.put("TOTALTRANSACTIONAMOUNT", payment.getBookingDetails().getAmountReceived());
data.put("MSTRCODEONE", "061");
data.put("SPLITAMOUNTONE", payment.getBookingDetails().getHallAmount());
data.put("MSTRCODETWO", "062");
data.put("SPLITAMOUNTTWO", payment.getBookingDetails().getDepositAmount());
data.put("MSTRCODETHREE", "063");
data.put("SPLITAMOUNTTHREE", payment.getBookingDetails().getGst());
// /Amount Collected from party/
data.put("PARTYNAME", payment.getBookingDetails().getUsers().getName());
data.put("PARTYADDRESS", payment.getBookingDetails().getUsers().getStreet() + "," +
payment.getBookingDetails().getUsers().getArea() + "," + payment.getBookingDetails().getUsers().getLocation() + "," +
payment.getBookingDetails().getUsers().getPinCode());
data.put("PARTYMOBILE", payment.getBookingDetails().getUsers().getMobileNo());
*//* end *//*
System.out.println(data);
System.out.println(appConfig.getCommErpUrl());
// ResponseEntity<String> stringResponseEntity = restTemplate.postForEntity(appConfig.getErpUrl(), data, String.class);
// System.out.println(stringResponseEntity.getBody());
erpData.setTx_id(payment.getTransactionId());
erpData.setBooking_det_booking_id(res.getBookingId());
erpData.setStatus(true);
erpData.setCdate(LocalDate.now());
erpData.setPay_status(1);
erpPostDataRepository.save(erpData);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(appConfig.getCommErpUrl());
for (Map.Entry<String, Object> entry : data.entrySet()) {
builder.queryParam(entry.getKey(), entry.getValue());
}
String urlMsg = builder.toUriString();
System.out.println(urlMsg);
try {
HttpURLConnection connection = null;
URL url = new URL(urlMsg);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
int responseCode = connection.getResponseCode();
// response=responseCode+"";
System.out.println("Response Code: " + responseCode);
if (responseCode == HttpURLConnection.HTTP_OK) { // 200 OK
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println("Response: " + response.toString());
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jsonNode = objectMapper.readTree(response.toString());
// 🔥 Fetch OR Generate booking_ref_id
String refId = bookser.getBookingRefIdByBookingId(bookingId);
String resultStatus = jsonNode.get("ResultStatus").asText();
// 🔐 Encrypt bookingId
String encryptedId = encryptionUtil.encrypt(String.valueOf(bookingId));
if (!resultStatus.isEmpty() && resultStatus.equals("false")) {
erpData.setStatus(false);
erpPostDataRepository.save(erpData);
}
model.addAttribute("ref_id", refId);
model.addAttribute("encryptedId", encryptedId);
} else {
System.out.println("GET request failed.");
}
return "redirect:/communityhall/user/acknowledgement?ref_id=" + refId;
}
} catch (Exception e) {
e.printStackTrace();
}
}*/
/*
* @PostMapping(value = "/response")
* public String response(Model model, @RequestParam(required = false) String
* msg) throws NoSuchAlgorithmException {
*
* String salt = this.paymentConfig.getEncryptionKey();
*
* String confirmToken = "";
* String status = this.paymentConfig.getTransactionSuccessCode();
* String s = new String(msg);
* String c = new String();
* String res[] = s.split("\\|");
*
* TransactionResponse response =
* this.paymentService.getTransactionResponseByTxansactionId(res[3], "temp");
* Payments payment = new Payments();
* payment.setTransactionId(response.getTxansactionId());
* double amount = 0;
*
*
* for (int i = 0; i < res.length; i++) {
* if (i == res.length - 1) {
* c = c + salt;
* confirmToken = res[i];
* } else if (res[i].isEmpty()) {
* c = c + "|";
* } else if (res[i].equals("NA")) {
* c = c + "NA|";
* } else {
* c = c + res[i] + "|";
* }
*
* if (i == 5) {
* response.setTpslTxnId(res[i]);
* response.setAmount(res[6]);
* response.setTxansactionId(res[3]);
* //String[] tDate = res[8].split(" ");
* response.setDate(res[8]);
* }
* }
* int bookingId = response.getBookingId();
* try {
* amount = Double.parseDouble(response.getAmount());
* } catch (Exception e) {
* // TODO: handle exception
* //System.out.println("payment Controller lineNo-67");
* }
* payment.setAmountReceived(amount);
* payment.setPaymentStatus("Not Completed");
*
* BookingDetails bookingsDetails = bookser.getBookingsById(bookingId);
* payment.setBookingDetails(bookingsDetails);
* response.setResponse(msg);
* response.setStatusCode(res[0]);
* bookingsDetails.setPayments(payment);
* payment.setCdate(new Date());
*
* System.out.println("bookingsDetails.getAmountReceived().." +
* bookingsDetails.getAmountReceived());
* System.out.println("amount: " + amount);
*
* TransactionResponse save = transactionResRepo.save(response);
*
* if (bookingsDetails.getAmountReceived() != amount) { // Reject booking if the
* amount is incorrect
* if(paymentService.generateToken(c).equals(confirmToken) &&
* status.equals(res[0])){
* payment.setPaymentStatus("Success");
* bookingsDetails.setPayments(payment);
* paymentRepo.save(payment);
* bookser.bookingFailure(bookingsDetails, 1);
* }
* //ak
*
*
*
* model.addAttribute("bookingsDetails", bookingsDetails);
* return "redirect:/communityhall/user/acknowledgement?bookingId=" +
* bookingsDetails.getBookingId();
* }
*
*
* if (paymentService.generateToken(c).equals(confirmToken) &&
* status.equals(res[0])) {
* payment.setPaymentStatus("Success");
* bookingsDetails.setPayments(payment);
* try {
* String confirmBooking = bookser.confirmBooking(response.getBookingId());
* }catch (Exception e){
* // return "redirect:/communityhall/user/acknowledgement?bookingId=" +
* bookingsDetails.getBookingId();
*
* }
* // postDataToERP(payment, response); // post payment details to ERP
* //
* System.out.println("\n confirmBooking:- paymentController 111"+confirmBooking
* +"\n");
* // if(confirmBooking.equals("Booking confirmed successfully")) {
* // //bookser.updateBookingStatusById(bookingsDetails.getBookingId(),
* BookingDetails.BookingStatus.APPROVED, "confirm");
* // // String bookingconfimationsms =
* "Your booking with ID "+bookingsDetails.getBookingId()+" on"
* +bookingsDetails.getBookingId()
* +" has been successfully confirmed. Thanks for using GCC Community Hall Booking System."
* ;
* // }else if(confirmBooking.equals("Slot occupied")) {
* //// System.out.println("Slot occupied line 115");
* //// BookingDetails crrSts =
* bookser.updateBookingStatusById(bookingsDetails.getBookingId(),
* BookingDetails.BookingStatus.REFUNDED,
* "slot occupied Refund will happen shortly");
* //// System.out.println("BookingDetails:-"+crrSts.getBookingStatus());
* // }
* // else if(confirmBooking.equals("Error confirming booking")) {
* // bookser.updateBookingStatusById(bookingsDetails.getBookingId(),
* BookingDetails.BookingStatus.PENDING, "Error");
* //
* // }
*
* }
*
* // System.out.println(response.toString());
* model.addAttribute("bookingsDetails", bookingsDetails); // Add single
* BookingDetails object
* //System.out.println(save.toString());
* paymentRepo.save(payment);
* return "redirect:/communityhall/user/acknowledgement?bookingId=" +
* bookingsDetails.getBookingId();
* }
*/
/*
* public void postDataToERP(Payments payment, TransactionResponse res) {
* RestTemplate restTemplate = new RestTemplate();
* erpPostData erpData = new erpPostData();
*
* SimpleDateFormat outputFormat = new SimpleDateFormat("dd/MM/yyyy");
* String txDate = outputFormat.format(payment.getCdate());
* String assesNo = LocalDate.now().getYear() + "/COMM/" + res.getBookingId();
*
* Map<String, Object> data = new TreeMap<>();
*//* static mandatory input to be sent *//*
* data.put("serviceId", "getOtherCollection");
* data.put("COLLECTION_TYPE", "Community Hall");
* data.put("TOTALTRANSACTIONCODE", "450310000");
* // /end of static/
* // /unique data to be send/
* data.put("ASSESSMENTNO", assesNo);
* data.put("UNIQUERECEIPTID", res.getBookingId());
* data.put("TRANSACTIONNO", payment.getTransactionId());
* data.put("TRANSACTIONREFNO", res.getTpslTxnId());
* data.put("TRANSACTIONDATE", txDate); //payment date format dd/mm/yyyy
* -> 19/02/2025
* data.put("TOTALTRANSACTIONAMOUNT",
* payment.getBookingDetails().getAmountReceived());
*
* data.put("MSTRCODEONE", "061");
* data.put("SPLITAMOUNTONE",
* payment.getBookingDetails().getHallAmount());
* data.put("MSTRCODETWO", "062");
* data.put("SPLITAMOUNTTWO",
* payment.getBookingDetails().getDepositAmount());
* data.put("MSTRCODETHREE", "063");
* data.put("SPLITAMOUNTTHREE", payment.getBookingDetails().getGst());
* // /Amount Collected from party/
* data.put("PARTYNAME",
* payment.getBookingDetails().getUsers().getName());
* data.put("PARTYADDRESS",
* payment.getBookingDetails().getUsers().getStreet() + "," +
* payment.getBookingDetails().getUsers().getArea() + "," +
* payment.getBookingDetails().getUsers().getLocation() + "," +
* payment.getBookingDetails().getUsers().getPinCode());
* data.put("PARTYMOBILE",
* payment.getBookingDetails().getUsers().getMobileNo());
*//* end *//*
* System.out.println(data);
* System.out.println(appConfig.getCommErpUrl());
* // ResponseEntity<String> stringResponseEntity =
* restTemplate.postForEntity(appConfig.getErpUrl(), data,
* String.class);
* // System.out.println(stringResponseEntity.getBody());
*
* erpData.setTx_id(payment.getTransactionId());
* erpData.setBooking_det_booking_id(res.getBookingId());
* erpData.setStatus(true);
* erpData.setCdate(LocalDate.now());
* erpData.setPay_status(1);
* erpPostDataRepository.save(erpData);
*
* UriComponentsBuilder builder =
* UriComponentsBuilder.fromHttpUrl(appConfig.getCommErpUrl())
* ;
* for (Map.Entry<String, Object> entry : data.entrySet()) {
* builder.queryParam(entry.getKey(), entry.getValue());
* }
*
* String urlMsg = builder.toUriString();
* System.out.println(urlMsg);
*
* try {
* HttpURLConnection connection = null;
*
* URL url = new URL(urlMsg);
* connection = (HttpURLConnection) url.openConnection();
* connection.setRequestMethod("GET");
*
* int responseCode = connection.getResponseCode();
* // response=responseCode+"";
* System.out.println("Response Code: " + responseCode);
*
* if (responseCode == HttpURLConnection.HTTP_OK) { // 200 OK
* BufferedReader in = new BufferedReader(new
* InputStreamReader(connection.getInputStream()));
* String inputLine;
* StringBuilder response = new StringBuilder();
* while ((inputLine = in.readLine()) != null) {
* response.append(inputLine);
* }
* in.close();
* System.out.println("Response: " + response.toString());
*
* ObjectMapper objectMapper = new ObjectMapper();
* JsonNode jsonNode =
* objectMapper.readTree(response.toString());
*
* String resultStatus =
* jsonNode.get("ResultStatus").asText();
*
* if (!resultStatus.isEmpty() &&
* resultStatus.equals("false")) {
* erpData.setStatus(false);
* erpPostDataRepository.save(erpData);
* }
*
* } else {
* System.out.println("GET request failed.");
* }
*
* } catch (Exception e) {
* e.printStackTrace();
* }
* }
*/
@PostMapping(value = "/additionaldamage-response")
public String additionaldamagePaymentresponse(Model model, @RequestParam(required = false) String msg) throws NoSuchAlgorithmException {
public String additionaldamagePaymentresponse(Model model, @RequestParam(required = false) String msg)
throws NoSuchAlgorithmException {
String salt = this.paymentConfig.getEncryptionKey();
@ -411,7 +454,6 @@ public String response(Model model, @RequestParam(required = false) String msg)
payment.setTransactionId(response.getTxansactionId());
double amount = 0;
for (int i = 0; i < res.length; i++) {
if (i == res.length - 1) {
c = c + salt;
@ -428,7 +470,7 @@ public String response(Model model, @RequestParam(required = false) String msg)
response.setTpslTxnId(res[i]);
response.setAmount(res[6]);
response.setTxansactionId(res[3]);
//String[] tDate = res[8].split(" ");
// String[] tDate = res[8].split(" ");
response.setDate(res[8]);
}
}
@ -437,7 +479,7 @@ public String response(Model model, @RequestParam(required = false) String msg)
amount = Double.parseDouble(response.getAmount());
} catch (Exception e) {
// TODO: handle exception
//System.out.println("payment Controller lineNo-67");
// System.out.println("payment Controller lineNo-67");
}
payment.setAmountReceived(amount);
payment.setPaymentStatus("Not Completed");
@ -462,108 +504,128 @@ public String response(Model model, @RequestParam(required = false) String msg)
}
model.addAttribute("bookingsDetails", bookingsDetails);
extraPaymentsRepository.save(payment);
// postEPDataToERP(payment, response); //post extra payments details to ERP
// return "redirect:/communityhall/user/collectionpendingacknowledgement?bookingId=" + bookingsDetails.getBookingId();
return "redirect:/communityhall/user/collectionpendingacknowledgement?bookingId=" + bookingsDetails.getBookingId();
// postEPDataToERP(payment, response); //post extra payments details to ERP
// return
// "redirect:/communityhall/user/collectionpendingacknowledgement?bookingId=" +
// bookingsDetails.getBookingId();
return "redirect:/communityhall/user/collectionpendingacknowledgement?bookingId="
+ bookingsDetails.getBookingId();
}
/*public void postEPDataToERP(ExtraPayments payment, TransactionResponse res) {
RestTemplate restTemplate = new RestTemplate();
erpPostData erpData = new erpPostData();
SimpleDateFormat outputFormat = new SimpleDateFormat("dd/MM/yyyy");
String txDate = outputFormat.format(payment.getCdate());
String assesNo = LocalDate.now().getYear() + "/COMM/ED/" + res.getBookingId();
Map<String, Object> data = new TreeMap<>();
*//*static mandatory input to be sent *//*
data.put("serviceId", "getOtherCollection");
data.put("COLLECTION_TYPE", "Community Hall");
data.put("TOTALTRANSACTIONCODE", "450310000");
// /end of static/
// /unique data to be send/
data.put("ASSESSMENTNO", assesNo);
data.put("UNIQUERECEIPTID", res.getBookingId());
data.put("TRANSACTIONNO", payment.getTransactionId());
data.put("TRANSACTIONREFNO", res.getTpslTxnId());
data.put("TRANSACTIONDATE", txDate); //payment date format dd/mm/yyyy -> 19/02/2025
data.put("TOTALTRANSACTIONAMOUNT", payment.getAmountReceived());
data.put("MSTRCODEONE", "061");
data.put("SPLITAMOUNTONE", 0);
data.put("MSTRCODETWO", "062");
data.put("SPLITAMOUNTTWO", payment.getAmountReceived());
data.put("MSTRCODETHREE", "063");
data.put("SPLITAMOUNTTHREE", 0);
// /Amount Collected from party/
data.put("PARTYNAME", payment.getBookingDetails().getUsers().getName());
data.put("PARTYADDRESS", payment.getBookingDetails().getUsers().getStreet() + "," +
payment.getBookingDetails().getUsers().getArea() + "," + payment.getBookingDetails().getUsers().getLocation() + "," +
payment.getBookingDetails().getUsers().getPinCode());
data.put("PARTYMOBILE", payment.getBookingDetails().getUsers().getMobileNo());
*//* end *//*
System.out.println(data);
System.out.println(appConfig.getCommErpUrl());
// ResponseEntity<String> stringResponseEntity = restTemplate.postForEntity(appConfig.getErpUrl(), data, String.class);
// System.out.println(stringResponseEntity.getBody());
erpData.setTx_id(payment.getTransactionId());
erpData.setBooking_det_booking_id(res.getBookingId());
erpData.setStatus(true);
erpData.setCdate(LocalDate.now());
erpData.setPay_status(2);
erpPostDataRepository.save(erpData);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(appConfig.getCommErpUrl());
for (Map.Entry<String, Object> entry : data.entrySet()) {
builder.queryParam(entry.getKey(), entry.getValue());
}
String urlMsg = builder.toUriString();
System.out.println(urlMsg);
try {
HttpURLConnection connection = null;
URL url = new URL(urlMsg);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
int responseCode = connection.getResponseCode();
// response=responseCode+"";
System.out.println("Response Code: " + responseCode);
if (responseCode == HttpURLConnection.HTTP_OK) { // 200 OK
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println("Response: " + response.toString());
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jsonNode = objectMapper.readTree(response.toString());
String resultStatus = jsonNode.get("ResultStatus").asText();
if (!resultStatus.isEmpty() && resultStatus.equals("false")) {
erpData.setStatus(false);
erpPostDataRepository.save(erpData);
}
} else {
System.out.println("GET request failed.");
}
} catch (Exception e) {
e.printStackTrace();
}
}*/
/*
* public void postEPDataToERP(ExtraPayments payment, TransactionResponse res) {
* RestTemplate restTemplate = new RestTemplate();
* erpPostData erpData = new erpPostData();
*
* SimpleDateFormat outputFormat = new SimpleDateFormat("dd/MM/yyyy");
* String txDate = outputFormat.format(payment.getCdate());
* String assesNo = LocalDate.now().getYear() + "/COMM/ED/" +
* res.getBookingId();
*
* Map<String, Object> data = new TreeMap<>();
*//* static mandatory input to be sent *//*
* data.put("serviceId", "getOtherCollection");
* data.put("COLLECTION_TYPE", "Community Hall");
* data.put("TOTALTRANSACTIONCODE", "450310000");
* // /end of static/
* // /unique data to be send/
* data.put("ASSESSMENTNO", assesNo);
* data.put("UNIQUERECEIPTID", res.getBookingId());
* data.put("TRANSACTIONNO", payment.getTransactionId());
* data.put("TRANSACTIONREFNO", res.getTpslTxnId());
* data.put("TRANSACTIONDATE", txDate); //payment date format dd/mm/yyyy
* -> 19/02/2025
* data.put("TOTALTRANSACTIONAMOUNT", payment.getAmountReceived());
*
* data.put("MSTRCODEONE", "061");
* data.put("SPLITAMOUNTONE", 0);
* data.put("MSTRCODETWO", "062");
* data.put("SPLITAMOUNTTWO", payment.getAmountReceived());
* data.put("MSTRCODETHREE", "063");
* data.put("SPLITAMOUNTTHREE", 0);
* // /Amount Collected from party/
* data.put("PARTYNAME",
* payment.getBookingDetails().getUsers().getName());
* data.put("PARTYADDRESS",
* payment.getBookingDetails().getUsers().getStreet() + "," +
* payment.getBookingDetails().getUsers().getArea() + "," +
* payment.getBookingDetails().getUsers().getLocation() + "," +
* payment.getBookingDetails().getUsers().getPinCode());
* data.put("PARTYMOBILE",
* payment.getBookingDetails().getUsers().getMobileNo());
*//* end *//*
* System.out.println(data);
* System.out.println(appConfig.getCommErpUrl());
* // ResponseEntity<String> stringResponseEntity =
* restTemplate.postForEntity(appConfig.getErpUrl(), data,
* String.class);
* // System.out.println(stringResponseEntity.getBody());
*
* erpData.setTx_id(payment.getTransactionId());
* erpData.setBooking_det_booking_id(res.getBookingId());
* erpData.setStatus(true);
* erpData.setCdate(LocalDate.now());
* erpData.setPay_status(2);
* erpPostDataRepository.save(erpData);
*
* UriComponentsBuilder builder =
* UriComponentsBuilder.fromHttpUrl(appConfig.getCommErpUrl())
* ;
* for (Map.Entry<String, Object> entry : data.entrySet()) {
* builder.queryParam(entry.getKey(), entry.getValue());
* }
*
* String urlMsg = builder.toUriString();
* System.out.println(urlMsg);
*
* try {
* HttpURLConnection connection = null;
*
* URL url = new URL(urlMsg);
* connection = (HttpURLConnection) url.openConnection();
* connection.setRequestMethod("GET");
*
* int responseCode = connection.getResponseCode();
* // response=responseCode+"";
* System.out.println("Response Code: " + responseCode);
*
* if (responseCode == HttpURLConnection.HTTP_OK) { // 200 OK
* BufferedReader in = new BufferedReader(new
* InputStreamReader(connection.getInputStream()));
* String inputLine;
* StringBuilder response = new StringBuilder();
* while ((inputLine = in.readLine()) != null) {
* response.append(inputLine);
* }
* in.close();
* System.out.println("Response: " + response.toString());
*
* ObjectMapper objectMapper = new ObjectMapper();
* JsonNode jsonNode =
* objectMapper.readTree(response.toString());
*
* String resultStatus =
* jsonNode.get("ResultStatus").asText();
*
* if (!resultStatus.isEmpty() &&
* resultStatus.equals("false")) {
* erpData.setStatus(false);
* erpPostDataRepository.save(erpData);
* }
*
* } else {
* System.out.println("GET request failed.");
* }
*
* } catch (Exception e) {
* e.printStackTrace();
* }
* }
*/
@PostMapping(value = "/updatetransaction")
public String updatetransaction(Model model, @RequestParam(required = false) String txansactionId, @RequestParam(required = false) String msg) throws NoSuchAlgorithmException {
public String updatetransaction(Model model, @RequestParam(required = false) String txansactionId,
@RequestParam(required = false) String msg) throws NoSuchAlgorithmException {
Optional<TransactionResponse> transactionresponse = transactionResRepo.findByTxansactionId(txansactionId);
TransactionResponse transactionres = transactionresponse.get();
@ -581,7 +643,6 @@ public String response(Model model, @RequestParam(required = false) String msg)
payment.setTransactionId(response.getTxansactionId());
double amount = 0;
for (int i = 0; i < res.length; i++) {
if (i == res.length - 1) {
c = c + salt;
@ -598,7 +659,7 @@ public String response(Model model, @RequestParam(required = false) String msg)
response.setTpslTxnId(res[i]);
response.setAmount(res[6]);
response.setTxansactionId(res[3]);
//String[] tDate = res[8].split(" ");
// String[] tDate = res[8].split(" ");
response.setDate(res[8]);
}
}
@ -607,7 +668,7 @@ public String response(Model model, @RequestParam(required = false) String msg)
amount = Double.parseDouble(response.getAmount());
} catch (Exception e) {
// TODO: handle exception
//System.out.println("payment Controller lineNo-67");
// System.out.println("payment Controller lineNo-67");
}
payment.setAmountReceived(amount);
payment.setPaymentStatus("Not Completed");
@ -630,7 +691,7 @@ public String response(Model model, @RequestParam(required = false) String msg)
// System.out.println(response.toString());
model.addAttribute("bookingsDetails", bookingsDetails); // Add single BookingDetails object
//System.out.println(save.toString());
// System.out.println(save.toString());
paymentRepo.save(payment);
return "success";
} else {
@ -639,7 +700,8 @@ public String response(Model model, @RequestParam(required = false) String msg)
}
@PostMapping(value = "/refundcompleted")
public String refundCompleted(Model model, @RequestParam String txansactionId, @RequestParam(required = false) String msg) throws NoSuchAlgorithmException {
public String refundCompleted(Model model, @RequestParam String txansactionId,
@RequestParam(required = false) String msg) throws NoSuchAlgorithmException {
Optional<TransactionResponse> transactionresponse = transactionResRepo.findByTxansactionId(txansactionId);
if (transactionresponse.isPresent()) {
TransactionResponse transactionres = transactionresponse.get();

3
src/main/java/com/gcc/communityHall/repository/BookingDetailsRepository.java

@ -1845,4 +1845,7 @@ public interface BookingDetailsRepository extends JpaRepository<BookingDetails,
@Modifying
@Query(value = "UPDATE booking_details SET mail_sent = 1, mailsent_date = NOW() WHERE booking_id = :bookingId", nativeQuery = true)
void markMailSent(@Param("bookingId") int bookingId);
@Query(value = "SELECT * FROM booking_details WHERE booking_status in ('APPROVED','WAITING_FOR_NOC') AND refund_status != 'COMPLETED'", nativeQuery = true)
List<BookingDetails> getApprovedBookingListforReschedule();
}

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

@ -214,8 +214,8 @@ public class BookingServiceImpl implements BookingService {
// Save
bookingDetailsRepository.save(booking);
System.out.println("Migrated booking ID " + bookingId +
" → ref_id = " + generatedRefId);
// System.out.println("Migrated booking ID " + bookingId +
// " → ref_id = " + generatedRefId);
}
}
@ -808,7 +808,7 @@ public class BookingServiceImpl implements BookingService {
Integer userId = userSession.getUserId();
String counterId = userSession.getCounter();
System.out.println("counterId.." + counterId);
// System.out.println("counterId.." + counterId);
ReasonMaster reasonMaster = reasonMasterService
.getReasonById(Integer.parseInt(formData.get("reasonId").toString()));
@ -878,14 +878,14 @@ public class BookingServiceImpl implements BookingService {
// double depositeamount = hallDetails.getDepositAmount() * daysrange;
double depositeamount = hallDetails.getDepositAmount();
System.out.println("depositeamount...." + depositeamount);
// System.out.println("depositeamount...." + depositeamount);
double halfDepositAmount = hallDetails.getHalfDepositAmount();
System.out.println("halfDepositAmount...." + halfDepositAmount);
System.err.println("days.." + days);
System.err.println("daysrange.." + daysrange);
// System.out.println("halfDepositAmount...." + halfDepositAmount);
// System.err.println("days.." + days);
// System.err.println("daysrange.." + daysrange);
double Totaldepositeamount = calculateDepositAmount(daysrange, startingSlot_txt, endingSlot_txt,
depositeamount, halfDepositAmount);
System.out.println("Totaldepositeamount.." + Totaldepositeamount);
// System.out.println("Totaldepositeamount.." + Totaldepositeamount);
depositeamount = Totaldepositeamount;
// Calculate discount based on user type
if (usertype.equals("COUNCILLOR") || usertype.equals("PENSIONER") || usertype.equals("GCC_EMPLOYEE")
@ -1182,9 +1182,9 @@ public class BookingServiceImpl implements BookingService {
double damount = 0;
// FOR FULL DAY
// If there is only one day
System.err.println("in calculate numDays..." + numDays);
System.err.println("in calculate depositAmount..." + depositAmount);
System.err.println("in calculate HalfDepositAmount..." + HalfDepositAmount);
// System.err.println("in calculate numDays..." + numDays);
// System.err.println("in calculate depositAmount..." + depositAmount);
// System.err.println("in calculate HalfDepositAmount..." + HalfDepositAmount);
if (numDays == 1) {
if ("1".equals(startPeriod) && "2".equals(endPeriod)) {
damount = depositAmount;
@ -1209,7 +1209,7 @@ public class BookingServiceImpl implements BookingService {
damount = numDays;
}
}
System.err.println("in calculate damount..." + damount);
// System.err.println("in calculate damount..." + damount);
return damount;
}
@ -1235,6 +1235,8 @@ public class BookingServiceImpl implements BookingService {
bookinghistory.setComments(bookingDetails.getComments());
bookinghistory.setCdate(new Date());
bookinghistory.setRefundStatus(bookingDetails.getRefundStatus());
bookinghistory.setStartingSlot(bookingDetails.getStartingSlot());
bookinghistory.setEndingSlot(bookingDetails.getEndingSlot());
bookingHistoryRepository.save(bookinghistory);
BookingDocuments bd = new BookingDocuments();
@ -1302,7 +1304,8 @@ public class BookingServiceImpl implements BookingService {
bookingDetails = bookingDetailsRepository.save(bookingDetails);
bookingIds.add(bookingDetails.getBookingId());
System.out.println("BookingDetails saved with ID: " + bookingDetails.getBookingId());
// System.out.println("BookingDetails saved with ID: " +
// bookingDetails.getBookingId());
}
// Save the list of booking IDs in the GccBlockingDate entity
@ -1409,6 +1412,8 @@ public class BookingServiceImpl implements BookingService {
bookHistory.setComments(bookDet.getComments());
bookHistory.setCdate(new Date());
bookHistory.setRefundStatus(bookDet.getRefundStatus());
bookHistory.setStartingSlot(bookDet.getStartingSlot());
bookHistory.setEndingSlot(bookDet.getEndingSlot());
bookingHistoryRepository.save(bookHistory);
// Update Booking Status
bookDet.setBookingStatus(status);
@ -1701,7 +1706,7 @@ public class BookingServiceImpl implements BookingService {
if (SettleBookingDetails.isPresent()) {
BookingDetails bookingDetails = SettleBookingDetails.get();
System.out.println("settlement list: " + bookingDetails);
// System.out.println("settlement list: " + bookingDetails);
// 🔹 Only do reset if settlement exists
if (bookingDetails.getSettlement() != null) { // ✅ FIXED HERE
@ -1712,9 +1717,10 @@ public class BookingServiceImpl implements BookingService {
long millisDiff = System.currentTimeMillis() - settlement.getApprovedFlagDate().getTime();
long daysDiff = millisDiff / (1000 * 60 * 60 * 24);
System.out.println("Approved Flag Date123: " + settlement.getApprovedFlagDate());
System.out.println("Current Java Date: " + new Date());
System.out.println("Days Difference: " + daysDiff);
// System.out.println("Approved Flag Date123: " +
// settlement.getApprovedFlagDate());
// System.out.println("Current Java Date: " + new Date());
// System.out.println("Days Difference: " + daysDiff);
if (daysDiff > 4) {
// settlement histoty insert
@ -1746,19 +1752,21 @@ public class BookingServiceImpl implements BookingService {
history.setShDate(new Date());
settlementHistoryRepository.save(history);
System.out.println(
"✅ Record inserted into SettlementHistory for Settlement ID: " + settlementId);
// System.out.println(
// "✅ Record inserted into SettlementHistory for Settlement ID: " +
// settlementId);
}
settlement.setApprovedFlag(0);
settlement.setApprovedFlagDate(null);
settlementRepository.save(settlement);
System.out.println("✅ Approved flag reset after 3 days for Settlement ID: "
+ settlement.getSettlementId());
// System.out.println("✅ Approved flag reset after 3 days for Settlement ID: "
// + settlement.getSettlementId());
}
}
} else {
System.out.println("⚠️ No settlement found for booking ID: " + bookingDetails.getBookingId());
// System.out.println("⚠️ No settlement found for booking ID: " +
// bookingDetails.getBookingId());
}
// ✅ Return same object (your original logic)
@ -1999,6 +2007,8 @@ public class BookingServiceImpl implements BookingService {
bookingHistory.setUpdatedBy(adminname);
bookingHistory.setCdate(new Date());
bookingHistory.setRefundStatus(bookingDetails.getRefundStatus());
bookingHistory.setStartingSlot(bookingDetails.getStartingSlot());
bookingHistory.setEndingSlot(bookingDetails.getEndingSlot());
bookingDetails.setComments("Completed the Refund");
bookingHistoryRepository.save(bookingHistory);
bookings.setBookingStatus(bookingStatus.COMPLETED);
@ -2107,6 +2117,8 @@ public class BookingServiceImpl implements BookingService {
bookingHistory.setUpdatedBy(adminname);
bookingHistory.setCdate(new Date());
bookingHistory.setRefundStatus(book.getRefundStatus());
bookingHistory.setStartingSlot(book.getStartingSlot());
bookingHistory.setEndingSlot(book.getEndingSlot());
bookingHistoryRepository.save(bookingHistory);
book.setComments("Refund status Updated to:-" + status);
@ -2309,12 +2321,6 @@ public class BookingServiceImpl implements BookingService {
LocalDate startDate = LocalDate.parse(startDat, formatter);
LocalDate endDate = LocalDate.parse(endDat, formatter);
// Temporarily apply new slots for calendar-check logic
int origStartSlot = bookingDetails.getStartingSlot();
int origEndSlot = bookingDetails.getEndingSlot();
bookingDetails.setStartingSlot(startingSlot);
bookingDetails.setEndingSlot(endingSlot);
// Clear old calendar entries
List<BookingCalendar> existingCalendars = bookingCalendarRepository
.getCancellingdata1(String.valueOf(bookingId));
@ -2339,23 +2345,14 @@ public class BookingServiceImpl implements BookingService {
(date.equals(startDate) && startingSlot == 2 && bookingCalendar.isEveningSlot()) ||
(date.equals(endDate) && endingSlot == 1 && bookingCalendar.isMorningSlot()) ||
(date.equals(endDate) && endingSlot == 2 && bookingCalendar.isEveningSlot())) {
// Restore original slots before throwing
bookingDetails.setStartingSlot(origStartSlot);
bookingDetails.setEndingSlot(origEndSlot);
throw new SlotOccupiedException(slotOccExpMsg);
} else if (bookingCalendar.isMorningSlot() && bookingCalendar.isEveningSlot()) {
bookingDetails.setStartingSlot(origStartSlot);
bookingDetails.setEndingSlot(origEndSlot);
throw new SlotOccupiedException(slotOccExpMsg);
} else if (!date.equals(endDate) && i != 0 && i != Math.round(bookingDetails.getNoOfDays() - 1)
&& (bookingCalendar.isMorningSlot() || bookingCalendar.isEveningSlot())) {
bookingDetails.setStartingSlot(origStartSlot);
bookingDetails.setEndingSlot(origEndSlot);
throw new SlotOccupiedException(slotOccExpMsg);
} else if (date.equals(endDate) && endingSlot == 2 && bookingCalendar.isMorningSlot()
&& i != 0 && i == Math.round(bookingDetails.getNoOfDays() - 1)) {
bookingDetails.setStartingSlot(origStartSlot);
bookingDetails.setEndingSlot(origEndSlot);
throw new SlotOccupiedException(slotOccExpMsg);
}
} else {
@ -2453,6 +2450,8 @@ public class BookingServiceImpl implements BookingService {
bookingHistory.setBookingStatus(BookingStatus.APPROVED);
bookingHistory.setUpdatedBy(userSession.getDispayName());
bookingHistory.setCdate(new Date());
bookingHistory.setStartingSlot(bookingDetails.getStartingSlot());
bookingHistory.setEndingSlot(bookingDetails.getEndingSlot());
bookingDetails.setStartDate(startDate);
bookingDetails.setEndDate(endDate);
bookingHistory.setRefundStatus(bookingDetails.getRefundStatus());
@ -2460,8 +2459,8 @@ public class BookingServiceImpl implements BookingService {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String formattedDate = LocalDateTime.now().format(formatter);
bookingDetails.setUpdatedDate(formattedDate);
bookingDetailsRepository.save(bookingDetails);
bookingHistoryRepository.save(bookingHistory);
bookingDetailsRepository.save(bookingDetails);
}
/** Overload – also persists updated starting/ending slot values. */
@ -2483,6 +2482,8 @@ public class BookingServiceImpl implements BookingService {
bookingHistory.setUpdatedBy(userSession.getDispayName());
bookingHistory.setCdate(new Date());
bookingHistory.setRefundStatus(bookingDetails.getRefundStatus());
bookingHistory.setStartingSlot(bookingDetails.getStartingSlot());
bookingHistory.setEndingSlot(bookingDetails.getEndingSlot());
bookingDetails.setStartDate(startDate);
bookingDetails.setEndDate(endDate);
// ── Persist the updated slots ──────────────────────────────────────
@ -2491,8 +2492,9 @@ public class BookingServiceImpl implements BookingService {
bookingDetails.setComments("slots Resheduled the Dates");
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
bookingDetails.setUpdatedDate(LocalDateTime.now().format(formatter));
bookingDetailsRepository.save(bookingDetails);
bookingHistoryRepository.save(bookingHistory);
bookingDetailsRepository.save(bookingDetails);
}
@Override
@ -2633,7 +2635,7 @@ public class BookingServiceImpl implements BookingService {
BookingCalendar data = getbyDates(aa, hallId.toString());
int userbookingbookingId = bookingIds.get(hallIdsList.indexOf(hallId));
if (data != null) {
System.out.println("uniqueId...1" + uniqueId);
// System.out.println("uniqueId...1" + uniqueId);
data.setBookingId_1(String.valueOf(userbookingbookingId));
data.setBookingId_2(String.valueOf(userbookingbookingId));
data.setMorningSlot(true);
@ -2642,7 +2644,7 @@ public class BookingServiceImpl implements BookingService {
data.setUnique_id(uniqueId);
updateBookingStatus(data);
} else {
System.out.println("uniqueId...2" + uniqueId);
// System.out.println("uniqueId...2" + uniqueId);
BookingCalendar book = new BookingCalendar();
book.setBdate(aa);
book.setBookingId_1(String.valueOf(userbookingbookingId));
@ -2745,7 +2747,7 @@ public class BookingServiceImpl implements BookingService {
String uniqueId = date.format(DateTimeFormatter.ofPattern("yyyyMMdd")) + hallId;
int userbookingbookingId = bookingIds.get(hallIdsList.indexOf(hallId));
if (data != null) {
System.out.println("uniqueId...11" + uniqueId);
// System.out.println("uniqueId...11" + uniqueId);
// data.setBookingId_1(String.valueOf(userbookingbookingId));
// data.setBookingId_2(String.valueOf(userbookingbookingId));
// data.setMorningSlot(true);
@ -2754,7 +2756,7 @@ public class BookingServiceImpl implements BookingService {
// data.setUnique_id(uniqueId);
updateBookingStatus(data);
} else {
System.out.println("uniqueId...21" + uniqueId);
// System.out.println("uniqueId...21" + uniqueId);
BookingCalendar book = new BookingCalendar();
book.setBdate(date);
book.setBookingId_1(String.valueOf(userbookingbookingId));
@ -3209,6 +3211,8 @@ public class BookingServiceImpl implements BookingService {
bookingHistory.setUpdatedBy(adminname);
bookingHistory.setCdate(new Date());
bookingHistory.setRefundStatus(book.getRefundStatus());
bookingHistory.setStartingSlot(book.getStartingSlot());
bookingHistory.setEndingSlot(book.getEndingSlot());
bookingHistoryRepository.save(bookingHistory);
return bookings;

74
src/main/java/com/gcc/communityHall/service/Impl/SettlementServiceImpl.java

@ -147,7 +147,7 @@ public class SettlementServiceImpl implements SettlementService {
String adminname = (String) session.getAttribute("usertype");
if (settlementOptional.isPresent()) {
Settlement settlement = settlementOptional.get();
System.out.println("settlement@12345" + settlement);
// System.out.println("settlement@12345" + settlement);
BookingDetails bookingDetails = settlement.getBookingDetails(); // Fetch associated BookingDetails
// Update BookingDetails with new RefundStatus
@ -161,48 +161,44 @@ public class SettlementServiceImpl implements SettlementService {
// to maintain history for settlement
bookingDetailsRepository.save(bookingDetails);
//ak
//settlement histoty insert
if (settlementOptional.isPresent()) {
SettlementHistory history = new SettlementHistory();
history.setSettlementId(settlement.getSettlementId());
history.setComments(settlement.getComments());
history.setCdate(settlement.getCdate());
history.setDamageAmount(settlement.getDamageAmount());
history.setEbAmount(settlement.getEbAmount());
history.setDepositAmount(settlement.getDepositAmount());
history.setRefundedAmount(settlement.getRefundedAmount());
history.setUpdatedDate(new Date());
history.setUpdatedId(adminname);
history.setChallon(settlement.getChallon());
history.setDddate(settlement.getDddate());
history.setDdnumber(settlement.getDdnumber());
history.setBookingDetails(settlement.getBookingDetails());
history.setCollectionPending(settlement.getCollectionPending());
history.setDdamount(settlement.getDdamount());
history.setChallonnumber(settlement.getChallonnumber());
history.setCollectionStatus(settlement.getCollectionStatus());
history.setChallonamount(settlement.getChallonamount());
history.setApprovedFlag(settlement.getApprovedFlag());
history.setApprovedFlagDate(settlement.getApprovedFlagDate());
history.setShDate(new Date());
settlementHistoryRepository.save(history);
System.out.println("✅ Record inserted into SettlementHistory for Settlement ID: " + settlementId);
}
// ak
// settlement histoty insert
if (settlementOptional.isPresent()) {
SettlementHistory history = new SettlementHistory();
history.setSettlementId(settlement.getSettlementId());
history.setComments(settlement.getComments());
history.setCdate(settlement.getCdate());
history.setDamageAmount(settlement.getDamageAmount());
history.setEbAmount(settlement.getEbAmount());
history.setDepositAmount(settlement.getDepositAmount());
history.setRefundedAmount(settlement.getRefundedAmount());
history.setUpdatedDate(new Date());
history.setUpdatedId(adminname);
history.setChallon(settlement.getChallon());
history.setDddate(settlement.getDddate());
history.setDdnumber(settlement.getDdnumber());
history.setBookingDetails(settlement.getBookingDetails());
history.setCollectionPending(settlement.getCollectionPending());
history.setDdamount(settlement.getDdamount());
history.setChallonnumber(settlement.getChallonnumber());
history.setCollectionStatus(settlement.getCollectionStatus());
history.setChallonamount(settlement.getChallonamount());
history.setApprovedFlag(settlement.getApprovedFlag());
history.setApprovedFlagDate(settlement.getApprovedFlagDate());
history.setShDate(new Date());
settlementHistoryRepository.save(history);
// System.out.println("✅ Record inserted into SettlementHistory for Settlement
// ID: " + settlementId);
}
// checking ak
//settlement.setApprovedFlag(1);
//settlement.setApprovedFlagDate(new Date());
// settlement.setApprovedFlag(1);
// settlement.setApprovedFlagDate(new Date());
settlement.setUpdatedDate(new Date());
// Update Settlement comments

23
src/main/java/com/gcc/communityHall/service/Impl/UserServiceImpl.java

@ -35,7 +35,6 @@ import jakarta.servlet.http.HttpSession;
@Service
public class UserServiceImpl implements UserService {
@Autowired
UsersRepository usersRepository;
@ -59,7 +58,8 @@ public class UserServiceImpl implements UserService {
@Override
@Transactional
public void approveUser(int userId) {
entityManager.createQuery("UPDATE Users u SET u.userstatus = 'APPROVED' WHERE u.userId = :userId AND u.userstatus = 'PENDING'")
entityManager.createQuery(
"UPDATE Users u SET u.userstatus = 'APPROVED' WHERE u.userId = :userId AND u.userstatus = 'PENDING'")
.setParameter("userId", userId)
.executeUpdate();
}
@ -80,10 +80,11 @@ public class UserServiceImpl implements UserService {
if (user.getUsertype() == null || !user.getUsertype().equals(Users.userType.PUBLIC)) {
user.setUserstatus(Users.userStatus.PENDING);
}
// if(user.getUsertype().equals(Users.userType.COUNCILLOR)) {
// Counsellordetails counsellordetails=counsellorDetailsRepository.findByMobile(user.getMobileNo());
// counsellordetails.getMobile1();counsellordetails.getMobile2()
// }
// if(user.getUsertype().equals(Users.userType.COUNCILLOR)) {
// Counsellordetails
// counsellordetails=counsellorDetailsRepository.findByMobile(user.getMobileNo());
// counsellordetails.getMobile1();counsellordetails.getMobile2()
// }
Users saveUser = usersRepository.save(user);
if (user.getUserPhoto() != null && !user.getUserPhoto().isEmpty()) {
@ -102,7 +103,6 @@ public class UserServiceImpl implements UserService {
return saveUser;
}
@Override
public Users getUserById(int userId) {
Optional<Users> user = usersRepository.findById(userId);
@ -161,7 +161,6 @@ public class UserServiceImpl implements UserService {
applicationLogsRepository.save(logs);
return users;
}
return null;
}
@ -172,14 +171,13 @@ public class UserServiceImpl implements UserService {
return usersRepository.findByMobileNo(mobileNo);
}
//yoga
// yoga
@Override
public List<Users> getAllUsers(String fromDate, String toDate) {
return usersRepository.getAllUsers(fromDate, toDate);
}
@Override
public List<Users> getAllUsersWithFilters(String fromDate, String toDate, String userStatus, String userType) {
return usersRepository.getAllUsersWithFilters(fromDate, toDate, userStatus, userType);
@ -197,7 +195,6 @@ public class UserServiceImpl implements UserService {
return usersRepository.getAllUsersWithTypeFilters(fromDate, toDate, userType);
}
public void updateProfile(Users userProfileRequest) {
// Retrieve the user entity from the repository based on the ID
Optional<Users> optionalUser = usersRepository.findById(userProfileRequest.getUserId());
@ -212,7 +209,8 @@ public class UserServiceImpl implements UserService {
user.setEmail(userProfileRequest.getDoorNo());
usersRepository.save(user);
} else {
System.out.println("User with ID " + userProfileRequest.getUserId() + " not found");
// System.out.println("User with ID " + userProfileRequest.getUserId() + " not
// found");
}
}
@ -246,7 +244,6 @@ public class UserServiceImpl implements UserService {
return "failed";
}
@Override
public void saveUsers(Users user) {
// TODO Auto-generated method stub

2139
src/main/resources/templates/cro/booking-list.html
File diff suppressed because it is too large
View File

0
src/main/resources/templates/cro/booking-status.html

0
src/main/resources/templates/cro/noc-details.html

2
src/main/resources/templates/fragments/adminMenu.html

@ -3,7 +3,7 @@
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/admin/dashboard">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">Dasboard</span>
<span class="nav-main-link-name">Dashboard</span>
</a>
</li>
<li class="nav-main-item">

199
src/main/resources/templates/fragments/croMenu.html

@ -0,0 +1,199 @@
<div class="content-side">
<ul class="nav-main">
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/cro/booking-list">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">Reschedule Booking</span>
</a>
</li>
<!-- <li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/cro/booking-status">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">Booking Status</span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/cro/nocdetails">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">NOC Details</span>
</a>
</li> -->
<!-- <li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/admin/userdeactive">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">User Deactive</span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/admin/approval-history">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">User Pending List</span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/admin/user-approved">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">User Approval List</span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/admin/user-reject">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">User Rejected List</span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/admin/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/admin/GccblockingNew">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">GCC Blocking (New)</span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/admin/ongoingevents">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">Recent Events</span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/admin/viewUploadNoc">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">Waiting For NOC </span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/admin/bookingwaitinglist">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">Waiting For NOC Approval</span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/admin/booking-list">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">Booking Approved List</span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/admin/rejected-list">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">Booking Rejected List</span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/admin/halldetailslist">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">Hall Details List</span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/admin/DiscountRange">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">Discount Range</span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/admin/settlement-approved">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">Settlement Approved List</span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/admin/settlement-initiatedlist">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">Settlement Initiated List</span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/admin/settlement-list">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">Settlement Pending List</span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/admin/settlementlist">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">Settlement List</span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/admin/settlement-reject">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">Settlement Rejected List</span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/admin/refundfailed-list">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">Refund Failed List</span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/admin/settlement-completedlist">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">Settlement Completed List</span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/admin/manualrefund">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">Manual Refund</span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/admin/ReasonMaster">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">Reason Master</span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/admin/notification">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">Notifications</span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/admin/Gccblocking">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">Gcc Blocking</span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/admin/Reports">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">Reports</span>
</a>
</li>
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/admin/developer">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">Developers</span>
</a>
</li>-->
<li class="nav-main-item">
<a class="nav-main-link" href="/communityhall/cro/logout">
<i class="nav-main-link-icon fa fa-location-arrow"></i>
<span class="nav-main-link-name">Sign Out</span>
</a>
</li>
</ul>
</div>

46
src/main/resources/templates/fragments/head-cro.html

@ -0,0 +1,46 @@
<head xmlns:th="http://www.w3.org/1999/xhtml">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title th:text="'GCC - '+communityHall">GCC</title>
<base th:href="${baseURL}" />
<meta name="description" content="GCC - communityHall">
<meta name="author" content="BonTon Softwares pvt Limited">
<meta name="robots" content="noindex, nofollow">
<!-- Open Graph Meta -->
<meta property="og:title" content="GCC - communityHall">
<meta property="og:site_name" content="GCC">
<meta property="og:description" content="Greater Chennai Corporation - communityHall">
<meta property="og:type" content="website">
<meta property="og:url" content="">
<meta property="og:image" content="">
<!-- Icons -->
<!-- The following icons can be replaced with your own, they are used by desktop and mobile browsers -->
<link rel="shortcut icon" href="media/favicons/favicon.png">
<link rel="icon" type="image/png" sizes="192x192" href="media/favicons/favicon-192x192.png">
<link rel="apple-touch-icon" sizes="180x180" href="media/favicons/apple-touch-icon-180x180.png">
<!-- END Icons -->
<!-- Stylesheets -->
<!-- Page JS Plugins CSS -->
<link rel="stylesheet" href="js/plugins/datatables-bs5/css/dataTables.bootstrap5.min.css">
<link rel="stylesheet" href="js/plugins/datatables-buttons-bs5/css/buttons.bootstrap5.min.css">
<link rel="stylesheet" href="js/plugins/datatables-responsive-bs5/css/responsive.bootstrap5.min.css">
<!-- Page JS Plugins CSS -->
<link rel="stylesheet" href="js/plugins/sweetalert2/sweetalert2.min.css">
<!-- Dashmix framework -->
<link rel="stylesheet" id="css-main" href="css/dashmix.css">
<!-- You can include a specific file from css/themes/ folder to alter the default color theme of the template. eg: -->
<!-- <link rel="stylesheet" id="css-theme" href="assets/css/themes/xwork.min.css"> -->
<link rel="stylesheet" id="css-theme" href="css/themes/xinspire.css">
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/css/bootstrap-multiselect.min.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<!-- END Stylesheets -->
</head>

98
src/main/resources/templates/fragments/header-cro.html

@ -0,0 +1,98 @@
<header id="page-header" xmlns:th="http://www.w3.org/1999/xhtml">
<!-- Header Content -->
<div class="content-header">
<!-- Left Section -->
<div class="space-x-1">
<!-- Toggle Sidebar -->
<!-- Layout API, functionality initialized in Template._uiApiLayout()-->
<button type="button" class="btn btn-alt-secondary" data-toggle="layout" data-action="sidebar_toggle">
<i class="fa fa-fw fa-bars"></i>
</button>
<!-- END Toggle Sidebar -->
</div>
<!-- END Left Section -->
<div class="row pt-1" style="margin:0px;">
<!--<div class="col-2 text-center p-1">
<img src="assets/media/images/tamilnadu-logo.png" style="padding-top:2px;" width="30px" alt="Tamilnadu Logo">
</div>-->
<div class="col-2 text-center p-1">
<img src='media/images/logo-sm.png' width="37" alt="Logo Sm">
</div>
<div class="col-8 text-center p-0" style="font-size:15px;">
பெருநகர சென்னை மாநகராட்சி
</div>
<!--<div class="col-2 text-center p-1">
<img src='assets/media/images/logo-sm.png' width="32" alt="Logo Sm">
</div>-->
</div>
<!-- Right Section -->
<div class="space-x-1">
<!-- User Dropdown
<div class="dropdown d-inline-block">
<button type="button" class="btn btn-alt-secondary" id="page-header-user-btn">
<i class="far fa-fw fa-user me-1"></i>
<span class="d-none d-sm-inline ms-1" th:text="${adminname}"></span>
</button>
</div> -->
<div class="dropdown d-inline-block">
<button type="button" class="btn btn-alt-secondary dropdown-toggle" id="page-header-user-dropdown"
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="far fa-fw fa-user me-1"></i>
<span class="d-none d-sm-inline ms-1" th:text="${adminname}"></span>
</button>
<div class="dropdown-menu dropdown-menu-end p-0" aria-labelledby="page-header-user-dropdown">
<div class="bg-primary-dark rounded-top fw-semibold text-white text-center p-3">
User Options
</div>
<div class="p-2">
<a class="dropdown-item" href="javascript:resetPassword();">
<i class="far fa-fw fa-user me-1"></i> Reset Password
</a>
<div role="separator" class="dropdown-divider"></div>
<a class="dropdown-item" href="/communityhall/cro/logout">
<i class="far fa-fw fa-arrow-alt-circle-left me-1"></i> Sign Out
</a>
</div>
</div>
</div>
<!-- END User Dropdown -->
<!-- Header Search -->
<div id="page-header-search" class="overlay-header bg-header-dark">
<div class="bg-white-10">
<div class="content-header">
<form class="w-100" action="be_pages_generic_search.html" method="POST">
<div class="input-group">
<!-- Layout API, functionality initialized in Template._uiApiLayout() -->
<button type="button" class="btn btn-alt-primary" data-toggle="layout"
data-action="header_search_off">
<i class="fa fa-fw fa-times-circle"></i>
</button>
<input type="text" class="form-control border-0" placeholder="Search or hit ESC.."
id="page-header-search-input" name="page-header-search-input">
</div>
</form>
</div>
</div>
</div>
<!-- END Header Search -->
<!-- Header Loader -->
<!-- Please check out the Loaders page under Components category to see examples of showing/hiding it -->
<div id="page-header-loader" class="overlay-header bg-header-dark">
<div class="bg-white-10">
<div class="content-header">
<div class="w-100 text-center">
<i class="fa fa-fw fa-sun fa-spin text-white"></i>
</div>
</div>
</div>
</div>
<!-- END Header Loader -->
</header>

4
src/main/resources/templates/fragments/loginhead.html

@ -11,9 +11,9 @@
<meta name="robots" content="noindex, nofollow">
<!-- Open Graph Meta -->
<meta property="og:title" content="GCC - Makkal Thedi Mayor">
<meta property="og:title" content="GCC - communityHall">
<meta property="og:site_name" content="GCC">
<meta property="og:description" content="Greater Chennai Corporation - Community Hall">
<meta property="og:description" content="Greater Chennai Corporation - communityHall">
<meta property="og:type" content="website">
<meta property="og:url" content="">
<meta property="og:image" content="">

163
src/main/resources/templates/fragments/loginscript.html

@ -28,99 +28,100 @@
<!-- Bootstrap and Multiselect -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.bundle.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/js/bootstrap-multiselect.min.js"></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/js/bootstrap-multiselect.min.js"></script>
<script>
$(document).ready(function () {
// Get the current URL
var currentUrl = window.location.href;
$(document).ready(function () {
// Get the current URL
var currentUrl = window.location.href;
// Loop through each navigation item
$('.nav-main-item').each(function () {
// Get the link for this item
var link = $(this).find('.nav-main-link').attr('href');
//console.log(link + " == " + currentUrl + " == " + currentUrl.indexOf(link));
// Check if the link matches the current URL
if (currentUrl.indexOf(link) !== -1) {
// Add the active class to this item
$(this).find('.nav-main-link').addClass('active');
// Loop through each navigation item
$('.nav-main-item').each(function () {
// Get the link for this item
var link = $(this).find('.nav-main-link').attr('href');
//console.log(link + " == " + currentUrl + " == " + currentUrl.indexOf(link));
// Check if the link matches the current URL
if (currentUrl.indexOf(link) !== -1) {
// Add the active class to this item
$(this).find('.nav-main-link').addClass('active');
// Add the open class to the parent item
$(this).parents('.nav-main-item').addClass('open');
}
});
});
function resetPassword() {
$('#resetpinForm').modal('show');
}
function resetpinsave() {
let resetpinmobilenumber = $("#resetpinmobilenumber").val();
let oldpin = $("#oldpin").val();
let newpin = $("#newpin").val();
// Add the open class to the parent item
$(this).parents('.nav-main-item').addClass('open');
}
});
// Validate that all fields are filled
if (!resetpinmobilenumber || !oldpin || !newpin) {
Swal.fire('Error', 'Please fill all the fields.', 'error');
return false; // Prevent form submission
});
function resetPassword() {
$('#resetpinForm').modal('show');
}
function resetpinsave() {
let resetpinmobilenumber = $("#resetpinmobilenumber").val();
let oldpin = $("#oldpin").val();
let newpin = $("#newpin").val();
$.ajax({
type: "GET",
url: '/communityhall/careTaker/api/resetPIN',
data: {
'oldpin': oldpin,
'newpin': newpin,
'resetpinmobilenumber': resetpinmobilenumber
},
dataType: 'text',
success: function(bodyMessage) {
if (bodyMessage.trim() === "Success") {
Swal.fire(
'PIN Registration!',
'Your New PIN Successfully Saved!<br>Now login with your new PIN.',
'success'
).then(() => {
window.location.href = '/communityhall/admin/logout';
});
} else if (bodyMessage.trim() === "error") {
// Validate that all fields are filled
if (!resetpinmobilenumber || !oldpin || !newpin) {
Swal.fire('Error', 'Please fill all the fields.', 'error');
return false; // Prevent form submission
}
$.ajax({
type: "GET",
url: '/communityhall/careTaker/api/resetPIN',
data: {
'oldpin': oldpin,
'newpin': newpin,
'resetpinmobilenumber': resetpinmobilenumber
},
dataType: 'text',
success: function (bodyMessage) {
if (bodyMessage.trim() === "Success") {
Swal.fire(
'PIN Registration!',
'Your New PIN Successfully Saved!<br>Now login with your new PIN.',
'success'
).then(() => {
window.location.href = '/communityhall/admin/logout';
});
} else if (bodyMessage.trim() === "error") {
Swal.fire(
'Error',
'Old PIN is not matched with your PIN',
'error'
)
}
},
error: function () {
Swal.fire(
'Error',
'Old PIN is not matched with your PIN',
'An error occurred while processing your request. Please try again later.',
'error'
)
);
}
},
error: function() {
Swal.fire(
'Error',
'An error occurred while processing your request. Please try again later.',
'error'
);
}
});
});
return false; // Prevent form submission as the form is handled by AJAX
}
document.addEventListener('DOMContentLoaded', function () {
function clearModalFields(modalId) {
const modal = document.getElementById(modalId);
if (modal) {
// Clear text inputs and select elements
modal.querySelectorAll('input[type="password"], select').forEach(input => {
if (input.tagName === 'SELECT') {
input.selectedIndex = 0; // Reset to default option
} else {
input.value = ''; // Clear text inputs
}
});
}
}
return false; // Prevent form submission as the form is handled by AJAX
}
document.addEventListener('DOMContentLoaded', function () {
function clearModalFields(modalId) {
const modal = document.getElementById(modalId);
if (modal) {
// Clear text inputs and select elements
modal.querySelectorAll('input[type="password"], select').forEach(input => {
if (input.tagName === 'SELECT') {
input.selectedIndex = 0; // Reset to default option
} else {
input.value = ''; // Clear text inputs
}
});
}
}
// Clear fields when the saveModal is hidden
document.getElementById('resetpinForm').addEventListener('hidden.bs.modal', function () {
clearModalFields('resetpinForm');
});
});
// Clear fields when the saveModal is hidden
document.getElementById('resetpinForm').addEventListener('hidden.bs.modal', function () {
clearModalFields('resetpinForm');
});
});
</script>

13
src/main/resources/templates/fragments/nav-cro.html

@ -0,0 +1,13 @@
<nav id="sidebar" aria-label="Main Navigation" xmlns:th="http://www.w3.org/1999/xhtml">
<!-- Side Header -->
<div th:replace="~{fragments/side-header :: div}"></div>
<!-- END Side Header -->
<!-- Sidebar Scrolling -->
<div class="js-sidebar-scroll">
<!-- Side Navigation -->
<div th:replace="~{fragments/croMenu :: div}"></div>
<!-- END Side Navigation -->
</div>
<!-- END Sidebar Scrolling -->
</nav>

3
src/main/resources/templates/officiallogin.html

@ -485,6 +485,9 @@
case "headquarters":
window.location.href = "/communityhall/headquarters/dashboard";
break;
case "cro":
window.location.href = "/communityhall/cro/booking-list";
break;
default:
console.error("Invalid user type:", userType);
}

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

@ -900,7 +900,7 @@
style="margin-right:0px;margin:0;padding:0;">
<div class="col-md-12 col-lg-12 col-sm-12">
<div class="card-body">
<table>
<table style="width: 100%;">
<tr>
<th colspan="10"
style="background-color: lightgrey;">
@ -913,7 +913,7 @@
User Name:
</th>
<td class="fw-semibold"
style="padding: 0.45rem 0.45rem;"
style="padding: 0.45rem 0.45rem;width: 100%; max-width: 180px; word-break: break-word; overflow-wrap: anywhere; white-space: normal; vertical-align: middle;"
id="td_userName"></td>
<th
style="padding: 0.45rem 0.45rem;font-weight: normal;">
@ -2961,13 +2961,48 @@
}
function Reschedule() {
// --- Slot availability check for today's date ---
var startDate = document.getElementById("startDateInput").value;
var endDate = document.getElementById("endDateInput").value;
var startingSlot = document.getElementById("startingSlot").value;
var endingSlot = document.getElementById("endingSlotHidden").value;
var todayDateStr = $("#serverDate").val();
var currentHour = new Date().getHours();
if (!startDate) {
Swal.fire({
icon: 'warning',
title: 'Select Start Date',
text: 'Please select a start date from the calendar.',
showConfirmButton: true
});
return;
}
if (!endDate) {
Swal.fire({
icon: 'error',
title: 'Error',
text: 'End Date is empty. Please check your Start Date and Slot selection.',
showConfirmButton: true
});
return;
}
// --- Check if booked date and slots are unchanged ---
if (startDate === rescheduleStartDate &&
endDate === rescheduleEndDate &&
parseInt(startingSlot) === parseInt(rescheduleStartingSlot) &&
parseInt(endingSlot) === parseInt(rescheduleEndingSlot)) {
Swal.fire({
icon: 'warning',
title: 'No Changes Detected',
text: 'The selected dates and slots are identical to your current booking. Please choose a different date or slot to reschedule.',
showConfirmButton: true
});
return;
}
// --- Slot availability check for today's date ---
if (startDate === todayDateStr) {
// Morning slot (1) is NOT available after 6 AM
if (startingSlot === "1" && currentHour >= 6) {
@ -3260,16 +3295,19 @@
currentHour: currentHour
});
// Check if the rescheduled start date is the same as the original booked start date
// if (startDate === originalStartDate) {
// Swal.fire({
// icon: 'warning',
// title: 'Warning',
// text: 'Your Rescheduled Start Date is the same as Your booking Start Date. Please change the date.',
// showConfirmButton: true
// });
// return;
// }
// Check if the rescheduled date and slots are identical to original booked booking
if (startDate === rescheduleStartDate &&
endDate === rescheduleEndDate &&
parseInt(startingSlot) === parseInt(rescheduleStartingSlot) &&
parseInt(endingSlot) === parseInt(rescheduleEndingSlot)) {
Swal.fire({
icon: 'warning',
title: 'No Changes Detected',
text: 'The selected dates and slots are identical to your current booking. Please choose a different date or slot to reschedule.',
showConfirmButton: true
});
return;
}
if (!endDate) {
Swal.fire({
icon: 'error',

Loading…
Cancel
Save