Browse Source
new changes added adjustment management controller, service, pages and manpower standby count, and payment tracker last updated files
master
new changes added adjustment management controller, service, pages and manpower standby count, and payment tracker last updated files
master
15 changed files with 2717 additions and 83 deletions
-
10src/main/java/com/gcc_manpower/config/DataSourceConfig.java
-
14src/main/java/com/gcc_manpower/config/SecurityConfig.java
-
9src/main/java/com/gcc_manpower/config/WebConfig.java
-
307src/main/java/com/gcc_manpower/gccadjustmentmanagement/controller/AdjustmentController.java
-
214src/main/java/com/gcc_manpower/gccadjustmentmanagement/service/AdjustmentService.java
-
26src/main/java/com/gcc_manpower/gccservicepaymenttracker/service/GccServicePaymentTrackerService.java
-
156src/main/java/com/gcc_manpower/service/AppUserService.java
-
28src/main/resources/static/assets/css/home-styles.css
-
22src/main/resources/templates/fragments/adjustment.html
-
1661src/main/resources/templates/gccadjustmentmanagement/dashboard.html
-
89src/main/resources/templates/gccadjustmentmanagement/login.html
-
56src/main/resources/templates/gccservicepaymenttracker/dashboard.html
-
35src/main/resources/templates/gccservicepaymenttracker/details.html
-
82src/main/resources/templates/home/home.html
-
91src/main/resources/templates/home/view-login-details.html
@ -0,0 +1,307 @@ |
|||||
|
package com.gcc_manpower.gccadjustmentmanagement.controller; |
||||
|
|
||||
|
import java.io.File; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.beans.factory.annotation.Value; |
||||
|
import org.springframework.security.authentication.AuthenticationManager; |
||||
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
||||
|
import org.springframework.security.core.Authentication; |
||||
|
import org.springframework.security.core.AuthenticationException; |
||||
|
import org.springframework.security.core.context.SecurityContextHolder; |
||||
|
import org.springframework.security.web.context.HttpSessionSecurityContextRepository; |
||||
|
import org.springframework.stereotype.Controller; |
||||
|
import org.springframework.ui.Model; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
import org.springframework.web.bind.annotation.ResponseBody; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
import com.gcc_manpower.gccadjustmentmanagement.service.AdjustmentService; |
||||
|
import com.gcc_manpower.service.AppUserService; |
||||
|
|
||||
|
import jakarta.servlet.http.HttpServletRequest; |
||||
|
import jakarta.servlet.http.HttpSession; |
||||
|
|
||||
|
@Controller |
||||
|
@RequestMapping("/gccadjustmentmanagement") |
||||
|
public class AdjustmentController { |
||||
|
|
||||
|
@Autowired |
||||
|
private AdjustmentService adjustmentService; |
||||
|
|
||||
|
@Autowired |
||||
|
private AppUserService appUserService; |
||||
|
|
||||
|
@Autowired |
||||
|
private AuthenticationManager authenticationManager; |
||||
|
|
||||
|
@Value("${adjustment.upload.path:gccadjustmentmanagementfiles}") |
||||
|
private String adjustmentUploadPathConfig; |
||||
|
|
||||
|
@GetMapping({ "", "/", "/dashboard" }) |
||||
|
public String viewDashboard(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/dashboard"; |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/login") |
||||
|
public String login(HttpSession session) { |
||||
|
return "gccadjustmentmanagement/login"; |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/api/login") |
||||
|
@ResponseBody |
||||
|
public Map<String, Object> validateLogin( |
||||
|
@RequestParam("usrName") String usrName, |
||||
|
@RequestParam("usrPass") String usrPass, |
||||
|
HttpSession session) { |
||||
|
|
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
|
||||
|
try { |
||||
|
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(usrName, |
||||
|
usrPass); |
||||
|
Authentication authentication = authenticationManager.authenticate(authenticationToken); |
||||
|
|
||||
|
SecurityContextHolder.getContext().setAuthentication(authentication); |
||||
|
session.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, |
||||
|
SecurityContextHolder.getContext()); |
||||
|
|
||||
|
String role = authentication.getAuthorities().stream() |
||||
|
.map(auth -> auth.getAuthority().replace("ROLE_", "")) |
||||
|
.findFirst() |
||||
|
.orElse("USER"); |
||||
|
|
||||
|
session.setAttribute("adj_usrName", usrName); |
||||
|
session.setAttribute("adj_usrRole", role); |
||||
|
session.setMaxInactiveInterval(1800); // 30 minutes session timeout |
||||
|
response.put("result", true); |
||||
|
response.put("usrName", usrName); |
||||
|
} catch (AuthenticationException e) { |
||||
|
response.put("result", false); |
||||
|
response.put("error", e.getMessage() != null ? e.getMessage() : "Invalid username or password!"); |
||||
|
} |
||||
|
|
||||
|
return response; |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/logout") |
||||
|
public String logout(HttpSession session, HttpServletRequest request) { |
||||
|
SecurityContextHolder.clearContext(); |
||||
|
if (session != null) { |
||||
|
session.removeAttribute("adj_usrName"); |
||||
|
session.removeAttribute("adj_usrRole"); |
||||
|
session.invalidate(); |
||||
|
} |
||||
|
request.getSession(true); |
||||
|
return "redirect:/gccadjustmentmanagement/login"; |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/api/advance-types") |
||||
|
@ResponseBody |
||||
|
public List<Map<String, Object>> getAdvanceTypes(HttpSession session) { |
||||
|
if (session.getAttribute("adj_usrName") == null) { |
||||
|
return java.util.Collections.emptyList(); |
||||
|
} |
||||
|
return adjustmentService.getAdvanceTypes(); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/api/fund-types") |
||||
|
@ResponseBody |
||||
|
public List<Map<String, Object>> getFundTypes(HttpSession session) { |
||||
|
if (session.getAttribute("adj_usrName") == null) { |
||||
|
return java.util.Collections.emptyList(); |
||||
|
} |
||||
|
return adjustmentService.getFundTypes(); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/api/list") |
||||
|
@ResponseBody |
||||
|
public List<Map<String, Object>> getFilesList(HttpSession session) { |
||||
|
if (session.getAttribute("adj_usrName") == null) { |
||||
|
return java.util.Collections.emptyList(); |
||||
|
} |
||||
|
return adjustmentService.getAllFiles(); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/api/save") |
||||
|
@ResponseBody |
||||
|
public Map<String, Object> saveAdjustment( |
||||
|
@RequestParam(value = "id", required = false) Integer id, |
||||
|
@RequestParam(value = "vend_name", required = false) String vendName, |
||||
|
@RequestParam(value = "fin_year", required = false) String finYear, |
||||
|
@RequestParam(value = "adv_type_id", required = false) String advTypeId, |
||||
|
@RequestParam(value = "fund_type_id", required = false) String fundTypeId, |
||||
|
@RequestParam(value = "bal_amt", required = false) Double balAmt, |
||||
|
@RequestParam(value = "file_remark", required = false) String fileRemark, |
||||
|
@RequestParam(value = "file_data_num", required = false) String fileDataNum, |
||||
|
@RequestParam(value = "pi_amt", required = false) Double piAmt, |
||||
|
@RequestParam(value = "pi_file_gen_date", required = false) String piFileGenDate, |
||||
|
@RequestParam(value = "fi_amt", required = false) String fiAmt, |
||||
|
@RequestParam(value = "fi_file_gen_date", required = false) String fiFileGenDate, |
||||
|
@RequestParam(value = "tc_file_gen_date", required = false) String tcFileGenDate, |
||||
|
@RequestParam(value = "ejv_num", required = false) String ejvNum, |
||||
|
@RequestParam(value = "ejv_num_file_gen_date", required = false) String ejvNumFileGenDate, |
||||
|
@RequestParam(value = "as_file_gen_date", required = false) String asFileGenDate, |
||||
|
@RequestParam(value = "as_final_file_gen_date", required = false) String asFinalFileGenDate, |
||||
|
@RequestParam(value = "file", required = false) MultipartFile file, |
||||
|
@RequestParam(value = "poFile", required = false) MultipartFile poFile, |
||||
|
@RequestParam(value = "dcFile", required = false) MultipartFile dcFile, |
||||
|
@RequestParam(value = "irFile", required = false) MultipartFile irFile, |
||||
|
@RequestParam(value = "srFile", required = false) MultipartFile srFile, |
||||
|
@RequestParam(value = "piFile", required = false) MultipartFile piFile, |
||||
|
@RequestParam(value = "fiFile", required = false) MultipartFile fiFile, |
||||
|
@RequestParam(value = "tcFile", required = false) MultipartFile tcFile, |
||||
|
@RequestParam(value = "rtgsFile", required = false) MultipartFile rtgsFile, |
||||
|
@RequestParam(value = "ejvFile", required = false) MultipartFile ejvFile, |
||||
|
@RequestParam(value = "asFile", required = false) MultipartFile asFile, |
||||
|
@RequestParam(value = "asFinalFile", required = false) MultipartFile asFinalFile, |
||||
|
HttpSession session) { |
||||
|
|
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
String username = (String) session.getAttribute("adj_usrName"); |
||||
|
if (username == null) { |
||||
|
response.put("success", false); |
||||
|
response.put("error", "Unauthorized access. Please log in."); |
||||
|
return response; |
||||
|
} |
||||
|
|
||||
|
try { |
||||
|
Map<String, Object> existing = null; |
||||
|
if (id != null) { |
||||
|
existing = adjustmentService.getAdjustmentFileById(id); |
||||
|
if (existing == null) { |
||||
|
response.put("success", false); |
||||
|
response.put("error", "Record not found."); |
||||
|
return response; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
File uploadDir = new File(adjustmentUploadPathConfig).getAbsoluteFile(); |
||||
|
if (!uploadDir.exists()) { |
||||
|
uploadDir.mkdirs(); |
||||
|
} |
||||
|
|
||||
|
// Save files or keep existing |
||||
|
String filePath = saveFile(file, "file", uploadDir, existing != null ? (String) existing.get("file_path") : null); |
||||
|
String poPath = saveFile(poFile, "po", uploadDir, existing != null ? (String) existing.get("po_file_path") : null); |
||||
|
String dcPath = saveFile(dcFile, "dc", uploadDir, existing != null ? (String) existing.get("dc_file_path") : null); |
||||
|
String irPath = saveFile(irFile, "ir", uploadDir, existing != null ? (String) existing.get("ir_file_path") : null); |
||||
|
String srPath = saveFile(srFile, "sr", uploadDir, existing != null ? (String) existing.get("sr_filepath") : null); |
||||
|
String piPath = saveFile(piFile, "pi", uploadDir, existing != null ? (String) existing.get("pi_file_path") : null); |
||||
|
String fiPath = saveFile(fiFile, "fi", uploadDir, existing != null ? (String) existing.get("fi_file_path") : null); |
||||
|
String tcPath = saveFile(tcFile, "tc", uploadDir, existing != null ? (String) existing.get("tc_file_path") : null); |
||||
|
String rtgsPath = saveFile(rtgsFile, "rtgs", uploadDir, existing != null ? (String) existing.get("rtgs_file_path") : null); |
||||
|
String ejvPath = saveFile(ejvFile, "ejv", uploadDir, existing != null ? (String) existing.get("ejv_num_file_path") : null); |
||||
|
String asPath = saveFile(asFile, "as", uploadDir, existing != null ? (String) existing.get("as_file_path") : null); |
||||
|
String asFinalPath = saveFile(asFinalFile, "as_final", uploadDir, existing != null ? (String) existing.get("as_final_file_path") : null); |
||||
|
|
||||
|
// Build data map |
||||
|
Map<String, Object> data = new HashMap<>(); |
||||
|
if (id != null) data.put("id", id); |
||||
|
data.put("vend_name", vendName); |
||||
|
data.put("fin_year", finYear); |
||||
|
data.put("adv_type_id", advTypeId); |
||||
|
data.put("fund_type_id", fundTypeId); |
||||
|
data.put("bal_amt", balAmt); |
||||
|
data.put("file_remark", fileRemark); |
||||
|
data.put("file_data_num", fileDataNum); |
||||
|
data.put("pi_amt", piAmt); |
||||
|
data.put("pi_file_gen_date", piFileGenDate); |
||||
|
data.put("fi_amt", fiAmt); |
||||
|
data.put("fi_file_gen_date", fiFileGenDate); |
||||
|
data.put("tc_file_gen_date", tcFileGenDate); |
||||
|
data.put("ejv_num", ejvNum); |
||||
|
data.put("ejv_num_file_gen_date", ejvNumFileGenDate); |
||||
|
data.put("as_file_gen_date", asFileGenDate); |
||||
|
data.put("as_final_file_gen_date", asFinalFileGenDate); |
||||
|
|
||||
|
// Paths |
||||
|
data.put("file_path", filePath); |
||||
|
data.put("po_file_path", poPath); |
||||
|
data.put("dc_file_path", dcPath); |
||||
|
data.put("ir_file_path", irPath); |
||||
|
data.put("sr_filepath", srPath); |
||||
|
data.put("pi_file_path", piPath); |
||||
|
data.put("fi_file_path", fiPath); |
||||
|
data.put("tc_file_path", tcPath); |
||||
|
data.put("rtgs_file_path", rtgsPath); |
||||
|
data.put("ejv_num_file_path", ejvPath); |
||||
|
data.put("as_file_path", asPath); |
||||
|
data.put("as_final_file_path", asFinalPath); |
||||
|
|
||||
|
boolean saved = adjustmentService.saveAdjustmentFile(data, username); |
||||
|
if (saved) { |
||||
|
response.put("success", true); |
||||
|
response.put("message", "Adjustment file details saved successfully."); |
||||
|
} else { |
||||
|
response.put("success", false); |
||||
|
response.put("error", "Failed to save details in database."); |
||||
|
} |
||||
|
} catch (Exception e) { |
||||
|
response.put("success", false); |
||||
|
response.put("error", "Error occurred: " + e.getMessage()); |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
|
||||
|
return response; |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/api/delete") |
||||
|
@ResponseBody |
||||
|
public Map<String, Object> deleteAdjustment( |
||||
|
@RequestParam("id") Integer id, |
||||
|
@RequestParam(value = "remarks", required = false) String remarks, |
||||
|
HttpSession session) { |
||||
|
|
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
String username = (String) session.getAttribute("adj_usrName"); |
||||
|
if (username == null) { |
||||
|
response.put("success", false); |
||||
|
response.put("error", "Unauthorized access. Please log in."); |
||||
|
return response; |
||||
|
} |
||||
|
|
||||
|
boolean deleted = adjustmentService.deleteAdjustmentFile(id, remarks != null ? remarks : "Deleted by user", username); |
||||
|
if (deleted) { |
||||
|
response.put("success", true); |
||||
|
response.put("message", "Record deleted successfully."); |
||||
|
} else { |
||||
|
response.put("success", false); |
||||
|
response.put("error", "Failed to delete record."); |
||||
|
} |
||||
|
|
||||
|
return response; |
||||
|
} |
||||
|
|
||||
|
private String saveFile(MultipartFile f, String prefix, File dir, String currentPath) throws Exception { |
||||
|
if (f == null || f.isEmpty()) { |
||||
|
return currentPath; |
||||
|
} |
||||
|
String orig = f.getOriginalFilename(); |
||||
|
String ext = orig != null && orig.lastIndexOf('.') > 0 ? orig.substring(orig.lastIndexOf('.')) : ".pdf"; |
||||
|
String filename = prefix + "_" + System.currentTimeMillis() + ext; |
||||
|
File dest = new File(dir, filename).getAbsoluteFile(); |
||||
|
f.transferTo(dest); |
||||
|
return "gccadjustmentmanagementfiles/" + filename; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,214 @@ |
|||||
|
package com.gcc_manpower.gccadjustmentmanagement.service; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
import javax.sql.DataSource; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.beans.factory.annotation.Qualifier; |
||||
|
import org.springframework.jdbc.core.JdbcTemplate; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
@Service |
||||
|
public class AdjustmentService { |
||||
|
|
||||
|
private JdbcTemplate jdbcTemplate; |
||||
|
|
||||
|
@Autowired |
||||
|
public void setDataSource(@Qualifier("mysqladjustmentDataSource") DataSource dataSource) { |
||||
|
this.jdbcTemplate = new JdbcTemplate(dataSource); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getAdvanceTypes() { |
||||
|
String sql = "SELECT id, adv_type FROM advance_type_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 advance types: " + e.getMessage()); |
||||
|
return new ArrayList<>(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getFundTypes() { |
||||
|
String sql = "SELECT id, fund_type FROM fund_type_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 fund types: " + e.getMessage()); |
||||
|
return new ArrayList<>(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getAllFiles() { |
||||
|
String sql = "SELECT a.*, " + |
||||
|
"adv.adv_type AS resolved_adv_type, " + |
||||
|
"f.fund_type AS resolved_fund_type " + |
||||
|
"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) " + |
||||
|
"WHERE a.is_active = 1 AND a.is_delete = 0 " + |
||||
|
"ORDER BY a.updated_date DESC, a.id DESC"; |
||||
|
try { |
||||
|
return jdbcTemplate.queryForList(sql); |
||||
|
} catch (Exception e) { |
||||
|
System.err.println("Error fetching adjustment files: " + e.getMessage()); |
||||
|
return new ArrayList<>(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public Map<String, Object> getAdjustmentFileById(int id) { |
||||
|
String sql = "SELECT * FROM adjustment_file_details WHERE id = ? AND is_active = 1 AND is_delete = 0"; |
||||
|
try { |
||||
|
return jdbcTemplate.queryForMap(sql, id); |
||||
|
} catch (Exception e) { |
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public boolean saveAdjustmentFile(Map<String, Object> data, String username) { |
||||
|
java.sql.Timestamp now = new java.sql.Timestamp(System.currentTimeMillis()); |
||||
|
Object idVal = data.get("id"); |
||||
|
|
||||
|
if (idVal != null && !String.valueOf(idVal).trim().isEmpty()) { |
||||
|
// Update |
||||
|
int id = Integer.parseInt(String.valueOf(idVal).trim()); |
||||
|
String sql = "UPDATE adjustment_file_details SET " + |
||||
|
"as_file_gen_date = ?, as_file_path = ?, as_final_file_gen_date = ?, as_final_file_path = ?, " + |
||||
|
"bal_amt = ?, dc_file_path = ?, ejv_num = ?, ejv_num_file_gen_date = ?, ejv_num_file_path = ?, " + |
||||
|
"fi_amt = ?, fi_file_gen_date = ?, fi_file_path = ?, file_data_num = ?, file_path = ?, " + |
||||
|
"file_remark = ?, fin_year = ?, 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 = ?, updated_date = ?, " + |
||||
|
"updated_by = ? WHERE id = ?"; |
||||
|
try { |
||||
|
int rows = jdbcTemplate.update(sql, |
||||
|
parseDate(data.get("as_file_gen_date")), |
||||
|
data.get("as_file_path"), |
||||
|
data.get("as_final_file_gen_date"), |
||||
|
data.get("as_final_file_path"), |
||||
|
parseDouble(data.get("bal_amt")), |
||||
|
data.get("dc_file_path"), |
||||
|
data.get("ejv_num"), |
||||
|
parseDate(data.get("ejv_num_file_gen_date")), |
||||
|
data.get("ejv_num_file_path"), |
||||
|
data.get("fi_amt"), |
||||
|
parseDate(data.get("fi_file_gen_date")), |
||||
|
data.get("fi_file_path"), |
||||
|
data.get("file_data_num"), |
||||
|
data.get("file_path"), |
||||
|
data.get("file_remark"), |
||||
|
data.get("fin_year"), |
||||
|
data.get("ir_file_path"), |
||||
|
parseDouble(data.get("pi_amt")), |
||||
|
parseDate(data.get("pi_file_gen_date")), |
||||
|
data.get("pi_file_path"), |
||||
|
data.get("po_file_path"), |
||||
|
data.get("rtgs_file_path"), |
||||
|
data.get("sr_filepath"), |
||||
|
parseDate(data.get("tc_file_gen_date")), |
||||
|
data.get("tc_file_path"), |
||||
|
data.get("vend_name"), |
||||
|
data.get("adv_type_id"), |
||||
|
data.get("fund_type_id"), |
||||
|
now, |
||||
|
username, |
||||
|
id |
||||
|
); |
||||
|
return rows > 0; |
||||
|
} catch (Exception e) { |
||||
|
System.err.println("Error updating adjustment file: " + e.getMessage()); |
||||
|
e.printStackTrace(); |
||||
|
return false; |
||||
|
} |
||||
|
} else { |
||||
|
// Insert |
||||
|
String sql = "INSERT INTO adjustment_file_details (" + |
||||
|
"as_file_gen_date, as_file_path, as_final_file_gen_date, as_final_file_path, " + |
||||
|
"bal_amt, dc_file_path, ejv_num, ejv_num_file_gen_date, ejv_num_file_path, " + |
||||
|
"fi_amt, fi_file_gen_date, fi_file_path, file_data_num, file_path, " + |
||||
|
"file_remark, fin_year, 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, 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")), |
||||
|
data.get("as_file_path"), |
||||
|
data.get("as_final_file_gen_date"), |
||||
|
data.get("as_final_file_path"), |
||||
|
parseDouble(data.get("bal_amt")), |
||||
|
data.get("dc_file_path"), |
||||
|
data.get("ejv_num"), |
||||
|
parseDate(data.get("ejv_num_file_gen_date")), |
||||
|
data.get("ejv_num_file_path"), |
||||
|
data.get("fi_amt"), |
||||
|
parseDate(data.get("fi_file_gen_date")), |
||||
|
data.get("fi_file_path"), |
||||
|
data.get("file_data_num"), |
||||
|
data.get("file_path"), |
||||
|
data.get("file_remark"), |
||||
|
data.get("fin_year"), |
||||
|
data.get("ir_file_path"), |
||||
|
parseDouble(data.get("pi_amt")), |
||||
|
parseDate(data.get("pi_file_gen_date")), |
||||
|
data.get("pi_file_path"), |
||||
|
data.get("po_file_path"), |
||||
|
data.get("rtgs_file_path"), |
||||
|
data.get("sr_filepath"), |
||||
|
parseDate(data.get("tc_file_gen_date")), |
||||
|
data.get("tc_file_path"), |
||||
|
data.get("vend_name"), |
||||
|
data.get("adv_type_id"), |
||||
|
data.get("fund_type_id"), |
||||
|
now, |
||||
|
now, |
||||
|
username |
||||
|
); |
||||
|
return rows > 0; |
||||
|
} catch (Exception e) { |
||||
|
System.err.println("Error saving adjustment file: " + e.getMessage()); |
||||
|
e.printStackTrace(); |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public boolean deleteAdjustmentFile(int id, String remarks, String username) { |
||||
|
java.sql.Timestamp now = new java.sql.Timestamp(System.currentTimeMillis()); |
||||
|
String sql = "UPDATE adjustment_file_details SET is_active = 0, is_delete = 1, file_remark = CONCAT(COALESCE(file_remark, ''), '\nDeleted: ', ?), updated_by = ?, updated_date = ? WHERE id = ?"; |
||||
|
try { |
||||
|
int rows = jdbcTemplate.update(sql, remarks, username, now, id); |
||||
|
return rows > 0; |
||||
|
} catch (Exception e) { |
||||
|
System.err.println("Error deleting adjustment file: " + e.getMessage()); |
||||
|
e.printStackTrace(); |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private java.sql.Date parseDate(Object val) { |
||||
|
if (val == null || String.valueOf(val).trim().isEmpty()) { |
||||
|
return null; |
||||
|
} |
||||
|
try { |
||||
|
return java.sql.Date.valueOf(String.valueOf(val).trim()); |
||||
|
} catch (Exception e) { |
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private Double parseDouble(Object val) { |
||||
|
if (val == null || String.valueOf(val).trim().isEmpty()) { |
||||
|
return null; |
||||
|
} |
||||
|
try { |
||||
|
return Double.parseDouble(String.valueOf(val).trim()); |
||||
|
} catch (Exception e) { |
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
<th:block th:fragment="adjustmentheader"> |
||||
|
<!-- Awesome Font --> |
||||
|
<link rel="stylesheet" th:href="@{/assets/font-awesome-6.5.2/css/all.min.css}" type="text/css"> |
||||
|
<!-- Bootstrap CSS --> |
||||
|
<link rel="stylesheet" th:href="@{/assets/bootstrap-5.3.2/css/bootstrap.min.css}" type="text/css"> |
||||
|
<!-- CSS for Header --> |
||||
|
<link rel="stylesheet" th:href="@{/assets/css/header-styles.css}" type="text/css"> |
||||
|
<div class="header"> |
||||
|
<div class="logo-left"> |
||||
|
<img th:src="@{/assets/header-images/gcc1.png}" alt="Greater Chennai Corporation Logo"> |
||||
|
<div class="logo-text"> |
||||
|
<h2>GREATER</h2> |
||||
|
<h2>CHENNAI</h2> |
||||
|
<h2>CORPORATION</h2> |
||||
|
<p>பெருநகர சென்னை மாநகராட்சி</p> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="title"> |
||||
|
<h2>GCC Adjustment Management</h2> |
||||
|
</div> |
||||
|
</div> |
||||
|
</th:block> |
||||
1661
src/main/resources/templates/gccadjustmentmanagement/dashboard.html
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,89 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<html xmlns:th="http://www.thymeleaf.org" lang="en"> |
||||
|
|
||||
|
<head> |
||||
|
<meta charset="UTF-8"> |
||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
||||
|
<title>GCC Adjustment Management</title> |
||||
|
|
||||
|
<!-- CSRF Tokens --> |
||||
|
<meta th:if="${_csrf != null}" name="_csrf" th:content="${_csrf.token}" /> |
||||
|
<meta th:if="${_csrf != null}" name="_csrf_header" th:content="${_csrf.headerName}" /> |
||||
|
|
||||
|
<!-- Include CSS --> |
||||
|
<link rel="stylesheet" type="text/css" th:href="@{/assets/css/login-form-styles.css}"> |
||||
|
|
||||
|
<!-- Awesome Font --> |
||||
|
<link th:href="@{/assets/font-awesome-6.5.1/css/all.min.css}" rel="stylesheet" type="text/css"> |
||||
|
|
||||
|
</head> |
||||
|
|
||||
|
<body> |
||||
|
<div class="container"> |
||||
|
<img th:src="@{/assets/header-images/gcc1.png}" alt="Greater Chennai Corporation" class="small-logo"> |
||||
|
<h3>GREATER CHENNAI CORPORATION</h3> |
||||
|
<h4>பெருநகர சென்னை மாநகராட்சி</h4> |
||||
|
<br> |
||||
|
<h3>GCC Adjustment Management</h3> |
||||
|
<br> |
||||
|
<h2>Login</h2> |
||||
|
<!--<form method="post" th:action="@{/liveurls/api/val-app-usr-login}" id="frm-usr-login-det" |
||||
|
name="frm-usr-login-det">--> |
||||
|
<form id="frm-usr-login-det" name="frm-usr-login-det"> |
||||
|
<div class="input-field"> |
||||
|
<input type="text" name="usrName" id="usrName" placeholder="Enter Username"> |
||||
|
<div class="underline"></div> |
||||
|
</div> |
||||
|
<div class="input-field"> |
||||
|
<input type="password" name="usrPass" id="usrPass" placeholder="Enter Password"> |
||||
|
<div class="underline"></div> |
||||
|
</div> |
||||
|
<input type="submit" value="Login" onclick="handleLoginSubmit(event)"> |
||||
|
</form> |
||||
|
</div> |
||||
|
|
||||
|
<!-- Footer Fragment --> |
||||
|
<th:block th:replace="~{fragments/footer :: footer}"></th:block> |
||||
|
|
||||
|
<!-- Custom JS --> |
||||
|
<!--<script th:src="@{/assets/js/login-script.js}" type="text/javascript"></script>--> |
||||
|
<script th:inline="javascript"> |
||||
|
const contextPath = /*[[@{/}]]*/ ''; |
||||
|
</script> |
||||
|
|
||||
|
<script> |
||||
|
function handleLoginSubmit(event) { |
||||
|
event.preventDefault(); |
||||
|
|
||||
|
const form = document.getElementById("frm-usr-login-det"); |
||||
|
const formData = new FormData(form); |
||||
|
|
||||
|
fetch(contextPath + 'gccadjustmentmanagement/api/login', { |
||||
|
method: 'POST', |
||||
|
body: formData |
||||
|
}) |
||||
|
.then(response => response.json()) |
||||
|
.then(data => { |
||||
|
if (data.result) { |
||||
|
let usrName = data.usrName && data.usrName.length > 0 ? data.usrName : null; |
||||
|
if (usrName) { |
||||
|
sessionStorage.setItem("adj_usrName", usrName); |
||||
|
console.log("Redirecting to:", contextPath + 'gccadjustmentmanagement/'); |
||||
|
alert("Login Success"); |
||||
|
window.location.href = contextPath + 'gccadjustmentmanagement/'; |
||||
|
} else { |
||||
|
alert("No role found for this user!"); |
||||
|
} |
||||
|
} else { |
||||
|
alert(data.error || "Login failed"); |
||||
|
} |
||||
|
}) |
||||
|
.catch(err => { |
||||
|
console.error("Error during login:", err); |
||||
|
}); |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
</body> |
||||
|
|
||||
|
</html> |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue