feat: manually create customer access link for offer and update status
addresses #869eea8d7
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\Admin\AccommodationBooking;
|
||||
|
||||
use App\Entity\Groups\AccommodationBooking;
|
||||
use App\Htmx\HxRedirectResponse;
|
||||
use App\Service\AccommodationBookingService;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
#[IsGranted('ROLE_GROUPS_MANAGER')]
|
||||
class GenerateAccessLinkController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly AccommodationBookingService $bookingService,
|
||||
private readonly LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/admin/accommodation-booking/{id}/generate-access-link', name: 'app_admin_accommodationbooking_generate_access_link')]
|
||||
public function index(AccommodationBooking $booking, Request $request): Response
|
||||
{
|
||||
// Same guard as sendOffer() — only a booking still waiting for its offer can have a
|
||||
// link generated for it.
|
||||
if (!$booking->isDraft() && !$booking->isRequested()) {
|
||||
return $this->redirectToRoute('app_admin_accommodationbooking_show', ['id' => $booking->getId()]);
|
||||
}
|
||||
|
||||
if ($request->isMethod(Request::METHOD_POST)) {
|
||||
if (!$this->isCsrfTokenValid('generate_access_link_accommodation_booking_'.$booking->getId(), $request->request->getString('_token'))) {
|
||||
throw $this->createAccessDeniedException('Invalid CSRF token.');
|
||||
}
|
||||
|
||||
$this->bookingService->generateAccessLink($booking);
|
||||
|
||||
$this->addFlash('success', 'Der Zugangslink wurde erzeugt. Die Buchung ist jetzt offen und wartet auf die Annahme durch den Kunden.');
|
||||
|
||||
$this->logger->info('Manually generated accommodation booking access link', [
|
||||
'id' => $booking->getId(),
|
||||
]);
|
||||
|
||||
return new HxRedirectResponse($this->generateUrl('app_admin_accommodationbooking_show', ['id' => $booking->getId()]));
|
||||
}
|
||||
|
||||
return $this->render('admin/accommodation_booking/modal_generate_access_link.html.twig', [
|
||||
'booking' => $booking,
|
||||
'csrf_token_id' => 'generate_access_link_accommodation_booking_'.$booking->getId(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -534,6 +534,22 @@ class AccommodationBookingService
|
||||
$this->sendCustomerConfirmationEmail($booking);
|
||||
}
|
||||
|
||||
/**
|
||||
* Publishes the offer the same way sendOffer() does — same guard, same transition into
|
||||
* Offen, same issued link — but for staff handing the link to the customer themselves
|
||||
* instead of through the automated mail. No email side effect.
|
||||
*/
|
||||
public function generateAccessLink(AccommodationBooking $booking): void
|
||||
{
|
||||
if (!$booking->isDraft() && !$booking->isRequested()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$booking->setStatus(AccommodationBookingStatus::Open);
|
||||
$this->issueAccessLink($booking);
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves a draft to another Gruppenhaus, for the case where the wrong one was picked at
|
||||
* creation. The chosen Verpflegung and Zusatzleistungen belong to the old house's catalog —
|
||||
|
||||
Reference in New Issue
Block a user