|
|
|
@ -1,6 +1,5 @@ |
|
|
|
package com.gcc.communityHall.controller; |
|
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDate; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
@ -36,7 +35,7 @@ import com.gcc.communityHall.service.UserService; |
|
|
|
import com.gcc.communityHall.service.Impl.WhatsappMsgServiceImpl; |
|
|
|
|
|
|
|
@Controller |
|
|
|
@RequestMapping(value = {"/communityhall/user", "/communityhall", "", "/"}) |
|
|
|
@RequestMapping(value = { "/communityhall/user", "/communityhall", "", "/" }) |
|
|
|
public class UserController { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
@ -49,7 +48,6 @@ public class UserController { |
|
|
|
@Autowired |
|
|
|
private HallDetailService hallDetailsService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
private UserService userService; |
|
|
|
|
|
|
|
@ -65,7 +63,7 @@ public class UserController { |
|
|
|
@Autowired |
|
|
|
private NotificationRepository notificationRepository; |
|
|
|
|
|
|
|
@GetMapping(value = {"", "/", "/dashboard", "/index"}) |
|
|
|
@GetMapping(value = { "", "/", "/dashboard", "/index" }) |
|
|
|
public String viewDashboard(Model model) { |
|
|
|
List<HallDetails> halls = hallDetailsRepository.findActiveHalls(); |
|
|
|
List<HallDetails> hallnames = hallDetailsService.getHallNames(); |
|
|
|
@ -82,28 +80,29 @@ public class UserController { |
|
|
|
for (Notification notification : newnotification) { |
|
|
|
notificationText.append(notification.getNotification_description()); |
|
|
|
} |
|
|
|
// System.out.println("user controller \nCounter Id: "+userSession.getCounter()+"\nCounter Name: "+userSession.getCounterName()); |
|
|
|
// 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("serverDate", LocalDate.now().toString()); // for server date |
|
|
|
model.addAttribute("counter", userSession.getCounter()); |
|
|
|
model.addAttribute("counterName", userSession.getCounterName()); |
|
|
|
|
|
|
|
return "user/dashboard"; |
|
|
|
} |
|
|
|
|
|
|
|
//Checkavilability Api |
|
|
|
// Checkavilability Api |
|
|
|
@GetMapping("/checkAvail") |
|
|
|
public String checkAvail(@RequestParam("fromDate") String fromDate, |
|
|
|
@RequestParam("toDate") String toDate, |
|
|
|
@RequestParam("starting") String starting, |
|
|
|
@RequestParam("ending") String ending, |
|
|
|
@RequestParam(name = "hallId", required = false) String hallId, |
|
|
|
@RequestParam(name = "zone", required = false) String zone, |
|
|
|
Model model) { |
|
|
|
@RequestParam("toDate") String toDate, |
|
|
|
@RequestParam("starting") String starting, |
|
|
|
@RequestParam("ending") String ending, |
|
|
|
@RequestParam(name = "hallId", required = false) String hallId, |
|
|
|
@RequestParam(name = "zone", required = false) String zone, |
|
|
|
Model model) { |
|
|
|
|
|
|
|
List<Notification> newnotification = notificationRepository.findActivenotifications(); |
|
|
|
|
|
|
|
@ -138,7 +137,8 @@ public class UserController { |
|
|
|
} |
|
|
|
|
|
|
|
// Fetch calendar data based on provided parameters |
|
|
|
List<BookingCalendar> data = calendarService.getCalendarByDateAndHallIdAndSlot(fromDate, toDate, starting, ending, hallIdd); |
|
|
|
List<BookingCalendar> data = calendarService.getCalendarByDateAndHallIdAndSlot(fromDate, toDate, starting, |
|
|
|
ending, hallIdd); |
|
|
|
HashSet<Integer> removeHallId = new HashSet<>(); |
|
|
|
|
|
|
|
// Collect hall IDs to be removed |
|
|
|
@ -151,16 +151,21 @@ public class UserController { |
|
|
|
|
|
|
|
if (isSameDay) { |
|
|
|
// Same day booking cases |
|
|
|
if (isMorningStart && isMorningEnd && (calendar.getBdate().toString().equals(fromDate) && calendar.isMorningSlot())) { |
|
|
|
// System.out.println("Same day morning-morning match found: hallId=" + calendar.getHallId()); |
|
|
|
if (isMorningStart && isMorningEnd |
|
|
|
&& (calendar.getBdate().toString().equals(fromDate) && calendar.isMorningSlot())) { |
|
|
|
// System.out.println("Same day morning-morning match found: hallId=" + |
|
|
|
// calendar.getHallId()); |
|
|
|
removeHallId.add(calendar.getHallId()); |
|
|
|
} else if (isEveningStart && isEveningEnd && (calendar.getBdate().toString().equals(fromDate) && calendar.isEveningSlot())) { |
|
|
|
// System.out.println("Same day evening-evening match found: hallId=" + calendar.getHallId()); |
|
|
|
} else if (isEveningStart && isEveningEnd |
|
|
|
&& (calendar.getBdate().toString().equals(fromDate) && calendar.isEveningSlot())) { |
|
|
|
// System.out.println("Same day evening-evening match found: hallId=" + |
|
|
|
// calendar.getHallId()); |
|
|
|
removeHallId.add(calendar.getHallId()); |
|
|
|
} else if (isMorningStart && isEveningEnd && |
|
|
|
((calendar.getBdate().toString().equals(fromDate) && calendar.isMorningSlot()) || |
|
|
|
(calendar.getBdate().toString().equals(toDate) && calendar.isEveningSlot()))) { |
|
|
|
// System.out.println("Same day morning-evening match found: hallId=" + calendar.getHallId()); |
|
|
|
// System.out.println("Same day morning-evening match found: hallId=" + |
|
|
|
// calendar.getHallId()); |
|
|
|
removeHallId.add(calendar.getHallId()); |
|
|
|
} |
|
|
|
} else { |
|
|
|
@ -168,22 +173,26 @@ public class UserController { |
|
|
|
if ((isMorningStart && isMorningEnd) && |
|
|
|
((calendar.getBdate().toString().equals(fromDate) && calendar.isMorningSlot()) || |
|
|
|
(calendar.getBdate().toString().equals(toDate) && calendar.isMorningSlot()))) { |
|
|
|
// System.out.println("Multi-day morning-morning match found: hallId=" + calendar.getHallId()); |
|
|
|
// System.out.println("Multi-day morning-morning match found: hallId=" + |
|
|
|
// calendar.getHallId()); |
|
|
|
removeHallId.add(calendar.getHallId()); |
|
|
|
} else if ((isEveningStart && isEveningEnd) && |
|
|
|
((calendar.getBdate().toString().equals(fromDate) && calendar.isEveningSlot()) || |
|
|
|
(calendar.getBdate().toString().equals(toDate) && calendar.isEveningSlot()))) { |
|
|
|
// System.out.println("Multi-day evening-evening match found: hallId=" + calendar.getHallId()); |
|
|
|
// System.out.println("Multi-day evening-evening match found: hallId=" + |
|
|
|
// calendar.getHallId()); |
|
|
|
removeHallId.add(calendar.getHallId()); |
|
|
|
} else if (isMorningStart && isEveningEnd && |
|
|
|
((calendar.getBdate().toString().equals(fromDate) && calendar.isMorningSlot()) || |
|
|
|
(calendar.getBdate().toString().equals(toDate) && calendar.isEveningSlot()))) { |
|
|
|
// System.out.println("Multi-day morning-evening match found: hallId=" + calendar.getHallId()); |
|
|
|
// System.out.println("Multi-day morning-evening match found: hallId=" + |
|
|
|
// calendar.getHallId()); |
|
|
|
removeHallId.add(calendar.getHallId()); |
|
|
|
} else if (isEveningStart && isMorningEnd && |
|
|
|
((calendar.getBdate().toString().equals(fromDate) && calendar.isEveningSlot()) || |
|
|
|
(calendar.getBdate().toString().equals(toDate) && calendar.isMorningSlot()))) { |
|
|
|
//System.out.println("Multi-day evening-morning match found: hallId=" + calendar.getHallId()); |
|
|
|
// System.out.println("Multi-day evening-morning match found: hallId=" + |
|
|
|
// calendar.getHallId()); |
|
|
|
removeHallId.add(calendar.getHallId()); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -216,7 +225,6 @@ public class UserController { |
|
|
|
return "user/dashboard"; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/newregistrationform") |
|
|
|
public String showRegistrationForm(@ModelAttribute("newform") Users newform, Model model) { |
|
|
|
Users user = userService.user(newform); |
|
|
|
@ -225,18 +233,26 @@ public class UserController { |
|
|
|
userSession.setUserId(user.getUserId()); |
|
|
|
userSession.setUserType(user.getUsertype().toString()); |
|
|
|
System.out.println("usetrtype==" + user.getUsertype().toString()); |
|
|
|
//System.out.println("employee id"+user.getGovernmentId()); |
|
|
|
//System.out.println("employee id"+user.getDepartment()); |
|
|
|
// System.out.println("employee id"+user.getGovernmentId()); |
|
|
|
// System.out.println("employee id"+user.getDepartment()); |
|
|
|
if (user.getUsertype() == userType.PUBLIC) { |
|
|
|
String registersms = "Welcome to GCC, Your User Registration for booking Community Centre is successful."; |
|
|
|
String registerurlString = "https://tmegov.onex-aura.com/api/sms?key=pfTEYN6H&to=" + user.getMobileNo() + "&from=GCCCRP&body=" + registersms + "&entityid=1401572690000011081&templateid=1407172346621223019"; |
|
|
|
String registerwhatsupmsg = "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to=" + user.getMobileNo() + "&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Welcome+to+GCC%2C+%0A%0AYour+User+Registration+for+booking+Community+Centre+is+successful."; |
|
|
|
String registerurlString = "https://tmegov.onex-aura.com/api/sms?key=pfTEYN6H&to=" + user.getMobileNo() |
|
|
|
+ "&from=GCCCRP&body=" + registersms |
|
|
|
+ "&entityid=1401572690000011081&templateid=1407172346621223019"; |
|
|
|
String registerwhatsupmsg = "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to=" |
|
|
|
+ user.getMobileNo() |
|
|
|
+ "&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Welcome+to+GCC%2C+%0A%0AYour+User+Registration+for+booking+Community+Centre+is+successful."; |
|
|
|
whatsappMsgServiceImpl.sendMsg(registerwhatsupmsg); |
|
|
|
whatsappMsgServiceImpl.sendSMS(registerurlString); |
|
|
|
} else { |
|
|
|
String registerpendingsms = "Welcome to GCC, Your User Registration request for booking Community Centre is submitted successfully."; |
|
|
|
String registerpendingurlString = "https://tmegov.onex-aura.com/api/sms?key=pfTEYN6H&to=" + user.getMobileNo() + "&from=GCCCRP&body=" + registerpendingsms + "&entityid=1401572690000011081&templateid=1407172346629919381"; |
|
|
|
String registerpendingwhatsupmsg = "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to=" + user.getMobileNo() + "&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Welcome+to+GCC%2C+%0A%0AYour+User+Registration+request+for+booking+Community+Centre+submitted+successfully."; |
|
|
|
String registerpendingurlString = "https://tmegov.onex-aura.com/api/sms?key=pfTEYN6H&to=" |
|
|
|
+ user.getMobileNo() + "&from=GCCCRP&body=" + registerpendingsms |
|
|
|
+ "&entityid=1401572690000011081&templateid=1407172346629919381"; |
|
|
|
String registerpendingwhatsupmsg = "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to=" |
|
|
|
+ user.getMobileNo() |
|
|
|
+ "&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Welcome+to+GCC%2C+%0A%0AYour+User+Registration+request+for+booking+Community+Centre+submitted+successfully."; |
|
|
|
whatsappMsgServiceImpl.sendMsg(registerpendingwhatsupmsg); |
|
|
|
whatsappMsgServiceImpl.sendSMS(registerpendingurlString); |
|
|
|
} |
|
|
|
@ -246,40 +262,43 @@ public class UserController { |
|
|
|
@GetMapping("/hallbookingform") |
|
|
|
public String viewform(Model model) { |
|
|
|
String username = userSession.getDispayName(); |
|
|
|
// System.out.println("server Date22....."+LocalDate.now().toString()); |
|
|
|
model.addAttribute("serverDate", LocalDate.now().toString()); //for server date |
|
|
|
// 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"; |
|
|
|
} |
|
|
|
// ak |
|
|
|
|
|
|
|
/* @GetMapping("/acknowledgement") |
|
|
|
@GetMapping("/acknowledgementwithoutrefid") |
|
|
|
public String viewakowledgement(Model model, int bookingId) { |
|
|
|
BookingDetails bookingsDetails = bookingService.getBookingsById(bookingId); |
|
|
|
model.addAttribute("bookingsDetails", bookingsDetails); // Add single BookingDetails object |
|
|
|
model.addAttribute("userName", userSession.getDispayName()); |
|
|
|
return "user/acknowledgement"; |
|
|
|
}*/ |
|
|
|
//ak |
|
|
|
} |
|
|
|
|
|
|
|
// ak |
|
|
|
@GetMapping("/acknowledgement") |
|
|
|
public String viewAcknowledgement(@RequestParam("ref_id") String refId, Model model) { |
|
|
|
public String viewAcknowledgement(@RequestParam("ref_id") String refId, Model model) { |
|
|
|
|
|
|
|
// Fetch booking using booking_ref_id |
|
|
|
BookingDetails bookingsDetails = bookingService.getBookingByRefId(refId); |
|
|
|
// Fetch booking using booking_ref_id |
|
|
|
BookingDetails bookingsDetails = bookingService.getBookingByRefId(refId); |
|
|
|
|
|
|
|
if (bookingsDetails == null) { |
|
|
|
model.addAttribute("errorMsg", "Invalid booking reference number."); |
|
|
|
return "user/error"; |
|
|
|
} |
|
|
|
if (bookingsDetails == null) { |
|
|
|
model.addAttribute("errorMsg", "Invalid booking reference number."); |
|
|
|
return "user/error"; |
|
|
|
} |
|
|
|
|
|
|
|
model.addAttribute("bookingsDetails", bookingsDetails); |
|
|
|
model.addAttribute("userName", userSession.getDispayName()); |
|
|
|
|
|
|
|
model.addAttribute("bookingsDetails", bookingsDetails); |
|
|
|
model.addAttribute("userName", userSession.getDispayName()); |
|
|
|
return "user/acknowledgement"; |
|
|
|
} |
|
|
|
|
|
|
|
return "user/acknowledgement"; |
|
|
|
} |
|
|
|
//ak |
|
|
|
@PostMapping("/migrate-old-bookings") |
|
|
|
// ak |
|
|
|
@PostMapping("/migrate-old-bookings") |
|
|
|
@ResponseBody |
|
|
|
public ResponseEntity<String> migrateOldBookings() { |
|
|
|
try { |
|
|
|
@ -292,9 +311,6 @@ public String viewAcknowledgement(@RequestParam("ref_id") String refId, Model mo |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/logout") |
|
|
|
public String logout(Model model) { |
|
|
|
// Clear all login session (Check API Controller /gcc-login) |
|
|
|
@ -305,61 +321,64 @@ public String viewAcknowledgement(@RequestParam("ref_id") String refId, Model mo |
|
|
|
return "redirect:/communityhall/user/dashboard"; |
|
|
|
} |
|
|
|
|
|
|
|
/*@GetMapping("/viewhistory") |
|
|
|
public String viewBookingDetails(Model model, @RequestParam(name = "bookingStatus", required = false) String bookingStatus) { |
|
|
|
// Retrieve userId from session |
|
|
|
/* |
|
|
|
* @GetMapping("/viewhistory") |
|
|
|
* public String viewBookingDetails(Model model, @RequestParam(name = |
|
|
|
* "bookingStatus", required = false) String bookingStatus) { |
|
|
|
* // Retrieve userId from session |
|
|
|
* Integer userId = userSession.getUserId(); |
|
|
|
* model.addAttribute("userName", userSession.getDispayName()); |
|
|
|
* |
|
|
|
* //List<String> test = new ArrayList<>(); |
|
|
|
* model.addAttribute("userName", userSession.getDispayName()); |
|
|
|
* model.addAttribute("counter", userSession.getCounter()); |
|
|
|
* model.addAttribute("counterName", userSession.getCounterName()); |
|
|
|
* |
|
|
|
* List<Map<String, Object>> bookingPast = |
|
|
|
* bookingService.getAllBookingEventsByUserId(userId); |
|
|
|
* |
|
|
|
* model.addAttribute("userBookingspast", bookingPast); |
|
|
|
* model.addAttribute("serverDate", LocalDate.now().toString()); //for server |
|
|
|
* date |
|
|
|
* |
|
|
|
* return "user/viewhistory"; |
|
|
|
* } |
|
|
|
*/ |
|
|
|
// ak |
|
|
|
@GetMapping("/viewhistory") |
|
|
|
public String viewBookingDetails(Model model, |
|
|
|
@RequestParam(name = "bookingStatus", required = false) String bookingStatus) { |
|
|
|
|
|
|
|
Integer userId = userSession.getUserId(); |
|
|
|
model.addAttribute("userName", userSession.getDispayName()); |
|
|
|
|
|
|
|
//List<String> test = new ArrayList<>(); |
|
|
|
model.addAttribute("userName", userSession.getDispayName()); |
|
|
|
model.addAttribute("counter", userSession.getCounter()); |
|
|
|
model.addAttribute("counterName", userSession.getCounterName()); |
|
|
|
|
|
|
|
// Fetch all past bookings |
|
|
|
List<Map<String, Object>> bookingPast = bookingService.getAllBookingEventsByUserId(userId); |
|
|
|
|
|
|
|
model.addAttribute("userBookingspast", bookingPast); |
|
|
|
model.addAttribute("serverDate", LocalDate.now().toString()); //for server date |
|
|
|
|
|
|
|
return "user/viewhistory"; |
|
|
|
}*/ |
|
|
|
//ak |
|
|
|
@GetMapping("/viewhistory") |
|
|
|
public String viewBookingDetails(Model model, |
|
|
|
@RequestParam(name = "bookingStatus", required = false) String bookingStatus) { |
|
|
|
|
|
|
|
Integer userId = userSession.getUserId(); |
|
|
|
// Extract booking_ref_id per booking |
|
|
|
Map<Integer, String> refIdMap = new HashMap<>(); |
|
|
|
|
|
|
|
model.addAttribute("userName", userSession.getDispayName()); |
|
|
|
model.addAttribute("counter", userSession.getCounter()); |
|
|
|
model.addAttribute("counterName", userSession.getCounterName()); |
|
|
|
for (Map<String, Object> row : bookingPast) { |
|
|
|
|
|
|
|
// Fetch all past bookings |
|
|
|
List<Map<String, Object>> bookingPast = bookingService.getAllBookingEventsByUserId(userId); |
|
|
|
Integer bookingId = (Integer) row.get("booking_id"); |
|
|
|
String refId = (String) row.get("booking_ref_id"); // <-- coming from SQL |
|
|
|
|
|
|
|
// Extract booking_ref_id per booking |
|
|
|
Map<Integer, String> refIdMap = new HashMap<>(); |
|
|
|
|
|
|
|
for (Map<String, Object> row : bookingPast) { |
|
|
|
|
|
|
|
Integer bookingId = (Integer) row.get("booking_id"); |
|
|
|
String refId = (String) row.get("booking_ref_id"); // <-- coming from SQL |
|
|
|
|
|
|
|
if (bookingId != null && refId != null) { |
|
|
|
refIdMap.put(bookingId, refId); |
|
|
|
if (bookingId != null && refId != null) { |
|
|
|
refIdMap.put(bookingId, refId); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
System.out.println("Row keys: " + bookingPast.get(0).keySet()); |
|
|
|
System.out.println("RefId Map123: " + refIdMap); |
|
|
|
|
|
|
|
model.addAttribute("userBookingspast", bookingPast); |
|
|
|
model.addAttribute("bookingRefIds", refIdMap); // <-- SENT TO FRONTEND |
|
|
|
model.addAttribute("serverDate", LocalDate.now().toString()); |
|
|
|
|
|
|
|
return "user/viewhistory"; |
|
|
|
} |
|
|
|
System.out.println("Row keys: " + bookingPast.get(0).keySet()); |
|
|
|
System.out.println("RefId Map123: " + refIdMap); |
|
|
|
|
|
|
|
model.addAttribute("userBookingspast", bookingPast); |
|
|
|
model.addAttribute("bookingRefIds", refIdMap); // <-- SENT TO FRONTEND |
|
|
|
model.addAttribute("serverDate", LocalDate.now().toString()); |
|
|
|
|
|
|
|
return "user/viewhistory"; |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/CommunityHallList") |
|
|
|
public String viewhalllist(Model model) { |
|
|
|
@ -397,10 +416,9 @@ public String viewBookingDetails(Model model, |
|
|
|
public String viewhallform(Model model) { |
|
|
|
String username = userSession.getDispayName(); |
|
|
|
model.addAttribute("userName", username); |
|
|
|
model.addAttribute("serverDate", LocalDate.now().toString()); //for server date |
|
|
|
model.addAttribute("serverDate", LocalDate.now().toString()); // for server date |
|
|
|
return "user/viewhallform"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |