|
|
<!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;}
</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>GIS</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">GIS</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> <div id="headingContainer"> <h5 style="font-weight: bold;"> <span th:text="${deptId}" id="deptId" style="display: none"></span> New Entry - GIS </h5> </div> <span th:text="${userId}" id="userId" style="display:none"></span> <div class="row mb-4"> <!-- Input Fields for Year Selection --> <!-- Start Year Dropdown as Button Dropdown --> <!-- Start Year Dropdown as Button Dropdown --> <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> <button id="addNewbutton" class="btn btn-success mt-2" Style="height: 38px;">Create New</button> </div> <div id="staffTypeContainer" style="display: none; margin-top: 10px;"> <label style="font-weight: bold; margin-bottom: 5px;">Select Staff Type:</label> <div style="display: flex; align-items: center; gap: 40px;"> <div> <input type="radio" id="temporaryStaff" name="staffType" value="temporary"> <label for="temporaryStaff">Temporary Staff</label> </div> <div> <input type="radio" id="permanentStaff" name="staffType" value="permanent"> <label for="permanentStaff">Permanent Staff</label> </div> </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 - GIS </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="text" 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="servicedeath" class="form-label fw-bold"> While In Service Death <span class="text-danger">*</span> </label> <div class="dropdown"> <input type="date" id="servicedeath" class="form-control" onclick="this.showPicker()" max=""> </div> </div> <div class="col-md-6"> <label for="deceased" class="form-label fw-bold">Relationship of Deceased<span class="text-danger">*</span></label> <div class="dropdown"> <input type="text" id="deceased" class="form-control" > </div> </div> <div class="col-md-6"> <label for="gisentry" class="form-label fw-bold">GIS Entry Type<span class="text-danger">*</span></label> <select id="gisentry" class="form-select" style="width: 100%;" required> </select> </div> <!-- div class="col-md-6">
<label for="funeraladvance" class="form-label fw-bold">Sanctioned GIS Advance <span class="text-danger">*</span></label> <div class="dropdown"> <input type="number" id="funeraladvance" class="form-control" > </div> </div> --> <div class="col-md-6"> <label for="gisamount" class="form-label fw-bold"> Sanctioned GIS Advance <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="yes1" name="gisamount" class="form-check-input" value="yes"> <label for="yes1" class="form-check-label">Yes</label> </div> <div class="form-check"> <input type="radio" id="no1" name="gisamount" class="form-check-input" value="no"> <label for="no1" class="form-check-label">No</label> </div> </div> <div class="dropdown" id="gisAmountInputContainer" style="display: none; margin-top: 10px;"> <input type="number" id="gisAmountInput" name="gisamount_value" class="form-control" placeholder="Enter Sanctioned Gis Amount" min="1" oninput="validatePositiveNumber(this)"> </div> </div>
<div class="col-md-6"> <label for="filesentdate" class="form-label fw-bold"> File Sent to GD Pension Section On<span class="text-danger">*</span></label> <div class="dropdown"> <input type="text" id="filesentdate" class="form-control" readonly> </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 mt-20"> <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.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}`; } document.addEventListener("DOMContentLoaded", function () { let today = new Date().toISOString().split("T")[0]; // Get today's date in YYYY-MM-DD format let servicedeathInput = document.getElementById("servicedeath");
// Set max attribute to disable future dates servicedeathInput.setAttribute("max", today);
// Prevent manual future date entry servicedeathInput.addEventListener("change", function () { if (this.value > today) { Swal.fire({ icon: 'warning', title: 'Invalid Date', text: 'Future dates are not allowed.', confirmButtonText: 'OK' }); this.value = ""; // Clear the invalid input } });}); console.log("before ajaxx....") $(document).ready(function () { $(document).ready(function () { $('#addNewbutton').on('click', function () { // Show the staff type container $('#staffTypeContainer').show(); $('#employeeCard').hide(); $('input[name="staffType"]').prop('checked', false); // Add change event listener to the radio buttons $('input[name="staffType"]').off('change').on('change', function () { const selectedType = $('input[name="staffType"]:checked').val(); $('#staffTypeContainer').hide();
if (selectedType === 'temporary') { // Show the employee card $('#employeeCard').show();
// Pre-fill "GIS" in Employee No and enforce rules $('#employeeno') .val('GIS') // Pre-fill with "GIS" .prop('readonly', false) // Allow editing, but only after "GIS" .off('input keydown') // Remove existing event listeners .on('input', function () { const value = $(this).val(); if (!value.startsWith('GIS')) { $(this).val('GIS'); } else { const numericPart = value.slice(3).replace(/\D/g, ''); // Allow only digits after "GIS" $(this).val('GIS' + numericPart); } }) .on('keydown', function (e) { const cursorPosition = this.selectionStart; if ((e.key === 'Backspace' || e.key === 'Delete') && cursorPosition <= 3) { e.preventDefault(); // Prevent removing "GIS" } });
// Pre-fill and enable fields $('#employeename').val('').prop('readonly', false); $('#department').val($('#deptname').text().trim()).prop('readonly', true); $('#designation').val('').prop('readonly', false); $('#servicedeath').val('').prop('readonly', false); $('#deceased').val('').prop('readonly', false); //$('#funeraladvance').val('').prop('readonly', false); $('#filesentdate').prop('readonly', true); $('#remarks').val('').prop('readonly', false); } else if (selectedType === 'permanent') { // Hide the employee card and show a SweetAlert $('#employeeCard').hide(); Swal.fire({ icon: 'warning', title: 'ERP Required', text: 'Please create a number in ERP for permanent staff.', confirmButtonText: 'OK', customClass: { confirmButton: 'btn btn-primary' } }); } }); }); $('#submitButton').off('click').on('click', function () { const gisPattern = /^GIS\d+$/; const employeeNo = $('#employeeno').val().trim();
// Validate Employee No if (!gisPattern.test(employeeNo)) { Swal.fire({ icon: 'warning', title: 'Validation Error', text: 'Employee No must start with "GIS" and be followed by one or more numbers.', confirmButtonText: 'OK' }); console.warn('Validation failed: Employee No is invalid.'); $('#submitButton').prop('disabled', false).text('Mark as Forwarded to Pension'); // Re-enable button return; // Stop execution if validation fails }
// Log and call save function console.log("Save button clicked. Triggering saveEntryDetails function."); saveEntryDetailsnew(); });
});
// Handle Search button click $('#searchButton').on('click', function () { const empCode = $('#empCode').val().trim(); // Trim input to avoid accidental spaces
console.log("empCode...",empCode);
if (!empCode) { Swal.fire({ icon: "warning", title: "Missing Employee Number", text: "Please enter an employee number to proceed.", confirmButtonText: "OK", customClass: { confirmButton: "btn btn-primary" } }); console.log("No Employee Code provided. Aborting search."); return; // Stop further execution if empCode is not provided }
// Show loader and hide other elements $('#pageLoader').show(); $('#employeeCard').hide(); $('#newemployeeCard').hide(); $('#gisAmountInput').val(''); $('input[name="gisamount"]').prop('checked', false);
console.log("Checking if employee exists: ${empCode}");
// Step 1: Check if employee exists in the database $.ajax({ url: '/gcc/api/department/newentry/exists', // Endpoint to check existence type: 'GET', data: { empCode: empCode }, success: function (existsResponse) { console.log("Exists API Response:", existsResponse); $('#pageLoader').hide();
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 the function if the employee exists }
console.log(`Employee Code ${empCode} does not exist. Fetching details from the external API.`); // If employee does not exist, fetch details from the external API fetchEmployeeDetails(empCode); }, error: function (xhr) { $('#pageLoader').hide(); console.error("Error during existence check:", xhr.responseText); Swal.fire({ icon: "error", title: "Error", text: "An error occurred while checking employee existence. Please try again.", confirmButtonText: "OK" }); } }); });
// Function to fetch employee details from external API console.log("fetchEmployeeDetails.....") function fetchEmployeeDetails(empCode) { console.log("Fetching details for employee:"); $('#pageLoader').show();
$.ajax({ url: '/gcc/api/department/newentry/employeedetails', // External API endpoint type: 'GET', data: { empCode: empCode }, success: function (response) { console.log("Employee Details API Response:", response); $('#pageLoader').hide();
if (response.list && response.list.length > 0) { const employeeDetails = response.list[0]; console.log("Employee Details Retrieved:", employeeDetails);
// Check if the employee code is null or not found const loggedInDeptId = $('#deptId').text().trim(); // Get 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 employeecode.", confirmButtonText: "OK", customClass: { confirmButton: "btn btn-danger" } }); return; }
// Populate the employee details console.log("Populating employee details in the UI."); $('#employeeno').val(employeeDetails.EMPLOYEE_CODE).prop('readonly', true);; $('#employeename').val(employeeDetails.EMPLOYEE_NAME).prop('readonly', true); $('#department').val(employeeDetails.DEPARTMENT).prop('readonly', true); $('#designation').val(employeeDetails.DESIGNATION).prop('readonly', true); $('#classes').val(employeeDetails.GROUP_TYPE); $('#retrirementdate').val(employeeDetails.RETIREMENT_DATE);
$('#EmployeeCode').text(empCode); $('#employeeCard').show();
// Attach event handler for saving details $('#submitButton').off('click').on('click', function () { console.log("Save button clicked. Triggering saveEntryDetails function."); saveEntryDetailsnew(); }); } else { console.warn("No employee data found in the external API response."); Swal.fire({ icon: "warning", title: "No Data Found", text: "No details found for this employee number.", confirmButtonText: "OK", customClass: { confirmButton: "btn btn-primary" } }); $('#newemployeeCard').show(); } }, error: function (xhr) { $('#pageLoader').hide(); console.error("Error in Employee Details API:", xhr.responseText); Swal.fire({ icon: "error", title: "Error", text: "An error occurred while fetching data. Please try again.", confirmButtonText: "OK" }); } }); }
document.querySelectorAll('input[name="gisamount"]').forEach(radio => { radio.addEventListener('change', function () { const gisAmountInputContainer = document.getElementById('gisAmountInputContainer'); if (this.value === 'yes') { gisAmountInputContainer.style.display = 'block'; // Show the input field } else { gisAmountInputContainer.style.display = 'none'; // Hide the input field document.getElementById('gisAmountInput').value = ''; // Clear the input field } }); }); //dropdown for gisentry type: $(document).ready(function () { function loadEntryTypes() { $.ajax({ url: "/gcc/api/getGisEntryTypes", type: "GET", success: function (data) { var dropdown = $("#gisentry"); dropdown.empty(); // Clear existing options dropdown.append('<option value="" selected>-- Select Option --</option>');
// Loop through the API response and add options $.each(data, function (key, entry) { dropdown.append($('<option></option>').attr('value', entry.gis_entry).text(entry.gis_entry)); //dropdown.append('<option value="' + item.id + '">' + item.gis_entry + '</option>'); }); }, error: function () { console.log("Error loading dropdown data."); } }); }
// Call function on page load loadEntryTypes(); });
function saveEntryDetailsnew() { let selgisamount = $('input[name="gisamount"]:checked').val(); let selgismamountval = null;
if (selgisamount === 'yes') { selgismamountval = $('#gisAmountInput').val(); if (!selgismamountval || selgismamountval <= 0) { Swal.fire({ icon: 'warning', title: 'Validation Error', text: 'Please enter a valid Sanctioned Gis Amount', confirmButtonText: 'OK' }); return ; // Stop further execution } } let entryDetails = { empNo: $('#employeeno').val(), empName: $('#employeename').val(), deptName: $('#department').val(), designation: $('#designation').val(), serviceDeath: $('#servicedeath').val(), dateToPension: convertDateFormat($('#filesentdate').val()?.trim()), deceased: $('#deceased').val(), gisentry: $('#gisentry').val(), //funeralAdvance: $('#funeraladvance').val(), gisAdvanceamount : selgismamountval, gisAdvance : selgisamount, remarks: $('#remarks').val(), deptId: $('#deptId').text().trim(), filemovedby: $('#userId').text().trim(), filecategory: $('#filecategory').text().trim() };
console.log("Saving employee details:", entryDetails);
if (!entryDetails.empName) { Swal.fire({ icon: 'warning', title: 'Validation Error!', text: 'Employee Name is required.', confirmButtonText: 'OK' }); return; }
if (!entryDetails.designation) { Swal.fire({ icon: 'warning', title: 'Validation Error!', text: 'Designation is required.', confirmButtonText: 'OK' }); return; }
if (!entryDetails.dateToPension) { Swal.fire({ icon: 'warning', title: 'Validation Error!', text: 'Date to Pension is required.', confirmButtonText: 'OK' }); return; }
if (!entryDetails.serviceDeath) { Swal.fire({ icon: 'warning', title: 'Validation Error!', text: 'Service Death Date is required.', confirmButtonText: 'OK' }); return; }
if (!entryDetails.deceased) { Swal.fire({ icon: 'warning', title: 'Validation Error!', text: 'Relationship of Deceased is required.', confirmButtonText: 'OK' }); return; }
if (!entryDetails.gisentry) { Swal.fire({ icon: 'warning', title: 'Validation Error!', text: 'Gis Entry Type is required.', confirmButtonText: 'OK' }); return; }
if (!entryDetails.gisAdvance) { Swal.fire({ icon: 'warning', title: 'Validation Error!', text: 'Sanctional Gis Advance is required.', confirmButtonText: 'OK' }); return; }
if (!entryDetails.remarks) { Swal.fire({ icon: 'warning', title: 'Validation Error!', text: 'Remarks are required.', confirmButtonText: 'OK' }); return; }
const employeeNo = entryDetails.empNo.trim();
// Validate Employee No format /* const gisPattern = /^GIS\d+$/; if (!gisPattern.test(employeeNo)) { Swal.fire({ icon: 'warning', title: 'Validation Error', text: 'Employee No must start with "GIS" and be followed by one or more numbers.', confirmButtonText: 'OK' }); console.warn('Validation failed: Employee No is invalid.'); $('#submitButton').prop('disabled', false).text('Mark as sent audit'); // Re-enable button return; // Stop further execution } */
// Step 1: Check if the employee exists in the database $('#submitButton').prop('disabled', true).text('Checking...'); $.ajax({ url: '/gcc/api/department/newentry/exists', type: 'GET', data: { empCode: employeeNo }, success: function (existsResponse) { console.log("Exists API Response:", existsResponse); $('#pageLoader').hide();
if (existsResponse && existsResponse.exists) { console.log(`Employee Code ${employeeNo} already exists in the database.`); Swal.fire({ icon: "warning", title: "Already Exists", text: "This employee number already exists in our database.", confirmButtonText: "OK", customClass: { confirmButton: "btn btn-primary" } }); $('#submitButton').prop('disabled', false).text('Mark as Forwarded to pension'); // Re-enable button return; // Exit the function if the employee exists }
// If employee does not exist, proceed to save details console.log(`Employee Code ${employeeNo} does not exist. Proceeding to save details.`); $('#submitButton').prop('disabled', true).text('Processing...'); $.ajax({ url: '/gcc/api/department/newentry/saveEmployeeDetailsGis', type: 'POST', contentType: 'application/json', data: JSON.stringify(entryDetails), success: function (response) { console.log("Save API Response:", response); Swal.fire({ icon: 'success', title: 'Success', text: response, allowOutsideClick: false, allowEscapeKey: false, allowEnterKey: false, confirmButtonText: 'OK' }).then((result) => { if (result.isConfirmed) { console.log("Save confirmed. Redirecting to GIS page."); $('#submitButton').prop('disabled', false).text('Mark as Forwarded to Pension'); window.location.href = "/gcc/department/newentry/gis"; } }); }, error: function (xhr) { console.error("Error in Save API:", xhr.responseText); Swal.fire({ icon: 'error', title: 'Error', text: 'Failed to save details. Please try again.', confirmButtonText: 'OK' }); $('#submitButton').prop('disabled', false).text('Mark as Forwarded to pension'); // Re-enable button } }); }, error: function (xhr) { console.error("Error during existence check:", xhr.responseText); Swal.fire({ icon: "error", title: "Error", text: "An error occurred while checking employee existence. Please try again.", confirmButtonText: "OK" }); $('#submitButton').prop('disabled', false).text('Mark as Forwarded to pension'); // Re-enable button } }); }
}); // 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(''); // Hide the card $('#employeeCard').hide(); $('#staffTypeContainer').hide();
});
// Handle close button click $('#cancelButtonnew').click(function () { // Clear the input field value $('#empCode').val('');
$('#newemployeeCard').hide(); }); function validatePositiveNumber(input) { if (input.value < 1) { input.value = ""; } }
$(document).ready(function () { // Restrict Employee Name to only alphabets $('#employeename').on('input', function () { let value = $(this).val(); $(this).val(value.replace(/[^A-Za-z\s]/g, '')); // Allow only letters and spaces });
$('#submitButton').on('click', function () { const employeeName = $('#employeename').val().trim();
if (!/^[A-Za-z\s]+$/.test(employeeName)) { Swal.fire({ icon: 'warning', title: 'Validation Error', text: 'Employee Name must contain only alphabets.', confirmButtonText: 'OK' }); return; } }); });
</script>
</body></html>
|