Browse Source

Counter Detailed Report added for admin and HQ login

master
kanimozhi 1 year ago
parent
commit
d66445f20d
  1. 85
      src/main/java/com/gcc/communityHall/controller/AdminAPIController.java
  2. 28
      src/main/java/com/gcc/communityHall/controller/Admincontroller.java
  3. 366
      src/main/java/com/gcc/communityHall/controller/HeadquartersController.java
  4. 58
      src/main/java/com/gcc/communityHall/repository/BookingDetailsRepository.java
  5. 5
      src/main/java/com/gcc/communityHall/service/BookingService.java
  6. 17
      src/main/java/com/gcc/communityHall/service/Impl/BookingServiceImpl.java
  7. 133
      src/main/resources/templates/admin/reports.html
  8. 703
      src/main/resources/templates/headquarters/reports.html
  9. 2
      src/main/resources/templates/user/viewhistory.html

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

@ -250,10 +250,10 @@ public class AdminAPIController {
hallDetailService.updateHallDetail(hallDetails, images);
String adminname = (String) session.getAttribute("usertype");
Integer loginid = (Integer) session.getAttribute("id");
ApplicationLogs logs=new ApplicationLogs();
ApplicationLogs logs = new ApplicationLogs();
logs.setComments("Action by " + adminname);
logs.setLoginId(loginid);
logs.setLogType("Hall Details edit:-"+hallName);
logs.setLogType("Hall Details edit:-" + hallName);
InetAddress inetAddress;
try {
inetAddress = InetAddress.getLocalHost();
@ -307,10 +307,10 @@ public class AdminAPIController {
Settlement updateInitialiseSettlement = settlementService.updateSettlementStatus(settlementId, status, comments);
String adminname = (String) session.getAttribute("usertype");
Integer loginid = (Integer) session.getAttribute("id");
ApplicationLogs logs=new ApplicationLogs();
ApplicationLogs logs = new ApplicationLogs();
logs.setComments("Action by " + adminname);
logs.setLoginId(loginid);
logs.setLogType("Settlement Initiation:-"+status);
logs.setLogType("Settlement Initiation:-" + status);
InetAddress inetAddress;
try {
inetAddress = InetAddress.getLocalHost();
@ -322,11 +322,12 @@ public class AdminAPIController {
}
applicationLogsRepository.save(logs);
if (updateInitialiseSettlement != null) {
return new ResponseEntity<>(updateInitialiseSettlement , HttpStatus.OK);
return new ResponseEntity<>(updateInitialiseSettlement, HttpStatus.OK);
} else {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
}
@Operation(
summary = "HallDetails by HallId REST API",
description = "REST API to Retrieving the Hall Details by hallId"
@ -407,10 +408,10 @@ public class AdminAPIController {
newnotification.setDelete(false);
notificationRepo.save(newnotification);
Integer loginid = (Integer) session.getAttribute("id");
ApplicationLogs logs=new ApplicationLogs();
ApplicationLogs logs = new ApplicationLogs();
logs.setComments("Action by " + adminname);
logs.setLoginId(loginid);
logs.setLogType("Added New Notification:-"+newnotification.getNotification_description());
logs.setLogType("Added New Notification:-" + newnotification.getNotification_description());
InetAddress inetAddress;
try {
inetAddress = InetAddress.getLocalHost();
@ -439,10 +440,10 @@ public class AdminAPIController {
updatediscount.setcDate(LocalDate.now());
discountRangeRepo.save(updatediscount);
Integer loginid = (Integer) session.getAttribute("id");
ApplicationLogs logs=new ApplicationLogs();
ApplicationLogs logs = new ApplicationLogs();
logs.setComments("Action by " + adminname);
logs.setLoginId(loginid);
logs.setLogType("Discount Details Update:-"+updatediscount.getUsertype());
logs.setLogType("Discount Details Update:-" + updatediscount.getUsertype());
InetAddress inetAddress;
try {
inetAddress = InetAddress.getLocalHost();
@ -470,10 +471,10 @@ public class AdminAPIController {
discountRangeRepo.deleteById(id);
String adminname = (String) session.getAttribute("usertype");
Integer loginid = (Integer) session.getAttribute("id");
ApplicationLogs logs=new ApplicationLogs();
ApplicationLogs logs = new ApplicationLogs();
logs.setComments("Action by " + adminname);
logs.setLoginId(loginid);
logs.setLogType("Discount Details Delete:-"+id);
logs.setLogType("Discount Details Delete:-" + id);
InetAddress inetAddress;
try {
inetAddress = InetAddress.getLocalHost();
@ -491,9 +492,9 @@ public class AdminAPIController {
}
@PostMapping("/deletenotificationById/{id}")
public ResponseEntity<String> deleteNotificationById(@PathVariable int id,HttpSession session) {
Optional<Notification> notification=notificationRepo.findById(id);
Notification newnotification=notification.get();
public ResponseEntity<String> deleteNotificationById(@PathVariable int id, HttpSession session) {
Optional<Notification> notification = notificationRepo.findById(id);
Notification newnotification = notification.get();
newnotification.setActive(false);
newnotification.setDelete(true);
String adminname = (String) session.getAttribute("usertype");
@ -502,10 +503,10 @@ public class AdminAPIController {
newnotification.setUpdatedDate(date);
notificationRepo.save(newnotification);
Integer loginid = (Integer) session.getAttribute("id");
ApplicationLogs logs=new ApplicationLogs();
ApplicationLogs logs = new ApplicationLogs();
logs.setComments("Action by " + adminname);
logs.setLoginId(loginid);
logs.setLogType("Detele Notification:-"+newnotification.getNotification_description());
logs.setLogType("Detele Notification:-" + newnotification.getNotification_description());
InetAddress inetAddress;
try {
inetAddress = InetAddress.getLocalHost();
@ -527,7 +528,7 @@ public class AdminAPIController {
//Retrieving the Discount Details
@GetMapping("/getDiscountDetails")
public Optional<DiscountRange> getDIscountDetails(@RequestParam("id") int id) {
Optional<DiscountRange> discountdetails =discountRangeRepo.findById(id);
Optional<DiscountRange> discountdetails = discountRangeRepo.findById(id);
return discountdetails;
}
@ -537,7 +538,7 @@ public class AdminAPIController {
)
//saving the Reason
@PostMapping("/saveReason")
public ResponseEntity<?> saveReason(@RequestBody ReasonMaster reasaon){
public ResponseEntity<?> saveReason(@RequestBody ReasonMaster reasaon) {
return ResponseEntity.ok(reasonMasterService.saveTheReason(reasaon));
}
@ -551,6 +552,7 @@ public class AdminAPIController {
public List<ReasonMaster> getAllReasons() {
return reasonMasterService.getAllReasons();
}
@Operation(
summary = "Reason Documents by reasonId REST API",
description = "REST API to Get the ReasonDocuments By reasonId"
@ -600,7 +602,6 @@ public class AdminAPIController {
}
@Operation(
summary = " GCC Blocked Booking Details REST API",
description = "REST API to get the GCC Blocked BookingDetails"
@ -630,7 +631,6 @@ public class AdminAPIController {
}
@Operation(
summary = "UNBLOCK the gcc Blocked Event REST API",
description = "REST API to unblocking the Gcc blocked Events for blocking"
@ -694,10 +694,10 @@ public class AdminAPIController {
}
String adminname = (String) session.getAttribute("usertype");
Integer loginid = (Integer) session.getAttribute("id");
ApplicationLogs logs=new ApplicationLogs();
ApplicationLogs logs = new ApplicationLogs();
logs.setComments("Action by " + adminname);
logs.setLoginId(loginid);
logs.setLogType("Gcc UnBlocking for the Id:-"+blockingDate.getBlockingId());
logs.setLogType("Gcc UnBlocking for the Id:-" + blockingDate.getBlockingId());
InetAddress inetAddress;
try {
inetAddress = InetAddress.getLocalHost();
@ -845,10 +845,10 @@ public class AdminAPIController {
bookingService.cancelAllBookings(fromDate, toDate, hallIdsList, reasonforblocking, selectedBookings, updatedBy, descriptions, documents);
String adminname = (String) session.getAttribute("usertype");
Integer loginid = (Integer) session.getAttribute("id");
ApplicationLogs logs=new ApplicationLogs();
ApplicationLogs logs = new ApplicationLogs();
logs.setComments("Action by " + adminname);
logs.setLoginId(loginid);
logs.setLogType("Gcc Blocking for the Reason:-"+reasonforblocking);
logs.setLogType("Gcc Blocking for the Reason:-" + reasonforblocking);
InetAddress inetAddress;
try {
inetAddress = InetAddress.getLocalHost();
@ -937,7 +937,7 @@ public class AdminAPIController {
// }
// }
// @GetMapping("/Gccblocking")
// @GetMapping("/Gccblocking")
// public ResponseEntity<List<Object>> getGccBlockingEvents(@RequestParam("hallId") int hallId) {
// System.out.println("Received hallId: " + hallId);
//
@ -953,6 +953,7 @@ public class AdminAPIController {
return ResponseEntity.ok(results);
}
@GetMapping("/getblockedbookingdetails")
public ResponseEntity<List<Map<String, Object>>> viewBlockedHallsByHallIdAndReason(
@RequestParam String hallIds,
@ -1100,8 +1101,8 @@ public class AdminAPIController {
//admin dashboard
@GetMapping("/bookingstatistics")
public ResponseEntity<Map<String, Map<String, Integer>>> getBookingStatistics(
@RequestParam (required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate fromDate,
@RequestParam (required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate toDate,
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate fromDate,
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate toDate,
@RequestParam(required = false, defaultValue = "ALL") String zone,
@RequestParam(required = false, defaultValue = "ALL") String division,
@RequestParam(required = false, defaultValue = "1000") Integer hallid,
@ -1117,9 +1118,8 @@ public class AdminAPIController {
}
@GetMapping("/getHallsDetailsByZone")
public ResponseEntity<Map<String, Object>> getHallsDetailsByZone( @RequestParam String zone)
{
Map<String, Object> hallzones=hallDetailService.getHallsDetailsByZone(zone);
public ResponseEntity<Map<String, Object>> getHallsDetailsByZone(@RequestParam String zone) {
Map<String, Object> hallzones = hallDetailService.getHallsDetailsByZone(zone);
// Debug log to verify the response before sending it to the client
// System.out.println("Response from getHallsDetailsByZone: " + hallzones);
return ResponseEntity.ok(hallzones);
@ -1162,6 +1162,7 @@ public class AdminAPIController {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(Collections.singletonMap("error", "Failed to update image"));
}
}
@DeleteMapping("/deleteHallImage/{hallImageId}")
public ResponseEntity<String> deleteHallImage(@PathVariable Integer hallImageId) {
try {
@ -1172,11 +1173,13 @@ public class AdminAPIController {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error deleting image.");
}
}
@GetMapping("/bookingdetailsByzone")
public ResponseEntity<List<BookingDetails>> getBookingDetailsByZone(@RequestParam String zone) {
List<BookingDetails> bookingDetails = bookingDetailsRepository.findByZone(zone);
return ResponseEntity.ok(bookingDetails);
}
@GetMapping("/divisionsByZone")
public List<String> getDivisionsByZone(@RequestParam("zoneId") String zoneId) {
// Use zoneId instead of zone
@ -1192,6 +1195,7 @@ public class AdminAPIController {
}
return new ResponseEntity<>(halls, HttpStatus.OK);
}
@PostMapping("/manualrefund")
public ResponseEntity<?> manualRefund(
@RequestParam int bookingId,
@ -1234,7 +1238,7 @@ public class AdminAPIController {
}
@GetMapping("/viewsettlement-complete")
@GetMapping("/viewsettlement-complete")
public ResponseEntity<Map<String, Object>> viewSettlementcompleteMaster(HttpSession session) {
List<BookingDetails> completedlist = bookingDetailsRepository.findAllwithCompletedRefundStatus();
@ -1276,7 +1280,7 @@ public class AdminAPIController {
return ResponseEntity.ok(response);
}
@GetMapping("/viewsettlement-initiated")
@GetMapping("/viewsettlement-initiated")
public ResponseEntity<Map<String, Object>> viewSettlementInitiateMaster(HttpSession session) {
List<BookingDetails> settlement = bookingDetailsRepository.findByBookingDetailsRefundStatus();
@ -1291,7 +1295,7 @@ public class AdminAPIController {
return ResponseEntity.ok(response);
}
@GetMapping("/user-pending")
@GetMapping("/user-pending")
public ResponseEntity<List<Users>> viewApproval() {
List<Users> pendingList = userRepository.getPendingList();
return new ResponseEntity<>(pendingList, HttpStatus.OK);
@ -1317,7 +1321,7 @@ public class AdminAPIController {
@GetMapping("/discountRange")
public ResponseEntity<List<DiscountRange>> getAllDiscountRanges() {
List<DiscountRange> discount= discountRangeRepo.findAll();
List<DiscountRange> discount = discountRangeRepo.findAll();
return ResponseEntity.ok(discount);
}
@ -1330,7 +1334,7 @@ public class AdminAPIController {
@RequestParam(name = "usertype", required = false) String usertype,
@RequestParam(name = "bookingStatus", required = false) String bookingStatus,
@RequestParam(name = "refundStatus", required = false) String refundStatus,
@RequestParam(name = "bookingId", required = false) Long bookingId){
@RequestParam(name = "bookingId", required = false) Long bookingId) {
Map<String, Object> response = new HashMap<>();
@ -1381,10 +1385,10 @@ public class AdminAPIController {
}
if (bookingStatus != null && !bookingStatus.isEmpty()) {
return bookingDetailsRepo.getAllBookingDetailsWithStatus(fromDate, toDate, bookingStatus);
} else if (bookingId != null){
} else if (bookingId != null) {
return bookingDetailsRepo.getAllBookingDetailsWithBookingId(fromDate, toDate, bookingId);
} else {
return bookingDetailsRepo.getAllBookingDetails(fromDate,toDate);
return bookingDetailsRepo.getAllBookingDetails(fromDate, toDate);
}
}
@ -1399,9 +1403,8 @@ public class AdminAPIController {
}
@GetMapping("/getHallDetailsById")
public ResponseEntity<List<Map<String, Object>>> getHallDetailsById(@RequestParam Integer hall_id)
{
List<Map<String, Object>> halldetails=bookingService.getHallDetailsForOfficer(hall_id);
public ResponseEntity<List<Map<String, Object>>> getHallDetailsById(@RequestParam Integer hall_id) {
List<Map<String, Object>> halldetails = bookingService.getHallDetailsForOfficer(hall_id);
return ResponseEntity.ok(halldetails);
}
@ -1450,6 +1453,7 @@ public class AdminAPIController {
List<Object[]> userDetails = userRepository.findUserDetailsByBookingDate(fromDate, toDate);
return ResponseEntity.ok(userDetails);
}
@GetMapping("/getPaymentswithRefunds")
public List<Object[]> getPaymentsWithRefunds(@RequestParam String startDate, @RequestParam String endDate) {
return userRepository.findPaymentsWithRefunds(startDate, endDate);
@ -1464,6 +1468,7 @@ public class AdminAPIController {
public List<Object[]> getPaymentsWithRefundsOnly(@RequestParam String startDate, @RequestParam String endDate) {
return userRepository.findPaymentsWithRefundsOnly(startDate, endDate);
}
@PostMapping("/send")
public ResponseEntity<Map<String, String>> sendMessage(@RequestBody Map<String, String> messagePayload) {
String userMessage = messagePayload.get("message");

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

@ -564,9 +564,11 @@ public class Admincontroller {
@RequestParam(name = "filterby", required = false) String filterby,
@RequestParam(name = "zone1", required = false, defaultValue = "ALL") String zone,
@RequestParam(name = "division1", required = false, defaultValue = "ALL") String division,
@RequestParam(name = "hall1", required = false, defaultValue = "1000") Integer hallid,
@RequestParam(name = "hall1", required = false) Integer hallid,
@RequestParam(name = "basedon", required = false) String basedon,
@RequestParam(name = "bookingId", required = false) Long bookingId, HttpSession session) throws JsonProcessingException {
@RequestParam(name = "bookingId", required = false) Long bookingId,
@RequestParam(name = "reporttype", required = false) String reporttype,
@RequestParam(name = "counterId", required = false) String counterId, HttpSession session) throws JsonProcessingException {
String adminname = (String) session.getAttribute("usertype");
if (adminname != null) {
long mobileno = (long) session.getAttribute("mobileno");
@ -621,20 +623,32 @@ public class Admincontroller {
model.addAttribute("totalBookings", totalBookings);
List<Object[]> hallbookingList = handleBookingHallDetailsReportRequest(request, fromDate, toDate, filterby, zone, division, hallid);
List<Object[]> counterBookingList = request.equals("9") ? bookingService.getCounterWiseBookingCount(fromDate, toDate) : new ArrayList<>();
model.addAttribute("counterBookingList",counterBookingList);
System.out.println("counterBookingList.."+counterBookingList);
if ("9".equals(request)) {
if("abstract".equals(reporttype)){
List<Object[]> counterBookingList = new ArrayList<>();
counterBookingList = bookingService.getCounterWiseBookingCount(fromDate, toDate);
model.addAttribute("counterBookingList", counterBookingList);
System.out.println("counterBookingList.." + counterBookingList);
List<Object[]> hallBookingByCounter = bookingService.getHallWiseBookingDetails(fromDate, toDate);
List<Object[]> hallBookingByCounter = bookingService.getHallWiseBookingDetails(fromDate, toDate, counterId);
// Convert to JSON for JS usage
String hallBookingJson = new ObjectMapper().writeValueAsString(hallBookingByCounter);
model.addAttribute("hallBookingJson", hallBookingJson);
List<Object[]> hallBookingDetails = bookingService.getBookingDetailsForAllHalls(fromDate, toDate);
List<Object[]> hallBookingDetails = bookingService.getBookingDetailsForAllHalls(fromDate, toDate, counterId, hallid);
String hallBookingDetailsJson = new ObjectMapper().writeValueAsString(hallBookingDetails);
model.addAttribute("hallBookingDetailsJson", hallBookingDetailsJson);
} else {
List<Object[]> counterBookingList = new ArrayList<>();
counterBookingList = bookingService.getCounterWiseBookingDetails(fromDate, toDate);
model.addAttribute("counterBookingList", counterBookingList);
}
model.addAttribute("reporttype", reporttype);
}
model.addAttribute("filterby", filterby);
model.addAttribute("users", userList);
model.addAttribute("bookings", bookingList);

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

@ -1,9 +1,12 @@
package com.gcc.communityHall.controller;
import java.util.*;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.gcc.communityHall.entity.GccBlockingDate;
import com.gcc.communityHall.others.AppConfig;
import com.gcc.communityHall.repository.GccBlockingDateRepository;
@ -60,7 +63,7 @@ public class HeadquartersController {
Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if(headquartersname != null) {
if (headquartersname != null) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
List<Map<String, Object>> getMonthCount = bookingDetailsRepository.getAllAdminmonthcount(zone);
@ -87,86 +90,85 @@ public class HeadquartersController {
@GetMapping("/Reports")
public String viewReports(Model model,HttpSession session)
{
public String viewReports(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if(headquartersname != null) {
if (headquartersname != null) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("headquartersname",headquartersname);
model.addAttribute("headquartersname", headquartersname);
return "headquarters/reports";
}else {
} else {
session.invalidate(); // Invalidate the session to clear all session attributes
return "redirect:/communityhall/login";
}
}
@GetMapping("/getReport")
public String getReports(Model model,HttpSession session)
{
public String getReports(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if(headquartersname != null) {
if (headquartersname != null) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("headquartersname",headquartersname);
model.addAttribute("headquartersname", headquartersname);
return "headquarters/reports";
}else {
} else {
session.invalidate(); // Invalidate the session to clear all session attributes
return "redirect:/communityhall/login";
}
}
@GetMapping("/approval-history")
public String viewApproval(Model model,HttpSession session) {
public String viewApproval(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if(headquartersname != null) {
if (headquartersname != null) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("headquartersname", headquartersname);
model.addAttribute("title", "approvalcontrol");
List<Users> Pending=usersRepository.getPendingList();
List<Users> Pending = usersRepository.getPendingList();
String zone = (String) session.getAttribute("zone");
model.addAttribute("zone", zone);
model.addAttribute("pendinglist",Pending);
model.addAttribute("pendinglist", Pending);
return "headquarters/approval-history";
}else {
} else {
session.invalidate(); // Invalidate the session to clear all session attributes
return "redirect:/communityhall/login";
}
}
@GetMapping("/user-approved")
public String viewUserApproved(Model model,HttpSession session){
public String viewUserApproved(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if(headquartersname != null) {
if (headquartersname != null) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("headquartersname", headquartersname);
model.addAttribute("title","reasondetails");
List<Users> approved= usersRepository.getUserApproved();
model.addAttribute("title", "reasondetails");
List<Users> approved = usersRepository.getUserApproved();
String zone = (String) session.getAttribute("zone");
model.addAttribute("zone", zone);
model.addAttribute("approvedlist",approved);
model.addAttribute("approvedlist", approved);
return "headquarters/user-approved";
}else {
} else {
session.invalidate(); // Invalidate the session to clear all session attributes
return "redirect:/communityhall/login";
}
}
@GetMapping("/user-reject")
public String viewUserReject(Model model,HttpSession session){
public String viewUserReject(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if(headquartersname != null) {
if (headquartersname != null) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("headquartersname", headquartersname);
model.addAttribute("title","reasondetails");
List<Users> reject= usersRepository.getUserReject();
model.addAttribute("title", "reasondetails");
List<Users> reject = usersRepository.getUserReject();
String zone = (String) session.getAttribute("zone");
model.addAttribute("zone", zone);
model.addAttribute("rejectedlist",reject);
model.addAttribute("rejectedlist", reject);
return "headquarters/user-reject";
}else {
} else {
session.invalidate(); // Invalidate the session to clear all session attributes
return "redirect:/communityhall/login";
}
@ -183,33 +185,35 @@ public class HeadquartersController {
@RequestParam(name = "refundStatus", required = false) String refundStatus,
@RequestParam(name = "paymentStatus", required = false) String paymentStatus,
@RequestParam(name = "filterby", required = false) String filterby,
@RequestParam(name = "zone1",required = false, defaultValue = "ALL") String zone,
@RequestParam(name = "division1",required = false, defaultValue = "ALL") String division,
@RequestParam(name = "hall1",required = false, defaultValue = "1000") Integer hallid,
@RequestParam(name = "zone1", required = false, defaultValue = "ALL") String zone,
@RequestParam(name = "division1", required = false, defaultValue = "ALL") String division,
@RequestParam(name = "hall1", required = false) Integer hallid,
@RequestParam(name = "basedon", required = false) String basedon,
@RequestParam(name = "bookingId", required = false) Long bookingId,HttpSession session) {
@RequestParam(name = "bookingId", required = false) Long bookingId,
@RequestParam(name = "reporttype", required = false) String reporttype,
@RequestParam(name = "counterId", required = false) String counterId, HttpSession session) throws JsonProcessingException {
String headquartersname = (String) session.getAttribute("usertype");
if(headquartersname != null) {
if (headquartersname != null) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
List<Users> userList = handleUserRequest(request, fromDate, toDate, userstatus, usertype);
List<Object[]> bookingList = handleBookingRequest(request, fromDate, toDate, bookingStatus, filterby,bookingId,zone,division,hallid);
List<BookingDetails> bookingSettlementList = handleBookingSettlementRequest(request, fromDate, toDate, refundStatus,filterby);
List<Object[]> bookingList = handleBookingRequest(request, fromDate, toDate, bookingStatus, filterby, bookingId, zone, division, hallid);
List<BookingDetails> bookingSettlementList = handleBookingSettlementRequest(request, fromDate, toDate, refundStatus, filterby);
//List<Object[]> paymentList = request.equals("3") ? bookingService.getAllPaymentsDetails(fromDate, toDate,zone,division,hallid) : new ArrayList<>();
List<Object[]> paymentList = new ArrayList<>();
List<Object[]> extrapaymentList = new ArrayList<>();
if (request.equals("3")) {
if (paymentStatus == null || paymentStatus.isEmpty()) {
paymentList = bookingService.getAllPaymentsDetails(fromDate, toDate, null,zone,division,hallid);
paymentList = bookingService.getAllPaymentsDetails(fromDate, toDate, null, zone, division, hallid);
} else {
paymentList = bookingService.getAllPaymentsDetails(fromDate, toDate, paymentStatus,zone,division,hallid);
paymentList = bookingService.getAllPaymentsDetails(fromDate, toDate, paymentStatus, zone, division, hallid);
}
}
if (request.equals("8")) {
if (paymentStatus == null || paymentStatus.isEmpty()) {
extrapaymentList = bookingService.getAllExtraPaymentsDetails(fromDate, toDate, null,zone,division,hallid);
extrapaymentList = bookingService.getAllExtraPaymentsDetails(fromDate, toDate, null, zone, division, hallid);
} else {
extrapaymentList = bookingService.getAllExtraPaymentsDetails(fromDate, toDate, paymentStatus,zone,division,hallid);
extrapaymentList = bookingService.getAllExtraPaymentsDetails(fromDate, toDate, paymentStatus, zone, division, hallid);
}
}
List<Object[]> userbookingList = request.equals("4") ? bookingService.getBookingUserDetailsReport(fromDate, toDate) : new ArrayList<>();
@ -223,13 +227,13 @@ public class HeadquartersController {
totalcount = bookingDetailsRepository.countBookingsByZone();
// Format zone data
totalcount = totalcount.stream()
.map(data -> new Object[] { "Zone-" + data[0], data[1] })
.map(data -> new Object[]{"Zone-" + data[0], data[1]})
.collect(Collectors.toList());
} else if ("division".equals(basedon)) {
totalcount = bookingDetailsRepository.countBookingsByDivisions();
// Format division data
totalcount = totalcount.stream()
.map(data -> new Object[] { "Division-" + data[0], data[1] })
.map(data -> new Object[]{"Division-" + data[0], data[1]})
.collect(Collectors.toList());
}
@ -240,8 +244,32 @@ public class HeadquartersController {
model.addAttribute("basedon", basedon);
model.addAttribute("totalcount", totalcount);
model.addAttribute("totalBookings", totalBookings);
List<Object[]> hallbookingList = handleBookingHallDetailsReportRequest(request, fromDate, toDate, filterby,zone,division,hallid);
List<Object[]> hallbookingList = handleBookingHallDetailsReportRequest(request, fromDate, toDate, filterby, zone, division, hallid);
if ("9".equals(request)) {
if("abstract".equals(reporttype)){
List<Object[]> counterBookingList = new ArrayList<>();
counterBookingList = bookingService.getCounterWiseBookingCount(fromDate, toDate);
model.addAttribute("counterBookingList", counterBookingList);
System.out.println("counterBookingList.." + counterBookingList);
List<Object[]> hallBookingByCounter = bookingService.getHallWiseBookingDetails(fromDate, toDate, counterId);
// Convert to JSON for JS usage
String hallBookingJson = new ObjectMapper().writeValueAsString(hallBookingByCounter);
model.addAttribute("hallBookingJson", hallBookingJson);
List<Object[]> hallBookingDetails = bookingService.getBookingDetailsForAllHalls(fromDate, toDate, counterId, hallid);
String hallBookingDetailsJson = new ObjectMapper().writeValueAsString(hallBookingDetails);
model.addAttribute("hallBookingDetailsJson", hallBookingDetailsJson);
} else {
List<Object[]> counterBookingList = new ArrayList<>();
counterBookingList = bookingService.getCounterWiseBookingDetails(fromDate, toDate);
model.addAttribute("counterBookingList", counterBookingList);
}
model.addAttribute("reporttype", reporttype);
}
model.addAttribute("filterby", filterby);
model.addAttribute("users", userList);
@ -266,31 +294,27 @@ public class HeadquartersController {
model.addAttribute("headquartersname", headquartersname);
return "headquarters/reports";
}else {
} else {
session.invalidate(); // Invalidate the session to clear all session attributes
return "redirect:/communityhall/login";
}
}
private List<Object[]> handleBookingHallDetailsReportRequest(String request, String fromDate, String toDate,String filterby,String zone,String division,Integer hallid)
{
private List<Object[]> handleBookingHallDetailsReportRequest(String request, String fromDate, String toDate, String filterby, String zone, String division, Integer hallid) {
if (!request.equals("5")) {
return new ArrayList<>();
}
if(filterby.isEmpty())
{
return bookingService.getBookingHallDetailsReportByBookingDate(fromDate, toDate,zone,division,hallid);
if (filterby.isEmpty()) {
return bookingService.getBookingHallDetailsReportByBookingDate(fromDate, toDate, zone, division, hallid);
}
if ("1".equals(filterby))
{
if ("1".equals(filterby)) {
return bookingService.getBookingHallDetailsReportByBookingDate(fromDate, toDate,zone,division,hallid);
return bookingService.getBookingHallDetailsReportByBookingDate(fromDate, toDate, zone, division, hallid);
}
if ("2".equals(filterby))
{
if ("2".equals(filterby)) {
return bookingService.getBookingHallDetailsReportByEventDate(fromDate, toDate,zone,division,hallid);
return bookingService.getBookingHallDetailsReportByEventDate(fromDate, toDate, zone, division, hallid);
}
@ -314,50 +338,37 @@ public class HeadquartersController {
}
private List<Object[]> handleBookingRequest(String request, String fromDate, String toDate, String bookingStatus, String filterby,Long bookingId,String zone,String division,Integer hallid) {
private List<Object[]> handleBookingRequest(String request, String fromDate, String toDate, String bookingStatus, String filterby, Long bookingId, String zone, String division, Integer hallid) {
if (!request.equals("2")) {
return new ArrayList<>();
}
if(filterby.isEmpty() && bookingStatus.isEmpty() && bookingId == null)
{
return bookingService.getBookingDetailsByBookingDate(fromDate, toDate,zone,division,hallid);
if (filterby.isEmpty() && bookingStatus.isEmpty() && bookingId == null) {
return bookingService.getBookingDetailsByBookingDate(fromDate, toDate, zone, division, hallid);
}
if(bookingId!=null && bookingStatus.isEmpty())
{
if (bookingId != null && bookingStatus.isEmpty()) {
return bookingDetailsRepo.getAllBookingDetailsWithBookingId(fromDate, toDate, bookingId);
}
if(bookingId!=null && !bookingStatus.isEmpty())
{
return bookingDetailsRepo.getAllBookingDetailsWithBookingIdwithbookingStatus(fromDate, toDate, bookingId,bookingStatus);
if (bookingId != null && !bookingStatus.isEmpty()) {
return bookingDetailsRepo.getAllBookingDetailsWithBookingIdwithbookingStatus(fromDate, toDate, bookingId, bookingStatus);
}
if(bookingId==null && filterby.isEmpty() && !bookingStatus.isEmpty())
{
return bookingService.getBookingDetailsByBookingDateWithStatus(fromDate, toDate, bookingStatus,zone,division,hallid);
if (bookingId == null && filterby.isEmpty() && !bookingStatus.isEmpty()) {
return bookingService.getBookingDetailsByBookingDateWithStatus(fromDate, toDate, bookingStatus, zone, division, hallid);
}
if(!filterby.isEmpty())
{
if (!filterby.isEmpty()) {
if ("1".equals(filterby))
{
if(bookingStatus.isEmpty())
{
return bookingService.getBookingDetailsByBookingDate(fromDate, toDate,zone,division,hallid);
}
else
{
return bookingService.getBookingDetailsByBookingDateWithStatus(fromDate, toDate, bookingStatus,zone,division,hallid);
if ("1".equals(filterby)) {
if (bookingStatus.isEmpty()) {
return bookingService.getBookingDetailsByBookingDate(fromDate, toDate, zone, division, hallid);
} else {
return bookingService.getBookingDetailsByBookingDateWithStatus(fromDate, toDate, bookingStatus, zone, division, hallid);
}
}
if ("2".equals(filterby))
{
if(bookingStatus.isEmpty())
{
return bookingService.getBookingDetailsByEventDate(fromDate, toDate,zone,division,hallid);
}
else {
return bookingService.getBookingDetailsByEventDateWithStatus(fromDate, toDate, bookingStatus,zone,division,hallid);
if ("2".equals(filterby)) {
if (bookingStatus.isEmpty()) {
return bookingService.getBookingDetailsByEventDate(fromDate, toDate, zone, division, hallid);
} else {
return bookingService.getBookingDetailsByEventDateWithStatus(fromDate, toDate, bookingStatus, zone, division, hallid);
}
}
@ -371,36 +382,26 @@ public class HeadquartersController {
if (!request.equals("6")) {
return new ArrayList<>();
}
if(filterby.isEmpty() && refundStatus.isEmpty())
{
if (filterby.isEmpty() && refundStatus.isEmpty()) {
return bookingService.getAllBookingsettlementDetailsByBookingDate(fromDate, toDate);
}
if(filterby.isEmpty() && !refundStatus.isEmpty())
{
if (filterby.isEmpty() && !refundStatus.isEmpty()) {
return bookingService.getAllBookingsettlementDetailsByBookingDateWithStatus(fromDate, toDate, refundStatus);
}
if(!filterby.isEmpty())
{
if (!filterby.isEmpty()) {
if ("1".equals(filterby))
{
if(refundStatus.isEmpty())
{
if ("1".equals(filterby)) {
if (refundStatus.isEmpty()) {
return bookingService.getAllBookingsettlementDetailsByBookingDate(fromDate, toDate);
}
else
{
} else {
return bookingService.getAllBookingsettlementDetailsByBookingDateWithStatus(fromDate, toDate, refundStatus);
}
}
if ("2".equals(filterby))
{
if(refundStatus.isEmpty())
{
if ("2".equals(filterby)) {
if (refundStatus.isEmpty()) {
return bookingService.getAllBookingsettlementDetailsByEventDate(fromDate, toDate);
}
else {
} else {
return bookingService.getAllBookingsettlementDetailsByEventDateWithStatus(fromDate, toDate, refundStatus);
}
@ -410,47 +411,48 @@ public class HeadquartersController {
// Handle default or error case
return new ArrayList<>();
}
@GetMapping("/ongoingevents")
public String viewRecentevents(Model model,HttpSession session) {
public String viewRecentevents(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if(headquartersname != null) {
if (headquartersname != null) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
List<BookingDetails> presenteventslist=bookingDetailsRepository.findPresentBookingList();
List<BookingDetails> pasteventslist=bookingDetailsRepository.findPastEventsList();
List<BookingDetails> futureeventslist=bookingDetailsRepository.findFutureEventsList();
model.addAttribute("title","settlement initiate");
List<BookingDetails> presenteventslist = bookingDetailsRepository.findPresentBookingList();
List<BookingDetails> pasteventslist = bookingDetailsRepository.findPastEventsList();
List<BookingDetails> futureeventslist = bookingDetailsRepository.findFutureEventsList();
model.addAttribute("title", "settlement initiate");
model.addAttribute("headquartersname", headquartersname);
model.addAttribute("presenteventslist",presenteventslist);
model.addAttribute("pasteventslist",pasteventslist);
model.addAttribute("futureeventslist",futureeventslist);
model.addAttribute("presenteventslist", presenteventslist);
model.addAttribute("pasteventslist", pasteventslist);
model.addAttribute("futureeventslist", futureeventslist);
return "headquarters/ongoingevents";
}else {
} else {
session.invalidate(); // Invalidate the session to clear all session attributes
return "redirect:/communityhall/login";
}
}
@GetMapping("/booking-list")
public String viewBookingList(Model model,HttpSession session) {
public String viewBookingList(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if(headquartersname != null) {
if (headquartersname != null) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("headquartersname", headquartersname);
List<BookingDetails> bookingList = bookingDetailsRepository.getAllApprovedList();
model.addAttribute("bookingList", bookingList);
return "headquarters/booking-list"; // Assuming "officer/rejected-booking-list" is the name of your HTML template
}else {
} else {
session.invalidate(); // Invalidate the session to clear all session attributes
return "redirect:/communityhall/login";
}
}
@GetMapping("/rejected-list")
public String viewRejectedBookings(Model model,HttpSession session) {
public String viewRejectedBookings(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if(headquartersname != null) {
if (headquartersname != null) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("headquartersname", headquartersname);
@ -458,16 +460,16 @@ public class HeadquartersController {
model.addAttribute("rejectedBookings", rejectedBookings);
return "headquarters/rejected-list";
}else {
} else {
session.invalidate(); // Invalidate the session to clear all session attributes
return "redirect:/communityhall/login";
}
}
@GetMapping("/bookingwaitinglist")
public String viewWaitingBookings(Model model,HttpSession session) {
public String viewWaitingBookings(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if(headquartersname != null) {
if (headquartersname != null) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("headquartersname", headquartersname);
@ -475,7 +477,7 @@ public class HeadquartersController {
model.addAttribute("waitingBookings", waitingBookings);
return "headquarters/bookingwaiting";
}else {
} else {
session.invalidate(); // Invalidate the session to clear all session attributes
return "redirect:/communityhall/login";
}
@ -484,108 +486,108 @@ public class HeadquartersController {
@GetMapping("/settlement-approved")
public String viewSettlementMaster(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if(headquartersname != null) {
if (headquartersname != null) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
List<BookingDetails> approvedSettlements = bookingDetailsRepository.findAllWithApprovedRefundStatus();
List<BookingDetails> settlements = new ArrayList<>();
settlements.addAll(approvedSettlements);
List<BookingDetails> approvedcancelledbookings=bookingDetailsRepository.findCancelledList();
List<BookingDetails> approvedrejectedbookings=bookingDetailsRepository.findRejectedList();
List<BookingDetails> approvedcancelledbookings = bookingDetailsRepository.findCancelledList();
List<BookingDetails> approvedrejectedbookings = bookingDetailsRepository.findRejectedList();
model.addAttribute("headquartersname", headquartersname);
model.addAttribute("settlementlist", settlements);
model.addAttribute("approvedcancelledbookings",approvedcancelledbookings);
model.addAttribute("approvedrejectedbookings",approvedrejectedbookings);
model.addAttribute("approvedcancelledbookings", approvedcancelledbookings);
model.addAttribute("approvedrejectedbookings", approvedrejectedbookings);
return "headquarters/settlement-approved";
}else {
} else {
session.invalidate(); // Invalidate the session to clear all session attributes
return "redirect:/communityhall/login";
}
}
@GetMapping("/settlement-initiatedlist")
public String viewSettlementInitiatedMaster(Model model,HttpSession session) {
public String viewSettlementInitiatedMaster(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if(headquartersname != null) {
if (headquartersname != null) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
List<BookingDetails> settlement=bookingDetailsRepository.findByBookingDetailsRefundStatus();
List<BookingDetails> Initiatedcancelledbookings=bookingDetailsRepository.findInitiatedCancelledList();
List<BookingDetails> Initiatedrejectedbookings=bookingDetailsRepository.findInitiatedRejectedList();
model.addAttribute("title","settlement initiate");
List<BookingDetails> settlement = bookingDetailsRepository.findByBookingDetailsRefundStatus();
List<BookingDetails> Initiatedcancelledbookings = bookingDetailsRepository.findInitiatedCancelledList();
List<BookingDetails> Initiatedrejectedbookings = bookingDetailsRepository.findInitiatedRejectedList();
model.addAttribute("title", "settlement initiate");
model.addAttribute("headquartersname", headquartersname);
model.addAttribute("settlementlist",settlement);
model.addAttribute("Initiatedcancelledbookings",Initiatedcancelledbookings);
model.addAttribute("Initiatedrejectedbookings",Initiatedrejectedbookings);
model.addAttribute("settlementlist", settlement);
model.addAttribute("Initiatedcancelledbookings", Initiatedcancelledbookings);
model.addAttribute("Initiatedrejectedbookings", Initiatedrejectedbookings);
return "headquarters/settlement-initiate";
}else {
} else {
session.invalidate(); // Invalidate the session to clear all session attributes
return "redirect:/communityhall/login";
}
}
@GetMapping("/settlement-list")
public String settlementPendingList(Model model,HttpSession session) {
public String settlementPendingList(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if(headquartersname!=null) {
if (headquartersname != null) {
model.addAttribute("headquartersname", headquartersname);
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("title","settlement Pending");
model.addAttribute("title", "settlement Pending");
String zone = (String) session.getAttribute("zone");
model.addAttribute("zone", zone);
List<BookingDetails> settlement=bookingDetailsRepository.findAllSettlementPending();
List<BookingDetails> cancelledbookings=bookingDetailsRepository.findAllSettlementCancelledList();
List<BookingDetails> rejectedbookings=bookingDetailsRepository.findAllSettlementRejectedList();
model.addAttribute("settlementlist",settlement);
model.addAttribute("cancelledbookings",cancelledbookings);
model.addAttribute("rejectedbookings",rejectedbookings);
List<BookingDetails> settlement = bookingDetailsRepository.findAllSettlementPending();
List<BookingDetails> cancelledbookings = bookingDetailsRepository.findAllSettlementCancelledList();
List<BookingDetails> rejectedbookings = bookingDetailsRepository.findAllSettlementRejectedList();
model.addAttribute("settlementlist", settlement);
model.addAttribute("cancelledbookings", cancelledbookings);
model.addAttribute("rejectedbookings", rejectedbookings);
return "headquarters/settlement-list";
}else {
} else {
session.invalidate();
return "redirect:/communityhall/login";
}
}
}
@GetMapping("/refundfailed-list")
public String RefundFailedList(Model model,HttpSession session) {
public String RefundFailedList(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if(headquartersname!=null) {
if (headquartersname != null) {
model.addAttribute("headquartersname", headquartersname);
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("title","settlementapproved");
model.addAttribute("title", "settlementapproved");
String zone = (String) session.getAttribute("zone");
model.addAttribute("zone", zone);
List<BookingDetails> settlementrefundfailed=bookingDetailsRepository.findAllSettlementRefundFailed();
List<BookingDetails> refundfailedcancelledbookings=bookingDetailsRepository.findAllRefundFaileCancelledList();
List<BookingDetails> refundfailedrejectedbookings=bookingDetailsRepository.findAllRefundFaileRejectedList();
model.addAttribute("settlementrefundfailed",settlementrefundfailed);
model.addAttribute("refundfailedcancelledbookings",refundfailedcancelledbookings);
model.addAttribute("refundfailedrejectedbookings",refundfailedrejectedbookings);
List<BookingDetails> settlementrefundfailed = bookingDetailsRepository.findAllSettlementRefundFailed();
List<BookingDetails> refundfailedcancelledbookings = bookingDetailsRepository.findAllRefundFaileCancelledList();
List<BookingDetails> refundfailedrejectedbookings = bookingDetailsRepository.findAllRefundFaileRejectedList();
model.addAttribute("settlementrefundfailed", settlementrefundfailed);
model.addAttribute("refundfailedcancelledbookings", refundfailedcancelledbookings);
model.addAttribute("refundfailedrejectedbookings", refundfailedrejectedbookings);
return "headquarters/refund-failedlist";
}
else {
} else {
session.invalidate();
return "redirect:/communityhall/login";
}
}
}
}
@GetMapping("/settlement-completedlist")
public String viewSettlementcompletedMaster(Model model,HttpSession session) {
public String viewSettlementcompletedMaster(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if(headquartersname != null) {
if (headquartersname != null) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
List<BookingDetails> completedlist=bookingDetailsRepository.findSettlementCompletedList();
List<BookingDetails> cancelledcompletedlist=bookingDetailsRepository.findCancelledCompletedList();
List<BookingDetails> rejectedcompletedlist=bookingDetailsRepository.findRejectedSettlementCompletedList();
model.addAttribute("title","settlement initiate");
List<BookingDetails> completedlist = bookingDetailsRepository.findSettlementCompletedList();
List<BookingDetails> cancelledcompletedlist = bookingDetailsRepository.findCancelledCompletedList();
List<BookingDetails> rejectedcompletedlist = bookingDetailsRepository.findRejectedSettlementCompletedList();
model.addAttribute("title", "settlement initiate");
model.addAttribute("headquartersname", headquartersname);
model.addAttribute("completedlist",completedlist);
model.addAttribute("cancelledcompletedlist",cancelledcompletedlist);
model.addAttribute("rejectedcompletedlist",rejectedcompletedlist);
model.addAttribute("completedlist", completedlist);
model.addAttribute("cancelledcompletedlist", cancelledcompletedlist);
model.addAttribute("rejectedcompletedlist", rejectedcompletedlist);
return "headquarters/settlement-completed";
}else {
} else {
session.invalidate(); // Invalidate the session to clear all session attributes
return "redirect:/communityhall/login";
}
@ -606,18 +608,18 @@ else {
}
@GetMapping("/headquarterspage")
public String viewcaretaker(Model model,HttpSession session,@RequestParam("bookingId") int bookingId) {
public String viewcaretaker(Model model, HttpSession session, @RequestParam("bookingId") int bookingId) {
String caretakerName = (String) session.getAttribute("usertype");
if(caretakerName!=null) {
if (caretakerName != null) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("caretakerName", caretakerName);
model.addAttribute("title","caretaker");
model.addAttribute("title", "caretaker");
model.addAttribute("baseURL", appConfig.getBaseUrl());
BookingDetails booking = bookingService.getBookingsById(bookingId);
model.addAttribute("booking",booking);
model.addAttribute("booking", booking);
return "headquarters/headquarterspage";
}else {
} else {
session.invalidate();
return "redirect:/communityhall/login";
}
@ -639,7 +641,7 @@ else {
}
@GetMapping("/logout")
public String viewLogout(Model model,HttpSession session) {
public String viewLogout(Model model, HttpSession session) {
session.invalidate();
return "redirect:/communityhall/login";
}
@ -647,7 +649,7 @@ else {
@GetMapping("/Gccblocking")
public String viewGccBlocking(Model model, HttpSession session) {
String headquartersname = (String) session.getAttribute("usertype");
if(headquartersname != null) {
if (headquartersname != null) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
model.addAttribute("headquartersname", headquartersname);
@ -682,7 +684,7 @@ else {
model.addAttribute("hallCountMap", hallCountMap);
return "headquarters/gccblocking";
}else {
} else {
session.invalidate(); // Invalidate the session to clear all session attributes
return "redirect:/communityhall/login";
}

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

@ -1434,14 +1434,20 @@ public interface BookingDetailsRepository extends JpaRepository<BookingDetails,
List<BookingDetails> getAllwaitingNOC();
@Query(value = "SELECT bd.counter_id, COUNT(*) AS total_count " +
@Query(value =
"SELECT bd.counter_id, COUNT(*) AS total_count " +
"FROM booking_details bd " +
"WHERE DATE(bd.booking_date) BETWEEN :fromDate AND :toDate " +
"AND bd.booking_status <> 'PENDING' " +
"AND bd.counter_id IS NOT NULL " +
"GROUP BY bd.counter_id", nativeQuery = true)
List<Object[]> getCounterWiseBookingCount(@Param("fromDate") String fromDate, @Param("toDate") String toDate);
"GROUP BY bd.counter_id",
nativeQuery = true)
List<Object[]> getCounterWiseBookingCount(
@Param("fromDate") String fromDate,
@Param("toDate") String toDate
);
@Query(value = "SELECT bd.counter_id, h.zone, h. division, h.hall_name, COUNT(*) as total_bookings " +
/*@Query(value = "SELECT bd.counter_id, h.zone, h. division, h.hall_name, COUNT(*) as total_bookings " +
"FROM booking_details bd " +
"JOIN hall_details h ON h.hall_id = bd.hall_details_hall_id " +
"WHERE DATE(bd.booking_date) BETWEEN :fromDate AND :toDate " +
@ -1457,6 +1463,48 @@ public interface BookingDetailsRepository extends JpaRepository<BookingDetails,
"JOIN hall_details h ON h.hall_id = bd.hall_details_hall_id " +
"WHERE DATE(bd.booking_date) BETWEEN :fromDate AND :toDate " +
"AND bd.counter_id IS NOT NULL", nativeQuery = true)
List<Object[]> getBookingDetailsForAllHalls(@Param("fromDate") String fromDate, @Param("toDate") String toDate);
List<Object[]> getBookingDetailsForAllHalls(@Param("fromDate") String fromDate, @Param("toDate") String toDate);*/
@Query(value =
"SELECT bd.counter_id, h.zone, h.division, h.hall_name, COUNT(*) AS total_bookings " +
"FROM booking_details bd " +
"JOIN hall_details h ON h.hall_id = bd.hall_details_hall_id " +
"WHERE DATE(bd.booking_date) BETWEEN :fromDate AND :toDate " +
"AND bd.counter_id IS NOT NULL " +
"AND bd.booking_status <> 'PENDING' " +
"AND (:counterId IS NULL OR bd.counter_id = :counterId) " +
"GROUP BY bd.counter_id, h.zone, h.division, h.hall_name",
nativeQuery = true)
List<Object[]> getHallWiseBookingDetails(
@Param("fromDate") String fromDate,
@Param("toDate") String toDate,
@Param("counterId") String counterId
);
@Query(value = " SELECT bd.booking_id, h.hall_name, bd.booking_date, bd.start_date, " +
"bd.end_date, bd.starting_slot, bd.ending_slot, bd.no_of_days, bd.reason, " +
"bd.amount_received, bd.hall_amount, bd.deposit_amount, bd.gst, bd.booking_status, " +
"bd.booking_type FROM booking_details bd " +
"JOIN hall_details h ON h.hall_id = bd.hall_details_hall_id " +
"WHERE DATE(bd.booking_date) BETWEEN :fromDate AND :toDate " +
"AND bd.counter_id IS NOT NULL " +
"AND ( :counterId IS NULL OR bd.counter_id = :counterId ) " +
"AND ( :hallid IS NULL OR bd.hall_details_hall_id = :hallid ) " +
"AND bd.booking_status <> 'PENDING' ", nativeQuery = true)
List<Object[]> getBookingDetailsForAllHalls(
@Param("fromDate") String fromDate,
@Param("toDate") String toDate,
@Param("counterId") String counterId,
@Param("hallid") Integer hallid
);
@Query(value = " SELECT bd.booking_id, h.hall_name, bd.booking_date, bd.start_date, " +
"bd.end_date, bd.starting_slot, bd.ending_slot, bd.no_of_days, bd.reason, " +
"bd.amount_received, bd.hall_amount, bd.deposit_amount, bd.gst, bd.booking_status, " +
"bd.booking_type, bd.counter_id FROM booking_details bd " +
"JOIN hall_details h ON h.hall_id = bd.hall_details_hall_id " +
"WHERE DATE(bd.booking_date) BETWEEN :fromDate AND :toDate " +
"AND bd.counter_id IS NOT NULL " +
"AND bd.booking_status <> 'PENDING' GROUP BY bd.counter_id, bd.booking_id ", nativeQuery = true)
List<Object[]> getCounterWiseBookingDetails(String fromDate, String toDate);
}

5
src/main/java/com/gcc/communityHall/service/BookingService.java

@ -207,8 +207,9 @@ public interface BookingService {
List<Object[]> getCounterWiseBookingCount(String fromDate, String toDate);
List<Object[]> getHallWiseBookingDetails(String fromDate, String toDate);
List<Object[]> getHallWiseBookingDetails(String fromDate, String toDate, String CounterId);
List<Object[]> getBookingDetailsForAllHalls(String fromDate, String toDate);
List<Object[]> getBookingDetailsForAllHalls(String fromDate, String toDate, String CounterId, Integer hallid);
List<Object[]> getCounterWiseBookingDetails(String fromDate, String toDate);
}

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

@ -2453,7 +2453,7 @@ public class BookingServiceImpl implements BookingService {
return bookingDetailsRepository.getCounterWiseBookingCount(fromDate, toDate);
}
@Override
/*@Override
public List<Object[]> getHallWiseBookingDetails(String fromDate, String toDate) {
return bookingDetailsRepository.getHallWiseBookingDetails(fromDate, toDate);
}
@ -2461,6 +2461,21 @@ public class BookingServiceImpl implements BookingService {
@Override
public List<Object[]> getBookingDetailsForAllHalls(String fromDate, String toDate){
return bookingDetailsRepository.getBookingDetailsForAllHalls(fromDate,toDate);
}*/
@Override
public List<Object[]> getHallWiseBookingDetails(String fromDate, String toDate, String counterId) {
return bookingDetailsRepository.getHallWiseBookingDetails(fromDate, toDate,counterId);
}
@Override
public List<Object[]> getBookingDetailsForAllHalls(String fromDate, String toDate, String counterId,Integer hallid){
return bookingDetailsRepository.getBookingDetailsForAllHalls(fromDate,toDate,counterId,hallid);
}
@Override
public List<Object[]> getCounterWiseBookingDetails(String fromDate, String toDate){
return bookingDetailsRepository.getCounterWiseBookingDetails(fromDate,toDate);
}
}

133
src/main/resources/templates/admin/reports.html

@ -131,7 +131,7 @@
</div>
<div class="col-sm-3 mb-2" id="bookingcountbasedonDropdown" style="display: none;">
<label class="form-label" for="basedon" >Based On: <span
<label class="form-label" for="basedon">Based On: <span
class="text-danger">*</span></label>
<select class="form-control text-center" id="basedon" name="basedon"
th:value="${basedon}">
@ -304,6 +304,20 @@
</select>
</div>
<div class="col-sm-3 mb-2" id="counterreportDropdown" style="display: none;">
<label class="form-label" for="reporttype">Report Type: <span
class="text-danger">*</span></label>
<select class="form-control text-center" id="reporttype" name="reporttype"
th:value="${reporttype}">
<option value="">Select</option>
<option value="abstract" th:selected="${reporttype == 'abstract'}">Abstract
</option>
<option value="detailed" th:selected="${reporttype == 'detailed'}">Detailed Report
</option>
</select>
<span id="reportTypeError" class="text-danger"></span>
</div>
<div class="col-sm-3">
<br>
@ -620,6 +634,7 @@
</div>
<!--<div class="table-responsive" id="countertable" th:if="${request == '9'}">-->
<div class="table-responsive" id="countertable" th:if="${request}==9">
<div th:if="${reporttype == 'abstract'}">
<table id="requestTable9" class="table table-striped table-bordered table-hover dataTable"
role="grid" width="99.5%">
<thead class="thead-dark">
@ -648,6 +663,61 @@
</tbody>
</table>
</div>
<div th:if="${reporttype == 'detailed'}">
<table id="detailedrequestTable" class="table table-striped table-bordered table-hover dataTable"
role="grid" width="99.5%">
<thead class="thead-dark">
<tr role="row">
<th>S.No</th>
<th>Booking ID</th>
<th>Hall Name</th>
<th>Booking Date</th>
<th>Start Date</th>
<th>End Date</th>
<th>Starting Slot</th>
<th>Ending Slot</th>
<th>No.of.Days</th>
<th>Reason for Booking</th>
<th>Hall Amount</th>
<th>Deposit Amount</th>
<th>GSt</th>
<th>Amount Received</th>
<th>Booking Status</th>
<th>Booking Type</th>
<th>Counter Id</th>
<th>View</th>
</tr>
</thead>
<tbody>
<tr th:each="counterdata, iterstat : ${counterBookingList}">
<td th:text="${iterstat.index + 1}"></td>
<td th:text="${counterdata[0]}"></td>
<td th:text="${counterdata[1]}"></td>
<td th:text="${counterdata[2]}"></td>
<td th:text="${counterdata[3]}"></td>
<td th:text="${counterdata[4]}"></td>
<td th:text="${counterdata[5]}"></td>
<td th:text="${counterdata[6]}"></td>
<td th:text="${counterdata[7]}"></td>
<td th:text="${counterdata[8]}"></td>
<td th:text="${counterdata[9]}"></td>
<td th:text="${counterdata[10]}"></td>
<td th:text="${counterdata[11]}"></td>
<td th:text="${counterdata[12]}"></td>
<td th:text="${counterdata[13]}"></td>
<td th:text="${counterdata[14]}"></td>
<td th:text="${counterdata[15]}"></td>
<td>
<p>
<span class="badge bg-warning" style="cursor: pointer;"
th:onclick="viewDetails([[${counterdata[0]}]])">View</span>
</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
@ -1487,6 +1557,9 @@
} else if (tableId === 'hallDetailsTable') {
orientation = 'landscape';
pageSize = 'A3';
} else if (tableId === 'detailedrequestTable') {
orientation = 'landscape';
pageSize = 'A3';
}
return [{
@ -1538,7 +1611,7 @@
});
// Tables with custom PDF buttons
['requestTable9', 'modalBookingTable', 'hallDetailsTable'].forEach(function (tableId) {
['requestTable9', 'modalBookingTable', 'hallDetailsTable', 'detailedrequestTable'].forEach(function (tableId) {
$('#' + tableId).DataTable({
dom: 'Bftip',
columnDefs: [{
@ -1610,7 +1683,7 @@
checkTodateCon();
});
function checkTodateCon(){
function checkTodateCon() {
var today = new Date();
var sixMonthsLater = new Date();
sixMonthsLater.setMonth(today.getMonth() + 6);
@ -1632,36 +1705,13 @@
}
// document.addEventListener("DOMContentLoaded", function () {
// const form = document.getElementById('myForm'); // Change selector if needed
// var requestValue = document.getElementById("request").value;
// if(requestValue ==="7"){
// console.log("inside 7");
// const basedonSelect = document.getElementById('basedon');
// const errorSpan = document.getElementById('basedonError');
//
// form.addEventListener("submit", function (event) {
// console.log("basedonSelect.value====="+basedonSelect.value);
// if (basedonSelect.value === "") {
// event.preventDefault(); // Stop form submission
// errorSpan.textContent = "Please select a value.";
// basedonSelect.classList.add("is-invalid"); // Optional: Bootstrap styling
// }
// else {
// errorSpan.textContent = "";
// basedonSelect.classList.remove("is-invalid");
// }
// });
// }
//
// });
document.addEventListener("DOMContentLoaded", function () {
const form = document.getElementById('myForm');
const basedonSelect = document.getElementById('basedon');
const errorSpan = document.getElementById('basedonError');
const request = document.getElementById('request');
const reportTypeSelect = document.getElementById('reporttype');
const reportTypeerror = document.getElementById('reportTypeError');
form.addEventListener("submit", function (event) {
const requestValue = request.value;
@ -1678,6 +1728,18 @@
errorSpan.textContent = "";
basedonSelect.classList.remove("is-invalid");
}
} else if (requestValue === "9") {
console.log("inside 9");
console.log("reportTypeSelect.value=====" + reportTypeSelect.value);
if (reportTypeSelect.value === "") {
event.preventDefault(); // Stop form submission
reportTypeerror.textContent = "Please select a value.";
reportTypeSelect.classList.add("is-invalid");
} else {
reportTypeerror.textContent = "";
reportTypeSelect.classList.remove("is-invalid");
}
}
});
@ -1685,10 +1747,13 @@
this.classList.remove("is-invalid");
document.getElementById("basedonError").textContent = "";
});
document.getElementById("reporttype").addEventListener("change", function () {
this.classList.remove("is-invalid");
document.getElementById("reportTypeError").textContent = "";
});
});
// Function to manage the display of dropdowns based on the request type
function myRequest() {
var requestValue = document.getElementById("request").value;
@ -1705,6 +1770,7 @@
document.getElementById("hallContainer").style.display = "none";
document.getElementById("bookingcountbasedonDropdown").style.display = "none";
document.getElementById("paymentInfoDropdown1").style.display = "none";
document.getElementById("counterreportDropdown").style.display = "none";
// Reset dropdown values
@ -1760,6 +1826,8 @@
document.getElementById("divisionContainer").style.display = "block";
document.getElementById("hallContainer").style.display = "block";
document.getElementById("paymentInfoDropdown1").style.display = "block";
} else if (requestValue === "9") {
document.getElementById("counterreportDropdown").style.display = "block";
}
}
@ -1771,6 +1839,13 @@
});
});
document.addEventListener("DOMContentLoaded", function () {
document.getElementById("reporttype").addEventListener("change", function () {
const selectedValue = this.value;
document.getElementById("counterreportDropdown").style.display = selectedValue ? "block" : "none";
});
});
// Function to reset date fields
function resetDate() {

703
src/main/resources/templates/headquarters/reports.html
File diff suppressed because it is too large
View File

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

@ -1362,7 +1362,7 @@
name="bookingId" required>
<label for="startDateInput" class="form-label">Start Date:</label>
<input type="text" class="form-control" id="startDateInput"
name="startDateInput" required>
name="startDateInput" required readonly>
<input type="hidden" class="form-control" id="startDatetext"
name="startDatetext" required>
</div>

Loading…
Cancel
Save