35 lines
1.3 KiB
PHP
35 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Controller\Admin\AccommodationBooking;
|
|
|
|
use App\Entity\Groups\AccommodationBooking;
|
|
use App\Service\AccommodationBookingPdfGenerator;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\Routing\Attribute\Route;
|
|
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
|
|
|
#[IsGranted('ROLE_GROUPS_MANAGER')]
|
|
class PdfController extends AbstractController
|
|
{
|
|
public function __construct(private readonly AccommodationBookingPdfGenerator $pdfGenerator)
|
|
{
|
|
}
|
|
|
|
#[Route('/admin/accommodation-booking/{id}/pdf', name: 'app_admin_accommodationbooking_pdf')]
|
|
public function index(AccommodationBooking $booking): Response
|
|
{
|
|
// Offered in every status, so the office can check the document before it goes out
|
|
// with the confirmation email; it labels itself Angebot or Buchung accordingly.
|
|
try {
|
|
return $this->pdfGenerator->createDownloadResponse($booking);
|
|
} catch (\RuntimeException $e) {
|
|
$this->addFlash('warning', 'Das PDF konnte nicht erstellt werden: '.$e->getMessage());
|
|
|
|
return $this->redirectToRoute('app_admin_accommodationbooking_show', ['id' => $booking->getId()]);
|
|
}
|
|
}
|
|
}
|