diff --git a/config/services.yaml b/config/services.yaml index 1996fa6..5be23f6 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -15,6 +15,8 @@ parameters: app.privacyPolicyUrl: '%env(PRIVACY_POLICY_URL)%' app.listmonkUrl: '%env(string:LISTMONK_URL)%' app.useMiddleName: '%env(bool:USE_MIDDLE_NAME)%' + app.sendFreshMemberEmailToBoard: '%env(bool:SEND_FRESH_MEMBER_EMAIL_TO_BOARD)%' + app.sendFreshMemberEmailToContactPeople: '%env(bool:SEND_FRESH_MEMBER_EMAIL_TO_CONTACT_PEOPLE)%' router.request_context.scheme: '%env(SECURE_SCHEME)%' asset.request_context.secure: true diff --git a/src/Controller/MemberController.php b/src/Controller/MemberController.php index 82ce9d4..4c9bf88 100644 --- a/src/Controller/MemberController.php +++ b/src/Controller/MemberController.php @@ -187,8 +187,9 @@ public function handleRedirect(Request $request, string $customerId): Response $memberFullName = $membershipApplication->getFullName(); $memberFirstName = $membershipApplication->getFirstName(); - $emailSender = $this->getParameter('app.noReplyAddress'); - $organizationName = $this->getParameter('app.organizationEmail'); + $noreplySender = $this->getParameter('app.noReplyAddress'); + $emailSender = $this->getParameter('app.organizationEmail'); + $organizationName = $this->getParameter('app.organizationName'); $message = (new Email()) ->subject("Bedankt voor je aanmelding bij $organizationName!") ->to(new Address($memberEmail, $memberFullName)) @@ -200,6 +201,30 @@ public function handleRedirect(Request $request, string $customerId): Response $this->renderView($templatePrefix . 'email/text/apply.txt.twig', ['memberFirstName' => $memberFirstName]) ); $this->mailer->send($message); + + if ($this->getParameter('app.sendFreshMemberEmailToBoard')) { + $message = (new Email()) + ->subject("Er is een nieuw lid die geaccepteerd kan worden") + ->to(new Address($emailSender, $organizationName)) + ->from(new Address($noreplySender, "De website")) + ->text( + $this->renderView($templatePrefix . 'email/text/fresh_member.txt.twig', ['memberFullName' => $memberFullName, 'memberEmail' => $memberEmail]) + ); + $this->mailer->send($message); + } + + if ($this->getParameter('app.sendFreshMemberEmailToContactPeople') && $membershipApplication->getPreferredDivision() !== null) { + $division = $membershipApplication->getPreferredDivision(); + $message = (new Email()) + ->subject("Er is een nieuw lid die geaccepteerd kan worden") + ->to(new Address($division->getEmail(), $division->getName())) + ->from(new Address($noreplySender, "De website")) + ->text( + $this->renderView($templatePrefix . 'email/text/fresh_member.txt.twig', ['memberFullName' => $memberFullName, 'memberEmail' => $memberEmail]) + ); + $this->mailer->send($message); + } + $membershipApplication->setHasSentInitialEmail(true); $em = $this->getDoctrine()->getManager(); $em->persist($membershipApplication); diff --git a/templates/email/text/apply.txt.twig b/templates/email/text/apply.txt.twig index f0917c2..c6cbb13 100644 --- a/templates/email/text/apply.txt.twig +++ b/templates/email/text/apply.txt.twig @@ -8,4 +8,4 @@ Kameraadschappelijke groet, {{ organisatienaam }} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/templates/email/text/fresh_member.txt.twig b/templates/email/text/fresh_member.txt.twig new file mode 100644 index 0000000..df8c288 --- /dev/null +++ b/templates/email/text/fresh_member.txt.twig @@ -0,0 +1,16 @@ +{% extends 'email/text/layout.txt.twig' %} +{% block content %} +Hoi bestuur of lokaal bestuur, + +Er heeft net een lid zich aangemeld op de website. Je kan dit lid nu goedkeuren of weigeren op de website. + +Dit is de informatie van het nieuwe lid: + +{{ memberFullName }} +{{ memberEmail }} + +Kameraadschappelijke groet, + +de website + +{% endblock %}