From 9c189b004b30e76cfc88332d0805031b70a94657 Mon Sep 17 00:00:00 2001 From: yoganandhank Date: Thu, 20 Feb 2025 18:31:50 +0530 Subject: [PATCH] updated files --- .../DepartmentReceivedApiController.java | 8 +- .../DeptPartiallyCompApiController.java | 2 +- .../controller/FileClosingApiController.java | 2 +- .../service/DepartmentReceivedService.java | 49 ++++- .../service/DeptPartiallyCompService.java | 2 +- .../pensioner/service/NewEntryService.java | 182 ++++++++++++++---- .../service/PensionPartiallyCompService.java | 2 +- .../pensioner/department/audit/pendency.html | 11 +- .../department/audit/retirement.html | 4 +- frontend/pensioner/department/closedList.html | 2 +- .../pensioner/department/completed/gis.html | 2 +- .../completed/provisionalretirement.html | 2 +- frontend/pensioner/department/dashboard.html | 56 +++++- .../pensioner/department/fileclosing.html | 94 +++++++-- .../department/newentry/familypension.html | 10 +- .../department/newentry/pendency.html | 47 +++-- .../department/partial/pendency.html | 4 +- .../department/received/pendency.html | 2 +- .../received/provisionalretirement.html | 4 +- .../department/received/retirement.html | 2 +- frontend/pensioner/department/reports.html | 50 +++-- .../pensioner/department/return/pendency.html | 12 +- .../department/return/retirement.html | 2 +- .../pensioner/pensioner/audit/pendency.html | 9 +- .../pensioner/pensioner/audit/retirement.html | 2 +- .../pensioner/pensioner/completed/gis.html | 2 +- .../pensioner/completed/pendency.html | 4 +- .../completed/provisionalretirement.html | 2 +- frontend/pensioner/pensioner/dashboard.html | 57 +++++- .../pensioner/pensioner/forward/pendency.html | 9 +- .../pensioner/forward/retirement.html | 2 +- .../pensioner/received/familypension.html | 63 +++++- .../pensioner/pensioner/received/gis.html | 2 +- .../pensioner/received/pendency.html | 74 ++++++- .../received/provisionalretirement.html | 2 +- .../pensioner/received/retirement.html | 65 ++++++- frontend/pensioner/pensioner/reports.html | 61 ++++-- 37 files changed, 741 insertions(+), 164 deletions(-) diff --git a/backend/pensioner/controller/DepartmentReceivedApiController.java b/backend/pensioner/controller/DepartmentReceivedApiController.java index f03eaef..b4b71d2 100644 --- a/backend/pensioner/controller/DepartmentReceivedApiController.java +++ b/backend/pensioner/controller/DepartmentReceivedApiController.java @@ -70,9 +70,13 @@ public class DepartmentReceivedApiController { if (updated && file_Status != 0) { if (file_Status == 11) { return ResponseEntity.ok("File Completed successfully!"); - } else { + } else if(file_Status == 9) { + //return ResponseEntity.ok("File Moved Department to Complete Pending fields!"); + return ResponseEntity.ok("File Moved to Department Partially Completed!"); + } + else { //return ResponseEntity.ok("File Moved Department to Complete Pending fields!"); - return ResponseEntity.ok("File Moved to Partially Completed!"); + return ResponseEntity.ok("File Moved to Pension Partially Completed!"); } } else { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) diff --git a/backend/pensioner/controller/DeptPartiallyCompApiController.java b/backend/pensioner/controller/DeptPartiallyCompApiController.java index a47491e..b8df21d 100644 --- a/backend/pensioner/controller/DeptPartiallyCompApiController.java +++ b/backend/pensioner/controller/DeptPartiallyCompApiController.java @@ -86,7 +86,7 @@ public class DeptPartiallyCompApiController { return ResponseEntity.ok("File Partially Completed!"); } else if(fs1==10 && fs1!=0){ - return ResponseEntity.ok("File Moved to Pension for Complete!"); + return ResponseEntity.ok("File Moved to Pension Partially Completed!"); } else { return ResponseEntity.ok("File Status is 0!"); diff --git a/backend/pensioner/controller/FileClosingApiController.java b/backend/pensioner/controller/FileClosingApiController.java index 705d058..8242115 100644 --- a/backend/pensioner/controller/FileClosingApiController.java +++ b/backend/pensioner/controller/FileClosingApiController.java @@ -86,7 +86,7 @@ public class FileClosingApiController { if(updated) { - return ResponseEntity.ok("File moved to Return from Audit successfully!"); + return ResponseEntity.ok("File Closed successfully!"); } else { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details in history."); diff --git a/backend/pensioner/service/DepartmentReceivedService.java b/backend/pensioner/service/DepartmentReceivedService.java index 19edd57..830a15a 100644 --- a/backend/pensioner/service/DepartmentReceivedService.java +++ b/backend/pensioner/service/DepartmentReceivedService.java @@ -75,30 +75,38 @@ public class DepartmentReceivedService { String benefit_dcrg = requestData.get("benefit_dcrg") != null ? requestData.get("benefit_dcrg").toString() : null; String benefit_commutation = (String) requestData.get("benefit_commutation"); - String benefit_pension_amount = (String) requestData.get("benefit_pension_amount"); + String benefit_pension_amount = (String) requestData.get("benefit_pension_amount")!= null ? requestData.get("benefit_pension_amount").toString() : null; String benefit_dcrg_amount = requestData.get("benefit_dcrg_amount") != null ? requestData.get("benefit_dcrg_amount").toString() : null; - String benefit_commutation_amount = (String) requestData.get("benefit_commutation_amount"); + String benefit_commutation_amount = (String) requestData.get("benefit_commutation_amount") != null ? requestData.get("benefit_commutation_amount").toString() : null; int deptId = Integer.parseInt(dept_Id); - int filestatus; + int filestatus=0; String file_entry_type=""; boolean check = checkTempPresent(tempId); if ("yes".equalsIgnoreCase(benefit_dcrg)) { - filestatus = CheckFieldsInDept(tempId) ? 11 : 9; //noted + + // filestatus = CheckFieldsInDept(tempId) ? 11 : 9; //noted + + filestatus = CheckFieldsInDept(tempId) ? (CheckFieldsInPensioner(tempId) ? 11 : 10 ) : 9; + file_entry_type="FILE_COMPLETED"; - } + } + else if("no".equalsIgnoreCase(benefit_pension) || "no".equalsIgnoreCase(benefit_dcrg)){ + + filestatus = 10; + file_entry_type="PENSION_PARTIAL"; + } else if(benefit_dcrg==null) { filestatus = 9; file_entry_type="DEPARTMENT_PARTIAL"; } - else { - filestatus = 9; - file_entry_type="DEPARTMENT_PARTIAL"; - } - + + + + String updateQuery = "UPDATE pensioner_details SET file_entry_type=?,file_status = ?, file_moved_date = ?, remarks = ?, updated_date = CURRENT_TIMESTAMP WHERE temp_id = ? LIMIT 1"; int rowsUpdated = jdbcTemplate.update(updateQuery,file_entry_type, filestatus, dateToAudit, remarks, tempId); @@ -149,6 +157,27 @@ public class DepartmentReceivedService { "WHERE temp_id = ?"; + try { + // Use queryForObject to get a single boolean result + Boolean result = jdbcTemplate.queryForObject(sql, Boolean.class, tempId); + return result != null && result; // Return the result if not null + } catch (Exception e) { + e.printStackTrace(); // Log the exception if needed + } + + return false; // Return false if an exception occurs + } + + private boolean CheckFieldsInPensioner(String tempId) { + + // Define the SQL query + String sql = "SELECT CASE " + + "WHEN benefit_pension = 'yes' AND benefit_dcrg = 'yes' THEN true " + + "ELSE false END AS allYes " + + "FROM pension_benefits " + + "WHERE temp_id = ?"; + + try { // Use queryForObject to get a single boolean result Boolean result = jdbcTemplate.queryForObject(sql, Boolean.class, tempId); diff --git a/backend/pensioner/service/DeptPartiallyCompService.java b/backend/pensioner/service/DeptPartiallyCompService.java index 1cb4f60..7675989 100644 --- a/backend/pensioner/service/DeptPartiallyCompService.java +++ b/backend/pensioner/service/DeptPartiallyCompService.java @@ -307,7 +307,7 @@ public class DeptPartiallyCompService { String sql = "SELECT \r\n" + " CASE \r\n" + " WHEN zb.gpf = 'yes' AND zb.spfgs = 'yes' AND zb.private_affairs = 'yes' AND zb.dcrg = 'yes' \r\n" - + " AND pb.benefit_pension = 'yes' AND pb.benefit_dcrg = 'yes' AND pb.benefit_commutation = 'yes' THEN 1 ELSE 0 \r\n" + + " AND pb.benefit_pension = 'yes' AND pb.benefit_dcrg = 'yes' THEN 1 ELSE 0 \r\n" + " END AS allYes \r\n" + "FROM zone_benefits AS zb\r\n" + "JOIN pension_benefits AS pb ON zb.temp_id = pb.temp_id \r\n" diff --git a/backend/pensioner/service/NewEntryService.java b/backend/pensioner/service/NewEntryService.java index bbb3f7e..9a51ede 100644 --- a/backend/pensioner/service/NewEntryService.java +++ b/backend/pensioner/service/NewEntryService.java @@ -52,7 +52,73 @@ public class NewEntryService { this.jdbcTemplate = new JdbcTemplate(dataSource); } - +// old retiment list getting method + +// public Map fetchEmplyeeDetails(String fromDate, String toDate, Integer deptId) { +// Map response = new HashMap<>(); +// +// String apiUrl = appconfig.qaqcurl + "serviceId=common_api" +// + "&jsonResp=Yes" +// + "&subService=getEmpPenDetDuration" +// + "&fromDate=" + fromDate +// + "&toDate=" + toDate +// + "&deptId=" + deptId; +// +// System.out.println("url: " + apiUrl); +// System.out.println("deptId:" + deptId); +// try { +// String rawResponse = restTemplate.getForObject(apiUrl, String.class); +// System.out.println("Raw Response: " + rawResponse); // Debugging step +// +// if (isValidJson(rawResponse)) { +// JsonNode jsonResponse = objectMapper.readTree(rawResponse); +// +// // Extract the "ListResult" array +// JsonNode details = jsonResponse.path("ListResult"); +// +// if (details.isArray() && details.size() > 0) { +// List> list = new ArrayList<>(); +// for (JsonNode detail : details) { +// Map listResult = new HashMap<>(); +// +// listResult.put("RETIREMENT_DATE", getNonNullValue(detail.path("RETIREMENT_DATE"))); +// listResult.put("DEATH_DATE", getNonNullValue(detail.path("DEATH_DATE"))); +// listResult.put("COMMUNITY_NAME", getNonNullValue(detail.path("COMMUNITY_NAME"))); +// listResult.put("GROUP_TYPE", getNonNullValue(detail.path("GROUP_TYPE"))); +// listResult.put("ID_DEPT", getNonNullValue(detail.path("ID_DEPT"))); +// listResult.put("EMPLOYEE_CODE", getNonNullValue(detail.path("EMPLOYEE_CODE"))); +// listResult.put("FUNCTIONARY", getNonNullValue(detail.path("FUNCTIONARY"))); +// listResult.put("IS_HANDICAPPED", getNonNullValue(detail.path("IS_HANDICAPPED"))); +// listResult.put("GENDER", getNonNullValue(detail.path("GENDER"))); +// listResult.put("DATE_OF_BIRTH", getNonNullValue(detail.path("DATE_OF_BIRTH"))); +// listResult.put("DATE_OF_APPOINTMENT", getNonNullValue(detail.path("DATE_OF_APPOINTMENT"))); +// listResult.put("DESIGNATION", getNonNullValue(detail.path("DESIGNATION"))); +// listResult.put("EMPLOYEE_NAME", getNonNullValue(detail.path("EMPLOYEE_NAME"))); +// listResult.put("DEPARTMENT", getNonNullValue(detail.path("DEPARTMENT"))); +// list.add(listResult); +// } +// // Sort the list by RETIREMENT_DATE in ascending order +// list.sort(Comparator.comparing(map -> parseDate(((Map) map).get("RETIREMENT_DATE")))); +// +// response.put("list", list); +// +// } else { +// response.put("list", Collections.emptyList()); +// } +// } else { +// System.err.println("Invalid JSON Response: " + rawResponse); +// response.put("list", Collections.emptyList()); +// } +// +// } catch (Exception e) { +// e.printStackTrace(); +// response.put("list", Collections.emptyList()); +// } +// return response; +// } + + + // new retirement list getting method with condition public Map fetchEmplyeeDetails(String fromDate, String toDate, Integer deptId) { Map response = new HashMap<>(); @@ -65,41 +131,48 @@ public class NewEntryService { System.out.println("url: " + apiUrl); System.out.println("deptId:" + deptId); + try { String rawResponse = restTemplate.getForObject(apiUrl, String.class); System.out.println("Raw Response: " + rawResponse); // Debugging step if (isValidJson(rawResponse)) { JsonNode jsonResponse = objectMapper.readTree(rawResponse); - - // Extract the "ListResult" array JsonNode details = jsonResponse.path("ListResult"); if (details.isArray() && details.size() > 0) { List> list = new ArrayList<>(); + LocalDate currentDate = LocalDate.now(); // Get today's date + for (JsonNode detail : details) { - Map listResult = new HashMap<>(); - listResult.put("RETIREMENT_DATE", getNonNullValue(detail.path("RETIREMENT_DATE"))); - listResult.put("DEATH_DATE", getNonNullValue(detail.path("DEATH_DATE"))); - listResult.put("COMMUNITY_NAME", getNonNullValue(detail.path("COMMUNITY_NAME"))); - listResult.put("GROUP_TYPE", getNonNullValue(detail.path("GROUP_TYPE"))); - listResult.put("ID_DEPT", getNonNullValue(detail.path("ID_DEPT"))); - listResult.put("EMPLOYEE_CODE", getNonNullValue(detail.path("EMPLOYEE_CODE"))); - listResult.put("FUNCTIONARY", getNonNullValue(detail.path("FUNCTIONARY"))); - listResult.put("IS_HANDICAPPED", getNonNullValue(detail.path("IS_HANDICAPPED"))); - listResult.put("GENDER", getNonNullValue(detail.path("GENDER"))); - listResult.put("DATE_OF_BIRTH", getNonNullValue(detail.path("DATE_OF_BIRTH"))); - listResult.put("DATE_OF_APPOINTMENT", getNonNullValue(detail.path("DATE_OF_APPOINTMENT"))); - listResult.put("DESIGNATION", getNonNullValue(detail.path("DESIGNATION"))); - listResult.put("EMPLOYEE_NAME", getNonNullValue(detail.path("EMPLOYEE_NAME"))); - listResult.put("DEPARTMENT", getNonNullValue(detail.path("DEPARTMENT"))); - list.add(listResult); + String retirementDateStr = getNonNullValue(detail.path("RETIREMENT_DATE")); + LocalDate retirementDate = parseDate(retirementDateStr); + + // Only add to the list if RETIREMENT_DATE is today or in the future + if (retirementDate != null && !retirementDate.isBefore(currentDate)) { + Map listResult = new HashMap<>(); + listResult.put("RETIREMENT_DATE", retirementDateStr); + listResult.put("DEATH_DATE", getNonNullValue(detail.path("DEATH_DATE"))); + listResult.put("COMMUNITY_NAME", getNonNullValue(detail.path("COMMUNITY_NAME"))); + listResult.put("GROUP_TYPE", getNonNullValue(detail.path("GROUP_TYPE"))); + listResult.put("ID_DEPT", getNonNullValue(detail.path("ID_DEPT"))); + listResult.put("EMPLOYEE_CODE", getNonNullValue(detail.path("EMPLOYEE_CODE"))); + listResult.put("FUNCTIONARY", getNonNullValue(detail.path("FUNCTIONARY"))); + listResult.put("IS_HANDICAPPED", getNonNullValue(detail.path("IS_HANDICAPPED"))); + listResult.put("GENDER", getNonNullValue(detail.path("GENDER"))); + listResult.put("DATE_OF_BIRTH", getNonNullValue(detail.path("DATE_OF_BIRTH"))); + listResult.put("DATE_OF_APPOINTMENT", getNonNullValue(detail.path("DATE_OF_APPOINTMENT"))); + listResult.put("DESIGNATION", getNonNullValue(detail.path("DESIGNATION"))); + listResult.put("EMPLOYEE_NAME", getNonNullValue(detail.path("EMPLOYEE_NAME"))); + listResult.put("DEPARTMENT", getNonNullValue(detail.path("DEPARTMENT"))); + list.add(listResult); + } } - // Sort the list by RETIREMENT_DATE in ascending order - list.sort(Comparator.comparing(map -> parseDate(((Map) map).get("RETIREMENT_DATE")))); - - response.put("list", list); + // Sort the list by RETIREMENT_DATE in ascending order + list.sort(Comparator.comparing(map -> parseDate(map.get("RETIREMENT_DATE")))); + + response.put("list", list); } else { response.put("list", Collections.emptyList()); } @@ -107,15 +180,16 @@ public class NewEntryService { System.err.println("Invalid JSON Response: " + rawResponse); response.put("list", Collections.emptyList()); } - } catch (Exception e) { e.printStackTrace(); response.put("list", Collections.emptyList()); } return response; } - - + + + + public Map fetchEmplyeeDetailsbyCode(String empCode) { @@ -123,7 +197,7 @@ public class NewEntryService { String apiUrl = appconfig.qaqcurl + "serviceId=common_api" + "&jsonResp=Yes" - + "&subService=getEmpPenDet" + + "&subService=getEmpWorkDet" + "&empCode=" + empCode; System.out.println("url: " + apiUrl); @@ -143,6 +217,7 @@ public class NewEntryService { for (JsonNode detail : details) { Map listResult = new HashMap<>(); listResult.put("RETIREMENT_DATE", formatToISODate(getNonNullValue(detail.path("RETIREMENT_DATE")))); + listResult.put("TO_DATE", parseDate(getNonNullValue(detail.path("TO_DATE"))).toString()); listResult.put("DEATH_DATE", getNonNullValue(detail.path("DEATH_DATE"))); listResult.put("COMMUNITY_NAME", getNonNullValue(detail.path("COMMUNITY_NAME"))); listResult.put("GROUP_TYPE", getNonNullValue(detail.path("GROUP_TYPE"))); @@ -161,6 +236,7 @@ public class NewEntryService { // Sort the list by RETIREMENT_DATE in ascending order list.sort(Comparator.comparing(map -> parseDate(((Map) map).get("RETIREMENT_DATE")))); response.put("list", list); + System.out.println("listresult: "+list); } else { response.put("list", Collections.emptyList()); @@ -208,21 +284,49 @@ public class NewEntryService { } } + + private LocalDate parseDate(String date) { + if (date == null || date.isEmpty()) { + return LocalDate.MIN; // Use a minimum value for invalid or empty dates + } + try { + // Remove time part if present + if (date.contains(" ")) { + date = date.split(" ")[0]; // Extract only the date part before space + } + + DateTimeFormatter formatter; + if (date.matches("\\d{4}-\\d{2}-\\d{2}")) { // yyyy-MM-dd + formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + } else if (date.matches("\\d{2}-\\d{2}-\\d{4}")) { // dd-MM-yyyy + formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + } else { + System.err.println("Unknown date format: " + date); + return LocalDate.MIN; + } + return LocalDate.parse(date, formatter); + } catch (DateTimeParseException e) { + e.printStackTrace(); + return LocalDate.MIN; // Fallback for invalid dates + } + } + + - private LocalDate parseDate(String date) { - if (date == null || date.isEmpty()) { - return LocalDate.MIN; // Use a minimum value for invalid or empty dates - } - try { - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); // Adjust format as needed - return LocalDate.parse(date, formatter); - } catch (DateTimeParseException e) { - e.printStackTrace(); - return LocalDate.MIN; // Fallback for invalid dates - } - } +// private LocalDate parseDate(String date) { +// if (date == null || date.isEmpty()) { +// return LocalDate.MIN; // Use a minimum value for invalid or empty dates +// } +// try { +// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); // Adjust format as needed +// return LocalDate.parse(date, formatter); +// } catch (DateTimeParseException e) { +// e.printStackTrace(); +// return LocalDate.MIN; // Fallback for invalid dates +// } +// } private boolean isValidJson(String json) { diff --git a/backend/pensioner/service/PensionPartiallyCompService.java b/backend/pensioner/service/PensionPartiallyCompService.java index 2cd94e4..1e7bf54 100644 --- a/backend/pensioner/service/PensionPartiallyCompService.java +++ b/backend/pensioner/service/PensionPartiallyCompService.java @@ -304,7 +304,7 @@ public class PensionPartiallyCompService { // Define the SQL query String sql = "SELECT " + "CASE " + - "WHEN pb.benefit_pension = 'yes' AND pb.benefit_dcrg = 'yes' AND pb.benefit_commutation = 'yes' " + + "WHEN pb.benefit_pension = 'yes' AND pb.benefit_dcrg = 'yes' " + "THEN 1 ELSE 0 " + "END AS allYes " + "FROM pension_benefits AS pb " + diff --git a/frontend/pensioner/department/audit/pendency.html b/frontend/pensioner/department/audit/pendency.html index d0e8981..084a933 100644 --- a/frontend/pensioner/department/audit/pendency.html +++ b/frontend/pensioner/department/audit/pendency.html @@ -313,7 +313,7 @@ margin-top: 10px; -
+
@@ -355,7 +355,7 @@ margin-top: 10px;
- +
@@ -546,6 +546,11 @@ margin-top: 10px; // $('#datefile').val(''); $('#remarks').val(''); document.getElementById("receivedcard").style.display = "block"; + // Scroll the receivedcard section into view + document.getElementById("receivedcard").scrollIntoView({ + behavior: "smooth", // Smooth scrolling effect + block: "center" // Aligns the element to the center of the viewport + }); }); @@ -663,7 +668,7 @@ margin-top: 10px; function saveEntryDetails(tempId,empNo) { //console.log("emp_no inside=="+empCode); let entryDetails = { - empNo: empNo, + empNo: $('#employeeno').val(), tempId: tempId, dateToAudit:convertDateFormat($('#datefile').val()?.trim()), remarks: $('#remarks').val(), diff --git a/frontend/pensioner/department/audit/retirement.html b/frontend/pensioner/department/audit/retirement.html index 3ed06c6..e976a60 100644 --- a/frontend/pensioner/department/audit/retirement.html +++ b/frontend/pensioner/department/audit/retirement.html @@ -249,7 +249,7 @@ margin-top: 10px;
-
+
@@ -304,7 +304,7 @@ margin-top: 10px;
- +
diff --git a/frontend/pensioner/department/closedList.html b/frontend/pensioner/department/closedList.html index 7511342..53b3558 100644 --- a/frontend/pensioner/department/closedList.html +++ b/frontend/pensioner/department/closedList.html @@ -628,7 +628,7 @@ margin-top: 10px; Swal.fire({ icon: "warning", title: "No Data Found", - text: "No details found for this employee number.", + text: "No details found.", confirmButtonText: "OK", customClass: { confirmButton: "btn btn-primary" diff --git a/frontend/pensioner/department/completed/gis.html b/frontend/pensioner/department/completed/gis.html index 09bcf75..f49837c 100644 --- a/frontend/pensioner/department/completed/gis.html +++ b/frontend/pensioner/department/completed/gis.html @@ -237,7 +237,7 @@ margin-top: 10px; -
+
diff --git a/frontend/pensioner/department/completed/provisionalretirement.html b/frontend/pensioner/department/completed/provisionalretirement.html index 4479023..1aee562 100644 --- a/frontend/pensioner/department/completed/provisionalretirement.html +++ b/frontend/pensioner/department/completed/provisionalretirement.html @@ -309,7 +309,7 @@ margin-top: 10px;
-
+
diff --git a/frontend/pensioner/department/dashboard.html b/frontend/pensioner/department/dashboard.html index c13aadd..fc58afc 100644 --- a/frontend/pensioner/department/dashboard.html +++ b/frontend/pensioner/department/dashboard.html @@ -680,7 +680,7 @@ margin-top: 10px; }); // Function to validate and set min-date for endDate - function validateEndDate() { + /* function validateEndDate() { const startDate = document.getElementById('startDate').value; const endDateInput = document.getElementById('endDate'); @@ -697,7 +697,7 @@ margin-top: 10px; } document.getElementById('startDate').addEventListener('change', validateEndDate); - + */ function renderCharts(startDate = null, endDate = null) { const deptId = $('#deptId').text().trim(); @@ -926,6 +926,58 @@ $.ajax({ }); }) + + + + $('#startDate').on('change', function () { + const fromDate = $(this).val(); + $('#endDate').attr('min', fromDate); // Update min attribute for To Date + + // If To Date is earlier than the new From Date, adjust it + const toDate = $('#endDate').val(); + if (new Date(toDate) < new Date(fromDate)) { + $('#endDate').val(fromDate); + } + }); + + // Update From Date's max attribute when To Date changes + $('#endDate').on('change', function () { + const toDate = $(this).val(); + $('#startDate').attr('max', toDate); // Update max attribute for From Date + + // If From Date is later than the new To Date, adjust it + const fromDate = $('#startDate').val(); + if (new Date(fromDate) > new Date(toDate)) { + $('#startDate').val(toDate); + } + }); + + + //disable future dates + document.addEventListener("DOMContentLoaded", function () { + let today = new Date().toISOString().split("T")[0]; // Get today's date in YYYY-MM-DD format + let startdateInput = document.getElementById("startDate"); + let enddateInput = document.getElementById("endDate"); + + // Set max attribute to disable future dates + startdateInput.setAttribute("max", today); + enddateInput.setAttribute("max", today); + + + // Prevent manual future date entry + startdateInput.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 + } + }); + }); + diff --git a/frontend/pensioner/department/fileclosing.html b/frontend/pensioner/department/fileclosing.html index 2fb23f6..63da3fc 100644 --- a/frontend/pensioner/department/fileclosing.html +++ b/frontend/pensioner/department/fileclosing.html @@ -580,7 +580,7 @@ margin-top: 10px;
- +
@@ -649,6 +649,31 @@ margin-top: 10px; // Call once on page load initializeDataTable(); + + + // 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 Search button click @@ -726,7 +751,7 @@ margin-top: 10px; ${audit.emp_name || 'N/A'} ${audit.dept_name || 'N/A'} ${audit.designation || 'N/A'} - ${audit.file_moved_date ? formatDate(audit['file_moved_date'],'dd-MM-yyyy') : 'N/A'} + ${audit.file_moved_date ? formatDate(audit.file_moved_date, 'dd-MM-yyyy') : 'N/A'} ${audit.file_entry_type || 'N/A'}