Browse Source

changes added in manpower project and adjustment management project api's and service controller, pages

master
yoganandhank 2 months ago
parent
commit
486bde1c54
  1. 89
      src/main/java/com/gcc_manpower/controller/HomeController.java
  2. 65
      src/main/java/com/gcc_manpower/gccadjustmentmanagement/controller/AdjustmentController.java
  3. 156
      src/main/java/com/gcc_manpower/gccadjustmentmanagement/service/AdjustmentService.java
  4. 98
      src/main/java/com/gcc_manpower/service/AppUserService.java
  5. 4
      src/main/resources/application-local.properties
  6. 996
      src/main/resources/templates/gccadjustmentmanagement/dashboard.html
  7. 1824
      src/main/resources/templates/gccadjustmentmanagement/details.html
  8. 2
      src/main/resources/templates/gccadjustmentmanagement/login.html
  9. 6
      src/main/resources/templates/gccservicepaymenttracker/details.html
  10. 290
      src/main/resources/templates/home/home.html

89
src/main/java/com/gcc_manpower/controller/HomeController.java

@ -471,6 +471,95 @@ public class HomeController {
return response; return response;
} }
@PostMapping("/api/vendor/edit-work-order")
@ResponseBody
public Map<String, Object> 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<String, Object> 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") @PostMapping("/api/employee/delete")
@ResponseBody @ResponseBody
public Map<String, Object> deleteEmployee( public Map<String, Object> deleteEmployee(

65
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.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -63,6 +64,24 @@ public class AdjustmentController {
return "gccadjustmentmanagement/dashboard"; 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") @GetMapping("/login")
public String login(HttpSession session) { public String login(HttpSession session) {
return "gccadjustmentmanagement/login"; return "gccadjustmentmanagement/login";
@ -120,7 +139,7 @@ public class AdjustmentController {
@ResponseBody @ResponseBody
public List<Map<String, Object>> getAdvanceTypes(HttpSession session) { public List<Map<String, Object>> getAdvanceTypes(HttpSession session) {
if (session.getAttribute("adj_usrName") == null) { if (session.getAttribute("adj_usrName") == null) {
return java.util.Collections.emptyList();
return Collections.emptyList();
} }
return adjustmentService.getAdvanceTypes(); return adjustmentService.getAdvanceTypes();
} }
@ -129,16 +148,25 @@ public class AdjustmentController {
@ResponseBody @ResponseBody
public List<Map<String, Object>> getFundTypes(HttpSession session) { public List<Map<String, Object>> getFundTypes(HttpSession session) {
if (session.getAttribute("adj_usrName") == null) { if (session.getAttribute("adj_usrName") == null) {
return java.util.Collections.emptyList();
return Collections.emptyList();
} }
return adjustmentService.getFundTypes(); return adjustmentService.getFundTypes();
} }
@GetMapping("/api/file-statuses")
@ResponseBody
public List<Map<String, Object>> getFileStatuses(HttpSession session) {
if (session.getAttribute("adj_usrName") == null) {
return Collections.emptyList();
}
return adjustmentService.getFileStatusList();
}
@GetMapping("/api/list") @GetMapping("/api/list")
@ResponseBody @ResponseBody
public List<Map<String, Object>> getFilesList(HttpSession session) { public List<Map<String, Object>> getFilesList(HttpSession session) {
if (session.getAttribute("adj_usrName") == null) { if (session.getAttribute("adj_usrName") == null) {
return java.util.Collections.emptyList();
return Collections.emptyList();
} }
return adjustmentService.getAllFiles(); return adjustmentService.getAllFiles();
} }
@ -147,11 +175,38 @@ public class AdjustmentController {
@ResponseBody @ResponseBody
public List<Map<String, Object>> getFilesListIncludingDeleted(HttpSession session) { public List<Map<String, Object>> getFilesListIncludingDeleted(HttpSession session) {
if (session.getAttribute("adj_usrName") == null) { if (session.getAttribute("adj_usrName") == null) {
return java.util.Collections.emptyList();
return Collections.emptyList();
} }
return adjustmentService.getAllFilesIncludingDeleted(); return adjustmentService.getAllFilesIncludingDeleted();
} }
@GetMapping("/api/pending/fi-available")
@ResponseBody
public List<Map<String, Object>> getPendingFIAvailable(HttpSession session) {
if (session.getAttribute("adj_usrName") == null) {
return Collections.emptyList();
}
return adjustmentService.getPendingFinalInvoiceAvailableFiles();
}
@GetMapping("/api/pending/fi-not-available")
@ResponseBody
public List<Map<String, Object>> getPendingFINotAvailable(HttpSession session) {
if (session.getAttribute("adj_usrName") == null) {
return Collections.emptyList();
}
return adjustmentService.getPendingFinalInvoiceNotAvailableFiles();
}
@GetMapping("/api/pending/ready-to-close")
@ResponseBody
public List<Map<String, Object>> getReadyToClose(HttpSession session) {
if (session.getAttribute("adj_usrName") == null) {
return Collections.emptyList();
}
return adjustmentService.getReadyToCloseFiles();
}
@PostMapping("/api/save") @PostMapping("/api/save")
@ResponseBody @ResponseBody
public Map<String, Object> saveAdjustment( public Map<String, Object> saveAdjustment(
@ -189,6 +244,7 @@ public class AdjustmentController {
@RequestParam(value = "ejvFile", required = false) MultipartFile ejvFile, @RequestParam(value = "ejvFile", required = false) MultipartFile ejvFile,
@RequestParam(value = "asFile", required = false) MultipartFile asFile, @RequestParam(value = "asFile", required = false) MultipartFile asFile,
@RequestParam(value = "asFinalFile", required = false) MultipartFile asFinalFile, @RequestParam(value = "asFinalFile", required = false) MultipartFile asFinalFile,
@RequestParam(value = "file_status_id", required = false) Integer fileStatusId,
HttpSession session) { HttpSession session) {
Map<String, Object> response = new HashMap<>(); Map<String, Object> response = new HashMap<>();
@ -266,6 +322,7 @@ public class AdjustmentController {
data.put("file_available_status", fileAvailableStatus); data.put("file_available_status", fileAvailableStatus);
data.put("rtgs_date", rtgsDate); data.put("rtgs_date", rtgsDate);
data.put("dc_completed_date", dcCompletedDate); data.put("dc_completed_date", dcCompletedDate);
data.put("file_status_id", fileStatusId);
// Paths // Paths
data.put("file_path", filePath); data.put("file_path", filePath);

156
src/main/java/com/gcc_manpower/gccadjustmentmanagement/service/AdjustmentService.java

@ -42,15 +42,31 @@ public class AdjustmentService {
} }
} }
public List<Map<String, Object>> 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<Map<String, Object>> getAllFiles() { public List<Map<String, Object>> getAllFiles() {
String sql = "SELECT a.*, " + String sql = "SELECT a.*, " +
"adv.adv_type AS resolved_adv_type, " + "adv.adv_type AS resolved_adv_type, " +
"f.fund_type AS resolved_fund_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 " + "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 " + "WHERE a.is_active = 1 AND a.is_delete = 0 " +
"ORDER BY a.updated_date DESC, a.id DESC"; "ORDER BY a.updated_date DESC, a.id DESC";
try { try {
@ -65,11 +81,17 @@ public class AdjustmentService {
String sql = "SELECT a.*, " + String sql = "SELECT a.*, " +
"adv.adv_type AS resolved_adv_type, " + "adv.adv_type AS resolved_adv_type, " +
"f.fund_type AS resolved_fund_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 " + "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"; "ORDER BY a.updated_date DESC, a.id DESC";
try { try {
return jdbcTemplate.queryForList(sql); return jdbcTemplate.queryForList(sql);
@ -79,6 +101,104 @@ public class AdjustmentService {
} }
} }
public List<Map<String, Object>> 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<Map<String, Object>> 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<Map<String, Object>> 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<String, Object> getAdjustmentFileById(int id) { public Map<String, Object> getAdjustmentFileById(int id) {
String sql = "SELECT * FROM adjustment_file_details WHERE id = ? AND is_active = 1 AND is_delete = 0"; String sql = "SELECT * FROM adjustment_file_details WHERE id = ? AND is_active = 1 AND is_delete = 0";
try { try {
@ -102,7 +222,7 @@ public class AdjustmentService {
"file_remark = ?, fin_year = ?, subject = ?, ir_file_path = ?, pi_amt = ?, pi_file_gen_date = ?, " + "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 = ?, " + "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 = ?, " + "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 { try {
int rows = jdbcTemplate.update(sql, int rows = jdbcTemplate.update(sql,
parseDate(data.get("as_file_gen_date")), parseDate(data.get("as_file_gen_date")),
@ -138,6 +258,7 @@ public class AdjustmentService {
data.get("file_available_status"), data.get("file_available_status"),
parseDate(data.get("dc_completed_date")), parseDate(data.get("dc_completed_date")),
parseDate(data.get("rtgs_date")), parseDate(data.get("rtgs_date")),
parseInteger(data.get("file_status_id")),
now, now,
username, username,
id); id);
@ -156,8 +277,9 @@ public class AdjustmentService {
"file_remark, fin_year, subject, ir_file_path, pi_amt, pi_file_gen_date, " + "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, " + "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, " + "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 { try {
int rows = jdbcTemplate.update(sql, int rows = jdbcTemplate.update(sql,
parseDate(data.get("as_file_gen_date")), parseDate(data.get("as_file_gen_date")),
@ -193,6 +315,7 @@ public class AdjustmentService {
data.get("file_available_status"), data.get("file_available_status"),
parseDate(data.get("dc_completed_date")), parseDate(data.get("dc_completed_date")),
parseDate(data.get("rtgs_date")), parseDate(data.get("rtgs_date")),
parseInteger(data.get("file_status_id")),
now, now,
now, now,
username); username);
@ -253,4 +376,15 @@ public class AdjustmentService {
return null; 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;
}
}
} }

98
src/main/java/com/gcc_manpower/service/AppUserService.java

@ -134,7 +134,10 @@ public class AppUserService {
} }
public List<Map<String, Object>> getVendorDetailsWithCounts() { public List<Map<String, Object>> 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' 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 " "(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() { 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 { try {
Integer sum = jdbcManpowerTemplate.queryForObject(sql, Integer.class); Integer sum = jdbcManpowerTemplate.queryForObject(sql, Integer.class);
return sum != null ? sum : 0; return sum != null ? sum : 0;
@ -678,30 +681,89 @@ 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 { try {
List<Map<String, Object>> 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<Map<String, Object>> list = jdbcManpowerTemplate.queryForList(selectSql, id);
if (list == null || list.isEmpty()) {
return false; 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<String, Object> 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;
}
return false;
} catch (Exception e) {
System.err.println("Error editing work order: " + e.getMessage());
e.printStackTrace();
return false;
} }
} }
int newTotal = currentTotal + addedEmployees;
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 = ?"; String updateSql = "UPDATE vendor_details SET total_employees = ? WHERE id = ?";
int updateRows = jdbcManpowerTemplate.update(updateSql, String.valueOf(newTotal), vendorId);
return updateRows > 0;
jdbcManpowerTemplate.update(updateSql, String.valueOf(total), vendorId);
} catch (Exception e) { } catch (Exception e) {
System.err.println("Error updating total employees for vendor ID " + vendorId + ": " + e.getMessage());
return false;
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) { public void recalculateDesignationManpower(String designationIdOrName, String vendorId) {

4
src/main/resources/application-local.properties

@ -31,9 +31,9 @@ logging.level.org.hibernate.orm.jdbc.bind=TRACE
# Spring JDBC / JdbcTemplate Logging # Spring JDBC / JdbcTemplate Logging
# =============================== # ===============================
# Log queries executed by JdbcTemplate # 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 # # 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 logging.level.org.springframework.jdbc.core=ERROR
# Production context path # Production context path

996
src/main/resources/templates/gccadjustmentmanagement/dashboard.html
File diff suppressed because it is too large
View File

1824
src/main/resources/templates/gccadjustmentmanagement/details.html
File diff suppressed because it is too large
View File

2
src/main/resources/templates/gccadjustmentmanagement/login.html

@ -68,7 +68,7 @@
let usrName = data.usrName && data.usrName.length > 0 ? data.usrName : null; let usrName = data.usrName && data.usrName.length > 0 ? data.usrName : null;
if (usrName) { if (usrName) {
sessionStorage.setItem("adj_usrName", usrName); sessionStorage.setItem("adj_usrName", usrName);
console.log("Redirecting to:", contextPath + 'gccadjustmentmanagement/');
//console.log("Redirecting to:", contextPath + 'gccadjustmentmanagement/');
alert("Login Success"); alert("Login Success");
window.location.href = contextPath + 'gccadjustmentmanagement/'; window.location.href = contextPath + 'gccadjustmentmanagement/';
} else { } else {

6
src/main/resources/templates/gccservicepaymenttracker/details.html

@ -315,9 +315,13 @@
<span>GCC Service Payment Tracker - Details View</span> <span>GCC Service Payment Tracker - Details View</span>
</a> </a>
<div class="d-flex align-items-center gap-3"> <div class="d-flex align-items-center gap-3">
<a th:href="@{/gccservicepaymenttracker/dashboard}" class="btn-back d-flex align-items-center gap-2">
<!-- <a th:href="@{/gccservicepaymenttracker/dashboard}" class="btn-back d-flex align-items-center gap-2">
<i class="fa-solid fa-arrow-left"></i> Back to Dashboard
</a> -->
<a href="#" onclick="window.close(); return false;" class="btn-back d-flex align-items-center gap-2">
<i class="fa-solid fa-arrow-left"></i> Back to Dashboard <i class="fa-solid fa-arrow-left"></i> Back to Dashboard
</a> </a>
</div> </div>
</div> </div>
</nav> </nav>

290
src/main/resources/templates/home/home.html

@ -239,7 +239,8 @@
</div> </div>
<!-- Total Standby Count --> <!-- Total Standby Count -->
<div class="summary-card interactive" id="card-total-standby" onclick="fetchAndShowAllStandbyEmployees()">
<div class="summary-card interactive" id="card-total-standby"
onclick="fetchAndShowAllStandbyEmployees()">
<div class="summary-icon-container bg-summary-standby"> <div class="summary-icon-container bg-summary-standby">
<i class="fa-solid fa-user-gear"></i> <i class="fa-solid fa-user-gear"></i>
</div> </div>
@ -1173,6 +1174,110 @@
</div> </div>
</div> </div>
<!-- Edit Vendor / Work Order Modal -->
<div class="modal fade" id="editWorkOrderModal" tabindex="-1" aria-labelledby="editWorkOrderModalLabel"
aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content"
style="border-radius: 14px; border: none; box-shadow: 0 10px 40px rgba(0,0,0,0.2);">
<div class="modal-custom-header">
<h5 class="modal-custom-title" id="editWorkOrderModalLabel">
<i class="fa-solid fa-pen-to-square"></i> Edit Vendor / Work Order
</h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"
aria-label="Close"></button>
</div>
<div class="modal-body">
<form id="editWorkOrderForm" onsubmit="updateWorkOrder(event)">
<input type="hidden" id="edit-vo-id">
<div class="row g-3">
<!-- Contractor Name -->
<div class="col-md-6">
<label for="edit-vo-contractor-name"
class="form-label fw-semibold text-secondary">Contractor Name</label>
<input type="text" class="form-control w-100" id="edit-vo-contractor-name"
placeholder="Enter contractor name"
style="border-radius: 8px; text-transform: uppercase;">
</div>
<!-- File No -->
<div class="col-md-6">
<label for="edit-vo-file-no" class="form-label fw-semibold text-secondary">File
No</label>
<input type="text" class="form-control w-100" id="edit-vo-file-no"
placeholder="Enter file number"
style="border-radius: 8px; text-transform: uppercase;">
</div>
<!-- Subject -->
<div class="col-md-6">
<label for="edit-vo-subject"
class="form-label fw-semibold text-secondary">Subject</label>
<input type="text" class="form-control w-100" id="edit-vo-subject"
placeholder="Enter subject" style="border-radius: 8px;">
</div>
<!-- Total Employees Count -->
<div class="col-md-6">
<label for="edit-vo-total-employees" class="form-label fw-semibold text-secondary">Total
Employees Count</label>
<input type="number" class="form-control w-100" id="edit-vo-total-employees" min="1"
placeholder="Number of employees" style="border-radius: 8px;">
</div>
<!-- Work Order Issue Date -->
<div class="col-md-6">
<label for="edit-vo-issue-date" class="form-label fw-semibold text-secondary">Issue
Date</label>
<input type="date" class="form-control w-100" id="edit-vo-issue-date"
style="border-radius: 8px;" onchange="restrictEditEndDate()"
onclick="this.showPicker()">
</div>
<!-- Work Order End Date -->
<div class="col-md-6">
<label for="edit-vo-end-date" class="form-label fw-semibold text-secondary">End
Date</label>
<input type="date" class="form-control w-100" id="edit-vo-end-date"
style="border-radius: 8px;" onclick="this.showPicker()">
</div>
<!-- Current PDF Link & Upload New PDF -->
<div class="col-md-12">
<label class="form-label fw-semibold text-secondary">Work Order PDF</label>
<div class="d-flex align-items-center gap-3 p-2 bg-light rounded border mb-2"
id="edit-vo-current-file-container" style="display: none !important;">
<span class="text-secondary" style="font-size: 0.85rem;"><i
class="fa-solid fa-file-pdf text-danger fs-5 me-1"></i> Current File:</span>
<a id="edit-vo-current-file-link" href="#" target="_blank"
class="btn btn-sm btn-outline-primary px-3 py-1 fw-semibold"
style="font-size: 0.8rem; border-radius: 6px;">
<i class="fa-solid fa-eye"></i> View Current PDF
</a>
</div>
<div class="w-100">
<label for="edit-vo-file" class="form-label fw-semibold text-secondary"
style="font-size: 0.8rem; margin-bottom: 4px;">Upload New PDF (Leave empty to
keep existing)</label>
<input type="file" class="form-control w-100" id="edit-vo-file" accept=".pdf"
style="border-radius: 8px;">
</div>
</div>
</div>
<div class="d-flex justify-content-end gap-2 mt-4">
<button type="button" class="btn btn-secondary px-4" data-bs-dismiss="modal"
style="border-radius: 8px;">Cancel</button>
<button type="submit" class="btn btn-primary px-4"
style="background-color: #0f5c78; border-color: #0f5c78; border-radius: 8px;">
<i class="fa-solid fa-floppy-disk"></i> Update Work Order
</button>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- Delete Employee Modal --> <!-- Delete Employee Modal -->
<div class="modal fade" id="deleteEmployeeModal" tabindex="-1" aria-labelledby="deleteEmployeeModalLabel" <div class="modal fade" id="deleteEmployeeModal" tabindex="-1" aria-labelledby="deleteEmployeeModalLabel"
aria-hidden="true"> aria-hidden="true">
@ -1952,7 +2057,7 @@
if (totalContractedEl) totalContractedEl.textContent = totalContractedEl.getAttribute("data-init") || filteredTotalTender; if (totalContractedEl) totalContractedEl.textContent = totalContractedEl.getAttribute("data-init") || filteredTotalTender;
if (totalOnRollEl) totalOnRollEl.textContent = totalOnRollEl.getAttribute("data-init") || filteredTotalOnRoll; if (totalOnRollEl) totalOnRollEl.textContent = totalOnRollEl.getAttribute("data-init") || filteredTotalOnRoll;
if (totalVacantEl) { if (totalVacantEl) {
console.log("stat-total-vacant dynamic content updating to:", filteredTotalVacant);
//console.log("stat-total-vacant dynamic content updating to:", filteredTotalVacant);
totalVacantEl.textContent = filteredTotalVacant; totalVacantEl.textContent = filteredTotalVacant;
} }
} else { } else {
@ -1960,11 +2065,11 @@
if (totalContractedEl) totalContractedEl.textContent = filteredTotalTender; if (totalContractedEl) totalContractedEl.textContent = filteredTotalTender;
if (totalOnRollEl) totalOnRollEl.textContent = filteredTotalOnRoll; if (totalOnRollEl) totalOnRollEl.textContent = filteredTotalOnRoll;
if (totalVacantEl) { if (totalVacantEl) {
console.log("stat-total-vacant filtered content updating to:", filteredTotalVacant);
//console.log("stat-total-vacant filtered content updating to:", filteredTotalVacant);
totalVacantEl.textContent = filteredTotalVacant; totalVacantEl.textContent = filteredTotalVacant;
} }
} }
console.log("filterVendorCards finished. anyFilterActive:", anyFilterActive, "filteredTotalVacant:", filteredTotalVacant);
//console.log("filterVendorCards finished. anyFilterActive:", anyFilterActive, "filteredTotalVacant:", filteredTotalVacant);
} }
// Globals to store current modal state // Globals to store current modal state
@ -2453,6 +2558,10 @@
if (isAdmin) { if (isAdmin) {
actionCellHtml = ` actionCellHtml = `
<td class="text-center"> <td class="text-center">
<button class="btn btn-sm btn-outline-primary py-1 px-2 me-1" style="border-radius: 6px; font-size: 0.8rem;"
onclick="openEditWorkOrderModal('${des.id}', '${escapeHtml(des.contract_name || '').replace(/'/g, "\\'")}', '${escapeHtml(des.File_no || '').replace(/'/g, "\\'")}', '${escapeHtml(des.subject || '').replace(/'/g, "\\'")}', '${des.work_order_issue_date || ''}', '${des.work_order_end_date || ''}', ${des.tender_manpower_designation_wise || 0}, '${escapeHtml(des.file_path || '').replace(/'/g, "\\'")}')">
<i class="fa-solid fa-pen-to-square"></i> Edit
</button>
<button class="btn btn-sm btn-danger py-1 px-2" style="border-radius: 6px; font-size: 0.8rem;" onclick="deleteWorkOrder('${des.id}', '${escapeHtml(vendorName).replace(/'/g, "\\'")}')"> <button class="btn btn-sm btn-danger py-1 px-2" style="border-radius: 6px; font-size: 0.8rem;" onclick="deleteWorkOrder('${des.id}', '${escapeHtml(vendorName).replace(/'/g, "\\'")}')">
<i class="fa-solid fa-trash-can"></i> Delete <i class="fa-solid fa-trash-can"></i> Delete
</button> </button>
@ -3672,10 +3781,159 @@
} }
} }
// Enforce Date restrictions dynamically for Edit
function restrictEditEndDate() {
const issueDateVal = document.getElementById("edit-vo-issue-date").value;
const endDateInput = document.getElementById("edit-vo-end-date");
if (issueDateVal) {
endDateInput.min = issueDateVal;
if (endDateInput.value && endDateInput.value < issueDateVal) {
endDateInput.value = "";
}
} else {
endDateInput.removeAttribute("min");
}
}
let editWorkOrderModalObj = null;
function openEditWorkOrderModal(id, contractName, fileNo, subject, issueDate, endDate, tenderCount, filePath) {
// Pre-populate fields
document.getElementById("edit-vo-id").value = id;
document.getElementById("edit-vo-contractor-name").value = contractName;
document.getElementById("edit-vo-file-no").value = fileNo;
document.getElementById("edit-vo-subject").value = subject;
document.getElementById("edit-vo-issue-date").value = issueDate;
document.getElementById("edit-vo-end-date").value = endDate;
document.getElementById("edit-vo-total-employees").value = tenderCount;
// Clear file input
document.getElementById("edit-vo-file").value = "";
// Show current file details if exists
const currentFileContainer = document.getElementById("edit-vo-current-file-container");
const currentFileLink = document.getElementById("edit-vo-current-file-link");
if (filePath && filePath !== "-" && filePath.trim() !== "") {
let url = filePath;
if (contextPath && contextPath.endsWith('/') && url.startsWith('/')) {
url = contextPath + url.substring(1);
} else {
url = contextPath + url;
}
currentFileLink.href = url;
currentFileContainer.setAttribute("style", "display: flex !important;");
} else {
currentFileContainer.setAttribute("style", "display: none !important;");
}
// Close the current work orders list modal
const woModalEl = document.getElementById("modal-wo-table").closest(".modal");
if (woModalEl) {
const woModal = bootstrap.Modal.getInstance(woModalEl);
if (woModal) woModal.hide();
}
// Open the edit modal
if (!editWorkOrderModalObj) {
editWorkOrderModalObj = new bootstrap.Modal(document.getElementById("editWorkOrderModal"));
}
editWorkOrderModalObj.show();
}
function updateWorkOrder(event) {
event.preventDefault();
const id = document.getElementById("edit-vo-id").value;
const contractorName = document.getElementById("edit-vo-contractor-name").value.trim();
const fileNo = document.getElementById("edit-vo-file-no").value.trim();
const subject = document.getElementById("edit-vo-subject").value.trim();
const issueDate = document.getElementById("edit-vo-issue-date").value;
const endDate = document.getElementById("edit-vo-end-date").value;
const totalEmployees = document.getElementById("edit-vo-total-employees").value.trim();
const fileInput = document.getElementById("edit-vo-file");
const form = document.getElementById("editWorkOrderForm");
const prevAlert = form.querySelector(".alert");
if (prevAlert) prevAlert.remove();
// Validate dates
if (issueDate && endDate && endDate < issueDate) {
const alertHtml = `
<div class="alert alert-danger alert-dismissible fade show mt-3" role="alert">
<i class="fa-solid fa-triangle-exclamation"></i> <strong>Validation Error:</strong> End Date cannot be before Issue Date.
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
`;
form.insertAdjacentHTML("afterbegin", alertHtml);
return;
}
const formData = new FormData();
formData.append("id", id);
formData.append("contractorName", contractorName);
formData.append("fileNo", fileNo);
formData.append("subject", subject);
formData.append("issueDate", issueDate);
formData.append("endDate", endDate);
formData.append("totalEmployees", totalEmployees);
if (fileInput && fileInput.files.length > 0) {
formData.append("file", fileInput.files[0]);
}
//showLoadingOverlay("Updating work order details...");
fetch(contextPath + 'api/vendor/edit-work-order', {
method: 'POST',
body: formData
})
.then(res => res.json())
.then(data => {
hideLoadingOverlay();
if (data.success) {
const alertHtml = `
<div class="alert alert-success alert-dismissible fade show mt-3" role="alert">
<i class="fa-solid fa-circle-check"></i> <strong>Success!</strong> Work Order updated successfully.
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
`;
form.insertAdjacentHTML("afterbegin", alertHtml);
setTimeout(() => {
if (editWorkOrderModalObj) {
editWorkOrderModalObj.hide();
window.location.reload();
}
// window.location.reload();
showLoadingOverlay("Updating work order details...");
}, 1500);
} else {
const alertHtml = `
<div class="alert alert-danger alert-dismissible fade show mt-3" role="alert">
<i class="fa-solid fa-triangle-exclamation"></i> <strong>Error:</strong> ${data.error || 'Failed to update work order.'}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
`;
form.insertAdjacentHTML("afterbegin", alertHtml);
}
})
.catch(err => {
hideLoadingOverlay();
console.error("Error updating work order:", err);
const alertHtml = `
<div class="alert alert-danger alert-dismissible fade show mt-3" role="alert">
<i class="fa-solid fa-triangle-exclamation"></i> <strong>Error:</strong> A connection error occurred.
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
`;
form.insertAdjacentHTML("afterbegin", alertHtml);
});
}
// Setup uppercase handlers for Contractor Name and File No // Setup uppercase handlers for Contractor Name and File No
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
const contractorInput = document.getElementById("add-vo-contractor-name"); const contractorInput = document.getElementById("add-vo-contractor-name");
const fileNoInput = document.getElementById("add-vo-file-no"); const fileNoInput = document.getElementById("add-vo-file-no");
const editContractorInput = document.getElementById("edit-vo-contractor-name");
const editFileNoInput = document.getElementById("edit-vo-file-no");
if (contractorInput) { if (contractorInput) {
contractorInput.addEventListener("input", function () { contractorInput.addEventListener("input", function () {
@ -3687,6 +3945,16 @@
this.value = this.value.toUpperCase(); this.value = this.value.toUpperCase();
}); });
} }
if (editContractorInput) {
editContractorInput.addEventListener("input", function () {
this.value = this.value.toUpperCase();
});
}
if (editFileNoInput) {
editFileNoInput.addEventListener("input", function () {
this.value = this.value.toUpperCase();
});
}
}); });
// Save Vendor and Work Order form handler // Save Vendor and Work Order form handler
@ -5112,7 +5380,7 @@
function renderPositionHistoryTable(searchQuery = "") { function renderPositionHistoryTable(searchQuery = "") {
try { try {
console.log("renderPositionHistoryTable called with query:", searchQuery);
//console.log("renderPositionHistoryTable called with query:", searchQuery);
const vendorSelect = document.getElementById("history-modal-vendor-select"); const vendorSelect = document.getElementById("history-modal-vendor-select");
const workorderSelect = document.getElementById("history-modal-workorder-select"); const workorderSelect = document.getElementById("history-modal-workorder-select");
const tbody = document.getElementById("position-history-tbody"); const tbody = document.getElementById("position-history-tbody");
@ -5125,13 +5393,13 @@
const selectedVendorId = vendorSelect.value; const selectedVendorId = vendorSelect.value;
const selectedFileNo = workorderSelect.value; const selectedFileNo = workorderSelect.value;
console.log("Selected Vendor ID:", selectedVendorId, "Selected File No:", selectedFileNo);
//console.log("Selected Vendor ID:", selectedVendorId, "Selected File No:", selectedFileNo);
tbody.innerHTML = ""; tbody.innerHTML = "";
noHistoryEl.style.display = "none"; noHistoryEl.style.display = "none";
if (!selectedVendorId || !selectedFileNo) { if (!selectedVendorId || !selectedFileNo) {
console.log("Vendor or Work Order not selected. Rendering prompt.");
//console.log("Vendor or Work Order not selected. Rendering prompt.");
tbody.innerHTML = ` tbody.innerHTML = `
<tr> <tr>
<td colspan="6" class="text-center py-5 text-secondary"> <td colspan="6" class="text-center py-5 text-secondary">
@ -5145,7 +5413,7 @@
} }
const vendorObj = vendorDetailsData.find(v => String(v.id) === String(selectedVendorId)); const vendorObj = vendorDetailsData.find(v => String(v.id) === String(selectedVendorId));
console.log("Found vendor object:", vendorObj);
//console.log("Found vendor object:", vendorObj);
if (!vendorObj || !vendorObj.designationDetails) { if (!vendorObj || !vendorObj.designationDetails) {
console.warn("Vendor object or designationsDetails missing"); console.warn("Vendor object or designationsDetails missing");
return; return;
@ -5156,7 +5424,7 @@
const fNo = d.File_no || d.file_no; const fNo = d.File_no || d.file_no;
return fNo === selectedFileNo; return fNo === selectedFileNo;
}); });
console.log("Designations under selected work order:", designations);
//console.log("Designations under selected work order:", designations);
// If search query is present, filter designations list // If search query is present, filter designations list
const q = searchQuery.toLowerCase().trim(); const q = searchQuery.toLowerCase().trim();
@ -5165,7 +5433,7 @@
} }
if (designations.length === 0) { if (designations.length === 0) {
console.log("No designations found for selected criteria");
//console.log("No designations found for selected criteria");
noHistoryEl.style.display = "block"; noHistoryEl.style.display = "block";
filteredHistoryList = []; filteredHistoryList = [];
return; return;
@ -5192,7 +5460,7 @@
return empVendorMatches && empDesMatches && empWoMatches; return empVendorMatches && empDesMatches && empWoMatches;
}); });
console.log(`Designation "${desName}": found ${employees.length} employees`);
//console.log(`Designation "${desName}": found ${employees.length} employees`);
// Separate active and inactive/deleted // Separate active and inactive/deleted
const activeEmps = employees.filter(emp => !(emp.isdelete === true || emp.isactive === false || parseInt(emp.isdelete) === 1 || parseInt(emp.isactive) === 0)); const activeEmps = employees.filter(emp => !(emp.isdelete === true || emp.isactive === false || parseInt(emp.isdelete) === 1 || parseInt(emp.isactive) === 0));

Loading…
Cancel
Save