|
|
@ -911,8 +911,8 @@ |
|
|
<!-- Joined Date --> |
|
|
<!-- Joined Date --> |
|
|
<div class="col-md-6"> |
|
|
<div class="col-md-6"> |
|
|
<label for="update-emp-joined-date" class="form-label fw-semibold text-secondary">Joined |
|
|
<label for="update-emp-joined-date" class="form-label fw-semibold text-secondary">Joined |
|
|
Date <span class="text-danger">*</span></label> |
|
|
|
|
|
<input type="date" class="form-control w-100" id="update-emp-joined-date" required |
|
|
|
|
|
|
|
|
Date</label> |
|
|
|
|
|
<input type="date" class="form-control w-100" id="update-emp-joined-date" |
|
|
style="border-radius: 8px;"> |
|
|
style="border-radius: 8px;"> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
@ -948,6 +948,7 @@ |
|
|
<th style="font-weight: 700; color: #475569;">Designation</th> |
|
|
<th style="font-weight: 700; color: #475569;">Designation</th> |
|
|
<th style="font-weight: 700; color: #475569;">Location</th> |
|
|
<th style="font-weight: 700; color: #475569;">Location</th> |
|
|
<th style="font-weight: 700; color: #475569;">Vendor Name</th> |
|
|
<th style="font-weight: 700; color: #475569;">Vendor Name</th> |
|
|
|
|
|
<th style="font-weight: 700; color: #475569;">Last Updated By</th> |
|
|
</tr> |
|
|
</tr> |
|
|
</thead> |
|
|
</thead> |
|
|
<tbody id="update-modal-history-tbody"> |
|
|
<tbody id="update-modal-history-tbody"> |
|
|
@ -1193,6 +1194,115 @@ |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<!-- Employee History Modal --> |
|
|
|
|
|
<div class="modal fade" id="employeeHistoryModal" tabindex="-1" aria-labelledby="employeeHistoryModalLabel" |
|
|
|
|
|
aria-hidden="true"> |
|
|
|
|
|
<div class="modal-dialog modal-xl modal-dialog-centered"> |
|
|
|
|
|
<div class="modal-content" |
|
|
|
|
|
style="border-radius: 14px; border: none; box-shadow: 0 10px 40px rgba(0,0,0,0.2);"> |
|
|
|
|
|
<div class="modal-custom-header" style="background-color: #0f5c78;"> |
|
|
|
|
|
<h5 class="modal-custom-title" id="employeeHistoryModalLabel"> |
|
|
|
|
|
<i class="fa-solid fa-clock-rotate-left"></i> Employee Update History - <span |
|
|
|
|
|
id="history-modal-emp-name" style="text-decoration: underline;">Employee</span> |
|
|
|
|
|
</h5> |
|
|
|
|
|
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" |
|
|
|
|
|
aria-label="Close"></button> |
|
|
|
|
|
</div> |
|
|
|
|
|
<div class="modal-body"> |
|
|
|
|
|
<div class="table-responsive" |
|
|
|
|
|
style="max-height: 400px; border: 1px solid #eef2f6; border-radius: 8px;"> |
|
|
|
|
|
<table class="table table-hover modal-table mb-0" id="history-modal-table" |
|
|
|
|
|
style="font-size: 0.9rem;"> |
|
|
|
|
|
<thead style="background-color: #f8fafc; position: sticky; top: 0; z-index: 1;"> |
|
|
|
|
|
<tr> |
|
|
|
|
|
<th style="width: 60px;" class="text-center">S.No</th> |
|
|
|
|
|
<th>Last Updated Date</th> |
|
|
|
|
|
<th>Name</th> |
|
|
|
|
|
<th>Email</th> |
|
|
|
|
|
<th>Mobile</th> |
|
|
|
|
|
<th>User Type</th> |
|
|
|
|
|
<th>Designation</th> |
|
|
|
|
|
<th>Location</th> |
|
|
|
|
|
<th>Vendor Name</th> |
|
|
|
|
|
<th>Last Updated By</th> |
|
|
|
|
|
</tr> |
|
|
|
|
|
</thead> |
|
|
|
|
|
<tbody id="history-modal-tbody"> |
|
|
|
|
|
<!-- Dynamically populated --> |
|
|
|
|
|
</tbody> |
|
|
|
|
|
</table> |
|
|
|
|
|
<div id="history-modal-no-history" class="text-center text-muted py-5" style="display: none;"> |
|
|
|
|
|
<i class="fa-solid fa-clock fs-1 mb-3 text-secondary"></i> |
|
|
|
|
|
<p class="fw-bold mb-0">No update history found for this employee.</p> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<!-- Deleted Employees Modal --> |
|
|
|
|
|
<div class="modal fade" id="deletedEmployeesModal" tabindex="-1" aria-labelledby="deletedEmployeesModalLabel" |
|
|
|
|
|
aria-hidden="true"> |
|
|
|
|
|
<div class="modal-dialog modal-xl modal-dialog-centered"> |
|
|
|
|
|
<div class="modal-content" |
|
|
|
|
|
style="border-radius: 14px; border: none; box-shadow: 0 10px 40px rgba(0,0,0,0.2);"> |
|
|
|
|
|
<div class="modal-custom-header" style="background-color: #2c3e50;"> |
|
|
|
|
|
<h5 class="modal-custom-title" id="deletedEmployeesModalLabel"> |
|
|
|
|
|
<i class="fa-solid fa-user-slash"></i> Deleted / Inactive Employees List |
|
|
|
|
|
</h5> |
|
|
|
|
|
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" |
|
|
|
|
|
aria-label="Close"></button> |
|
|
|
|
|
</div> |
|
|
|
|
|
<div class="modal-body"> |
|
|
|
|
|
<!-- Search and Export Toolbar --> |
|
|
|
|
|
<div class="d-flex flex-column flex-md-row justify-content-between align-items-center gap-3 mb-4"> |
|
|
|
|
|
<div class="modal-search-box flex-grow-1 m-0"> |
|
|
|
|
|
<i class="fa-solid fa-magnifying-glass"></i> |
|
|
|
|
|
<input type="text" id="deleted-employee-search-input" |
|
|
|
|
|
placeholder="Search deleted employees by name, designation, location, code..." |
|
|
|
|
|
oninput="filterDeletedEmployees()"> |
|
|
|
|
|
</div> |
|
|
|
|
|
<button class="export-btn text-nowrap" onclick="exportDeletedEmployeesToCSV()" |
|
|
|
|
|
style="background-color: #2c3e50;"> |
|
|
|
|
|
<i class="fa-solid fa-file-csv"></i> Export to CSV |
|
|
|
|
|
</button> |
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<!-- Table of Deleted Employees --> |
|
|
|
|
|
<div class="table-responsive" |
|
|
|
|
|
style="max-height: 450px; border: 1px solid #eef2f6; border-radius: 8px;"> |
|
|
|
|
|
<table class="table table-hover modal-table" id="deleted-employee-table"> |
|
|
|
|
|
<thead> |
|
|
|
|
|
<tr> |
|
|
|
|
|
<th style="width: 60px;" class="text-center">S.No</th> |
|
|
|
|
|
<th>Emp Code</th> |
|
|
|
|
|
<th>Name</th> |
|
|
|
|
|
<th>Email</th> |
|
|
|
|
|
<th>Mobile</th> |
|
|
|
|
|
<th>User Type</th> |
|
|
|
|
|
<th>Designation</th> |
|
|
|
|
|
<th>Location</th> |
|
|
|
|
|
<th>Vendor Name</th> |
|
|
|
|
|
<th class="text-center" style="width: 150px;">Last Updated On</th> |
|
|
|
|
|
<th class="text-center" style="width: 130px;">Last Updated By</th> |
|
|
|
|
|
<th class="text-center" style="width: 120px;">Status</th> |
|
|
|
|
|
</tr> |
|
|
|
|
|
</thead> |
|
|
|
|
|
<tbody id="deleted-employee-tbody"> |
|
|
|
|
|
<!-- Dynamically populated --> |
|
|
|
|
|
</tbody> |
|
|
|
|
|
</table> |
|
|
|
|
|
<div id="no-deleted-employees-found" class="text-center text-muted py-5" style="display: none;"> |
|
|
|
|
|
<i class="fa-solid fa-user-slash fs-1 mb-3 text-secondary"></i> |
|
|
|
|
|
<p class="fw-bold mb-0">No deleted employees found.</p> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
<!-- Include the quick-view-modal for product --> |
|
|
<!-- Include the quick-view-modal for product --> |
|
|
<th:block th:replace="~{modals/login-modal :: login-modal}"></th:block> |
|
|
<th:block th:replace="~{modals/login-modal :: login-modal}"></th:block> |
|
|
|
|
|
|
|
|
@ -2312,11 +2422,23 @@ |
|
|
if (isAdmin) { |
|
|
if (isAdmin) { |
|
|
actionTd = ` |
|
|
actionTd = ` |
|
|
<td class="text-center"> |
|
|
<td class="text-center"> |
|
|
<button class="btn btn-sm btn-outline-danger border-0 p-1 lh-1" |
|
|
|
|
|
onclick="deleteEmployee('${escapeHtml(emp.emp_code)}', '${escapeHtml(emp.name)}')" |
|
|
|
|
|
title="Delete Employee" style="cursor: pointer; background: transparent;"> |
|
|
|
|
|
<i class="fa-solid fa-trash-can text-danger"></i> |
|
|
|
|
|
</button> |
|
|
|
|
|
|
|
|
<div class="d-flex align-items-center justify-content-center gap-1"> |
|
|
|
|
|
<button class="btn btn-sm btn-outline-primary border-0 p-1 lh-1" |
|
|
|
|
|
onclick="editEmployee('${escapeHtml(emp.emp_code)}')" |
|
|
|
|
|
title="Edit Employee" style="cursor: pointer; background: transparent;"> |
|
|
|
|
|
<i class="fa-solid fa-user-pen text-primary"></i> |
|
|
|
|
|
</button> |
|
|
|
|
|
<button class="btn btn-sm btn-outline-info border-0 p-1 lh-1" |
|
|
|
|
|
onclick="showEmployeeHistory('${escapeHtml(emp.emp_code)}', '${escapeHtml(emp.name)}')" |
|
|
|
|
|
title="View History" style="cursor: pointer; background: transparent;"> |
|
|
|
|
|
<i class="fa-solid fa-clock-rotate-left text-info"></i> |
|
|
|
|
|
</button> |
|
|
|
|
|
<button class="btn btn-sm btn-outline-danger border-0 p-1 lh-1" |
|
|
|
|
|
onclick="deleteEmployee('${escapeHtml(emp.emp_code)}', '${escapeHtml(emp.name)}')" |
|
|
|
|
|
title="Delete Employee" style="cursor: pointer; background: transparent;"> |
|
|
|
|
|
<i class="fa-solid fa-trash-can text-danger"></i> |
|
|
|
|
|
</button> |
|
|
|
|
|
</div> |
|
|
</td> |
|
|
</td> |
|
|
`; |
|
|
`; |
|
|
} |
|
|
} |
|
|
@ -2660,7 +2782,7 @@ |
|
|
|
|
|
|
|
|
tbody.innerHTML = ` |
|
|
tbody.innerHTML = ` |
|
|
<tr> |
|
|
<tr> |
|
|
<td colspan="9" class="text-center py-3"> |
|
|
|
|
|
|
|
|
<td colspan="10" class="text-center py-3"> |
|
|
<div class="spinner-border spinner-border-sm text-primary" role="status"> |
|
|
<div class="spinner-border spinner-border-sm text-primary" role="status"> |
|
|
<span class="visually-hidden">Loading history...</span> |
|
|
<span class="visually-hidden">Loading history...</span> |
|
|
</div> |
|
|
</div> |
|
|
@ -2695,6 +2817,7 @@ |
|
|
<td class="fw-semibold">${escapeHtml(item.designation || '-')}</td> |
|
|
<td class="fw-semibold">${escapeHtml(item.designation || '-')}</td> |
|
|
<td><span class="badge bg-light text-dark border">${escapeHtml(item.location || '-')}</span></td> |
|
|
<td><span class="badge bg-light text-dark border">${escapeHtml(item.location || '-')}</span></td> |
|
|
<td class="fw-semibold text-secondary">${escapeHtml(item.vendor_name || '-')}</td> |
|
|
<td class="fw-semibold text-secondary">${escapeHtml(item.vendor_name || '-')}</td> |
|
|
|
|
|
<td class="text-center fw-semibold text-secondary">${escapeHtml(item.updated_by_name || '-')}</td> |
|
|
`; |
|
|
`; |
|
|
tbody.appendChild(tr); |
|
|
tbody.appendChild(tr); |
|
|
}); |
|
|
}); |
|
|
@ -2703,7 +2826,7 @@ |
|
|
console.error("Error fetching employee history:", err); |
|
|
console.error("Error fetching employee history:", err); |
|
|
tbody.innerHTML = ` |
|
|
tbody.innerHTML = ` |
|
|
<tr> |
|
|
<tr> |
|
|
<td colspan="9" class="text-center text-danger fw-bold py-3"> |
|
|
|
|
|
|
|
|
<td colspan="10" class="text-center text-danger fw-bold py-3"> |
|
|
<i class="fa-solid fa-triangle-exclamation"></i> Failed to load history records. |
|
|
<i class="fa-solid fa-triangle-exclamation"></i> Failed to load history records. |
|
|
</td> |
|
|
</td> |
|
|
</tr> |
|
|
</tr> |
|
|
@ -2744,7 +2867,7 @@ |
|
|
designation: designation, |
|
|
designation: designation, |
|
|
location: location, |
|
|
location: location, |
|
|
vendor_id: vendorId, |
|
|
vendor_id: vendorId, |
|
|
joined_date: joinedDate |
|
|
|
|
|
|
|
|
joined_date: joinedDate ? joinedDate : null |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
.then(res => res.json()) |
|
|
.then(res => res.json()) |
|
|
@ -2968,6 +3091,11 @@ |
|
|
if (modalEl) { |
|
|
if (modalEl) { |
|
|
bootstrap.Modal.getOrCreateInstance(modalEl).show(); |
|
|
bootstrap.Modal.getOrCreateInstance(modalEl).show(); |
|
|
} |
|
|
} |
|
|
|
|
|
} else if (action === 'deletedEmployees') { |
|
|
|
|
|
const modalEl = document.getElementById('deletedEmployeesModal'); |
|
|
|
|
|
if (modalEl) { |
|
|
|
|
|
bootstrap.Modal.getOrCreateInstance(modalEl).show(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Initialize Flatpickr datepickers for dd/mm/yyyy display format |
|
|
// Initialize Flatpickr datepickers for dd/mm/yyyy display format |
|
|
@ -3060,6 +3188,12 @@ |
|
|
deleteModalEl.addEventListener("hidden.bs.modal", resetDeleteEmployeeModal); |
|
|
deleteModalEl.addEventListener("hidden.bs.modal", resetDeleteEmployeeModal); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const deletedModalEl = document.getElementById("deletedEmployeesModal"); |
|
|
|
|
|
if (deletedModalEl) { |
|
|
|
|
|
deletedModalEl.addEventListener("show.bs.modal", fetchAndShowDeletedEmployees); |
|
|
|
|
|
deletedModalEl.addEventListener("hidden.bs.modal", resetDeletedEmployeesModal); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// Initialize designation dropdown options on load |
|
|
// Initialize designation dropdown options on load |
|
|
updateDesignationDropdown(); |
|
|
updateDesignationDropdown(); |
|
|
}); |
|
|
}); |
|
|
@ -3654,6 +3788,225 @@ |
|
|
showUpdateInitialMessage(); |
|
|
showUpdateInitialMessage(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Edit Employee from list |
|
|
|
|
|
function editEmployee(empCode) { |
|
|
|
|
|
// Hide details modal if open |
|
|
|
|
|
const detailsModalEl = document.getElementById("employeeDetailsModal"); |
|
|
|
|
|
if (detailsModalEl) { |
|
|
|
|
|
const detailsModal = bootstrap.Modal.getInstance(detailsModalEl); |
|
|
|
|
|
if (detailsModal) detailsModal.hide(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Show update modal |
|
|
|
|
|
const updateModalEl = document.getElementById("updateEmployeeModal"); |
|
|
|
|
|
if (updateModalEl) { |
|
|
|
|
|
const updateModal = bootstrap.Modal.getOrCreateInstance(updateModalEl); |
|
|
|
|
|
updateModal.show(); |
|
|
|
|
|
searchEmployee(empCode); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Show Employee history modal |
|
|
|
|
|
function showEmployeeHistory(empCode, empName) { |
|
|
|
|
|
document.getElementById("history-modal-emp-name").textContent = `${empName} (${empCode})`; |
|
|
|
|
|
const tbody = document.getElementById("history-modal-tbody"); |
|
|
|
|
|
const noHistoryEl = document.getElementById("history-modal-no-history"); |
|
|
|
|
|
|
|
|
|
|
|
tbody.innerHTML = ` |
|
|
|
|
|
<tr> |
|
|
|
|
|
<td colspan="10" class="text-center py-5"> |
|
|
|
|
|
<div class="spinner-border text-primary" role="status" style="width: 2.5rem; height: 2.5rem;"> |
|
|
|
|
|
<span class="visually-hidden">Loading history...</span> |
|
|
|
|
|
</div> |
|
|
|
|
|
<p class="mt-2 text-secondary fw-semibold mb-0">Loading employee update history...</p> |
|
|
|
|
|
</td> |
|
|
|
|
|
</tr> |
|
|
|
|
|
`; |
|
|
|
|
|
noHistoryEl.style.display = "none"; |
|
|
|
|
|
|
|
|
|
|
|
const modalElement = document.getElementById("employeeHistoryModal"); |
|
|
|
|
|
const modal = bootstrap.Modal.getOrCreateInstance(modalElement); |
|
|
|
|
|
modal.show(); |
|
|
|
|
|
|
|
|
|
|
|
fetch(contextPath + 'api/employee/history?empCode=' + encodeURIComponent(empCode)) |
|
|
|
|
|
.then(res => res.json()) |
|
|
|
|
|
.then(historyList => { |
|
|
|
|
|
tbody.innerHTML = ""; |
|
|
|
|
|
if (!historyList || historyList.length === 0) { |
|
|
|
|
|
noHistoryEl.style.display = "block"; |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
noHistoryEl.style.display = "none"; |
|
|
|
|
|
|
|
|
|
|
|
historyList.forEach((item, index) => { |
|
|
|
|
|
const tr = document.createElement("tr"); |
|
|
|
|
|
const formattedDate = formatDateTime(item.updated_date); |
|
|
|
|
|
|
|
|
|
|
|
tr.innerHTML = ` |
|
|
|
|
|
<td class="text-center fw-bold text-secondary">${index + 1}</td> |
|
|
|
|
|
<td class="fw-semibold text-dark">${escapeHtml(formattedDate)}</td> |
|
|
|
|
|
<td>${escapeHtml(item.name || '-')}</td> |
|
|
|
|
|
<td>${escapeHtml(item.email || '-')}</td> |
|
|
|
|
|
<td>${escapeHtml(item.mobile || '-')}</td> |
|
|
|
|
|
<td><span class="badge bg-secondary">${escapeHtml(item.user_type || '-')}</span></td> |
|
|
|
|
|
<td class="fw-semibold">${escapeHtml(item.designation || '-')}</td> |
|
|
|
|
|
<td><span class="badge bg-light text-dark border">${escapeHtml(item.location || '-')}</span></td> |
|
|
|
|
|
<td class="fw-semibold text-secondary">${escapeHtml(item.vendor_name || '-')}</td> |
|
|
|
|
|
<td class="text-center fw-semibold text-secondary">${escapeHtml(item.updated_by_name || '-')}</td> |
|
|
|
|
|
`; |
|
|
|
|
|
tbody.appendChild(tr); |
|
|
|
|
|
}); |
|
|
|
|
|
}) |
|
|
|
|
|
.catch(err => { |
|
|
|
|
|
console.error("Error fetching employee history:", err); |
|
|
|
|
|
tbody.innerHTML = ` |
|
|
|
|
|
<tr> |
|
|
|
|
|
<td colspan="10" class="text-center text-danger fw-bold py-4"> |
|
|
|
|
|
<i class="fa-solid fa-triangle-exclamation fs-3 mb-2"></i> |
|
|
|
|
|
<p class="mb-0">Failed to load history records.</p> |
|
|
|
|
|
</td> |
|
|
|
|
|
</tr> |
|
|
|
|
|
`; |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Globals for Deleted Employees Modal |
|
|
|
|
|
let deletedEmployeesList = []; |
|
|
|
|
|
let filteredDeletedEmployeesList = []; |
|
|
|
|
|
|
|
|
|
|
|
function fetchAndShowDeletedEmployees() { |
|
|
|
|
|
const tbody = document.getElementById("deleted-employee-tbody"); |
|
|
|
|
|
tbody.innerHTML = ` |
|
|
|
|
|
<tr> |
|
|
|
|
|
<td colspan="10" class="text-center py-5"> |
|
|
|
|
|
<div class="spinner-border text-primary" role="status" style="width: 3rem; height: 3rem;"> |
|
|
|
|
|
<span class="visually-hidden">Loading...</span> |
|
|
|
|
|
</div> |
|
|
|
|
|
<p class="mt-3 text-secondary fw-semibold">Loading deleted employees...</p> |
|
|
|
|
|
</td> |
|
|
|
|
|
</tr> |
|
|
|
|
|
`; |
|
|
|
|
|
document.getElementById("no-deleted-employees-found").style.display = "none"; |
|
|
|
|
|
document.getElementById("deleted-employee-search-input").value = ""; |
|
|
|
|
|
|
|
|
|
|
|
fetch(contextPath + 'api/all-employees-with-deleted') |
|
|
|
|
|
.then(res => res.json()) |
|
|
|
|
|
.then(data => { |
|
|
|
|
|
// Filter to only include inactive/deleted employees |
|
|
|
|
|
deletedEmployeesList = data.filter(emp => (emp.isdelete === true || emp.isactive === false || parseInt(emp.isdelete) === 1 || parseInt(emp.isactive) === 0)); |
|
|
|
|
|
filterDeletedEmployees(); |
|
|
|
|
|
}) |
|
|
|
|
|
.catch(err => { |
|
|
|
|
|
console.error("Error fetching deleted employees:", err); |
|
|
|
|
|
tbody.innerHTML = ` |
|
|
|
|
|
<tr> |
|
|
|
|
|
<td colspan="10" class="text-center py-5 text-danger fw-bold"> |
|
|
|
|
|
<i class="fa-solid fa-circle-exclamation fs-1 mb-2"></i> |
|
|
|
|
|
<p>Failed to connect to server and fetch database records. Please try again.</p> |
|
|
|
|
|
</td> |
|
|
|
|
|
</tr> |
|
|
|
|
|
`; |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function filterDeletedEmployees() { |
|
|
|
|
|
const query = document.getElementById("deleted-employee-search-input").value.toLowerCase().trim(); |
|
|
|
|
|
|
|
|
|
|
|
if (query === "") { |
|
|
|
|
|
filteredDeletedEmployeesList = deletedEmployeesList; |
|
|
|
|
|
} else { |
|
|
|
|
|
filteredDeletedEmployeesList = deletedEmployeesList.filter(emp => { |
|
|
|
|
|
return (emp.name && emp.name.toLowerCase().includes(query)) || |
|
|
|
|
|
(emp.emp_code && emp.emp_code.toLowerCase().includes(query)) || |
|
|
|
|
|
(emp.designation && emp.designation.toLowerCase().includes(query)) || |
|
|
|
|
|
(emp.location && emp.location.toLowerCase().includes(query)) || |
|
|
|
|
|
(emp.email && emp.email.toLowerCase().includes(query)) || |
|
|
|
|
|
(emp.mobile && emp.mobile.toLowerCase().includes(query)) || |
|
|
|
|
|
(emp.vendor_name && emp.vendor_name.toLowerCase().includes(query)) || |
|
|
|
|
|
(emp.user_type && emp.user_type.toLowerCase().includes(query)); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
renderDeletedEmployeesTable(filteredDeletedEmployeesList); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function renderDeletedEmployeesTable(list) { |
|
|
|
|
|
const tbody = document.getElementById("deleted-employee-tbody"); |
|
|
|
|
|
const noEmployeesEl = document.getElementById("no-deleted-employees-found"); |
|
|
|
|
|
tbody.innerHTML = ""; |
|
|
|
|
|
|
|
|
|
|
|
if (list.length === 0) { |
|
|
|
|
|
noEmployeesEl.style.display = "block"; |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
noEmployeesEl.style.display = "none"; |
|
|
|
|
|
|
|
|
|
|
|
list.forEach((emp, index) => { |
|
|
|
|
|
const tr = document.createElement("tr"); |
|
|
|
|
|
tr.style.backgroundColor = "#fdf2f2"; // light pink background for soft-deleted rows |
|
|
|
|
|
tr.innerHTML = ` |
|
|
|
|
|
<td class="text-center fw-bold text-secondary">${index + 1}</td> |
|
|
|
|
|
<td class="fw-semibold text-primary">${escapeHtml(emp.emp_code || '-')}</td> |
|
|
|
|
|
<td class="fw-bold text-dark">${escapeHtml(emp.name || '-')}</td> |
|
|
|
|
|
<td>${escapeHtml(emp.email || '-')}</td> |
|
|
|
|
|
<td>${escapeHtml(emp.mobile || '-')}</td> |
|
|
|
|
|
<td><span class="badge bg-secondary">${escapeHtml(emp.user_type || '-')}</span></td> |
|
|
|
|
|
<td class="fw-semibold">${escapeHtml(emp.designation || '-')}</td> |
|
|
|
|
|
<td><span class="badge bg-light text-dark border">${escapeHtml(emp.location || '-')}</span></td> |
|
|
|
|
|
<td class="fw-semibold text-secondary">${escapeHtml(emp.vendor_name || '-')}</td> |
|
|
|
|
|
<td class="text-center fw-semibold text-primary">${escapeHtml(formatDateTime(emp.updated_at || emp.cdate))}</td> |
|
|
|
|
|
<td class="text-center fw-semibold text-secondary">${escapeHtml(emp.updated_by_name || '-')}</td> |
|
|
|
|
|
<td class="text-center"><span class="badge bg-danger">Inactive</span></td> |
|
|
|
|
|
`; |
|
|
|
|
|
tbody.appendChild(tr); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function resetDeletedEmployeesModal() { |
|
|
|
|
|
document.getElementById("deleted-employee-search-input").value = ""; |
|
|
|
|
|
document.getElementById("deleted-employee-tbody").innerHTML = ""; |
|
|
|
|
|
document.getElementById("no-deleted-employees-found").style.display = "none"; |
|
|
|
|
|
deletedEmployeesList = []; |
|
|
|
|
|
filteredDeletedEmployeesList = []; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function exportDeletedEmployeesToCSV() { |
|
|
|
|
|
if (filteredDeletedEmployeesList.length === 0) { |
|
|
|
|
|
alert("No employee records to export!"); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let csvContent = "data:text/csv;charset=utf-8,"; |
|
|
|
|
|
csvContent += "S.No,Employee Code,Name,Email,Mobile,User Type,Designation,Location,Vendor Name,Last Updated On,Last Updated By,Status\n"; |
|
|
|
|
|
|
|
|
|
|
|
filteredDeletedEmployeesList.forEach((emp, index) => { |
|
|
|
|
|
const row = [ |
|
|
|
|
|
index + 1, |
|
|
|
|
|
`"${(emp.emp_code || '-').replace(/"/g, '""')}"`, |
|
|
|
|
|
`"${(emp.name || '-').replace(/"/g, '""')}"`, |
|
|
|
|
|
`"${(emp.email || '-').replace(/"/g, '""')}"`, |
|
|
|
|
|
`"${(emp.mobile || '-').replace(/"/g, '""')}"`, |
|
|
|
|
|
`"${(emp.user_type || '-').replace(/"/g, '""')}"`, |
|
|
|
|
|
`"${(emp.designation || '-').replace(/"/g, '""')}"`, |
|
|
|
|
|
`"${(emp.location || '-').replace(/"/g, '""')}"`, |
|
|
|
|
|
`"${(emp.vendor_name || '-').replace(/"/g, '""')}"`, |
|
|
|
|
|
`"${formatDateTime(emp.updated_at || emp.cdate)}"`, |
|
|
|
|
|
`"${(emp.updated_by_name || '-').replace(/"/g, '""')}"`, |
|
|
|
|
|
"Inactive" |
|
|
|
|
|
]; |
|
|
|
|
|
csvContent += row.join(",") + "\n"; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const encodedUri = encodeURI(csvContent); |
|
|
|
|
|
const link = document.createElement("a"); |
|
|
|
|
|
link.setAttribute("href", encodedUri); |
|
|
|
|
|
link.setAttribute("download", "deleted_employees.csv"); |
|
|
|
|
|
document.body.appendChild(link); |
|
|
|
|
|
link.click(); |
|
|
|
|
|
document.body.removeChild(link); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
function resetDeleteEmployeeModal() { |
|
|
function resetDeleteEmployeeModal() { |
|
|
document.getElementById("delete-modal-vendor-select").value = ""; |
|
|
document.getElementById("delete-modal-vendor-select").value = ""; |
|
|
document.getElementById("delete-modal-workorder-select").innerHTML = '<option value="">-- Select Work Order --</option>'; |
|
|
document.getElementById("delete-modal-workorder-select").innerHTML = '<option value="">-- Select Work Order --</option>'; |
|
|
|