Browse Source

Updated Park API in NULM

main
Hariprasath S 7 months ago
parent
commit
41cc4d115d
  1. 9
      gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/configuration/DataSourceConfig.java
  2. 237
      gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/nulm/controller/NulmAPIController.java
  3. 62
      gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/nulm/controller/NulmController.java
  4. 567
      gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/nulm/service/NulmService.java
  5. 4
      gcc_officer_portal/src/main/resources/application.properties
  6. 394
      gcc_officer_portal/src/main/resources/templates/modules/nulm/salary-approve-park.html
  7. 4
      gcc_officer_portal/src/main/resources/templates/modules/nulm/salary-approve.html
  8. 274
      gcc_officer_portal/src/main/resources/templates/modules/nulm/salary-report-park.html

9
gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/configuration/DataSourceConfig.java

@ -24,15 +24,14 @@ import java.util.Properties;
@EnableTransactionManagement @EnableTransactionManagement
public class DataSourceConfig { public class DataSourceConfig {
private static String host = "localhost:3306";
private static String dbpassword = "root";
// private static String host = "localhost:3306";
// private static String dbpassword = "root";
// private static String dbpassword = "gccroot"; // private static String dbpassword = "gccroot";
// AWS // AWS
// private static String host =
// "gcc-facial-db-instance-1.cf48eqcciziq.ap-south-1.rds.amazonaws.com:3306";
// private static String dbpassword = "gcc-facial-password";
private static String host ="gcc-facial-db-instance-1.cf48eqcciziq.ap-south-1.rds.amazonaws.com:3306";
private static String dbpassword = "gcc-facial-password";
////////////////////////////// (For GCC APP) //////////////////////// ////////////////////////////// (For GCC APP) ////////////////////////
@Configuration @Configuration

237
gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/nulm/controller/NulmAPIController.java

@ -16,6 +16,7 @@ import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.EmptyResultDataAccessException;
@ -33,6 +34,7 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import in.gov.chennaicorporation.gccoffice.nulm.service.NulmService; import in.gov.chennaicorporation.gccoffice.nulm.service.NulmService;
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo;
@RequestMapping("/gcc/api/nulm") @RequestMapping("/gcc/api/nulm")
@RestController("nulmAPI") @RestController("nulmAPI")
@ -509,14 +511,34 @@ public class NulmAPIController {
@RequestParam(value = "inchargeId", required = false) Integer inchargeId, @RequestParam(value = "inchargeId", required = false) Integer inchargeId,
@RequestParam(value = "month", required = false) String month, @RequestParam(value = "month", required = false) String month,
@RequestParam(value = "year", required = false) String year, @RequestParam(value = "year", required = false) String year,
@RequestParam(value = "incharge_name", required = false) String inchargeName,
@RequestParam(value = "inchargeName", required = false) String inchargeName,
@RequestParam(value = "enrollmentIds", required = false) List<Integer> enrollmentIds) { @RequestParam(value = "enrollmentIds", required = false) List<Integer> enrollmentIds) {
System.out.println("inchargeName="+inchargeName);
List<Map<String, Object>> staffList = nulmService.getAttendanceWithInitiatedSalary(inchargeId, month, year, List<Map<String, Object>> staffList = nulmService.getAttendanceWithInitiatedSalary(inchargeId, month, year,
inchargeName, enrollmentIds); inchargeName, enrollmentIds);
return ResponseEntity.ok(staffList); return ResponseEntity.ok(staffList);
} }
/////
@GetMapping("/staffInititeadList-park")
public ResponseEntity<List<Map<String, Object>>> getAttendanceWithInitiatedSalaryByGroupId_Park(
@RequestParam(value = "inchargeId", required = false) Integer inchargeId,
@RequestParam(value = "month", required = false) String month,
@RequestParam(value = "year", required = false) String year,
@RequestParam(value = "inchargeName", required = false) String inchargeName,
@RequestParam(value = "enrollmentIds", required = false) List<Integer> enrollmentIds) {
List<Map<String, Object>> staffList = nulmService.getAttendanceWithInitiatedSalary_Park(inchargeId, month, year,
inchargeName, enrollmentIds);
return ResponseEntity.ok(staffList);
}
/////
/* /*
* @PostMapping("/salaryDetailUpdate") * @PostMapping("/salaryDetailUpdate")
* public ResponseEntity<String> addSalaryDetails(@RequestBody List<Map<String, * public ResponseEntity<String> addSalaryDetails(@RequestBody List<Map<String,
@ -623,6 +645,75 @@ public class NulmAPIController {
.body("Invalid request data: " + e.getMessage()); .body("Invalid request data: " + e.getMessage());
} }
} }
///
@PostMapping("/salaryDetailUpdate_Park")
public ResponseEntity<String> addSalaryDetails_Park(@RequestBody List<Map<String, Object>> requestList) {
System.out.println("Received POST request with data: " + requestList);
try {
for (Map<String, Object> request : requestList) {
System.out.println("enrollment_id = " + request.get("enrollment_id").toString());
int totalDaysPresent = Integer.parseInt(request.get("total_days_present").toString());
int totalDaysOd = Integer.parseInt(request.get("total_days_od").toString());
int totalDaysSalary = Integer.parseInt(request.get("total_days_salary").toString());
int totalDaysAbsent = Integer.parseInt(request.get("total_days_absent").toString());
String month = request.get("month").toString();
int year = Integer.parseInt(request.get("year").toString());
int salaryAmount = Integer.parseInt(request.get("salary_amount").toString());
int enrollmentId = Integer.parseInt(request.get("enrollment_id").toString());
int groupId = Integer.parseInt(request.get("group_id").toString());
int wageId = Integer.parseInt(request.get("wage_id").toString());
int inchargeID = 0;// Integer.parseInt(""+request.get("incharge_id"));
// Check if the month and year are valid for salary initiation (past month)
if (isFutureOrCurrentMonth(month, year)) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
.body("Salary cannot be initiated for the current or future months. Please select a past month.");
}
String salaryStatus = "Initiated";
boolean checkexist = nulmService.checkSalaryDetails_park(enrollmentId, month, year);
System.out.println("checkexist: " + checkexist);
if (!checkexist) {
// Call the service method to insert the salary details
int rowsAffected = nulmService.addSalaryDetails_park(totalDaysPresent, totalDaysOd, totalDaysSalary,
totalDaysAbsent, month, year, salaryAmount, salaryStatus, enrollmentId, groupId, wageId,
inchargeID);
if (rowsAffected <= 0) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body("Failed to add salary details for enrollment ID: " + enrollmentId);
}
} else {
int rowsAffected = nulmService.updateSalaryDetails_park(totalDaysPresent, totalDaysOd, totalDaysSalary,
totalDaysAbsent, month, year, salaryAmount, salaryStatus, enrollmentId, groupId, wageId,
inchargeID);
if (rowsAffected <= 0) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body("Failed to update salary details for enrollment ID: " + enrollmentId);
}
}
}
return ResponseEntity.status(HttpStatus.CREATED)
.body("Salary details added successfully for all selected entries.");
} catch (Exception e) {
e.printStackTrace(); // Log the exception for debugging
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
.body("Invalid request data: " + e.getMessage());
}
}
///
// Helper method to check if the month is future or current // Helper method to check if the month is future or current
private boolean isFutureOrCurrentMonth(String month, int year) { private boolean isFutureOrCurrentMonth(String month, int year) {
@ -696,6 +787,41 @@ public class NulmAPIController {
nulmService.updateSalaryStatusToApproved(enrollmentIds, month, year); nulmService.updateSalaryStatusToApproved(enrollmentIds, month, year);
return ResponseEntity.ok("Salary status updated to 'Approved' for the provided enrollments."); return ResponseEntity.ok("Salary status updated to 'Approved' for the provided enrollments.");
} }
////
@GetMapping("/salary-approve-park-testdata")
public List<Map<String, Object>> getsalaryInitiatedCounts(@RequestParam(required = false) String month,
@RequestParam(required = false) Integer year,
@RequestParam(required = false) String salaryStatus,
@RequestParam (required = false) String LoginUserId){
List<Map<String, Object>> salaryInitiatedCounts;
// Fetch data if both month and year are provided, otherwise return an empty list
if (month != null && year != null) {
salaryInitiatedCounts = nulmService.getFilteredSalaryDetails_park(month, year, salaryStatus,LoginUserId); // Pass department to the service method
} else {
salaryInitiatedCounts = Collections.emptyList(); // Empty list if no month and year are provided
}
return salaryInitiatedCounts;
}
@PostMapping("/update-salary-status-park")
public ResponseEntity<String> updateSalaryStatus_Park(
@RequestParam List<Integer> enrollmentIds,
@RequestParam String month,
@RequestParam int year) {
System.out.println("Enrollment IDs: " + enrollmentIds);
System.out.println("Month: " + month);
System.out.println("Year: " + year);
nulmService.updateSalaryStatusToApproved_Park(enrollmentIds, month, year);
return ResponseEntity.ok("Salary status updated to 'Approved' for the provided enrollments.");
}
////
/*************** API For Mobile Application *********************************/ /*************** API For Mobile Application *********************************/
/* /*
@ -774,6 +900,59 @@ public class NulmAPIController {
List.of(Map.of("error", "An error occurred while fetching attendance data: " + ex.getMessage()))); List.of(Map.of("error", "An error occurred while fetching attendance data: " + ex.getMessage())));
} }
} }
////
@GetMapping("/attendanceWithSalary_New")
public ResponseEntity<List<Map<String, Object>>> getAttendanceWithSalaryByInchargeId_New(
@RequestParam(value = "month", required = false) String month,
@RequestParam(value = "year", required = false) Integer year,
@RequestParam(value = "incharge_id", required = false) Integer inchargeId,
@RequestParam(value = "type", required = false) String type) {
try {
List<Map<String, Object>> attendanceWithSalary = new ArrayList<>();
String ids = nulmService.checkInchargeID(inchargeId);
System.out.println("IDS = "+ids);
if (ids != null || !ids.trim().isEmpty()) {
// Call the service method to fetch the data
attendanceWithSalary = nulmService.getAttendanceWithSalaryByInchargeId_New(month, year, inchargeId, type, ids);
}
// If no data is found, return a NOT FOUND response total_days_salary,
// total_salary and total_days_absent
if (attendanceWithSalary.isEmpty()) {
return ResponseEntity.status(404)
.body(List.of(Map.of("error", "No attendance records found for the specified parameters.")));
}
for (Map<String, Object> aa : attendanceWithSalary) {
long days = ((Number) aa.get("total_days")).longValue();
long present = ((Number) aa.get("total_days_present")).longValue();
long od = ((Number) aa.get("total_days_od")).longValue();
long salaryPerDay = ((Number) aa.get("salary_per_day")).longValue();
long totalPresent = present + od;
long totalAbsent = days - totalPresent;
long totalSalary = totalPresent * salaryPerDay;
aa.put("total_salary", totalSalary);
aa.put("total_days_absent", totalAbsent);
aa.put("total_days_salary", totalPresent);
}
// Return the data in the response
return ResponseEntity.ok(attendanceWithSalary);
} catch (Exception ex) {
// Return a 500 Internal Server Error with the error message
return ResponseEntity.status(500).body(
List.of(Map.of("error", "An error occurred while fetching attendance data: " + ex.getMessage())));
}
}
////
@PostMapping("/salaryDetailInitiate") @PostMapping("/salaryDetailInitiate")
public ResponseEntity<String> addInitiatedSalaryDetails( public ResponseEntity<String> addInitiatedSalaryDetails(
@ -821,6 +1000,62 @@ public class NulmAPIController {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Invalid request data: " + e.getMessage()); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Invalid request data: " + e.getMessage());
} }
} }
////
// @PostMapping("/salaryDetailInitiate_park")
// public ResponseEntity<String> addInitiatedSalaryDetails_park(
// @RequestParam("total_days_present") List<Integer> totalDaysPresentList,
// @RequestParam("total_days_od") List<Integer> totalDaysOdList,
// @RequestParam("total_days_salary") List<Integer> totalDaysSalaryList,
// @RequestParam("total_days_absent") List<Integer> totalDaysAbsentList,
// @RequestParam("month") List<String> monthList,
// @RequestParam("year") List<Integer> yearList,
// @RequestParam("salary_amount") List<Integer> salaryAmountList,
// @RequestParam("enrollment_id") List<Integer> enrollmentIdList,
// @RequestParam("group_id") List<Integer> groupIdList,
// @RequestParam("wage_id") List<Integer> wageIdList) {
// // System.out.println("Received POST request with form-data");
//
// try {
// // Iterate through each list to process the form data
// for (int i = 0; i < totalDaysPresentList.size(); i++) {
// int totalDaysPresent = totalDaysPresentList.get(i);
// int totalDaysOd = totalDaysOdList.get(i);
// int total_days_salary = totalDaysSalaryList.get(i);
// int totalDaysAbsent = totalDaysAbsentList.get(i);
// String month = monthList.get(i);
// int year = yearList.get(i);
// int salaryAmount = salaryAmountList.get(i);
// int enrollmentId = enrollmentIdList.get(i);
// int groupId = groupIdList.get(i);
// int wageId = wageIdList.get(i);
//
// String salaryStatus = "Initiated";
//
// // Call the service method to insert the salary details
// int rowsAffected = nulmService.addSalaryDetails_park(totalDaysPresent, totalDaysOd, total_days_salary,
// totalDaysAbsent, month, year, salaryAmount, salaryStatus, enrollmentId, groupId, wageId);
//
// if (rowsAffected <= 0) {
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
// .body("Failed to add salary details for enrollment ID: " + enrollmentId);
// }
// }
// return ResponseEntity.status(HttpStatus.CREATED)
// .body("Salary details added successfully for all selected entries in park.");
// } catch (Exception e) {
// e.printStackTrace(); // Log the exception for debugging
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Invalid request data: " + e.getMessage());
// }
// }
////
// @GetMapping("/filtered-details") // @GetMapping("/filtered-details")
// public List<Map<String, Object>> getFilteredSalaryDetails( // public List<Map<String, Object>> getFilteredSalaryDetails(

62
gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/nulm/controller/NulmController.java

@ -120,6 +120,8 @@ public class NulmController {
String LoginUserId = LoginUserInfo.getLoginUserId(); String LoginUserId = LoginUserInfo.getLoginUserId();
model.addAttribute("LoginUserId",LoginUserId); model.addAttribute("LoginUserId",LoginUserId);
System.out.println("LoginUserId=="+LoginUserId);
List<Map<String, Object>> salaryInitiatedCounts; List<Map<String, Object>> salaryInitiatedCounts;
// Fetch data if both month and year are provided, otherwise return an empty list // Fetch data if both month and year are provided, otherwise return an empty list
@ -134,6 +136,38 @@ public class NulmController {
return "modules/nulm/salary-approve"; return "modules/nulm/salary-approve";
} }
////
@GetMapping("/salary-approve-park")
public String viewSalaryApproveScreen_park(@RequestParam(required = false) String month,
@RequestParam(required = false) Integer year,
@RequestParam(required = false) String salaryStatus, // Added department parameter
Model model) {
String LoginUserId = LoginUserInfo.getLoginUserId();
model.addAttribute("LoginUserId",LoginUserId);
List<Map<String, Object>> salaryInitiatedCounts;
// Fetch data if both month and year are provided, otherwise return an empty list
if (month != null && year != null) {
salaryInitiatedCounts = nulmService.getFilteredSalaryDetails_park(month, year, salaryStatus,LoginUserId); // Pass department to the service method
} else {
salaryInitiatedCounts = Collections.emptyList(); // Empty list if no month and year are provided
}
model.addAttribute("salaryInitiatedCounts", salaryInitiatedCounts);
return "modules/nulm/salary-approve-park";
}
////
@GetMapping("/salary-report") @GetMapping("/salary-report")
public String viewSalaryReport( public String viewSalaryReport(
@RequestParam(required = false) String month, @RequestParam(required = false) String month,
@ -159,6 +193,34 @@ public class NulmController {
return "modules/nulm/salary-report"; // Returns the view 'salary-report' return "modules/nulm/salary-report"; // Returns the view 'salary-report'
} }
////
@GetMapping("/salary-report-park")
public String viewSalaryReport_Park(
@RequestParam(required = false) String month,
@RequestParam(required = false) Integer year,
@RequestParam(required = false) String salaryStatus,
@RequestParam(required = false) String groupName,
Model model) {
String LoginUserId = LoginUserInfo.getLoginUserId();
model.addAttribute("LoginUserId",LoginUserId);
// Initialize an empty salaryReport list
List<Map<String, Object>> salaryReport = new ArrayList<>();
// Only fetch the report if month and year are provided
if (month != null && year != null) {
salaryReport = nulmService.getSalaryReport_park(month, year, salaryStatus, groupName, LoginUserId);
}
// Add the fetched data to the model
model.addAttribute("salaryReport", salaryReport);
return "modules/nulm/salary-report-park"; // Returns the view 'salary-report'
}
////
@GetMapping("/salary-zonereport") @GetMapping("/salary-zonereport")
public String viewZoneWiseReport( public String viewZoneWiseReport(

567
gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/nulm/service/NulmService.java

@ -478,6 +478,24 @@ public class NulmService {
return jdbcTemplate.update(sql, totalDaysPresent, totalDaysOd, totalDaysSalary, totalDaysAbsent, month, year, return jdbcTemplate.update(sql, totalDaysPresent, totalDaysOd, totalDaysSalary, totalDaysAbsent, month, year,
salaryAmount, salaryStatus, enrollmentId, groupId, wageId); salaryAmount, salaryStatus, enrollmentId, groupId, wageId);
} }
////
// public int addSalaryDetails_park(int totalDaysPresent, int totalDaysOd, int totalDaysSalary, int totalDaysAbsent,
// String month, int year, int salaryAmount,
// String salaryStatus, int enrollmentId, int groupId, int wageId)
// {
// String sql = "INSERT INTO salary_details_park (total_days_present, total_days_od, total_days_salary, total_days_absent, month, year, salary_amount, salary_status, enrollment_id, group_id, wage_id) "
// +
// "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
//
// return jdbcTemplate.update(sql, totalDaysPresent, totalDaysOd, totalDaysSalary, totalDaysAbsent, month, year,
// salaryAmount, salaryStatus, enrollmentId, groupId, wageId);
// }
////
public List<Map<String, Object>> getAttendanceWithSalary(String month, Integer year) { public List<Map<String, Object>> getAttendanceWithSalary(String month, Integer year) {
StringBuilder sql = new StringBuilder("SELECT " + StringBuilder sql = new StringBuilder("SELECT " +
@ -887,6 +905,94 @@ public class NulmService {
List<Map<String, Object>> results = jdbcTemplate.queryForList(sql.toString(), params.toArray()); List<Map<String, Object>> results = jdbcTemplate.queryForList(sql.toString(), params.toArray());
return results; return results;
} }
///
public List<Map<String, Object>> getSalaryReport_park(String month, Integer year, String salaryStatus, String groupName,
String loginId) {
// Retrieve zone access for the user
String ZoneWhare = "";
String zoneAccessSQL = "SELECT zone FROM gcc_apps.login_mapping_user WHERE appuser_id = ?";
List<Map<String, Object>> getAccess = jdbcTemplate.queryForList(zoneAccessSQL, loginId);
System.out.println(zoneAccessSQL + "->" + loginId);
/*
* // Extract the zones from getAccess
* List<String> zones = getAccess.stream()
* .map(access -> (String) access.get("zone"))
* .filter(Objects::nonNull)
* .collect(Collectors.toList());
*/
// Extract the zones from getAccess
List<String> zones = new ArrayList<String>();
if (getAccess != null) {
for (Map<String, Object> access : getAccess) {
Object zoneObj = access.get("zone");
if (zoneObj != null) {
zones.add(zoneObj.toString());
}
}
}
/*
* // If the user has zone access, add it to the WHERE clause
* if (!zones.isEmpty()) {
* String zoneList = zones.stream()
* .map(zone -> "'" + zone + "'")
* .collect(Collectors.joining(", "));
* ZoneWhare = " AND en.zone IN ("+zoneList+")";
* }
* else {
* ZoneWhare = " AND en.zone IN (0)";
* }
*/
// If the user has zone access, add it to the WHERE clause
// String ZoneWhare = "";
if (zones != null && !zones.isEmpty()) {
StringBuilder zoneListBuilder = new StringBuilder();
for (int i = 0; i < zones.size(); i++) {
zoneListBuilder.append("'").append(zones.get(i)).append("'");
if (i < zones.size() - 1) {
zoneListBuilder.append(", ");
}
}
ZoneWhare = " AND en.zone IN (" + zoneListBuilder.toString() + ")";
} else {
ZoneWhare = " AND en.zone IN (0)";
}
String sql = "select en.emp_id, en.name, en.incharge_name, en.designation, en.incharge_designation, sk.group_name, s.total_days_present, s.total_days_od, "
+ "s.total_days_absent, s.total_days_salary, s.month as imonth,s.year as iyear, s.salary_status, s.salary_amount as total_salary, "
+ "DAY(LAST_DAY(STR_TO_DATE(CONCAT(s.year, '-', s.month, '-01'), '%Y-%M-%d'))) AS total_days from salary_details_park s "
+ "left join enrollment_table en on s.enrollment_id = en.enrollment_id "
+ "left join suyaudavi_kuzhu sk on s.group_id = sk.group_id "
+ "where s.month = ? and s.year =? "
+ "AND (s.salary_status = 'Initiated' OR s.salary_status = 'Approved') "
+ (salaryStatus != null && !salaryStatus.isEmpty() ? "AND s.salary_status = ? " : "")
+ (groupName != null && !groupName.isEmpty() ? "AND sk.group_name = ? " : "")
+ ZoneWhare;
// Prepare the query parameters based on provided inputs
List<Object> params = new ArrayList<>();
params.add(month);
params.add(year);
if (salaryStatus != null && !salaryStatus.isEmpty()) {
params.add(salaryStatus);
}
if (groupName != null && !groupName.isEmpty()) {
params.add(groupName);
}
List<Map<String, Object>> results = jdbcTemplate.queryForList(sql.toString(), params.toArray());
return results;
}
///
/* /*
* public List<Map<String, Object>> getSalaryReport(String month, Integer year, * public List<Map<String, Object>> getSalaryReport(String month, Integer year,
* String salaryStatus, String groupName) { * String salaryStatus, String groupName) {
@ -1334,6 +1440,46 @@ public class NulmService {
* return results; * return results;
* } * }
*/ */
/////
public boolean checkSalaryDetails_park(int enrollmentId, String month, int year) {
String sql = "select enrollment_id from salary_details_park where enrollment_id =? and month = ? and year = ?";
List<Integer> results = jdbcTemplate.queryForList(sql, Integer.class, enrollmentId, month, year);
return !results.isEmpty();
}
public int addSalaryDetails_park(
int totalDaysPresent, int totalDaysOd, int totalDaysSalary, int totalDaysAbsent,
String month, int year, int salaryAmount,
String salaryStatus, int enrollmentId, int groupId, int wageId, int inchargeID) {
String sql = "INSERT INTO salary_details_park (total_days_present, total_days_od, total_days_salary, total_days_absent, month, year, "
+ "salary_amount, salary_status, enrollment_id, group_id, wage_id, incharge_id) "
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
return jdbcTemplate.update(sql, totalDaysPresent, totalDaysOd, totalDaysSalary, totalDaysAbsent, month, year,
salaryAmount, salaryStatus, enrollmentId, groupId, wageId, inchargeID);
}
public int updateSalaryDetails_park(
int totalDaysPresent, int totalDaysOd, int totalDaysSalary,
int totalDaysAbsent, String month, int year, int salaryAmount,
String salaryStatus, int enrollmentId, int groupId,
int wageId, int inchargeID) {
String sql = "update salary_details_park set total_days_present =?, total_days_od=?, total_days_salary = ? , total_days_absent = ?, month = ?, year = ?, "
+ "salary_amount = ?, salary_status = ?, enrollment_id = ?, group_id= ?, wage_id= ?, incharge_id = ? where enrollment_id =? and month = ? and year = ? ";
return jdbcTemplate.update(sql, totalDaysPresent, totalDaysOd, totalDaysSalary, totalDaysAbsent, month, year,
salaryAmount, salaryStatus, enrollmentId, groupId, wageId, inchargeID, enrollmentId, month, year);
}
/////
public List<Map<String, Object>> getAttendanceWithInitiatedSalary( public List<Map<String, Object>> getAttendanceWithInitiatedSalary(
int inchargeId, String month, String year, String inchargeName, List<Integer> enrollmentIds) { int inchargeId, String month, String year, String inchargeName, List<Integer> enrollmentIds) {
@ -1368,7 +1514,8 @@ public class NulmService {
"AND s.year = YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) " + "AND s.year = YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) " +
"WHERE (a.inby IS NOT NULL OR a.leaveby IS NOT NULL OR a.odby IS NOT NULL) " + "WHERE (a.inby IS NOT NULL OR a.leaveby IS NOT NULL OR a.odby IS NOT NULL) " +
"AND (? IS NULL OR e.incharge_id = ?) " + "AND (? IS NULL OR e.incharge_id = ?) " +
"AND (? IS NULL OR e.incharge_name = ?) ";
"AND (? IS NULL OR e.incharge_name = ?) "+
"AND e.emp_type = 'NULM' ";
if (month != null && !month.isEmpty()) { if (month != null && !month.isEmpty()) {
sql += "AND MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) = ? "; sql += "AND MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) = ? ";
@ -1419,6 +1566,97 @@ public class NulmService {
return jdbcTemplate.queryForList(sql, params.toArray()); return jdbcTemplate.queryForList(sql, params.toArray());
} }
///
public List<Map<String, Object>> getAttendanceWithInitiatedSalary_Park(
int inchargeId, String month, String year, String inchargeName, List<Integer> enrollmentIds) {
String sql = "SELECT " +
"e.group_id, " +
"(SELECT group_name FROM suyaudavi_kuzhu WHERE suyaudavi_kuzhu.group_id = e.group_id LIMIT 1) AS group_name, "
+
"a.enrollment_id, e.emp_id, e.name, e.incharge_id, " +
"(SELECT salary_per_day FROM staff_wages_park WHERE isactive = 1 AND e.designation_id = staff_wages_park.designation_id) AS salary_per_day, "
+
"(SELECT wage_id FROM staff_wages_park WHERE isactive = 1 AND e.designation_id = staff_wages_park.designation_id) AS wage_id, " +
"YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) AS year, " +
"MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) AS month, " +
"DAY(LAST_DAY(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime))) AS total_days, " +
"COUNT(DISTINCT DATE(a.indatetime)) AS total_days_present, " +
"COUNT(DISTINCT CASE WHEN a.indatetime IS NULL THEN DATE(a.oddatetime) END) AS total_days_od, " +
"COUNT(DISTINCT DATE(a.indatetime)) + COUNT(DISTINCT CASE WHEN a.indatetime IS NULL THEN DATE(a.oddatetime) END) AS total_days_salary, "
+
"((COUNT(DISTINCT DATE(a.indatetime)) + COUNT(DISTINCT CASE WHEN a.indatetime IS NULL THEN DATE(a.oddatetime) END)) * "
+
"(SELECT salary_per_day FROM staff_wages WHERE isactive = 1 ORDER BY wage_id DESC LIMIT 1)) AS total_salary, "
+
"(MAX(DAY(LAST_DAY(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)))) - " +
"(COUNT(DISTINCT DATE(a.indatetime)) + COUNT(DISTINCT CASE WHEN a.indatetime IS NULL THEN DATE(a.oddatetime) END))) AS total_days_absent, "
+
"IFNULL(s.salary_status, '') AS salary_status " +
"FROM attendance AS a " +
"INNER JOIN enrollment_table AS e ON a.enrollment_id = e.enrollment_id " +
"LEFT JOIN salary_details_park AS s ON a.enrollment_id = s.enrollment_id " +
"AND s.month = MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) " +
"AND s.year = YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) " +
"WHERE (a.inby IS NOT NULL OR a.leaveby IS NOT NULL OR a.odby IS NOT NULL) " +
"AND (? IS NULL OR e.incharge_id = ?) " +
"AND (? IS NULL OR e.incharge_name = ?) "+
"AND e.emp_type = 'Park' " ;
if (month != null && !month.isEmpty()) {
sql += "AND MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) = ? ";
}
if (year != null && !year.isEmpty()) {
sql += "AND YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) = ? ";
}
// Assuming enrollmentIds is a List<String> or List<Integer>
StringBuilder placeholders = new StringBuilder();
for (int i = 0; i < enrollmentIds.size(); i++) {
placeholders.append("?");
if (i < enrollmentIds.size() - 1) {
placeholders.append(", ");
}
}
String inClause = placeholders.toString() + ") ";
sql += "AND IFNULL(s.salary_status, '') IN ('Initiated', 'Approved') " +
"AND e.enrollment_id IN (" +
inClause +
"GROUP BY a.enrollment_id, e.group_id, " +
"YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)), " +
"MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)), " +
"(SELECT salary_per_day FROM staff_wages_park WHERE isactive = 1 AND e.designation_id = staff_wages_park.designation_id), " +
"(SELECT wage_id FROM staff_wages_park WHERE isactive = 1 AND e.designation_id = staff_wages_park.designation_id), " +
"(SELECT group_name FROM suyaudavi_kuzhu WHERE suyaudavi_kuzhu.group_id = e.group_id LIMIT 1), " +
"DAY(LAST_DAY(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime))), " +
"s.salary_status";
List<Object> params = new ArrayList<>();
params.add(inchargeId);
params.add(inchargeId);
params.add(inchargeName);
params.add(inchargeName);
if (month != null && !month.isEmpty()) {
params.add(month);
}
if (year != null && !year.isEmpty()) {
params.add(year);
}
params.addAll(enrollmentIds);
System.out.println("SQL = " + sql);
System.out.println("Parameter = " + params);
return jdbcTemplate.queryForList(sql, params.toArray());
}
////
@Transactional @Transactional
public void updateSalaryStatusToApproved(List<Integer> enrollmentIds, String month, int year) { public void updateSalaryStatusToApproved(List<Integer> enrollmentIds, String month, int year) {
@ -1429,6 +1667,22 @@ public class NulmService {
jdbcTemplate.update(sql, enrollmentId, month, year); jdbcTemplate.update(sql, enrollmentId, month, year);
} }
} }
////
@Transactional
public void updateSalaryStatusToApproved_Park(List<Integer> enrollmentIds, String month, int year) {
String sql = "UPDATE salary_details_park SET salary_status = 'Approved' WHERE enrollment_id = ? AND month = ? AND year = ?";
for (Integer enrollmentId : enrollmentIds) {
// Pass the individual enrollmentId instead of the entire list
jdbcTemplate.update(sql, enrollmentId, month, year);
}
}
////
/* /*
* public List<Map<String, Object>> getFilteredSalaryDetails(String month, * public List<Map<String, Object>> getFilteredSalaryDetails(String month,
* Integer year, String salaryStatus) { * Integer year, String salaryStatus) {
@ -1588,7 +1842,7 @@ public class NulmService {
"e.department " + // Select the department as well "e.department " + // Select the department as well
"FROM enrollment_table e " + "FROM enrollment_table e " +
"JOIN salary_details sd ON e.enrollment_id = sd.enrollment_id " + "JOIN salary_details sd ON e.enrollment_id = sd.enrollment_id " +
"WHERE 1=1 "); // Placeholder for dynamic conditions
"WHERE 1=1 AND e.emp_type = 'NULM' "); // Placeholder for dynamic conditions
// Add filters for month, year, salary status, and department // Add filters for month, year, salary status, and department
if (month != null && !month.isEmpty()) { if (month != null && !month.isEmpty()) {
@ -1700,17 +1954,155 @@ public class NulmService {
} }
} }
////
public List<Map<String, Object>> getFilteredSalaryDetails_park(String month, Integer year, String salaryStatus,
String loginId) {
StringBuilder sql = new StringBuilder("SELECT " +
"e.incharge_name, " +
"e.incharge_id, " +
"e.zone, " +
"GROUP_CONCAT(e.enrollment_id) AS enrollment_ids, " +
"COUNT(e.enrollment_id) AS total_staff_count, " +
"sd.month, " +
"sd.year, " +
"sd.salary_status, " +
"COUNT(CASE WHEN sd.salary_status = 'Initiated' THEN 1 END) AS total_initiated_count, " +
"COUNT(CASE WHEN sd.salary_status = 'Approved' THEN 1 END) AS total_approved_count, " +
"SUM(CASE WHEN sd.salary_status IN ('Initiated', 'Approved') THEN sd.salary_amount ELSE 0 END) AS total_salary_amount, "
+
"e.department " + // Select the department as well
"FROM enrollment_table e " +
"JOIN salary_details_park sd ON e.enrollment_id = sd.enrollment_id " +
"WHERE 1=1 AND e.emp_type = 'Park' "); // Placeholder for dynamic conditions
// Add filters for month, year, salary status, and department
if (month != null && !month.isEmpty()) {
sql.append(" AND sd.month = '").append(month).append("'");
}
if (year != null) {
sql.append(" AND sd.year = ").append(year);
}
if (salaryStatus != null && !salaryStatus.isEmpty()) {
sql.append(" AND sd.salary_status = '").append(salaryStatus).append("'");
}
// Retrieve zone access for the user
String zoneAccessSQL = "SELECT zone FROM gcc_apps.login_mapping_user WHERE appuser_id = ?";
List<Map<String, Object>> getAccess = jdbcTemplate.queryForList(zoneAccessSQL, loginId);
System.out.println(zoneAccessSQL + "->" + loginId);
// Extract the zones from getAccess
/*
* List<String> zones = getAccess.stream()
* .map(access -> (String) access.get("zone"))
* .filter(Objects::nonNull)
* .collect(Collectors.toList());
*
* // If the user has zone acc ess, add it to the WHERE clause
* if (!zones.isEmpty()) {
* String zoneList = zones.stream()
* .map(zone -> "'" + zone + "'")
* .collect(Collectors.joining(", "));
* sql.append(" AND e.zone IN (").append(zoneList).append(")");
* // System.out.println("AND e.zone IN ("+zoneList+")");
* }
* else {
* sql.append(" AND e.zone IN (").append("0").append(")");
* }
*/
// Extract zones from getAccess
List<String> zones = new ArrayList<String>();
for (Map<String, Object> access : getAccess) {
Object zoneObj = access.get("zone");
if (zoneObj != null) {
zones.add(zoneObj.toString());
}
}
// If the user has zone access, add it to the WHERE clause
if (!zones.isEmpty()) {
StringBuilder zoneList = new StringBuilder();
for (int i = 0; i < zones.size(); i++) {
zoneList.append("'").append(zones.get(i)).append("'");
if (i < zones.size() - 1) {
zoneList.append(", ");
}
}
sql.append(" AND e.zone IN (").append(zoneList.toString()).append(")");
} else {
sql.append(" AND e.zone IN (0)");
}
sql.append(
" GROUP BY e.incharge_name, e.incharge_id, e.zone, sd.month, sd.year, sd.salary_status, e.department ");
sql.append(" ORDER BY sd.year DESC, sd.month DESC");
/*
* try {
* List<Map<String, Object>> result = jdbcTemplate.queryForList(sql.toString());
* for (Map<String, Object> row : result) {
* String enrollmentIdsString = (String) row.get("enrollment_ids");
* if (enrollmentIdsString != null) {
* List<Integer> enrollmentIds = Arrays.stream(enrollmentIdsString.split(","))
* .map(String::trim)
* .filter(id -> !id.isEmpty())
* .map(Integer::parseInt)
* .collect(Collectors.toList());
* row.put("enrollment_ids", enrollmentIds);
* }
* }
* return result;
* } catch (Exception e) {
* e.printStackTrace();
* return Collections.emptyList();
* }
*/
try {
List<Map<String, Object>> result = jdbcTemplate.queryForList(sql.toString());
for (Map<String, Object> row : result) {
String enrollmentIdsString = (String) row.get("enrollment_ids");
if (enrollmentIdsString != null) {
String[] parts = enrollmentIdsString.split(",");
List<Integer> enrollmentIds = new ArrayList<Integer>();
for (int i = 0; i < parts.length; i++) {
String part = parts[i].trim();
if (!part.isEmpty()) {
try {
enrollmentIds.add(Integer.parseInt(part));
} catch (NumberFormatException nfe) {
// Ignore or log invalid integers
nfe.printStackTrace();
}
}
}
row.put("enrollment_ids", enrollmentIds);
}
}
return result;
} catch (Exception e) {
e.printStackTrace();
return Collections.emptyList();
}
public Integer checkInchargeID(Integer inchargeId) {
String sql = "SELECT EXISTS( " +
"SELECT 1 FROM additional_incharge " +
"WHERE incharge_id = ? AND is_active = 1 AND is_delete = 0)";
Integer result = jdbcTemplate.queryForObject(sql, Integer.class, inchargeId);
return result;
} }
////
// public Integer checkInchargeID(Integer inchargeId) {
//
// String sql = "SELECT EXISTS( " +
// "SELECT 1 FROM additional_incharge " +
// "WHERE incharge_id = ? AND is_active = 1 AND is_delete = 0)";
//
// Integer result = jdbcTemplate.queryForObject(sql, Integer.class, inchargeId);
//
// return result;
// }
public List<Map<String, Object>> getAttendanceWithSalaryByInchargeId(String month, Integer year, public List<Map<String, Object>> getAttendanceWithSalaryByInchargeId(String month, Integer year,
Integer incharge_id) { Integer incharge_id) {
@ -1749,7 +2141,7 @@ public class NulmService {
"LEFT JOIN salary_details AS s ON a.enrollment_id = s.enrollment_id " + "LEFT JOIN salary_details AS s ON a.enrollment_id = s.enrollment_id " +
"AND s.month = MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) " + "AND s.month = MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) " +
"AND s.year = YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) " + "AND s.year = YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) " +
"WHERE (a.inby IS NOT NULL OR a.leaveby IS NOT NULL OR a.odby IS NOT NULL) ");
"WHERE (a.inby IS NOT NULL OR a.leaveby IS NOT NULL OR a.odby IS NOT NULL) AND e.emp_type = 'NULM' ");
// Append condition for incharge_id // Append condition for incharge_id
sql.append("AND (? IS NULL OR e.incharge_id = ?) "); sql.append("AND (? IS NULL OR e.incharge_id = ?) ");
@ -1797,6 +2189,135 @@ public class NulmService {
List<Map<String, Object>> results = jdbcTemplate.queryForList(sql.toString(), params.toArray()); List<Map<String, Object>> results = jdbcTemplate.queryForList(sql.toString(), params.toArray());
return results; return results;
} }
///
public List<Map<String, Object>> getAttendanceWithSalaryByInchargeId_New(String month, Integer year,
Integer incharge_id, String type, String ids)
{
List<Map<String, Object>> results = new ArrayList<>();
if(type.equalsIgnoreCase("1")){
results = getAttendanceWithSalaryByInchargeId(month,year, incharge_id);
}
else
{
StringBuilder sql = new StringBuilder("SELECT " +
"e.group_id, " +
"(SELECT group_name FROM suyaudavi_kuzhu WHERE suyaudavi_kuzhu.group_id = e.group_id LIMIT 1) AS group_name, "
+
"a.enrollment_id, " +
"e.emp_id, " +
"e.name, " +
"e.incharge_id, " +
"e.incharge_name, " +
"(SELECT salary_per_day FROM staff_wages_park WHERE isactive = 1 AND e.designation_id = staff_wages_park.designation_id) AS salary_per_day, "
+
"(SELECT wage_id FROM staff_wages_park WHERE isactive = 1 AND e.designation_id = staff_wages_park.designation_id) AS wage_id, " +
"YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) AS year, " +
"MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) AS month, " +
"DAY(LAST_DAY(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime))) AS total_days, " +
"COUNT(DISTINCT DATE(a.indatetime)) AS total_days_present, " +
// Subquery to get total_days_od
"(SELECT COUNT(DISTINCT DATE(a2.oddatetime)) " +
" FROM attendance AS a2 " +
" WHERE MONTHNAME(a2.oddatetime) = ? " + // Use placeholder for month
" AND YEAR(a2.oddatetime) = ? " + // Use placeholder for year
" AND a2.enrollment_id = a.enrollment_id " +
" AND DATE(a2.oddatetime) NOT IN ( " +
" SELECT DISTINCT DATE(a3.indatetime) " +
" FROM attendance AS a3 " +
" WHERE MONTHNAME(a3.indatetime) = ? " + // Use placeholder for month
" AND YEAR(a3.indatetime) = ? " + // Use placeholder for year
" AND a3.enrollment_id = a.enrollment_id " +
")) AS total_days_od, " +
"IFNULL(s.salary_status, '') AS salary_status " +
"FROM attendance AS a " +
"INNER JOIN enrollment_table AS e ON a.enrollment_id = e.enrollment_id " +
"LEFT JOIN salary_details_park AS s ON a.enrollment_id = s.enrollment_id " +
"AND s.month = MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) " +
"AND s.year = YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) " +
"WHERE (a.inby IS NOT NULL OR a.leaveby IS NOT NULL OR a.odby IS NOT NULL) AND e.emp_type = 'Park' ");
List<Object> params = new ArrayList<>();
params.add(month); // Add month for total_days_od
params.add(year); // Add year for total_days_od
params.add(month); // Add month for the inner subquery
params.add(year); // Add year for the inner subquery
// Append condition for incharge_id
//sql.append("AND (? IS NULL OR e.incharge_id = ?) ");
if (ids != null && !ids.trim().isEmpty()) {
List<Integer> idList = Arrays.stream(ids.split(","))
.map(String::trim)
.map(Integer::parseInt)
.toList();
String placeholders = idList.stream()
.map(i -> "?")
.collect(Collectors.joining(","));
System.out.println("placeholders = "+placeholders);
sql.append(" AND e.incharge_id IN (").append(placeholders).append(") ");
System.out.println("idList = "+idList);
params.addAll(idList);
}
// Append condition for month if provided
if (month != null && !month.isEmpty()) {
sql.append("AND MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) = ? ");
params.add(month);
}
// Append condition for year if provided
if (year != null) {
sql.append("AND YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) = ? ");
params.add(year);
}
// Group by necessary columns
sql.append("GROUP BY a.enrollment_id, e.group_id, " +
"YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)), " +
"MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)), " +
"(SELECT salary_per_day FROM staff_wages_park WHERE isactive = 1 AND e.designation_id = staff_wages_park.designation_id), " +
"(SELECT wage_id FROM staff_wages_park WHERE isactive = 1 AND e.designation_id = staff_wages_park.designation_id), " +
"(SELECT group_name FROM suyaudavi_kuzhu WHERE suyaudavi_kuzhu.group_id = e.group_id LIMIT 1), " +
"DAY(LAST_DAY(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime))), " +
"s.salary_status");
System.out.println("Query = " + sql);
// Create a list of parameters
//params.add(incharge_id);
//params.add(incharge_id); // Added twice for the conditional check in the SQL
//if (month != null && !month.isEmpty()) {
//params.add(month);
//}
//if (year != null) {
//params.add(year);
//}
// Log the SQL and parameters (optional for debugging)
System.out.println("Generated SQL: " + sql.toString());
System.out.println("Parameters: " + params);
// Execute the query using JdbcTemplate
results = jdbcTemplate.queryForList(sql.toString(), params.toArray());
}
return results;
}
////
public List<Map<String, Object>> getZoneWiseReport(String month, Integer year, String salaryStatus, public List<Map<String, Object>> getZoneWiseReport(String month, Integer year, String salaryStatus,
String groupName, String zone, String division) { String groupName, String zone, String division) {
@ -2256,4 +2777,26 @@ public class NulmService {
return jdbcTemplate.update(sql, totalDaysPresent, totalDaysOd, totalDaysSalary, totalDaysAbsent, month, year, return jdbcTemplate.update(sql, totalDaysPresent, totalDaysOd, totalDaysSalary, totalDaysAbsent, month, year,
salaryAmount, salaryStatus, enrollmentId, groupId, wageId, inchargeID, enrollmentId, month, year); salaryAmount, salaryStatus, enrollmentId, groupId, wageId, inchargeID, enrollmentId, month, year);
} }
public String checkInchargeID(Integer inchargeId) {
String sql = "SELECT " +
" CONCAT_WS( " +
" ',', " +
" GROUP_CONCAT(DISTINCT " +
" TRIM(SUBSTRING_INDEX(additional_id, ',', 1)) " +
" ), " +
" incharge_id " +
" ) AS final_ids " +
" FROM gcc_nulm.additional_incharge " +
" WHERE incharge_id = ? " +
" AND is_active = 1 " +
" AND is_delete = 0 " +
" GROUP BY incharge_id ";
String result = jdbcTemplate.queryForObject(sql, String.class, inchargeId);
return result;
}
} }

4
gcc_officer_portal/src/main/resources/application.properties

@ -1,5 +1,5 @@
# spring.profiles.active=local
spring.profiles.active=production
spring.profiles.active=local
#spring.profiles.active=production
#For Server production #For Server production
#assets.base-url=/gcc/assets/ #assets.base-url=/gcc/assets/
#For local test #For local test

394
gcc_officer_portal/src/main/resources/templates/modules/nulm/salary-approve-park.html

@ -0,0 +1,394 @@
<!DOCTYPE html>
<html>
<head th:replace="~{fragments/modules/base/head :: head}">
<!-- Include Bootstrap CSS for styling the modal -->
<link th:href="@{/css/bootstrap.min.css}" rel="stylesheet">
</head>
<body>
<div class="wrapper">
<header th:replace="~{fragments/modules/base/header :: header}"></header>
<div class="page-wrap">
<div th:replace="~{fragments/modules/base/menu :: menu}"></div>
<div class="main-content">
<div class="container-fluid">
<div class="page-header">
<div class="row align-items-end">
<div class="col-lg-6">
<div class="page-header-title">
<i class="ik ik-thumbs-up bg-blue"></i>
<div class="d-inline">
<h5>Park STAFF</h5>
<span>Salary Approval</span>
</div>
</div>
</div>
<div class="col-lg-6">
<nav class="breadcrumb-container" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="/index"><i class="ik ik-home"></i></a>
</li>
<li class="breadcrumb-item active" aria-current="page">Park Salary Approval</li>
</ol>
</nav>
</div>
</div>
</div>
<hr>
<div class="row">
<div class="col-sm-3">
<label for="month">Month:</label>
<select id="month" class="form-control" required>
<option value="">Select</option>
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>
</div>
<div class="col-sm-3">
<label for="year">Year:</label>
<input type="number" id="year" class="form-control" min="2000" max="2100" required>
</div>
<div class="col-sm-3">
<label for="salaryStatus">Salary Status:</label>
<select id="salaryStatus" class="form-control">
<option value="">Select</option>
<option value="Initiated">Initiated</option>
<option value="Approved">Approved</option>
</select>
</div>
<div class="col-sm-3">
<button class="btn btn-primary mt-4" onclick="fetchSalaryReport()">Get Salary Info</button>
</div>
</div>
<div class="card-block mt-4">
<div>
<table id="salaryDatatable" class="table table-striped table-bordered table-hover dataTable" role="grid" width="99.5%">
<thead class="thead-dark">
<tr role="row">
<th>S.No</th>
<th>Incharge Name</th>
<th>Total Staff Count</th>
<th>Salary Processed</th>
<th>Total Salary Amount</th>
<th>Salary Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr th:each="salaryInitiatedCounts, i : ${salaryInitiatedCounts}">
<td th:text="${i.count}">0</td>
<td th:text="${salaryInitiatedCounts.incharge_name}"></td>
<!-- Make the Total Staff Count clickable -->
<td>
<a href="#" class="total-staff-count"
th:data-incharge-id="${salaryInitiatedCounts.incharge_id}"
th:data-month="${salaryInitiatedCounts.month}"
th:data-year="${salaryInitiatedCounts.year}"
th:data-incharge-name="${salaryInitiatedCounts.incharge_name}"
th:data-zone="${salaryInitiatedCounts.zone}"
th:data-enrollment-ids="${salaryInitiatedCounts.enrollment_ids}"
th:text="${salaryInitiatedCounts.total_staff_count}"
data-toggle="modal" data-target="#shgModal">
</a>
</td>
<td th:text="${salaryInitiatedCounts.total_approved_count}"></td>
<td th:text="${salaryInitiatedCounts.total_salary_amount}"></td>
<td th:text="${salaryInitiatedCounts.salary_status}"></td>
<td>
<span th:if="${salaryInitiatedCounts.salary_status == 'Approved'}" class="badge badge-success">Approved</span>
<button th:if="${salaryInitiatedCounts.salary_status == 'Initiated'}"
class="btn btn-primary approve-btn"
th:data-enrollment-ids="${salaryInitiatedCounts.enrollment_ids}"
th:data-month="${salaryInitiatedCounts.month}"
th:data-year="${salaryInitiatedCounts.year}">
Approve
</button>
</td>
</tr>
</tbody>
<tfoot class="thead-dark">
<tr>
<th>S.No</th>
<th>Incharge Name</th>
<th>Total Staff Count</th>
<th>Salary Processed</th>
<th>Total Salary Amount</th>
<th>Salary Status</th>
<th>Action</th>
</tr>
</tfoot>
</table>
</div>
</div>
<!-- Modal for displaying staff details -->
<div class="modal fade" id="shgModal" tabindex="-1" role="dialog" aria-labelledby="shgModalLabel" aria-hidden="true">
<div class="modal-dialog modal-xl" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="shgModalLabel">Staff Details</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<!-- Table for displaying attendance details -->
<div id="attendanceDetailsContainer">
<h5>Attendance Details</h5>
<table class="table table-striped">
<thead>
<tr>
<th>S.No</th>
<th>Employee ID</th>
<th>Name</th>
<th>Year</th>
<th>Month</th>
<th>Total Days Present</th>
<th>Total Days Absent</th>
<th>Total Days OD</th>
<th>Total Days Salary</th>
<th>Total Salary</th>
<th>Salary Status</th>
</tr>
</thead>
<tbody id="attendanceDetailsTableBody">
<!-- Dynamic content will be loaded here -->
</tbody>
</table>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</div>
<footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
<div th:replace="~{fragments/modules/pgr/modal-box :: div}"></div>
<script th:replace="~{fragments/modules/base/script :: script}"></script>
<script th:replace="~{fragments/modules/pgr/script :: script}"></script>
<script th:inline="javascript">
function fetchSalaryReport() {
const month = document.getElementById('month').value;
const year = document.getElementById('year').value;
const salaryStatus = document.getElementById('salaryStatus').value;
if (month && year) {
window.location.href = `/gcc/nulm/salary-approve-park?month=${month}&year=${year}&salaryStatus=${salaryStatus}`;
} else {
alert("Please select both month and year.");
}
}
$(document).ready(function () {
function clearUrlParams() {
const currentUrl = window.location.href;
const urlWithoutParams = currentUrl.split('?')[0]; // Remove the query parameters
window.history.replaceState({}, document.title, urlWithoutParams); // Replace the current URL without params
}
// Call this on page load to reset the URL
clearUrlParams();
// Initialize DataTable
var table = $('#salaryDatatable').DataTable({
dom: 'Bftip',
columnDefs: [
{ targets: 'no-sort', orderable: false }
],
lengthMenu: [
[50, 100, 200, 500, -1],
['50 rows', '100 rows', '200 rows', 'Show all']
],
scrollY: '50vh',
fixedColumns: {
left: 1,
right: 1
},
buttons: [
{
extend: 'pageLength',
className: 'btn btn-warning'
},
{
title: 'Data export',
extend: 'copyHtml5',
text: 'Copy',
className: 'btn btn-secondary',
id: 'copyBtn',
columns: [0,1,2,3,4,5]
},
{
extend: 'pdfHtml5',
text: 'PDF',
className: 'btn btn-secondary',
id: 'pdfBtn',
exportOptions: {
columns: [0, 1, 2, 3, 4, 5]
}
},
/*
{
extend: 'excelHtml5',
text: 'EXCEL',
className: 'btn btn-secondary',
id: 'excelBtn'
},
{
extend: 'csvHtml5',
text: 'CSV',
className: 'btn btn-secondary',
id: 'csvBtn'
}*/
],
fixedHeader: true,
autoWidth: true,
responsive: true,
searching: true,
select: false,
processing: false
});
// Handle total-staff-count click event
$('.total-staff-count').on('click', function (event) {
event.preventDefault(); // Prevent default anchor click behavior
// Get inchargeName and month from the clicked element's data attributes
// var inchargeName = $(this).data('incharge-name');
var inchargeId = $(this).data('incharge-id')
var month = $(this).data('month')
var year = $(this).data('year')
var inchargeName = $(this).data('incharge-name')
var zone = $(this).data('zone');
var enrollmentIds = $(this).data('enrollment-ids');
console.log(zone);
console.log(inchargeName);
// Make the AJAX call to fetch attendance details
$.ajax({
url: '/gcc/api/nulm/staffInititeadList-park',
method: 'GET',
data: {
//inchargeName: inchargeName,
inchargeId: inchargeId,
month: month,
year: year,
inchargeName: inchargeName,
enrollmentIds: enrollmentIds.join(',')
},
success: function (data) {
// Populate the modal's table with the fetched data
var tbody = $('#attendanceDetailsTableBody');
tbody.empty(); // Clear any previous data
// Loop through the data and append rows to the table
$.each(data, function (index, item) {
var row = `<tr>
<td>${index + 1}</td>
<td>${item.emp_id}</td>
<td>${item.name}</td>
<td>${item.year}</td>
<td>${item.month}</td>
<td>${item.total_days_present}</td>
<td>${item.total_days_absent}</td>
<td>${item.total_days_od}</td>
<td>${item.total_days_salary}</td>
<td>${item.total_salary}</td>
<td>${item.salary_status}</td>
</tr>`;
tbody.append(row);
});
// Show the modal after data is populated
$('#shgModal').modal('show');
},
error: function (xhr, status, error) {
console.error('Failed to fetch data:', error);
alert('Failed to load staff details. Please try again.');
}
});
});
$(document).on('click', '.approve-btn', function () {
var enrollmentIds = $(this).data('enrollment-ids'); // Get the data attribute
var month = $(this).data('month');
var year = $(this).data('year');
// Confirm the action with SweetAlert
Swal.fire({
title: 'Are you sure?',
text: 'Do you want to approve the selected enrollments?',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, approve it!'
}).then((result) => {
if (result.isConfirmed) {
// Make the AJAX call
$.ajax({
url: '/gcc/api/nulm/update-salary-status-park',
method: 'POST',
contentType: 'application/x-www-form-urlencoded',
data: {
// Pass the enrollment IDs as a comma-separated string
enrollmentIds: enrollmentIds.join(','), // Convert array to a comma-separated string
month: month,
year: year
},
success: function (response) {
Swal.fire(
'Approved!',
response,
'success'
);
// Optionally refresh the table or update the UI
location.reload();
},
error: function (xhr, status, error) {
console.error('Failed to approve:', error);
Swal.fire(
'Error!',
'Failed to approve the selected enrollments. Please try again.',
'error'
);
}
});
}
});
});
});
</script>
</div>
</div>
</body>
</html>

4
gcc_officer_portal/src/main/resources/templates/modules/nulm/salary-approve.html

@ -183,9 +183,11 @@
</div> </div>
</div> </div>
<footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
</div> </div>
</div> </div>
<footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
<div th:replace="~{fragments/modules/pgr/modal-box :: div}"></div> <div th:replace="~{fragments/modules/pgr/modal-box :: div}"></div>

274
gcc_officer_portal/src/main/resources/templates/modules/nulm/salary-report-park.html

@ -0,0 +1,274 @@
<!DOCTYPE html>
<html lang="en" dir="">
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{fragments/modules/base/head :: head}"></head>
<body>
<div class="wrapper">
<header th:replace="~{fragments/modules/base/header :: header}"></header>
<div class="page-wrap">
<div th:replace="~{fragments/modules/base/menu :: menu}"></div>
<div class="main-content">
<div class="container-fluid">
<div class="page-header">
<div class="row align-items-end">
<div class="col-lg-6">
<div class="page-header-title">
<i class="ik ik-thumbs-up bg-blue"></i>
<div class="d-inline">
<h5>Park STAFF</h5>
<span>Salary Report</span>
</div>
</div>
</div>
<div class="col-lg-6">
<nav class="breadcrumb-container" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="/index"><i class="ik ik-home"></i></a>
</li>
<li class="breadcrumb-item active" aria-current="page">Salary Report Park</li>
</ol>
</nav>
</div>
</div>
</div>
<hr>
<!-- Filters Section -->
<div class="row">
<div class="col-sm-3">
<label for="month">Month:</label>
<select id="month" class="form-control" required>
<option value="">Select</option>
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>
</div>
<div class="col-sm-3">
<label for="year">Year:</label>
<input type="number" id="year" class="form-control" min="2000" max="2100" required>
</div>
<div class="col-sm-3">
<label for="salaryStatus">Salary Status:</label>
<select id="salaryStatus" class="form-control">
<option value="">Select</option>
<option value="Initiated">Initiated</option>
<option value="Approved">Approved</option>
</select>
</div>
<div class="col-sm-3">
<label for="selfhelp">Self Help Group:</label>
<select id="selfhelp" class="form-control">
<option value="">Select</option>
<!-- Group names will be populated here -->
</select>
</div>
<div class="col-sm-3">
<button class="btn btn-primary mt-4" onclick="fetchSalaryReport()">Get Salary Info</button>
</div>
</div>
<!-- Salary Report Table -->
<div class="card-block mt-3">
<table id="salaryreporttable" class="table table-striped table-bordered">
<thead class="thead-dark">
<tr>
<th>S.No</th>
<th>Employee Id</th>
<th>Employee Name</th>
<th>Employee Designation</th>
<th>Incharge Name</th>
<th>Incharge Designation</th>
<th>Self Help Group</th>
<th>Days Present</th>
<th>OD</th>
<th>Total Days for Salary</th>
<th>Total Days</th>
<th>Total Days Absent</th>
<th>Month</th>
<th>Year</th>
<th>Salary Amount</th>
<th>Salary Status</th>
</tr>
</thead>
<tbody>
<tr th:each="salary, i : ${salaryReport}">
<td th:text="${i.count}">1</td>
<td th:text="${salary.emp_id}"></td>
<td th:text="${salary.name}"></td>
<td th:text="${salary.designation}"></td>
<td th:text="${salary.incharge_name}"></td>
<td th:text="${salary.incharge_designation}"></td>
<td th:text="${salary.group_name}"></td>
<td th:text="${salary.total_days_present}"></td>
<td th:text="${salary.total_days_od}"></td>
<td th:text="${salary.total_days_salary}"></td>
<td th:text="${salary.total_days}"></td>
<td th:text="${salary.total_days_absent}"></td>
<td th:text="${salary.imonth}"></td>
<td th:text="${salary.iyear}"></td>
<td th:text="${salary.total_salary}"></td>
<td th:text="${salary.salary_status}"></td>
</tr>
</tbody>
<tfoot class="thead-dark">
<tr>
<th>S.No</th>
<th>Employee Id</th>
<th>Employee Name</th>
<th>Employee Designation</th>
<th>Incharge Name</th>
<th>Incharge Designation</th>
<th>Self Help Group</th>
<th>Days Present</th>
<th>OD</th>
<th>Total Days for Salary</th>
<th>Total Days</th>
<th>Total Days Absent</th>
<th>Month</th>
<th>Year</th>
<th>Salary Amount</th>
<th>Salary Status</th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
<footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
</div>
</div>
<div th:replace="~{fragments/modules/base/script :: script}"></div>
<script th:inline="javascript">
function fetchSalaryReport() {
const month = document.getElementById('month').value;
const year = document.getElementById('year').value;
const salaryStatus = document.getElementById('salaryStatus').value;
const groupName=document.getElementById('selfhelp').value;
if (month && year) {
window.location.href = `/gcc/nulm/salary-report-park?month=${month}&year=${year}&salaryStatus=${salaryStatus}&groupName=${groupName}`;
} else {
alert("Please select both month and year.");
}
}
$(document).ready(function () {
function clearUrlParams() {
const currentUrl = window.location.href;
const urlWithoutParams = currentUrl.split('?')[0]; // Remove the query parameters
window.history.replaceState({}, document.title, urlWithoutParams); // Replace the current URL without params
}
// Call this on page load to reset the URL
clearUrlParams();
// Initialize DataTable
var table = $('#salaryreporttable').DataTable({
dom: 'Bftip',
columnDefs: [
{targets: 'no-sort', orderable: false}
],
lengthMenu: [
[50, 100, 200, 500, -1],
['50 rows', '100 rows', '200 rows', 'Show all']
],
scrollY: '50vh',
fixedColumns: {
left: 1,
right: 1
},
buttons: [
{
extend: 'pageLength',
className: 'btn btn-warning'
},
{
extend: 'pdfHtml5',
text: 'PDF',
className: 'btn btn-secondary',
id: 'pdfBtn',
exportOptions: {
columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
},
orientation: 'landscape', // Change to landscape for more horizontal space
pageSize: 'A3', // You can change to A4 or A3 depending on your needs
customize: function (doc) {
// Custom column widths for better fit
//doc.content[1].table.widths = ['2%', '6%', '6%', '6%', '6%', '6%', '6%', '3%', '3%', '3%', '3%', '3%', '3%', '6%', '6%', '6%'];
// Optional: Adjust font size if needed
doc.styles.tableBodyEven.alignment = 'center';
doc.styles.tableBodyOdd.alignment = 'center';
}
}
],
fixedHeader: true,
autoWidth: true,
responsive: true,
searching: true,
select: false,
processing: false
});
});
$(document).ready(function () {
$.ajax({
url: '/gcc/api/nulm/selfHelpGroups', // Your API endpoint
type: 'GET',
success: function (data) {
// Clear existing options (if any)
$('#selfhelp').empty().append('<option value="">Select</option>');
// Check if data is an array and iterate through it
if (Array.isArray(data)) {
let options = '';
data.forEach(function (group) {
// Access the correct properties
options += `<option value="${group.groupName}">${group.groupName}</option>`;
});
$('#selfhelp').append(options);
} else {
console.error("Data is not an array:", data);
}
},
error: function (xhr, status, error) {
console.error("Error fetching self-help groups:", error);
}
});
});
</script>
</body>
</html>
Loading…
Cancel
Save