diff --git a/migrations/Version20260321270000.php b/migrations/Version20260321270000.php new file mode 100644 index 0000000..5b5e5b5 --- /dev/null +++ b/migrations/Version20260321270000.php @@ -0,0 +1,26 @@ +addSql('ALTER TABLE billet_buyer ADD COLUMN IF NOT EXISTS is_invitation BOOLEAN DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE billet_buyer DROP COLUMN IF EXISTS is_invitation'); + } +} diff --git a/src/Controller/AccountController.php b/src/Controller/AccountController.php index 0d685f4..84879f1 100644 --- a/src/Controller/AccountController.php +++ b/src/Controller/AccountController.php @@ -408,7 +408,7 @@ class AccountController extends AbstractController 'commission_rate' => $user->getCommissionRate() ?? 0, 'billet_design' => $em->getRepository(BilletDesign::class)->findOneBy(['event' => $event]), 'event_orders' => $eventOrders, - 'invitations' => $em->getRepository(BilletBuyer::class)->findBy(['event' => $event, 'totalHT' => 0], ['createdAt' => 'DESC']), + 'invitations' => $em->getRepository(BilletBuyer::class)->findBy(['event' => $event, 'isInvitation' => true], ['createdAt' => 'DESC']), 'event_total_ht' => $eventTotalHT / 100, 'event_total_sold' => $eventTotalSold, 'event_total_orders' => \count($paidEventOrders), @@ -731,6 +731,7 @@ class AccountController extends AbstractController $order->setEmail($email); $order->setOrderNumber(date('Y-m-d').'-'.$count); $order->setTotalHT(0); + $order->setIsInvitation(true); foreach ($items as $itemData) { $billetId = (int) ($itemData['billet_id'] ?? 0); diff --git a/src/Entity/BilletBuyer.php b/src/Entity/BilletBuyer.php index aac7152..d41e640 100644 --- a/src/Entity/BilletBuyer.php +++ b/src/Entity/BilletBuyer.php @@ -52,6 +52,9 @@ class BilletBuyer #[ORM\Column(length: 20)] private string $status = self::STATUS_PENDING; + #[ORM\Column(nullable: true)] + private ?bool $isInvitation = null; + #[ORM\Column(length: 255, nullable: true)] private ?string $stripeSessionId = null; @@ -172,6 +175,18 @@ class BilletBuyer return $this; } + public function isInvitation(): ?bool + { + return $this->isInvitation; + } + + public function setIsInvitation(?bool $isInvitation): static + { + $this->isInvitation = $isInvitation; + + return $this; + } + public function getAccessToken(): string { return $this->accessToken; diff --git a/src/Service/BilletOrderService.php b/src/Service/BilletOrderService.php index d205ae7..00463e2 100644 --- a/src/Service/BilletOrderService.php +++ b/src/Service/BilletOrderService.php @@ -165,7 +165,7 @@ class BilletOrderService 'token' => $order->getAccessToken(), ], UrlGeneratorInterface::ABSOLUTE_URL); - $isInvitation = 0 === $order->getTotalHT(); + $isInvitation = true === $order->isInvitation(); $html = $this->twig->render('email/order_confirmation.html.twig', [ 'order' => $order, diff --git a/templates/pdf/invoice.html.twig b/templates/pdf/invoice.html.twig index 75bfed5..ac9fd5a 100644 --- a/templates/pdf/invoice.html.twig +++ b/templates/pdf/invoice.html.twig @@ -85,7 +85,7 @@