diff --git a/src/main/java/com/gcc/crslogs/controller/ApiController.java b/src/main/java/com/gcc/crslogs/controller/ApiController.java index f3588f1..ec6f6d7 100644 --- a/src/main/java/com/gcc/crslogs/controller/ApiController.java +++ b/src/main/java/com/gcc/crslogs/controller/ApiController.java @@ -17,6 +17,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -149,35 +150,114 @@ public class ApiController { } - ///////////////////////birth details getting method/////////////////// + - @GetMapping("/birth-details") - public ResponseEntity fetchBirthCertificateSecurely( - @RequestParam String dob, - @RequestParam String sex, - @RequestParam(required = false) String regno, - @RequestParam(required = false) String childname, - @RequestParam(required = false) String fathername, - @RequestParam(required = false) String mothername) { - - if (dob.isEmpty() || sex.isEmpty()) { - Map error = new HashMap<>(); - error.put("status", false); - error.put("message", "DOB and Sex are mandatory."); - return ResponseEntity.badRequest().body(error); - } - - try { - Map result = birthAndDeathDetailsService.fetchBirthCertificate(dob, sex, regno, childname, fathername, mothername); - return ResponseEntity.ok(result); - } catch (Exception e) { - e.printStackTrace(); - Map error = new HashMap<>(); - error.put("status", false); - error.put("message", "Something went wrong: " + e.getMessage()); - return ResponseEntity.status(500).body(error); - } - } + + ///////////////////////birth details getting method/////////////////// +// now using in live + // @GetMapping("/birth-details") + // public ResponseEntity fetchBirthCertificateSecurely( + // @RequestParam String dob, + // @RequestParam String sex, + // @RequestParam(required = false) String regno, + // @RequestParam(required = false) String childname, + // @RequestParam(required = false) String fathername, + // @RequestParam(required = false) String mothername) { + + // if (dob.isEmpty() || sex.isEmpty()) { + // Map error = new HashMap<>(); + // error.put("status", false); + // error.put("message", "DOB and Sex are mandatory."); + // return ResponseEntity.badRequest().body(error); + // } + + // try { + // Map result = birthAndDeathDetailsService.fetchBirthCertificate(dob, sex, regno, childname, fathername, mothername); + // return ResponseEntity.ok(result); + // } catch (Exception e) { + // e.printStackTrace(); + // Map error = new HashMap<>(); + // error.put("status", false); + // error.put("message", "Something went wrong: " + e.getMessage()); + // return ResponseEntity.status(500).body(error); + // } + // } + + +// from external api restapiservices + +@PostMapping("/birth-details") +public ResponseEntity fetchBirthCertificateSecurely(@RequestBody Map params) { + String dob = params.get("dob"); + String sex = params.get("sex"); + String childname = params.getOrDefault("childname", ""); + String fathername = params.getOrDefault("fathername", ""); + String mothername = params.getOrDefault("mothername", ""); + + if (dob == null || dob.isEmpty() || sex == null || sex.isEmpty()) { + Map error = new HashMap<>(); + error.put("status", false); + error.put("message", "DOB and Sex are mandatory."); + return ResponseEntity.badRequest().body(error); + } + + //System.out.println("fathername " + fathername); + //System.out.println("mothername " + mothername); + + try { + Map result = birthAndDeathDetailsService.fetchLocalBirthCertificate( + dob, fathername, mothername, childname, sex + ); + return ResponseEntity.ok(result); + } catch (Exception e) { + e.printStackTrace(); + Map error = new HashMap<>(); + error.put("status", false); + error.put("message", "Something went wrong: " + e.getMessage()); + return ResponseEntity.status(500).body(error); + } +} + + +// from external api restapiservices + +@PostMapping("/death-details") +public ResponseEntity fetchDeathCertificateSecurely(@RequestBody Map params) { + String dod = params.get("dod"); + String sex = params.get("sex"); + String personname = params.getOrDefault("personname", ""); + String fathername = params.getOrDefault("fathername", ""); + String mothername = params.getOrDefault("mothername", ""); + + if (dod == null || dod.isEmpty() || sex == null || sex.isEmpty()) { + Map error = new HashMap<>(); + error.put("status", false); + error.put("message", "DOB and Sex are mandatory."); + return ResponseEntity.badRequest().body(error); + } + + //System.out.println("fathername " + fathername); + //System.out.println("mothername " + mothername); + + try { + Map result = birthAndDeathDetailsService.fetchLocalDeathCertificate( + dod, fathername, mothername, personname, sex + ); + return ResponseEntity.ok(result); + } catch (Exception e) { + e.printStackTrace(); + Map error = new HashMap<>(); + error.put("status", false); + error.put("message", "Something went wrong: " + e.getMessage()); + return ResponseEntity.status(500).body(error); + } +} + + + + + + diff --git a/src/main/java/com/gcc/crslogs/controller/CustomErrorController.java b/src/main/java/com/gcc/crslogs/controller/CustomErrorController.java new file mode 100644 index 0000000..3baec89 --- /dev/null +++ b/src/main/java/com/gcc/crslogs/controller/CustomErrorController.java @@ -0,0 +1,43 @@ +package com.gcc.crslogs.controller; + +import org.springframework.boot.web.servlet.error.ErrorController; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.ui.Model; +import jakarta.servlet.http.HttpServletRequest; + +@Controller +public class CustomErrorController implements ErrorController { + @RequestMapping("/error") + public String handleError(HttpServletRequest request, Model model) { + Integer statusCode = (Integer) request.getAttribute("jakarta.servlet.error.status_code"); + String title = "Error"; + String message = "An unexpected error occurred."; + String code = statusCode != null ? statusCode.toString() : ""; + + if (statusCode != null) { + switch (statusCode) { + case 404: + title = "Page Not Found"; + message = "Sorry, the page you are looking for does not exist."; + break; + case 403: + title = "Access Forbidden"; + message = "You do not have permission to access this page."; + break; + case 500: + title = "Internal Server Error"; + message = "Oops! Something went wrong on our end."; + break; + default: + title = "Error"; + message = "An unexpected error occurred."; + } + } + + model.addAttribute("code", code); + model.addAttribute("title", title); + model.addAttribute("message", message); + return "modules/crslogspages/message"; + } +} diff --git a/src/main/java/com/gcc/crslogs/controller/MainController.java b/src/main/java/com/gcc/crslogs/controller/MainController.java index 9e2e643..d74ec4f 100644 --- a/src/main/java/com/gcc/crslogs/controller/MainController.java +++ b/src/main/java/com/gcc/crslogs/controller/MainController.java @@ -84,4 +84,15 @@ public class MainController { return "modules/crslogspages/death"; } + + // Example for error +@GetMapping("/some-error") +public String showError(Model model) { + model.addAttribute("code", "404"); + model.addAttribute("title", "Page Not Found"); + model.addAttribute("message", "Sorry, the page you are looking for does not exist."); + return "modules/crslogspages/message"; +} + + } diff --git a/src/main/java/com/gcc/crslogs/service/BirthAndDeathDetailsService.java b/src/main/java/com/gcc/crslogs/service/BirthAndDeathDetailsService.java index 8f37380..f5c8915 100644 --- a/src/main/java/com/gcc/crslogs/service/BirthAndDeathDetailsService.java +++ b/src/main/java/com/gcc/crslogs/service/BirthAndDeathDetailsService.java @@ -2,8 +2,10 @@ package com.gcc.crslogs.service; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; +import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; @@ -12,12 +14,17 @@ import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.UriComponentsBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; @@ -39,7 +46,7 @@ public class BirthAndDeathDetailsService { - + //using for live public Map fetchBirthCertificate(String dob, String sex, String regno, String childName, String fatherName, String motherName) throws Exception { Map params = new LinkedHashMap(); // keep order @@ -76,11 +83,114 @@ public class BirthAndDeathDetailsService { return mapper.readValue(cleanJson, new TypeReference>() {}); } - + +// to created our external api from restservices + public Map fetchLocalBirthCertificate( + String dob, String fatherName, String motherName, String childName, String sex) throws Exception { + + String apiUrl = "https://gccservices.chennaicorporation.gov.in/gccrestservices/api/birth-certificate/by-detailsnewforWeb"; + + MultiValueMap params = new LinkedMultiValueMap<>(); + params.add("incident_date", dob); // yyyy-MM-dd + params.add("gender", sex); + + // 🔹 Pass optional values if provided (converted to UPPERCASE, DB expects this) + if (fatherName != null && !fatherName.trim().isEmpty()) { + params.add("father_name", fatherName.trim().toUpperCase()); + } + if (motherName != null && !motherName.trim().isEmpty()) { + params.add("mother_name", motherName.trim().toUpperCase()); + } + if (childName != null && !childName.trim().isEmpty()) { + params.add("child_name", childName.trim().toUpperCase()); + } + + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); + + HttpEntity> entity = new HttpEntity<>(params, headers); + + ResponseEntity response = restTemplate.postForEntity(apiUrl, entity, String.class); + + String rawJson = response.getBody(); + ObjectMapper mapper = new ObjectMapper(); + Map result = mapper.readValue(rawJson, new TypeReference>() {}); + + // ✅ Only keep records that actually have a PDF link + // if (result.containsKey("certificate_details")) { + // List> details = (List>) result.get("certificate_details"); + + // List> filtered = details.stream() + // .filter(row -> row.get("pdf_url") != null && !row.get("pdf_url").toString().trim().isEmpty()) + // .toList(); + + // result.put("certificate_details", filtered); + // } + + return result; +} + + + + + + + +// to created our external api from restservices + public Map fetchLocalDeathCertificate( + String dod, String fatherName, String motherName, String personName, String sex) throws Exception { + + String apiUrl = "https://gccservices.chennaicorporation.gov.in/gccrestservices/api/death-certificate/by-detailsnewforWeb"; + + MultiValueMap params = new LinkedMultiValueMap<>(); + params.add("incident_date", dod); // yyyy-MM-dd + params.add("gender", sex); + + // 🔹 Pass optional values if provided (converted to UPPERCASE, DB expects this) + if (fatherName != null && !fatherName.trim().isEmpty()) { + params.add("father_name", fatherName.trim().toUpperCase()); + } + if (motherName != null && !motherName.trim().isEmpty()) { + params.add("mother_name", motherName.trim().toUpperCase()); + } + if (personName != null && !personName.trim().isEmpty()) { + params.add("person_name", personName.trim().toUpperCase()); + } + + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); + + HttpEntity> entity = new HttpEntity<>(params, headers); + + ResponseEntity response = restTemplate.postForEntity(apiUrl, entity, String.class); + + String rawJson = response.getBody(); + ObjectMapper mapper = new ObjectMapper(); + Map result = mapper.readValue(rawJson, new TypeReference>() {}); + + // ✅ Only keep records that actually have a PDF link + // if (result.containsKey("certificate_details")) { + // List> details = (List>) result.get("certificate_details"); + + // List> filtered = details.stream() + // .filter(row -> row.get("pdf_url") != null && !row.get("pdf_url").toString().trim().isEmpty()) + // .toList(); + + // result.put("certificate_details", filtered); + // } + + return result; +} + + + + + + //using in live public Map fetchDeathCertificate(String dod, String sex, String regno, String personName, String fatherName, String motherName) throws Exception { @SuppressWarnings("rawtypes") @@ -115,51 +225,9 @@ public class BirthAndDeathDetailsService { return mapper.readValue(cleanJson, new TypeReference>() {}); } - - - - private String clean(String input) { - if (input == null) return ""; - return input.replace("\"", "").trim(); // remove unescaped quotes - } - -// private String sanitizeJsonResponse(String rawJson) { -// if (rawJson == null) return ""; -// -// // Remove illegal control characters (but keep line breaks if needed) -// return rawJson -// .replace("\\", "\\\\") // Escape backslashes -// .replaceAll("[\\p{Cntrl}&&[^\r\n\t]]", "") // Remove non-printable control characters (except tabs/newlines) -// .replaceAll("\t", "") // Remove tab characters explicitly (common cause of error) -// .replaceAll("\\s*:\\s*\n\\s*\"", ":\"") // Fix broken key-value splits -// .replaceAll("\r", "") // Remove carriage return if any -// .replaceAll("\n", "") // Optionally remove newlines if JSON is malformed across lines -// .replaceAll(",\\s*\\[", "[") // Remove comma before array start -// .replaceAll("\\[\\s*,", "[") // Remove comma after array start -// .replaceAll(",\\s*\\]", "]"); // Remove trailing comma in array -// } - - - // private String sanitizeJsonResponse(String rawJson) { - // if (rawJson == null) return ""; - - // return rawJson - // .replace("\\", "\\\\") // Escape backslashes - // .replaceAll("[\\p{Cntrl}&&[^\r\n\t]]", "") // Remove non-printable control characters - // .replaceAll("\t", "") // Remove tab characters - // .replaceAll("\\s*:\\s*\n\\s*\"", ":\"") // Fix broken key-value splits - // .replaceAll("\r", "") // Remove carriage return - // .replaceAll("\n", "") // Remove newlines - // .replaceAll(",\\s*\\[", "[") // Remove comma before array start - // .replaceAll("\\[\\s*,", "[") // Remove comma after array start - // .replaceAll(",\\s*\\]", "]") // Remove trailing comma in array - // .replaceAll("\"\"\"", "\"\"") // ← fix triple quotes - // .replaceAll("\"{3,}", "\"") // ← fallback: collapse 3+ quotes to 1 - // .replaceAll(":(\\s*)\"{2,}\"", ":\"\"") // ← handle `:"""` to `:""` - // .replaceAll("\"\\s*\\(", " ("); // Remove quote before parenthesis - - // } + + private String sanitizeJsonResponse(String rawJson) { diff --git a/src/main/resources/templates/modules/crslogspages/birth.html b/src/main/resources/templates/modules/crslogspages/birth.html index 92c7fec..ffeac5f 100644 --- a/src/main/resources/templates/modules/crslogspages/birth.html +++ b/src/main/resources/templates/modules/crslogspages/birth.html @@ -517,7 +517,7 @@ body {
- Enter Register Number
@@ -609,7 +609,7 @@ body {
- Enter Register Number
@@ -744,7 +744,7 @@ body {
- + @@ -966,134 +966,254 @@ document.addEventListener("DOMContentLoaded", function () { }); +// this function currently using in live + +// function fetchBirthData() { + + +// const dob = document.getElementById('dateofbirth').value; +// const gender = document.querySelector('input[name="gender"]:checked')?.value; +// const captchaInput = document.getElementById('birth-captcha-input'); + +// //console.log("gender:", gender); + +// // Validate Date of Birth +// if (!dob) { +// Swal.fire({ +// icon: 'warning', +// title: 'Missing Date of Birth', +// text: 'Please enter your Date of Birth.' +// }); +// return; +// } + +// // Validate Gender +// if (!gender) { +// Swal.fire({ +// icon: 'warning', +// title: 'Missing Gender Selection', +// text: 'Please select a gender.' +// }); +// return; +// } + +// // CAPTCHA validation first +// // Validate CAPTCHA +// if (!validateCaptcha('birth')) { +// //captchaInput.classList.add('is-invalid'); +// //captchaInput.focus(); +// return; +// } else { +// captchaInput.classList.remove('is-invalid'); +// } + +// const formattedDob = dob.split("-").reverse().join("/"); // Convert yyyy-MM-dd to dd/MM/yyyy +// //console.log("dob:", formattedDob); +// $('#pageLoader').show(); + +// $.ajax({ +// url: '/crs/api/birth-details', +// method: 'GET', +// data: { +// dob: formattedDob, +// sex: gender.charAt(0).toUpperCase() +// }, +// success: function (response) { +// $('#pageLoader').hide(); + +// if (response && response.BIRTH && response.BIRTH.length > 0) { + +// console.log("birthdetails:",response); +// let html = ` +// +// +// +// +// +// +// +// +// +// +// +// +// `; + +// response.BIRTH.forEach((row, index) => { +// html += ` +// +// +// +// +// +// +// +// `; +// }); + +// html += `
S.NoReg NoChild NameFatherMotherDOBCertificate Link
${index + 1}${row.REGNO}${row.CHILDNAME}${row.FATHERNAME}${row.MOTHERNAME}${row.DOB}${row.ENGLISHURL ? `View` : 'N/A'}
`; +// $('#birthModalBody').html(html); + +// setTimeout(() => { +// $('#birthDataTable').DataTable({ +// responsive: true, +// pagingType: "full_numbers", // Buttons for pagination +// language: { +// search: "🔍 Search: ", +// emptyTable: "No records found", +// paginate: { +// previous: "", +// next: "" +// } +// }, +// columnDefs: [ +// { orderable: false, targets: 0 } // Disable sorting on S.No +// ] +// }); +// }, 100); +// } +// else { +// $('#birthModalBody').html('

No birth records found.

'); +// } + +// const modal = new bootstrap.Modal(document.getElementById('birthModal')); +// modal.show(); +// }, +// error: function (xhr) { +// $('#pageLoader').hide(); +// let message = "Something went wrong."; +// if (xhr.responseJSON && xhr.responseJSON.message) { +// message = xhr.responseJSON.message; +// } +// alert("Error: " + message); +// } +// }); + +// } + + + + +// new function function fetchBirthData() { + const dob = document.getElementById('dateofbirth').value; + const gender = document.querySelector('input[name="gender"]:checked')?.value; + const captchaInput = document.getElementById('birth-captcha-input'); + const fatherName = document.getElementById('fathername')?.value || ""; + const motherName = document.getElementById('mothername')?.value || ""; + const childName = document.getElementById('childname')?.value || ""; + + // Validate DOB + if (!dob) { + Swal.fire({ icon: 'warning', title: 'Missing Date of Birth', text: 'Please enter your Date of Birth.' }); + return; + } + // Validate Gender + if (!gender) { + Swal.fire({ icon: 'warning', title: 'Missing Gender Selection', text: 'Please select a gender.' }); + return; + } -const dob = document.getElementById('dateofbirth').value; -const gender = document.querySelector('input[name="gender"]:checked')?.value; -const captchaInput = document.getElementById('birth-captcha-input'); - -//console.log("gender:", gender); - -// Validate Date of Birth - if (!dob) { - Swal.fire({ - icon: 'warning', - title: 'Missing Date of Birth', - text: 'Please enter your Date of Birth.' - }); - return; - } - - // Validate Gender - if (!gender) { - Swal.fire({ - icon: 'warning', - title: 'Missing Gender Selection', - text: 'Please select a gender.' - }); - return; - } - -// CAPTCHA validation first -// Validate CAPTCHA -if (!validateCaptcha('birth')) { - //captchaInput.classList.add('is-invalid'); - //captchaInput.focus(); - return; -} else { - captchaInput.classList.remove('is-invalid'); -} + // CAPTCHA validation + if (!validateCaptcha('birth')) { + return; + } else { + captchaInput.classList.remove('is-invalid'); + } -const formattedDob = dob.split("-").reverse().join("/"); // Convert yyyy-MM-dd to dd/MM/yyyy -//console.log("dob:", formattedDob); -$('#pageLoader').show(); + $('#pageLoader').show(); -$.ajax({ - url: '/crs/api/birth-details', - method: 'GET', - data: { - dob: formattedDob, + const payload = { + dob: dob, sex: gender.charAt(0).toUpperCase() - }, - success: function (response) { - $('#pageLoader').hide(); - - - if (response && response.BIRTH && response.BIRTH.length > 0) { - - console.log("birthdetails:",response); - let html = ` - - - - - - - - - - - - - `; - - response.BIRTH.forEach((row, index) => { - html += ` - - - - - - - - `; - }); + }; + + if (fatherName.trim()) payload.fathername = fatherName.trim(); + if (motherName.trim()) payload.mothername = motherName.trim(); + if (childName.trim()) payload.childname = childName.trim(); + + $.ajax({ + url: '/crs/api/birth-details', + method: 'POST', + contentType: 'application/json', + data: JSON.stringify(payload), + success: function (response) { + $('#pageLoader').hide(); + + if (response && response.certificate_details && response.certificate_details.length > 0) { + let html = ` +
S.NoReg NoChild NameFatherMotherDOBCertificate Link
${index + 1}${row.REGNO}${row.CHILDNAME}${row.FATHERNAME}${row.MOTHERNAME}${row.DOB}${row.ENGLISHURL ? `View` : 'N/A'}
+ + + + + + + + + + + + `; + + response.certificate_details.forEach((row, index) => { + html += ` + + + + + + + + `; + }); - html += `
S.NoReg NoChild NameDOBFather NameMother NameCertificate Link
${index + 1}${row.regno}${row.name}${row.dob}${row.father_name}${row.mother_name}View
`; - $('#birthModalBody').html(html); + html += ``; + $('#birthModalBody').html(html); + + setTimeout(() => { + $('#birthDataTable').DataTable({ + responsive: true, + pagingType: "full_numbers", + language: { + search: "🔍 Search: ", + emptyTable: "No records found", + paginate: { + previous: "", + next: "" + } + }, + columnDefs: [{ orderable: false, targets: 0 }] + }); + }, 100); + } else { + $('#birthModalBody').html('

No birth records found.

'); + } - setTimeout(() => { - $('#birthDataTable').DataTable({ - responsive: true, - pagingType: "full_numbers", // Buttons for pagination - language: { - search: "🔍 Search: ", - emptyTable: "No records found", - paginate: { - previous: "", - next: "" - } - }, - columnDefs: [ - { orderable: false, targets: 0 } // Disable sorting on S.No - ] - }); - }, 100); - } - else { - $('#birthModalBody').html('

No birth records found.

'); + const modal = new bootstrap.Modal(document.getElementById('birthModal')); + modal.show(); + }, + error: function (xhr) { + $('#pageLoader').hide(); + let message = "Something went wrong."; + if (xhr.responseJSON && xhr.responseJSON.message) { + message = xhr.responseJSON.message; + } + alert("Error: " + message); } + }); +} + - const modal = new bootstrap.Modal(document.getElementById('birthModal')); - modal.show(); - }, - error: function (xhr) { - $('#pageLoader').hide(); - let message = "Something went wrong."; - if (xhr.responseJSON && xhr.responseJSON.message) { - message = xhr.responseJSON.message; - } - alert("Error: " + message); - } -}); -} +// this function only using in live function fetchDeathData() { const dod = document.getElementById('dateofdeath').value; diff --git a/src/main/resources/templates/modules/crslogspages/death.html b/src/main/resources/templates/modules/crslogspages/death.html index 2626b7c..0c78999 100644 --- a/src/main/resources/templates/modules/crslogspages/death.html +++ b/src/main/resources/templates/modules/crslogspages/death.html @@ -1095,12 +1095,128 @@ $.ajax({ } - +// using fetchdeathdata function in live + +// function fetchDeathData() { +// const dod = document.getElementById('dateofdeath').value; +// const gender = document.querySelector('input[name="deathgender"]:checked')?.value; +// const captchaInput = document.getElementById('death-captcha-input'); + +// // console.log("gender:", gender); + +// // Validate Date of Birth +// if (!dod) { +// Swal.fire({ +// icon: 'warning', +// title: 'Missing Date of Birth', +// text: 'Please enter your Date of Birth.' +// }); +// return; +// } + +// // Validate Gender +// if (!gender) { +// Swal.fire({ +// icon: 'warning', +// title: 'Missing Gender Selection', +// text: 'Please select a gender.' +// }); +// return; +// } + + +// if (!validateCaptcha('death')) { +// //captchaInput.classList.add('is-invalid'); +// //captchaInput.focus(); +// return; +// } else { +// captchaInput.classList.remove('is-invalid'); +// } + +// const formattedDod = dod.split("-").reverse().join("/"); // Convert yyyy-MM-dd to dd/MM/yyyy + +// // console.log("dod:", formattedDod); +// $('#pageLoader').show(); + +// $.ajax({ +// url: '/crs/api/death-details', +// method: 'GET', +// data: { +// dod: formattedDod, +// sex: gender.charAt(0).toUpperCase() +// }, +// success: function (response) { +// $('#pageLoader').hide(); + +// if (response && response.DEATH && response.DEATH.length > 0) { +// let html = '' + +// '' + +// ''; + +// response.DEATH.forEach((row ,index) => { +// html += ` +// +// +// +// +// +// +// `; +// }); + +// html += '
S.NoReg NoPerson NameFather NameMother NameDODCertificate Link
${index + 1}${row.REGNO}${row.DEATHPERSONNAME}${row.FATHERNAME}${row.MOTHERNAME}${row.DOD}${row.ENGLISHURL ? `View` : 'N/A'}
'; +// $('#deathModalBody').html(html); + +// // Delay initialization to ensure DOM is ready +// setTimeout(() => { +// $('#deathDataTable').DataTable({ +// responsive: true, +// pagingType: "full_numbers", // Buttons for pagination +// language: { +// search: "🔍 Search: ", +// emptyTable: "No records found", +// paginate: { +// previous: "", +// next: "" +// } +// }, +// columnDefs: [ +// { orderable: false, targets: 0 } // Disable sorting on S.No +// ] +// }); +// }, 100); +// } else { +// $('#deathModalBody').html('

No deathrecords found.

'); +// } + +// const modal = new bootstrap.Modal(document.getElementById('deathModal')); +// modal.show(); +// }, +// error: function (xhr) { +// $('#pageLoader').hide(); +// let message = "Something went wrong."; +// if (xhr.responseJSON && xhr.responseJSON.message) { +// message = xhr.responseJSON.message; +// } +// alert("Error: " + message); +// } +// }); + +// } + + +// using for local testin from restapiservices function fetchDeathData() { const dod = document.getElementById('dateofdeath').value; const gender = document.querySelector('input[name="deathgender"]:checked')?.value; const captchaInput = document.getElementById('death-captcha-input'); +const fatherName = document.getElementById('deathfathername')?.value || ""; +const motherName = document.getElementById('deathmothername')?.value || ""; +const personName = document.getElementById('personname')?.value || ""; + + // console.log("gender:", gender); @@ -1108,8 +1224,8 @@ const captchaInput = document.getElementById('death-captcha-input'); if (!dod) { Swal.fire({ icon: 'warning', - title: 'Missing Date of Birth', - text: 'Please enter your Date of Birth.' + title: 'Missing Date of Death', + text: 'Please enter your Date of Death.' }); return; } @@ -1138,31 +1254,40 @@ const formattedDod = dod.split("-").reverse().join("/"); // Convert yyyy-MM-dd t // console.log("dod:", formattedDod); $('#pageLoader').show(); + const payload = { + dod: dod, + sex: gender.charAt(0).toUpperCase() + }; + + if (fatherName.trim()) payload.fathername = fatherName.trim(); + if (motherName.trim()) payload.mothername = motherName.trim(); + if (personName.trim()) payload.personName = personName.trim(); + + $.ajax({ url: '/crs/api/death-details', - method: 'GET', - data: { - dod: formattedDod, - sex: gender.charAt(0).toUpperCase() - }, + method: 'POST', + contentType: 'application/json', + data: JSON.stringify(payload), success: function (response) { $('#pageLoader').hide(); - if (response && response.DEATH && response.DEATH.length > 0) { + if (response && response.certificate_details && response.certificate_details.length > 0) { let html = '' + '' + ''; - response.DEATH.forEach((row ,index) => { + response.certificate_details.forEach((row ,index) => { html += ` - - - - - - `; + + + + + + + `; }); html += '
S.NoReg NoPerson NameFather NameMother NameDODCertificate Link
${index + 1}${row.REGNO}${row.DEATHPERSONNAME}${row.FATHERNAME}${row.MOTHERNAME}${row.DOD}${row.ENGLISHURL ? `View` : 'N/A'}
${row.regno}${row.name}${row.father_name}${row.mother_name}${row.dod}View
'; @@ -1207,7 +1332,6 @@ $.ajax({ - function saveCertificateLog(regNo, eventDate, url, service){ $.ajax({ url: '/crs/api/saveCertificateLogs', diff --git a/src/main/resources/templates/modules/crslogspages/message.html b/src/main/resources/templates/modules/crslogspages/message.html new file mode 100644 index 0000000..6f63a04 --- /dev/null +++ b/src/main/resources/templates/modules/crslogspages/message.html @@ -0,0 +1,49 @@ + + + + + Message + + + + +
+

Info

+

Message

+

No details provided.

+ Go to Home +
+ + + \ No newline at end of file