diff --git a/src/Controller/Admin/AdvertController.php b/src/Controller/Admin/AdvertController.php index 80c5677..ed901ce 100644 --- a/src/Controller/Admin/AdvertController.php +++ b/src/Controller/Admin/AdvertController.php @@ -311,6 +311,19 @@ class AdvertController extends AbstractController $amountFormatted = number_format((float) $amount, 2, '.', ''); $payment = new \App\Entity\AdvertPayment($advert, \App\Entity\AdvertPayment::TYPE_SUCCESS, $amountFormatted); $payment->setMethod($method); + + // Lier a un echeancier si methode = echeancier + if ('echeancier' === $method) { + $echeancierId = $request->request->getInt('echeancierId'); + if ($echeancierId > 0) { + $echeancier = $this->em->getRepository(\App\Entity\Echeancier::class)->find($echeancierId); + if (null !== $echeancier) { + $payment->setEcheancier($echeancier); + $methodLabel = 'Echeancier #'.$echeancier->getId().' - '.$echeancier->getDescription(); + } + } + } + $this->em->persist($payment); // Tracker l'evenement diff --git a/src/Entity/AdvertPayment.php b/src/Entity/AdvertPayment.php index f6a37ae..6998efe 100644 --- a/src/Entity/AdvertPayment.php +++ b/src/Entity/AdvertPayment.php @@ -30,6 +30,10 @@ class AdvertPayment #[ORM\Column(length: 30, nullable: true)] private ?string $method = null; + #[ORM\ManyToOne(targetEntity: \App\Entity\Echeancier::class)] + #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')] + private ?\App\Entity\Echeancier $echeancier = null; + #[ORM\Column] private \DateTimeImmutable $createdAt; @@ -73,6 +77,18 @@ class AdvertPayment return $this; } + public function getEcheancier(): ?\App\Entity\Echeancier + { + return $this->echeancier; + } + + public function setEcheancier(?\App\Entity\Echeancier $echeancier): static + { + $this->echeancier = $echeancier; + + return $this; + } + public function getCreatedAt(): \DateTimeImmutable { return $this->createdAt; diff --git a/templates/admin/clients/show.html.twig b/templates/admin/clients/show.html.twig index b21475f..c94a562 100644 --- a/templates/admin/clients/show.html.twig +++ b/templates/admin/clients/show.html.twig @@ -712,14 +712,24 @@