Commit 4e393d6f authored by Deep Dey's avatar Deep Dey

feat: add attachment for interview email

parent 7a42f234
......@@ -4,6 +4,7 @@ import com.example.LaMartin.admission.dao.repository.AdmissionFormDataRepository
import com.example.LaMartin.admission.model.AdmissionFormData;
import com.example.LaMartin.common.service.EmailService;
import com.example.LaMartin.common.service.FileStorageService;
import com.example.LaMartin.common.service.PdfService;
import com.example.LaMartin.common.service.TemplateService;
import com.example.LaMartin.config.Settings;
import lombok.AllArgsConstructor;
......@@ -11,6 +12,7 @@ import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import java.io.ByteArrayInputStream;
import java.util.List;
@Controller
......@@ -23,6 +25,7 @@ public class AdmissionFormDAOController {
private final EmailService emailService;
private final TemplateService templateService;
private final PdfService pdfService;
public boolean addNewAdmissionData(@NotNull AdmissionFormData formData) throws Exception {
......@@ -108,10 +111,13 @@ public class AdmissionFormDAOController {
String emailBody = this.templateService
.generateAdmissionInterviewTemplate(data);
ByteArrayInputStream pdfStream = pdfService.convertHtmlToPdf(emailBody);
this.emailService.sendHtmlEmail(
data.getFatherEmail(),
"SCHEDULED INTERVIEW | " + data.getSchool().toUpperCase(),
emailBody
emailBody,
pdfStream
);
}
......
......@@ -8,6 +8,9 @@ import org.springframework.stereotype.Service;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import javax.mail.util.ByteArrayDataSource;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@Service
@AllArgsConstructor(onConstructor_ = @__({@Autowired}))
......@@ -25,4 +28,16 @@ public class EmailService {
mailSender.send(message);
}
public void sendHtmlEmail(String to, String subject, String htmlBody, ByteArrayInputStream attachment) throws MessagingException, IOException {
MimeMessage message = mailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(message, true);
helper.setSubject(subject);
helper.setTo(to);
helper.setText(htmlBody, true); // true indicates HTML
ByteArrayDataSource dataSource = new ByteArrayDataSource(attachment, "application/pdf");
helper.addAttachment("interaction.pdf", dataSource);
mailSender.send(message);
}
}
......@@ -3,6 +3,7 @@
<head>
<title>Intimation for Interaction</title>
<style>
@page { margin: 0; }
body {
font-family: Arial, sans-serif;
margin: 0;
......@@ -15,8 +16,6 @@
box-sizing: border-box;
}
.header {
display: flex;
align-items: center;
border-bottom: 3px solid #204C89;
text-align: left;
padding: 10px 5px;
......@@ -26,11 +25,15 @@
.header img {
width: 100px;
margin-right: 20px;
display: inline-block;
vertical-align: middle;
}
.header .title {
color: #204C89;
font-weight: bold;
font-size: 18px;
display: inline-block;
vertical-align: middle;
}
.main-section {
border: 2px solid #F1C232;
......@@ -38,12 +41,8 @@
margin-bottom: 10px;
}
.main-sub-section {
display: flex;
justify-content: space-between;
align-items: start;
}
.details {
display: inline-block;
width: 50%;
margin-bottom: 20px;
}
......@@ -52,7 +51,9 @@
font-size: 14px;
}
.interaction {
width: 50%;
display: inline-block;
vertical-align: top;
width: 45%;
border: 1px solid #353535;
margin-bottom: 20px;
}
......@@ -61,20 +62,25 @@
flex: 1;
}
.interaction-date {
display: flex;
justify-content: center;
align-items: center;
border-bottom: 1px solid #353535;
padding: 10px 5px;
}
.interaction-date-item {
display: inline-block;
width: 45%;
text-align: center;
}
.interaction-images {
display: flex;
justify-content: center;
align-items: center;
padding: 10px 5px;
font-size: 14px;
font-weight: bold;
}
.interaction-images>div {
text-align: center;
display: inline-block;
width: 30%;
vertical-align: bottom;
}
.interaction-images img {
width: 100px;
margin: 8px 0;
......@@ -115,10 +121,10 @@
<body>
<div class="container">
<div class="header">
<img th:src="@{${serverPath + 'static/la-martin-logo.webp'}}" alt="Logo">
<img th:src="@{${serverPath + 'static/la-martin-logo.png'}}" alt="Logo" />
<div class="title">
<div>INTIMATION FOR INTERACTION</div>
<div style="text-transform: uppercase;" th:text="${admissionForm.school}"></div>
<div style="text-transform: uppercase;" th:text="${admissionForm.school}">LA MARTINIERE FOR BOYS</div>
</div>
</div>
......@@ -130,33 +136,33 @@
<p><strong>Mother: <span th:text="${admissionForm.motherName}"></span></strong></p>
<p><strong>Father's Email: <span th:text="${admissionForm.fatherEmail}"></span></strong></p>
<p><strong>Father's Mobile: <span th:text="${admissionForm.fatherMobile}"></span></strong></p>
<br>
<br/>
<p><strong>Your date and time of Interaction</strong></p>
<p>Interaction Date: <strong th:text="${admissionForm.interactionDate}"></strong></p>
<p>Interaction Time: <strong th:text="${admissionForm.interactionTime}">10:00 AM</strong></p>
</div>
<div class="interaction" style="flex-direction: column;">
<div class="interaction-date">
<div>
<div class="interaction-date-item">
<div>Interaction Date:</div>
<div><strong th:text="${admissionForm.interactionDate}">2024-01-31</strong></div>
</div>
<div>
<div class="interaction-date-item">
<div>Interaction Time:</div>
<div><strong th:text="${admissionForm.interactionTime}">10:00 AM</strong></div>
</div>
</div>
<div class="interaction-images">
<div>
<img th:src="@{${serverPath + 'resources/images/' + admissionForm.candidateImageName}}" alt="Candidate">
<img th:src="@{${serverPath + 'resources/images/' + admissionForm.candidateImageName}}" src="" alt="Candidate" />
<div><i>Candidate</i></div>
</div>
<div>
<img th:src="@{${serverPath + 'resources/images/' + admissionForm.fatherImageName}}" alt="Father">
<img th:src="@{${serverPath + 'resources/images/' + admissionForm.fatherImageName}}" alt="Father" />
<div><i>Father</i></div>
</div>
<div>
<img th:src="@{${serverPath + 'resources/images/' + admissionForm.motherImageName}}" alt="Mother">
<img th:src="@{${serverPath + 'resources/images/' + admissionForm.motherImageName}}" alt="Mother" />
<div><i>Mother</i></div>
</div>
</div>
......@@ -173,16 +179,16 @@
<li>2. Hospital/Nursing Home Discharge Certificate</li>
<li>3. Baptism Certificate for Christian candidates (if applicable)</li>
<li>4. School Leaving Certificate of Ex-Students</li>
<li>5. Prescribed Medical Certificate (in original) duly filled in by Qualified Medical Practitioner<br>&nbsp;&nbsp;&nbsp;<b>(format available on our website https://lamartiniere.co)</b></li>
<li>5. Prescribed Medical Certificate (in original) duly filled in by Qualified Medical Practitioner<br/>&nbsp;&nbsp;&nbsp;<b>(format available on our website https://lamartiniere.co)</b></li>
<li>6. Proof of Employment/ Business of Parent</li>
<li>7. Proof of Educational & Professional Qualification for both parents.</li>
<li>7. Proof of Educational &amp; Professional Qualification for both parents.</li>
<li>8. Proof of income of both the parents.</li>
<li>9. Legal Adoption papers, if applicable.</li>
<li>10. In case of Single Parent, Decree of the Court regarding the custody of the child.</li>
</ul>
</div>
<div class="footer">
<img th:src="@{${serverPath + 'static/signature.png'}}" width="100px">
<img th:src="@{${serverPath + 'static/signature.png'}}" width="100px" />
<div><strong>SUPRIYO DHAR</strong></div>
<div>SECRETARY, LA MARTINIERE, KOLKATA</div>
<p>A PRINTOUT OF THIS PAGE (IN ORIGINAL) MUST BE BROUGHT DURING THE INTERACTION AND SHOWN TO THE SECURITY PERSONNEL AT THE SCHOOL GATE</p>
......@@ -190,4 +196,4 @@
</div>
</div>
</body>
</html>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment