diff --git a/backend/pensioner/controller/NewEntryAPIController.java b/backend/pensioner/controller/NewEntryAPIController.java index 24ed3f9..6428bcb 100644 --- a/backend/pensioner/controller/NewEntryAPIController.java +++ b/backend/pensioner/controller/NewEntryAPIController.java @@ -110,7 +110,7 @@ public class NewEntryAPIController { Map datalist = newEntryService.fetchEmplyeeDetails(formattedFromDate, formattedToDate, deptId); System.out.println("datalist="+datalist); - List emps= newEntryService.getRegisteredEmps(deptId,file_category); + List emps= newEntryService.getRegisteredEmps(deptId); // Format the dates for frontend in "yyyy-MM-dd" DateTimeFormatter frontendFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); diff --git a/backend/pensioner/service/NewEntryService.java b/backend/pensioner/service/NewEntryService.java index b7e637b..4502abb 100644 --- a/backend/pensioner/service/NewEntryService.java +++ b/backend/pensioner/service/NewEntryService.java @@ -428,8 +428,21 @@ public class NewEntryService { } - public List getRegisteredEmps(Integer deptId, Integer file_category) { - String query = "SELECT DISTINCT emp_no FROM pensioner_details WHERE dept_id=? " + +// public List getRegisteredEmps(Integer deptId) { +// String query = "SELECT DISTINCT emp_no FROM pensioner_details WHERE dept_id=? AND file_category <> 5 " + +// "UNION ALL " + +// "SELECT DISTINCT emp_no FROM cps_pensioner_details WHERE dept_id=?"; +// +// List emps = jdbcTemplate.queryForList(query, String.class, deptId, deptId); +// System.out.println("emps====" + emps); +// +// return emps; +// } + + + public List getRegisteredEmps(Integer deptId) { + String query = "SELECT DISTINCT emp_no FROM pensioner_details " + + "WHERE dept_id=? AND (file_category <> 5 OR (file_category = 5 AND file_status != 11)) " + "UNION ALL " + "SELECT DISTINCT emp_no FROM cps_pensioner_details WHERE dept_id=?"; @@ -438,6 +451,7 @@ public class NewEntryService { return emps; } + public Integer getRetirementFileCategoryId() { String query = "SELECT id FROM file_category_master WHERE file_name = 'Retirement'"; @@ -476,7 +490,7 @@ public class NewEntryService { } public Integer getPRFileCategoryId() { - String query = "SELECT id FROM file_category_master WHERE file_name = 'Provisional Retirement'"; + String query = "SELECT id FROM file_category_master WHERE file_name = 'Provisional Pension'"; try { return jdbcTemplate.queryForObject(query, Integer.class); } catch (EmptyResultDataAccessException e) { @@ -573,9 +587,9 @@ public class NewEntryService { String remarks = (String) requestData.get("remarks"); String serviceDeath =(String) requestData.get("serviceDeath"); String deceased =(String) requestData.get("deceased"); - String gisentry = (String) requestData.get("gisentry"); - String gisAdvanceamount =(String) requestData.get("gisAdvanceamount"); - String gisAdvance = (String) requestData.get("gisAdvance"); + String gisentry = requestData.get("gisentry") != null ?(String) requestData.get("gisentry") : null; + String gisAdvanceamount =requestData.get("gisAdvanceamount") != null ?(String) requestData.get("gisAdvanceamount") : null; + String gisAdvance = requestData.get("gisAdvance") != null ? (String) requestData.get("gisAdvance") : null; String dept_Id = (String) requestData.get("deptId"); int deptId = Integer.parseInt(dept_Id); diff --git a/backend/pensioner/service/ReportApiService.java b/backend/pensioner/service/ReportApiService.java index 741a9db..51598d0 100644 --- a/backend/pensioner/service/ReportApiService.java +++ b/backend/pensioner/service/ReportApiService.java @@ -445,14 +445,76 @@ public class ReportApiService { +// public List> getReportDetailspension(String startDate, String endDate, List deptIds, Integer fileCatId, List fileStatus) { +// String sql = ""; +// List params = new ArrayList<>(); +// +// boolean selectAll = deptIds.contains("ALL"); +// +// // ✅ If "ALL" is selected, remove department filtering +// String deptCondition = selectAll ? "1=1" : "pd.dept_id IN (" + String.join(",", Collections.nCopies(deptIds.size(), "?")) + ")"; +// +// // ✅ Handle fileStatus as multiple values in IN clause +// String fileStatusCondition = (fileStatus != null && !fileStatus.isEmpty()) +// ? " AND pd.file_status IN (" + String.join(",", Collections.nCopies(fileStatus.size(), "?")) + ")" +// : ""; // Skip condition if fileStatus is empty or null +// +// if (fileCatId == 6) { +// sql = "SELECT pd.emp_no, pd.emp_name, pd.designation, pd.type_of_retirement, pd.reason_for_pending,pd.retirement_date, " + +// "fm.file_status AS fst, pd.file_category_name, pd.remarks, DATE(pd.created_date) AS created_date " + +// "FROM cps_pensioner_details pd " + +// "INNER JOIN file_status_master fm ON pd.file_status = fm.id " + +// "WHERE DATE(pd.created_date) BETWEEN DATE(?) AND DATE(?) " + // First: Date filter +// "AND pd.file_category = ? " + // Second: File category filter +// "AND " + deptCondition + // Third: Department condition +// fileStatusCondition; // Last: File status condition +// +// } else { +// sql = "SELECT pd.*, fm.file_status as fst " + +// "FROM pensioner_details pd " + +// "INNER JOIN file_status_master fm ON pd.file_status = fm.id " + +// "WHERE DATE(pd.created_date) BETWEEN DATE(?) AND DATE(?) " + // First: Date filter +// "AND pd.file_category = ? " + // Second: File category filter +// "AND " + deptCondition + // Third: Department condition +// fileStatusCondition; // Last: File status condition +// } +// +// // Add date range parameters first +// params.add(startDate); +// params.add(endDate); +// +// // Add file category next +// params.add(fileCatId); +// +// // Add department filter parameters if not "ALL" +// if (!selectAll) { +// params.addAll(deptIds); +// } +// +// // Add fileStatus parameters if present +// if (fileStatus != null && !fileStatus.isEmpty()) { +// params.addAll(fileStatus); +// } +// +// System.out.println("Executing SQL Query: " + sql); +// System.out.println("Query Parameters: " + params); +// +// return jdbcTemplate.queryForList(sql, params.toArray()); +// } + + + public List> getReportDetailspension(String startDate, String endDate, List deptIds, Integer fileCatId, List fileStatus) { String sql = ""; List params = new ArrayList<>(); - boolean selectAll = deptIds.contains("ALL"); + // ✅ Ensure deptIds is never empty, otherwise fetch nothing + if (deptIds == null || deptIds.isEmpty()) { + return new ArrayList<>(); + } - // ✅ If "ALL" is selected, remove department filtering - String deptCondition = selectAll ? "1=1" : "pd.dept_id IN (" + String.join(",", Collections.nCopies(deptIds.size(), "?")) + ")"; + // ✅ Construct IN clause for department filtering + String deptCondition = "pd.dept_id IN (" + String.join(",", Collections.nCopies(deptIds.size(), "?")) + ")"; // ✅ Handle fileStatus as multiple values in IN clause String fileStatusCondition = (fileStatus != null && !fileStatus.isEmpty()) @@ -460,23 +522,23 @@ public class ReportApiService { : ""; // Skip condition if fileStatus is empty or null if (fileCatId == 6) { - sql = "SELECT pd.emp_no, pd.emp_name, pd.designation, pd.type_of_retirement, pd.reason_for_pending,pd.retirement_date, " + + sql = "SELECT pd.emp_no, pd.emp_name, pd.designation, pd.type_of_retirement, pd.reason_for_pending, pd.retirement_date, " + "fm.file_status AS fst, pd.file_category_name, pd.remarks, DATE(pd.created_date) AS created_date " + "FROM cps_pensioner_details pd " + "INNER JOIN file_status_master fm ON pd.file_status = fm.id " + - "WHERE DATE(pd.created_date) BETWEEN DATE(?) AND DATE(?) " + // First: Date filter - "AND pd.file_category = ? " + // Second: File category filter - "AND " + deptCondition + // Third: Department condition - fileStatusCondition; // Last: File status condition + "WHERE DATE(pd.created_date) BETWEEN DATE(?) AND DATE(?) " + + "AND pd.file_category = ? " + + "AND " + deptCondition + + fileStatusCondition; } else { sql = "SELECT pd.*, fm.file_status as fst " + "FROM pensioner_details pd " + "INNER JOIN file_status_master fm ON pd.file_status = fm.id " + - "WHERE DATE(pd.created_date) BETWEEN DATE(?) AND DATE(?) " + // First: Date filter - "AND pd.file_category = ? " + // Second: File category filter - "AND " + deptCondition + // Third: Department condition - fileStatusCondition; // Last: File status condition + "WHERE DATE(pd.created_date) BETWEEN DATE(?) AND DATE(?) " + + "AND pd.file_category = ? " + + "AND " + deptCondition + + fileStatusCondition; } // Add date range parameters first @@ -486,10 +548,8 @@ public class ReportApiService { // Add file category next params.add(fileCatId); - // Add department filter parameters if not "ALL" - if (!selectAll) { - params.addAll(deptIds); - } + // Add department filter parameters + params.addAll(deptIds); // Add fileStatus parameters if present if (fileStatus != null && !fileStatus.isEmpty()) { @@ -504,7 +564,6 @@ public class ReportApiService { - public List> getDepartmentpending(int file_category) { String sql = "SELECT dept_name, emp_name, emp_no, file_category_name, file_status, file_moved_date, remarks " + diff --git a/frontend/pensioner/department/completed/gis.html b/frontend/pensioner/department/completed/gis.html index 3035849..5c93f94 100644 --- a/frontend/pensioner/department/completed/gis.html +++ b/frontend/pensioner/department/completed/gis.html @@ -248,6 +248,7 @@ margin-top: 10px; + + +
@@ -392,7 +395,7 @@ margin-top: 10px; $('#employeename').val(employeeDetails.emp_name); $('#department').val(employeeDetails.dept_name); $('#designation').val(employeeDetails.designation); - $('#gisentry').val(employeeDetails.gis_entry); + $('#classes').val(employeeDetails.relationship_deceased); $('#datefile_modal').val(employeeDetails.file_moved_date); @@ -410,16 +413,26 @@ margin-top: 10px; // Populate gis advance Section based on response or data - if (employeeDetails.gis_advance === "yes") { - $('#gisyes').prop('checked', true); // Check Yes radio button - $('#gisno').prop('disabled', true); // Disable No radio button - $('#gisAmountInputContainer').show(); // Show CPS amount input field - $('#gisAmountInput').val(employeeDetails.gis_advance_amount || '').prop('readonly', true); // Set CPS amount and make readonly - } else if (employeeDetails.gis_advance === "no") { - $('#gisno').prop('checked', true); // Check No radio button - $('#gisyes').prop('disabled', true); // Disable Yes radio button - $('#gisAmountInputContainer').hide(); // Hide CPS amount input field - } + if(employeeDetails.gis_entry!=null && employeeDetails.gis_advance!=null){ + + $('#gisentrycontainer').show(); + + $('#gisentry').val(employeeDetails.gis_entry); + // Populate gis advance Section based on response or data + if (employeeDetails.gis_advance === "yes") { + $('#gisyes').prop('checked', true); // Check Yes radio button + $('#gisno').prop('disabled', true); // Disable No radio button + $('#gisAmountInputContainer').show(); // Show CPS amount input field + $('#gisAmountInput').val(employeeDetails.gis_advance_amount || '').prop('readonly', true); // Set CPS amount and make readonly + } else if (employeeDetails.gis_advance === "no") { + $('#gisno').prop('checked', true); // Check No radio button + $('#gisyes').prop('disabled', true); // Disable Yes radio button + $('#gisAmountInputContainer').hide(); // Hide CPS amount input field + } + } + else{ + $('#gisentrycontainer').hide(); + } // Update the modal title with the employee code $('#modalEmployeeCode').text(employeeDetails.emp_no); diff --git a/frontend/pensioner/department/newentry/gis.html b/frontend/pensioner/department/newentry/gis.html index e9afa85..c7a2c38 100644 --- a/frontend/pensioner/department/newentry/gis.html +++ b/frontend/pensioner/department/newentry/gis.html @@ -274,6 +274,7 @@ input.form-control {
+ +
@@ -391,7 +394,7 @@ margin-top: 10px; $('#employeename').val(employeeDetails.emp_name); $('#department').val(employeeDetails.dept_name); $('#designation').val(employeeDetails.designation); - $('#gisentry').val(employeeDetails.gis_entry); + $('#classes').val(employeeDetails.relationship_deceased); $('#datefile_modal').val(employeeDetails.file_moved_date); @@ -409,16 +412,26 @@ margin-top: 10px; // Populate gis advance Section based on response or data - if (employeeDetails.gis_advance === "yes") { - $('#gisyes').prop('checked', true); // Check Yes radio button - $('#gisno').prop('disabled', true); // Disable No radio button - $('#gisAmountInputContainer').show(); // Show CPS amount input field - $('#gisAmountInput').val(employeeDetails.gis_advance_amount || '').prop('readonly', true); // Set CPS amount and make readonly - } else if (employeeDetails.gis_advance === "no") { - $('#gisno').prop('checked', true); // Check No radio button - $('#gisyes').prop('disabled', true); // Disable Yes radio button - $('#gisAmountInputContainer').hide(); // Hide CPS amount input field - } + if(employeeDetails.gis_entry!=null && employeeDetails.gis_advance!=null){ + + $('#gisentrycontainer').show(); + + $('#gisentry').val(employeeDetails.gis_entry); + // Populate gis advance Section based on response or data + if (employeeDetails.gis_advance === "yes") { + $('#gisyes').prop('checked', true); // Check Yes radio button + $('#gisno').prop('disabled', true); // Disable No radio button + $('#gisAmountInputContainer').show(); // Show CPS amount input field + $('#gisAmountInput').val(employeeDetails.gis_advance_amount || '').prop('readonly', true); // Set CPS amount and make readonly + } else if (employeeDetails.gis_advance === "no") { + $('#gisno').prop('checked', true); // Check No radio button + $('#gisyes').prop('disabled', true); // Disable Yes radio button + $('#gisAmountInputContainer').hide(); // Hide CPS amount input field + } + } + else{ + $('#gisentrycontainer').hide(); + } // Update the modal title with the employee code $('#modalEmployeeCode').text(employeeDetails.emp_no); diff --git a/frontend/pensioner/pensioner/received/gis.html b/frontend/pensioner/pensioner/received/gis.html index db03576..d861ba2 100644 --- a/frontend/pensioner/pensioner/received/gis.html +++ b/frontend/pensioner/pensioner/received/gis.html @@ -247,12 +247,15 @@ margin-top: 10px;
+ + @@ -444,25 +449,34 @@ margin-top: 10px; $('#employeename').val(employeeDetails.emp_name); $('#department').val(employeeDetails.dept_name); $('#designation').val(employeeDetails.designation); - $('#gisentry').val(employeeDetails.gis_entry); + $('#classes').val(employeeDetails.relationship_deceased); $('#datefile_modal').val(employeeDetails.file_moved_date); $('#remarks_modal').val(employeeDetails.remarks); $('#retirementdate').val(employeeDetails.service_death); - - // Populate gis advance Section based on response or data - if (employeeDetails.gis_advance === "yes") { - $('#gisyes').prop('checked', true); // Check Yes radio button - $('#gisno').prop('disabled', true); // Disable No radio button - $('#gisAmountInputContainer').show(); // Show CPS amount input field - $('#gisAmountInput').val(employeeDetails.gis_advance_amount || '').prop('readonly', true); // Set CPS amount and make readonly - } else if (employeeDetails.gis_advance === "no") { - $('#gisno').prop('checked', true); // Check No radio button - $('#gisyes').prop('disabled', true); // Disable Yes radio button - $('#gisAmountInputContainer').hide(); // Hide CPS amount input field - } - + if(employeeDetails.gis_entry!=null && employeeDetails.gis_advance!=null){ + + $('#gisentrycontainer').show(); + + $('#gisentry').val(employeeDetails.gis_entry); + // Populate gis advance Section based on response or data + if (employeeDetails.gis_advance === "yes") { + $('#gisyes').prop('checked', true); // Check Yes radio button + $('#gisno').prop('disabled', true); // Disable No radio button + $('#gisAmountInputContainer').show(); // Show CPS amount input field + $('#gisAmountInput').val(employeeDetails.gis_advance_amount || '').prop('readonly', true); // Set CPS amount and make readonly + } else if (employeeDetails.gis_advance === "no") { + $('#gisno').prop('checked', true); // Check No radio button + $('#gisyes').prop('disabled', true); // Disable Yes radio button + $('#gisAmountInputContainer').hide(); // Hide CPS amount input field + } + } + else{ + $('#gisentrycontainer').hide(); + } + + // Update the modal title with the employee code $('#modalEmployeeCode').text(employeeDetails.emp_no); diff --git a/frontend/pensioner/pensioner/reports.html b/frontend/pensioner/pensioner/reports.html index 4e3061c..6f05994 100644 --- a/frontend/pensioner/pensioner/reports.html +++ b/frontend/pensioner/pensioner/reports.html @@ -221,19 +221,12 @@ td, th {