From 486bde1c547422a8ce7e39055f821772e677415d Mon Sep 17 00:00:00 2001 From: yoganandhank Date: Sat, 8 Aug 2026 17:10:36 +0530 Subject: [PATCH] changes added in manpower project and adjustment management project api's and service controller, pages --- .../controller/HomeController.java | 89 + .../controller/AdjustmentController.java | 65 +- .../service/AdjustmentService.java | 156 +- .../gcc_manpower/service/AppUserService.java | 100 +- .../resources/application-local.properties | 4 +- .../gccadjustmentmanagement/dashboard.html | 1032 ++++++++-- .../gccadjustmentmanagement/details.html | 1824 +++++++++++++++++ .../gccadjustmentmanagement/login.html | 2 +- .../gccservicepaymenttracker/details.html | 6 +- src/main/resources/templates/home/home.html | 290 ++- 10 files changed, 3379 insertions(+), 189 deletions(-) create mode 100644 src/main/resources/templates/gccadjustmentmanagement/details.html diff --git a/src/main/java/com/gcc_manpower/controller/HomeController.java b/src/main/java/com/gcc_manpower/controller/HomeController.java index ab70d7d..066b307 100644 --- a/src/main/java/com/gcc_manpower/controller/HomeController.java +++ b/src/main/java/com/gcc_manpower/controller/HomeController.java @@ -471,6 +471,95 @@ public class HomeController { return response; } + @PostMapping("/api/vendor/edit-work-order") + @ResponseBody + public Map editVendorWorkOrder( + @RequestParam("id") String workOrderId, + @RequestParam(value = "contractorName", required = false) String contractorName, + @RequestParam(value = "fileNo", required = false) String fileNo, + @RequestParam(value = "subject", required = false) String subject, + @RequestParam(value = "issueDate", required = false) String issueDate, + @RequestParam(value = "endDate", required = false) String endDate, + @RequestParam(value = "totalEmployees", required = false) String totalEmployees, + @RequestParam(value = "file", required = false) MultipartFile file, + HttpSession session) { + Map response = new HashMap<>(); + String usrName = (String) session.getAttribute("usrName"); + String usrRole = (String) session.getAttribute("usrRole"); + boolean isAdmin = "ADMIN".equalsIgnoreCase(usrRole); + + if (usrName == null || !isAdmin) { + response.put("success", false); + response.put("error", "Unauthorized! Admin access required."); + return response; + } + + try { + if (workOrderId == null || workOrderId.trim().isEmpty()) { + response.put("success", false); + response.put("error", "Work order ID is required."); + return response; + } + + // Convert to uppercase for Contractor Name and File No + if (contractorName != null) { + contractorName = contractorName.toUpperCase(); + } + if (fileNo != null) { + fileNo = fileNo.toUpperCase(); + } + + String fileWebUrl = null; + if (file != null && !file.isEmpty()) { + File uploadDir = new File(uploadPathConfig).getAbsoluteFile(); + if (!uploadDir.exists()) { + uploadDir.mkdirs(); + } + String originalFilename = file.getOriginalFilename(); + String nameWithoutExt = ""; + String ext = ".pdf"; + if (originalFilename != null && originalFilename.contains(".")) { + int dotIdx = originalFilename.lastIndexOf("."); + nameWithoutExt = originalFilename.substring(0, dotIdx); + ext = originalFilename.substring(dotIdx); + } else { + nameWithoutExt = originalFilename != null ? originalFilename : "file"; + } + nameWithoutExt = nameWithoutExt.replaceAll("[^a-zA-Z0-9-_]", "_"); + String savedFilename = nameWithoutExt + "_" + System.currentTimeMillis() + ext; + + File destFile = new File(uploadDir, savedFilename).getAbsoluteFile(); + file.transferTo(destFile); + + fileWebUrl = "/gcc_manpower_uploads/" + savedFilename; + } + + boolean success = appUserService.editVendorWorkOrder( + workOrderId, + contractorName, + fileNo, + subject, + issueDate, + endDate, + totalEmployees, + fileWebUrl, + usrName); + + if (success) { + response.put("success", true); + response.put("message", "Work Order updated successfully!"); + } else { + response.put("success", false); + response.put("error", "Failed to update work order."); + } + } catch (Exception e) { + response.put("success", false); + response.put("error", "Error: " + e.getMessage()); + } + + return response; + } + @PostMapping("/api/employee/delete") @ResponseBody public Map deleteEmployee( diff --git a/src/main/java/com/gcc_manpower/gccadjustmentmanagement/controller/AdjustmentController.java b/src/main/java/com/gcc_manpower/gccadjustmentmanagement/controller/AdjustmentController.java index d91db3a..694341f 100644 --- a/src/main/java/com/gcc_manpower/gccadjustmentmanagement/controller/AdjustmentController.java +++ b/src/main/java/com/gcc_manpower/gccadjustmentmanagement/controller/AdjustmentController.java @@ -2,6 +2,7 @@ package com.gcc_manpower.gccadjustmentmanagement.controller; import java.io.File; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -63,6 +64,24 @@ public class AdjustmentController { return "gccadjustmentmanagement/dashboard"; } + @GetMapping("/details") + public String viewDetails(Model model, HttpSession session) { + String username = (String) session.getAttribute("adj_usrName"); + if (username == null) { + return "redirect:/gccadjustmentmanagement/login"; + } + + String usrRole = (String) session.getAttribute("adj_usrRole"); + boolean isAdmin = "ADMIN".equalsIgnoreCase(usrRole); + + model.addAttribute("isLoggedIn", true); + model.addAttribute("isAdmin", isAdmin); + model.addAttribute("usrName", username); + model.addAttribute("curPage", "gccadjustmentmanagement"); + + return "gccadjustmentmanagement/details"; + } + @GetMapping("/login") public String login(HttpSession session) { return "gccadjustmentmanagement/login"; @@ -120,7 +139,7 @@ public class AdjustmentController { @ResponseBody public List> getAdvanceTypes(HttpSession session) { if (session.getAttribute("adj_usrName") == null) { - return java.util.Collections.emptyList(); + return Collections.emptyList(); } return adjustmentService.getAdvanceTypes(); } @@ -129,16 +148,25 @@ public class AdjustmentController { @ResponseBody public List> getFundTypes(HttpSession session) { if (session.getAttribute("adj_usrName") == null) { - return java.util.Collections.emptyList(); + return Collections.emptyList(); } return adjustmentService.getFundTypes(); } + @GetMapping("/api/file-statuses") + @ResponseBody + public List> getFileStatuses(HttpSession session) { + if (session.getAttribute("adj_usrName") == null) { + return Collections.emptyList(); + } + return adjustmentService.getFileStatusList(); + } + @GetMapping("/api/list") @ResponseBody public List> getFilesList(HttpSession session) { if (session.getAttribute("adj_usrName") == null) { - return java.util.Collections.emptyList(); + return Collections.emptyList(); } return adjustmentService.getAllFiles(); } @@ -147,11 +175,38 @@ public class AdjustmentController { @ResponseBody public List> getFilesListIncludingDeleted(HttpSession session) { if (session.getAttribute("adj_usrName") == null) { - return java.util.Collections.emptyList(); + return Collections.emptyList(); } return adjustmentService.getAllFilesIncludingDeleted(); } + @GetMapping("/api/pending/fi-available") + @ResponseBody + public List> getPendingFIAvailable(HttpSession session) { + if (session.getAttribute("adj_usrName") == null) { + return Collections.emptyList(); + } + return adjustmentService.getPendingFinalInvoiceAvailableFiles(); + } + + @GetMapping("/api/pending/fi-not-available") + @ResponseBody + public List> getPendingFINotAvailable(HttpSession session) { + if (session.getAttribute("adj_usrName") == null) { + return Collections.emptyList(); + } + return adjustmentService.getPendingFinalInvoiceNotAvailableFiles(); + } + + @GetMapping("/api/pending/ready-to-close") + @ResponseBody + public List> getReadyToClose(HttpSession session) { + if (session.getAttribute("adj_usrName") == null) { + return Collections.emptyList(); + } + return adjustmentService.getReadyToCloseFiles(); + } + @PostMapping("/api/save") @ResponseBody public Map saveAdjustment( @@ -189,6 +244,7 @@ public class AdjustmentController { @RequestParam(value = "ejvFile", required = false) MultipartFile ejvFile, @RequestParam(value = "asFile", required = false) MultipartFile asFile, @RequestParam(value = "asFinalFile", required = false) MultipartFile asFinalFile, + @RequestParam(value = "file_status_id", required = false) Integer fileStatusId, HttpSession session) { Map response = new HashMap<>(); @@ -266,6 +322,7 @@ public class AdjustmentController { data.put("file_available_status", fileAvailableStatus); data.put("rtgs_date", rtgsDate); data.put("dc_completed_date", dcCompletedDate); + data.put("file_status_id", fileStatusId); // Paths data.put("file_path", filePath); diff --git a/src/main/java/com/gcc_manpower/gccadjustmentmanagement/service/AdjustmentService.java b/src/main/java/com/gcc_manpower/gccadjustmentmanagement/service/AdjustmentService.java index 05b94ae..e0c6a00 100644 --- a/src/main/java/com/gcc_manpower/gccadjustmentmanagement/service/AdjustmentService.java +++ b/src/main/java/com/gcc_manpower/gccadjustmentmanagement/service/AdjustmentService.java @@ -42,15 +42,31 @@ public class AdjustmentService { } } + public List> getFileStatusList() { + String sql = "SELECT id, status_name FROM file_status_list WHERE is_active = 1 AND is_delete = 0 ORDER BY CAST(order_by AS UNSIGNED) ASC, id ASC"; + try { + return jdbcTemplate.queryForList(sql); + } catch (Exception e) { + System.err.println("Error fetching file status list: " + e.getMessage()); + return new ArrayList<>(); + } + } + public List> getAllFiles() { String sql = "SELECT a.*, " + "adv.adv_type AS resolved_adv_type, " + "f.fund_type AS resolved_fund_type, " + - "u.usr_name AS updated_by_name " + + "u.usr_name AS updated_by_name, " + + "fs.status_name AS resolved_file_status " + "FROM adjustment_file_details a " + - "LEFT JOIN advance_type_list adv ON TRIM(a.adv_type_id) REGEXP '^[0-9]+$' AND adv.id = CAST(TRIM(a.adv_type_id) AS UNSIGNED) " + - "LEFT JOIN fund_type_list f ON TRIM(a.fund_type_id) REGEXP '^[0-9]+$' AND f.id = CAST(TRIM(a.fund_type_id) AS UNSIGNED) " + - "LEFT JOIN gcc_manpower.app_user u ON (a.updated_by = CAST(u.usr_id AS CHAR) OR a.updated_by = u.usr_name) " + + "LEFT JOIN advance_type_list adv ON TRIM(a.adv_type_id) REGEXP '^[0-9]+$' AND adv.id = CAST(TRIM(a.adv_type_id) AS UNSIGNED) " + + + "LEFT JOIN fund_type_list f ON TRIM(a.fund_type_id) REGEXP '^[0-9]+$' AND f.id = CAST(TRIM(a.fund_type_id) AS UNSIGNED) " + + + "LEFT JOIN file_status_list fs ON TRIM(a.file_status_id) REGEXP '^[0-9]+$' AND fs.id = CAST(TRIM(a.file_status_id) AS UNSIGNED) " + + + "LEFT JOIN gcc_manpower.app_user u ON (a.updated_by = CAST(u.usr_id AS CHAR) OR a.updated_by = u.usr_name) " + + "WHERE a.is_active = 1 AND a.is_delete = 0 " + "ORDER BY a.updated_date DESC, a.id DESC"; try { @@ -65,11 +81,17 @@ public class AdjustmentService { String sql = "SELECT a.*, " + "adv.adv_type AS resolved_adv_type, " + "f.fund_type AS resolved_fund_type, " + - "u.usr_name AS updated_by_name " + + "u.usr_name AS updated_by_name, " + + "fs.status_name AS resolved_file_status " + "FROM adjustment_file_details a " + - "LEFT JOIN advance_type_list adv ON TRIM(a.adv_type_id) REGEXP '^[0-9]+$' AND adv.id = CAST(TRIM(a.adv_type_id) AS UNSIGNED) " + - "LEFT JOIN fund_type_list f ON TRIM(a.fund_type_id) REGEXP '^[0-9]+$' AND f.id = CAST(TRIM(a.fund_type_id) AS UNSIGNED) " + - "LEFT JOIN gcc_manpower.app_user u ON (a.updated_by = CAST(u.usr_id AS CHAR) OR a.updated_by = u.usr_name) " + + "LEFT JOIN advance_type_list adv ON TRIM(a.adv_type_id) REGEXP '^[0-9]+$' AND adv.id = CAST(TRIM(a.adv_type_id) AS UNSIGNED) " + + + "LEFT JOIN fund_type_list f ON TRIM(a.fund_type_id) REGEXP '^[0-9]+$' AND f.id = CAST(TRIM(a.fund_type_id) AS UNSIGNED) " + + + "LEFT JOIN file_status_list fs ON TRIM(a.file_status_id) REGEXP '^[0-9]+$' AND fs.id = CAST(TRIM(a.file_status_id) AS UNSIGNED) " + + + "LEFT JOIN gcc_manpower.app_user u ON (a.updated_by = CAST(u.usr_id AS CHAR) OR a.updated_by = u.usr_name) " + + "ORDER BY a.updated_date DESC, a.id DESC"; try { return jdbcTemplate.queryForList(sql); @@ -79,6 +101,104 @@ public class AdjustmentService { } } + public List> getPendingFinalInvoiceAvailableFiles() { + String sql = "SELECT a.*, " + + "adv.adv_type AS resolved_adv_type, " + + "f.fund_type AS resolved_fund_type, " + + "u.usr_name AS updated_by_name, " + + "fs.status_name AS resolved_file_status " + + "FROM adjustment_file_details a " + + "LEFT JOIN advance_type_list adv ON TRIM(a.adv_type_id) REGEXP '^[0-9]+$' AND adv.id = CAST(TRIM(a.adv_type_id) AS UNSIGNED) " + + + "LEFT JOIN fund_type_list f ON TRIM(a.fund_type_id) REGEXP '^[0-9]+$' AND f.id = CAST(TRIM(a.fund_type_id) AS UNSIGNED) " + + + "LEFT JOIN file_status_list fs ON TRIM(a.file_status_id) REGEXP '^[0-9]+$' AND fs.id = CAST(TRIM(a.file_status_id) AS UNSIGNED) " + + + "LEFT JOIN gcc_manpower.app_user u ON (a.updated_by = CAST(u.usr_id AS CHAR) OR a.updated_by = u.usr_name) " + + + "WHERE a.is_active = 1 AND a.is_delete = 0 " + + "AND NOT ((a.ejv_num IS NOT NULL AND TRIM(a.ejv_num) != '' AND TRIM(a.ejv_num) != '-') " + + " OR (a.ejv_num_file_path IS NOT NULL AND TRIM(a.ejv_num_file_path) != '' AND TRIM(a.ejv_num_file_path) != '-')) " + + + "AND (a.fi_file_path IS NOT NULL AND TRIM(a.fi_file_path) != '' AND TRIM(a.fi_file_path) != '-') " + + "AND (a.fi_amt IS NOT NULL AND TRIM(a.fi_amt) != '' AND TRIM(a.fi_amt) != '-') " + + "AND a.fi_file_gen_date IS NOT NULL " + + "ORDER BY a.updated_date DESC, a.id DESC"; + try { + return jdbcTemplate.queryForList(sql); + } catch (Exception e) { + System.err.println("Error fetching pending final invoice available files: " + e.getMessage()); + return new ArrayList<>(); + } + } + + public List> getPendingFinalInvoiceNotAvailableFiles() { + String sql = "SELECT a.*, " + + "adv.adv_type AS resolved_adv_type, " + + "f.fund_type AS resolved_fund_type, " + + "u.usr_name AS updated_by_name, " + + "fs.status_name AS resolved_file_status " + + "FROM adjustment_file_details a " + + "LEFT JOIN advance_type_list adv ON TRIM(a.adv_type_id) REGEXP '^[0-9]+$' AND adv.id = CAST(TRIM(a.adv_type_id) AS UNSIGNED) " + + + "LEFT JOIN fund_type_list f ON TRIM(a.fund_type_id) REGEXP '^[0-9]+$' AND f.id = CAST(TRIM(a.fund_type_id) AS UNSIGNED) " + + + "LEFT JOIN file_status_list fs ON TRIM(a.file_status_id) REGEXP '^[0-9]+$' AND fs.id = CAST(TRIM(a.file_status_id) AS UNSIGNED) " + + + "LEFT JOIN gcc_manpower.app_user u ON (a.updated_by = CAST(u.usr_id AS CHAR) OR a.updated_by = u.usr_name) " + + + "WHERE a.is_active = 1 AND a.is_delete = 0 " + + "AND NOT ((a.ejv_num IS NOT NULL AND TRIM(a.ejv_num) != '' AND TRIM(a.ejv_num) != '-') " + + " OR (a.ejv_num_file_path IS NOT NULL AND TRIM(a.ejv_num_file_path) != '' AND TRIM(a.ejv_num_file_path) != '-')) " + + + "AND NOT (" + + " (a.fi_file_path IS NOT NULL AND TRIM(a.fi_file_path) != '' AND TRIM(a.fi_file_path) != '-') " + + " AND (a.fi_amt IS NOT NULL AND TRIM(a.fi_amt) != '' AND TRIM(a.fi_amt) != '-') " + + " AND a.fi_file_gen_date IS NOT NULL" + + ") " + + "ORDER BY a.updated_date DESC, a.id DESC"; + try { + return jdbcTemplate.queryForList(sql); + } catch (Exception e) { + System.err.println("Error fetching pending final invoice not available files: " + e.getMessage()); + return new ArrayList<>(); + } + } + + public List> getReadyToCloseFiles() { + String sql = "SELECT a.*, " + + "adv.adv_type AS resolved_adv_type, " + + "f.fund_type AS resolved_fund_type, " + + "u.usr_name AS updated_by_name, " + + "fs.status_name AS resolved_file_status " + + "FROM adjustment_file_details a " + + "LEFT JOIN advance_type_list adv ON TRIM(a.adv_type_id) REGEXP '^[0-9]+$' AND adv.id = CAST(TRIM(a.adv_type_id) AS UNSIGNED) " + + + "LEFT JOIN fund_type_list f ON TRIM(a.fund_type_id) REGEXP '^[0-9]+$' AND f.id = CAST(TRIM(a.fund_type_id) AS UNSIGNED) " + + + "LEFT JOIN file_status_list fs ON TRIM(a.file_status_id) REGEXP '^[0-9]+$' AND fs.id = CAST(TRIM(a.file_status_id) AS UNSIGNED) " + + + "LEFT JOIN gcc_manpower.app_user u ON (a.updated_by = CAST(u.usr_id AS CHAR) OR a.updated_by = u.usr_name) " + + + "WHERE a.is_active = 1 AND a.is_delete = 0 " + + "AND NOT ((a.ejv_num IS NOT NULL AND TRIM(a.ejv_num) != '' AND TRIM(a.ejv_num) != '-') " + + " OR (a.ejv_num_file_path IS NOT NULL AND TRIM(a.ejv_num_file_path) != '' AND TRIM(a.ejv_num_file_path) != '-')) " + + + "AND (a.fi_file_path IS NOT NULL AND TRIM(a.fi_file_path) != '' AND TRIM(a.fi_file_path) != '-') " + + "AND (a.fi_amt IS NOT NULL AND TRIM(a.fi_amt) != '' AND TRIM(a.fi_amt) != '-') " + + "AND a.fi_file_gen_date IS NOT NULL " + + "AND (a.sr_filepath IS NOT NULL AND TRIM(a.sr_filepath) != '' AND TRIM(a.sr_filepath) != '-') " + + "AND (a.dc_file_path IS NOT NULL AND TRIM(a.dc_file_path) != '' AND TRIM(a.dc_file_path) != '-') " + + "AND a.dc_completed_date IS NOT NULL " + + "ORDER BY a.updated_date DESC, a.id DESC"; + try { + return jdbcTemplate.queryForList(sql); + } catch (Exception e) { + System.err.println("Error fetching ready to close files: " + e.getMessage()); + return new ArrayList<>(); + } + } + public Map getAdjustmentFileById(int id) { String sql = "SELECT * FROM adjustment_file_details WHERE id = ? AND is_active = 1 AND is_delete = 0"; try { @@ -102,7 +222,7 @@ public class AdjustmentService { "file_remark = ?, fin_year = ?, subject = ?, ir_file_path = ?, pi_amt = ?, pi_file_gen_date = ?, " + "pi_file_path = ?, po_file_path = ?, rtgs_file_path = ?, sr_filepath = ?, tc_file_gen_date = ?, " + "tc_file_path = ?, vend_name = ?, adv_type_id = ?, fund_type_id = ?, ac_code = ?, " + - "file_available_status = ?, dc_completed_date = ?, rtgs_date = ?, updated_date = ?, updated_by = ? WHERE id = ?"; + "file_available_status = ?, dc_completed_date = ?, rtgs_date = ?, file_status_id = ?, updated_date = ?, updated_by = ? WHERE id = ?"; try { int rows = jdbcTemplate.update(sql, parseDate(data.get("as_file_gen_date")), @@ -138,6 +258,7 @@ public class AdjustmentService { data.get("file_available_status"), parseDate(data.get("dc_completed_date")), parseDate(data.get("rtgs_date")), + parseInteger(data.get("file_status_id")), now, username, id); @@ -156,8 +277,9 @@ public class AdjustmentService { "file_remark, fin_year, subject, ir_file_path, pi_amt, pi_file_gen_date, " + "pi_file_path, po_file_path, rtgs_file_path, sr_filepath, tc_file_gen_date, " + "tc_file_path, vend_name, adv_type_id, fund_type_id, ac_code, file_available_status, " + - "dc_completed_date, rtgs_date, cdate, updated_date, updated_by, is_active, is_delete) VALUES " + - "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, 0)"; + "dc_completed_date, rtgs_date, file_status_id, cdate, updated_date, updated_by, is_active, is_delete) VALUES " + + + "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, 0)"; try { int rows = jdbcTemplate.update(sql, parseDate(data.get("as_file_gen_date")), @@ -193,6 +315,7 @@ public class AdjustmentService { data.get("file_available_status"), parseDate(data.get("dc_completed_date")), parseDate(data.get("rtgs_date")), + parseInteger(data.get("file_status_id")), now, now, username); @@ -253,4 +376,15 @@ public class AdjustmentService { return null; } } + + private Integer parseInteger(Object val) { + if (val == null || String.valueOf(val).trim().isEmpty() || String.valueOf(val).trim().equals("null")) { + return null; + } + try { + return Integer.parseInt(String.valueOf(val).trim()); + } catch (Exception e) { + return null; + } + } } diff --git a/src/main/java/com/gcc_manpower/service/AppUserService.java b/src/main/java/com/gcc_manpower/service/AppUserService.java index cbcaf06..93fd44b 100644 --- a/src/main/java/com/gcc_manpower/service/AppUserService.java +++ b/src/main/java/com/gcc_manpower/service/AppUserService.java @@ -134,7 +134,10 @@ public class AppUserService { } public List> getVendorDetailsWithCounts() { - String sql = "SELECT id, vendor_name, description, total_employees, orderby, cdate, isactive, isdelete, " + + String sql = "SELECT id, vendor_name, description, " + + "(SELECT COALESCE(SUM(CAST(tender_manpower_designation_wise AS SIGNED)), 0) FROM employee_workorder_details WHERE vid = CAST(v.id AS CHAR) AND isactive = 1 AND isdelete = 0) AS total_employees, " + + + "orderby, cdate, isactive, isdelete, " + "(SELECT COUNT(*) FROM employee_details e LEFT JOIN user_type_details ut ON (e.user_type = CAST(ut.id AS CHAR) OR e.user_type = ut.usertype) WHERE (e.vendor_id = CAST(v.id AS CHAR) OR e.vendor_id = v.vendor_name) AND (e.user_type != '3' AND (ut.usertype IS NULL OR ut.usertype != 'Standby Employees')) AND e.isactive = 1 AND e.isdelete = 0) AS actual_employee_count, " + "(SELECT COUNT(*) FROM employee_details e LEFT JOIN user_type_details ut ON (e.user_type = CAST(ut.id AS CHAR) OR e.user_type = ut.usertype) WHERE (e.vendor_id = CAST(v.id AS CHAR) OR e.vendor_id = v.vendor_name) AND (e.user_type = '3' OR ut.usertype = 'Standby Employees') AND e.isactive = 1 AND e.isdelete = 0) AS standby_employee_count " @@ -159,7 +162,7 @@ public class AppUserService { } public int getOverallTenderCount() { - String sql = "SELECT SUM(total_employees) FROM vendor_details WHERE isactive = 1 AND isdelete = 0"; + String sql = "SELECT COALESCE(SUM(CAST(tender_manpower_designation_wise AS SIGNED)), 0) FROM employee_workorder_details WHERE isactive = 1 AND isdelete = 0"; try { Integer sum = jdbcManpowerTemplate.queryForObject(sql, Integer.class); return sum != null ? sum : 0; @@ -678,32 +681,91 @@ public class AppUserService { } } - public boolean updateVendorTotalEmployees(String vendorId, int addedEmployees) { - String selectSql = "SELECT total_employees FROM vendor_details WHERE id = ?"; + public boolean editVendorWorkOrder(String id, String contractorName, String fileNo, String subject, + String issueDate, String endDate, String totalEmployees, String filePath, String updatedByUsername) { try { - List> rows = jdbcManpowerTemplate.queryForList(selectSql, vendorId); - if (rows == null || rows.isEmpty()) { + // Fetch existing record + String selectSql = "SELECT * FROM employee_workorder_details WHERE id = ? AND isdelete = 0"; + List> list = jdbcManpowerTemplate.queryForList(selectSql, id); + if (list == null || list.isEmpty()) { return false; } - Object rawTotal = rows.get(0).get("total_employees"); - String currentTotalStr = rawTotal != null ? String.valueOf(rawTotal) : "0"; - int currentTotal = 0; - if (currentTotalStr != null) { - try { - currentTotal = Integer.parseInt(currentTotalStr.trim()); - } catch (NumberFormatException ignored) { - } + Map existing = list.get(0); + + // Use existing values if the parameter is null/empty + String finalContractorName = (contractorName != null) ? contractorName + : (String) existing.get("contract_name"); + String finalFileNo = (fileNo != null) ? fileNo : (String) existing.get("File_no"); + String finalSubject = (subject != null) ? subject : (String) existing.get("subject"); + String finalIssueDate = (issueDate != null && !issueDate.isEmpty()) ? issueDate + : String.valueOf(existing.get("work_order_issue_date")); + String finalEndDate = (endDate != null && !endDate.isEmpty()) ? endDate + : String.valueOf(existing.get("work_order_end_date")); + String finalTotalEmployees = (totalEmployees != null) ? totalEmployees + : (String) existing.get("tender_manpower_designation_wise"); + String finalFilePath = (filePath != null && !filePath.isEmpty()) ? filePath + : (String) existing.get("file_path"); + + String sql = "UPDATE employee_workorder_details SET " + + "designation = ?, " + + "tender_manpower_designation_wise = ?, " + + "contract_name = ?, " + + "File_no = ?, " + + "subject = ?, " + + "work_order_issue_date = ?, " + + "work_order_end_date = ?, " + + "file_path = ?, " + + "updated_at = NOW(), " + + "updated_by = ? " + + "WHERE id = ? AND isdelete = 0"; + + int rows = jdbcManpowerTemplate.update(sql, + finalSubject, // designation + finalTotalEmployees, // tender_manpower_designation_wise + finalContractorName, // contract_name + finalFileNo, // File_no + finalSubject, // subject + (finalIssueDate != null && !"null".equals(finalIssueDate)) ? finalIssueDate : null, // work_order_issue_date + (finalEndDate != null && !"null".equals(finalEndDate)) ? finalEndDate : null, // work_order_end_date + finalFilePath, // file_path + getUserIdByName(updatedByUsername), // updated_by + id); + + if (rows > 0) { + String vendorId = String.valueOf(existing.get("vid")); + syncVendorTotalEmployees(vendorId); + recalculateDesignationManpower(id, vendorId); + return true; } - int newTotal = currentTotal + addedEmployees; - String updateSql = "UPDATE vendor_details SET total_employees = ? WHERE id = ?"; - int updateRows = jdbcManpowerTemplate.update(updateSql, String.valueOf(newTotal), vendorId); - return updateRows > 0; + return false; } catch (Exception e) { - System.err.println("Error updating total employees for vendor ID " + vendorId + ": " + e.getMessage()); + System.err.println("Error editing work order: " + e.getMessage()); + e.printStackTrace(); return false; } } + public void syncVendorTotalEmployees(String vendorId) { + if (vendorId == null || vendorId.trim().isEmpty()) { + return; + } + try { + String sumSql = "SELECT SUM(CAST(tender_manpower_designation_wise AS SIGNED)) FROM employee_workorder_details WHERE vid = ? AND isactive = 1 AND isdelete = 0"; + Integer sum = jdbcManpowerTemplate.queryForObject(sumSql, Integer.class, vendorId); + int total = (sum != null) ? sum : 0; + + String updateSql = "UPDATE vendor_details SET total_employees = ? WHERE id = ?"; + jdbcManpowerTemplate.update(updateSql, String.valueOf(total), vendorId); + } catch (Exception e) { + System.err.println("Error syncing total employees for vendor ID " + vendorId + ": " + e.getMessage()); + } + } + + public boolean updateVendorTotalEmployees(String vendorId, int addedEmployees) { + syncVendorTotalEmployees(vendorId); + return true; + } + public void recalculateDesignationManpower(String designationIdOrName, String vendorId) { if (designationIdOrName == null || designationIdOrName.trim().isEmpty() || vendorId == null || vendorId.trim().isEmpty()) { diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties index aa7b40b..e47e476 100644 --- a/src/main/resources/application-local.properties +++ b/src/main/resources/application-local.properties @@ -31,9 +31,9 @@ logging.level.org.hibernate.orm.jdbc.bind=TRACE # Spring JDBC / JdbcTemplate Logging # =============================== # Log queries executed by JdbcTemplate -# logging.level.org.springframework.jdbc.core.JdbcTemplate=DEBUG +logging.level.org.springframework.jdbc.core.JdbcTemplate=DEBUG # # Log values bound as placeholders in JdbcTemplate queries -# logging.level.org.springframework.jdbc.core.StatementCreatorUtils=TRACE +logging.level.org.springframework.jdbc.core.StatementCreatorUtils=TRACE logging.level.org.springframework.jdbc.core=ERROR # Production context path diff --git a/src/main/resources/templates/gccadjustmentmanagement/dashboard.html b/src/main/resources/templates/gccadjustmentmanagement/dashboard.html index 4d2f336..0c3c203 100644 --- a/src/main/resources/templates/gccadjustmentmanagement/dashboard.html +++ b/src/main/resources/templates/gccadjustmentmanagement/dashboard.html @@ -678,6 +678,7 @@ } .pagination .page-item.active .page-link { + background-color: var(--primary) !important; border-color: var(--primary) !important; color: #ffffff !important; @@ -702,6 +703,23 @@ font-size: 0.88rem !important; } + @media (max-width: 1574px) { + .header { + flex-wrap: wrap; + justify-content: space-between; + gap: 15px; + } + + .header-title { + position: static; + transform: none; + width: 100%; + order: 3; + margin: 10px 0 0 0; + text-align: center; + } + } + /* Mobile and Tablet Responsiveness */ @media (max-width: 991px) { .header { @@ -851,6 +869,18 @@ gap: 15px !important; } } + + /* Clickable cells and styling for Reason for Pending Table */ + .pending-reason-table td.clickable-cell { + cursor: pointer; + transition: background-color 0.2s ease, color 0.2s ease; + } + + .pending-reason-table td.clickable-cell:hover { + background-color: var(--primary-light) !important; + color: var(--primary) !important; + font-weight: 700; + } @@ -916,17 +946,6 @@ -
- - - - -
@@ -947,26 +966,88 @@ Reset
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ + +
+ + +
+
+ +
+
+ Reason for Pending (No. of + Files) by Category +
+
+ +
+
+ -
+