diff --git a/src/Controller/Admin/EFlexController.php b/src/Controller/Admin/EFlexController.php index a487fd4..35daab5 100644 --- a/src/Controller/Admin/EFlexController.php +++ b/src/Controller/Admin/EFlexController.php @@ -295,7 +295,7 @@ class EFlexController extends AbstractController * Enregistre un paiement manuel (virement, CB externe, etc.). */ #[Route('/{id}/manual-payment/{lineId}', name: 'manual_payment', requirements: ['id' => '\d+', 'lineId' => '\d+'], methods: ['POST'])] - public function manualPayment(int $id, int $lineId, Request $request): Response + public function manualPayment(int $id, int $lineId, Request $request, MailerService $mailer, Environment $twig): Response { $eflex = $this->em->getRepository(EFlex::class)->find($id); if (null === $eflex) { @@ -322,7 +322,36 @@ class EFlexController extends AbstractController $this->em->flush(); } - $this->addFlash('success', 'Echeance '.$line->getPosition().' marquee comme payee ('.$method.').'); + // Email de confirmation au client + $customer = $eflex->getCustomer(); + if (null !== $customer->getEmail()) { + try { + $methodLabels = [ + 'virement' => 'Virement bancaire', + 'cb_externe' => 'Carte bancaire (externe)', + 'cheque' => 'Cheque', + 'especes' => 'Especes', + ]; + + $mailer->sendEmail( + $customer->getEmail(), + 'Paiement recu - Echeance '.$line->getPosition().'/'.$eflex->getNbLines().' - '.$eflex->getReference(), + $twig->render('emails/eflex_paiement_recu.html.twig', [ + 'customer' => $customer, + 'eflex' => $eflex, + 'line' => $line, + 'methodLabel' => $methodLabels[$method] ?? $method, + ]), + null, + null, + false, + ); + } catch (\Throwable) { + // silencieux + } + } + + $this->addFlash('success', 'Echeance '.$line->getPosition().' marquee comme payee ('.$method.'). Email de confirmation envoye.'); return $this->redirectToRoute('app_admin_eflex_show', ['id' => $id]); } diff --git a/templates/emails/eflex_paiement_recu.html.twig b/templates/emails/eflex_paiement_recu.html.twig new file mode 100644 index 0000000..9c267d1 --- /dev/null +++ b/templates/emails/eflex_paiement_recu.html.twig @@ -0,0 +1,55 @@ +{% extends 'email/base.html.twig' %} + +{% block content %} + + + + +
+ {% set greeting = customer.raisonSociale ? 'Chez ' ~ customer.raisonSociale : 'Bonjour ' ~ customer.firstName %} +

{{ greeting }},

+ +

+ Nous confirmons la reception de votre paiement pour l'echeance {{ line.position }}/{{ eflex.nbLines }} du contrat {{ eflex.reference }}. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Reference{{ eflex.reference }}
Echeance{{ line.label }}
Montant{{ line.amount|number_format(2, ',', ' ') }} €
Methode{{ methodLabel }}
Date de paiement{{ line.paidAt ? line.paidAt|date('d/m/Y') : 'Aujourd\'hui' }}
Progression{{ eflex.nbPaid }}/{{ eflex.nbLines }} echeances payees ({{ eflex.progress }}%)
+ + {% if eflex.nbPaid >= eflex.nbLines %} +
+

+ Toutes les echeances ont ete payees. Votre contrat E-Flex est termine. +

+
+ {% endif %} + +

+ Pour toute question : contact@e-cosplay.fr +

+
+{% endblock %}