Commit dbd9d124 authored by Deep Dey's avatar Deep Dey

Merge branch 'master' into 'master'

Initialize form interview

See merge request deepdey/lamartin-webomagic!2
parents cb00966a 7cc22160
...@@ -153,6 +153,11 @@ ...@@ -153,6 +153,11 @@
<groupId>javax.mail</groupId> <groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId> <artifactId>javax.mail-api</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.1</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
......
...@@ -17,11 +17,14 @@ import org.springframework.http.MediaType; ...@@ -17,11 +17,14 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -197,6 +200,46 @@ public class AdmissionFormController { ...@@ -197,6 +200,46 @@ public class AdmissionFormController {
IOUtils.copy(pdfStream, response.getOutputStream()); IOUtils.copy(pdfStream, response.getOutputStream());
} }
@GetMapping(
value = "/admission-confirmation-form/download-form"
)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "SUCCESS"),
@ApiResponse(code = 400, message = "FAILED"),
@ApiResponse(code = 500, message = "Exception Occurred")
})
@ApiOperation(value = "")
public void downloadAdmissionConfirmationForm(
HttpServletRequest request,
HttpServletResponse response,
@RequestParam("apikey") String apiKey,
@RequestParam("formIds") String formIds
) throws Exception {
// TODO: validation of api key using redis
List<Long> formIdList = Stream.of(formIds.split(","))
.map(Long::valueOf)
.collect(Collectors.toList());
if (formIdList.isEmpty()) {
throw new Exception("Provide formIds to download");
}
List<AdmissionFormData> admissionFormDataList =
this.admissionFormDAOController.getAdmissionFormDataListByIds(formIdList);
if (admissionFormDataList.isEmpty()) {
throw new Exception("No Admission Data Found");
}
String output = templateService
.generateAdmissionConfirmationFormListTemplate(admissionFormDataList);
ByteArrayInputStream pdfStream = pdfService.convertHtmlToPdf(output);
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
response.setHeader("Content-Disposition", "attachment; filename=admission-confirmation-form-list.pdf");
IOUtils.copy(pdfStream, response.getOutputStream());
}
@GetMapping( @GetMapping(
value = "/admission-form/download-counsellor-scoring-template" value = "/admission-form/download-counsellor-scoring-template"
) )
...@@ -316,6 +359,38 @@ public class AdmissionFormController { ...@@ -316,6 +359,38 @@ public class AdmissionFormController {
response.setHeader("Content-Disposition", "attachment; filename=master-interaction-template.pdf"); response.setHeader("Content-Disposition", "attachment; filename=master-interaction-template.pdf");
IOUtils.copy(pdfStream, response.getOutputStream()); IOUtils.copy(pdfStream, response.getOutputStream());
} }
public byte[] convertAdmissionFormToExcel(List<AdmissionFormData> admissionFormDataList) throws Exception {
Workbook workbook = new HSSFWorkbook();
Sheet sheet = workbook.createSheet("Admission Form Data");
Row headerRow = sheet.createRow(0);
headerRow.createCell(0).setCellValue("SL. NO.");
headerRow.createCell(1).setCellValue("Reference Id");
headerRow.createCell(2).setCellValue("Name");
headerRow.createCell(3).setCellValue("Father's Name");
headerRow.createCell(4).setCellValue("Interaction Time");
// Start data rows from second row
int rowIndex = 1;
for (AdmissionFormData admissionFormData : admissionFormDataList) {
Row dataRow = sheet.createRow(rowIndex++);
// Set data for each column based on AdmissionFormData fields
dataRow.createCell(0).setCellValue(admissionFormData.getId());
dataRow.createCell(1).setCellValue(admissionFormData.getFatherEmail());
dataRow.createCell(2).setCellValue(admissionFormData.getFullName());
dataRow.createCell(3).setCellValue(admissionFormData.getFatherName());
dataRow.createCell(4).setCellValue(admissionFormData.getInteractionTime());
}
// Write the workbook to a byte array
ByteArrayOutputStream out = new ByteArrayOutputStream();
workbook.write(out);
return out.toByteArray();
}
@GetMapping( @GetMapping(
...@@ -327,7 +402,7 @@ public class AdmissionFormController { ...@@ -327,7 +402,7 @@ public class AdmissionFormController {
@ApiResponse(code = 500, message = "Exception Occurred") @ApiResponse(code = 500, message = "Exception Occurred")
}) })
@ApiOperation(value = "") @ApiOperation(value = "")
public Object downloadMasterInteractionExcel( public void downloadMasterInteractionExcel(
HttpServletRequest request, HttpServletRequest request,
HttpServletResponse response, HttpServletResponse response,
@RequestParam("apikey") String apiKey, @RequestParam("apikey") String apiKey,
...@@ -348,24 +423,18 @@ public class AdmissionFormController { ...@@ -348,24 +423,18 @@ public class AdmissionFormController {
throw new Exception("No Admission Data Found"); throw new Exception("No Admission Data Found");
} }
//TODO: write logic to download excel // Call the convertAdmissionFormToExcel method to get the Excel data as byte array
return new ResponseEntity<>( byte[] excelData = convertAdmissionFormToExcel(admissionFormDataList);
new GeneralResponse(
true, // Set response content type as application/vnd.ms-excel
AppConstants.RESPONSE_SUCCESS_STATUS_CODE, response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE + "; charset=UTF-8");
"Excel should be downloaded",
null // Set a downloadable filename
), response.setHeader("Content-Disposition", "attachment; filename=\"master-interaction-excel.xls\"");
HttpStatus.OK);
// Write the Excel data to the response output stream
response.getOutputStream().write(excelData);
// 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());
} }
@GetMapping( @GetMapping(
......
...@@ -2,6 +2,7 @@ package com.example.LaMartin.admission.dao.repository; ...@@ -2,6 +2,7 @@ package com.example.LaMartin.admission.dao.repository;
import com.example.LaMartin.admission.mapper.AdmissionFormCountMapper; import com.example.LaMartin.admission.mapper.AdmissionFormCountMapper;
import com.example.LaMartin.admission.mapper.AdmissionFormMapper; import com.example.LaMartin.admission.mapper.AdmissionFormMapper;
import com.example.LaMartin.admission.mapper.AdmissionFormPreviewMapper;
import com.example.LaMartin.admission.model.AdmissionFormData; import com.example.LaMartin.admission.model.AdmissionFormData;
import com.example.LaMartin.admission.pojo.AdmissionFormCount; import com.example.LaMartin.admission.pojo.AdmissionFormCount;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
...@@ -199,7 +200,7 @@ public class AdmissionFormDataRepository { ...@@ -199,7 +200,7 @@ public class AdmissionFormDataRepository {
parameters.addValue("correspondenceEmail", correspondenceEmail); parameters.addValue("correspondenceEmail", correspondenceEmail);
} }
return namedParameterJdbcTemplate return namedParameterJdbcTemplate
.query(sql.toString(), parameters, new AdmissionFormMapper()); .query(sql.toString(), parameters, new AdmissionFormPreviewMapper());
} }
public List<AdmissionFormData> getAdmissionFormDataListByIds(List<Long> ids) { public List<AdmissionFormData> getAdmissionFormDataListByIds(List<Long> ids) {
......
package com.example.LaMartin.admission.mapper;
import com.example.LaMartin.admission.model.AdmissionFormData;
import com.example.LaMartin.common.utils.RowMapperUtil;
import org.jetbrains.annotations.NotNull;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Component;
import java.sql.ResultSet;
import java.sql.SQLException;
@Component
public class AdmissionFormPreviewMapper implements RowMapper<AdmissionFormData> {
@Override
public AdmissionFormData mapRow(@NotNull ResultSet rs, int rowNum) throws SQLException {
AdmissionFormData formData = new AdmissionFormData();
formData.setFullName(RowMapperUtil.getString(rs, "full_name"));
formData.setFatherName(RowMapperUtil.getString(rs, "father_name"));
formData.setFatherEmail(RowMapperUtil.getString(rs, "father_email"));
formData.setMotherName(RowMapperUtil.getString(rs, "mother_name"));
formData.setInteractionDate(RowMapperUtil.getString(rs, "interaction_date"));
formData.setInteractionTime(RowMapperUtil.getString(rs, "interaction_time"));
return formData;
}
}
...@@ -28,6 +28,23 @@ public class TemplateService { ...@@ -28,6 +28,23 @@ public class TemplateService {
return templateEngine.process("AdmissionFormListTemplate", context); return templateEngine.process("AdmissionFormListTemplate", context);
} }
public String generateAdmissionConfirmationFormListTemplate(List<AdmissionFormData> admissionFormDataList) {
// for (AdmissionFormData admissionFormData: admissionFormDataList)
// {
// String originalDate = "2024-07-04";
// LocalDate date = LocalDate.parse(admissionFormData.getInteractionDate());
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");
// admissionFormData.setInteractionDate(date.format(formatter));
// }
Context context = new Context();
context.setVariable("admissionFormList", admissionFormDataList);
context.setVariable("serverPath", settings.getStaticServerPath());
return templateEngine.process("AdmissionConfimationFormListTemplate", context);
}
public String generateAdmissionInterviewTemplate(@NotNull AdmissionFormData admissionFormData) { public String generateAdmissionInterviewTemplate(@NotNull AdmissionFormData admissionFormData) {
String originalDate = "2024-07-04"; // Example date string String originalDate = "2024-07-04"; // Example date string
LocalDate date = LocalDate.parse(admissionFormData.getInteractionDate()); LocalDate date = LocalDate.parse(admissionFormData.getInteractionDate());
......
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<title>Intimation for Admission</title>
<style>
* {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
font-size: 12px;
}
body {
margin: 0px 20px;
}
.header,
.content,
.footer {
text-align: center;
position: relative;
width: 100%;
}
.content {
text-align: justify;
}
.left,
.center,
.right {
display: inline-block;
}
.left{
position: absolute;
left: 0;
}
.right{
position: absolute;
right: 0;
}
.middle{
margin: 0 auto;
text-align: center;
}
.header img {
height: 80px;
}
.content {
margin-top: 10px;
}
.content p {
margin: 5px 0;
}
.content b {
font-weight: bold;
}
.account-details,
.fee-details {
width: 100%;
margin-top: 20px;
border-collapse: collapse;
}
.account-details td,
.fee-details td,
.fee-details th {
border: 1px solid black;
padding: 5px;
text-align: left;
}
.fee-details th {
text-align: center;
}
.signature {
margin-top: 40px;
text-align: left;
}
.signature img{
width: 18%;
height: 18%;
}
</style>
</head>
<body>
<div class="container" th:each="admissionForm : ${admissionFormList}">
<div class="header">
<div class="left">
<h4>Supriyo Dhar, HRM, MBA, LLB<br />Secretary</h4>
</div>
<div class="center">
<img th:src="@{${serverPath + 'static/la-martin-logo.png'}}" alt="Logo" height="80px"/>
<!-- <img src="la-martin-logo copy.png" alt="Logo" height="80px" /> -->
</div>
<div class="right">
<h2>La Martiniere</h2>
</div>
</div>
<div class="content">
<div class="left">
<p><b>To,</b><br />
<b th:text="${admissionForm.fatherName}">Pratik Shrivastava</b>
</p>
</div>
<div class="right">
<p><b th:text="${admissionForm.interactionDate}">17/07/2024</b></p>
</div>
<br/>
<br/>
<br/>
<div class="middle">
<strong>Sub: <u>Intimation for Admission</u></strong>
</div>
<p>Dear Parent/s,</p>
<br />
<p>We are pleased to inform you that your son <b th:text="${admissionForm.fullName}"></b> has been
granted admission to <b th:text="${admissionForm.admissionClass}"></b> for the year
2024-2025.</p>
<p>Please contact the <b>Principal's office of La Martiniere for Boys, 11 Dr. U.N. Brahmachari Street,
Kolkata 700 017</b>, in person, along with a printout of this letter on <b>05/04/2024 at 10:00am</b>
for necessary formalities.</p>
<p>Parents willing to pay the full year fee may do so, or pay quarterly by way of Pay Order favouring <b>“La
Martiniere Calcutta”</b> or bank transfer, at the time of admission.</p>
<p>For the <b>1<sup>st</sup> Quarter (April to June 2024)</b>, parents are to pay <b>Rs. 1,69,500/- (Rupees
One Lacs Sixty Nine Thousand Five Hundred only)</b> towards Tuition Fees, Session Fees,
Infrastructure Development Fees, Admission Fees, Building Development Fees and Security Deposit
(refundable). The amount may be transferred directly to the following account.</p>
<br />
<p><b><u>Penalty of Rs.5000/- will be levied if fees not paid on the due date.</u></b></p>
<table class="account-details">
<tr>
<td>Account Name</td>
<td>: La Martiniere, Calcutta</td>
</tr>
<tr>
<td>Account Number</td>
<td>: 031201001229</td>
</tr>
<tr>
<td>Bank Name</td>
<td>: ICICI Bank, Gorky Terrace</td>
</tr>
<tr>
<td>Account Type</td>
<td>: Savings</td>
</tr>
<tr>
<td>RTGS/NEFT/IFS Code</td>
<td>: ICIC0000312</td>
</tr>
</table>
<br />
<p>Please email the enclosed format to <b>lmcao@rediffmail.com</b> for confirmation of your payment and also
bring a hard copy while visiting Principal’s Office.</p>
<table class="fee-details">
<tr>
<th>Quarters</th>
<th>Amount</th>
<th>Date of Payment</th>
</tr>
<tr>
<td>1<sup>st</sup> Quarter (April to June 2024)</td>
<td>Rs. 1,69,500.00</td>
<td>On the date of admission</td>
</tr>
<tr>
<td>2<sup>nd</sup> Quarter (July to Sept. 2024)</td>
<td>Rs. 1,24,500.00</td>
<td>1<sup>st</sup> to 5<sup>th</sup> July, 2024</td>
</tr>
<tr>
<td>3<sup>rd</sup> Quarter (Oct to Dec. 2024)</td>
<td>Rs. 1,24,500.00</td>
<td>1<sup>st</sup> to 5<sup>th</sup> Oct. 2024</td>
</tr>
<tr>
<td>4<sup>th</sup> Quarter (Jan to March 2025)</td>
<td>Rs. 1,24,500.00</td>
<td>6<sup>th</sup> to 11<sup>th</sup> Jan 2025</td>
</tr>
<tr>
<td><b>Total</b></td>
<td colspan="2"><b>Rs 5,43,000.00</b></td>
</tr>
</table>
<div class="signature">
<p>Yours faithfully,</p>
<!-- <img th:src="@{${serverPath + 'static/signature.png'}}" alt="Logo" height="80px" /> -->
<img src="signature.png" alt="Logo" height="80px" />
<p><b>SUPRIYO DHAR</b><br />Secretary<br />La Martiniere, Kolkata</p>
</div>
<div class="footer">
<div class="left">
<p>11 Dr. U.N. Brahmachari Street<br />Kolkata - 700 017 (INDIA)</p>
</div>
<div class="center">
<p>+91-33-4040-6600/01<br />22890112(D)</p>
</div>
<div class="right">
<p>secretary@lamartiniere.co<br />lamartiniere.co</p>
</div>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
...@@ -55,8 +55,11 @@ ...@@ -55,8 +55,11 @@
<button id="summary-popup-btn" class="btn btn-success btn-sm">Download Score Sheets</button> <button id="summary-popup-btn" class="btn btn-success btn-sm">Download Score Sheets</button>
<button id="download-admission-data-btn" class="btn btn-success btn-sm">Download Admission Data</button> <button id="download-admission-data-btn" class="btn btn-success btn-sm">Download Admission Data</button>
</div> </div>
<div>
<button id="bookAppointmentBtn" class="btn btn-primary btn-sm">Schedule Admission</button>
<button id="bookAppointmentBtn" class="btn btn-primary btn-sm">Schedule Appointment</button> <button id="bookAppointmentBtn" class="btn btn-primary btn-sm">Schedule Appointment</button>
</div> </div>
</div>
</div> </div>
<div class="record-data"> <div class="record-data">
......
...@@ -25,6 +25,7 @@ body { ...@@ -25,6 +25,7 @@ body {
justify-content: center; justify-content: center;
align-items: center; align-items: center;
flex-direction: column; flex-direction: column;
text-align: center;
} }
.la-header-title { .la-header-title {
...@@ -157,7 +158,7 @@ body { ...@@ -157,7 +158,7 @@ body {
justify-content: center; justify-content: center;
align-items: center; align-items: center;
flex-direction: column; flex-direction: column;
width: 30%; /* width: 30%; */
padding: 0px 10px; padding: 0px 10px;
} }
...@@ -192,3 +193,27 @@ input[type="file"] { ...@@ -192,3 +193,27 @@ input[type="file"] {
transform: rotate(360deg); transform: rotate(360deg);
} }
} }
@media only screen and (max-width: 768px) {
#application-form {
width: 100%;
}
.form-image-group{
display: flex;
flex-wrap: wrap;
/* flex-direction: column; */
}
.la-form-group{
width: 100%;
}
/* input[type="file"] {
width: 80%;
} */
.la-body-container {
padding: 0px 60px;
}
}
\ 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