|
|
|
@ -10,11 +10,18 @@ |
|
|
|
<!-- Bootstrap CSS --> |
|
|
|
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"> |
|
|
|
|
|
|
|
|
|
|
|
<!-- Include Bootstrap Icons CDN in <head> if not already --> |
|
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css"> |
|
|
|
|
|
|
|
<!-- <link th:href="@{/styles/birthanddeath.css}" rel="stylesheet" /> --> |
|
|
|
|
|
|
|
</head> |
|
|
|
|
|
|
|
|
|
|
|
<style> |
|
|
|
|
|
|
|
|
|
|
|
.form-check { |
|
|
|
display: flex; |
|
|
|
align-items: center; |
|
|
|
@ -405,7 +412,7 @@ body { |
|
|
|
@media (min-width: 769px) { |
|
|
|
.mobile-username, |
|
|
|
.mobile-logout { |
|
|
|
display: none; |
|
|
|
display: block; |
|
|
|
} |
|
|
|
|
|
|
|
.header .center-text{ |
|
|
|
@ -417,7 +424,7 @@ body { |
|
|
|
|
|
|
|
|
|
|
|
</style> |
|
|
|
</head> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<body style="background-color: #ebf1fa;"> |
|
|
|
@ -557,16 +564,16 @@ body { |
|
|
|
id="mothername"> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="col-md-5 mt-3"> |
|
|
|
<label for="birth-captcha-input">Enter Captcha <span class="text-danger">*</span></label> |
|
|
|
<div class="d-flex align-items-center"> |
|
|
|
<div id="birth-captcha" class="captcha-box mr-2" style="width: 140px; text-align: center; user-select: none;"></div> |
|
|
|
<button type="button" class="btn btn-sm btn-outline-secondary" onclick="generateCaptcha('birth')">↻</button> |
|
|
|
</div> |
|
|
|
<input type="text" id="birth-captcha-input" class="form-control mt-2" |
|
|
|
placeholder="Enter Captcha" |
|
|
|
onpaste="return false" oncopy="return false" oncut="return false" /> |
|
|
|
</div> |
|
|
|
<div class="col-md-5 mt-3"> |
|
|
|
<label for="birth-captcha-input">Enter Captcha <span class="text-danger">*</span></label> |
|
|
|
<div class="d-flex align-items-center"> |
|
|
|
<div id="birth-captcha" class="captcha-box mr-2" style="width: 140px; text-align: center; user-select: none;"></div> |
|
|
|
<button type="button" class="btn btn-sm btn-outline-secondary" onclick="generateCaptcha('birth')">↻</button> |
|
|
|
</div> |
|
|
|
<input type="text" id="birth-captcha-input" class="form-control mt-2" |
|
|
|
placeholder="Enter Captcha" |
|
|
|
onpaste="return false" oncopy="return false" oncut="return false" /> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
@ -652,15 +659,15 @@ body { |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="col-md-5 mt-3"> |
|
|
|
<label for="death-captcha-input">Enter Captcha <span class="text-danger">*</span></label> |
|
|
|
<div class="d-flex align-items-center"> |
|
|
|
<div id="death-captcha" class="captcha-box mr-2" style="width: 140px; text-align: center; user-select: none;"></div> |
|
|
|
<button type="button" class="btn btn-sm btn-outline-secondary" onclick="generateCaptcha('death')">↻</button> |
|
|
|
</div> |
|
|
|
<input type="text" id="death-captcha-input" class="form-control mt-2" |
|
|
|
placeholder="Enter Captcha" |
|
|
|
onpaste="return false" oncopy="return false" oncut="return false" /> |
|
|
|
</div> |
|
|
|
<label for="death-captcha-input">Enter Captcha <span class="text-danger">*</span></label> |
|
|
|
<div class="d-flex align-items-center"> |
|
|
|
<div id="death-captcha" class="captcha-box mr-2" style="width: 140px; text-align: center; user-select: none;"></div> |
|
|
|
<button type="button" class="btn btn-sm btn-outline-secondary" onclick="generateCaptcha('death')">↻</button> |
|
|
|
</div> |
|
|
|
<input type="text" id="death-captcha-input" class="form-control mt-2" |
|
|
|
placeholder="Enter Captcha" |
|
|
|
onpaste="return false" oncopy="return false" oncut="return false" /> |
|
|
|
</div> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
@ -742,452 +749,452 @@ body { |
|
|
|
|
|
|
|
|
|
|
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> |
|
|
|
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script> |
|
|
|
|
|
|
|
<script |
|
|
|
src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script> |
|
|
|
|
|
|
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> |
|
|
|
<script |
|
|
|
src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js"></script> |
|
|
|
<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script> |
|
|
|
|
|
|
|
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script> |
|
|
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script> |
|
|
|
|
|
|
|
<!-- Your custom script |
|
|
|
<script th:src="@{/script/birthanddeath.js}"></script> --> |
|
|
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
<script> |
|
|
|
|
|
|
|
|
|
|
|
// Redirect after 60 seconds (1 minute) of inactivity |
|
|
|
let timeoutDuration = 10 * 60 * 1000; // 60 seconds |
|
|
|
|
|
|
|
// Redirect after 60 seconds (1 minute) of inactivity |
|
|
|
let timeoutDuration = 10 * 60 * 1000; // 60 seconds |
|
|
|
let timeout; |
|
|
|
|
|
|
|
let timeout; |
|
|
|
|
|
|
|
function resetTimeout() { |
|
|
|
clearTimeout(timeout); |
|
|
|
timeout = setTimeout(() => { |
|
|
|
// Optionally check if session is still active via an API |
|
|
|
window.location.href = "/crs/loginpage"; |
|
|
|
}, timeoutDuration); |
|
|
|
} |
|
|
|
function resetTimeout() { |
|
|
|
clearTimeout(timeout); |
|
|
|
timeout = setTimeout(() => { |
|
|
|
// Optionally check if session is still active via an API |
|
|
|
window.location.href = "/crs/loginpage"; |
|
|
|
}, timeoutDuration); |
|
|
|
} |
|
|
|
|
|
|
|
// Reset timeout on user interaction |
|
|
|
['click', 'mousemove', 'keypress', 'scroll', 'touchstart'].forEach(evt => { |
|
|
|
document.addEventListener(evt, resetTimeout, false); |
|
|
|
}); |
|
|
|
// Reset timeout on user interaction |
|
|
|
['click', 'mousemove', 'keypress', 'scroll', 'touchstart'].forEach(evt => { |
|
|
|
document.addEventListener(evt, resetTimeout, false); |
|
|
|
}); |
|
|
|
|
|
|
|
// Start timer initially |
|
|
|
resetTimeout(); |
|
|
|
// Start timer initially |
|
|
|
resetTimeout(); |
|
|
|
|
|
|
|
|
|
|
|
$(document).ready(function () { |
|
|
|
$(document).ready(function () { |
|
|
|
|
|
|
|
$('#birthModal, #deathModal').on('hidden.bs.modal', function () { |
|
|
|
window.location.reload(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
$('#birthModal, #deathModal').on('hidden.bs.modal', function () { |
|
|
|
window.location.reload(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
$(document).ready(function () { |
|
|
|
function resetFields(cardId) { |
|
|
|
// Clear all input fields inside the given card |
|
|
|
$(`#${cardId} input[type="text"], #${cardId} input[type="date"]`).val(''); |
|
|
|
$(`#${cardId} input[type="radio"]`).prop('checked', false); |
|
|
|
} |
|
|
|
$(document).ready(function () { |
|
|
|
function resetFields(cardId) { |
|
|
|
// Clear all input fields inside the given card |
|
|
|
$(`#${cardId} input[type="text"], #${cardId} input[type="date"]`).val(''); |
|
|
|
$(`#${cardId} input[type="radio"]`).prop('checked', false); |
|
|
|
} |
|
|
|
|
|
|
|
$('#birth-link').on('click', function () { |
|
|
|
resetFields('birth-card'); |
|
|
|
}); |
|
|
|
$('#birth-link').on('click', function () { |
|
|
|
resetFields('birth-card'); |
|
|
|
}); |
|
|
|
|
|
|
|
$('#death-link').on('click', function () { |
|
|
|
resetFields('death-card'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
document.addEventListener("DOMContentLoaded", function () { |
|
|
|
const today = new Date().toISOString().split("T")[0]; // yyyy-mm-dd format |
|
|
|
document.getElementById("dateofbirth").setAttribute("max", today); |
|
|
|
document.getElementById("dateofdeath").setAttribute("max", today); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
document.addEventListener("DOMContentLoaded", function () { |
|
|
|
const userName = localStorage.getItem("userName"); |
|
|
|
console.log("userName ",userName); |
|
|
|
|
|
|
|
|
|
|
|
if (userName) { |
|
|
|
// Mobile |
|
|
|
const mobileName = document.getElementById("loggedUserNameMobile"); |
|
|
|
const mobileWrapper = document.querySelector(".mobile-username .user-name-wrapper"); |
|
|
|
|
|
|
|
if (mobileName) mobileName.textContent = userName; |
|
|
|
if (mobileWrapper) mobileWrapper.title = "Logged in as " + userName; |
|
|
|
|
|
|
|
// Desktop |
|
|
|
const desktopName = document.getElementById("loggedUserNameDesktop"); |
|
|
|
const desktopNameCopy = document.getElementById("loggedUserNameCopy"); |
|
|
|
const desktopWrapper = document.querySelector(".user-info .user-name-wrapper"); |
|
|
|
|
|
|
|
if (desktopName) desktopName.textContent = userName; |
|
|
|
if (desktopNameCopy) desktopNameCopy.textContent = userName; |
|
|
|
if (desktopWrapper) desktopWrapper.title = "Logged in as " + userName; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$('#logoutBtn').click(function (e) { |
|
|
|
e.stopPropagation(); |
|
|
|
|
|
|
|
Swal.fire({ |
|
|
|
title: "Are you sure?", |
|
|
|
text: "Do you really want to logout?", |
|
|
|
icon: "warning", |
|
|
|
showCancelButton: true, |
|
|
|
confirmButtonColor: "#d33", |
|
|
|
cancelButtonColor: "#3085d6", |
|
|
|
confirmButtonText: "Yes, logout", |
|
|
|
cancelButtonText: "Cancel" |
|
|
|
}).then((result) => { |
|
|
|
if (result.isConfirmed) { |
|
|
|
$.ajax({ |
|
|
|
url: "/crs/logout", |
|
|
|
method: "GET", |
|
|
|
success: function () { |
|
|
|
localStorage.clear(); // Clear frontend storage |
|
|
|
window.location.href = "/crs/loginpage"; // Redirect to login page |
|
|
|
}, |
|
|
|
error: function () { |
|
|
|
Swal.fire("Error", "Logout failed. Try again.", "error"); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
$('#death-link').on('click', function () { |
|
|
|
resetFields('death-card'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const links = document.querySelectorAll('.nav-link'); |
|
|
|
links.forEach(link => { |
|
|
|
if (window.location.href.includes(link.getAttribute('href'))) { |
|
|
|
link.classList.add('active'); |
|
|
|
} |
|
|
|
}); |
|
|
|
document.addEventListener("DOMContentLoaded", function () { |
|
|
|
const today = new Date().toISOString().split("T")[0]; // yyyy-mm-dd format |
|
|
|
document.getElementById("dateofbirth").setAttribute("max", today); |
|
|
|
document.getElementById("dateofdeath").setAttribute("max", today); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
/* card display script */ |
|
|
|
document.addEventListener("DOMContentLoaded", function () { |
|
|
|
const birthLink = document.getElementById("birth-link"); |
|
|
|
const deathLink = document.getElementById("death-link"); |
|
|
|
const birthCard = document.getElementById("birth-card"); |
|
|
|
const deathCard = document.getElementById("death-card"); |
|
|
|
|
|
|
|
function showCard(selectedLink, selectedCard, otherLink, otherCard) { |
|
|
|
selectedCard.style.display = "block"; |
|
|
|
otherCard.style.display = "none"; |
|
|
|
selectedLink.classList.add("active"); |
|
|
|
otherLink.classList.remove("active"); |
|
|
|
const userName = localStorage.getItem("userName"); |
|
|
|
//console.log("userName ",userName); |
|
|
|
|
|
|
|
|
|
|
|
if (userName) { |
|
|
|
// Mobile |
|
|
|
const mobileName = document.getElementById("loggedUserNameMobile"); |
|
|
|
const mobileWrapper = document.querySelector(".mobile-username .user-name-wrapper"); |
|
|
|
|
|
|
|
if (mobileName) mobileName.textContent = userName; |
|
|
|
if (mobileWrapper) mobileWrapper.title = "Logged in as " + userName; |
|
|
|
|
|
|
|
// Desktop |
|
|
|
const desktopName = document.getElementById("loggedUserNameDesktop"); |
|
|
|
const desktopNameCopy = document.getElementById("loggedUserNameCopy"); |
|
|
|
const desktopWrapper = document.querySelector(".user-info .user-name-wrapper"); |
|
|
|
|
|
|
|
if (desktopName) desktopName.textContent = userName; |
|
|
|
if (desktopNameCopy) desktopNameCopy.textContent = userName; |
|
|
|
if (desktopWrapper) desktopWrapper.title = "Logged in as " + userName; |
|
|
|
} |
|
|
|
|
|
|
|
birthLink.addEventListener("click", function () { |
|
|
|
showCard(birthLink, birthCard, deathLink, deathCard); |
|
|
|
}); |
|
|
|
|
|
|
|
deathLink.addEventListener("click", function () { |
|
|
|
showCard(deathLink, deathCard, birthLink, birthCard); |
|
|
|
$('#logoutBtn,#logoutBtnMobile').click(function () { |
|
|
|
|
|
|
|
Swal.fire({ |
|
|
|
title: "Are you sure?", |
|
|
|
text: "Do you really want to logout?", |
|
|
|
icon: "warning", |
|
|
|
showCancelButton: true, |
|
|
|
confirmButtonColor: "#d33", |
|
|
|
cancelButtonColor: "#3085d6", |
|
|
|
confirmButtonText: "Yes, logout", |
|
|
|
cancelButtonText: "Cancel" |
|
|
|
}).then((result) => { |
|
|
|
if (result.isConfirmed) { |
|
|
|
$.ajax({ |
|
|
|
url: "/crs/logout", |
|
|
|
method: "GET", |
|
|
|
success: function () { |
|
|
|
localStorage.clear(); // Clear frontend storage |
|
|
|
window.location.href = "/crs/loginpage"; // Redirect to login page |
|
|
|
}, |
|
|
|
error: function () { |
|
|
|
Swal.fire("Error", "Logout failed. Try again.", "error"); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const links = document.querySelectorAll('.nav-link'); |
|
|
|
links.forEach(link => { |
|
|
|
if (window.location.href.includes(link.getAttribute('href'))) { |
|
|
|
link.classList.add('active'); |
|
|
|
} |
|
|
|
}); |
|
|
|
////////////////////////////////////////////// |
|
|
|
|
|
|
|
|
|
|
|
/* card display script */ |
|
|
|
document.addEventListener("DOMContentLoaded", function () { |
|
|
|
const birthLink = document.getElementById("birth-link"); |
|
|
|
const deathLink = document.getElementById("death-link"); |
|
|
|
const birthCard = document.getElementById("birth-card"); |
|
|
|
const deathCard = document.getElementById("death-card"); |
|
|
|
|
|
|
|
function showCard(selectedLink, selectedCard, otherLink, otherCard) { |
|
|
|
selectedCard.style.display = "block"; |
|
|
|
otherCard.style.display = "none"; |
|
|
|
selectedLink.classList.add("active"); |
|
|
|
otherLink.classList.remove("active"); |
|
|
|
} |
|
|
|
|
|
|
|
birthLink.addEventListener("click", function () { |
|
|
|
showCard(birthLink, birthCard, deathLink, deathCard); |
|
|
|
}); |
|
|
|
|
|
|
|
deathLink.addEventListener("click", function () { |
|
|
|
showCard(deathLink, deathCard, birthLink, birthCard); |
|
|
|
}); |
|
|
|
}); |
|
|
|
////////////////////////////////////////////// |
|
|
|
|
|
|
|
|
|
|
|
function generateCaptcha(type) { |
|
|
|
const chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; |
|
|
|
let captcha = ""; |
|
|
|
for (let i = 0; i < 6; i++) { |
|
|
|
captcha += chars.charAt(Math.floor(Math.random() * chars.length)); |
|
|
|
} |
|
|
|
const chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; |
|
|
|
let captcha = ""; |
|
|
|
for (let i = 0; i < 6; i++) { |
|
|
|
captcha += chars.charAt(Math.floor(Math.random() * chars.length)); |
|
|
|
} |
|
|
|
|
|
|
|
const targetId = `${type}-captcha`; // FIXED: match HTML ID |
|
|
|
const element = document.getElementById(targetId); |
|
|
|
if (element) { |
|
|
|
element.textContent = captcha; |
|
|
|
|
|
|
|
// Styling for obscurity |
|
|
|
element.style.fontSize = "18px"; |
|
|
|
element.style.letterSpacing = "3px"; |
|
|
|
element.style.fontWeight = "bold"; |
|
|
|
element.style.backgroundColor = "#f0f0f0"; |
|
|
|
element.style.border = "1px solid #ccc"; |
|
|
|
element.style.padding = "5px"; |
|
|
|
element.style.userSelect = "none"; |
|
|
|
} |
|
|
|
} |
|
|
|
const targetId = `${type}-captcha`; // FIXED: match HTML ID |
|
|
|
const element = document.getElementById(targetId); |
|
|
|
if (element) { |
|
|
|
element.textContent = captcha; |
|
|
|
|
|
|
|
// Styling for obscurity |
|
|
|
element.style.fontSize = "18px"; |
|
|
|
element.style.letterSpacing = "3px"; |
|
|
|
element.style.fontWeight = "bold"; |
|
|
|
element.style.backgroundColor = "#f0f0f0"; |
|
|
|
element.style.border = "1px solid #ccc"; |
|
|
|
element.style.padding = "5px"; |
|
|
|
element.style.userSelect = "none"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function validateCaptcha(type) { |
|
|
|
const generated = document.getElementById(`${type}-captcha`).textContent.trim(); |
|
|
|
const entered = document.getElementById(`${type}-captcha-input`).value.trim(); |
|
|
|
|
|
|
|
if (!entered) { |
|
|
|
Swal.fire({ |
|
|
|
icon: 'warning', |
|
|
|
title: 'CAPTCHA Required', |
|
|
|
text: 'Please enter the CAPTCHA before submitting.' |
|
|
|
}); |
|
|
|
//inputField.focus(); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
if (generated !== entered) { |
|
|
|
const generated = document.getElementById(`${type}-captcha`).textContent.trim(); |
|
|
|
const entered = document.getElementById(`${type}-captcha-input`).value.trim(); |
|
|
|
|
|
|
|
if (!entered) { |
|
|
|
Swal.fire({ |
|
|
|
icon: 'error', |
|
|
|
title: 'Invalid CAPTCHA', |
|
|
|
text: 'The entered CAPTCHA is incorrect. Please try again.' |
|
|
|
icon: 'warning', |
|
|
|
title: 'CAPTCHA Required', |
|
|
|
text: 'Please enter the CAPTCHA before submitting.' |
|
|
|
}); |
|
|
|
generateCaptcha(type); |
|
|
|
//inputField.focus(); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
if (generated !== entered) { |
|
|
|
Swal.fire({ |
|
|
|
icon: 'error', |
|
|
|
title: 'Invalid CAPTCHA', |
|
|
|
text: 'The entered CAPTCHA is incorrect. Please try again.' |
|
|
|
}); |
|
|
|
generateCaptcha(type); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
document.addEventListener("DOMContentLoaded", function () { |
|
|
|
generateCaptcha("birth"); |
|
|
|
generateCaptcha("death"); |
|
|
|
}); |
|
|
|
document.addEventListener("DOMContentLoaded", function () { |
|
|
|
generateCaptcha("birth"); |
|
|
|
generateCaptcha("death"); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 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) { |
|
|
|
let html = ` |
|
|
|
<table id="birthDataTable" class="table table-bordered table-striped"> |
|
|
|
<thead> |
|
|
|
<tr> |
|
|
|
<th>S.No</th> |
|
|
|
<th>Reg No</th> |
|
|
|
<th>Child Name</th> |
|
|
|
<th>Father</th> |
|
|
|
<th>Mother</th> |
|
|
|
<th>DOB</th> |
|
|
|
<th>Certificate Link</th> |
|
|
|
</tr> |
|
|
|
</thead> |
|
|
|
<tbody>`; |
|
|
|
|
|
|
|
response.BIRTH.forEach((row, index) => { |
|
|
|
html += `<tr> |
|
|
|
<td>${index + 1}</td> |
|
|
|
<td>${row.REGNO}</td> |
|
|
|
<td>${row.CHILDNAME}</td> |
|
|
|
<td>${row.FATHERNAME}</td> |
|
|
|
<td>${row.MOTHERNAME}</td> |
|
|
|
<td>${row.DOB}</td> |
|
|
|
<td>${row.ENGLISHURL ? `<a href="${row.ENGLISHURL}" target="_blank" |
|
|
|
onclick="saveCertificateLog('${row.REGNO}', '${row.DOB}', '${row.ENGLISHURL}', 'Birth')">View</a>` : 'N/A'}</td> |
|
|
|
</tr>`; |
|
|
|
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) { |
|
|
|
let html = ` |
|
|
|
<table id="birthDataTable" class="table table-bordered table-striped"> |
|
|
|
<thead> |
|
|
|
<tr> |
|
|
|
<th>S.No</th> |
|
|
|
<th>Reg No</th> |
|
|
|
<th>Child Name</th> |
|
|
|
<th>Father</th> |
|
|
|
<th>Mother</th> |
|
|
|
<th>DOB</th> |
|
|
|
<th>Certificate Link</th> |
|
|
|
</tr> |
|
|
|
</thead> |
|
|
|
<tbody>`; |
|
|
|
|
|
|
|
response.BIRTH.forEach((row, index) => { |
|
|
|
html += `<tr> |
|
|
|
<td>${index + 1}</td> |
|
|
|
<td>${row.REGNO}</td> |
|
|
|
<td>${row.CHILDNAME}</td> |
|
|
|
<td>${row.FATHERNAME}</td> |
|
|
|
<td>${row.MOTHERNAME}</td> |
|
|
|
<td>${row.DOB}</td> |
|
|
|
<td>${row.ENGLISHURL ? `<a href="${row.ENGLISHURL}" target="_blank" |
|
|
|
onclick="saveCertificateLog('${row.REGNO}', '${row.DOB}', '${row.ENGLISHURL}', 'Birth')">View</a>` : 'N/A'}</td> |
|
|
|
</tr>`; |
|
|
|
}); |
|
|
|
|
|
|
|
html += `</tbody></table>`; |
|
|
|
$('#birthModalBody').html(html); |
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
$('#birthDataTable').DataTable({ |
|
|
|
responsive: true, |
|
|
|
pagingType: "full_numbers", // Buttons for pagination |
|
|
|
language: { |
|
|
|
search: "🔍 Search: ", |
|
|
|
emptyTable: "No records found", |
|
|
|
paginate: { |
|
|
|
previous: "<button class='btn btn-outline-primary btn-sm'>Previous</button>", |
|
|
|
next: "<button class='btn btn-outline-primary btn-sm'>Next</button>" |
|
|
|
} |
|
|
|
}, |
|
|
|
columnDefs: [ |
|
|
|
{ orderable: false, targets: 0 } // Disable sorting on S.No |
|
|
|
] |
|
|
|
}); |
|
|
|
}, 100); |
|
|
|
} |
|
|
|
else { |
|
|
|
$('#birthModalBody').html('<p class="text-danger">No birth records found.</p>'); |
|
|
|
} |
|
|
|
|
|
|
|
html += `</tbody></table>`; |
|
|
|
$('#birthModalBody').html(html); |
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
$('#birthDataTable').DataTable({ |
|
|
|
responsive: true, |
|
|
|
pagingType: "full_numbers", // Buttons for pagination |
|
|
|
language: { |
|
|
|
search: "🔍 Search: ", |
|
|
|
emptyTable: "No records found", |
|
|
|
paginate: { |
|
|
|
previous: "<button class='btn btn-outline-primary btn-sm'>Previous</button>", |
|
|
|
next: "<button class='btn btn-outline-primary btn-sm'>Next</button>" |
|
|
|
} |
|
|
|
}, |
|
|
|
columnDefs: [ |
|
|
|
{ orderable: false, targets: 0 } // Disable sorting on S.No |
|
|
|
] |
|
|
|
}); |
|
|
|
}, 100); |
|
|
|
} |
|
|
|
else { |
|
|
|
$('#birthModalBody').html('<p class="text-danger">No birth records found.</p>'); |
|
|
|
} |
|
|
|
|
|
|
|
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); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
} |
|
|
|
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 = '<table id="deathDataTable" class="table table-bordered"><thead><tr>' + |
|
|
|
'<th>S.No</th><th>Reg No</th><th>Person Name</th>' + |
|
|
|
'<th>Father Name</th><th>Mother Name</th><th>DOD</th><th>Certificate Link</th></tr></thead><tbody>'; |
|
|
|
|
|
|
|
response.DEATH.forEach((row ,index) => { |
|
|
|
html += `<tr> |
|
|
|
<td>${index + 1}</td> |
|
|
|
<td>${row.REGNO}</td> |
|
|
|
<td>${row.DEATHPERSONNAME}</td> |
|
|
|
<td>${row.FATHERNAME}</td> |
|
|
|
<td>${row.MOTHERNAME}</td> |
|
|
|
<td>${row.DOD}</td> |
|
|
|
<td>${row.ENGLISHURL ? `<a href="${row.ENGLISHURL}" target="_blank" |
|
|
|
onclick="saveCertificateLog('${row.REGNO}', '${row.DOD}', '${row.ENGLISHURL}', 'Death')">View</a>` : 'N/A'}</td> </tr>`; |
|
|
|
}); |
|
|
|
if (!validateCaptcha('death')) { |
|
|
|
//captchaInput.classList.add('is-invalid'); |
|
|
|
//captchaInput.focus(); |
|
|
|
return; |
|
|
|
} else { |
|
|
|
captchaInput.classList.remove('is-invalid'); |
|
|
|
} |
|
|
|
|
|
|
|
html += '</tbody></table>'; |
|
|
|
$('#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: "<button class='btn btn-outline-primary btn-sm'>Previous</button>", |
|
|
|
next: "<button class='btn btn-outline-primary btn-sm'>Next</button>" |
|
|
|
} |
|
|
|
}, |
|
|
|
columnDefs: [ |
|
|
|
{ orderable: false, targets: 0 } // Disable sorting on S.No |
|
|
|
] |
|
|
|
}); |
|
|
|
}, 100); |
|
|
|
} else { |
|
|
|
$('#deathModalBody').html('<p class="text-danger">No deathrecords found.</p>'); |
|
|
|
} |
|
|
|
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 = '<table id="deathDataTable" class="table table-bordered"><thead><tr>' + |
|
|
|
'<th>S.No</th><th>Reg No</th><th>Person Name</th>' + |
|
|
|
'<th>Father Name</th><th>Mother Name</th><th>DOD</th><th>Certificate Link</th></tr></thead><tbody>'; |
|
|
|
|
|
|
|
response.DEATH.forEach((row ,index) => { |
|
|
|
html += `<tr> |
|
|
|
<td>${index + 1}</td> |
|
|
|
<td>${row.REGNO}</td> |
|
|
|
<td>${row.DEATHPERSONNAME}</td> |
|
|
|
<td>${row.FATHERNAME}</td> |
|
|
|
<td>${row.MOTHERNAME}</td> |
|
|
|
<td>${row.DOD}</td> |
|
|
|
<td>${row.ENGLISHURL ? `<a href="${row.ENGLISHURL}" target="_blank" |
|
|
|
onclick="saveCertificateLog('${row.REGNO}', '${row.DOD}', '${row.ENGLISHURL}', 'Death')">View</a>` : 'N/A'}</td> </tr>`; |
|
|
|
}); |
|
|
|
|
|
|
|
html += '</tbody></table>'; |
|
|
|
$('#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: "<button class='btn btn-outline-primary btn-sm'>Previous</button>", |
|
|
|
next: "<button class='btn btn-outline-primary btn-sm'>Next</button>" |
|
|
|
} |
|
|
|
}, |
|
|
|
columnDefs: [ |
|
|
|
{ orderable: false, targets: 0 } // Disable sorting on S.No |
|
|
|
] |
|
|
|
}); |
|
|
|
}, 100); |
|
|
|
} else { |
|
|
|
$('#deathModalBody').html('<p class="text-danger">No deathrecords found.</p>'); |
|
|
|
} |
|
|
|
|
|
|
|
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); |
|
|
|
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); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@ -1195,27 +1202,27 @@ function fetchDeathData() { |
|
|
|
|
|
|
|
|
|
|
|
function saveCertificateLog(regNo, eventDate, url, service){ |
|
|
|
$.ajax({ |
|
|
|
url: '/crs/api/saveCertificateLogs', |
|
|
|
type: 'POST', |
|
|
|
data: { |
|
|
|
regNo: regNo, |
|
|
|
eventDate: eventDate, |
|
|
|
Url: url, |
|
|
|
service: service |
|
|
|
}, |
|
|
|
success: function() { |
|
|
|
console.log('View logged successfully'); |
|
|
|
}, |
|
|
|
error: function(xhr, status, error) { |
|
|
|
console.error('Logging failed:', error); |
|
|
|
} |
|
|
|
}); |
|
|
|
$.ajax({ |
|
|
|
url: '/crs/api/saveCertificateLogs', |
|
|
|
type: 'POST', |
|
|
|
data: { |
|
|
|
regNo: regNo, |
|
|
|
eventDate: eventDate, |
|
|
|
Url: url, |
|
|
|
service: service |
|
|
|
}, |
|
|
|
success: function() { |
|
|
|
//console.log('View logged successfully'); |
|
|
|
}, |
|
|
|
error: function(xhr, status, error) { |
|
|
|
console.error('Logging failed:', error); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
</script> |
|
|
|
|
|
|
|
</script> |
|
|
|
</body> |
|
|
|
|
|
|
|
</html> |
|
|
|
|