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;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.HashMap;
@ -49,7 +48,6 @@ public class UserController {
@Autowired
private HallDetailService hallDetailsService;
@Autowired
private UserService userService;
@ -82,7 +80,8 @@ 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());
@ -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);
@ -229,14 +237,22 @@ public class UserController {
// 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);
}
@ -253,14 +269,16 @@ public class UserController {
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
@GetMapping("/acknowledgement")
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";
}
// ak
@PostMapping("/migrate-old-bookings")
@ResponseBody
@ -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,24 +321,29 @@ 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
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
@GetMapping("/viewhistory")
public String viewBookingDetails(Model model,
@ -359,8 +380,6 @@ public String viewBookingDetails(Model model,
return "user/viewhistory";
}
@GetMapping("/CommunityHallList")
public String viewhalllist(Model model) {
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>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head th:replace="~{fragments/head :: head}">
<style>
@media print {
@ -15,6 +16,7 @@
}
</style>
</head>
<body>
<div th:replace="~{fragments/Details :: div}"></div>
<script th:replace="~{fragments/script :: script}"></script>
@ -22,7 +24,7 @@
function printTables(bookingId) {
$.ajax({
type: "GET",
url: '/communityhall/user/acknowledgement',
url: '/communityhall/user/acknowledgementwithoutrefid',
data: { bookingId: bookingId },
success: function (bodyMessage) {
exportLicToPDF(bodyMessage, bookingId);
@ -113,4 +115,5 @@
}
</script>
</body>
</html>
Loading…
Cancel
Save