You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
849 lines
33 KiB
849 lines
33 KiB
<!DOCTYPE html>
|
|
<html lang="en" dir="">
|
|
<html xmlns:th="http://www.thymeleaf.org">
|
|
<head th:replace="~{fragments/modules/base/head :: head}"></head>
|
|
<style>
|
|
.required{
|
|
color: red;
|
|
}
|
|
#modalBody h4 {
|
|
font-weight: bold;
|
|
margin-top: 15px;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
#modalBody p {
|
|
margin: 5px 0;
|
|
}
|
|
|
|
#modalBody hr {
|
|
margin: 15px 0;
|
|
}
|
|
.comment {
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.comment p {
|
|
margin: 0;
|
|
}
|
|
|
|
hr {
|
|
border: 1px solid #ccc;
|
|
margin-top: 20px;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
h5 {
|
|
|
|
font-size: bold;
|
|
}
|
|
|
|
/* Limit the height of the dropdown menu and make it scrollable */
|
|
.dropdown-menu {
|
|
max-height: 200px; /* Adjust this value as needed */
|
|
overflow-y: auto;
|
|
}
|
|
|
|
|
|
.col-4 {
|
|
font-weight: bold;
|
|
text-align: right;
|
|
}
|
|
|
|
.col-8 {
|
|
padding-left: 20px;
|
|
}
|
|
|
|
.comment {
|
|
padding: 10px 0;
|
|
}
|
|
|
|
.comment .text-muted {
|
|
font-size: 0.9em;
|
|
color: #6c757d;
|
|
}
|
|
|
|
.comment hr {
|
|
border-top: 1px solid #ccc;
|
|
}
|
|
|
|
.comment .btn-link {
|
|
font-size: 0.9em;
|
|
text-decoration: underline;
|
|
color: #007bff;
|
|
}
|
|
/* Make the modal body scrollable */
|
|
#detailsModal .modal-body {
|
|
max-height: 70vh; /* Limit the height to 70% of the viewport */
|
|
overflow-y: auto; /* Enable vertical scrolling */
|
|
}
|
|
|
|
.card-box {
|
|
border-radius: 20px;
|
|
box-shadow: rgba(0, 0, 0, 0.5) 0px 3px 8px;
|
|
}
|
|
|
|
#followupCard {
|
|
transition: transform 0.2s ease; /* Smooth scaling transition */
|
|
cursor: pointer; /* Default cursor change */
|
|
}
|
|
|
|
#followupCard:hover {
|
|
transform: scale(1.05); /* Slightly scale up on hover */
|
|
cursor: pointer; /* Change cursor to hand symbol */
|
|
}
|
|
|
|
.card-block {
|
|
padding: 20px;
|
|
}
|
|
|
|
.form-label {
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
|
|
input.form-control {
|
|
padding: 10px;
|
|
}
|
|
.form-select {
|
|
padding: 10px;
|
|
height: 40px;
|
|
}
|
|
#employeeCard label{
|
|
padding-top: 2%;
|
|
}
|
|
|
|
|
|
|
|
.is-invalid {
|
|
border: 1px solid red;
|
|
}
|
|
|
|
|
|
|
|
|
|
</style>
|
|
<body>
|
|
<!--[if lt IE 8]>
|
|
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
|
|
<![endif]-->
|
|
|
|
<div class="wrapper">
|
|
<!-- header top menu Start -->
|
|
<header th:replace="~{fragments/modules/base/header :: header}"></header>
|
|
<!-- header top menu end -->
|
|
|
|
<div class="page-wrap">
|
|
<!--=============== Left Menu side Start ================-->
|
|
<div th:replace="~{fragments/modules/base/menu :: menu}"></div>
|
|
<!--=============== Left side End ================-->
|
|
<div class="main-content">
|
|
<div class="container-fluid">
|
|
<div class="page-header mb-2">
|
|
<div class="row align-items-end">
|
|
<div class="col-lg-8">
|
|
<div class="page-header-title">
|
|
<i class="fa fa-list-alt bg-blue"></i>
|
|
<div class="d-inline">
|
|
<h5>Department Entries</h5>
|
|
<span>Provisional Retirement</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-lg-4">
|
|
<nav class="breadcrumb-container" aria-label="breadcrumb">
|
|
<ol class="breadcrumb">
|
|
<li class="breadcrumb-item"><a href="/gcc/index"><i class="ik ik-home"></i></a></li>
|
|
<li class="breadcrumb-item" aria-current="page">Department Entries</li>
|
|
<li class="breadcrumb-item" aria-current="page">NewEntry</li>
|
|
<li class="breadcrumb-item active" aria-current="page">Provisional Retirement</li>
|
|
</ol>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mt-4" >
|
|
|
|
<div class="col-md-12">
|
|
<div class="card">
|
|
<div class="card-block">
|
|
<h5 style="font-weight:bold;"> <span th:text="${deptname}" id="deptname"></span> Department</h5><span th:text="${filecategory}" id="filecategory" style="display:none"></span>
|
|
<h5 style="font-weight:bold;"><span th:text="${deptId}" id="deptId" style="display:none"></span> New Entry - Provisional Retirement</h5>
|
|
<span th:text="${userId}" id="userId" style="display:none"></span>
|
|
<div class="row mb-4">
|
|
|
|
<div class="col-md-4" >
|
|
<label for="empCode" class="form-label fw-bold">Search by Employee No <span class="text-danger">*</span></label>
|
|
|
|
<div class="dropdown">
|
|
<input type="number" id="empCode" class="form-control" pattern="^[A-Za-z0-9]+$" placeholder="Enter Employee No" required>
|
|
<small id="employeenoHelp" class="form-text text-muted">Only numeric characters (numbers) are allowed.</small>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-4 mt-20">
|
|
<button id="searchButton" class="btn btn-primary mt-2" Style="height:38px;">Search</button>
|
|
<!-- <button id="resetButton" class="btn btn-secondary mt-2">Reset</button> -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="row mb-4" id="employeeCard" style="display: none;">
|
|
<div class="col-md-12">
|
|
<div class="card">
|
|
<div class="card-block">
|
|
<h5 style="font-weight:bold;">New Entry - Provisional Retirement - <span id="EmployeeCode"></span></h5>
|
|
<hr>
|
|
<div class="row">
|
|
<!-- Employee No -->
|
|
<div class="col-md-6">
|
|
<label for="employeeno" class="form-label fw-bold">Employee No <span class="text-danger">*</span></label>
|
|
<div class="dropdown">
|
|
<input type="number" id="employeeno" class="form-control" readonly>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Employee Name -->
|
|
<div class="col-md-6">
|
|
<label for="employeename" class="form-label fw-bold">Employee Name <span class="text-danger">*</span></label>
|
|
<div class="dropdown">
|
|
<input type="text" id="employeename" class="form-control" readonly>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
<label for="Department" class="form-label fw-bold">Department <span class="text-danger">*</span></label>
|
|
<div class="dropdown">
|
|
<input type="text" id="department" class="form-control" readonly>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
<label for="Designation" class="form-label fw-bold">Designation<span class="text-danger">*</span></label>
|
|
<div class="dropdown">
|
|
<input type="text" id="designation" class="form-control" readonly>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
<label for="classes" class="form-label fw-bold">Class<span class="text-danger">*</span></label>
|
|
<div class="dropdown" >
|
|
<input type="text" id="classes" class="form-control" readonly>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="col-sm-6">
|
|
<label for="retirementdate" class="form-label fw-bold">Retirement Date <span class="text-danger">*</span></label>
|
|
<input type="date" id="retirementdate" class="form-control" readonly>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="col-sm-6">
|
|
<label for="retirement" class="form-label fw-bold">Type Of Retirement<span class="text-danger">*</span></label>
|
|
<select id="retirement" class="form-select" style="width: 100%;" required>
|
|
<option value="" selected>-- Select Option --</option>
|
|
</select>
|
|
</div>
|
|
|
|
|
|
<div class="col-sm-6">
|
|
<label for="reason" class="form-label fw-bold">Reason For Provisional Pension Given<span class="text-danger">*</span></label>
|
|
<select id="reason" class="form-select" style="width: 100%;" required>
|
|
<option value="" selected>-- Select Option --</option>
|
|
</select>
|
|
<div id="otherReasonDiv" style="display: none; margin-top: 10px;">
|
|
<label for="otherReason" class="form-label">Please specify:</label>
|
|
<input type="text" id="otherReason" class="form-control" placeholder="Enter reason">
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="col-md-6">
|
|
<label for="Audit File" class="form-label fw-bold">
|
|
Date file sent to Pension Section <span class="text-danger">*</span>
|
|
</label>
|
|
<div class="dropdown">
|
|
<input type="text" id="filesentdate" class="form-control" readonly>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
<label for="pendingDuration" class="form-label fw-bold">Pending Duration <span class="text-danger">*</span></label>
|
|
<div class="d-flex align-items-center">
|
|
<div class="form-check" style="padding-right:10px;">
|
|
<input type="radio" id="yespen" name="pendingDuration" value="Yes" class="form-check-input" onclick="toggleInputField(this)">
|
|
<label for="yespen" class="form-check-label">yes</label>
|
|
</div>
|
|
<div class="form-check">
|
|
<input type="radio" id="nopen" name="pendingDuration" value="No" class="form-check-input" onclick="toggleInputField(this)">
|
|
<label for="nopen" class="form-check-label">no</label>
|
|
</div>
|
|
</div>
|
|
<div id="clickyesdiv" style="display: none; margin-top: 10px;">
|
|
<label for="clickyes" class="form-label">Please specify:<span class="text-danger">*</span></label>
|
|
<input type="text" id="Clickyes" class="form-control" placeholder="Enter reason">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
<label for="DP" class="form-label fw-bold">DP<span class="text-danger">*</span></label>
|
|
<div class="d-flex align-items-center">
|
|
<div class="form-check " style="padding-right:10px;">
|
|
<input type="radio" id="yes" name="DP" value="yes" class="form-check-input">
|
|
<label for="yes" class="form-check-label">yes</label>
|
|
</div>
|
|
<br>
|
|
<div class="form-check" >
|
|
<input type="radio" id="No" name="DP" value="no" class="form-check-input">
|
|
<label for="No" class="form-check-label">no</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-12">
|
|
<label for="Remarks" class="form-label fw-bold">Comments/Remarks <span class="text-danger">*</span></label>
|
|
<div class="dropdown">
|
|
<textarea id="remarks" class="form-control" rows="4" placeholder="Enter your remarks here" required></textarea>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mt-4">
|
|
<div class="col-12 d-flex justify-content-center">
|
|
<button id="submitButton" class="btn btn-primary mt-2 mx-2">Mark as Forward to Pension</button>
|
|
<button id="cancelButton" class="btn btn-secondary mt-2">Cancel</button>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="pageLoader" style="display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255, 255, 255, 0.8); z-index: 9999; text-align: center;">
|
|
<div style="position: relative; top: 50%; transform: translateY(-50%);">
|
|
<div class="spinner-border text-primary" role="status" style="width: 3rem; height: 3rem;">
|
|
<span class="sr-only">Loading...</span>
|
|
</div>
|
|
<!-- Add the 'Please wait' text below the spinner -->
|
|
<p style="margin-top: 1rem; font-size: 1.2rem; color: #007bff;">Please wait...</p>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div th:replace="~{fragments/modules/base/app_module_menu_box :: div}"></div>
|
|
|
|
<script th:replace="~{fragments/modules/base/script :: script}"></script>
|
|
<script src="node_modules/tempusdominus-bootstrap-4/build/js/tempusdominus-bootstrap-4.min.js"></script>
|
|
<!-- Bootstrap 5 JS -->
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
|
|
|
<script>
|
|
|
|
|
|
$(document).ready(function (){
|
|
|
|
|
|
// Handle Search button click
|
|
$('#searchButton').on('click', function () {
|
|
const empCode = $('#empCode').val();
|
|
|
|
console.log("empCode",empCode);
|
|
|
|
if (empCode) {
|
|
$('#pageLoader').show();
|
|
document.getElementById("employeeCard").style.display = "block";
|
|
}else{
|
|
|
|
|
|
Swal.fire({
|
|
icon: "warning", // Display a warning icon
|
|
title: "Missing Employee Number",
|
|
text: "Please enter an employee number to proceed.",
|
|
confirmButtonText: "OK",
|
|
customClass: {
|
|
confirmButton: "btn btn-primary" // Optional styling for the button
|
|
}
|
|
});
|
|
//document.getElementById("newemployeeCard").style.display = "block";
|
|
return;
|
|
}
|
|
|
|
// Format dates to dd-MM-yyyy
|
|
|
|
$('#pageLoader').show();
|
|
$('#employeeCard').hide();
|
|
$('#newemployeeCard').hide();
|
|
|
|
$('#retirement').val('');
|
|
$('#reason').val('');
|
|
$('#otherReason').val('');
|
|
// $('#filesentdate').val('');
|
|
$('#remarks').val('');
|
|
$('input[name="pendingDuration"]').prop('checked', false); // Clear "pendingDuration" radio buttons
|
|
$('input[name="DP"]').prop('checked', false); // Clear "DP" radio buttons
|
|
|
|
|
|
// Step 1: Check if employee exists in the database and fetch employee details if not
|
|
$('#pageLoader').show(); // Show loader before starting AJAX requests
|
|
$.ajax({
|
|
url: '/gcc/api/department/newentry/prexists', // Endpoint to check existence
|
|
type: 'GET',
|
|
data: { empCode: empCode },
|
|
success: function (existsResponse) {
|
|
console.log("Exists API Response:", existsResponse);
|
|
$('#pageLoader').hide(); // Hide loader after the first API response
|
|
|
|
if (existsResponse && existsResponse.exists) {
|
|
console.log(`Employee Code ${empCode} exists in the database.`);
|
|
Swal.fire({
|
|
icon: "warning",
|
|
title: "Already Exists",
|
|
text: "This employee number already exists.",
|
|
confirmButtonText: "OK",
|
|
customClass: {
|
|
confirmButton: "btn btn-primary"
|
|
}
|
|
});
|
|
return; // Exit if employee already exists
|
|
}
|
|
|
|
// If employee does not exist, proceed to fetch details
|
|
$('#pageLoader').show(); // Show loader for the second API call
|
|
$.ajax({
|
|
url: '/gcc/api/department/newentry/employeedetails', // Correct API URL
|
|
type: 'GET',
|
|
data: { empCode: empCode },
|
|
success: function (response) {
|
|
$('#pageLoader').hide(); // Hide loader after the second API response
|
|
console.log("Employee Details API Response:", response.list);
|
|
|
|
if (response.list && response.list.length > 0) {
|
|
// Extract employee details
|
|
let employeeDetails = response.list[0];
|
|
console.log("Employee Details:", employeeDetails);
|
|
|
|
const loggedInDeptId = $('#deptId').text().trim(); // Get logged-in deptId dynamically
|
|
|
|
// Validate department ID
|
|
if (employeeDetails.ID_DEPT !== loggedInDeptId) {
|
|
Swal.fire({
|
|
icon: "error",
|
|
title: "Access Denied",
|
|
text: "This employee does not belong to your department. Please try again with a valid employee code.",
|
|
confirmButtonText: "OK",
|
|
customClass: {
|
|
confirmButton: "btn btn-danger"
|
|
}
|
|
});
|
|
return; // Exit if the department does not match
|
|
}
|
|
|
|
// Populate employee details in the form
|
|
$('#employeeno').val(employeeDetails.EMPLOYEE_CODE);
|
|
$('#employeename').val(employeeDetails.EMPLOYEE_NAME);
|
|
$('#department').val(employeeDetails.DEPARTMENT);
|
|
$('#designation').val(employeeDetails.DESIGNATION);
|
|
$('#classes').val(employeeDetails.GROUP_TYPE);
|
|
$('#retirementdate').val(employeeDetails.RETIREMENT_DATE);
|
|
|
|
$('#EmployeeCode').text(empCode);
|
|
|
|
// Show the employee card
|
|
$('#employeeCard').show();
|
|
|
|
|
|
} else {
|
|
// No details found for the employee
|
|
Swal.fire({
|
|
icon: "warning",
|
|
title: "No Data Found",
|
|
text: "No details found for this employee number.",
|
|
confirmButtonText: "OK",
|
|
customClass: {
|
|
confirmButton: "btn btn-primary"
|
|
}
|
|
});
|
|
|
|
document.getElementById("newemployeeCard").style.display = "block"; // Show the new employee card
|
|
}
|
|
},
|
|
error: function () {
|
|
$('#pageLoader').hide(); // Hide loader on error
|
|
Swal.fire({
|
|
icon: "error",
|
|
title: "Error",
|
|
text: "An error occurred while fetching data. Please try again.",
|
|
confirmButtonText: "OK",
|
|
});
|
|
}
|
|
});
|
|
},
|
|
|
|
error: function () {
|
|
$('#pageLoader').hide(); // Hide loader on error
|
|
Swal.fire({
|
|
icon: "error",
|
|
title: "Error",
|
|
text: "An error occurred while checking the employee. Please try again.",
|
|
confirmButtonText: "OK",
|
|
});
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
|
|
})
|
|
|
|
// Attach event listener to the submit button
|
|
/* document.getElementById('submitButton').addEventListener('click', function () {
|
|
saveEntryDetails(); // Trigger save function when clicked
|
|
}); */
|
|
|
|
//$('#submitButton').one('click', saveEntryDetails);
|
|
|
|
$('#submitButton').off('click').on('click', saveEntryDetails);
|
|
|
|
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
// Get today's date
|
|
const today = new Date();
|
|
|
|
// Format the date as DD-MM-YYYY for display
|
|
const day = String(today.getDate()).padStart(2, '0');
|
|
const month = String(today.getMonth() + 1).padStart(2, '0'); // Months are 0-based
|
|
const year = today.getFullYear();
|
|
|
|
// Combine into DD-MM-YYYY format for display
|
|
const formattedDateDisplay = `${day}-${month}-${year}`;
|
|
|
|
// Set the value of the input field to the current date (in DD-MM-YYYY format for display)
|
|
document.getElementById("filesentdate").value = formattedDateDisplay;
|
|
|
|
|
|
});
|
|
|
|
|
|
function convertDateFormat(dateString) {
|
|
if (!dateString) return '';
|
|
let [day, month, year] = dateString.split('-');
|
|
return `${year}-${month}-${day}`;
|
|
}
|
|
|
|
|
|
// Dropdown for Type of Retriment
|
|
$(document).ready(function () {
|
|
function loadRetirementTypes() {
|
|
$.ajax({
|
|
url: "/gcc/api/getRetrimentTypes",
|
|
type: "GET",
|
|
success: function (data) {
|
|
var dropdown = $("#retirement");
|
|
dropdown.empty();
|
|
dropdown.append('<option value="" selected>-- Select Option --</option>');
|
|
|
|
$.each(data, function (key, entry) {
|
|
dropdown.append($('<option></option>').attr('value', entry.retriment_type).text(entry.retriment_type));
|
|
});
|
|
},
|
|
error: function () {
|
|
console.log("Error loading dropdown data.");
|
|
}
|
|
});
|
|
}
|
|
|
|
// Call function on page load
|
|
loadRetirementTypes();
|
|
});
|
|
|
|
|
|
|
|
|
|
//Dropdown for Reason of Provisional
|
|
$(document).ready(function () {
|
|
function loadRetirementReasonTypes() {
|
|
$.ajax({
|
|
url: "/gcc/api/getProvisionalReasonTypes",
|
|
type: "GET",
|
|
success: function (data) {
|
|
var dropdown = $("#reason");
|
|
dropdown.empty();
|
|
dropdown.append('<option value="" selected>-- Select Option --</option>');
|
|
|
|
$.each(data, function (key, entry) {
|
|
dropdown.append($('<option></option>').attr('value', entry.provisional_reason).text(entry.provisional_reason));
|
|
});
|
|
},
|
|
error: function () {
|
|
console.log("Error loading dropdown data.");
|
|
}
|
|
});
|
|
}
|
|
|
|
// Call function on page load
|
|
loadRetirementReasonTypes();
|
|
});
|
|
|
|
|
|
document.getElementById('reason').addEventListener('change', function () {
|
|
const otherReasonDiv = document.getElementById('otherReasonDiv'); // Get the div to show/hide
|
|
if (this.value === 'Others') {
|
|
otherReasonDiv.style.display = 'block'; // Show the input field if "Others" is selected
|
|
} else {
|
|
otherReasonDiv.style.display = 'none'; // Hide the input field otherwise
|
|
document.getElementById('otherReason').value = ''; // Clear the input field
|
|
}
|
|
});
|
|
|
|
|
|
|
|
|
|
function toggleInputField(radio) {
|
|
const inputFieldDiv = document.getElementById('clickyesdiv');
|
|
if (radio.value === "Yes") {
|
|
inputFieldDiv.style.display = 'block';
|
|
} else {
|
|
inputFieldDiv.style.display = 'none';
|
|
document.getElementById('Clickyes').value = ''; // Clear the input field
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Trigger search on pressing Enter key
|
|
$('#empCode').on('keydown', function (event) {
|
|
if (event.key === 'Enter') {
|
|
event.preventDefault(); // Prevent default form submission or page reload
|
|
|
|
const empCode = $('#empCode').val(); // Get the value of empCode
|
|
if (!empCode) {
|
|
// Show Swal alert if the employee number is missing
|
|
Swal.fire({
|
|
icon: "warning", // Display a warning icon
|
|
title: "Missing Employee Number",
|
|
text: "Please enter an employee number to proceed.",
|
|
confirmButtonText: "OK",
|
|
customClass: {
|
|
confirmButton: "btn btn-primary" // Optional styling for the button
|
|
}
|
|
});
|
|
return; // Stop further execution
|
|
}
|
|
|
|
$('#searchButton').click(); // Trigger the click event of the search button
|
|
}
|
|
});
|
|
|
|
|
|
// Handle close button click
|
|
$('#cancelButton').click(function () {
|
|
// Clear the input field value
|
|
$('#empCode').val('');
|
|
document.getElementById('otherReasonDiv').style.display = 'none';
|
|
// Hide the card
|
|
$('#employeeCard').hide();
|
|
});
|
|
|
|
// Handle close button click
|
|
$('#cancelButtonnew').click(function () {
|
|
// Clear the input field value
|
|
$('#empCode').val('');
|
|
|
|
$('#newemployeeCard').hide();
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function saveEntryDetails() {
|
|
let selectedDPValue = $('input[name="DP"]:checked').val();
|
|
let selectedPendingDurationValue = $('input[name="pendingDuration"]:checked').val();
|
|
let selectedReasonValue = $('#reason').val();
|
|
let selectedOtherReason = null;
|
|
let selectedReasonPending = null;
|
|
|
|
// Check for "Others" in Reason of Pension
|
|
if (selectedReasonValue === 'Others') {
|
|
selectedOtherReason = $('#otherReason').val()?.trim() || null;
|
|
if (!selectedOtherReason) {
|
|
Swal.fire({
|
|
icon: 'warning',
|
|
title: 'Validation Error',
|
|
text: 'Please specify the reason for selecting "Others".',
|
|
confirmButtonText: 'OK'
|
|
});
|
|
return;
|
|
}
|
|
}
|
|
|
|
// Check for "Yes" in Pending Duration
|
|
if (selectedPendingDurationValue === 'Yes') {
|
|
selectedReasonPending = $('#Clickyes').val()?.trim() || null;
|
|
if (!selectedReasonPending) {
|
|
Swal.fire({
|
|
icon: 'warning',
|
|
title: 'Validation Error',
|
|
text: 'Please specify the reason for selecting "Yes" for Pending Duration.',
|
|
confirmButtonText: 'OK'
|
|
});
|
|
return;
|
|
}
|
|
}
|
|
|
|
// Create the entryDetails object
|
|
let entryDetails = {
|
|
empNo: $('#employeeno').val()?.trim(),
|
|
empName: $('#employeename').val()?.trim(),
|
|
deptName: $('#department').val()?.trim(),
|
|
designation: $('#designation').val()?.trim(),
|
|
retirementClass: $('#classes').val()?.trim(),
|
|
retirementDate: $('#retirementdate').val()?.trim(),
|
|
typeOfRetirement: $('#retirement').val()?.trim(),
|
|
ReasonofPension: selectedReasonValue || null,
|
|
// Convert DD-MM-YYYY to YYYY-MM-DD
|
|
dateToAudit: convertDateFormat($('#filesentdate').val()?.trim()),
|
|
//dateToAudit: $('#filesentdate').val()?.trim(),
|
|
pendingDuration: selectedPendingDurationValue,
|
|
reasonofPending: selectedReasonPending || null,
|
|
dp: selectedDPValue,
|
|
otherReason: selectedOtherReason,
|
|
remarks: $('#remarks').val()?.trim(),
|
|
deptId: $('#deptId').text()?.trim(),
|
|
filemovedby: $('#userId').text()?.trim(),
|
|
filecategory: $('#filecategory').text()?.trim()
|
|
};
|
|
|
|
|
|
// Validate each required field separately
|
|
|
|
if (!entryDetails.typeOfRetirement) {
|
|
Swal.fire({
|
|
icon: 'warning',
|
|
title: 'Validation Error!',
|
|
text: 'Type of Retirement is required.',
|
|
confirmButtonText: 'OK'
|
|
});
|
|
console.warn("Validation error: Missing Type of Retirement");
|
|
return;
|
|
}
|
|
|
|
if (!entryDetails.ReasonofPension) {
|
|
Swal.fire({
|
|
icon: 'warning',
|
|
title: 'Validation Error!',
|
|
text: 'Reason of Pension is required.',
|
|
confirmButtonText: 'OK'
|
|
});
|
|
console.warn("Validation error: Missing Reason of Pension");
|
|
return;
|
|
}
|
|
|
|
if (!entryDetails.pendingDuration) {
|
|
Swal.fire({
|
|
icon: 'warning',
|
|
title: 'Validation Error!',
|
|
text: 'Pending Duration is required.',
|
|
confirmButtonText: 'OK'
|
|
});
|
|
console.warn("Validation error: Missing Pending Duration");
|
|
return;
|
|
}
|
|
|
|
if (!entryDetails.dp) {
|
|
Swal.fire({
|
|
icon: 'warning',
|
|
title: 'Validation Error!',
|
|
text: 'DP is required.',
|
|
confirmButtonText: 'OK'
|
|
});
|
|
console.warn("Validation error: Missing DP");
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
if (!entryDetails.remarks) {
|
|
Swal.fire({
|
|
icon: 'warning',
|
|
title: 'Validation Error!',
|
|
text: 'Remarks are required.',
|
|
confirmButtonText: 'OK'
|
|
});
|
|
console.warn("Validation error: Missing Remarks");
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
console.log("entryDetails==", entryDetails);
|
|
|
|
// Disable the button to prevent multiple submissions
|
|
$('#submitButton').prop('disabled', true).text('Processing...');
|
|
|
|
// Make AJAX POST request
|
|
$.ajax({
|
|
url: '/gcc/api/department/newentry/saveEmployeeDetailsProvisionalretirement',
|
|
type: 'POST',
|
|
contentType: 'application/json',
|
|
data: JSON.stringify(entryDetails),
|
|
success: function (response) {
|
|
$('#submitButton').prop('disabled', false).text('Mark as Forward to Pension');
|
|
Swal.fire({
|
|
icon: 'success',
|
|
title: 'Success',
|
|
text: response,
|
|
allowOutsideClick: false,
|
|
allowEscapeKey: false,
|
|
allowEnterKey: false,
|
|
confirmButtonText: 'OK'
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
window.location.href = "/gcc/department/newentry/provisionalretirement";
|
|
}
|
|
});
|
|
},
|
|
error: function (xhr, status, error) {
|
|
$('#submitButton').prop('disabled', false).text('Mark as Forward to Pension');
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Error',
|
|
text: 'Failed to save details. Please try again.',
|
|
confirmButtonText: 'OK'
|
|
});
|
|
console.error('Error:', xhr.responseText);
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
</body>
|
|
</html>
|
|
|
|
|
|
|