Browse Source

changes in manpower and payment tracker project ui and query changes

master
yoganandhank 3 months ago
parent
commit
0f994f0d86
  1. 5
      src/main/java/com/gcc_manpower/controller/HomeController.java
  2. 3
      src/main/java/com/gcc_manpower/gccservicepaymenttracker/controller/GccServicePaymentTrackerController.java
  3. 76
      src/main/java/com/gcc_manpower/gccservicepaymenttracker/service/GccServicePaymentTrackerService.java
  4. 841
      src/main/resources/templates/gccservicepaymenttracker/dashboard.html
  5. 16
      src/main/resources/templates/home/home.html

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

@ -42,7 +42,10 @@ public class HomeController {
Object vacantObj = des.get("vacant_count");
if (vacantObj != null) {
try {
totalVacantCount += Integer.parseInt(String.valueOf(vacantObj).trim());
double val = Double.parseDouble(String.valueOf(vacantObj).trim());
if (val > 0) {
totalVacantCount += (int) val;
}
} catch (NumberFormatException ignored) {
}
}

3
src/main/java/com/gcc_manpower/gccservicepaymenttracker/controller/GccServicePaymentTrackerController.java

@ -162,6 +162,7 @@ public class GccServicePaymentTrackerController {
@ResponseBody
public Map<String, Object> deleteDetail(
@RequestParam("id") int id,
@RequestParam(value = "remarks", required = false, defaultValue = "") String remarks,
HttpSession session) {
Map<String, Object> response = new HashMap<>();
@ -186,7 +187,7 @@ public class GccServicePaymentTrackerController {
}
try {
boolean deleted = paymentTrackerService.deleteDetail(id);
boolean deleted = paymentTrackerService.deleteDetail(id, remarks, username);
response.put("success", deleted);
if (!deleted) {
response.put("error", "Failed to delete record.");

76
src/main/java/com/gcc_manpower/gccservicepaymenttracker/service/GccServicePaymentTrackerService.java

@ -34,6 +34,8 @@ public class GccServicePaymentTrackerService {
counts.put("delivery chellan", 0);
counts.put("asd", 0);
counts.put("agreement", 0);
counts.put("total", 0);
counts.put("status_not_updated", 0);
String sql = "SELECT "
+ "CASE WHEN p.type REGEXP '^[0-9]+$' THEN t.type_name ELSE p.type END as type_resolved, "
@ -43,6 +45,20 @@ public class GccServicePaymentTrackerService {
+ "WHERE p.is_active = 1 AND p.is_delete = 0 "
+ "GROUP BY type_resolved";
try {
// Count total active records
String sqlTotal = "SELECT COUNT(*) FROM payment_tracking_details WHERE is_active = 1 AND is_delete = 0";
Integer totalCount = jdbcTemplate.queryForObject(sqlTotal, Integer.class);
counts.put("total", totalCount != null ? totalCount : 0);
// Count records where type is missing
String sqlMissingType = "SELECT COUNT(*) FROM payment_tracking_details WHERE is_active = 1 AND is_delete = 0 AND (type IS NULL OR TRIM(type) = '')";
Integer missingTypeCount = jdbcTemplate.queryForObject(sqlMissingType, Integer.class);
counts.put("status_not_updated", missingTypeCount != null ? missingTypeCount : 0);
} catch (Exception e) {
System.err.println("Error getting total or missing type counts: " + e.getMessage());
}
try {
List<Map<String, Object>> rows = jdbcTemplate.queryForList(sql);
for (Map<String, Object> row : rows) {
@ -90,7 +106,9 @@ public class GccServicePaymentTrackerService {
if (type != null && !type.trim().isEmpty()) {
String category = type.trim().toLowerCase();
if (category.equals("asd")) {
if (category.equals("status_not_updated")) {
sql.append(" AND (p.type IS NULL OR TRIM(p.type) = '')");
} else if (category.equals("asd")) {
sql.append(
" AND (LOWER(p.type) = 'asd' OR LOWER(p.type) LIKE '%asd%' OR LOWER(t.type_name) LIKE '%asd%' OR LOWER(t.type_name) LIKE '%additional security%')");
} else if (category.equals("agreement")) {
@ -132,7 +150,8 @@ public class GccServicePaymentTrackerService {
if (status != null && !status.trim().isEmpty()) {
if (status.trim().matches("^[0-9]+$")) {
sql.append(" AND (p.status = ? OR (NOT p.status REGEXP '^[0-9]+$' AND p.status = (SELECT status_name FROM status_list WHERE id = ? LIMIT 1)))");
sql.append(
" AND (p.status = ? OR (NOT p.status REGEXP '^[0-9]+$' AND p.status = (SELECT status_name FROM status_list WHERE id = ? LIMIT 1)))");
params.add(status.trim());
params.add(status.trim());
} else {
@ -268,10 +287,54 @@ public class GccServicePaymentTrackerService {
}
}
public boolean deleteDetail(int id) {
String sql = "UPDATE payment_tracking_details SET is_active = 0, is_delete = 1 WHERE id = ?";
public boolean deleteDetail(int id, String remarks, String updatedBy) {
String sql = "UPDATE payment_tracking_details SET is_active = 0, is_delete = 1, remarks = ?, updated_by = ?, updated_date = ? WHERE id = ?";
try {
int rows = jdbcTemplate.update(sql, id);
// Retrieve old record first to populate history
Map<String, Object> old = null;
try {
old = jdbcTemplate.queryForMap("SELECT * FROM payment_tracking_details WHERE id = ?", id);
} catch (Exception e) {
System.err.println("Could not find old record for history before delete: " + e.getMessage());
}
int rows = jdbcTemplate.update(sql, remarks, updatedBy, new java.sql.Timestamp(System.currentTimeMillis()),
id);
if (rows > 0 && old != null) {
try {
String histSql = "INSERT INTO payment_tracking_details_history ("
+ "detail_id, received_date, vendor_name, subject, amount, invoice_no, receiptno, "
+ "invoice_date, type, physical_file_no, remarks, tat, status, followup, myfollowup, "
+ "is_active, is_delete, order_by, file_path, cdate, updated_at, updated_by"
+ ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
jdbcTemplate.update(histSql,
id,
old.get("received_date"),
old.get("vendor_name"),
old.get("subject"),
old.get("amount"),
old.get("invoice_no"),
old.get("receiptno"),
old.get("invoice_date"),
old.get("type"),
old.get("physical_file_no"),
remarks,
old.get("tat"),
old.get("status"),
old.get("followup"),
old.get("myfollowup"),
0, // is_active = 0
1, // is_delete = 1
old.get("order_by"),
old.get("file_path"),
old.get("cdate"),
new java.sql.Timestamp(System.currentTimeMillis()),
updatedBy);
} catch (Exception he) {
System.err.println("Error saving history during delete: " + he.getMessage());
}
}
return rows > 0;
} catch (Exception e) {
System.err.println("Error soft-deleting payment tracking detail ID " + id + ": " + e.getMessage());
@ -380,7 +443,8 @@ public class GccServicePaymentTrackerService {
try {
return jdbcTemplate.queryForList(sql, detailId);
} catch (Exception e) {
System.err.println("Error fetching payment tracking history for detail ID " + detailId + ": " + e.getMessage());
System.err.println(
"Error fetching payment tracking history for detail ID " + detailId + ": " + e.getMessage());
return new ArrayList<>();
}
}

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

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

@ -1548,7 +1548,7 @@
if (desObj) {
const tender = parseInt(desObj.tender_manpower_designation_wise) || 0;
cardTenderCount += tender;
cardActualVacantCount += (parseInt(desObj.vacant_count) || 0);
cardActualVacantCount += Math.max(0, parseInt(desObj.vacant_count) || 0);
}
}
} else {
@ -1622,7 +1622,7 @@
const actualEmployees = parseInt(vendor.actual_employee_count) || 0;
filteredTotalTender += totalEmployees;
filteredTotalOnRoll += actualEmployees;
filteredTotalVacant += Math.max(0, totalEmployees - actualEmployees);
filteredTotalVacant += cardActualVacantCount;
}
const tenderBadge = card.querySelector(".vendor-card-footer div:nth-child(1) span:nth-child(2)");
@ -1650,13 +1650,20 @@
if (totalVendorsEl) totalVendorsEl.textContent = vendorDetailsData.length;
if (totalContractedEl) totalContractedEl.textContent = totalContractedEl.getAttribute("data-init") || filteredTotalTender;
if (totalOnRollEl) totalOnRollEl.textContent = totalOnRollEl.getAttribute("data-init") || filteredTotalOnRoll;
if (totalVacantEl) totalVacantEl.textContent = totalVacantEl.getAttribute("data-init") || filteredTotalVacant;
if (totalVacantEl) {
console.log("stat-total-vacant dynamic content updating to:", filteredTotalVacant);
totalVacantEl.textContent = filteredTotalVacant;
}
} else {
if (totalVendorsEl) totalVendorsEl.textContent = filteredVendorsCount;
if (totalContractedEl) totalContractedEl.textContent = filteredTotalTender;
if (totalOnRollEl) totalOnRollEl.textContent = filteredTotalOnRoll;
if (totalVacantEl) totalVacantEl.textContent = filteredTotalVacant;
if (totalVacantEl) {
console.log("stat-total-vacant filtered content updating to:", filteredTotalVacant);
totalVacantEl.textContent = filteredTotalVacant;
}
}
console.log("filterVendorCards finished. anyFilterActive:", anyFilterActive, "filteredTotalVacant:", filteredTotalVacant);
}
// Globals to store current modal state
@ -3196,6 +3203,7 @@
// Initialize designation dropdown options on load
updateDesignationDropdown();
filterVendorCards();
});
function deleteEmployee(empCode, empName) {

Loading…
Cancel
Save