diff --git a/app/config/routing/admin_event.yml b/app/config/routing/admin_event.yml index 6c9d756b3..fee64e9ab 100644 --- a/app/config/routing/admin_event.yml +++ b/app/config/routing/admin_event.yml @@ -61,6 +61,12 @@ admin_event_special_price: path: /special_price defaults: {_controller: AppBundle\Controller\Admin\Event\SpecialPriceAction} +admin_event_special_price_extend: + path: /special_price/{id}/extend + defaults: {_controller: AppBundle\Controller\Admin\Event\ExtendSpecialPriceAction} + requirements: + id: \d+ + admin_event_prices: path: /prices defaults: {_controller: AppBundle\Controller\Admin\Event\PricesAction } diff --git a/sources/AppBundle/Controller/Admin/Event/ExtendSpecialPriceAction.php b/sources/AppBundle/Controller/Admin/Event/ExtendSpecialPriceAction.php new file mode 100644 index 000000000..f52a2bc43 --- /dev/null +++ b/sources/AppBundle/Controller/Admin/Event/ExtendSpecialPriceAction.php @@ -0,0 +1,39 @@ +ticketSpecialPriceRepository->get($id); + + if (!$specialPrice instanceof TicketSpecialPrice) { + throw $this->createNotFoundException(); + } + + $newDateEnd = clone $specialPrice->getDateEnd(); + $newDateEnd->modify(sprintf('+%d days', SpecialPriceAction::EXTEND_DAYS)); + $specialPrice->setDateEnd($newDateEnd); + + $this->ticketSpecialPriceRepository->save($specialPrice); + + $this->addFlash('notice', sprintf('La validité du token a été prolongée de %d jours.', SpecialPriceAction::EXTEND_DAYS)); + + return $this->redirectToRoute('admin_event_special_price', [ + 'id' => $eventSelection->event->getId(), + ]); + } +} diff --git a/sources/AppBundle/Controller/Admin/Event/SpecialPriceAction.php b/sources/AppBundle/Controller/Admin/Event/SpecialPriceAction.php index 9a30a8c7f..3ca87b934 100644 --- a/sources/AppBundle/Controller/Admin/Event/SpecialPriceAction.php +++ b/sources/AppBundle/Controller/Admin/Event/SpecialPriceAction.php @@ -16,6 +16,8 @@ class SpecialPriceAction extends AbstractController { + public const EXTEND_DAYS = 3; // jours + public function __construct( private readonly TicketSpecialPriceRepository $ticketSpecialPriceRepository, private readonly Authentication $authentication, @@ -53,6 +55,7 @@ public function __invoke(Request $request, AdminEventSelection $eventSelection): 'title' => 'Gestion des prix custom', 'form' => $form->createView(), 'event_select_form' => $eventSelection->selectForm(), + 'extend_days' => self::EXTEND_DAYS, ]); } } diff --git a/sources/AppBundle/Event/Model/Repository/TicketSpecialPriceRepository.php b/sources/AppBundle/Event/Model/Repository/TicketSpecialPriceRepository.php index 732c86652..92514c2fb 100644 --- a/sources/AppBundle/Event/Model/Repository/TicketSpecialPriceRepository.php +++ b/sources/AppBundle/Event/Model/Repository/TicketSpecialPriceRepository.php @@ -80,6 +80,7 @@ public static function initMetadata(SerializerFactoryInterface $serializerFactor ->addField([ 'columnName' => 'id', 'fieldName' => 'id', + 'primary' => true, 'type' => 'int', ]) ->addField([ diff --git a/templates/admin/event/special_price.html.twig b/templates/admin/event/special_price.html.twig index 9a73c1517..1c3ce1341 100644 --- a/templates/admin/event/special_price.html.twig +++ b/templates/admin/event/special_price.html.twig @@ -15,6 +15,7 @@