-
-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Admin] allow send national event tickets (#10233)
* [Admin] allow send national event tickets * Add search
- Loading branch information
Showing
19 changed files
with
575 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
final class Version20240517080738 extends AbstractMigration | ||
{ | ||
public function up(Schema $schema): void | ||
{ | ||
$this->addSql('ALTER TABLE | ||
national_event | ||
ADD | ||
subject_ticket_email VARCHAR(255) DEFAULT NULL, | ||
ADD | ||
image_ticket_email LONGTEXT DEFAULT NULL'); | ||
$this->addSql('ALTER TABLE national_event_inscription ADD ticket_qrcode_file VARCHAR(255) DEFAULT NULL'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
$this->addSql('ALTER TABLE national_event DROP subject_ticket_email, DROP image_ticket_email'); | ||
$this->addSql('ALTER TABLE national_event_inscription DROP ticket_qrcode_file'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
namespace App\Controller\Admin; | ||
|
||
use App\Entity\NationalEvent\NationalEvent; | ||
use App\NationalEvent\Command\GenerateTicketQRCodeCommand; | ||
use App\NationalEvent\Command\SendTicketCommand; | ||
use App\NationalEvent\InscriptionStatusEnum; | ||
use App\Repository\NationalEvent\EventInscriptionRepository; | ||
use Sonata\AdminBundle\Controller\CRUDController; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Messenger\MessageBusInterface; | ||
|
||
class AdminNationalEventCRUDController extends CRUDController | ||
{ | ||
public function inscriptionsAction(Request $request, NationalEvent $event, EventInscriptionRepository $eventInscriptionRepository): Response | ||
{ | ||
return $this->renderWithExtraParams('admin/national_event/inscriptions.html.twig', [ | ||
'national_event' => $event, | ||
'action' => 'inscriptions', | ||
'event_inscriptions' => $eventInscriptionRepository->findAllForEventPaginated( | ||
$event, | ||
$request->query->get('q'), | ||
$statuses = [InscriptionStatusEnum::ACCEPTED, InscriptionStatusEnum::INCONCLUSIVE], | ||
$request->query->getInt('page', 1), | ||
2 | ||
), | ||
'count_without_qrcodes' => $eventInscriptionRepository->countWithoutTicketQRCodes($event), | ||
'count_without_ticket' => $eventInscriptionRepository->countTickets($event, true, $statuses), | ||
'count_with_ticket' => $eventInscriptionRepository->countTickets($event, false, $statuses), | ||
'count_by_status' => $eventInscriptionRepository->countByStatus($event), | ||
]); | ||
} | ||
|
||
public function sendTicketsAction(Request $request, NationalEvent $event, EventInscriptionRepository $eventInscriptionRepository, MessageBusInterface $messageBus): Response | ||
{ | ||
$inscriptions = []; | ||
|
||
if ($request->query->has('all')) { | ||
$inscriptions = $eventInscriptionRepository->findAllPartialForEvent($event, [InscriptionStatusEnum::ACCEPTED, InscriptionStatusEnum::INCONCLUSIVE]); | ||
} elseif ($request->query->has('only_missing')) { | ||
$inscriptions = $eventInscriptionRepository->findAllPartialForEvent($event, [InscriptionStatusEnum::ACCEPTED, InscriptionStatusEnum::INCONCLUSIVE], true); | ||
} | ||
|
||
if ($inscriptions) { | ||
foreach ($inscriptions as $inscription) { | ||
$messageBus->dispatch(new SendTicketCommand($inscription->getUuid())); | ||
} | ||
|
||
$this->addFlash('sonata_flash_success', 'Les billets sont en cours d\'envoi.'); | ||
} else { | ||
$this->addFlash('sonata_flash_error', 'Aucun billet à envoyer.'); | ||
} | ||
|
||
return $this->redirect($this->admin->generateObjectUrl('inscriptions', $event)); | ||
} | ||
|
||
public function generateTicketQRCodesAction(NationalEvent $event, EventInscriptionRepository $eventInscriptionRepository, MessageBusInterface $messageBus): Response | ||
{ | ||
$inscriptions = $eventInscriptionRepository->findAllWithoutTickets($event); | ||
|
||
foreach ($inscriptions as $inscription) { | ||
$messageBus->dispatch(new GenerateTicketQRCodeCommand($inscription->getUuid())); | ||
} | ||
|
||
$this->addFlash('sonata_flash_success', 'Les codes QR des billets sont en cours de génération.'); | ||
|
||
return $this->redirect($this->admin->generateObjectUrl('inscriptions', $event)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace App\NationalEvent\Command; | ||
|
||
use App\Messenger\Message\UuidDefaultAsyncMessage; | ||
|
||
class GenerateTicketQRCodeCommand extends UuidDefaultAsyncMessage | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace App\NationalEvent\Command; | ||
|
||
use App\Messenger\Message\UuidDefaultAsyncMessage; | ||
|
||
class SendTicketCommand extends UuidDefaultAsyncMessage | ||
{ | ||
} |
Oops, something went wrong.