Browse Source

modified for downloading pdf on acknowledgement page

master
AJITHKUMAR12 9 months ago
parent
commit
fe55d8550b
  1. 106
      src/main/java/com/gcc/communityHall/controller/UserController.java
  2. 5
      src/main/resources/templates/user/acknowledgement.html

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

@ -1,6 +1,5 @@
package com.gcc.communityHall.controller; package com.gcc.communityHall.controller;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -49,7 +48,6 @@ public class UserController {
@Autowired @Autowired
private HallDetailService hallDetailsService; private HallDetailService hallDetailsService;
@Autowired @Autowired
private UserService userService; private UserService userService;
@ -82,7 +80,8 @@ public class UserController {
for (Notification notification : newnotification) { for (Notification notification : newnotification) {
notificationText.append(notification.getNotification_description()); 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 // Pass the concatenated string to the model
model.addAttribute("newnotification", notificationText.toString()); model.addAttribute("newnotification", notificationText.toString());
model.addAttribute("userName", userSession.getDispayName()); model.addAttribute("userName", userSession.getDispayName());
@ -138,7 +137,8 @@ public class UserController {
} }
// Fetch calendar data based on provided parameters // 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<>(); HashSet<Integer> removeHallId = new HashSet<>();
// Collect hall IDs to be removed // Collect hall IDs to be removed
@ -151,16 +151,21 @@ public class UserController {
if (isSameDay) { if (isSameDay) {
// Same day booking cases // 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()); 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()); removeHallId.add(calendar.getHallId());
} else if (isMorningStart && isEveningEnd && } else if (isMorningStart && isEveningEnd &&
((calendar.getBdate().toString().equals(fromDate) && calendar.isMorningSlot()) || ((calendar.getBdate().toString().equals(fromDate) && calendar.isMorningSlot()) ||
(calendar.getBdate().toString().equals(toDate) && calendar.isEveningSlot()))) { (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()); removeHallId.add(calendar.getHallId());
} }
} else { } else {
@ -168,22 +173,26 @@ public class UserController {
if ((isMorningStart && isMorningEnd) && if ((isMorningStart && isMorningEnd) &&
((calendar.getBdate().toString().equals(fromDate) && calendar.isMorningSlot()) || ((calendar.getBdate().toString().equals(fromDate) && calendar.isMorningSlot()) ||
(calendar.getBdate().toString().equals(toDate) && 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()); removeHallId.add(calendar.getHallId());
} else if ((isEveningStart && isEveningEnd) && } else if ((isEveningStart && isEveningEnd) &&
((calendar.getBdate().toString().equals(fromDate) && calendar.isEveningSlot()) || ((calendar.getBdate().toString().equals(fromDate) && calendar.isEveningSlot()) ||
(calendar.getBdate().toString().equals(toDate) && 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()); removeHallId.add(calendar.getHallId());
} else if (isMorningStart && isEveningEnd && } else if (isMorningStart && isEveningEnd &&
((calendar.getBdate().toString().equals(fromDate) && calendar.isMorningSlot()) || ((calendar.getBdate().toString().equals(fromDate) && calendar.isMorningSlot()) ||
(calendar.getBdate().toString().equals(toDate) && calendar.isEveningSlot()))) { (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()); removeHallId.add(calendar.getHallId());
} else if (isEveningStart && isMorningEnd && } else if (isEveningStart && isMorningEnd &&
((calendar.getBdate().toString().equals(fromDate) && calendar.isEveningSlot()) || ((calendar.getBdate().toString().equals(fromDate) && calendar.isEveningSlot()) ||
(calendar.getBdate().toString().equals(toDate) && calendar.isMorningSlot()))) { (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()); removeHallId.add(calendar.getHallId());
} }
} }
@ -216,7 +225,6 @@ public class UserController {
return "user/dashboard"; return "user/dashboard";
} }
@PostMapping("/newregistrationform") @PostMapping("/newregistrationform")
public String showRegistrationForm(@ModelAttribute("newform") Users newform, Model model) { public String showRegistrationForm(@ModelAttribute("newform") Users newform, Model model) {
Users user = userService.user(newform); Users user = userService.user(newform);
@ -229,14 +237,22 @@ public class UserController {
// System.out.println("employee id"+user.getDepartment()); // System.out.println("employee id"+user.getDepartment());
if (user.getUsertype() == userType.PUBLIC) { if (user.getUsertype() == userType.PUBLIC) {
String registersms = "Welcome to GCC, Your User Registration for booking Community Centre is successful."; 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.sendMsg(registerwhatsupmsg);
whatsappMsgServiceImpl.sendSMS(registerurlString); whatsappMsgServiceImpl.sendSMS(registerurlString);
} else { } else {
String registerpendingsms = "Welcome to GCC, Your User Registration request for booking Community Centre is submitted successfully."; 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.sendMsg(registerpendingwhatsupmsg);
whatsappMsgServiceImpl.sendSMS(registerpendingurlString); whatsappMsgServiceImpl.sendSMS(registerpendingurlString);
} }
@ -253,14 +269,16 @@ public class UserController {
model.addAttribute("counterName", userSession.getCounterName()); model.addAttribute("counterName", userSession.getCounterName());
return "user/hallbookingform"; return "user/hallbookingform";
} }
// ak
/* @GetMapping("/acknowledgement")
@GetMapping("/acknowledgementwithoutrefid")
public String viewakowledgement(Model model, int bookingId) { public String viewakowledgement(Model model, int bookingId) {
BookingDetails bookingsDetails = bookingService.getBookingsById(bookingId); BookingDetails bookingsDetails = bookingService.getBookingsById(bookingId);
model.addAttribute("bookingsDetails", bookingsDetails); // Add single BookingDetails object model.addAttribute("bookingsDetails", bookingsDetails); // Add single BookingDetails object
model.addAttribute("userName", userSession.getDispayName()); model.addAttribute("userName", userSession.getDispayName());
return "user/acknowledgement"; return "user/acknowledgement";
}*/
}
// ak // ak
@GetMapping("/acknowledgement") @GetMapping("/acknowledgement")
public String viewAcknowledgement(@RequestParam("ref_id") String refId, Model model) { public String viewAcknowledgement(@RequestParam("ref_id") String refId, Model model) {
@ -278,6 +296,7 @@ public String viewAcknowledgement(@RequestParam("ref_id") String refId, Model mo
return "user/acknowledgement"; return "user/acknowledgement";
} }
// ak // ak
@PostMapping("/migrate-old-bookings") @PostMapping("/migrate-old-bookings")
@ResponseBody @ResponseBody
@ -292,9 +311,6 @@ public String viewAcknowledgement(@RequestParam("ref_id") String refId, Model mo
} }
} }
@GetMapping("/logout") @GetMapping("/logout")
public String logout(Model model) { public String logout(Model model) {
// Clear all login session (Check API Controller /gcc-login) // Clear all login session (Check API Controller /gcc-login)
@ -305,24 +321,29 @@ public String viewAcknowledgement(@RequestParam("ref_id") String refId, Model mo
return "redirect:/communityhall/user/dashboard"; return "redirect:/communityhall/user/dashboard";
} }
/*@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";
}*/
/*
* @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 // ak
@GetMapping("/viewhistory") @GetMapping("/viewhistory")
public String viewBookingDetails(Model model, public String viewBookingDetails(Model model,
@ -359,8 +380,6 @@ public String viewBookingDetails(Model model,
return "user/viewhistory"; return "user/viewhistory";
} }
@GetMapping("/CommunityHallList") @GetMapping("/CommunityHallList")
public String viewhalllist(Model model) { public String viewhalllist(Model model) {
model.addAttribute("userName", userSession.getDispayName()); model.addAttribute("userName", userSession.getDispayName());
@ -402,5 +421,4 @@ public String viewBookingDetails(Model model,
} }
} }

5
src/main/resources/templates/user/acknowledgement.html

@ -1,5 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml"> <html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head th:replace="~{fragments/head :: head}"> <head th:replace="~{fragments/head :: head}">
<style> <style>
@media print { @media print {
@ -15,6 +16,7 @@
} }
</style> </style>
</head> </head>
<body> <body>
<div th:replace="~{fragments/Details :: div}"></div> <div th:replace="~{fragments/Details :: div}"></div>
<script th:replace="~{fragments/script :: script}"></script> <script th:replace="~{fragments/script :: script}"></script>
@ -22,7 +24,7 @@
function printTables(bookingId) { function printTables(bookingId) {
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: '/communityhall/user/acknowledgement',
url: '/communityhall/user/acknowledgementwithoutrefid',
data: { bookingId: bookingId }, data: { bookingId: bookingId },
success: function (bodyMessage) { success: function (bodyMessage) {
exportLicToPDF(bodyMessage, bookingId); exportLicToPDF(bodyMessage, bookingId);
@ -113,4 +115,5 @@
} }
</script> </script>
</body> </body>
</html> </html>
Loading…
Cancel
Save