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.
802 lines
30 KiB
802 lines
30 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 */
|
|
}
|
|
|
|
.modal-body label{
|
|
padding-top: 10px;
|
|
}
|
|
|
|
</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>Retirement</h5>
|
|
<span>Department Entries</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">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}"></span> Department</h5>
|
|
<h5 style="font-weight:bold;"><span th:text="${deptId}" id="deptId" style="display:none"></span><span th:text="${filecategory}" id="filecategory" style="display:none"></span>
|
|
<span th:text="${userId}" id="userId" style="display:none"></span> New Entry - Retirement</h5>
|
|
<div class="row mb-4">
|
|
|
|
<div class="col-md-4">
|
|
<label for="fromDate" class="form-label fw-bold">From Date<span class="text-danger">*</span></label>
|
|
<input type="date" id="fromDate" class="form-control" onclick="this.showPicker()">
|
|
</div>
|
|
<div class="col-md-4">
|
|
<label for="toDate" class="form-label fw-bold">To Date<span class="text-danger">*</span></label>
|
|
<input type="date" id="toDate" class="form-control" onclick="this.showPicker()" >
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mt-4">
|
|
<div class="col-12 d-flex justify-content-center">
|
|
<button id="searchButton" class="btn btn-primary mx-2" >Search</button>
|
|
<button id="resetButton" class="btn btn-secondary">Reset</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="employeedetails">
|
|
<table id="FollowupDatatable" class="table table-striped table-bordered table-hover dataTable" role="grid">
|
|
<thead class="thead-dark">
|
|
<tr role="row">
|
|
<th class="text-center">S.No</th>
|
|
<th class="text-center">Employee Code</th>
|
|
<th class="text-center">Name </th>
|
|
<th class="text-center">DOB</th>
|
|
<th class="text-center">Retirement Date</th>
|
|
<th class="text-center">Department</th>
|
|
<th class="text-center">Designation</th>
|
|
<th class="text-center">View</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody style="text-align:center;">
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
</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>
|
|
<!-- Modal -->
|
|
<div class="modal fade" id="returnretrieddetailsModal" tabindex="-1" role="dialog" aria-labelledby="detailsModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false">
|
|
<div class="modal-dialog modal-lg" role="document">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="detailsModalLabel">
|
|
New Entry - Retirement (<span id="modalEmployeeCode"></span>)
|
|
</h5>
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="row">
|
|
|
|
<div class="col-sm-6">
|
|
<label for="employeeno" class="form-label fw-bold">Employee No <span class="text-danger">*</span></label>
|
|
<input type="number" id="employeeno" class="form-control" readonly>
|
|
</div>
|
|
<div class="col-sm-6">
|
|
<label for="employeename" class="form-label fw-bold">Employee Name <span class="text-danger">*</span></label>
|
|
<input type="text" id="employeename" class="form-control" readonly>
|
|
</div>
|
|
<div class="col-sm-6">
|
|
<label for="department" class="form-label fw-bold">Department <span class="text-danger">*</span></label>
|
|
<input type="text" id="department" class="form-control" readonly>
|
|
</div>
|
|
<div class="col-sm-6">
|
|
<label for="designation" class="form-label fw-bold">Designation <span class="text-danger">*</span></label>
|
|
<input type="text" id="designation" class="form-control" readonly>
|
|
</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="classes" class="form-label fw-bold">Class <span class="text-danger">*</span></label>
|
|
<input type="text" id="classes" class="form-control" readonly>
|
|
</div>
|
|
|
|
<div class="col-sm-6">
|
|
<label for="typeretirement" class="form-label fw-bold">Type Of Retirement<span class="text-danger">*</span></label>
|
|
<select id="typeretirement" class="form-select" style="width: 100%;height: 30px;" required>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<div class="col-sm-6">
|
|
<label for="datefile" class="form-label fw-bold">Date File Sent to Audit <span class="text-danger">*</span></label>
|
|
<input type="text" id="datefile" class="form-control" readonly>
|
|
</div>
|
|
|
|
|
|
<div class="col-md-12">
|
|
<label for="remarks" class="form-label fw-bold">Comments/Remarks <span class="text-danger">*</span></label>
|
|
<textarea id="remarks" class="form-control" rows="2" placeholder="Enter your remarks here"></textarea>
|
|
</div>
|
|
|
|
</div>
|
|
<div class="row mt-4">
|
|
<div class="col-12 d-flex justify-content-center">
|
|
<button id="auditsubmit" class="btn btn-primary mx-2">Mark as sent audit</button>
|
|
<button type="button" class="btn btn-secondary" data-dismiss="modal" id="close">Close</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</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>
|
|
|
|
|
|
|
|
// Initialize DataTable
|
|
// Helper function to convert yyyy-MM-dd to dd-MM-yyyy for API calls
|
|
function formatDateForAPI(dateStr) {
|
|
const [year, month, day] = dateStr.split('-');
|
|
return `${day}-${month}-${year}`; // Convert to dd-MM-yyyy
|
|
}
|
|
|
|
document.getElementById('resetButton').addEventListener('click', function () {
|
|
event.preventDefault();
|
|
|
|
window.location.href="/gcc/department/newentry/retirement";
|
|
|
|
});
|
|
|
|
|
|
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("datefile").value = formattedDateDisplay;
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function convertDateFormat(dateString) {
|
|
if (!dateString) return '';
|
|
let [day, month, year] = dateString.split('-');
|
|
return `${year}-${month}-${day}`;
|
|
}
|
|
|
|
//Function to convert date to dd/mm/yyyy format
|
|
|
|
|
|
$(document).ready(function () {
|
|
// Initialize the DataTable
|
|
const dataTable = $('#FollowupDatatable').DataTable({
|
|
dom: 'Bftip',
|
|
columnDefs: [
|
|
{ targets: 'no-sort', orderable: false }
|
|
],
|
|
lengthMenu: [
|
|
[50, 100, 200, 500, -1],
|
|
['50 rows', '100 rows', '200 rows', 'Show all']
|
|
],
|
|
scrollY: '50vh',
|
|
buttons: [
|
|
{ extend: 'pageLength', className: 'btn btn-warning' },
|
|
{ title: 'Data export', extend: 'copyHtml5', text: 'Copy', className: 'btn btn-secondary' },
|
|
{ extend: 'excelHtml5', text: 'Excel', className: 'btn btn-secondary' },
|
|
{ extend: 'csvHtml5', text: 'CSV', className: 'btn btn-secondary' },
|
|
{ extend: 'pdfHtml5', text: 'PDF', className: 'btn btn-secondary' }
|
|
],
|
|
fixedHeader: true,
|
|
autoWidth: true,
|
|
responsive: true,
|
|
searching: false, // Disable searching as it's custom
|
|
paging: true,
|
|
info: true,
|
|
ordering: false,
|
|
});
|
|
|
|
// Update To Date's min attribute when From Date changes
|
|
$('#fromDate').on('change', function () {
|
|
const fromDate = $(this).val();
|
|
$('#toDate').attr('min', fromDate); // Update min attribute for To Date
|
|
|
|
// If To Date is earlier than the new From Date, adjust it
|
|
const toDate = $('#toDate').val();
|
|
if (new Date(toDate) < new Date(fromDate)) {
|
|
$('#toDate').val(fromDate);
|
|
}
|
|
});
|
|
|
|
// Update From Date's max attribute when To Date changes
|
|
$('#toDate').on('change', function () {
|
|
const toDate = $(this).val();
|
|
$('#fromDate').attr('max', toDate); // Update max attribute for From Date
|
|
|
|
// If From Date is later than the new To Date, adjust it
|
|
const fromDate = $('#fromDate').val();
|
|
if (new Date(fromDate) > new Date(toDate)) {
|
|
$('#fromDate').val(toDate);
|
|
}
|
|
});
|
|
|
|
getstart(dataTable);
|
|
|
|
document.getElementById('searchButton').addEventListener('click', function () {
|
|
event.preventDefault();
|
|
|
|
getstart(dataTable);
|
|
|
|
});
|
|
|
|
function getstart(dataTable)
|
|
{
|
|
const fromDate=$('#fromDate').val();
|
|
const toDate=$('#toDate').val();
|
|
const deptId = $('#deptId').text().trim(); // Default department ID
|
|
const file_category = $('#filecategory').text().trim();
|
|
|
|
console.log("fromDate==",fromDate);
|
|
console.log("toDate==",toDate);
|
|
console.log("deptId", deptId);
|
|
|
|
|
|
/* if (!fromDate && !toDate) {
|
|
Swal.fire({
|
|
icon: "info",
|
|
title: "Info",
|
|
text: "Select Both Date for Searching",
|
|
confirmButtonText: "OK",
|
|
});
|
|
return;
|
|
} */
|
|
|
|
if (!deptId) {
|
|
Swal.fire({
|
|
icon: "warning",
|
|
title: "Error",
|
|
text: "Department ID is Missing",
|
|
confirmButtonText: "OK",
|
|
});
|
|
return;
|
|
}
|
|
|
|
$('#pageLoader').show();
|
|
// Call the API
|
|
$.ajax({
|
|
url: '/gcc/api/department/newentry/retirementdetails', // Correct API URL
|
|
type: 'GET',
|
|
data: { deptId: deptId,
|
|
file_category:file_category,
|
|
fromDate:fromDate,
|
|
toDate:toDate
|
|
},
|
|
success: function (response) {
|
|
$('#pageLoader').hide();
|
|
console.log("response:", response.details);
|
|
fromDate1 = response.fromDate; // Extract the fromDate
|
|
toDate1 = response.toDate; // Extract the toDate
|
|
|
|
|
|
// Set formatted date values
|
|
$('#fromDate').val(fromDate1);
|
|
$('#toDate').val(toDate1);
|
|
|
|
if (response.status === "success") {
|
|
|
|
// Clear existing data
|
|
dataTable.clear();
|
|
|
|
let table = $('#FollowupDatatable').DataTable({
|
|
destroy: true,
|
|
searching: true,
|
|
autoWidth: true,
|
|
responsive: true,
|
|
paging: true,
|
|
info: true,
|
|
data: response.details.list,
|
|
|
|
columns: [
|
|
{
|
|
data: null,
|
|
render: (data, type, row, meta) => meta.row + 1,
|
|
className: 'text-center'
|
|
},
|
|
|
|
{ data: 'EMPLOYEE_CODE', defaultContent: '-', className: 'text-center' },
|
|
{ data: 'EMPLOYEE_NAME', defaultContent: '-', className: 'text-center' },
|
|
{ data: 'DATE_OF_BIRTH', defaultContent: '-', className: 'text-center' },
|
|
{ data: 'RETIREMENT_DATE', defaultContent: '-', className: 'text-center' },
|
|
{ data: 'DEPARTMENT', defaultContent: '-', className: 'text-center' },
|
|
{ data: 'DESIGNATION', defaultContent: '-', className: 'text-center' },
|
|
{
|
|
data: 'EMPLOYEE_CODE',
|
|
render: function(data, type, row) {
|
|
return `
|
|
<td class="text-center">
|
|
<button type="button" class="btn btn-info" data-employee-code="${data}">
|
|
View
|
|
</button>
|
|
</td>`;
|
|
},
|
|
className: 'text-center'
|
|
}
|
|
|
|
],
|
|
dom: 'Bfrtip',
|
|
buttons: [
|
|
{
|
|
extend: 'pageLength',
|
|
className: 'btn btn-warning'
|
|
},
|
|
{
|
|
title: 'Data export',
|
|
extend: 'copyHtml5',
|
|
text: 'Copy',
|
|
className: 'btn btn-secondary',
|
|
id: 'copyBtn'
|
|
},
|
|
{
|
|
extend: 'excelHtml5',
|
|
text: 'Excel',
|
|
className: 'btn btn-secondary',
|
|
id: 'excelBtn'
|
|
},
|
|
{
|
|
extend: 'csvHtml5',
|
|
text: 'CSV',
|
|
className: 'btn btn-secondary',
|
|
id: 'csvBtn'
|
|
},
|
|
{
|
|
extend: 'pdfHtml5',
|
|
text: 'PDF',
|
|
className: 'btn btn-secondary',
|
|
id: 'pdfBtn'
|
|
}
|
|
],
|
|
columnDefs: [
|
|
{ targets: 'no-sort', orderable: false }
|
|
],
|
|
lengthMenu: [
|
|
[50, 100, 200, 500, -1],
|
|
['50 rows', '100 rows', '200 rows', 'Show all']
|
|
],
|
|
scrollY: '50vh',
|
|
fixedColumns: {
|
|
left: 1,
|
|
right: 1
|
|
}
|
|
});
|
|
|
|
}
|
|
else if (response.status === "deptid") {
|
|
// Display the error message for missing department ID
|
|
dataTable.clear().draw();
|
|
$('#FollowupDatatable tbody').html(`
|
|
<tr>
|
|
<td colspan="8" class="text-center text-danger">${response.message}</td>
|
|
</tr>
|
|
`);
|
|
} else if (response.status === "nodata") {
|
|
// Display the no data message
|
|
dataTable.clear().draw();
|
|
$('#FollowupDatatable tbody').html(`
|
|
<tr>
|
|
<td colspan="8" class="text-center text-danger">${response.message}</td>
|
|
</tr>
|
|
`);
|
|
}
|
|
else {
|
|
$('#pageLoader').hide();
|
|
dataTable.clear().draw();
|
|
Swal.fire({
|
|
icon: "info",
|
|
title: "No Data",
|
|
text: "No data available for the selected date range.",
|
|
confirmButtonText: "OK",
|
|
});
|
|
}
|
|
},
|
|
error: function () {
|
|
$('#pageLoader').hide();
|
|
Swal.fire({
|
|
icon: "error",
|
|
title: "Error",
|
|
text: "An error occurred while fetching data. Please try again.",
|
|
confirmButtonText: "OK",
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
});
|
|
|
|
|
|
$(document).ready(function () {
|
|
function loadRetirementTypes() {
|
|
$.ajax({
|
|
url: "/gcc/api/getRetrimentTypes",
|
|
type: "GET",
|
|
success: function (data) {
|
|
var dropdown = $("#typeretirement");
|
|
dropdown.empty();
|
|
dropdown.append('<option value="" selected>-- Select Option --</option>');
|
|
|
|
$.each(data, function (key, entry) {
|
|
if (entry.retriment_type !== "Provisional") { // Exclude "Provisional"
|
|
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();
|
|
});
|
|
|
|
// Fetch count on page load
|
|
|
|
$(document).ready(function () {
|
|
|
|
$(document).on('click', '.btn-info', function () {
|
|
const empCode = $(this).data('employee-code'); // Get EMPLOYEE_CODE from button
|
|
fetchEmployeeDetails(empCode); // Call the function to fetch employee details
|
|
});
|
|
|
|
// Initialize the modal with static backdrop and disabled keyboard closing
|
|
$('#returnretrieddetailsModal').modal({
|
|
backdrop: 'static',
|
|
keyboard: false,
|
|
show: false // Ensure it doesn't auto-show on page load
|
|
});
|
|
|
|
|
|
// Handle close button click
|
|
$('#close').click(function () {
|
|
$('#returnretrieddetailsModal').modal('hide');
|
|
});
|
|
|
|
$('.close').click(function () {
|
|
$('#returnretrieddetailsModal').modal('hide');
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
function fetchEmployeeDetails(empCode) {
|
|
|
|
// Clear previous values in the modal fields
|
|
$('#employeeno').val('');
|
|
$('#employeename').val('');
|
|
$('#department').val('');
|
|
$('#designation').val('');
|
|
$('#retirementdate').val('');
|
|
$('#classes').val('');
|
|
$('#typeretirement').val('').prop('selected', true); // Reset the dropdown to default
|
|
//$('#datefile').val('');
|
|
$('#remarks').val('');
|
|
|
|
$.ajax({
|
|
url: '/gcc/api/department/newentry/employeedetails', // API to fetch employee details
|
|
type: 'GET',
|
|
data: { empCode: empCode }, // Pass EMPLOYEE_CODE as a parameter
|
|
success: function (response) {
|
|
if (response.list && response.list.length > 0) {
|
|
|
|
let employeeDetails = response.list[0];
|
|
console.log("employeecode",response);
|
|
|
|
// Populate modal fields
|
|
$('#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);
|
|
|
|
|
|
// Update the modal title with the employee code
|
|
$('#modalEmployeeCode').text(empCode);
|
|
|
|
// Show the modal
|
|
$('#returnretrieddetailsModal').modal('show');
|
|
|
|
|
|
|
|
} else {
|
|
Swal.fire({
|
|
icon: 'info',
|
|
title: 'No Data',
|
|
text: 'No details found for the selected employee.',
|
|
confirmButtonText: 'OK',
|
|
});
|
|
}
|
|
},
|
|
error: function () {
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Error',
|
|
text: 'Failed to fetch employee details. Please try again.',
|
|
confirmButtonText: 'OK',
|
|
});
|
|
},
|
|
});
|
|
}
|
|
|
|
//$('#auditsubmit').one('click', saveEntryDetails);
|
|
|
|
$('#auditsubmit').off('click').on('click', saveEntryDetails);
|
|
|
|
/* document.getElementById('auditsubmit').addEventListener('click', function () {
|
|
// Trigger the save function when the button is clicked
|
|
saveEntryDetails();
|
|
}); */
|
|
|
|
|
|
|
|
function saveEntryDetails() {
|
|
let entryDetails = {
|
|
empNo: $('#employeeno').val(),
|
|
empName: $('#employeename').val(),
|
|
deptName: $('#department').val(),
|
|
designation: $('#designation').val(),
|
|
typeOfRetirement: $('#typeretirement').val(),
|
|
retirementdate: $('#retirementdate').val(),
|
|
retirementclass: $('#classes').val(),
|
|
dateToAudit: convertDateFormat($('#datefile').val()?.trim()),
|
|
remarks: $('#remarks').val(),
|
|
deptId: $('#deptId').text().trim(),
|
|
filemovedby: $('#userId').text().trim(),
|
|
filecategory: $('#filecategory').text().trim()
|
|
};
|
|
|
|
console.log("entryDetails:", entryDetails);
|
|
|
|
|
|
if(!entryDetails.typeOfRetirement){
|
|
Swal.fire({
|
|
icon: 'warning',
|
|
title: 'Validation Error!',
|
|
text: 'Type of Retirement.',
|
|
confirmButtonText: 'OK'
|
|
});
|
|
return;
|
|
}
|
|
|
|
|
|
if(!entryDetails.remarks){
|
|
Swal.fire({
|
|
icon: 'warning',
|
|
title: 'Validation Error!',
|
|
text: 'Remarks.',
|
|
confirmButtonText: 'OK'
|
|
});
|
|
return;
|
|
}
|
|
|
|
// Disable the button to prevent multiple submissions
|
|
$('#auditsubmit').prop('disabled', true).text('Processing...');
|
|
|
|
$.ajax({
|
|
url: '/gcc/api/department/newentry/saveEmployeeDetails',
|
|
type: 'POST',
|
|
contentType: 'application/json',
|
|
data: JSON.stringify(entryDetails),
|
|
success: function (response) {
|
|
$('#auditsubmit').prop('disabled', false).text('Mark as sent audit');
|
|
Swal.fire({
|
|
icon: 'success',
|
|
title: 'Success',
|
|
text: response,
|
|
allowOutsideClick: false,
|
|
allowEscapeKey: false,
|
|
allowEnterKey: false,
|
|
confirmButtonText: 'OK'
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
$('#auditsubmit').prop('disabled', false).text('Mark as sent audit');
|
|
window.location.href = "/gcc/department/newentry/retirement";
|
|
console.log("Continue clicked");
|
|
}
|
|
});
|
|
},
|
|
error: function (xhr, status, error) {
|
|
$('#auditsubmit').prop('disabled', false).text('Mark as sent audit');
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Error',
|
|
text: 'Failed to save details. Please try again.',
|
|
confirmButtonText: 'OK'
|
|
});
|
|
console.error('Error:', xhr.responseText);
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|