Browse Source

sofa bed collection updated

master
Hariprasath S 11 months ago
parent
commit
d351f46529
  1. 9
      src/main/java/com/gcc/commissionerreview/configuration/DataSourceConfig.java
  2. 12
      src/main/java/com/gcc/commissionerreview/controller/MainController.java
  3. 81
      src/main/java/com/gcc/commissionerreview/controller/PetLicenseApiController.java
  4. 29
      src/main/java/com/gcc/commissionerreview/controller/SofaBedCollectionApiController.java
  5. 507
      src/main/java/com/gcc/commissionerreview/service/SofaBedCollectionService.java
  6. 168
      src/main/resources/templates/modules/pet/petlicense.html
  7. 784
      src/main/resources/templates/modules/sofa_bed/collectiondetails.html
  8. 440
      src/main/resources/templates/modules/sofa_bed/pendingdetails.html

9
src/main/java/com/gcc/commissionerreview/configuration/DataSourceConfig.java

@ -21,12 +21,12 @@ import javax.sql.DataSource;
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 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";
public static class MyDataSourceConfig {
@ -42,6 +42,7 @@ public class DataSourceConfig {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setUrl("jdbc:mysql://"+host+"/commissioner_review");
//dataSource.setUrl("jdbc:mysql://"+host+"/dashboard_service");
dataSource.setUsername("root");
dataSource.setPassword(dbpassword);
dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");

12
src/main/java/com/gcc/commissionerreview/controller/MainController.java

@ -149,10 +149,20 @@ public class MainController {
return "modules/sofa_bed/zonewise1";
}
@GetMapping("/petlicense")
@GetMapping("/petmisreport")
public String petReport(Model model) {
return "modules/pet/petlicense";
}
@GetMapping("/sofacollectiondetails")
public String sofaBedZoneReport(Model model) {
return "modules/sofa_bed/collectiondetails";
}
@GetMapping("/viewpendingdetails")
public String viewpendingdetails(Model model) {
return "modules/sofa_bed/pendingdetails";
}
}

81
src/main/java/com/gcc/commissionerreview/controller/PetLicenseApiController.java

@ -26,7 +26,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
public class PetLicenseApiController {
@GetMapping("/getzonewisedata")
@GetMapping("/getzonewisedata")
public ResponseEntity<String> getZonewiseData() {
try {
// Step 1: Login and get session token
@ -40,16 +40,35 @@ public class PetLicenseApiController {
String dashboardUrl = "https://petservice.gccservices.in/api/v1/dashboard/license-dashboard";
String dashboardResponse = getDashboardData(dashboardUrl, sessionToken);
// hari
String dashboardUrl2 = "https://petservice.gccservices.in/api/v1/dashboard/vaccination-dashboard";
String dashboardResponse2 = getDashboardData(dashboardUrl2, sessionToken);
// String dashboardUrl2 = "https://petservice.gccservices.in/api/v1/dashboard/vaccination-dashboard";
// String dashboardResponse2 = getDashboardData(dashboardUrl2, sessionToken);
//
// String dashboardUrl3 = "https://petservice.gccservices.in/api/v1/dashboard/microchip-dashboard";
// String dashboardResponse3 = getDashboardData(dashboardUrl3, sessionToken);
String dashboardUrl3 = "https://petservice.gccservices.in/api/v1/dashboard/microchip-dashboard";
String dashboardResponse3 = getDashboardData(dashboardUrl3, sessionToken);
// sanjay
// vaccination data for pet and community
String dashboardUrlPet = "https://petservice.gccservices.in/api/v1/dashboard/vaccination-dashboard/pet";
String dashboardResponsePet = getDashboardData(dashboardUrlPet, sessionToken);
String dashboardUrlCommunity = "https://petservice.gccservices.in/api/v1/dashboard/vaccination-dashboard/community";
String dashboardResponseCommunity = getDashboardData(dashboardUrlCommunity, sessionToken);
// microchip data for pet and community
// String dashboardUrlPet1 = "https://petservice.gccservices.in/api/v1/dashboard/microchip-dashboard/pet";
// String dashboardResponsePet1 = getDashboardData(dashboardUrlPet1, sessionToken);
//
//
// String dashboardUrlCommunity1 = "https://petservice.gccservices.in/api/v1/dashboard/microchip-dashboard/community";
// String dashboardResponseCommunity1 = getDashboardData(dashboardUrlCommunity1, sessionToken);
//
// System.out.println("dashboardResponse="+dashboardResponse);
// System.out.println("dashboardResponse2="+dashboardResponse2);
// System.out.println("dashboardResponse3="+dashboardResponse3);
ObjectMapper mapper = new ObjectMapper();
ObjectNode wrapper = mapper.createObjectNode();
@ -57,8 +76,13 @@ public class PetLicenseApiController {
wrapper.put("status", true);
JsonNode root = mapper.readTree(dashboardResponse);
JsonNode root2 = mapper.readTree(dashboardResponse2);
JsonNode root3 = mapper.readTree(dashboardResponse3);
JsonNode rootPet = mapper.readTree(dashboardResponsePet);
JsonNode rootCommunity = mapper.readTree(dashboardResponseCommunity);
// JsonNode rootPet1 = mapper.readTree(dashboardResponsePet1);
// JsonNode rootCommunity1 = mapper.readTree(dashboardResponseCommunity1);
// Check if "success" is true
if (root.has("success") && root.get("success").asBoolean()) {
@ -67,19 +91,40 @@ public class PetLicenseApiController {
errors.add("License dashboard returned success=false");
}
if (root2.has("success") && root2.get("success").asBoolean()) {
wrapper.set("vaccinationdata", root2);
// vaccination
} else {
errors.add("Vaccination dashboard returned success=false");
}
if (rootPet.has("success") && rootPet.get("success").asBoolean()) {
wrapper.set("vaccinationpetdata", rootPet);
if (root3.has("success") && root3.get("success").asBoolean()) {
wrapper.set("microchipdata", root3);
} else {
errors.add("Microchip dashboard returned success=false");
errors.add("Vaccination pet dashboard returned success=false");
}
if (rootCommunity.has("success") && rootCommunity.get("success").asBoolean()) {
wrapper.set("vaccinationcommunitydata", rootCommunity);
} else {
errors.add("Vaccination community dashboard returned success=false");
}
// microchip
// if (rootPet1.has("success") && rootPet1.get("success").asBoolean()) {
// wrapper.set("microchippetdata", rootPet1);
// } else {
// errors.add("Microchip pet dashboard returned success=false");
// }
//
// if (rootCommunity1.has("success") && rootCommunity1.get("success").asBoolean()) {
// wrapper.set("microchipcommunitydata", rootCommunity1);
// } else {
// errors.add("Microchip community dashboard returned success=false");
// }
// --- If any failed, mark status false but still return data ---
if (!errors.isEmpty()) {
wrapper.put("status", false);

29
src/main/java/com/gcc/commissionerreview/controller/SofaBedCollectionApiController.java

@ -39,4 +39,33 @@ public class SofaBedCollectionApiController {
{
return sofaBedCollectionService.getWardStatusDetails(ward,status);
}
////////////////////////////
@GetMapping("/getZoneDetails")
public List<Map<String, Object>> getZoneDetails()
{
return sofaBedCollectionService.getZoneDetails();
}
@GetMapping("/getWardDetails")
public List<Map<String, Object>> getWardDetails(@RequestParam String zone)
{
return sofaBedCollectionService.getWardDetails(zone);
}
@GetMapping("/getWardStatusDetails")
public List<Map<String, Object>> getWardStatusDetails(@RequestParam String ward,@RequestParam String status)
{
return sofaBedCollectionService.getWardStatusDetailsReport(ward,status);
}
///////////////////////////////
@GetMapping("/getPendingDetails")
public List<Map<String, Object>> getPendingDetails()
{
return sofaBedCollectionService.getPendingDetails();
}
}

507
src/main/java/com/gcc/commissionerreview/service/SofaBedCollectionService.java

@ -1,5 +1,7 @@
package com.gcc.commissionerreview.service;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
@ -413,4 +415,509 @@ public class SofaBedCollectionService {
return Collections.singletonList(response);
}
//////////////////////////////////////////////////////
public List<Map<String, Object>> getZoneDetails() {
String sql="""
SELECT
COALESCE(zone, 'Total') AS Zone,
COUNT(*) AS Total_Requests_Received,
SUM( CASE WHEN status = '2' AND STR_TO_DATE(close_date, '%Y-%m-%d') <= DATE_SUB(DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) + 1 DAY), INTERVAL 1 DAY) THEN 1 ELSE 0 END ) AS Overall_Complaints_Attended,
(COUNT(*) - SUM(CASE WHEN status IN ('2','4','5') THEN 1 ELSE 0 END)) AS Overall_Pending_Complaints,
SUM(CASE WHEN status = '4' THEN 1 ELSE 0 END) AS Cancelled_By_User,
SUM(CASE WHEN status = '5' THEN 1 ELSE 0 END) AS Cancelled_By_Officer,
SUM(
CASE
WHEN DATE(cdate) <= (DATE_SUB(DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) + 1 DAY), INTERVAL 1 DAY))
AND (close_date IS NULL
OR STR_TO_DATE(close_date, '%Y-%m-%d') > (DATE_SUB(DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) + 1 DAY), INTERVAL 1 DAY)))
AND status NOT IN ('4','5')
THEN 1 ELSE 0
END
) AS Overall_Balance_Before_Current_Week,
SUM(
CASE
WHEN DATE(cdate) = CURDATE()
AND status NOT IN ('3','4','5')
THEN 1 ELSE 0
END
) AS Today_Complaint_Received,
SUM(
CASE
WHEN status = '2'
AND STR_TO_DATE(close_date, '%Y-%m-%d') >= DATE_SUB(CURDATE(), INTERVAL ((WEEKDAY(CURDATE()) + 2) % 7) DAY)
AND STR_TO_DATE(close_date, '%Y-%m-%d') <= DATE_ADD(DATE_SUB(CURDATE(), INTERVAL ((WEEKDAY(CURDATE()) + 2) % 7) DAY), INTERVAL 6 DAY)
THEN 1 ELSE 0
END
) AS This_Week_Attended,
(
(COUNT(*) - SUM(CASE WHEN status IN ('2','4','5') THEN 1 ELSE 0 END))
-
SUM(
CASE
WHEN status = '3'
AND STR_TO_DATE(close_date, '%Y-%m-%d') >= DATE_SUB(CURDATE(), INTERVAL ((WEEKDAY(CURDATE()) + 2) % 7) DAY)
AND STR_TO_DATE(close_date, '%Y-%m-%d') <= DATE_ADD(DATE_SUB(CURDATE(), INTERVAL ((WEEKDAY(CURDATE()) + 2) % 7) DAY), INTERVAL 6 DAY)
THEN 1 ELSE 0
END
)
) AS Balance_To_Be_Attended
FROM user_request_table
WHERE is_active = 1 AND is_delete = 0
GROUP BY zone WITH ROLLUP
ORDER BY
CASE WHEN zone IS NULL THEN 2 ELSE 1 END,
zone
""";
LocalDate today = LocalDate.now();
int weekday = today.getDayOfWeek().getValue();
LocalDate ocaDate = today.minusDays(weekday).minusDays(1);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");
String formattedOcaDate = ocaDate.format(formatter);
String formattedCurrentDate = today.format(formatter);
List<Map<String, Object>> reportList = jdbcDomesticWasteTemplate.queryForList(sql);
Map<String, Object> response = new LinkedHashMap<>();
response.put("status", "Success");
response.put("message", "Zonewise Report Details");
response.put("data", reportList);
response.put("oca_date", formattedOcaDate);
response.put("current_date", formattedCurrentDate);
return Collections.singletonList(response);
}
public List<Map<String, Object>> getWardDetails(String zone) {
String sql="""
SELECT
COALESCE(division, 'Total') AS Division,
COUNT(*) AS Total_Requests_Received,
SUM( CASE WHEN status = '2' AND STR_TO_DATE(close_date, '%Y-%m-%d') <= DATE_SUB(DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) + 1 DAY), INTERVAL 1 DAY) THEN 1 ELSE 0 END ) AS Overall_Complaints_Attended,
(COUNT(*) - SUM(CASE WHEN status IN ('2','4','5') THEN 1 ELSE 0 END)) AS Overall_Pending_Complaints,
SUM(CASE WHEN status = '4' THEN 1 ELSE 0 END) AS Cancelled_By_User,
SUM(CASE WHEN status = '5' THEN 1 ELSE 0 END) AS Cancelled_By_Officer,
SUM(
CASE
WHEN DATE(cdate) <= (DATE_SUB(DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) + 1 DAY), INTERVAL 1 DAY))
AND (close_date IS NULL
OR STR_TO_DATE(close_date, '%Y-%m-%d') > (DATE_SUB(DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) + 1 DAY), INTERVAL 1 DAY)))
AND status NOT IN ('4','5')
THEN 1 ELSE 0
END
) AS Overall_Balance_Before_Current_Week,
SUM(
CASE
WHEN DATE(cdate) = CURDATE()
AND status NOT IN ('3','4','5')
THEN 1 ELSE 0
END
) AS Today_Complaint_Received,
SUM(
CASE
WHEN status = '2'
AND STR_TO_DATE(close_date, '%Y-%m-%d') >= DATE_SUB(CURDATE(), INTERVAL ((WEEKDAY(CURDATE()) + 2) % 7) DAY)
AND STR_TO_DATE(close_date, '%Y-%m-%d') <= DATE_ADD(DATE_SUB(CURDATE(), INTERVAL ((WEEKDAY(CURDATE()) + 2) % 7) DAY), INTERVAL 6 DAY)
THEN 1 ELSE 0
END
) AS This_Week_Attended,
(
(COUNT(*) - SUM(CASE WHEN status IN ('2','4','5') THEN 1 ELSE 0 END))
-
SUM(
CASE
WHEN status = '3'
AND STR_TO_DATE(close_date, '%Y-%m-%d') >= DATE_SUB(CURDATE(), INTERVAL ((WEEKDAY(CURDATE()) + 2) % 7) DAY)
AND STR_TO_DATE(close_date, '%Y-%m-%d') <= DATE_ADD(DATE_SUB(CURDATE(), INTERVAL ((WEEKDAY(CURDATE()) + 2) % 7) DAY), INTERVAL 6 DAY)
THEN 1 ELSE 0
END
)
) AS Balance_To_Be_Attended
FROM user_request_table
WHERE is_active = 1 AND is_delete = 0 AND zone=?
GROUP BY division WITH ROLLUP
ORDER BY
CASE WHEN division IS NULL THEN 2 ELSE 1 END,
division
""";
LocalDate today = LocalDate.now();
int weekday = today.getDayOfWeek().getValue();
LocalDate ocaDate = today.minusDays(weekday).minusDays(1);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");
String formattedOcaDate = ocaDate.format(formatter);
String formattedCurrentDate = today.format(formatter);
List<Map<String, Object>> reportList = jdbcDomesticWasteTemplate.queryForList(sql, zone);
Map<String, Object> response = new LinkedHashMap<>();
response.put("status", "Success");
response.put("message", "Ward-wise Details");
response.put("data", reportList);
response.put("oca_date", formattedOcaDate);
response.put("current_date", formattedCurrentDate);
return Collections.singletonList(response);
}
public List<Map<String, Object>> getWardStatusDetailsReport(String ward, String status) {
String fileBaseUrl = "https://gccservices.in";
// ✅ Base SQL (common part)
StringBuilder sql = new StringBuilder("""
SELECT
u.id,
u.request_id,
u.user_name,
u.mobile,
u.address,
u.latitude,
u.longitude,
u.zone,
u.division,
u.street_name,
u.quantity AS main_quantity,
u.remarks,
CAST(u.is_app AS CHAR) AS is_app,
u.is_active,
u.is_delete,
u.street_id,
CONCAT(?, u.image_url) AS image_url,
DATE_FORMAT(u.cdate, '%d-%m-%Y') AS cdate,
sm.status_master AS status,
DATE_FORMAT(u.close_date, '%d-%m-%Y') AS close_date,
CONCAT(?, u.officer_upload_url) AS officer_upload_url,
itm.iteam_id,
im.item_name,
itm.quantity
FROM user_request_table u
LEFT JOIN items itm ON u.id = itm.req_table_id
LEFT JOIN item_master im ON itm.iteam_id = im.id AND im.is_active = 1
LEFT JOIN status_master sm ON sm.id = u.status AND sm.is_active = 1 AND sm.is_delete = 0
WHERE
u.is_active = 1
AND u.is_delete = 0
AND u.division = ?
""");
// ✅ Dynamic WHERE condition based on status
switch (status) {
case "1":
sql.append(
"""
AND u.status = '2' AND STR_TO_DATE(u.close_date, '%Y-%m-%d') <= DATE_SUB(DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) + 1 DAY), INTERVAL 1 DAY)
""");
break;
case "2":
sql.append(
" AND u.status NOT IN ('2','4','5') ");
break;
case "3":
sql.append(
" AND DATE(u.cdate) = CURDATE() AND u.status NOT IN ('3','4','5') ");
break;
case "4":
sql.append(
" AND u.status = '2' "
+ " AND STR_TO_DATE(u.close_date, '%Y-%m-%d') >= DATE_SUB(CURDATE(), INTERVAL ((WEEKDAY(CURDATE()) + 2) % 7) DAY) "
+ " AND STR_TO_DATE(u.close_date, '%Y-%m-%d') <= DATE_ADD(DATE_SUB(CURDATE(), INTERVAL ((WEEKDAY(CURDATE()) + 2) % 7) DAY), INTERVAL 6 DAY) ");
break;
case "5":
sql.append(
" AND u.status NOT IN ('2','4','5') ");
break;
default:
// Return empty result if status invalid
return List.of(Map.of(
"status", "Failed",
"message", "Invalid status type",
"data", List.of()));
}
sql.append(" ORDER BY u.cdate DESC ");
List<Map<String, Object>> reportList = jdbcDomesticWasteTemplate.queryForList(
sql.toString(),
fileBaseUrl + "/gccofficialapp/files",
fileBaseUrl + "/gccofficialapp/files",
ward);
Map<Integer, Map<String, Object>> groupedMap = new LinkedHashMap<>();
for (Map<String, Object> row : reportList) {
Integer id = (Integer) row.get("id");
Map<String, Object> item = null;
if (row.get("item_name") != null) {
item = new LinkedHashMap<>();
item.put("item_name", row.get("item_name"));
item.put("quantity", row.get("quantity"));
}
if (groupedMap.containsKey(id)) {
if (item != null) {
((List<Map<String, Object>>) groupedMap.get(id).get("items")).add(item);
}
} else {
Map<String, Object> newEntry = new LinkedHashMap<>();
newEntry.put("id", id);
newEntry.put("request_id", row.get("request_id"));
newEntry.put("user_name", row.get("user_name"));
newEntry.put("mobile", row.get("mobile"));
newEntry.put("address", row.get("address"));
newEntry.put("latitude", row.get("latitude"));
newEntry.put("longitude", row.get("longitude"));
newEntry.put("zone", row.get("zone"));
newEntry.put("division", row.get("division"));
newEntry.put("street_name", row.get("street_name"));
newEntry.put("main_quantity", row.get("main_quantity"));
newEntry.put("remarks", row.get("remarks"));
newEntry.put("image_url", row.get("image_url"));
newEntry.put("cdate", row.get("cdate"));
newEntry.put("is_active", row.get("is_active"));
newEntry.put("is_delete", row.get("is_delete"));
newEntry.put("street_id", row.get("street_id"));
newEntry.put("status", row.get("status"));
newEntry.put("is_app", row.get("is_app"));
newEntry.put("close_date", row.get("close_date"));
newEntry.put("officer_upload_url", row.get("officer_upload_url"));
List<Map<String, Object>> items = new ArrayList<>();
if (item != null)
items.add(item);
newEntry.put("items", items);
groupedMap.put(id, newEntry);
}
}
Map<String, Object> response = new LinkedHashMap<>();
response.put("status", "Success");
response.put("message", "Ward-wise Report for Status " + status);
response.put("data", groupedMap.values());
return Collections.singletonList(response);
}
public List<Map<String, Object>> getPendingDetails() {
String fileBaseUrl = "https://gccservices.in";
String sql="SELECT "
+ " u.id, "
+ " u.request_id, "
+ " u.user_name, "
+ " u.mobile, "
+ " u.address, "
+ " u.latitude, "
+ " u.longitude, "
+ " u.zone, "
+ " u.division, "
+ " u.street_name, "
+ " u.quantity AS main_quantity, "
+ " u.remarks, "
+ " CAST(u.is_app AS CHAR) AS is_app, "
+ " u.is_active, "
+ " u.is_delete, "
+ " u.street_id, "
+ " CONCAT(?, u.image_url) AS image_url, "
+ " DATE_FORMAT(u.cdate, '%d-%m-%Y') AS cdate, "
+ " sm.status_master AS status, "
+ " DATE_FORMAT(u.close_date, '%d-%m-%Y') AS close_date, "
+ " CONCAT(?, u.officer_upload_url) AS officer_upload_url, "
+ " itm.iteam_id, "
+ " im.item_name, "
+ " itm.quantity, "
+ "CASE WHEN is_app = 1 THEN 'NAMMA CHENNAI APP' "
+ " WHEN is_app = 2 THEN 'WHATSAPP' "
+ " WHEN is_app = 3 THEN '1913' "
+ " ELSE 'OTHER SOURCE' "
+ " END AS Source "
+ " FROM user_request_table u "
+ " LEFT JOIN items itm ON u.id = itm.req_table_id "
+ " LEFT JOIN item_master im ON itm.iteam_id = im.id AND im.is_active = 1 "
+ " LEFT JOIN status_master sm ON sm.id = u.status AND sm.is_active = 1 AND sm.is_delete = 0 "
+ " WHERE "
+ " u.is_active = 1 "
+ " AND u.is_delete = 0 AND u.status NOT IN ('2','4','5') ORDER BY u.zone,u.division,u.cdate DESC";
List<Map<String, Object>> reportList = jdbcDomesticWasteTemplate.queryForList(
sql.toString(),
fileBaseUrl + "/gccofficialapp/files",
fileBaseUrl + "/gccofficialapp/files"
);
Map<Integer, Map<String, Object>> groupedMap = new LinkedHashMap<>();
for (Map<String, Object> row : reportList) {
Integer id = (Integer) row.get("id");
Map<String, Object> item = null;
if (row.get("item_name") != null) {
item = new LinkedHashMap<>();
item.put("item_name", row.get("item_name"));
item.put("quantity", row.get("quantity"));
}
if (groupedMap.containsKey(id)) {
if (item != null) {
((List<Map<String, Object>>) groupedMap.get(id).get("items")).add(item);
}
} else {
Map<String, Object> newEntry = new LinkedHashMap<>();
newEntry.put("id", id);
newEntry.put("request_id", row.get("request_id"));
newEntry.put("user_name", row.get("user_name"));
newEntry.put("mobile", row.get("mobile"));
newEntry.put("address", row.get("address"));
newEntry.put("latitude", row.get("latitude"));
newEntry.put("longitude", row.get("longitude"));
newEntry.put("zone", row.get("zone"));
newEntry.put("division", row.get("division"));
newEntry.put("street_name", row.get("street_name"));
newEntry.put("main_quantity", row.get("main_quantity"));
newEntry.put("remarks", row.get("remarks"));
newEntry.put("image_url", row.get("image_url"));
newEntry.put("cdate", row.get("cdate"));
newEntry.put("is_active", row.get("is_active"));
newEntry.put("is_delete", row.get("is_delete"));
newEntry.put("street_id", row.get("street_id"));
newEntry.put("status", row.get("status"));
newEntry.put("is_app", row.get("is_app"));
newEntry.put("Source", row.get("Source"));
newEntry.put("close_date", row.get("close_date"));
newEntry.put("officer_upload_url", row.get("officer_upload_url"));
List<Map<String, Object>> items = new ArrayList<>();
if (item != null)
items.add(item);
newEntry.put("items", items);
groupedMap.put(id, newEntry);
}
}
Map<String, Object> response = new LinkedHashMap<>();
response.put("status", "Success");
response.put("message", "Pending Detail Report for Sofa Bed Collection");
response.put("data", groupedMap.values());
String sqldata1="SELECT "
+ " COUNT(*) AS count, "
+ " CASE "
+ " WHEN is_app = 1 THEN 'NAMMA CHENNAI APP' "
+ " WHEN is_app = 2 THEN 'WHATSAPP' "
+ " ELSE '1913' "
+ " END AS SOURCE "
+ "FROM user_request_table "
+ "WHERE is_active = 1 "
+ " AND is_delete = 0 "
+ " AND status NOT IN (4,5) "
+ "GROUP BY SOURCE "
+ " "
+ "UNION ALL "
+ " "
+ "SELECT "
+ " COUNT(*) AS count, "
+ " 'Total' AS SOURCE "
+ "FROM user_request_table "
+ "WHERE is_active = 1 "
+ " AND is_delete = 0 "
+ " AND status NOT IN (4,5) "
+ " "
+ "ORDER BY "
+ " CASE "
+ " WHEN SOURCE = 'NAMMA CHENNAI APP' THEN 1 "
+ " WHEN SOURCE = 'WHATSAPP' THEN 2 "
+ " WHEN SOURCE = '1913' THEN 3 "
+ " WHEN SOURCE = 'Total' THEN 4 "
+ " END";
List<Map<String, Object>> sourcedata = jdbcDomesticWasteTemplate.queryForList(sqldata1);
response.put("source_data", sourcedata);
String sqldata2="SELECT "
+ " COUNT(*) AS total_count, "
+ " CASE "
+ " WHEN sm.id IN (1, 3) THEN 'Pending' "
+ " WHEN sm.id = 2 THEN 'Completed' "
+ " ELSE 'Others' "
+ " END AS status_category "
+ "FROM user_request_table urt "
+ "LEFT JOIN status_master sm ON urt.status = sm.id "
+ "WHERE urt.is_active = 1 "
+ " AND urt.is_delete = 0 "
+ " AND urt.status NOT IN (4, 5) "
+ "GROUP BY status_category "
+ " "
+ "UNION ALL "
+ " "
+ "SELECT "
+ " COUNT(*) AS total_count, "
+ " 'Total' AS status_category "
+ "FROM user_request_table urt "
+ "LEFT JOIN status_master sm ON urt.status = sm.id "
+ "WHERE urt.is_active = 1 "
+ " AND urt.is_delete = 0 "
+ " AND urt.status NOT IN (4, 5) "
+ " "
+ "ORDER BY "
+ " CASE "
+ " WHEN status_category = 'Pending' THEN 1 "
+ " WHEN status_category = 'Completed' THEN 2 "
+ " WHEN status_category = 'Others' THEN 3 "
+ " WHEN status_category = 'Total' THEN 4 "
+ " END";
List<Map<String, Object>> statusdata = jdbcDomesticWasteTemplate.queryForList(sqldata2);
response.put("status_data", statusdata);
return Collections.singletonList(response);
}
}

168
src/main/resources/templates/modules/pet/petlicense.html

@ -59,46 +59,45 @@
<div id="opSummaryTable" style="display: block;" class="container">
<p style="font-weight: bold;">Microchip Details:</p>
<table class="table table-striped table-bordered display nowrap w-100">
<tr>
<th class="text-center">Total requirement:&nbsp;&nbsp;<span id="micro_total"></span></th>
<th class="text-center">Completed:&nbsp;&nbsp;<span id="micro_completed"></span></th>
<th class="text-center">Pending:&nbsp;&nbsp;<span id="micro_pending"></span></th>
</tr>
</table>
<!-- <p style="font-weight: bold;">Microchip Details:</p>-->
<!-- <table class="table table-striped table-bordered display nowrap w-100">-->
<!-- <tr>-->
<!-- <th class="text-center">Total requirement:&nbsp;&nbsp;<span id="micro_total"></span></th>-->
<!-- <th class="text-center">Completed:&nbsp;&nbsp;<span id="micro_completed"></span></th>-->
<!-- <th class="text-center">Pending:&nbsp;&nbsp;<span id="micro_pending"></span></th>-->
<!-- </tr>-->
<!-- </table>-->
<table id="ZoneOpDatatable" class="table table-striped table-bordered display nowrap w-100">
<thead>
<tr>
<th class="text-center" rowspan="2">Zones</th>
<th class="text-center" colspan="3">License</th>
<th class="text-center" colspan="3">Vaccination</th>
</tr>
<tr>
<th class="text-center">License Total Request</th>
<th class="text-center">Completed</th>
<th class="text-center">Pending</th>
<th class="text-center">Vaccination Total Request</th>
<th class="text-center">Completed</th>
<th class="text-center">Pending</th>
</tr>
<tr>
<th class="text-center" rowspan="3">Zones</th>
<th class="text-center" colspan="3">License</th>
<th class="text-center" colspan="6">Vaccination</th>
</tr>
<tr>
<th class="text-center" rowspan="2">Total license Request</th>
<th class="text-center" rowspan="2">Completed</th>
<th class="text-center" rowspan="2">Pending</th>
<th class="text-center" colspan="3">Vaccination Pet</th>
<th class="text-center" colspan="3">Vaccination Community</th>
</tr>
<tr>
<th class="text-center">Total Request</th>
<th class="text-center">Completed</th>
<th class="text-center">Pending</th>
<th class="text-center">Total Request</th>
<th class="text-center">Completed</th>
<th class="text-center">Pending</th>
</tr>
</thead>
<tbody>
</tbody>
<!-- <tfoot>
<tr>
<th class="text-center">TOTAL</th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
</tr>
</tfoot> -->
</table>
</div>
@ -142,33 +141,41 @@ $(document).ready(function () {
success: function(response) {
$('#pageLoader').hide();
console.log(response);
console.log(response.status);
if (response.status === true) {
if (response.licensedata && response.vaccinationdata &&
if (response.licensedata && response.vaccinationpetdata && response.vaccinationcommunitydata &&
response.licensedata.data &&
Array.isArray(response.licensedata.data.zoneWise)) {
const licenseData = response.licensedata?.data?.zoneWise || [];
const vaccData = response.vaccinationdata?.data?.zoneWise || [];
const microData = response.microchipdata.data;
const vaccPetData = response.vaccinationpetdata?.data?.zoneWise || [];
const vaccCommunityData = response.vaccinationcommunitydata?.data?.zoneWise || [];
$('#micro_total').text(microData.totalRequirement || 0);
$('#micro_completed').text(microData.completed || 0);
$('#micro_pending').text(microData.pending || 0);
const mergedData = licenseData.map(lic => {
const vacc = vaccData.find(v => v.zone === lic.zone) || {};
const pet = vaccPetData.find(v => v.zone === lic.zone) || {};
const community = vaccCommunityData.find(v => v.zone === lic.zone) || {};
return {
license_zone: lic.zone || '-',
license_total: parseInt(lic.completed || 0) + parseInt(lic.pending || 0),
license_completed: lic.completed || '0',
license_pending: lic.pending || '0',
vacc_zone: vacc.zone || '-',
vacc_total: parseInt(vacc.completed || 0) + parseInt(vacc.pending || 0),
vacc_completed: vacc.completed || '0',
vacc_pending: vacc.pending || '0'
// add by sanjay
// Vaccination Pet
vaccpet_total: parseInt(pet.completed || 0) + parseInt(pet.pending || 0),
vaccpet_completed: pet.completed || 0,
vaccpet_pending: pet.pending || 0,
// Vaccination Community
vacccomm_total: parseInt(community.completed || 0) + parseInt(community.pending || 0),
vacccomm_completed: community.completed || 0,
vacccomm_pending: community.pending || 0
};
});
@ -178,18 +185,34 @@ $(document).ready(function () {
acc.license_total += parseInt(curr.license_total || 0);
acc.license_completed += parseInt(curr.license_completed || 0);
acc.license_pending += parseInt(curr.license_pending || 0);
acc.vacc_total += parseInt(curr.vacc_total || 0);
acc.vacc_completed += parseInt(curr.vacc_completed || 0);
acc.vacc_pending += parseInt(curr.vacc_pending || 0);
// Vaccination Pet1
acc.vaccpet_total += parseInt(curr.vaccpet_total || 0);
acc.vaccpet_completed += parseInt(curr.vaccpet_completed || 0);
acc.vaccpet_pending += parseInt(curr.vaccpet_pending || 0);
// Vaccination Community1
acc.vacccomm_total += parseInt(curr.vacccomm_total || 0);
acc.vacccomm_completed += parseInt(curr.vacccomm_completed || 0);
acc.vacccomm_pending += parseInt(curr.vacccomm_pending || 0);
return acc;
},
{
license_total: 0,
license_completed: 0,
license_pending: 0,
vacc_total: 0,
vacc_completed: 0,
vacc_pending: 0
vaccpet_total: 0,
vaccpet_completed: 0,
vaccpet_pending: 0,
vacccomm_total: 0,
vacccomm_completed: 0,
vacccomm_pending: 0
}
);
@ -199,9 +222,17 @@ $(document).ready(function () {
license_total: `<strong>${totals.license_total}</strong>`,
license_completed: `<strong>${totals.license_completed}</strong>`,
license_pending: `<strong>${totals.license_pending}</strong>`,
vacc_total: `<strong>${totals.vacc_total}</strong>`,
vacc_completed: `<strong>${totals.vacc_completed}</strong>`,
vacc_pending: `<strong>${totals.vacc_pending}</strong>`
vaccpet_total: `<strong>${totals.vaccpet_total}</strong>`,
vaccpet_completed: `<strong>${totals.vaccpet_completed}</strong>`,
vaccpet_pending: `<strong>${totals.vaccpet_pending}</strong>`,
vacccomm_total: `<strong>${totals.vacccomm_total}</strong>`,
vacccomm_completed: `<strong>${totals.vacccomm_completed}</strong>`,
vacccomm_pending: `<strong>${totals.vacccomm_pending}</strong>`
});
@ -212,12 +243,37 @@ $(document).ready(function () {
data: mergedData,
columns: [
{ data: 'license_zone',defaultContent: '-', className: 'text-center'},
/* {
data: 'license_zone',
render: function (data, type, row) {
// Skip last row
if (row === mergedData.data[mergedData.data.length - 1]) {
return data; // just plain text
} else {
return `<a href="#" onclick="openZoneModal('${data}')" style="text-decoration: underline;">${data}</a>`;
}
}
}, */
// license
{ data: 'license_total', defaultContent: '-', className: 'text-center' },
{ data: 'license_completed', defaultContent: '-', className: 'text-center' },
{ data: 'license_pending', defaultContent: '-', className: 'text-center' },
{ data: 'vacc_total', defaultContent: '-', className: 'text-center' },
{ data: 'vacc_completed',defaultContent: '-', className: 'text-center' },
{ data: 'vacc_pending',defaultContent: '-', className: 'text-center' }
// Vaccination Pet
{ data: 'vaccpet_total', className: 'text-center' },
{ data: 'vaccpet_completed', className: 'text-center' },
{ data: 'vaccpet_pending', className: 'text-center' },
// Vaccination Community
{ data: 'vacccomm_total', className: 'text-center' },
{ data: 'vacccomm_completed', className: 'text-center' },
{ data: 'vacccomm_pending', className: 'text-center' }
],
dom: 'Bfrtip',

784
src/main/resources/templates/modules/sofa_bed/collectiondetails.html

@ -0,0 +1,784 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<title>Sofa Bed collection Detail Report Summary</title>
<!-- Bootstrap 5 CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- DataTables CSS -->
<link href="https://cdn.datatables.net/1.13.4/css/jquery.dataTables.min.css" rel="stylesheet"/>
<link href="https://cdn.datatables.net/buttons/2.3.6/css/buttons.dataTables.min.css" rel="stylesheet"/>
<style>
table.dataTable th, table.dataTable td {
text-align: center;
vertical-align: middle;
border: 1px solid #000;
}
table.dataTable th{
background-color: #003366 !important;
color: white;
}
.dataTables_wrapper .dt-buttons {
margin-bottom: 10px;
}
.dataTables_filter {
margin-bottom: 25px; /* adjust as needed */
}
.page-header-title h4 {
margin: 20px 0;
text-align: center;
}
#zoneDetailsTable_wrapper .dataTables_scrollBody {
border: none !important;
}
#zoneDetailsTable td, #zoneDetailsTable th {
vertical-align: middle;
text-align: center;
white-space: nowrap;
}
#DetailsModal .modal-body{
max-height: 85vh;
overflow-y: auto;
}
</style>
</head>
<body>
<div class="page-header-title">
<h4>Details of Sofa,Bed,furniture and Cloths</h4>
</div>
<div id="opSummaryTable" style="display: block;" class="container">
<table id="ZoneOpDatatable" class="table table-striped table-bordered display nowrap w-100">
<thead>
<tr>
<th rowspan="2" class="text-center">Zones</th>
<th rowspan="2" class="text-center" style="white-space: normal; word-wrap: break-word;">Total request received so far from 11/10/2025</th>
<th colspan="2" class="text-center" style="white-space: normal; word-wrap: break-word;">Overall Request Cancelled</th>
<th rowspan="2" class="text-center" style="white-space: normal; word-wrap: break-word;" id="zone_formatted_oca_date">Overall Complaint attended up to</th>
<th rowspan="2" class="text-center" style="white-space: normal; word-wrap: break-word;" id="zone_formatted_op_date">Overall Pending as on </th>
<th rowspan="2" class="text-center" style="white-space: normal; word-wrap: break-word;" id="zone_formatted_cur_date">Today complaint received</th>
<th rowspan="2" class="text-center" style="white-space: normal; word-wrap: break-word;" id="zone_formatted_twa_date">This week Attended</th>
<th rowspan="2" class="text-center" style="white-space: normal; word-wrap: break-word;">Balance to be Attended</th>
</tr>
<tr>
<th class="text-center" style="white-space: normal; word-wrap: break-word;">user cancelled</th>
<th class="text-center" style="white-space: normal; word-wrap: break-word;">officer cancelled</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div class="modal fade" id="zoneDetailsModal" tabindex="-1" aria-labelledby="zoneDetailsLabel" aria-hidden="true" data-bs-keyboard="false" data-bs-backdrop="static">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="zoneModalTitle">Zone Details</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<table id="WardDatatable" class="table table-striped table-bordered display nowrap w-100">
<thead>
<tr>
<th rowspan="2" class="text-center">Divisions</th>
<th rowspan="2" class="text-center" style="white-space: normal; word-wrap: break-word;">Total request received so far from 11/10/2025</th>
<th colspan="2" class="text-center" style="white-space: normal; word-wrap: break-word;">Overall Request Cancelled</th>
<th rowspan="2" class="text-center" style="white-space: normal; word-wrap: break-word;" id="ward_formatted_oca_date">Overall Complaint attended up to</th>
<th rowspan="2" class="text-center" style="white-space: normal; word-wrap: break-word;" id="ward_formatted_op_date">Overall Pending as on </th>
<th rowspan="2" class="text-center" style="white-space: normal; word-wrap: break-word;" id="ward_formatted_cur_date">Today complaint received</th>
<th rowspan="2" class="text-center" style="white-space: normal; word-wrap: break-word;" id="ward_formatted_twa_date">This week Attended</th>
<th rowspan="2" class="text-center" style="white-space: normal; word-wrap: break-word;">Balance to be Attended</th>
</tr>
<tr>
<th class="text-center" style="white-space: normal; word-wrap: break-word;">user cancelled</th>
<th class="text-center" style="white-space: normal; word-wrap: break-word;">officer cancelled</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="modal fade" id="DetailsModal" tabindex="-1" aria-labelledby="DetailsLabel" aria-hidden="true" data-bs-keyboard="false" data-bs-backdrop="static">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="DeatilsModalTitle">Details</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body" id="detailscontent">
</div>
</div>
</div>
</div>
<div id="pageLoader" style="display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255, 255, 255, 0.8); z-index: 9999; text-align: center;">
<div style="position: relative; top: 50%; transform: translateY(-50%);">
<div class="spinner-border text-primary" role="status" style="width: 3rem; height: 3rem;">
<span class="sr-only"></span>
</div>
<!-- Add the 'Please wait' text below the spinner -->
<p style="margin-top: 1rem; font-size: 1.2rem; color: #007bff;">Please wait...</p>
</div>
</div>
<!-- Scripts -->
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
<!-- DataTables JS -->
<script src="https://cdn.datatables.net/1.13.4/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.3.6/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.3.6/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.3.6/js/buttons.print.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js"></script>
<!-- SweetAlert -->
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script>
$(document).ready(function () {
$('#pageLoader').show();
$.ajax({
url: '/commissionerreview/api/sofabedcollection/getZoneDetails',
method: 'GET',
success: function(response) {
// Safely extract data whether it's an array or an object
var res = Array.isArray(response) ? response[0] : response;
console.log("Response:", res);
$('#pageLoader').hide();
if (res.status === "Success") {
if (Array.isArray(res.data) && res.data.length > 0) {
console.log("Details Array:", response);
let table = $('#ZoneOpDatatable').DataTable({
destroy: true,
autoWidth: true,
info: true,
data: res.data, // using response directly
columns: [
{
data: 'Zone',
render: function (data, type, row) {
// Skip last row
if (row === res.data[res.data.length - 1]) {
return data; // just plain text
} else {
return `<a href="#" onclick="openZoneModal('${data}')" style="text-decoration: underline;">${data}</a>`;
}
}
},
{ data: 'Total_Requests_Received', defaultContent: '-', className: 'text-center' },
{ data: 'Cancelled_By_User', defaultContent: '-', className: 'text-center' },
{ data: 'Cancelled_By_Officer', defaultContent: '-', className: 'text-center' },
{ data: 'Overall_Complaints_Attended', defaultContent: '-', className: 'text-center' },
{ data: 'Overall_Pending_Complaints', defaultContent: '-', className: 'text-center' },
{ data: 'Today_Complaint_Received', defaultContent: '-', className: 'text-center' },
{ data: 'This_Week_Attended', defaultContent: '-', className: 'text-center' },
{ data: 'Balance_To_Be_Attended', defaultContent: '-', className: 'text-center' }
],
dom: 'Bfrtip',
buttons: [
{
extend: 'excelHtml5',
title: 'SofaBed_Zonewise_Report',
text: '<i class="fa fa-file-excel"></i> Export to Excel',
className: 'btn btn-success btn-sm',
exportOptions: { columns: ':visible' }
},
{
extend: 'pdfHtml5',
title: 'SofaBed_Zonewise_Report',
text: '<i class="fa fa-file-pdf"></i> Export to PDF',
className: 'btn btn-danger btn-sm',
orientation: 'portrait', // Optional: 'portrait' or 'landscape'
pageSize: 'A4', // Optional: 'A4', 'LETTER', etc.
exportOptions: { columns: ':visible' }
}
],
lengthMenu: [
[50, 100, 200, 500, -1],
['50 rows', '100 rows', '200 rows', 'Show all']
],
scrollY: 'auto',
scrollX: true,
responsive: false,
searching: false,
ordering: false
});
$('#zone_formatted_oca_date').text('Overall Complaint attended up to ' + res.oca_date);
$('#zone_formatted_cur_date').text('Today complaint received ' + res.current_date);
$('#zone_formatted_op_date').text('Overall Pending as on ' + res.current_date);
$('#zone_formatted_twa_date').text('This week Attended ' + res.oca_date);
}
else if(Array.isArray(res.data) && res.data.length === 0) {
$('#pageLoader').hide();
//alert("No data available.");
Swal.fire({
icon: 'info',
title: 'No Data',
text: 'No data available.',
showConfirmButton: true,
timer: 3000
});
}
else {
$('#pageLoader').hide();
//alert("Error: " + response.message);
Swal.fire({
icon: 'error',
title: 'Error',
text: 'Error',
showConfirmButton: true,
timer: 3000
});
}
}
else if(res.status === "nodata") {
$('#pageLoader').hide();
//alert("No data available.");
Swal.fire({
icon: 'info',
title: 'No Data',
text: 'No data available.',
showConfirmButton: true,
timer: 3000
});
}
else {
$('#pageLoader').hide();
//alert("Error: " + response.message);
Swal.fire({
icon: 'error',
title: 'Error',
text: res.message || 'Error',
showConfirmButton: true,
timer: 3000
});
}
},
error: function(xhr, status, error) {
$('#pageLoader').hide();
// alert("Request failed: " + error);
Swal.fire({
icon: 'error',
title: 'Error',
text: error,
showConfirmButton: true,
timer: 3000
});
}
});
$('#zoneDetailsModal').on('shown.bs.modal', function () {
if ($.fn.DataTable.isDataTable('#WardDatatable')) {
let questionDatatable = $('#WardDatatable').DataTable();
questionDatatable.columns.adjust().draw();
}
});
});
function openZoneModal(zoneCode) {
console.log("Opening modal for zone:", zoneCode);
$('#pageLoader').show();
// Set data in modal (example)
$('#zoneModalTitle').text('Zone ' + zoneCode + ' Details');
$.ajax({
url: '/commissionerreview/api/sofabedcollection/getWardDetails',
method: 'GET',
data:{zone:zoneCode},
success: function(response) {
var res = Array.isArray(response) ? response[0] : response;
console.log("Response:", res);
$('#pageLoader').hide();
if (res.status === "Success") {
if (Array.isArray(res.data) && res.data.length > 0){
console.log("Details Array:", response);
let table = $('#WardDatatable').DataTable({
destroy: true,
autoWidth: true,
info: true,
data: res.data,
columns: [
{ data: 'Division', defaultContent: '-', className: 'text-center' },
{ data: 'Total_Requests_Received', defaultContent: '-', className: 'text-center' },
{ data: 'Cancelled_By_User', defaultContent: '-', className: 'text-center' },
{ data: 'Cancelled_By_Officer', defaultContent: '-', className: 'text-center' },
{ data: 'Overall_Complaints_Attended', defaultContent: '-', className: 'text-center' },
{ data: 'Overall_Pending_Complaints', defaultContent: '-', className: 'text-center' },
{ data: 'Today_Complaint_Received', defaultContent: '-', className: 'text-center' },
{ data: 'This_Week_Attended', defaultContent: '-', className: 'text-center' } ,
{ data: 'Balance_To_Be_Attended', defaultContent: '-', className: 'text-center' }
],
dom: 'Bfrtip',
buttons: [
{
extend: 'excelHtml5',
title: 'SofaBed_Zone_'+ zoneCode+'_Wardwise_Report',
text: '<i class="fa fa-file-excel"></i> Export to Excel',
className: 'btn btn-success btn-sm',
exportOptions: { columns: ':visible' }
},
{
extend: 'pdfHtml5',
title: 'SofaBed_Zone_'+ zoneCode+'_Wardwise_Report',
text: '<i class="fa fa-file-pdf"></i> Export to PDF',
className: 'btn btn-danger btn-sm',
orientation: 'portrait', // Optional: 'portrait' or 'landscape'
pageSize: 'A4', // Optional: 'A4', 'LETTER', etc.
exportOptions: { columns: ':visible' }
}
],
lengthMenu: [
[50, 100, 200, 500, -1],
['50 rows', '100 rows', '200 rows', 'Show all']
],
scrollY: '400px',
scrollX: true,
responsive: false,
searching: false,
ordering: false,
createdRow: function (row, data, dataIndex) {
if (dataIndex === res.data.length - 1) return;
const clickableCols = ['Overall_Complaints_Attended', 'Overall_Pending_Complaints', 'Today_Complaint_Received', 'This_Week_Attended','Balance_To_Be_Attended'];
clickableCols.forEach((col) => {
const value = parseInt(data[col]);
if (!isNaN(value) && value > 0) {
const colIndex = {
Overall_Complaints_Attended: 4,
Overall_Pending_Complaints: 5,
Today_Complaint_Received: 6,
This_Week_Attended: 7,
Balance_To_Be_Attended:8
}[col];
$('td:eq(' + colIndex + ')', row).css({
'color': '#007bff',
'text-decoration': 'underline',
'cursor': 'pointer'
});
}
});
}
});
$('#ward_formatted_oca_date').text('Overall Complaint attended up to ' + res.oca_date);
$('#ward_formatted_cur_date').text('Today complaint received ' + res.current_date);
$('#ward_formatted_twa_date').text('This week Attended ' + res.oca_date);
$('#ward_formatted_op_date').text('Overall Pending as on ' + res.current_date);
$('#zoneDetailsModal').modal('show');
}
else if (Array.isArray(res.data) && res.data.length === 0){
$('#pageLoader').hide();
//alert("No data available.");
Swal.fire({
icon: 'info',
title: 'No Data',
text: 'No data available.',
showConfirmButton: true,
timer: 3000
});
}
else{
$('#pageLoader').hide();
//alert("Error: " + response.message);
Swal.fire({
icon: 'error',
title: 'Error',
text: res.message || 'Error',
showConfirmButton: true,
timer: 3000
});
}
}
else if (res.status === "nodata") {
$('#pageLoader').hide();
//alert("No data available.");
Swal.fire({
icon: 'info',
title: 'No Data',
text: 'No data available.',
showConfirmButton: true,
timer: 3000
});
}
else {
$('#pageLoader').hide();
//alert("Error: " + response.message);
Swal.fire({
icon: 'error',
title: 'Error',
text: res.message || 'Error',
showConfirmButton: true,
timer: 3000
});
}
// Attach click handler after DataTable initialization
$('#WardDatatable tbody').off('click').on('click', 'td', function () {
let table = $('#WardDatatable').DataTable();
let rowData = table.row($(this).closest('tr')).data();
let columnIndex = table.cell(this).index().column;
// Define column-to-status mapping (based on your requirement)
const columnMap = {
4: 1, // open
5: 2, // completed
6: 3, // user_cancel
7: 4, // officer_cancel
8: 5 // pending
};
// Get column name using column index
let columnName = table.column(columnIndex).dataSrc();
// If clicked column is one of the target columns
if (columnMap[columnIndex]) {
let status = columnMap[columnIndex];
let value = rowData[columnName];
let division = rowData['Division'];
// Proceed only if value > 0
if (parseInt(value) > 0) {
openWardDetails(division, status);
}
}
});
},
error: function(xhr, status, error) {
$('#pageLoader').hide();
//alert("Request failed: " + error);
Swal.fire({
icon: 'error',
title: 'Error',
text: error,
showConfirmButton: true,
timer: 3000
});
}
});
}
function openWardDetails(division, status){
console.log("division:",division," status:",status);
// Optional: show in a modal or send AJAX
$('#pageLoader').show();
$.ajax({
url: '/commissionerreview/api/sofabedcollection/getWardStatusDetails',
method: 'GET',
data: {
ward: division,
status: status
},
success: function (response) {
$('#pageLoader').hide();
var res = Array.isArray(response) ? response[0] : response;
//console.log("Response:", res);
$('#pageLoader').hide();
console.log("Details:", res);
if(res.status === "Success"){
let modalBody = $("#detailscontent");
modalBody.empty(); // Clear previous content
if (Array.isArray(res.data) && res.data.length > 0){
res.data.forEach(item => {
// Create a container div for each record
let streetDiv = $('<div class="mb-4 p-3 border rounded shadow-sm bg-light"></div>');
let sourceText = '-';
if (item.is_app === "1") sourceText = 'Namma Chennai App';
else if (item.is_app === "2") sourceText = 'Whatsapp registration';
else if (item.is_app === "3") sourceText = '1913';
// Info section (2 columns layout)
let infoHtml = `
<div class="container-fluid">
<div class="row mb-2">
<div class="col-md-4"><strong>Zone:</strong> ${item.zone || '-'}</div>
<div class="col-md-4"><strong>Ward:</strong> ${item.division || '-'}</div>
<div class="col-md-4"><strong>Request ID:</strong> ${item.request_id || '-'}</div>
</div>
<div class="row mb-2">
<div class="col-md-4"><strong>User Name:</strong> ${item.user_name || '-'}</div>
<div class="col-md-4"><strong>Status:</strong> ${item.status || '-'}</div>
<div class="col-md-4"><strong>Mobile Number:</strong> ${item.mobile || '-'}</div>
</div>
<div class="row mb-2">
<div class="col-md-8"><strong>Address:</strong> ${item.address || '-'}</div>
<div class="col-md-4"><strong>Created Date:</strong> ${item.cdate || '-'}</div>
</div>
<div class="row mb-2">
<div class="col-md-4"><strong>Source:</strong> ${sourceText}</div>
</div>
</div>
`;
streetDiv.append(infoHtml);
// 🧾 Items section (as divs)
let itemsHtml = `
<div class="mt-3">
<p><strong>Items:</strong></p>
${
Array.isArray(item.items) && item.items.length > 0
? item.items.map((it, idx) => `
<div class="d-flex flex-wrap border rounded p-2 mb-2 ">
<div class="flex-fill"><strong>Item ${idx + 1}:</strong> ${it.item_name || '-'}</div>
<div class="flex-fill"><strong>Quantity:</strong> ${it.quantity ?? '-'}</div>
</div>
`).join("")
: `<p class="text-muted">No items available.</p>`
}
</div>
`;
streetDiv.append(itemsHtml);
let imagesHtml;
if(item.status === "completed"){
imagesHtml = `
<hr>
<div class="d-flex mt-2">
<div class="me-2 text-center" style="flex:1;">
<p><strong>User Uploaded Image</strong></p>
${
item.image_url
? (() => {
let beforePath = item.image_url.split(",")[0].trim();
return `<img src="${beforePath}"
alt="User's Uploaded Image"
style="width: 250px; height: 200px; object-fit: contain;"
/>`;
})()
: `<p>No image</p>`
}
</div>
<div class="text-center" style="flex:1;">
<p><strong>Officer Uploaded Image</strong></p>
${
item.officer_upload_url
? (() => {
let afterPath = item.officer_upload_url.split(",")[0].trim();
return `<img src="${afterPath}"
alt="Officer's Uploaded Image"
style="width: 250px; height: 200px; object-fit: contain;"
/>`;
})()
: `<p>No image</p>`
}
</div>
</div>
`;
}
else{
imagesHtml = `
<hr>
<div class="mt-2" style="text-align:center;">
<p><strong>Image:</strong></p>
${
item.image_url
? (() => {
// Handle multiple comma-separated images
return item.image_url.split(",").map(img => {
let trimmed = img.trim();
return `
<img src="${trimmed}"
alt="Image"
style="width: 250px; height: 200px; object-fit: contain;"
/>
`;
}).join("");
})()
: `<p class="text-muted">No image.</p>`
}
</div>
`;
}
streetDiv.append(imagesHtml);
modalBody.append(streetDiv);
});
$('#DeatilsModalTitle').text('Division '+division +' Details');
$('#DetailsModal').modal('show');
}
else if (Array.isArray(res.data) && res.data.length === 0){
$('#pageLoader').hide();
//alert("No data available.");
Swal.fire({
icon: 'info',
title: 'No Data',
text: 'No data available.',
showConfirmButton: true,
timer: 3000
});
}
else{
$('#pageLoader').hide();
//alert("Error: " + response.message);
Swal.fire({
icon: 'error',
title: 'Error',
text: response.message,
showConfirmButton: true,
timer: 3000
});
}
}
else if (res.status === "nodata") {
$('#pageLoader').hide();
//alert("No data available.");
Swal.fire({
icon: 'info',
title: 'No Data',
text: 'No data available.',
showConfirmButton: true,
timer: 3000
});
}
else {
$('#pageLoader').hide();
//alert("Error: " + response.message);
Swal.fire({
icon: 'error',
title: 'Error',
text: res.message,
showConfirmButton: true,
timer: 3000
});
}
},
error: function (xhr, status, error) {
$('#pageLoader').hide();
//alert("Request failed: " + error);
Swal.fire({
icon: 'error',
title: 'Error',
text: error,
showConfirmButton: true,
timer: 3000
});
}
});
}
</script>
</body>
</html>

440
src/main/resources/templates/modules/sofa_bed/pendingdetails.html

@ -0,0 +1,440 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<title>Pending Details of Sofa Bed collection</title>
<!-- Bootstrap 5 CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- DataTables CSS -->
<link href="https://cdn.datatables.net/1.13.4/css/jquery.dataTables.min.css" rel="stylesheet"/>
<link href="https://cdn.datatables.net/buttons/2.3.6/css/buttons.dataTables.min.css" rel="stylesheet"/>
<style>
table.dataTable th, table.dataTable td {
text-align: center;
vertical-align: middle;
border: 1px solid #000;
}
table.dataTable th{
background-color: #003366 !important;
color: white;
}
.dataTables_wrapper .dt-buttons {
margin-bottom: 10px;
}
.dataTables_filter {
margin-bottom: 25px; /* adjust as needed */
}
.page-header-title h4 {
margin: 20px 0;
text-align: center;
}
#zoneDetailsTable_wrapper .dataTables_scrollBody {
border: none !important;
}
#zoneDetailsTable td, #zoneDetailsTable th {
vertical-align: middle;
text-align: center;
white-space: nowrap;
}
.word-wrap {
white-space: normal !important;
word-wrap: break-word;
max-width: 200px; /* Adjust width as needed */
}
#opSummaryTable1, #opSummaryTable2 {
background-color: #fff;
border-radius: 8px;
padding: 10px;
}
</style>
</head>
<body>
<div class="page-header-title">
<h4>Pending Details of Sofa,Bed,furniture and Cloths</h4>
</div>
<div class="container">
<div class="row">
<!-- Left side: Source Summary -->
<div class="col-md-6">
<div id="opSummaryTable1" class="table-responsive">
<table id="SourceAbstracttable" class="table table-striped table-bordered display nowrap w-100">
<thead>
<tr>
<th class="text-center" style="white-space: normal; word-wrap: break-word;">Received From</th>
<th class="text-center" style="white-space: normal; word-wrap: break-word;">Total</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
<!-- Right side: Status Summary -->
<div class="col-md-6">
<div id="opSummaryTable2" class="table-responsive">
<table id="StatusAbstracttable" class="table table-striped table-bordered display nowrap w-100">
<thead>
<tr>
<th class="text-center" style="white-space: normal; word-wrap: break-word;">Status</th>
<th class="text-center" style="white-space: normal; word-wrap: break-word;">Total</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</div>
</div>
<hr>
<div id="opSummaryTable" style="display: block;" class="container">
<table id="ZoneOpDatatable" class="table table-striped table-bordered display nowrap w-100">
<thead>
<tr>
<th class="text-center">S.No</th>
<th class="text-center" style="white-space: normal; word-wrap: break-word;">Zone</th>
<th class="text-center" style="white-space: normal; word-wrap: break-word;">Division</th>
<th class="text-center" style="white-space: normal; word-wrap: break-word;">Request Id</th>
<th class="text-center" style="white-space: normal; word-wrap: break-word;">Registered Date</th>
<th class="text-center" style="white-space: normal; word-wrap: break-word;">User Name</th>
<th class="text-center" style="white-space: normal; word-wrap: break-word;">Mobile</th>
<th class="text-center" style="white-space: normal; word-wrap: break-word;">Address</th>
<th class="text-center" style="white-space: normal; word-wrap: break-word;">Street Name</th>
<th class="text-center" style="white-space: normal; word-wrap: break-word;">Image</th>
<th class="text-center" style="white-space: normal; word-wrap: break-word;">Remarks</th>
<th class="text-center" style="white-space: normal; word-wrap: break-word;">Items</th>
<th class="text-center" style="white-space: normal; word-wrap: break-word;">Source</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div id="pageLoader" style="display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255, 255, 255, 0.8); z-index: 9999; text-align: center;">
<div style="position: relative; top: 50%; transform: translateY(-50%);">
<div class="spinner-border text-primary" role="status" style="width: 3rem; height: 3rem;">
<span class="sr-only"></span>
</div>
<!-- Add the 'Please wait' text below the spinner -->
<p style="margin-top: 1rem; font-size: 1.2rem; color: #007bff;">Please wait...</p>
</div>
</div>
<!-- Scripts -->
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
<!-- DataTables JS -->
<script src="https://cdn.datatables.net/1.13.4/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.3.6/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.3.6/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.3.6/js/buttons.print.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js"></script>
<!-- SweetAlert -->
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script>
$(document).ready(function () {
$('#pageLoader').show();
$.ajax({
url: '/commissionerreview/api/sofabedcollection/getPendingDetails',
method: 'GET',
success: function(response) {
// Safely extract data whether it's an array or an object
var res = Array.isArray(response) ? response[0] : response;
console.log("Response:", res);
$('#pageLoader').hide();
if (res.status === "Success") {
if (Array.isArray(res.data) && res.data.length > 0) {
console.log("Details Array:", response);
let table = $('#ZoneOpDatatable').DataTable({
destroy: true,
autoWidth: true,
info: true,
data: res.data, // using response directly
columns: [
{
data: null,
render: (data, type, row, meta) => meta.row + 1,
className: 'text-center'
},
{ data: 'zone', defaultContent: '-', className: 'text-center' },
{ data: 'division', defaultContent: '-', className: 'text-center' },
{ data: 'request_id', defaultContent: '-', className: 'text-center' },
{ data: 'cdate', defaultContent: '-', className: 'text-center' },
{ data: 'user_name', defaultContent: '-', className: 'text-center' },
{ data: 'mobile', defaultContent: '-', className: 'text-center' },
{ data: 'address', defaultContent: '-', className: 'text-center word-wrap' },
{ data: 'street_name', defaultContent: '-', className: 'text-center word-wrap' },
{
data: 'image_url',
defaultContent: '-',
className: 'text-center',
render: function (data, type, row) {
if (!data || data === "null" || data.trim() === "") {
return '-';
}
// ✅ Make it a clickable hyperlink opening in a new tab
return `<a href="${data}" target="_blank" style="color: #007bff; text-decoration: underline;">View</a>`;
}
},
{ data: 'remarks', defaultContent: '-', className: 'text-center word-wrap' },
{
data: 'items',
defaultContent: '-',
className: 'text-center word-wrap',
render: function (data, type, row) {
if (Array.isArray(data) && data.length > 0) {
return data.map(item => `${item.item_name}-${item.quantity}`).join(', ');
}
return '-';
}
},
{ data: 'Source', defaultContent: '-', className: 'text-center' }
],
dom: 'Bfrtip',
buttons: [
{
extend: 'excelHtml5',
title: 'SofaBed_Pending_Report',
text: '<i class="fa fa-file-excel"></i> Export to Excel',
className: 'btn btn-success btn-sm',
exportOptions: { columns: ':visible' }
}
],
lengthMenu: [
[50, 100, 200, 500, -1],
['50 rows', '100 rows', '200 rows', 'Show all']
],
scrollY: 'auto',
scrollX: true,
responsive: false,
searching: true,
ordering: false
});
if (Array.isArray(res.source_data) && res.source_data.length > 0) {
let table1 = $('#SourceAbstracttable').DataTable({
destroy: true,
autoWidth: true,
info: false,
data: res.source_data, // using response directly
columns: [
{ data: 'SOURCE',
render: function (data, type, row) {
// Skip last row
if (row === res.source_data[res.source_data.length - 1]) {
return `<b>${data}</b>`;
} else {
return data;
}
}
},
{ data: 'count', defaultContent: '-', className: 'text-center word-wrap' }
],
dom: 'Bfrtip',
buttons: [
{
extend: 'excelHtml5',
title: 'SofaBed_Pending_Source_Report',
text: '<i class="fa fa-file-excel"></i> Export to Excel',
className: 'btn btn-success btn-sm',
exportOptions: { columns: ':visible' }
}
],
paging:false,
scrollY: 'auto',
scrollX: true,
responsive: false,
searching: false,
ordering: false
});
}
if (Array.isArray(res.status_data) && res.status_data.length > 0) {
let table1 = $('#StatusAbstracttable').DataTable({
destroy: true,
autoWidth: true,
info: false,
data: res.status_data, // using response directly
columns: [
{ data: 'status_category',
render: function (data, type, row) {
// Skip last row
if (row === res.status_data[res.status_data.length - 1]) {
return `<b>${data}</b>`;
} else {
return data;
}
}
},
{ data: 'total_count', defaultContent: '-', className: 'text-center word-wrap' }
],
dom: 'Bfrtip',
buttons: [
{
extend: 'excelHtml5',
title: 'SofaBed_Pending_Status_Report',
text: '<i class="fa fa-file-excel"></i> Export to Excel',
className: 'btn btn-success btn-sm',
exportOptions: { columns: ':visible' }
}
],
paging:false,
scrollY: 'auto',
scrollX: true,
responsive: false,
searching: false,
ordering: false
});
}
}
else if(Array.isArray(res.data) && res.data.length === 0) {
$('#pageLoader').hide();
//alert("No data available.");
Swal.fire({
icon: 'info',
title: 'No Data',
text: 'No data available.',
showConfirmButton: true,
timer: 3000
});
}
else {
$('#pageLoader').hide();
//alert("Error: " + response.message);
Swal.fire({
icon: 'error',
title: 'Error',
text: 'Error',
showConfirmButton: true,
timer: 3000
});
}
}
else if(res.status === "nodata") {
$('#pageLoader').hide();
//alert("No data available.");
Swal.fire({
icon: 'info',
title: 'No Data',
text: 'No data available.',
showConfirmButton: true,
timer: 3000
});
}
else {
$('#pageLoader').hide();
//alert("Error: " + response.message);
Swal.fire({
icon: 'error',
title: 'Error',
text: res.message,
showConfirmButton: true,
timer: 3000
});
}
},
error: function(xhr, status, error) {
$('#pageLoader').hide();
// alert("Request failed: " + error);
Swal.fire({
icon: 'error',
title: 'Error',
text: error,
showConfirmButton: true,
timer: 3000
});
}
});
/* $('#zoneDetailsModal').on('shown.bs.modal', function () {
if ($.fn.DataTable.isDataTable('#WardDatatable')) {
let questionDatatable = $('#WardDatatable').DataTable();
questionDatatable.columns.adjust().draw();
}
}); */
});
</script>
</body>
</html>
Loading…
Cancel
Save