diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index 5291372..0000000 --- a/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,3 +0,0 @@ -wrapperVersion=3.3.4 -distributionType=only-script -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.15/apache-maven-3.9.15-bin.zip diff --git a/src/main/java/com/gcc_manpower/gccservicedocuments/controller/GccServiceDocumentsController.java b/src/main/java/com/gcc_manpower/gccservicedocuments/controller/GccServiceDocumentsController.java index 0cf9d44..c051ec8 100644 --- a/src/main/java/com/gcc_manpower/gccservicedocuments/controller/GccServiceDocumentsController.java +++ b/src/main/java/com/gcc_manpower/gccservicedocuments/controller/GccServiceDocumentsController.java @@ -261,6 +261,7 @@ public class GccServiceDocumentsController { public Map updateFile( @RequestParam("id") Long id, @RequestParam("title") String title, + @RequestParam("mainCategory") String mainCategory, @RequestParam("subCategory") String subCategory, @RequestParam("fileType") String fileType, @RequestParam(value = "file", required = false) MultipartFile file, @@ -274,7 +275,8 @@ public class GccServiceDocumentsController { return response; } - if (title == null || title.trim().isEmpty() || subCategory == null || subCategory.trim().isEmpty() + if (title == null || title.trim().isEmpty() || mainCategory == null || mainCategory.trim().isEmpty() + || subCategory == null || subCategory.trim().isEmpty() || fileType == null || fileType.trim().isEmpty()) { response.put("success", false); response.put("error", "Required fields cannot be empty."); @@ -318,7 +320,7 @@ public class GccServiceDocumentsController { fileWebUrl = "/gccservicedocuments/files/" + cleanCategory + "/" + savedFilename; } - boolean updated = documentService.updateDocument(id, title.trim(), subCategory.trim(), fileType.trim(), + boolean updated = documentService.updateDocument(id, title.trim(), mainCategory.trim(), subCategory.trim(), fileType.trim(), fileWebUrl, originalFilename); if (updated) { diff --git a/src/main/java/com/gcc_manpower/gccservicedocuments/service/GccServiceDocumentsService.java b/src/main/java/com/gcc_manpower/gccservicedocuments/service/GccServiceDocumentsService.java index 2415556..b24237d 100644 --- a/src/main/java/com/gcc_manpower/gccservicedocuments/service/GccServiceDocumentsService.java +++ b/src/main/java/com/gcc_manpower/gccservicedocuments/service/GccServiceDocumentsService.java @@ -226,7 +226,7 @@ public class GccServiceDocumentsService { return null; } - public boolean updateDocument(Long id, String title, String subCategory, String fileType, String filePath, + public boolean updateDocument(Long id, String title, String mainCategory, String subCategory, String fileType, String filePath, String originalFilename) { // Insert old record into history before update try { @@ -252,17 +252,10 @@ public class GccServiceDocumentsService { // Resolve subCategoryId and fileTypeId int subCategoryId = 0; - String findSubSql = "SELECT id FROM sub_category_list WHERE category_name = ? AND is_delete = 0 LIMIT 1"; try { - List ids = jdbcTemplate.queryForList(findSubSql, Integer.class, subCategory.trim()); - if (!ids.isEmpty()) { - subCategoryId = ids.get(0); - } else { - // Find old document's main category ID - String oldMainCatSql = "SELECT s.mid FROM documents_uploads d JOIN sub_category_list s ON d.category = s.id WHERE d.id = ?"; - List mids = jdbcTemplate.queryForList(oldMainCatSql, Integer.class, id); - int mid = mids.isEmpty() ? 1 : mids.get(0); - subCategoryId = getOrCreateSubCategory(subCategory, mid); + int mainCategoryId = getOrCreateMainCategory(mainCategory); + if (mainCategoryId != 0) { + subCategoryId = getOrCreateSubCategory(subCategory, mainCategoryId); } } catch (Exception e) { System.err.println("Error resolving subcategory: " + e.getMessage()); diff --git a/src/main/java/com/gcc_manpower/service/AppUserService.java b/src/main/java/com/gcc_manpower/service/AppUserService.java index e3198af..78ee16b 100644 --- a/src/main/java/com/gcc_manpower/service/AppUserService.java +++ b/src/main/java/com/gcc_manpower/service/AppUserService.java @@ -520,6 +520,7 @@ public class AppUserService { " h.email, " + " h.mobile, " + " h.updated_date, " + + " COALESCE(u.usr_name, h.updated_by) AS updated_by_name, " + " COALESCE(v.vendor_name, h.vendor_id) AS vendor_name, " + " COALESCE(ut.usertype, h.user_type) AS user_type, " + " COALESCE(des.designation, h.designation) AS designation, " + @@ -527,10 +528,9 @@ public class AppUserService { "FROM employee_details_update_history h " + "LEFT JOIN vendor_details v ON (h.vendor_id = CAST(v.id AS CHAR) OR h.vendor_id = v.vendor_name) " + "LEFT JOIN user_type_details ut ON (h.user_type = CAST(ut.id AS CHAR) OR h.user_type = ut.usertype) " + - "LEFT JOIN employee_workorder_details des ON (h.designation = CAST(des.id AS CHAR) OR h.designation = des.designation) " - + - "LEFT JOIN employee_location_details loc ON (h.location = CAST(loc.id AS CHAR) OR h.location = loc.location_name) " - + + "LEFT JOIN employee_workorder_details des ON (h.designation = CAST(des.id AS CHAR) OR h.designation = des.designation) " + + "LEFT JOIN employee_location_details loc ON (h.location = CAST(loc.id AS CHAR) OR h.location = loc.location_name) " + + "LEFT JOIN app_user u ON (h.updated_by = CAST(u.usr_id AS CHAR) OR h.updated_by = u.usr_name) " + "WHERE h.emp_code = ? " + "ORDER BY h.updated_date DESC"; try { diff --git a/src/main/resources/templates/fragments/navbar.html b/src/main/resources/templates/fragments/navbar.html index 011384c..4f7ff00 100644 --- a/src/main/resources/templates/fragments/navbar.html +++ b/src/main/resources/templates/fragments/navbar.html @@ -40,6 +40,12 @@ Delete Employee +