Linux SRV-16 6.18.44-paas #1 SMP PREEMPT_DYNAMIC Thu Aug 13 10:08:12 UTC 2026 x86_64
/
srv
/
data
/
web
/
vhosts
/
716cf56cb2.url-de-test.ws
/
htdocs
/
src
/
Controller
/
Back
/
/srv/data/web/vhosts/716cf56cb2.url-de-test.ws/htdocs/src/Controller/Back/BookingController.php
<?php namespace App\Controller\Back; use App\Form\BookingType; use App\Repository\BookingRepository; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Annotation\Route; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; /** * @Route("/admin/booking") */ class BookingController extends AbstractController { protected $em; protected $bookingRepository; public function __construct(EntityManagerInterface $em, BookingRepository $bookingRepository) { $this->em = $em; $this->bookingRepository = $bookingRepository; } /** * @Route("/", name="app_back_search_booking") */ public function index(Request $request) { $order = $request->query->get('order') ?: 'DESC'; $bookings = $this->bookingRepository->findBookingsNotImported($order); return $this->render("Back/Booking/search.html.twig", [ "bookings" => $bookings ]); } /** * @Route("/edit/{id}", name="app_back_edit_booking") */ public function edit(int $id, Request $request) { $booking = $this->bookingRepository->find($id); $form = $this->createForm(BookingType::class, $booking); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $this->em->persist($booking); $this->em->flush(); $this->addFlash('success', "Réservation modifié avec succès"); return $this->redirectToRoute("app_back_search_booking"); } return $this->render("Back/Booking/edit.html.twig", [ "form" => $form->createView() ]); } /** * @Route("/cancel/{id}", name="app_back_cancel_booking") */ public function cancel(int $id) { $booking = $this->bookingRepository->find($id); $booking->setIsCancel(true); $this->em->persist($booking); $this->em->flush(); $this->addFlash('success', 'La réservation à bien été annulée'); return $this->redirectToRoute("app_back_search_booking"); } }