You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
126 lines
4.7 KiB
126 lines
4.7 KiB
package com.gcc.communityHall.controller;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import com.gcc.communityHall.entity.BookingDetails;
|
|
import com.gcc.communityHall.entity.BookingDetails.BookingStatus;
|
|
import com.gcc.communityHall.entity.CounterDetails;
|
|
import com.gcc.communityHall.entity.CounterRefundList;
|
|
import com.gcc.communityHall.entity.Users;
|
|
import com.gcc.communityHall.others.UserSession;
|
|
import com.gcc.communityHall.repository.BookingDetailsRepository;
|
|
import com.gcc.communityHall.repository.CounterDetailsRepository;
|
|
import com.gcc.communityHall.repository.CounterRefundListRepository;
|
|
import com.gcc.communityHall.service.BookingService;
|
|
import com.gcc.communityHall.service.CounterService;
|
|
import com.gcc.communityHall.service.UserService;
|
|
|
|
import jakarta.servlet.http.HttpSession;
|
|
|
|
@Controller
|
|
@RequestMapping("/counter")
|
|
public class CounterController {
|
|
|
|
@Autowired
|
|
private UserSession userSession;
|
|
|
|
@Autowired
|
|
private CounterDetailsRepository counterRepo;
|
|
|
|
@Autowired
|
|
private CounterService counterservice;
|
|
|
|
@Autowired
|
|
private BookingService bookser;
|
|
|
|
@Autowired
|
|
private UserService userService;
|
|
|
|
@Autowired
|
|
private BookingDetailsRepository bookingDetailsRepository;
|
|
|
|
@Autowired
|
|
private CounterRefundListRepository counterRefundRepository;
|
|
|
|
@GetMapping(value = {"","/","/counterbooking"})
|
|
public String viewcounter(Model model,HttpSession session) {
|
|
System.out.println("viewcounter");
|
|
String countername=(String) session.getAttribute("usertype");
|
|
model.addAttribute("countername", countername);
|
|
return "counter/counter-booking";
|
|
}
|
|
|
|
@GetMapping("/counterdetailslist")
|
|
public String viewcounterlist(Model model,HttpSession session) {
|
|
List<CounterDetails> counterlist= counterRepo.findAll();
|
|
String countername=(String) session.getAttribute("usertype");
|
|
model.addAttribute("countername", countername);
|
|
model.addAttribute("counterlist", counterlist);
|
|
return "counter/counter-list";
|
|
}
|
|
|
|
@PostMapping("/saveDDdetails")
|
|
public String saveDD(
|
|
@RequestParam String bankName,
|
|
@RequestParam int bankAccNo,
|
|
@RequestParam int ddNumber,
|
|
@RequestParam double amountReceived,
|
|
@RequestParam MultipartFile counterddphoto,
|
|
@RequestParam int bookingId) {
|
|
// Call the service method and pass the bookingId along with other parameters
|
|
String confirmBooking = bookser.confirmBooking(bookingId);
|
|
BookingDetails booking=new BookingDetails();
|
|
booking.setBookingStatus(BookingStatus.APPROVED);
|
|
if (confirmBooking.equals("Booking confirmed successfully")) {
|
|
// Perform additional actions if needed
|
|
}
|
|
bookingDetailsRepository.save(booking);
|
|
counterservice.saveCounterDetails(bankName, bankAccNo, ddNumber, amountReceived, counterddphoto, bookingId);
|
|
return "redirect:/counter/counterdetailslist";
|
|
}
|
|
|
|
@GetMapping("/bookinglist")
|
|
public String viewbookingpage(Model model,HttpSession session)
|
|
{
|
|
List<Map<String, Object>> bookinglists= bookser.getOfflineBookings();
|
|
|
|
model.addAttribute("bookinglist",bookinglists);
|
|
String countername=(String) session.getAttribute("usertype");
|
|
model.addAttribute("countername", countername);
|
|
|
|
return "counter/viewhistory";
|
|
}
|
|
@GetMapping("/refundinitialisation")
|
|
public String viewrefund(Model model,HttpSession session) {
|
|
List<CounterRefundList> counterRefundLists = counterRefundRepository.findAll();
|
|
model.addAttribute("counterRefundLists", counterRefundLists);
|
|
String countername=(String) session.getAttribute("usertype");
|
|
model.addAttribute("countername", countername);
|
|
return "counter/refund-initialisation";
|
|
}
|
|
@GetMapping("/calculateamount")
|
|
public String viewCalculate(Model model){
|
|
return "counter/calculate-hall-amount";
|
|
}
|
|
|
|
@GetMapping("/logout")
|
|
public String viewLogout(Model model,HttpSession session) {
|
|
session.invalidate();
|
|
return "redirect:/communityhall/login";
|
|
}
|
|
}
|
|
|