Commit db630f46 authored by Deep Dey's avatar Deep Dey

feat: add apis download different templates

parent 8cd2577e
......@@ -194,4 +194,122 @@ public class AdmissionFormController {
response.setHeader("Content-Disposition", "attachment; filename=admission-form-list.pdf");
IOUtils.copy(pdfStream, response.getOutputStream());
}
@GetMapping(
value = "/admission-form/download-counsellor-scoring-template"
)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "SUCCESS"),
@ApiResponse(code = 400, message = "FAILED"),
@ApiResponse(code = 500, message = "Exception Occurred")
})
@ApiOperation(value = "")
public void downloadCounsellorScoringTemplate(
HttpServletRequest request,
HttpServletResponse response,
@RequestParam("apikey") String apiKey,
@RequestParam String schoolName,
@RequestParam String interactionDate
) throws Exception {
List<AdmissionFormData> admissionFormDataList =
this.admissionFormDAOController.getAdmissionFormDataList(
schoolName,
null,
interactionDate,
null
);
if (admissionFormDataList.isEmpty()) {
throw new Exception("No Admission Data Found");
}
String output = templateService
.generateCounsellorScoringTemplate(admissionFormDataList);
ByteArrayInputStream pdfStream = pdfService.convertHtmlToPdf(output);
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
response.setHeader("Content-Disposition", "attachment; filename=counsellor-scoring-template.pdf");
IOUtils.copy(pdfStream, response.getOutputStream());
}
@GetMapping(
value = "/admission-form/download-interaction-scoring-template"
)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "SUCCESS"),
@ApiResponse(code = 400, message = "FAILED"),
@ApiResponse(code = 500, message = "Exception Occurred")
})
@ApiOperation(value = "")
public void downloadInteractionScoringTemplate(
HttpServletRequest request,
HttpServletResponse response,
@RequestParam("apikey") String apiKey,
@RequestParam String schoolName,
@RequestParam String interactionDate
) throws Exception {
List<AdmissionFormData> admissionFormDataList =
this.admissionFormDAOController.getAdmissionFormDataList(
schoolName,
null,
interactionDate,
null
);
if (admissionFormDataList.isEmpty()) {
throw new Exception("No Admission Data Found");
}
String output = templateService
.generateInteractionScoringTemplate(admissionFormDataList);
ByteArrayInputStream pdfStream = pdfService.convertHtmlToPdf(output);
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
response.setHeader("Content-Disposition", "attachment; filename=interaction-scoring-template.pdf");
IOUtils.copy(pdfStream, response.getOutputStream());
}
@GetMapping(
value = "/admission-form/download-master-interaction-template"
)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "SUCCESS"),
@ApiResponse(code = 400, message = "FAILED"),
@ApiResponse(code = 500, message = "Exception Occurred")
})
@ApiOperation(value = "")
public void downloadMasterInteractionTemplate(
HttpServletRequest request,
HttpServletResponse response,
@RequestParam("apikey") String apiKey,
@RequestParam String schoolName,
@RequestParam String interactionDate,
@RequestParam String interactionTime
) throws Exception {
List<AdmissionFormData> admissionFormDataList =
this.admissionFormDAOController.getAdmissionFormDataList(
schoolName,
null,
interactionDate,
interactionTime
);
if (admissionFormDataList.isEmpty()) {
throw new Exception("No Admission Data Found");
}
String output = templateService
.generateMasterInteractionTemplate(admissionFormDataList);
ByteArrayInputStream pdfStream = pdfService.convertHtmlToPdf(output);
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
response.setHeader("Content-Disposition", "attachment; filename=master-interaction-template.pdf");
IOUtils.copy(pdfStream, response.getOutputStream());
}
}
......@@ -3,6 +3,7 @@ package com.example.LaMartin.common.service;
import com.example.LaMartin.admission.model.AdmissionFormData;
import com.example.LaMartin.config.Settings;
import lombok.AllArgsConstructor;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.thymeleaf.TemplateEngine;
......@@ -40,4 +41,29 @@ public class TemplateService {
return templateEngine.process("FormAutoReplyTemplate", context);
}
public String generateCounsellorScoringTemplate(@NotNull List<AdmissionFormData> admissionFormDataList) {
String givenYear = admissionFormDataList.get(0).getInteractionDate().substring(0, 4);
Context context = new Context();
context.setVariable("admissionFormList", admissionFormDataList);
context.setVariable("givenYear", Integer.parseInt(givenYear));
return templateEngine.process("CounsellorScoringTemplate", context);
}
public String generateInteractionScoringTemplate(@NotNull List<AdmissionFormData> admissionFormDataList) {
String givenYear = admissionFormDataList.get(0).getInteractionDate().substring(0, 4);
Context context = new Context();
context.setVariable("admissionFormList", admissionFormDataList);
context.setVariable("givenYear", Integer.parseInt(givenYear));
return templateEngine.process("InteractionScoringTemplate", context);
}
public String generateMasterInteractionTemplate(@NotNull List<AdmissionFormData> admissionFormDataList) {
Context context = new Context();
context.setVariable("admissionFormList", admissionFormDataList);
return templateEngine.process("InteractionMasterTemplate", context);
}
}
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<title>Interaction Scoring Sheet</title>
<style>
@page { size: landscape; margin: 0; }
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
}
.container {
width: 85%;
margin: 30px auto;
}
h1,
h2 {
text-align: center;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
table,
th,
td {
border: 1px solid black;
}
th,
td {
padding: 8px;
text-align: center;
}
.header-row th {
background-color: #f2f2f2;
}
.date {
text-align: left;
margin-top: 10px;
margin-bottom: 10px;
}
</style>
</head>
<body>
<div class="container">
<h1 style="text-transform: uppercase" th:text="${admissionFormList[0].school}"></h1>
<h2>
INTERACTION SCORING SHEET FOR THE YEAR
<span th:text="${givenYear} + ' - ' + (${givenYear + 1})"></span>
</h2>
<div class="date">
DATE: <span th:text="${admissionFormList[0].interactionDate}"></span>
<br></br>
ASSESSMENT BY COUNSELLOR / TEACHER
</div>
<table style="font-size: 12px;">
<tr class="header-row">
<th>SL. NO.</th>
<th>Name, DOB &amp; Comm.</th>
<th>Class</th>
<th>SELF CONFIDENCE</th>
<th>SOCIAL DEVELOPMENT</th>
<th>EMOTIONAL DEVELOPMENT</th>
<th>MENTAL DEVELOPMENT</th>
<th>COMMUNICATION</th>
<th>PARENTAL CARE</th>
<th>TOTAL</th>
</tr>
<tr th:each="admissionForm, iterStat : ${admissionFormList}">
<td th:text="${iterStat.count}">1</td>
<td th:text="${admissionForm.fullName}">VIVANN SURANA</td>
<td th:text="${admissionForm.admissionClass}">Upper Nursery</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<title>Interaction Scoring Sheet</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
}
.container {
width: 80%;
margin: 0 auto;
}
.h1,
.h4 {
text-align: center;
}
.h1 {
text-transform: uppercase;
font-size: 24px;
margin-bottom: 10px;
font-weight: 600;
}
.h4 {
font-size: 16px;
margin-bottom: 20px;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
table,
th,
td {
border: 1px solid black;
}
th,
td {
padding: 8px;
text-align: center;
}
.header-row th {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<div class="container">
<div class="h1" th:text="${admissionFormList[0].school}">LA MARTINIERE FOR BOYS</div>
<div class="h4">INTERACTION MASTER LIST FOR
<span th:text="${admissionFormList[0].interactionDate}"></span> AT
<span th:text="${admissionFormList[0].interactionTime}"></span>
</div>
<table style="font-size: 12px;">
<tr class="header-row">
<th>SL. NO.</th>
<th>Reference Id</th>
<th>Name</th>
<th>Father's Name</th>
</tr>
<tr th:each="admissionForm, iterStat : ${admissionFormList}">
<td th:text="${iterStat.count}">1</td>
<td th:text="${admissionForm.fatherEmail}">VIVANN SURANA</td>
<td th:text="${admissionForm.fullName}">VIVANN SURANA</td>
<td th:text="${admissionForm.fatherName}">Upper Nursery</td>
</tr>
</table>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<title>Interaction Scoring Sheet</title>
<style>
@page { size: landscape; margin: 0; }
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
}
.container {
width: 90%;
margin: 30px auto;
}
h1,
h2 {
text-align: center;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
font-size: 12px;
}
table,
th,
td {
border: 1px solid black;
}
th {
text-align: center;
}
th,
td {
padding: 8px;
text-align: center;
}
.header-row th {
background-color: #f2f2f2;
}
.date {
font-size: 10.5px;
text-align: left;
margin-bottom: 10px;
}
</style>
</head>
<body>
<div class="container">
<h1 style="text-transform: uppercase" th:text="${admissionFormList[0].school}"></h1>
<h2>
INTERACTION SCORING SHEET FOR THE YEAR
<span th:text="${givenYear} + ' - ' + (${givenYear + 1})"></span>
</h2>
<div style="margin-top: 10px;">
<div class="date" style="float: right;">
<div>ASSESSMENT BY (ON SCALE OF 10)</div>
<div>(1 BEING LOWEST, 10 BEING HIGHEST)</div>
</div>
<div class="date">
DATE: <span th:text="${admissionFormList[0].interactionDate}"></span>
</div>
</div>
<table style="font-size: 12px;">
<tr class="header-row">
<th>SL. NO.</th>
<th>Name, DOB &amp; Comm.</th>
<th>Class</th>
<th>Category</th>
<th>Rev. (Dr.) S. Bar<br></br>(Ex-Officio, Governor)</th>
<th>Rev. Abir Adhikari<br></br>(Member, Board of Acting Governors)</th>
<th>Mr. P.A. John Stephen<br></br>(Acting Principal, La Martiniere for Boys)</th>
<th>Mr. S. Dhar<br></br>(Secretary)</th>
<th>Mr. R. Sarkar<br></br>(Bursar-cum-Assistant Secretary)</th>
<th>TOTAL</th>
</tr>
<tr th:each="admissionForm, iterStat : ${admissionFormList}">
<td th:text="${iterStat.count}">1</td>
<td th:text="${admissionForm.fullName}">VIVANN SURANA</td>
<td th:text="${admissionForm.admissionClass}">Upper Nursery</td>
<td th:text="${admissionForm.category}"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</div>
</body>
</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