diff --git a/src/main/java/com/gcc/communityHall/controller/CareTakerAPIController.java b/src/main/java/com/gcc/communityHall/controller/CareTakerAPIController.java index b7d7b95f..cd394305 100644 --- a/src/main/java/com/gcc/communityHall/controller/CareTakerAPIController.java +++ b/src/main/java/com/gcc/communityHall/controller/CareTakerAPIController.java @@ -4,8 +4,11 @@ import java.io.FileWriter; import java.io.IOException; import java.net.InetAddress; import java.net.UnknownHostException; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import com.gcc.communityHall.others.UserSession; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -55,6 +58,9 @@ import lombok.AllArgsConstructor; @Validated public class CareTakerAPIController { + @Autowired + private UserSession userSession; + @Autowired private BookingService bookingService; @@ -199,6 +205,7 @@ public class CareTakerAPIController { @RequestParam String pin, HttpSession session) { try { +// System.out.println("careTaker API Controller\nCounter Id: "+userSession.getCounter()+"\nCounter Name: "+userSession.getCounterName()); // Fetch login details from the repository Login login = loginrepo.findByMobileNoAndPin(Long.parseLong(mobileNo), pin); if (login != null) { @@ -230,7 +237,15 @@ public class CareTakerAPIController { logs.setLoginId(login.getId()); logs.setIpaddress(inetAddress.getHostAddress()); logs.setSystemName(hostname); - applicationLogsRepository.save(logs); + applicationLogsRepository.save(logs); + + userSession.setCounter(login.getEmployeeId()); + userSession.setCounterName(login.getName()); + + Map response = new HashMap<>(); + response.put("userType", login.getUserType()); + response.put("counterName", login.getName()); // Send Counter Name + response.put("token", token); // Write the token to a file try (FileWriter fileWriter = new FileWriter("jwtToken.txt")) { diff --git a/src/main/java/com/gcc/communityHall/controller/CounterController.java b/src/main/java/com/gcc/communityHall/controller/CounterController.java index 6e6311e6..c67c4af5 100644 --- a/src/main/java/com/gcc/communityHall/controller/CounterController.java +++ b/src/main/java/com/gcc/communityHall/controller/CounterController.java @@ -1,10 +1,19 @@ package com.gcc.communityHall.controller; +import java.io.FileWriter; +import java.io.IOException; +import java.net.InetAddress; +import java.time.LocalDate; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.gcc.communityHall.component.JwtUtil; +import com.gcc.communityHall.dto.ErrorResponseDto; +import com.gcc.communityHall.entity.*; +import com.gcc.communityHall.repository.*; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; @@ -16,15 +25,8 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; -import com.gcc.communityHall.entity.BookingDetails; import com.gcc.communityHall.entity.BookingDetails.BookingStatus; -import com.gcc.communityHall.entity.CounterDetails; -import com.gcc.communityHall.entity.CounterRefundList; -import com.gcc.communityHall.entity.Users; import com.gcc.communityHall.others.UserSession; -import com.gcc.communityHall.repository.BookingDetailsRepository; -import com.gcc.communityHall.repository.CounterDetailsRepository; -import com.gcc.communityHall.repository.CounterRefundListRepository; import com.gcc.communityHall.service.BookingService; import com.gcc.communityHall.service.CounterService; import com.gcc.communityHall.service.UserService; @@ -32,47 +34,57 @@ import com.gcc.communityHall.service.UserService; import jakarta.servlet.http.HttpSession; @Controller -@RequestMapping("/counter") +@RequestMapping("/communityhall/counter") public class CounterController { - - @Autowired - private UserSession userSession; - - @Autowired - private CounterDetailsRepository counterRepo; - - @Autowired - private CounterService counterservice; - - @Autowired - private BookingService bookser; - - @Autowired - private UserService userService; - - @Autowired - private BookingDetailsRepository bookingDetailsRepository; - - @Autowired - private CounterRefundListRepository counterRefundRepository; - - @GetMapping(value = {"","/","/counterbooking"}) - public String viewcounter(Model model,HttpSession session) { + + @Autowired + private UserSession userSession; + + @Autowired + private CounterDetailsRepository counterRepo; + + @Autowired + private CounterService counterservice; + + @Autowired + private BookingService bookser; + + @Autowired + private UserService userService; + + @Autowired + private BookingDetailsRepository bookingDetailsRepository; + + @Autowired + private CounterRefundListRepository counterRefundRepository; + @Autowired + private LoginRepository loginRepository; + + @Autowired + private JwtUtil jwtUtil; + + @Autowired + private ApplicationLogsRepository applicationLogsRepository; + + @GetMapping(value = {"", "/", "/counterbooking"}) + public String viewcounter(Model model, HttpSession session) { System.out.println("viewcounter"); - String countername=(String) session.getAttribute("usertype"); - model.addAttribute("countername", countername); + String countername = (String) session.getAttribute("usertype"); + System.out.println("serverDate....."+ LocalDate.now().toString()); + model.addAttribute("serverDate", LocalDate.now().toString()); //for server date + model.addAttribute("countername", countername); return "counter/counter-booking"; } - + @GetMapping("/counterdetailslist") - public String viewcounterlist(Model model,HttpSession session) { - List counterlist= counterRepo.findAll(); - String countername=(String) session.getAttribute("usertype"); - model.addAttribute("countername", countername); - model.addAttribute("counterlist", counterlist); - return "counter/counter-list"; + public String viewcounterlist(Model model, HttpSession session) { + List counterlist = counterRepo.findAll(); + String countername = (String) session.getAttribute("usertype"); + model.addAttribute("countername", countername); + model.addAttribute("counterlist", counterlist); + return "counter/counter-list"; } - + @PostMapping("/saveDDdetails") public String saveDD( @RequestParam String bankName, @@ -83,7 +95,7 @@ public class CounterController { @RequestParam int bookingId) { // Call the service method and pass the bookingId along with other parameters String confirmBooking = bookser.confirmBooking(bookingId); - BookingDetails booking=new BookingDetails(); + BookingDetails booking = new BookingDetails(); booking.setBookingStatus(BookingStatus.APPROVED); if (confirmBooking.equals("Booking confirmed successfully")) { // Perform additional actions if needed @@ -92,35 +104,125 @@ public class CounterController { counterservice.saveCounterDetails(bankName, bankAccNo, ddNumber, amountReceived, counterddphoto, bookingId); return "redirect:/counter/counterdetailslist"; } - + @GetMapping("/bookinglist") - public String viewbookingpage(Model model,HttpSession session) - { - List> bookinglists= bookser.getOfflineBookings(); - - model.addAttribute("bookinglist",bookinglists); - String countername=(String) session.getAttribute("usertype"); - model.addAttribute("countername", countername); - - return "counter/viewhistory"; + public String viewbookingpage(Model model, HttpSession session) { + List> bookinglists = bookser.getOfflineBookings(); + + model.addAttribute("bookinglist", bookinglists); + String countername = (String) session.getAttribute("usertype"); + model.addAttribute("countername", countername); + + return "counter/viewhistory"; } + @GetMapping("/refundinitialisation") - public String viewrefund(Model model,HttpSession session) { + public String viewrefund(Model model, HttpSession session) { List counterRefundLists = counterRefundRepository.findAll(); model.addAttribute("counterRefundLists", counterRefundLists); - String countername=(String) session.getAttribute("usertype"); - model.addAttribute("countername", countername); + String countername = (String) session.getAttribute("usertype"); + model.addAttribute("countername", countername); return "counter/refund-initialisation"; } + @GetMapping("/calculateamount") - public String viewCalculate(Model model){ + public String viewCalculate(Model model) { return "counter/calculate-hall-amount"; } - + @GetMapping("/logout") - public String viewLogout(Model model,HttpSession session) { - session.invalidate(); - return "redirect:/communityhall/login"; + public String viewLogout(Model model, HttpSession session) { + session.invalidate(); + userSession.setUserId(null); + userSession.setMobileno(null); + userSession.setUserType(null); + userSession.setDispayName(null); + userSession.setCounter(null); + userSession.setCounterName(null); +// return "redirect:/communityhall/login"; + return "redirect:/communityhall/user/dashboard"; + } + + // newly added for counter login + @GetMapping("/verifyLogin") + public ResponseEntity verifyLogin( + @RequestParam("username") String username, + @RequestParam("password") String password, + Model model, HttpSession session) { + System.out.println("username: "+username+"\n"+"password: "+password); + + try { + Login login = loginRepository.findByUsernameAndPass(username, password); + System.out.println("counter controller\nCounter Id: "+userSession.getCounter()+"\nCounter Name: "+userSession.getCounterName()); + + if (login != null) { + // System.out.println("Login successful for mobile number: " + mobileNo); + + // Generate JWT token if login is successful + String token = jwtUtil.generateToken( + login.getUserType(), + login.getHallId(), + login.getMobileNumber(), + login.getEmployeeId(), + login.getZone() + ); + //System.out.println("Generated JWT Token: " + token); + + // Store JWT token and user information in session + session.setAttribute("jwtToken", token); + session.setAttribute("id", login.getId()); + session.setAttribute("hall_id", login.getHallId()); + session.setAttribute("mobileno", login.getMobileNumber()); + session.setAttribute("usertype", login.getUserType()); + session.setAttribute("employeeId", login.getEmployeeId()); + session.setAttribute("zone", login.getZone()); + session.setAttribute("counterName", login.getName()); + + model.addAttribute("counter", userSession.getCounter()); + model.addAttribute("counterName", userSession.getCounterName()); + + InetAddress inetAddress = InetAddress.getLocalHost(); + String hostname = InetAddress.getLocalHost().getHostName(); + System.out.println("Hostname: " + hostname); + + ApplicationLogs logs = new ApplicationLogs(); + logs.setComments("login as " + login.getName()); + logs.setLoginId(login.getId()); + logs.setIpaddress(inetAddress.getHostAddress()); + logs.setSystemName(hostname); + applicationLogsRepository.save(logs); + + userSession.setCounter(login.getEmployeeId()); + userSession.setCounterName(login.getName()); + + Map response = new HashMap<>(); + response.put("userType", login.getUserType()); + response.put("counterName", login.getName()); // Send Counter Name + response.put("token", token); + + // Write the token to a file + try (FileWriter fileWriter = new FileWriter("jwtToken.txt")) { + fileWriter.write(token); + } catch (IOException e) { + e.printStackTrace(); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to store token in file"); + } + + // Return successful response with user type + return ResponseEntity.ok(response); + } else { + // Handle case where login details are incorrect + return ResponseEntity.status(HttpStatus.EXPECTATION_FAILED).body("Invalid Username or Password"); + } + } catch (NumberFormatException e) { + // Handle case where mobile number format is incorrect + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Mobile number must be 10 digits"); + } catch (Exception e) { + // Handle any other unexpected exceptions + e.printStackTrace(); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new ErrorResponseDto()); + } + } } diff --git a/src/main/java/com/gcc/communityHall/controller/UserAPIController.java b/src/main/java/com/gcc/communityHall/controller/UserAPIController.java index 9cc89dbc..4ca9d5a6 100644 --- a/src/main/java/com/gcc/communityHall/controller/UserAPIController.java +++ b/src/main/java/com/gcc/communityHall/controller/UserAPIController.java @@ -238,8 +238,8 @@ public class UserAPIController { //System.out.println(purpose); //System.out.print("\n MobileNo---:"+mobileNo); Random rand = new Random(); -// int otp = rand.nextInt(90000) + 10000; - int otp = 11111; + int otp = rand.nextInt(90000) + 10000; +// int otp = 11111; System.out.print("\n otp---:"+otp); DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd-MMM-yyyy%20HH:mm"); LocalDateTime now = LocalDateTime.now(); @@ -250,7 +250,7 @@ public class UserAPIController { System.out.println(urlString); System.out.println("\n urlString---: "+urlString); String bodyMessage = ""+otp; - /*try { + try { RestTemplate restTemplate = new RestTemplate(); String Response = restTemplate.getForObject(urlString, String.class); bodyMessage=Response; @@ -267,7 +267,7 @@ public class UserAPIController { } catch (Exception e) { // System.out.print("ERROR in Sending---: "+e); bodyMessage = "Error"; - }*/ + } HttpSession session = request.getSession(); session.setAttribute("otp", otp); diff --git a/src/main/java/com/gcc/communityHall/controller/UserController.java b/src/main/java/com/gcc/communityHall/controller/UserController.java index 31d90dcc..66ceca8b 100644 --- a/src/main/java/com/gcc/communityHall/controller/UserController.java +++ b/src/main/java/com/gcc/communityHall/controller/UserController.java @@ -72,20 +72,22 @@ public class UserController { } } List newnotification = notificationRepository.findActivenotifications(); - // Create a string to concatenate all notifications descriptions StringBuilder notificationText = new StringBuilder(); for (Notification notification : newnotification) { notificationText.append(notification.getNotification_description()); } - +// System.out.println("user controller \nCounter Id: "+userSession.getCounter()+"\nCounter Name: "+userSession.getCounterName()); // Pass the concatenated string to the model model.addAttribute("newnotification", notificationText.toString()); model.addAttribute("userName", userSession.getDispayName()); model.addAttribute("halls", halls); model.addAttribute("hallnames", hallnames); model.addAttribute("serverDate", LocalDate.now().toString()); //for server date + model.addAttribute("counter", userSession.getCounter()); + model.addAttribute("counterName", userSession.getCounterName()); + return "user/dashboard"; } @@ -204,6 +206,8 @@ public class UserController { model.addAttribute("startingSlot", starting.equals("1") ? "Morning" : "Evening"); model.addAttribute("endingSlot", ending.equals("1") ? "Morning" : "Evening"); model.addAttribute("halls", (hallId != null && !hallId.isEmpty()) ? removeHallById : hallsByZone); + model.addAttribute("counter", userSession.getCounter()); + model.addAttribute("counterName", userSession.getCounterName()); return "user/dashboard"; } @@ -238,9 +242,11 @@ public class UserController { @GetMapping("/hallbookingform") public String viewform(Model model) { String username = userSession.getDispayName(); - System.out.println("serverDate....."+LocalDate.now().toString()); +// System.out.println("server Date22....."+LocalDate.now().toString()); model.addAttribute("serverDate", LocalDate.now().toString()); //for server date model.addAttribute("userName", username); + model.addAttribute("counter", userSession.getCounter()); + model.addAttribute("counterName", userSession.getCounterName()); return "user/hallbookingform"; } @@ -270,6 +276,8 @@ public class UserController { //List test = new ArrayList<>(); model.addAttribute("userName", userSession.getDispayName()); + model.addAttribute("counter", userSession.getCounter()); + model.addAttribute("counterName", userSession.getCounterName()); List> bookingPast = bookingService.getAllBookingEventsByUserId(userId); @@ -282,12 +290,16 @@ public class UserController { @GetMapping("/CommunityHallList") public String viewhalllist(Model model) { model.addAttribute("userName", userSession.getDispayName()); + model.addAttribute("counter", userSession.getCounter()); + model.addAttribute("counterName", userSession.getCounterName()); return "user/communityHallList"; } @GetMapping("/hallAmountCalculation") public String viewCalculate(Model model) { model.addAttribute("userName", userSession.getDispayName()); + model.addAttribute("counter", userSession.getCounter()); + model.addAttribute("counterName", userSession.getCounterName()); return "user/calculatehallamount"; } diff --git a/src/main/java/com/gcc/communityHall/entity/BookingCalendar.java b/src/main/java/com/gcc/communityHall/entity/BookingCalendar.java index 4663959f..8f6b79c6 100644 --- a/src/main/java/com/gcc/communityHall/entity/BookingCalendar.java +++ b/src/main/java/com/gcc/communityHall/entity/BookingCalendar.java @@ -24,7 +24,7 @@ public class BookingCalendar { private int hallId; - @Column(name = "unique_id", unique = true) + @Column(name = "unique_id", nullable = false, unique = true) private String uniqueId; public Integer getId() { diff --git a/src/main/java/com/gcc/communityHall/entity/BookingDetails.java b/src/main/java/com/gcc/communityHall/entity/BookingDetails.java index deb5be5e..e3794e3f 100644 --- a/src/main/java/com/gcc/communityHall/entity/BookingDetails.java +++ b/src/main/java/com/gcc/communityHall/entity/BookingDetails.java @@ -95,6 +95,8 @@ public class BookingDetails { @OneToOne(cascade = CascadeType.ALL,fetch = FetchType.LAZY,mappedBy = "bookingDetails") private RefundTransaction refundTransaction; + private String counterId; + public int getBookingId() { return bookingId; @@ -343,5 +345,13 @@ public class BookingDetails { public void setExtrapayments(ExtraPayments extrapayments) { this.extrapayments = extrapayments; } + + public String getCounterId() { + return counterId; + } + + public void setCounterId(String counterId) { + this.counterId = counterId; + } } \ No newline at end of file diff --git a/src/main/java/com/gcc/communityHall/others/UserSession.java b/src/main/java/com/gcc/communityHall/others/UserSession.java index 46e13742..7b6b0192 100644 --- a/src/main/java/com/gcc/communityHall/others/UserSession.java +++ b/src/main/java/com/gcc/communityHall/others/UserSession.java @@ -13,6 +13,10 @@ public class UserSession { private String dispayName; private Long mobileno; + // added for counter login + private String counter; + private String counterName; + public Integer getUserId() { return userId; } @@ -45,6 +49,20 @@ public class UserSession { this.mobileno = mobileno; } + public String getCounter() { + return counter; + } + + public void setCounter(String counter) { + this.counter = counter; + } + public String getCounterName() { + return counterName; + } + + public void setCounterName(String counterName) { + this.counterName = counterName; + } } diff --git a/src/main/java/com/gcc/communityHall/paymentService/controller/PaymentController.java b/src/main/java/com/gcc/communityHall/paymentService/controller/PaymentController.java index 8d37059e..c4676f18 100644 --- a/src/main/java/com/gcc/communityHall/paymentService/controller/PaymentController.java +++ b/src/main/java/com/gcc/communityHall/paymentService/controller/PaymentController.java @@ -15,7 +15,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.gcc.communityHall.entity.*; import com.gcc.communityHall.others.AppConfig; -import com.gcc.communityHall.repository.ErpPostDataRepository; +//import com.gcc.communityHall.repository.ErpPostDataRepository; import com.gcc.communityHall.service.PaymentsService; import org.apache.tomcat.util.json.JSONParser; import org.springframework.beans.factory.annotation.Autowired; @@ -70,8 +70,8 @@ public class PaymentController { @Autowired private AppConfig appConfig; - @Autowired - private ErpPostDataRepository erpPostDataRepository; +// @Autowired +// private ErpPostDataRepository erpPostDataRepository; @Autowired private PaymentsService paymentsService; @@ -147,7 +147,6 @@ public class PaymentController { model.addAttribute("bookingsDetails", bookingsDetails); -// bookser.updateBookingStatusById(bookingsDetails.getBookingId(), BookingStatus.PENDING, "Amount mismatch - Booking Not Confirmed"); return "redirect:/communityhall/user/acknowledgement?bookingId=" + bookingsDetails.getBookingId(); } @@ -185,7 +184,7 @@ public class PaymentController { return "redirect:/communityhall/user/acknowledgement?bookingId=" + bookingsDetails.getBookingId(); } - public void postDataToERP(Payments payment, TransactionResponse res) { + /*public void postDataToERP(Payments payment, TransactionResponse res) { RestTemplate restTemplate = new RestTemplate(); erpPostData erpData = new erpPostData(); @@ -194,7 +193,7 @@ public class PaymentController { String assesNo = LocalDate.now().getYear() + "/COMM/" + res.getBookingId(); Map data = new TreeMap<>(); - /*static mandatory input to be sent */ + *//*static mandatory input to be sent *//* data.put("serviceId", "getOtherCollection"); data.put("COLLECTION_TYPE", "Community Hall"); data.put("TOTALTRANSACTIONCODE", "450310000"); @@ -219,7 +218,7 @@ public class PaymentController { payment.getBookingDetails().getUsers().getArea() + "," + payment.getBookingDetails().getUsers().getLocation() + "," + payment.getBookingDetails().getUsers().getPinCode()); data.put("PARTYMOBILE", payment.getBookingDetails().getUsers().getMobileNo()); - /* end */ + *//* end *//* System.out.println(data); System.out.println(appConfig.getCommErpUrl()); // ResponseEntity stringResponseEntity = restTemplate.postForEntity(appConfig.getErpUrl(), data, String.class); @@ -278,7 +277,7 @@ public class PaymentController { } catch (Exception e) { e.printStackTrace(); } - } + }*/ @PostMapping(value = "/additionaldamage-response") public String additionaldamagePaymentresponse(Model model, @RequestParam(required = false) String msg) throws NoSuchAlgorithmException { @@ -351,7 +350,7 @@ public class PaymentController { return "redirect:/communityhall/user/collectionpendingacknowledgement?bookingId=" + bookingsDetails.getBookingId(); } - public void postEPDataToERP(ExtraPayments payment, TransactionResponse res) { + /*public void postEPDataToERP(ExtraPayments payment, TransactionResponse res) { RestTemplate restTemplate = new RestTemplate(); erpPostData erpData = new erpPostData(); @@ -360,7 +359,7 @@ public class PaymentController { String assesNo = LocalDate.now().getYear() + "/COMM/ED/" + res.getBookingId(); Map data = new TreeMap<>(); - /*static mandatory input to be sent */ + *//*static mandatory input to be sent *//* data.put("serviceId", "getOtherCollection"); data.put("COLLECTION_TYPE", "Community Hall"); data.put("TOTALTRANSACTIONCODE", "450310000"); @@ -385,7 +384,7 @@ public class PaymentController { payment.getBookingDetails().getUsers().getArea() + "," + payment.getBookingDetails().getUsers().getLocation() + "," + payment.getBookingDetails().getUsers().getPinCode()); data.put("PARTYMOBILE", payment.getBookingDetails().getUsers().getMobileNo()); - /* end */ + *//* end *//* System.out.println(data); System.out.println(appConfig.getCommErpUrl()); // ResponseEntity stringResponseEntity = restTemplate.postForEntity(appConfig.getErpUrl(), data, String.class); @@ -444,7 +443,7 @@ public class PaymentController { } 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 { diff --git a/src/main/java/com/gcc/communityHall/paymentService/repository/TransactionResponseRepository.java b/src/main/java/com/gcc/communityHall/paymentService/repository/TransactionResponseRepository.java index bb71977f..34c840a4 100644 --- a/src/main/java/com/gcc/communityHall/paymentService/repository/TransactionResponseRepository.java +++ b/src/main/java/com/gcc/communityHall/paymentService/repository/TransactionResponseRepository.java @@ -59,7 +59,7 @@ public interface TransactionResponseRepository extends JpaRepository> getTransactionResponseByStatus(String status); diff --git a/src/main/java/com/gcc/communityHall/paymentService/scheduler/PaymentStatusScheduler.java b/src/main/java/com/gcc/communityHall/paymentService/scheduler/PaymentStatusScheduler.java index 17367810..27d6b8f2 100644 --- a/src/main/java/com/gcc/communityHall/paymentService/scheduler/PaymentStatusScheduler.java +++ b/src/main/java/com/gcc/communityHall/paymentService/scheduler/PaymentStatusScheduler.java @@ -1,6 +1,8 @@ -package com.gcc.communityHall.paymentService.scheduler;/* +/* +package com.gcc.communityHall.paymentService.scheduler; + // Import necessary packages -package com.gcc.communityHall.paymentService.Scheduler; +//package com.gcc.communityHall.paymentService.Scheduler; import com.fasterxml.jackson.databind.ObjectMapper; import com.gcc.communityHall.entity.BookingDetails; @@ -332,4 +334,5 @@ public class PaymentStatusScheduler { } + */ diff --git a/src/main/java/com/gcc/communityHall/repository/BookingDetailsRepository.java b/src/main/java/com/gcc/communityHall/repository/BookingDetailsRepository.java index 220feaa8..321b1baa 100644 --- a/src/main/java/com/gcc/communityHall/repository/BookingDetailsRepository.java +++ b/src/main/java/com/gcc/communityHall/repository/BookingDetailsRepository.java @@ -336,7 +336,7 @@ public interface BookingDetailsRepository extends JpaRepository> getAllBookingEventsByUserId(Integer userId); diff --git a/src/main/java/com/gcc/communityHall/repository/LoginRepository.java b/src/main/java/com/gcc/communityHall/repository/LoginRepository.java index d0a3d4fc..425b30b5 100644 --- a/src/main/java/com/gcc/communityHall/repository/LoginRepository.java +++ b/src/main/java/com/gcc/communityHall/repository/LoginRepository.java @@ -15,4 +15,7 @@ public interface LoginRepository extends JpaRepository { @Query(value = "SELECT a FROM Login a WHERE a.mobileNumber = ?1") Login checkUserbyMobile(long mobileNo); + + @Query(value = "SELECT * FROM login where name=:username and password=:pass LIMIT 1",nativeQuery = true) + Login findByUsernameAndPass(String username, String pass); } diff --git a/src/main/java/com/gcc/communityHall/service/Impl/BookingServiceImpl.java b/src/main/java/com/gcc/communityHall/service/Impl/BookingServiceImpl.java index 3d11f2e2..bc541346 100644 --- a/src/main/java/com/gcc/communityHall/service/Impl/BookingServiceImpl.java +++ b/src/main/java/com/gcc/communityHall/service/Impl/BookingServiceImpl.java @@ -569,6 +569,7 @@ public class BookingServiceImpl implements BookingService { BookingDetails bookingDetails = null; Integer userId = userSession.getUserId(); + String counterId = userSession.getCounter(); ReasonMaster reasonMaster = reasonMasterService.getReasonById(Integer.parseInt(formData.get("reasonId").toString())); HallDetails hallDetails = hallDetailService.getHallById(Integer.parseInt(formData.get("hallId").toString())); @@ -589,7 +590,9 @@ public class BookingServiceImpl implements BookingService { if (user != null) { bookingDetails.setUsers(user); - + if(counterId!=null){ + bookingDetails.setCounterId(counterId); + } if (hallDetails != null) { bookingDetails.setHallDetails(hallDetails); @@ -1643,11 +1646,13 @@ public class BookingServiceImpl implements BookingService { } else { + String uniqueId = date.format(DateTimeFormatter.ofPattern("yyyyMMdd")) + hallId; bookingCalendar = new BookingCalendar(); bookingCalendar.setBdate(date); bookingCalendar.setHallId(hallId); bookingCalendar.setIs_booked(0); bookingCalendar.setIs_active(true); + bookingCalendar.setUnique_id(uniqueId); } // Mark the appropriate slot as booked based on starting and ending slots diff --git a/src/main/java/com/gcc/communityHall/service/Impl/CounterServiceImpl.java b/src/main/java/com/gcc/communityHall/service/Impl/CounterServiceImpl.java index 68b7a578..61429118 100644 --- a/src/main/java/com/gcc/communityHall/service/Impl/CounterServiceImpl.java +++ b/src/main/java/com/gcc/communityHall/service/Impl/CounterServiceImpl.java @@ -43,9 +43,8 @@ import com.gcc.communityHall.service.ReasonMasterService; import com.gcc.communityHall.service.UserService; @Service -public class CounterServiceImpl implements CounterService -{ - @Autowired +public class CounterServiceImpl implements CounterService { + @Autowired private BookingDetailsRepository bookingDetailsRepository; @Autowired @@ -56,15 +55,13 @@ public class CounterServiceImpl implements CounterService @Autowired private HallDetailService hallDetailService; - + @Autowired private CounterRefundListRepository counterRefundListRepository; - + @Autowired private DiscountRangeService discountRangeService; - - - + @Autowired private UserService userService; @@ -75,28 +72,29 @@ public class CounterServiceImpl implements CounterService @Value("${file.fullpath}") private String serverPath; - - @Autowired - private CounterDetailsRepository counterRepo; - - private final String ddDirectory; - private final String ddPhotoUrl; - private final String refundDirectory; - private final String refundPhotoUrl; - @Autowired - CounterServiceImpl(CounterDetailsRepository counterRepo, - @Value("${file.dd.upload.directory}") String ddDirectory, - @Value("${file.dd.fullpath}") String ddPhotoUrl, - @Value("${file.counterrefund.upload.directory}") String refundDirectory, - @Value("${file.counterrefund.fullpath}") String refundPhotoUrl){ - this.counterRepo=counterRepo; - this.ddDirectory=ddDirectory; - this.ddPhotoUrl=ddPhotoUrl; - this.refundDirectory=refundDirectory; - this.refundPhotoUrl=refundPhotoUrl; - } - - @Override + + @Autowired + private CounterDetailsRepository counterRepo; + + private final String ddDirectory; + private final String ddPhotoUrl; + private final String refundDirectory; + private final String refundPhotoUrl; + + @Autowired + CounterServiceImpl(CounterDetailsRepository counterRepo, + @Value("${file.dd.upload.directory}") String ddDirectory, + @Value("${file.dd.fullpath}") String ddPhotoUrl, + @Value("${file.counterrefund.upload.directory}") String refundDirectory, + @Value("${file.counterrefund.fullpath}") String refundPhotoUrl) { + this.counterRepo = counterRepo; + this.ddDirectory = ddDirectory; + this.ddPhotoUrl = ddPhotoUrl; + this.refundDirectory = refundDirectory; + this.refundPhotoUrl = refundPhotoUrl; + } + + @Override public CounterDetails saveCounterDetails(String bankName, int bankAccNo, int ddNumber, double amountReceived, MultipartFile counterddphoto, int bookingId) { BookingDetails bookingDetails = bookingDetailsRepository.findById(bookingId) .orElseThrow(() -> new RuntimeException("Booking not found")); @@ -125,27 +123,26 @@ public class CounterServiceImpl implements CounterService return counterRepo.save(counterDetails); } - @Override - public CounterDetails getDdImageById(int counterId) { - Optional counterdetails = counterRepo.findById(counterId); - - return counterdetails.orElse(null); - } + @Override + public CounterDetails getDdImageById(int counterId) { + Optional counterdetails = counterRepo.findById(counterId); + return counterdetails.orElse(null); + } - @Override + @Override public Map saveCounterBooking(Map formData) { Map response = new HashMap<>(); BookingDetails bookingDetails = new BookingDetails(); ReasonMaster reasonMaster = reasonMasterService.getReasonById(Integer.parseInt(formData.get("reasonId").toString())); HallDetails hallDetails = hallDetailService.getHallById(Integer.parseInt(formData.get("hallId").toString())); - Users user=userService.getUserById(userSession.getUserId()); - String bookingId =formData.get("bookingId").toString(); - if(bookingId!=null && bookingId.equals("0")){ - bookingDetails= new BookingDetails(); - }else { + Users user = userService.getUserById(userSession.getUserId()); + String bookingId = formData.get("bookingId").toString(); + if (bookingId != null && bookingId.equals("0")) { + bookingDetails = new BookingDetails(); + } else { BookingDetails book = getBookingsById(Integer.parseInt(formData.get("bookingId").toString())); if (book != null) { bookingDetails = book; @@ -159,23 +156,25 @@ public class CounterServiceImpl implements CounterService if (hallDetails != null) { bookingDetails.setHallDetails(hallDetails); - bookingDetails.setDepositAmount(hallDetails.getDepositAmount()); +// bookingDetails.setDepositAmount(hallDetails.getDepositAmount()); String startDate = formData.get("startDate").toString(); String endDate = formData.get("endDate").toString(); - int days = Integer.parseInt(formData.get("days").toString()); + String relation = formData.get("relation").toString(); + double days = Double.parseDouble(formData.get("days").toString()); + int daysrange = Integer.parseInt(formData.get("daysrange").toString()); Optional discountOpt = discountRangeService.getDiscountByUserType(user.getUsertype()); - DiscountRange discountrange=discountOpt.get(); + DiscountRange discountrange = discountOpt.get(); float discount = discountrange.getDiscountRange(); int startingSlot = Integer.parseInt(formData.get("startingSlot").toString()); int endingSlot = Integer.parseInt(formData.get("endingSlot").toString()); - double hallAmount =calcHallAmount(hallDetails,days,startingSlot,endingSlot); + double hallAmount = calcHallAmount(hallDetails, daysrange, startingSlot, endingSlot); double discountAmount = 0; - String usertype=user.getUsertype().toString(); - if(usertype.equals("COUNCILLOR") || usertype.equals("PENSIONER") || usertype.equals("GCC_EMPLOYEE") || usertype.equals("PUBLIC")) { - discountAmount = (hallAmount*discount)/100; + String usertype = user.getUsertype().toString(); + if (usertype.equals("COUNCILLOR") || usertype.equals("PENSIONER") || usertype.equals("GCC_EMPLOYEE") || usertype.equals("PUBLIC")) { + discountAmount = (hallAmount * discount) / 100; } - hallAmount = hallAmount-discountAmount; - double gstAmount = (hallAmount*hallDetails.getGst())/100; + hallAmount = hallAmount - discountAmount; + double gstAmount = (hallAmount * hallDetails.getGst()) / 100; //double discountAmount=hallAmount*(1-(discount/100)); double totalAmount = hallAmount + gstAmount + bookingDetails.getDepositAmount(); @@ -187,7 +186,7 @@ public class CounterServiceImpl implements CounterService // Print the result // System.out.println("Total Amount: " + formattedTotalAmount); - + bookingDetails.setHallAmount(hallAmount); bookingDetails.setGst(gstAmount); @@ -201,7 +200,7 @@ public class CounterServiceImpl implements CounterService bookingDetails.setReason(reasonMaster.getReason()); bookingDetails.setRefundStatus(BookingDetails.RefundStatus.WAITING); bookingDetails.setBookingtype(BookingDetails.BookingType.OFFLINE); - + bookingDetails = bookingDetailsRepository.save(bookingDetails); @@ -210,12 +209,12 @@ public class CounterServiceImpl implements CounterService response.put("noOfDays", bookingDetails.getNoOfDays()); response.put("startDate", bookingDetails.getStartDate()); response.put("endDate", bookingDetails.getEndDate()); - response.put("startingSlot",bookingDetails.getStartingSlot()); - response.put("endingSlot",bookingDetails.getEndingSlot()); + response.put("startingSlot", bookingDetails.getStartingSlot()); + response.put("endingSlot", bookingDetails.getEndingSlot()); response.put("hallAmount", bookingDetails.getHallAmount()); response.put("gst", bookingDetails.getGst()); response.put("depositAmount", bookingDetails.getDepositAmount()); - response.put("discount",discountrange.getDiscountRange()); + response.put("discount", discountrange.getDiscountRange()); //response.put("totalAmount",formattedTotalAmount); response.put("username", bookingDetails.getUsers().getName()); response.put("userId", bookingDetails.getUsers().getUserId()); @@ -257,67 +256,68 @@ public class CounterServiceImpl implements CounterService return response; } - private double calcHallAmount(HallDetails hallDetails,int days,int startingSlot,int endingSlot){ + private double calcHallAmount(HallDetails hallDetails, int days, int startingSlot, int endingSlot) { double hallAmount = 0; - if(days==1 && startingSlot==1 && endingSlot==2){ //full day - hallAmount =hallDetails.getFullDayRent(); - - } else if (days==1 && (startingSlot==1 && endingSlot==1)|| (startingSlot==2 && endingSlot==2) ) { // half day - hallAmount =hallDetails.getHalfDayRent(); - } else if (days>1) { - if(startingSlot==2 && endingSlot==1){ - hallAmount =hallDetails.getHalfDayRent()*2; - days=days-2; - } else if (startingSlot==2 || endingSlot==1) { - hallAmount =hallDetails.getHalfDayRent(); - days=days-1; + if (days == 1 && startingSlot == 1 && endingSlot == 2) { //full day + hallAmount = hallDetails.getFullDayRent(); + + } else if (days == 1 && (startingSlot == 1 && endingSlot == 1) || (startingSlot == 2 && endingSlot == 2)) { // half day + hallAmount = hallDetails.getHalfDayRent(); + } else if (days > 1) { + if (startingSlot == 2 && endingSlot == 1) { + hallAmount = hallDetails.getHalfDayRent() * 2; + days = days - 2; + } else if (startingSlot == 2 || endingSlot == 1) { + hallAmount = hallDetails.getHalfDayRent(); + days = days - 1; } - for(int i=0;i OPBookingDetails =bookingDetailsRepository.findById(BookingId); - if(OPBookingDetails.isPresent()) { - return OPBookingDetails.get(); - } - return null; + + @Override + public BookingDetails getBookingsById(int BookingId) { + Optional OPBookingDetails = bookingDetailsRepository.findById(BookingId); + if (OPBookingDetails.isPresent()) { + return OPBookingDetails.get(); } + return null; + } - public CounterRefundList saveCancellation(int counterId, MultipartFile letterdocs, String reason) throws IOException { + public CounterRefundList saveCancellation(int counterId, MultipartFile letterdocs, String reason) throws IOException { - CounterRefundList counterRefundList = new CounterRefundList(); - counterRefundList.setInitialisationStatus(CounterRefundList.InitialisationStatus.INITIATED); - counterRefundList.setReasonforCancelling(reason); + CounterRefundList counterRefundList = new CounterRefundList(); + counterRefundList.setInitialisationStatus(CounterRefundList.InitialisationStatus.INITIATED); + counterRefundList.setReasonforCancelling(reason); - if (letterdocs != null && !letterdocs.isEmpty()) { + if (letterdocs != null && !letterdocs.isEmpty()) { - try { - String fileName = counterId + "_" + letterdocs.getOriginalFilename(); - String filePath = refundDirectory + "/" + fileName; - String imageUrl = refundPhotoUrl + "/" + fileName; + try { + String fileName = counterId + "_" + letterdocs.getOriginalFilename(); + String filePath = refundDirectory + "/" + fileName; + String imageUrl = refundPhotoUrl + "/" + fileName; - try (FileOutputStream fos = new FileOutputStream(filePath)) { - fos.write(letterdocs.getBytes()); - counterRefundList.setLetterdocument(imageUrl); - } - counterRefundList.setLetterdocument(refundPhotoUrl + "cr/" + fileName); - } catch (Exception e) { - throw new RuntimeException("Failed to store file", e); - } + try (FileOutputStream fos = new FileOutputStream(filePath)) { + fos.write(letterdocs.getBytes()); + counterRefundList.setLetterdocument(imageUrl); } + counterRefundList.setLetterdocument(refundPhotoUrl + "cr/" + fileName); + } catch (Exception e) { + throw new RuntimeException("Failed to store file", e); + } + } - CounterDetails counterDetails = new CounterDetails(); - counterDetails.setCounterId(counterId); - counterRefundList.setCounterDetails(counterDetails); + CounterDetails counterDetails = new CounterDetails(); + counterDetails.setCounterId(counterId); + counterRefundList.setCounterDetails(counterDetails); - return counterRefundListRepository.save(counterRefundList); + return counterRefundListRepository.save(counterRefundList); - } + } } diff --git a/src/main/resources/templates/admin/adminpage.html b/src/main/resources/templates/admin/adminpage.html index 3a4aeb29..a6f97a5f 100644 --- a/src/main/resources/templates/admin/adminpage.html +++ b/src/main/resources/templates/admin/adminpage.html @@ -471,7 +471,7 @@ displayError(fileInput, errorMessage); } else { - console.log('File size is within limit:', file.size, 'bytes'); + // console.log('File size is within limit:', file.size, 'bytes'); clearError(fileInput); } } diff --git a/src/main/resources/templates/admin/booking-list.html b/src/main/resources/templates/admin/booking-list.html index 6c2c742b..b3833cab 100644 --- a/src/main/resources/templates/admin/booking-list.html +++ b/src/main/resources/templates/admin/booking-list.html @@ -454,7 +454,7 @@ 'reasonName': list.reason }, success: function (x) { - console.log(x); + // console.log(x); showReasonWithDocument(x, list); } }); diff --git a/src/main/resources/templates/admin/caretakerpage.html b/src/main/resources/templates/admin/caretakerpage.html index 5b0ced38..40b01cab 100644 --- a/src/main/resources/templates/admin/caretakerpage.html +++ b/src/main/resources/templates/admin/caretakerpage.html @@ -467,7 +467,7 @@ displayError(fileInput, errorMessage); } else { - console.log('File size is within limit:', file.size, 'bytes'); + // console.log('File size is within limit:', file.size, 'bytes'); clearError(fileInput); } } diff --git a/src/main/resources/templates/admin/developer.html b/src/main/resources/templates/admin/developer.html index 660a599e..dfcfb9fa 100644 --- a/src/main/resources/templates/admin/developer.html +++ b/src/main/resources/templates/admin/developer.html @@ -379,7 +379,7 @@ function myRequest() { fetch('/communityhall/user/api/gethallnames') .then(response => response.json()) .then(data => { - console.log('Hall Names Data:', data); // Debug log + // console.log('Hall Names Data:', data); // Debug log const hallNameDropdown = document.getElementById('hallNameDropdown'); const selectedHall = hallNameDropdown.value; // Retain current selection diff --git a/src/main/resources/templates/admin/gccblocking.html b/src/main/resources/templates/admin/gccblocking.html index f604194b..8aa3c10f 100644 --- a/src/main/resources/templates/admin/gccblocking.html +++ b/src/main/resources/templates/admin/gccblocking.html @@ -842,7 +842,7 @@ .filter(value => !isNaN(value)) .join(','); - console.log("hallIds: "+hallIds); + // console.log("hallIds: "+hallIds); // Create FormData for AJAX var formData = new FormData(); @@ -1051,7 +1051,7 @@ endDate: endDate }, success: function (response) { - console.log("Unblock response:", response); + // console.log("Unblock response:", response); $("#viewdetails").modal('hide'); window.location.reload(); }, diff --git a/src/main/resources/templates/admin/halldetailslist.html b/src/main/resources/templates/admin/halldetailslist.html index 2a660cfd..4559a201 100644 --- a/src/main/resources/templates/admin/halldetailslist.html +++ b/src/main/resources/templates/admin/halldetailslist.html @@ -721,7 +721,7 @@ fileInput.value = ''; // Clear the file input displayError(fileInput, errorMessage); } else { - console.log('File size is within limit:', file.size, 'bytes'); + // console.log('File size is within limit:', file.size, 'bytes'); } } } diff --git a/src/main/resources/templates/admin/ongoingevents.html b/src/main/resources/templates/admin/ongoingevents.html index 741b8334..019fea9e 100644 --- a/src/main/resources/templates/admin/ongoingevents.html +++ b/src/main/resources/templates/admin/ongoingevents.html @@ -986,9 +986,9 @@ $(document).ready(function () { $("#submitEbDetails").click(function () { var bookid = parseInt($("#bookingId").val()); - console.log("bookid = "+ bookid) + // console.log("bookid = "+ bookid) var startingReading = $("#startingReading").val(); - console.log("startingReading = "+ startingReading) + // console.log("startingReading = "+ startingReading) var startingReadingimage = $("#startingReadingimage")[0].files[0]; // Get the file var formData = new FormData(); diff --git a/src/main/resources/templates/admin/refund-failedlist.html b/src/main/resources/templates/admin/refund-failedlist.html index 6b93cbda..15ec0c31 100644 --- a/src/main/resources/templates/admin/refund-failedlist.html +++ b/src/main/resources/templates/admin/refund-failedlist.html @@ -916,8 +916,8 @@ $(document).ready(function () { } function showSettlementInfo(list) { - console.log(list); // Log the damageList array - console.log(list.damageList[0]); + // console.log(list); // Log the damageList array + // console.log(list.damageList[0]); $('#pendingSettlementForm').modal({ backdrop: 'static', @@ -1098,7 +1098,7 @@ $(document).ready(function () { var refundStatus = data.refundStatus; if (settleAmount < 0) { - console.log(settleAmount); + // console.log(settleAmount); $("#td_settel_amt").html(0.00); $("#pendingcolumn").show(); $("#td_pending_amt").html('₹ ' + Math.abs(settleAmount).toFixed(2)); @@ -1379,7 +1379,7 @@ $(document).ready(function () { }).then((result) => { /* Read more about isConfirmed, isDenied below */ if (result.isConfirmed) { - console.log("Submitting rejection..."); + // console.log("Submitting rejection..."); $.ajax({ type: "POST", @@ -1390,7 +1390,7 @@ $(document).ready(function () { 'settlementId': id }, success: function (data, textStatus, xhr) { - console.log("Rejection successful"); + // console.log("Rejection successful"); if (xhr.status === 200) { // Check if the response status is OK Swal.fire( 'Done', @@ -1466,7 +1466,7 @@ $(document).ready(function () { 'bookingsId': bookingId }, success: function (x) { - console.log(x); + // console.log(x); showcancelledbookingDetails(x); } }); @@ -1481,7 +1481,7 @@ $(document).ready(function () { 'bookingsId': bookingId }, success: function (x) { - console.log(x); + // console.log(x); showcancelledbookingDetails(x); } }); @@ -1528,7 +1528,7 @@ $(document).ready(function () { document.getElementById("bookid").innerHTML = list.bookingId; function getTimeSlot(slotValue) { - console.log("Slot Value in getTimeSlot function:", slotValue); + // console.log("Slot Value in getTimeSlot function:", slotValue); var timeSlot; var trimmedSlotValue = String(slotValue).trim(); // Convert to string and then trim if (trimmedSlotValue === '1') { @@ -1538,7 +1538,7 @@ $(document).ready(function () { } else { timeSlot = 'Unknown'; } - console.log("Time Slot:", timeSlot); + // console.log("Time Slot:", timeSlot); return timeSlot; } @@ -1560,7 +1560,7 @@ $(document).ready(function () { 'reasonName': list.reason }, success: function (x) { - console.log(x); + // console.log(x); showReasonWithDocument(x, list); } }); diff --git a/src/main/resources/templates/admin/rejected-list.html b/src/main/resources/templates/admin/rejected-list.html index d57a6a81..8582e2f6 100644 --- a/src/main/resources/templates/admin/rejected-list.html +++ b/src/main/resources/templates/admin/rejected-list.html @@ -422,7 +422,7 @@ 'reasonName': list.reason }, success: function (x) { - console.log(x); + // console.log(x); showReasonWithDocument(x, list); } }); diff --git a/src/main/resources/templates/admin/reports.html b/src/main/resources/templates/admin/reports.html index 2032d95d..91f804b8 100644 --- a/src/main/resources/templates/admin/reports.html +++ b/src/main/resources/templates/admin/reports.html @@ -1594,7 +1594,7 @@ 'reasonName': list.reason }, success: function (x) { - console.log(x); + // console.log(x); showReasonWithDocument(x, list); } }); @@ -1680,7 +1680,7 @@ url: '/communityhall/admin/api/bookingdetailsByuserId', data: {'userId': userId}, success: function (response) { - console.log(response); + // console.log(response); $("#bookingTableBody").empty(); // Ensure bookingTableBody is the correct ID of the table body $.each(response, function (index, booking) { // Create table row with the data from response @@ -1717,7 +1717,7 @@ url: '/communityhall/admin/api/bookingdetailsByzone', data: {'zone': zone}, success: function (response) { - console.log(response); + // console.log(response); // Clear existing table data and destroy DataTable instance if it exists var table = $('#bookinglistdataTablebyzone').DataTable(); diff --git a/src/main/resources/templates/admin/settlement-approved.html b/src/main/resources/templates/admin/settlement-approved.html index ccb1dfc9..592d5dd8 100644 --- a/src/main/resources/templates/admin/settlement-approved.html +++ b/src/main/resources/templates/admin/settlement-approved.html @@ -858,7 +858,7 @@ 'settlementsid': settlementId }, success: function (x) { - console.log(x); + // console.log(x); showSettlementInfo(x) showDamageDetails(x); } @@ -867,8 +867,8 @@ } function showSettlementInfo(list) { - console.log(list); // Log the damageList array - console.log(list.damageList[0]); + // console.log(list); // Log the damageList array + // console.log(list.damageList[0]); $('#initiateSettlementForm').modal({ backdrop: 'static', @@ -1049,7 +1049,7 @@ if (data.damageList.length === 0) { var refundStatus = data.refundStatus; if (settleAmount < 0) { - console.log(settleAmount); + // console.log(settleAmount); $("#td_settel_amt").html(0.00); $("#pendingcolumn").show(); $("#td_pending_amt").html('₹ ' + Math.abs(settleAmount).toFixed(2)); @@ -1170,7 +1170,7 @@ if (data.damageList.length === 0) { function initiate() { let id = document.getElementById("settlementid").value; let refundAmount = document.getElementById("refundAmount").value; - console.log(refundAmount); + // console.log(refundAmount); Swal.fire({ title: 'Do you want to Initiate this Settlement?', @@ -1181,7 +1181,7 @@ if (data.damageList.length === 0) { }).then((result) => { if (result.isConfirmed) { let status = (refundAmount > 0) ? 'INITIATED' : 'COMPLETED'; - console.log(status); + // console.log(status); $.ajax({ type: "POST", url: '/communityhall/admin/api/updateInitiatedSettlementStatus/' + id, @@ -1238,7 +1238,7 @@ if (data.damageList.length === 0) { 'bookingsId': bookingId }, success: function (x) { - console.log(x); + // console.log(x); showApprovedcancelledbookingDetails(x); } }); @@ -1286,7 +1286,7 @@ if (data.damageList.length === 0) { document.getElementById("bookid").innerHTML = list.bookingId; function getTimeSlot(slotValue) { - console.log("Slot Value in getTimeSlot function:", slotValue); + // console.log("Slot Value in getTimeSlot function:", slotValue); var timeSlot; var trimmedSlotValue = String(slotValue).trim(); // Convert to string and then trim if (trimmedSlotValue === '1') { @@ -1296,7 +1296,7 @@ if (data.damageList.length === 0) { } else { timeSlot = 'Unknown'; } - console.log("Time Slot:", timeSlot); + // console.log("Time Slot:", timeSlot); return timeSlot; } @@ -1318,7 +1318,7 @@ if (data.damageList.length === 0) { 'reasonName': list.reason }, success: function (x) { - console.log(x); + // console.log(x); showReasonWithDocument(x, list); } }); diff --git a/src/main/resources/templates/admin/settlement-completed.html b/src/main/resources/templates/admin/settlement-completed.html index 48d93952..5393b63c 100644 --- a/src/main/resources/templates/admin/settlement-completed.html +++ b/src/main/resources/templates/admin/settlement-completed.html @@ -1155,7 +1155,7 @@ if (data.damageList.length === 0) { } else { timeSlot = 'Unknown'; } - console.log("Time Slot:", timeSlot); + // console.log("Time Slot:", timeSlot); return timeSlot; } document.getElementById("startingSlot").innerHTML = getTimeSlot(list.startingSlot); diff --git a/src/main/resources/templates/admin/settlement-initiate.html b/src/main/resources/templates/admin/settlement-initiate.html index 8d592512..d18b8f5d 100644 --- a/src/main/resources/templates/admin/settlement-initiate.html +++ b/src/main/resources/templates/admin/settlement-initiate.html @@ -1270,7 +1270,7 @@ document.getElementById("bookid").innerHTML = list.bookingId; function getTimeSlot(slotValue) { - console.log("Slot Value in getTimeSlot function:", slotValue); + // console.log("Slot Value in getTimeSlot function:", slotValue); var timeSlot; var trimmedSlotValue = String(slotValue).trim(); // Convert to string and then trim if (trimmedSlotValue === '1') { diff --git a/src/main/resources/templates/admin/settlement-list.html b/src/main/resources/templates/admin/settlement-list.html index d0a98170..44eef482 100644 --- a/src/main/resources/templates/admin/settlement-list.html +++ b/src/main/resources/templates/admin/settlement-list.html @@ -835,8 +835,8 @@ } function showSettlementInfo(list) { - console.log(list); // Log the damageList array - console.log(list.damageList[0]); + // console.log(list); // Log the damageList array + // console.log(list.damageList[0]); $('#pendingSettlementForm').modal({ backdrop: 'static', @@ -1017,7 +1017,7 @@ var refundStatus = data.refundStatus; var pendingstatus=data.settlement.collectionStatus if (settleAmount < 0) { - console.log(settleAmount); + // console.log(settleAmount); $("#td_settel_amt").html(0.00); $("#pendingcolumn").show(); $("#collectionstatuscolumn").show(); @@ -1123,7 +1123,7 @@ }).then((result) => { /* Read more about isConfirmed, isDenied below */ if (result.isConfirmed) { - console.log("Submitting rejection..."); + // console.log("Submitting rejection..."); $.ajax({ type: "POST", @@ -1134,7 +1134,7 @@ 'settlementId': id }, success: function (data, textStatus, xhr) { - console.log("Rejection successful"); + // console.log("Rejection successful"); if (xhr.status === 200) { // Check if the response status is OK Swal.fire( 'Done', @@ -1210,7 +1210,7 @@ 'bookingsId': bookingId }, success: function (x) { - console.log(x); + // console.log(x); showcancelledbookingDetails(x); } }); @@ -1225,7 +1225,7 @@ 'bookingsId': bookingId }, success: function (x) { - console.log(x); + // console.log(x); showcancelledbookingDetails(x); } }); @@ -1272,7 +1272,7 @@ document.getElementById("bookid").innerHTML = list.bookingId; function getTimeSlot(slotValue) { - console.log("Slot Value in getTimeSlot function:", slotValue); + // console.log("Slot Value in getTimeSlot function:", slotValue); var timeSlot; var trimmedSlotValue = String(slotValue).trim(); // Convert to string and then trim if (trimmedSlotValue === '1') { @@ -1282,7 +1282,7 @@ } else { timeSlot = 'Unknown'; } - console.log("Time Slot:", timeSlot); + // console.log("Time Slot:", timeSlot); return timeSlot; } @@ -1304,7 +1304,7 @@ 'reasonName': list.reason }, success: function (x) { - console.log(x); + // console.log(x); showReasonWithDocument(x, list); } }); diff --git a/src/main/resources/templates/admin/settlement-reject.html b/src/main/resources/templates/admin/settlement-reject.html index 3e19123c..72ce422b 100644 --- a/src/main/resources/templates/admin/settlement-reject.html +++ b/src/main/resources/templates/admin/settlement-reject.html @@ -448,7 +448,7 @@ $(document).ready(function () { 'settlementsid': settlementId }, success: function (x) { - console.log(x); + // console.log(x); showSettlementInfo(x) showDamageDetails(x); } @@ -457,8 +457,8 @@ $(document).ready(function () { } function showSettlementInfo(list) { - console.log(list); // Log the damageList array - console.log(list.damageList[0]); + // console.log(list); // Log the damageList array + // console.log(list.damageList[0]); $('#rejectSettlementForm').modal({ backdrop: 'static', @@ -636,7 +636,7 @@ if (data.damageList.length === 0) { var refundStatus = data.refundStatus; if (settleAmount < 0) { - console.log(settleAmount); + // console.log(settleAmount); $("#td_settel_amt").html(0.00); $("#pendingcolumn").show(); $("#td_pending_amt").html('₹ ' + Math.abs(settleAmount).toFixed(2)); diff --git a/src/main/resources/templates/admin/settlementlist.html b/src/main/resources/templates/admin/settlementlist.html index 6b314a2b..c5c02671 100644 --- a/src/main/resources/templates/admin/settlementlist.html +++ b/src/main/resources/templates/admin/settlementlist.html @@ -717,7 +717,7 @@ // Set the QR code image source $('#qrview').modal('show'); $('#qrCodeImage').attr('src', 'data:image/png;base64,' + data); - console.log(data); + // console.log(data); }, error: function(jqXHR, textStatus, errorThrown) { console.error('Error fetching QR code:', textStatus, errorThrown); diff --git a/src/main/resources/templates/admin/viewUploadNoc.html b/src/main/resources/templates/admin/viewUploadNoc.html index 7fe32915..5bca75e9 100644 --- a/src/main/resources/templates/admin/viewUploadNoc.html +++ b/src/main/resources/templates/admin/viewUploadNoc.html @@ -411,7 +411,7 @@ // Get the booking ID from the hidden input field let id = $('#bookingid').val(); - console.log("Booking ID:", id); + // console.log("Booking ID:", id); // Get the selected file let fileInput = $('#nocFile')[0].files[0]; @@ -432,7 +432,7 @@ formData.append('nocFile', fileInput); formData.append('bookingid', id); // Ensure key matches backend parameter - console.log("FormData entries:"); + // console.log("FormData entries:"); for (let [key, value] of formData.entries()) { console.log(`${key}: ${value}`); } @@ -445,7 +445,7 @@ contentType: false, // Set to false for multipart/form-data processData: false, // Prevent jQuery from processing the data success: function (response) { - console.log("Upload success response:", response); + // console.log("Upload success response:", response); Swal.fire({ icon: 'success', title: 'Success', @@ -472,7 +472,7 @@ $('#uploadNocModal').on('show.bs.modal', function (event) { var button = $(event.relatedTarget); // Button that triggered the modal var bookingId = button.data('booking-id'); // Extract bookingId from the button - console.log("Setting bookingId in modal:", bookingId); + // console.log("Setting bookingId in modal:", bookingId); $('#bookingid').val(bookingId); // Set the bookingId in the hidden input field }); diff --git a/src/main/resources/templates/caretaker/caretakerpage.html b/src/main/resources/templates/caretaker/caretakerpage.html index 17b26693..8f412f35 100644 --- a/src/main/resources/templates/caretaker/caretakerpage.html +++ b/src/main/resources/templates/caretaker/caretakerpage.html @@ -471,7 +471,7 @@ displayError(fileInput, errorMessage); } else { - console.log('File size is within limit:', file.size, 'bytes'); + // console.log('File size is within limit:', file.size, 'bytes'); clearError(fileInput); } } diff --git a/src/main/resources/templates/caretaker/past-booking.html b/src/main/resources/templates/caretaker/past-booking.html index f38bd8a3..621fa5e3 100644 --- a/src/main/resources/templates/caretaker/past-booking.html +++ b/src/main/resources/templates/caretaker/past-booking.html @@ -557,7 +557,7 @@ displayError(fileInput, errorMessage); } else { - console.log('File size is within limit:', file.size, 'bytes'); + // console.log('File size is within limit:', file.size, 'bytes'); clearError(fileInput); } } diff --git a/src/main/resources/templates/caretaker/present-booking.html b/src/main/resources/templates/caretaker/present-booking.html index 1da9b728..0e9128e5 100644 --- a/src/main/resources/templates/caretaker/present-booking.html +++ b/src/main/resources/templates/caretaker/present-booking.html @@ -431,7 +431,7 @@ displayError(fileInput, errorMessage); } else { - console.log('File size is within limit:', file.size, 'bytes'); + // console.log('File size is within limit:', file.size, 'bytes'); clearError(fileInput); } } diff --git a/src/main/resources/templates/caretaker/settlementlist.html b/src/main/resources/templates/caretaker/settlementlist.html index 18dc3829..8aa3cd8d 100644 --- a/src/main/resources/templates/caretaker/settlementlist.html +++ b/src/main/resources/templates/caretaker/settlementlist.html @@ -718,7 +718,7 @@ // Set the QR code image source $('#qrview').modal('show'); $('#qrCodeImage').attr('src', 'data:image/png;base64,' + data); - console.log(data); + // console.log(data); }, error: function(jqXHR, textStatus, errorThrown) { console.error('Error fetching QR code:', textStatus, errorThrown); diff --git a/src/main/resources/templates/counter/calculate-hall-amount.html b/src/main/resources/templates/counter/calculate-hall-amount.html index ebb29e39..7b2976e5 100644 --- a/src/main/resources/templates/counter/calculate-hall-amount.html +++ b/src/main/resources/templates/counter/calculate-hall-amount.html @@ -135,7 +135,7 @@ // Get hallId from URL parameters and fetch hall details const urlParams = new URLSearchParams(window.location.search); const hallId = urlParams.get('hallId'); - console.log("Hall ID:", hallId); + // console.log("Hall ID:", hallId); $(document).ready(function () { if (hallId != null) { getHallDetails(hallId, function (response) { diff --git a/src/main/resources/templates/counter/counter-booking.html b/src/main/resources/templates/counter/counter-booking.html index 41ed2e5c..01551614 100644 --- a/src/main/resources/templates/counter/counter-booking.html +++ b/src/main/resources/templates/counter/counter-booking.html @@ -964,6 +964,74 @@ aria-labelledby="register-tab">
+ +
+
+
+ + +
+
+ +
@@ -986,17 +1054,30 @@
- - + +
+
- + + +
+
+
+
+
@@ -1009,15 +1090,15 @@ placeholder="doorNo" required>
+ +
+ placeholder="street" required>
-
-
@@ -1044,73 +1125,7 @@
-
-
-
- - -
-
- - - -
+
+

Gcc + Blocked

+
-
+
+
+ + <!– Input field for start date –> @@ -1423,7 +1488,7 @@
- + <!– Center align the button –>
+
--> +
+ + +
+ + +
+ + +
+
+
+
+
+ + +
+ + + +
+
+ + +
+
+
+
+
+ + +
+ + + + +
+
+ + +
+
+
+
+
+ +
+ + +
+
+

Booking Summary:

+

+
+ +
+
+
+
+ + + + +
@@ -2035,7 +2227,7 @@ var ch = 0; function saveCounterBooking() { - console.log("saveCounterBooking called"); + // console.log("saveCounterBooking called"); $("#startPeriodDropdown").prop("disabled", false); $("#endPeriodDropdown").prop("disabled", false); @@ -2043,7 +2235,11 @@ var form = document.getElementById('booking'); var formData = new FormData(form); - console.log(formData); + // console.log(formData); + // Debugging: Log each FormData entry + for (var pair of formData.entries()) { + //console.log(pair[0] + ', ', pair[1]); + } $.ajax({ url: '../communityhall/user/api/counter-booking', @@ -2052,7 +2248,7 @@ processData: false, contentType: false, success: function (response) { - console.log("response=", response); + // console.log("response=", response); // Update the UI with the response data $("#bookingId").val(response.bookingId); $("#userId").val(response.userId); @@ -2096,7 +2292,7 @@ } function addnewdd(bookingId) { - console.log("bookingId==", bookingId); + // console.log("bookingId==", bookingId); $('#ddDetailsModal').modal('show'); // Set the bookingId value in the hidden input field $('#ddform #bookingId').val(bookingId); @@ -2108,12 +2304,12 @@ data: {bookingId: bookingId}, success: function (response) { // Assuming the response contains the booking details - console.log("Booking details: ", response); + // console.log("Booking details: ", response); // Display the amountReceived field in the modal's readonly input field $('#totalamount').val(response.amountReceived); // Adjust according to your response structure }, error: function (error) { - console.log("Error fetching booking details: ", error); + // console.log("Error fetching booking details: ", error); } }); } @@ -2124,7 +2320,7 @@ alert("Booking ID is missing!"); return false; } - console.log("Submitting form with bookingId=", bookingId); + // console.log("Submitting form with bookingId=", bookingId); return true; } @@ -2171,7 +2367,7 @@ }); - function fetchReasonsAndPopulateDropdown() { + /*function fetchReasonsAndPopulateDropdown() { // Make an AJAX call to fetch all reasons $.ajax({ url: '/communityhall/admin/api/getReasons', @@ -2189,6 +2385,82 @@ .fail(function (xhr, status, error) { console.error('Error fetching reasons:', error); }); + }*/ + + function fetchReasonsAndPopulateDropdown() { + // Make an AJAX call to fetch all reasons + $.ajax({ + url: '/communityhall/admin/api/getReasons', + type: 'GET', + dataType: 'json' + }) + .done(function (data) { + const reasonDropdown = $('#reasonforbooking'); + reasonDropdown.empty(); + reasonDropdown.append($('').text('Select a reason')); + + // Populate the dropdown and store reason metadata + $.each(data, function (index, reason) { + reasonDropdown.append($('').attr('value', reason.reasonId).text(reason.reason)); + reasonMaxData.set(reason.reasonId, reason.maxdays); + reasonLabelData.set(reason.reasonId, reason.reason); + reasoncode.set(reason.reasonId, reason.reasoncode); + }); + + // Add change event listener to the dropdown + reasonDropdown.change(function () { + const selectedReasonId = $(this).val(); + const selectedReasonCode = reasoncode.get(parseInt(selectedReasonId)); + const selectedHallId = document.getElementById("statichallId").value; // Getting the selected hall ID + + // Make another AJAX call to get hall details based on the selected hall ID + $.ajax({ + type: 'GET', + url: '/communityhall/user/api/gethalldetails/' + selectedHallId, + success: function (response) { + // console.log(response); + const isSGE = response.sge; // Fetch SGE status from the response + const isCGE = response.cge; // Fetch CGE status from the response + + // Check for State Government Event (SGE) + if (selectedReasonCode === 'SGE' && !isSGE) { + // Show popup for State govt event + Swal.fire({ + title: 'Government Event', + text: 'Shenoy Nagar Community Center (Auditorium) full Mandapam (Amma Arangam) is available for state government events.', + icon: 'info', + confirmButtonText: 'OK' + }).then((result) => { + if (result.isConfirmed && !isSGE) { + window.location.href = '/communityhall/hallbookingform'; + } + }); + } + // Check for Central Government Event (CGE) + else if (selectedReasonCode === 'CGE' && !isCGE) { + // Show popup for Central govt event + Swal.fire({ + title: 'Government Event', + text: 'Shenoy Nagar Community Center (Auditorium) full Mandapam (Amma Arangam) is available for central government events.', + icon: 'info', + confirmButtonText: 'OK' + }).then((result) => { + if (result.isConfirmed && !isCGE) { + // Redirect only if hallId is not 3 + window.location.href = '/counter/counter-booking'; + } + }); + } + }, + error: function (xhr, status, error) { + console.error('Error fetching hall details:', error); + } + }); + }); + }) + .fail(function (xhr, status, error) { + console.error('Error fetching reasons:', error); + }); } function togglePaymentButton(checkbox) { @@ -2205,7 +2477,7 @@ document.getElementById('confirmPaymentBtn').disabled = !checkbox.checked; } function displayStep(stepNumber) { - console.log(stepNumber); + // console.log(stepNumber); if (stepNumber >= 1 && stepNumber <= 4) { @@ -2323,7 +2595,7 @@ $(".step-" + currentStep).fadeOut(500, function () { if (currentStep === 4) { $(".step-" + currentStep).fadeIn(500); - console.log(currentStep); + // console.log(currentStep); updateProgressBar(); return ""; } else { @@ -2411,7 +2683,7 @@ validateStep3(); // Log statement to ensure the button is being enabled - console.log("Enabling the button..."); + // console.log("Enabling the button..."); $('.step-1 .next-step').prop('disabled', false); }); @@ -2502,8 +2774,8 @@ var selectHallDropdown = $('#selecthall'); $.each(response, function (index, hall) { - console.log("response==", response); - console.log("halls", hall); + // console.log("response==", response); + // console.log("halls", hall); var hallId = 0; if (hallId == hall.hallId) { selectHallDropdown.append($('').attr('value', hall.hallId).text(hall.hallName)); @@ -2522,7 +2794,7 @@ $(document).ready(function () { $('#selecthall').change(function () { var selectedHallId = $(this).val(); - console.log('Selected hall ID:', selectedHallId); + // console.log('Selected hall ID:', selectedHallId); // Call the getHallDetails function with the selected hall ID getHallDetails(selectedHallId); }); @@ -2534,23 +2806,26 @@ type: 'GET', url: '/communityhall/user/api/gethalldetails/' + hallId, success: function (response) { - console.log(response); + // console.log(response); // Display the container $('#hallDetailsContainer').show(); // Set hall details - $('#zone').text(response.zone); - $('#division').text(response.division); - $('#address').text(response.doorNo + ', ' + response.street + ', ' + response.area + ', ' + response.city + ', ' + response.pinCode); - $('#landmark').text(response.landMark); - $('#seatingCapacity').text(response.seatingCapacity); - $('#caretakerNumber').text(response.hallInchargeMobno); - $('#rentAmount').text(response.depositAmount); + $('#zone').html('' + response.zone + '     Division: ' + response.division + ''); + $('#address').html('' + response.doorNo + ', ' + response.street + ', ' + response.area + ', ' + response.city + ', ' + response.pinCode + ''); + // $('#address').text(response.doorNo + ', ' + response.street + ', ' + response.area + ', ' + response.city + ', ' + response.pinCode); + $('#landmark').html('' + response.landMark + ''); + $('#seatingCapacity').html('' + response.seatingCapacity + ''); + var parkingCapacity = response.parkingCapacity; + var parkingAvailability = parkingCapacity > 0 ? "Yes" : "No"; + $('#caretakerNumber').html('' + response.hallInchargeMobno + ''); + $('#rentAmount').html('' + response.depositAmount + ''); // Set amount details - $('#gst').text(response.gst); - $('#fullDayAmount').text(response.fullDayRent); - $('#halfDayAmount').text(response.halfDayRent); - $('#ebunit').text(response.ebCostPerUnit); + $('#gst').html('' + response.gst + ''); + $('#fullDayAmount').html('' + response.fullDayRent + ''); + $('#halfDayAmount').html('' + response.halfDayRent + ''); + $('#ebunit').html('' + response.ebCostPerUnit + ''); + $('#statichallId').val(response.hallId); // Set hall images var carouselInner = $('#hallImagesCarousel .carousel-inner'); @@ -2563,30 +2838,27 @@ carouselInner.append(carouselItem); }); - // Initialize ViewerJS on the carousel after images are loaded - var viewer = new Viewer(document.getElementById('hallImagesCarousel'), { - inline: false, - viewed: function () { - viewer.zoomTo(0.5); // Adjust the zoom level here - }, - toolbar: { - zoomIn: 4, - zoomOut: 4, - oneToOne: 4, - reset: 4, - prev: 4, - play: { - show: 4, - size: 'large', - }, - next: 4, - rotateLeft: 4, - rotateRight: 4, - flipHorizontal: 4, - flipVertical: 4, - }, + // Clear existing floor details to prevent duplicates + $('#hallareainsqft').empty(); + + // Use a Set to store unique floor details + var uniqueFloorDetails = new Set(); + + $.each(response.floorDetailsList, function (index, hallarea) { + + // Construct the text for each floor's details + var floorDetailText = hallarea.floor + " - " + hallarea.hallarea + " Sq.ft ,"; + + // Add to the Set if it's not a duplicate + if (!uniqueFloorDetails.has(floorDetailText)) { + uniqueFloorDetails.add(floorDetailText); + // Append the floor details to the target element + $('#hallareainsqft').append('' + floorDetailText + ''); + } }); + // Initialize ViewerJS on the carousel after images are loaded + initializeViewerJS(); getBookingCalendar(hallId); @@ -2603,7 +2875,47 @@ } }); } - function getBookingCalendar(hall_id) { + + function initializeViewerJS() { + // Ensure ViewerJS initialization after images are added to the DOM + var carouselInner = document.querySelector('#hallImagesCarousel .carousel-inner'); + var floordetails = document.querySelector('#hallareainsqft'); + + // Destroy existing viewer instance if it exists + if (carouselInner.viewer) { + carouselInner.viewer.destroy(); + } + if (floordetails.viewer) { + floordetails.viewer.destroy(); + } + // Initialize ViewerJS + var viewer = new Viewer(carouselInner, { + inline: false, + viewed: function () { + viewer.zoomTo(0.5); // Adjust the zoom level here + }, + toolbar: { + zoomIn: 4, + zoomOut: 4, + oneToOne: 4, + reset: 4, + prev: 4, + play: { + show: 4, + size: 'large', + }, + + next: 4, + rotateLeft: 4, + rotateRight: 4, + flipHorizontal: 4, + flipVertical: 4, + }, + }); + carouselInner.viewer = viewer; + } + + /*function getBookingCalendar(hall_id) { // Make an AJAX call to fetch booking data $.ajax({ type: 'GET', @@ -2632,6 +2944,37 @@ console.error('Error fetching hall details:', error); } }); + }*/ + + function getBookingCalendar(hall_id) { + // Make an AJAX call to fetch booking data + $.ajax({ + type: 'GET', + url: '/communityhall/user/api/getPastData', + data: { + hall_id: hall_id + }, + success: function (response) { + window.bookingResponse = {}; + if (response && Array.isArray(response)) { + $("#startDateInput").datepicker("destroy"); + for (var i = 0; i < response.length; i++) { + var dateString = datepickerFormat(response[i].bdate); + window.bookingResponse[dateString] = [response[i].morningSlot, response[i].eveningSlot, response[i].is_blocked]; + } + + initializeDatepickerWithColors(hall_id); + if (response.length == 0) { + initializeDatepickerWithColors(hall_id); + } + } else { + console.error('Invalid or empty response data.'); + } + }, + error: function (xhr, status, error) { + console.error('Error fetching hall details:', error); + } + }); } // Function to update the end date and slot availability @@ -2727,12 +3070,12 @@ var bookingStatus = window.bookingResponse[$("#endDateInput").val()]; if (bookingStatus) { if (bookingStatus[0]) { - console.log("hi1", bookingStatus[0]); + // console.log("hi1", bookingStatus[0]); $("#endPeriodDropdown").val(2); $("#endPeriodDropdown").prop("disabled", true); } else if (bookingStatus[1]) { - console.log("hi2", bookingStatus[1]); + // console.log("hi2", bookingStatus[1]); $("#endPeriodDropdown").val(1) $("#endPeriodDropdown").prop("disabled", true); } @@ -2741,8 +3084,8 @@ } }); - function initializeDatepickerWithColors(hallId) { - console.log("Initializing Datepicker with hallId:", hallId); // Confirm hallId is passed here + /*function initializeDatepickerWithColors(hallId) { + // console.log("Initializing Datepicker with hallId:", hallId); // Confirm hallId is passed here $("#datepicker-container").datepicker("destroy"); $("#startDateInput,#datepicker-container").datepicker({ dateFormat: "yy-mm-dd", @@ -2793,11 +3136,11 @@ var bookingStatus = window.bookingResponse[selectedDate]; if (bookingStatus) { if (bookingStatus[0]) { - console.log("hi3", bookingStatus[0]); + // console.log("hi3", bookingStatus[0]); $("#startPeriodDropdown").val(2); $("#startPeriodDropdown").prop("disabled", true); } else if (bookingStatus[1]) { - console.log("hi4", bookingStatus[1]); + // console.log("hi4", bookingStatus[1]); $("#startPeriodDropdown").val(1); $("#startPeriodDropdown").prop("disabled", true); } @@ -2806,6 +3149,103 @@ } updateEndDate(selectedDate); }); + }*/ + + function initializeDatepickerWithColors(hallId) { + // Destroy existing datepicker to avoid duplicate initialization + $("#datepicker-container").datepicker("destroy"); + + const serverDate =new Date($("#serverDate").val() + "T00:00:00") + // console.log("serverDate:", serverDate); + + const maxDate = new Date(serverDate); + maxDate.setMonth(maxDate.getMonth() + 6); + // console.log(" hall booking form Max Date: "+maxDate); + + // Initialize the datepicker + $("#startDateInput,#datepicker-container").datepicker({ + dateFormat: "yy-mm-dd", + minDate: serverDate, + maxDate: maxDate, + beforeShowDay: function (eDate) { + const dateString = $.datepicker.formatDate("yy-mm-dd", eDate); + const bookingStatus = window.bookingResponse[dateString] || {}; + + // const currentDate = new Date(); + serverDate.setHours(0, 0, 0, 0); // Normalize current date to midnight + eDate.setHours(0, 0, 0, 0); // Normalize selected date to midnight + + // Logic for other dates + if (eDate < serverDate) { + return [false, "highlight-disabled", "Slot not Available"]; + } + + const isToday = eDate.getTime() === serverDate.getTime(); + const currentHour = new Date().getHours(); + const isBefore6AM = currentHour < 6; + const isAfter2PM = currentHour >= 14; + + // Block 3-day logic for specific event types + // const today = new Date(); + const blockedDate = new Date(serverDate); + blockedDate.setDate(serverDate.getDate() + 2); + + if (eDate <= blockedDate && window.isThreeDayBlock) { + return [false, "highlight-disabled", "Blocked due to event type"]; + } + + // Logic for today + if (isToday) { + if (isBefore6AM) { + // Before 6 AM: Allow full-day booking or adjust based on booking status + return handleBookingStatus(bookingStatus, "Full Day Available"); + } else if (isAfter2PM) { + // After 2 PM: Block all bookings + return handleAfter2PM(bookingStatus); + } else { + // Between 6 AM and 2 PM: Check status and disable morning slots + return handleMorningSlots(bookingStatus); + } + } + + return handleBookingStatus(bookingStatus, "Slot Available"); + }, + }); + + // Show datepicker when hall is selected + $('#selecthall').off('click').on('click', function () { + $('#datepicker-container').datepicker('show'); + }); + + // Handle changes in the start date input + $("#startDateInput").on("change", function () { + const selectedDate = $(this).val(); + const bookingStatus = window.bookingResponse[selectedDate] || {}; + // const currentDate = new Date(); + const currentHours = serverDate.getHours(); + const currentDateString = serverDate.toISOString().split("T")[0]; + + $("#startPeriodDropdown").val(0).prop("disabled", false); + $("#endPeriodDropdown").val(0).prop("disabled", false); + $("#numDaysCount").val(''); + validateForm(); + + if (selectedDate === currentDateString && currentHours >= 6) { + $("#startPeriodDropdown").val(2).prop("disabled", true); + } else if (bookingStatus[0]) { + $("#startPeriodDropdown").val(2).prop("disabled", true); + } else if (bookingStatus[1]) { + $("#startPeriodDropdown").val(1).prop("disabled", true); + } + updateEndDate(selectedDate); + }); + + // Event type change logic + $("#reasonforbooking").on("change", function () { + const selectedEventType = $(this).find("option:selected").text().trim(); + window.isThreeDayBlock = ["Commercial", "State Govt Event", "Central Govt Event"].includes(selectedEventType); + $("#datepicker-container").datepicker("refresh"); + }); } function datepickerFormat(dateString) { @@ -2848,7 +3288,7 @@ var endDate = $("#endDateInput").val(); // Call validateSlot with updated parameters - console.log("hiiii"); + // console.log("hiiii"); validateSlot(starting, ending, startDate, endDate); validateForm(); }); @@ -2932,7 +3372,7 @@ url: '/communityhall/user/api/counterbookinglimit', data: {mobileNo: mobileNo}, success: function (statusResponse) { - console.log("hiiii", statusResponse); + // console.log("hiiii", statusResponse); if (statusResponse === "deactive") { Swal.fire({ title: "Account Deactivated", @@ -2953,7 +3393,7 @@ }); } else if (statusResponse === "checkmobilenoexists") { // User status is not pending, proceed to check mobile number existence - console.log("statusResponse===", statusResponse); + // console.log("statusResponse===", statusResponse); $.ajax({ type: "GET", url: '/communityhall/user/api/checkMobileExits', @@ -3067,6 +3507,7 @@ otpValue += $(this).val(); }); var mobileNoValue = $("#mobileNumber").val(); + var aadharnumber = $("#aadharnumber").val(); $.ajax({ type: "GET", @@ -3078,12 +3519,13 @@ dataType: 'text', success: function (bodyMessage) { if (bodyMessage.trim() == "Success") { - console.log("OTP is Verified!!!"); + // console.log("OTP is Verified!!!"); $('#otpForm').modal('hide'); if (verifyLogin == "new") { var formData = new FormData(); formData.append('mobileNo', mobileNoValue); + formData.append('aadharnumber', aadharnumber); formData.append('name', $('#name').val()); formData.append('email', $('#email').val()); formData.append('doorNo', $('#doorNo').val()); @@ -3104,14 +3546,14 @@ processData: false, contentType: false, success: function (response) { - console.log("Registration successful:", response); + // console.log("Registration successful:", response); // alert(response.message); showProfileDetailsInCard(); document.getElementById("profileCard").style.display = "block"; document.getElementById("container").style.display = "none"; }, error: function (jqXHR, textStatus, errorThrown) { - console.log("Error registering user:", textStatus, errorThrown); + // console.log("Error registering user:", textStatus, errorThrown); alert("Registration failed. Please try again."); } }); @@ -3122,11 +3564,11 @@ url: '/communityhall/user/api/getUserDetails', data: {'mobileNo': mobileNoValue}, success: function (userDetails) { - console.log("User details retrieved:", userDetails); + // console.log("User details retrieved:", userDetails); showexistedProfileDetailsInCard(userDetails); // Pass the user details to the function }, error: function (jqXHR, textStatus, errorThrown) { - console.log("Error retrieving user details:", textStatus, errorThrown); + // console.log("Error retrieving user details:", textStatus, errorThrown); } }); } @@ -3136,7 +3578,7 @@ }, error: function () { - console.log("Error verifying OTP"); + // console.log("Error verifying OTP"); } }); return false; @@ -3246,13 +3688,13 @@ } else if (usertype == "GCC_EMPLOYEE") { var employeeId = $("#employeeId").val(); - console.log(employeeId); + // console.log(employeeId); $.ajax({ type: "GET", url: '/communityhall/user/api/EmployeeDetails', data: {'employeeId': $("#employeeId").val()}, success: function (response) { - console.log(response); + // console.log(response); if (response.ResultStatus == false) { var alertMessage = "The Employee Id Not Found! " + employeeId; Swal.fire({ @@ -3269,7 +3711,7 @@ } }, error: function () { - console.log("Error"); + // console.log("Error"); } }); return false; @@ -3470,6 +3912,47 @@ paymentStart(userId, bookingId, true); } + // Newly added for calendar + + function handleBookingStatus(bookingStatus, defaultMessage) { + if (bookingStatus[2]) { + return [true, "highlight-blue disabled", "GCC Blocked"]; + } /*else if (bookingStatus[3]) { + return [true, "highlight-lightpink disabled", "Temporary Blocked"]; + } */else if (bookingStatus[0] && bookingStatus[1]) { + return [true, "highlight-pink disabled", "Slot Occupied"]; + } else if (bookingStatus[0] && !bookingStatus[1]) { + return [true, "highlight-yellow", "Evening Slot Available"]; + } else if (!bookingStatus[0] && bookingStatus[1]) { + return [true, "highlight-violet", "Only Morning Slot Available"]; + } + return [true, "highlight-greens", defaultMessage]; + } + + // Helper function: Handles logic after 2 PM + function handleAfter2PM(bookingStatus) { + if (bookingStatus[2]) { + return [true, "highlight-blue disabled", "GCC Blocked"]; + } else if (bookingStatus[0] || bookingStatus[1]) { + return [true, "highlight-pink disabled", "Slot Occupied"]; + } + return [false, "highlight-disabled", "Not Allowed to Book"]; + } + + // Helper function: Handles morning slots between 6 AM and 2 PM + function handleMorningSlots(bookingStatus) { + if (bookingStatus[2]) { + return [true, "highlight-blue disabled", "GCC Blocked"]; + } else if (bookingStatus[0] && bookingStatus[1]) { + return [true, "highlight-pink disabled", "Slot Occupied"]; + } else if (bookingStatus[0] && !bookingStatus[1]) { + return [true, "highlight-yellow", "Evening Slot Available"]; + } else if (!bookingStatus[0] && bookingStatus[1]) { + return [false, "highlight-disabled", "Slot Occupied"]; + } + return [true, "highlight-yellow", "Evening Slot Available"]; + } + diff --git a/src/main/resources/templates/counter/refund-initialisation.html b/src/main/resources/templates/counter/refund-initialisation.html index 47dd070a..fab0ffde 100644 --- a/src/main/resources/templates/counter/refund-initialisation.html +++ b/src/main/resources/templates/counter/refund-initialisation.html @@ -244,14 +244,14 @@ }); function UserDetails(counterDetails) { - console.log("Initial Counter Details:", counterDetails); + // console.log("Initial Counter Details:", counterDetails); var counterId = counterDetails.counterId; $.ajax({ url: '/communityhall/user/api/counterdetails', type: 'GET', data: {counterId: counterId}, success: function (response) { - console.log("Fetched User Details:", response); + // console.log("Fetched User Details:", response); // Assuming the response is an array and we need the first element if (response.length > 0) { @@ -286,7 +286,7 @@ type: 'GET', data: {counterId: counterId}, success: function (response) { - console.log("Fetched Booking Details:", response); + // console.log("Fetched Booking Details:", response); if (response.length > 0) { var bookingDetails = response[0]; diff --git a/src/main/resources/templates/counter/viewhistory.html b/src/main/resources/templates/counter/viewhistory.html index 86074ba3..89605ff6 100644 --- a/src/main/resources/templates/counter/viewhistory.html +++ b/src/main/resources/templates/counter/viewhistory.html @@ -603,7 +603,7 @@ //function to get the slot value function getTimeSlot(slotValue) { - console.log("Slot Value in getTimeSlot function:", slotValue); + // console.log("Slot Value in getTimeSlot function:", slotValue); var timeSlot; var trimmedSlotValue = String(slotValue).trim(); // Convert to string and then trim if (trimmedSlotValue === '1') { @@ -613,7 +613,7 @@ } else { timeSlot = 'Unknown'; } - console.log("Time Slot:", timeSlot); + // console.log("Time Slot:", timeSlot); return timeSlot; } @@ -624,7 +624,7 @@ method: 'GET', data: {bookingId: bookingId}, success: function (response) { - console.log("response=", response); + // console.log("response=", response); document.getElementById("name").innerHTML = response.users.name; document.getElementById("mobileno").innerHTML = response.users.mobileNo; document.getElementById("email").innerHTML = response.users.email; @@ -693,8 +693,8 @@ var bookingId = booking; var mobileNum = mobileNo; - console.log("mobileNumber", mobileNum); - console.log("bookingId", bookingId); + // console.log("mobileNumber", mobileNum); + // console.log("bookingId", bookingId); // Check if the booking type is OFFLINE if (bookingType === "ONLINE") { @@ -794,7 +794,7 @@ return false; } function verifyOtp() { - console.log("cancel booking hhjjjh" + cancelBookingLogin); + // console.log("cancel booking hhjjjh" + cancelBookingLogin); var otpInputs = $('.otp-input'); var otpValue = ''; otpInputs.each(function () { @@ -819,7 +819,7 @@ dataType: 'text', success: function (bodyMessage) { if (bodyMessage.trim() == "Success") { - console.log("OTP is Verified!!!"); + // console.log("OTP is Verified!!!"); $('#otpForm').modal('hide'); // Hide OTP form modal $.ajax({ @@ -831,7 +831,7 @@ comments: 'user cancelled' }, success: function (response) { - console.log(response); + // console.log(response); if (response.trim() === "success") { Swal.fire( 'Cancelled!', @@ -867,7 +867,7 @@ } }, error: function () { - console.log("Error verifying OTP"); + // console.log("Error verifying OTP"); } }); return false; @@ -895,7 +895,7 @@ var formData = new FormData(this); var counterId = $('#counterId').val(); - console.log("counterId: " + counterId); + // console.log("counterId: " + counterId); $.ajax({ url: '/communityhall/user/api/saveCancellation', type: 'POST', @@ -938,7 +938,7 @@ $('#totalamount').val(response.amountReceived); // Adjust according to your response structure }, error: function (error) { - console.log("Error fetching booking details: ", error); + // console.log("Error fetching booking details: ", error); } }); } @@ -950,7 +950,7 @@ alert("Booking ID is missing!"); return false; } - console.log("Submitting form with bookingId=", bookingId); + // console.log("Submitting form with bookingId=", bookingId); return true; } diff --git a/src/main/resources/templates/departments/counsellor/dashboard.html b/src/main/resources/templates/departments/counsellor/dashboard.html index 4759e778..6d216ccc 100644 --- a/src/main/resources/templates/departments/counsellor/dashboard.html +++ b/src/main/resources/templates/departments/counsellor/dashboard.html @@ -214,7 +214,7 @@ keyboard: false }); $('#rejectForm').modal('show'); - console.log(list) + // console.log(list) document.getElementById("uniqid").value = list.uniqueid; document.getElementById("petna").value = list.petname; document.getElementById("speci").value = list.species; @@ -253,7 +253,7 @@ data: {'id': id, 'reason': reason}, success: function (bodyMessage) { if (bodyMessage == "success") { - console.log("done"); + // console.log("done"); Swal.fire( 'Done', 'Successfully Rejected to the ID:' + id, @@ -277,7 +277,7 @@ } function viewOwner(mobilenum) { - console.log(mobilenum); + // console.log(mobilenum); // let list; let own; $.ajax({ @@ -342,7 +342,7 @@ function getbydate() { var x = document.getElementById("fromdate").value; var y = document.getElementById("todate").value; - console.log(x, y); + // console.log(x, y); $.ajax({ type: "GET", url: '/api/getbydate', diff --git a/src/main/resources/templates/departments/counsellor/user-pending.html b/src/main/resources/templates/departments/counsellor/user-pending.html index a514046a..0fb1968d 100644 --- a/src/main/resources/templates/departments/counsellor/user-pending.html +++ b/src/main/resources/templates/departments/counsellor/user-pending.html @@ -240,7 +240,7 @@ 'usersid': userId }, success: function (x) { - console.log(x); + // console.log(x); showUserInfo(x) } }); diff --git a/src/main/resources/templates/departments/gccstaff/user-approved.html b/src/main/resources/templates/departments/gccstaff/user-approved.html index aa3bcd7b..421a6e3b 100644 --- a/src/main/resources/templates/departments/gccstaff/user-approved.html +++ b/src/main/resources/templates/departments/gccstaff/user-approved.html @@ -239,7 +239,7 @@ 'usersid': userId }, success: function (x) { - console.log(x); + // console.log(x); showUserInfo(x) } }); diff --git a/src/main/resources/templates/departments/gccstaff/user-pending.html b/src/main/resources/templates/departments/gccstaff/user-pending.html index e0fd0a32..3a862eff 100644 --- a/src/main/resources/templates/departments/gccstaff/user-pending.html +++ b/src/main/resources/templates/departments/gccstaff/user-pending.html @@ -250,7 +250,7 @@ 'usersid': userId }, success: function (x) { - console.log(x); + // console.log(x); showUserInfo(x) } }); @@ -348,7 +348,7 @@ }).then((result) => { /* Read more about isConfirmed, isDenied below */ if (result.isConfirmed) { - console.log("Submitting rejection..."); + // console.log("Submitting rejection..."); $.ajax({ type: "POST", @@ -359,7 +359,7 @@ 'userId': id }, success: function (data, textStatus, xhr) { - console.log("Rejection successful"); + // console.log("Rejection successful"); if (xhr.status === 200) { // Check if the response status is OK Swal.fire( 'Done', diff --git a/src/main/resources/templates/departments/gccstaff/user-reject.html b/src/main/resources/templates/departments/gccstaff/user-reject.html index ec86b58b..f4e1b884 100644 --- a/src/main/resources/templates/departments/gccstaff/user-reject.html +++ b/src/main/resources/templates/departments/gccstaff/user-reject.html @@ -246,7 +246,7 @@ 'usersid': userId }, success: function (x) { - console.log(x); + // console.log(x); showUserInfo(x) } }); diff --git a/src/main/resources/templates/departments/pensioner/user-pending.html b/src/main/resources/templates/departments/pensioner/user-pending.html index f3050390..5465d616 100644 --- a/src/main/resources/templates/departments/pensioner/user-pending.html +++ b/src/main/resources/templates/departments/pensioner/user-pending.html @@ -250,7 +250,7 @@ 'usersid': userId }, success: function (x) { - console.log(x); + // console.log(x); showUserInfo(x) } }); @@ -348,7 +348,7 @@ }).then((result) => { /* Read more about isConfirmed, isDenied below */ if (result.isConfirmed) { - console.log("Submitting rejection..."); + // console.log("Submitting rejection..."); $.ajax({ type: "POST", @@ -359,7 +359,7 @@ 'userId': id }, success: function (data, textStatus, xhr) { - console.log("Rejection successful"); + // console.log("Rejection successful"); if (xhr.status === 200) { // Check if the response status is OK Swal.fire( 'Done', diff --git a/src/main/resources/templates/departments/pensioner/user-reject.html b/src/main/resources/templates/departments/pensioner/user-reject.html index 6949437a..59b2c3f3 100644 --- a/src/main/resources/templates/departments/pensioner/user-reject.html +++ b/src/main/resources/templates/departments/pensioner/user-reject.html @@ -246,7 +246,7 @@ 'usersid': userId }, success: function (x) { - console.log(x); + // console.log(x); showUserInfo(x) } }); diff --git a/src/main/resources/templates/fragments/PaymentScript.html b/src/main/resources/templates/fragments/PaymentScript.html index ad66b2bc..bf17ed53 100644 --- a/src/main/resources/templates/fragments/PaymentScript.html +++ b/src/main/resources/templates/fragments/PaymentScript.html @@ -119,7 +119,7 @@ url: '/communityhall/payment/api/payment-request', data: {'userId': userIdd, 'bookingId': bookingIdd}, success: function (response) { - console.log(response); + // console.log(response); if (response.error) { alert("please Contact Admin..") } else { @@ -165,7 +165,7 @@ url: '/communityhall/payment/api/additionaldamage-payment-request', data: {'userId': userIdd, 'bookingId': bookingIdd}, success: function (response) { - console.log(response); + // console.log(response); if (response.error) { alert("please Contact Admin..") } else { @@ -218,12 +218,12 @@ $(document).off("click", "#extrapaymentbtnSubmit").on("click", "#extrapaymentbtnSubmit", function (e) { e.preventDefault(); - console.log(txansactionId); - console.log(consumerMobileNo); - console.log(token); - console.log(merchantId); - console.log(consumerId); - console.log(amount); + // console.log(txansactionId); + // console.log(consumerMobileNo); + // console.log(token); + // console.log(merchantId); + // console.log(consumerId); + // console.log(amount); var reqJson = { diff --git a/src/main/resources/templates/fragments/head.html b/src/main/resources/templates/fragments/head.html index 79927785..3c1fd537 100644 --- a/src/main/resources/templates/fragments/head.html +++ b/src/main/resources/templates/fragments/head.html @@ -37,13 +37,13 @@ - + - + diff --git a/src/main/resources/templates/fragments/header-counter.html b/src/main/resources/templates/fragments/header-counter.html index 9a1c5b0f..f96bd1a8 100644 --- a/src/main/resources/templates/fragments/header-counter.html +++ b/src/main/resources/templates/fragments/header-counter.html @@ -1,73 +1,73 @@
\ No newline at end of file diff --git a/src/main/resources/templates/fragments/logRegiOtpScript.html b/src/main/resources/templates/fragments/logRegiOtpScript.html index cf5299fe..1235c2dd 100644 --- a/src/main/resources/templates/fragments/logRegiOtpScript.html +++ b/src/main/resources/templates/fragments/logRegiOtpScript.html @@ -1,666 +1,676 @@ \ No newline at end of file diff --git a/src/main/resources/templates/fragments/loginhead.html b/src/main/resources/templates/fragments/loginhead.html index 7cd70512..2d6c218f 100644 --- a/src/main/resources/templates/fragments/loginhead.html +++ b/src/main/resources/templates/fragments/loginhead.html @@ -38,7 +38,7 @@ - + diff --git a/src/main/resources/templates/fragments/loginreg.html b/src/main/resources/templates/fragments/loginreg.html index e16cd063..60338ef5 100644 --- a/src/main/resources/templates/fragments/loginreg.html +++ b/src/main/resources/templates/fragments/loginreg.html @@ -1,408 +1,494 @@ -