Browse Source

implemented resuce list and new sms meeting list

master
AJITHKUMAR12 2 weeks ago
parent
commit
b91f33ae6f
  1. 16
      src/main/java/in/gov/chennaicorporation/gccoffice/configuration/DataSourceConfig.java
  2. 8
      src/main/java/in/gov/chennaicorporation/gccoffice/shelterinspection/Controller/MainController.java
  3. 243
      src/main/java/in/gov/chennaicorporation/gccoffice/shelterinspection/Controller/ShelterInspectionController.java
  4. 480
      src/main/java/in/gov/chennaicorporation/gccoffice/shelterinspection/Service/ShelterInspectionService.java
  5. 1015
      src/main/java/in/gov/chennaicorporation/gccoffice/shelterinspection/Service/ShelterService.java
  6. 17
      src/main/resources/templates/modules/shelterinspection/dashboard.html
  7. 984
      src/main/resources/templates/modules/shelterinspection/resucelist.html
  8. 800
      src/main/resources/templates/modules/shelterinspection/smcmeetinglist.html
  9. 131
      src/main/resources/templates/modules/shelterinspection/visitlist.html

16
src/main/java/in/gov/chennaicorporation/gccoffice/configuration/DataSourceConfig.java

@ -30,8 +30,9 @@ public class DataSourceConfig {
// 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
@ -453,6 +454,17 @@ public class DataSourceConfig {
return dataSource; return dataSource;
} }
/////////////// Shelter /////////////////////
@Bean(name = "mysqlShelterDataSource")
public DataSource mysqlShelterDataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
dataSource.setUrl("jdbc:mysql://" + host + "/gcc_shelter");
dataSource.setUsername("root");
dataSource.setPassword(dbpassword);
return dataSource;
}
////////////////////////////// (For GCC USER) //////////////////////// ////////////////////////////// (For GCC USER) ////////////////////////
@Bean(name = "mysqlGCCUserDataSource") @Bean(name = "mysqlGCCUserDataSource")
public DataSource mysqlGCCUserDataSource() { public DataSource mysqlGCCUserDataSource() {

8
src/main/java/in/gov/chennaicorporation/gccoffice/shelterinspection/Controller/MainController.java

@ -28,6 +28,14 @@ public class MainController {
return "modules/shelterinspection/complaintlist"; return "modules/shelterinspection/complaintlist";
} }
@GetMapping("/smcmeetinglist")
public String SmcMeetinglist() {
return "modules/shelterinspection/smcmeetinglist";
}
@GetMapping("/resucelist")
public String Resucelist() {
return "modules/shelterinspection/resucelist";
}
} }

243
src/main/java/in/gov/chennaicorporation/gccoffice/shelterinspection/Controller/ShelterInspectionController.java

@ -19,7 +19,7 @@ import org.springframework.web.client.RestTemplate;
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; import in.gov.chennaicorporation.gccoffice.configuration.AppConfig;
import in.gov.chennaicorporation.gccoffice.shelterinspection.Service.MasterShelterService; import in.gov.chennaicorporation.gccoffice.shelterinspection.Service.MasterShelterService;
import in.gov.chennaicorporation.gccoffice.shelterinspection.Service.ShelterInspectionService; import in.gov.chennaicorporation.gccoffice.shelterinspection.Service.ShelterInspectionService;
import in.gov.chennaicorporation.gccoffice.shelterinspection.Service.ShelterService;
@RestController @RestController
@RequestMapping("/gcc/api/shelterinspection") @RequestMapping("/gcc/api/shelterinspection")
@ -28,6 +28,9 @@ public class ShelterInspectionController {
@Autowired @Autowired
private ShelterInspectionService shelterApiService; private ShelterInspectionService shelterApiService;
@Autowired
private ShelterService shelterService1;
@Autowired @Autowired
private MasterShelterService masterShelterService; private MasterShelterService masterShelterService;
@ -40,7 +43,7 @@ public class ShelterInspectionController {
this.appConfig = appConfig; this.appConfig = appConfig;
} }
//private final RestTemplate restTemplate = new RestTemplate();
// private final RestTemplate restTemplate = new RestTemplate();
@GetMapping("/Sheltercount") @GetMapping("/Sheltercount")
public ResponseEntity<Map<String, Object>> getTotalCount() { public ResponseEntity<Map<String, Object>> getTotalCount() {
@ -54,35 +57,35 @@ public class ShelterInspectionController {
} }
@GetMapping("/dashboard") @GetMapping("/dashboard")
public Map<String,Object> dashboard(
public Map<String, Object> dashboard(
@RequestParam String type, @RequestParam String type,
@RequestParam String value){
@RequestParam String value) {
return shelterApiService.getDashboardData(type,value);
return shelterApiService.getDashboardData(type, value);
} }
@GetMapping("/top5Shelters") @GetMapping("/top5Shelters")
public List<Map<String,Object>> top5Shelters(
public List<Map<String, Object>> top5Shelters(
@RequestParam String type, @RequestParam String type,
@RequestParam String value){
@RequestParam String value) {
return shelterApiService.getTop5Shelters(type,value);
return shelterApiService.getTop5Shelters(type, value);
} }
@GetMapping("/regionSummary") @GetMapping("/regionSummary")
public List<Map<String,Object>> regionSummary(
public List<Map<String, Object>> regionSummary(
@RequestParam String type, @RequestParam String type,
@RequestParam String value){
@RequestParam String value) {
return shelterApiService.getRegionSummary(type,value);
return shelterApiService.getRegionSummary(type, value);
} }
@GetMapping("/fundReceivedSummary") @GetMapping("/fundReceivedSummary")
public List<Map<String,Object>> fundSummary(
public List<Map<String, Object>> fundSummary(
@RequestParam String type, @RequestParam String type,
@RequestParam String value){
@RequestParam String value) {
return shelterApiService.getFundReceivedSummary(type,value);
return shelterApiService.getFundReceivedSummary(type, value);
} }
@GetMapping("/fundReceivedShelterDetails") @GetMapping("/fundReceivedShelterDetails")
@ -90,39 +93,38 @@ public class ShelterInspectionController {
@RequestParam String type, @RequestParam String type,
@RequestParam String value) { @RequestParam String value) {
return shelterApiService.getFundReceivedShelterDetails( type, value);
return shelterApiService.getFundReceivedShelterDetails(type, value);
} }
@GetMapping("/monthlyTrends") @GetMapping("/monthlyTrends")
public List<Map<String,Object>> monthlyTrends(
public List<Map<String, Object>> monthlyTrends(
@RequestParam String type, @RequestParam String type,
@RequestParam String value){
@RequestParam String value) {
return shelterApiService.getMonthlyTrends(type,value);
return shelterApiService.getMonthlyTrends(type, value);
} }
@GetMapping("/weeklyVisits") @GetMapping("/weeklyVisits")
public List<Map<String,Object>> weeklyVisits(
public List<Map<String, Object>> weeklyVisits(
@RequestParam String type, @RequestParam String type,
@RequestParam String value){
@RequestParam String value) {
List<Map<String,Object>> results = shelterApiService.getWeeklyVisits(type,value);
System.out.println("Weekly Visits Results:" +results);
List<Map<String, Object>> results = shelterApiService.getWeeklyVisits(type, value);
System.out.println("Weekly Visits Results:" + results);
return results; return results;
} }
@GetMapping("/latestVisitShelters") @GetMapping("/latestVisitShelters")
public List<Map<String,Object>> latestVisitShelters(
public List<Map<String, Object>> latestVisitShelters(
@RequestParam String type, @RequestParam String type,
@RequestParam String value){
@RequestParam String value) {
return shelterApiService.getLatestVisitShelters(type,value);
return shelterApiService.getLatestVisitShelters(type, value);
} }
@GetMapping("/shelterList") @GetMapping("/shelterList")
public List<Map<String,Object>> shelterList(
public List<Map<String, Object>> shelterList(
@RequestParam(required = false) String zone, @RequestParam(required = false) String zone,
@RequestParam(required = false) String category) { @RequestParam(required = false) String category) {
return shelterApiService.getShelterList(zone, category); return shelterApiService.getShelterList(zone, category);
@ -130,18 +132,18 @@ public class ShelterInspectionController {
} }
@GetMapping("/visitList") @GetMapping("/visitList")
public List<Map<String,Object>> visitList(
@RequestParam(required=false) String fromDate,
@RequestParam(required=false) String toDate,
@RequestParam(required=false) String zone,
@RequestParam(required=false) String cdo){
public List<Map<String, Object>> visitList(
@RequestParam(required = false) String fromDate,
@RequestParam(required = false) String toDate,
@RequestParam(required = false) String zone,
@RequestParam(required = false) String cdo) {
return shelterApiService.getVisitList( fromDate, toDate, zone, cdo);
return shelterApiService.getVisitList(fromDate, toDate, zone, cdo);
} }
@GetMapping("/visitDetails") @GetMapping("/visitDetails")
public Map<String,Object> visitDetails(
@RequestParam String surveyId){
public Map<String, Object> visitDetails(
@RequestParam String surveyId) {
return shelterApiService.getVisitDetails(surveyId); return shelterApiService.getVisitDetails(surveyId);
@ -153,51 +155,27 @@ public class ShelterInspectionController {
try { try {
String apiUrl =
appConfig.shelterurl + "/questions?cid=" + cid;
String apiUrl = appConfig.shelterurl + "/questions?cid=" + cid;
System.out.println(
"API URL for night inspection questions: " + apiUrl
);
System.out.println("API URL for night inspection questions: " + apiUrl);
ResponseEntity<Object> response =
restTemplate.getForEntity(
apiUrl,
Object.class
);
ResponseEntity<Object> response = restTemplate.getForEntity(apiUrl, Object.class);
return ResponseEntity
.status(response.getStatusCode())
.body(response.getBody());
return ResponseEntity.status(response.getStatusCode()).body(response.getBody());
} catch (HttpClientErrorException e) { } catch (HttpClientErrorException e) {
System.out.println(
"Question API Client Error: " +
e.getStatusCode()
);
return ResponseEntity
.status(e.getStatusCode())
.body(e.getResponseBodyAsString());
System.out.println("Question API Client Error: " + e.getStatusCode());
return ResponseEntity.status(e.getStatusCode()).body(e.getResponseBodyAsString());
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
System.out.println(
"Question API Server Error: " +
e.getStatusCode()
);
return ResponseEntity
.status(e.getStatusCode())
.body(e.getResponseBodyAsString());
System.out.println("Question API Server Error: " + e.getStatusCode());
return ResponseEntity.status(e.getStatusCode()).body(e.getResponseBodyAsString());
} catch (ResourceAccessException e) { } catch (ResourceAccessException e) {
System.out.println(
"Question API Connection Error: " +
e.getMessage()
);
System.out.println("Question API Connection Error: " + e.getMessage());
return ResponseEntity return ResponseEntity
.status(HttpStatus.BAD_GATEWAY) .status(HttpStatus.BAD_GATEWAY)
@ -205,91 +183,71 @@ public class ShelterInspectionController {
Map.of( Map.of(
"status", false, "status", false,
"message", "message",
"Unable to connect to Question Master API."
)
);
"Unable to connect to Question Master API."));
} catch (Exception e) { } catch (Exception e) {
System.out.println(
"Question API Exception"
);
System.out.println("Question API Exception");
e.printStackTrace(); e.printStackTrace();
return ResponseEntity return ResponseEntity
.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(
Map.of(
"status", false,
"message",
"Unable to load question details."
)
);
.status(HttpStatus.INTERNAL_SERVER_ERROR).body(
Map.of("status", false, "message", "Unable to load question details."));
}
}
@GetMapping("/shelterMeetingList")
public List<Map<String, Object>> shelterMeetingList(
@RequestParam(required = false) String fromDate,
@RequestParam(required = false) String toDate,
@RequestParam(required = false) String zone,
@RequestParam(required = false) String category) {
return shelterService1.getShelterMeetingList(fromDate, toDate, zone, category);
}
@GetMapping("/shelterMeetingDetails")
public List<Map<String, Object>> shelterMeetingDetails(
@RequestParam String uqid,
@RequestParam(required = false) String fromDate,
@RequestParam(required = false) String toDate) {
return shelterService1.getShelterMeetingDetails(uqid, fromDate, toDate);
} }
@GetMapping("/shelterMeetingMinDate")
public String shelterMeetingMinDate() {
return shelterService1.getShelterMeetingMinDate();
} }
@GetMapping("/shelterResuceList")
public List<Map<String, Object>> shelterResuceList(
@RequestParam(required = false) String fromDate,
@RequestParam(required = false) String toDate) {
return shelterService1.getShelterRescueList(fromDate, toDate);
}
// @GetMapping("/questions")
// public ResponseEntity<?> getquestionsDetails(@RequestParam("cid") String cid) {
//
// try {
//
// String apiUrl = appConfig.shelterurl + "/questions?cid=" + cid;
//
// System.out.println("apiUrl for night inspection questions:" +apiUrl);
//
// ResponseEntity<String> response =
// restTemplate.getForEntity(apiUrl, String.class);
//
// return ResponseEntity
// .status(response.getStatusCode())
// .body(response.getBody());
//
// } catch (HttpClientErrorException e) {
//
// return ResponseEntity
// .status(e.getStatusCode())
// .body(e.getResponseBodyAsString());
//
// } catch (HttpServerErrorException e) {
//
// return ResponseEntity
// .status(e.getStatusCode())
// .body(e.getResponseBodyAsString());
//
// } catch (ResourceAccessException e) {
//
// return ResponseEntity
// .status(HttpStatus.BAD_GATEWAY)
// .body("Unable to connect to Question Master API.");
//
// } catch (Exception e) {
//
// System.out.println("apiUrl for night inspection questions Exception.....");
// e.printStackTrace();
//
// return ResponseEntity
// .status(HttpStatus.INTERNAL_SERVER_ERROR)
// .body("Unable to load question details.");
//
// }
// }
// @GetMapping("/questions")
// public ResponseEntity<?> getQuestions(@RequestParam String cid) {
//
// return restTemplate.getForEntity(
// "https://gccservices.in/gccofficialapp/api/shelterinspection/questions?cid="+cid,
// Object.class
// );
//
// }
// @GetMapping("/shelterList")
// public List<Map<String,Object>> shelterList(){
// return shelterApiService.getShelterList();
// }
@GetMapping("/shelterResuceDetails")
public List<Map<String, Object>> shelterResuceDetails(
@RequestParam String resuceDesignationId,
@RequestParam String uqid,
@RequestParam(required = false) String fromDate,
@RequestParam(required = false) String toDate) {
return shelterService1.getShelterRescueDetails(resuceDesignationId, uqid, fromDate, toDate);
}
@GetMapping("/shelterRescuedPeopleDetails")
public List<Map<String, Object>> getShelterRescuedPeopleDetails(
@RequestParam String surveyId,
@RequestParam(required = false) String fromDate,
@RequestParam(required = false) String toDate) {
return shelterService1.getShelterRescuedPeopleDetails(surveyId, fromDate, toDate);
}
@GetMapping("/shelterResuceMinDate")
public String shelterResuceMinDate() {
return shelterService1.getShelterResuceMinDate();
}
@GetMapping("/categories") @GetMapping("/categories")
public List<String> getCategories() { public List<String> getCategories() {
@ -311,5 +269,4 @@ public class ShelterInspectionController {
return masterShelterService.getAvailableYears(); return masterShelterService.getAvailableYears();
} }
} }

480
src/main/java/in/gov/chennaicorporation/gccoffice/shelterinspection/Service/ShelterInspectionService.java

@ -29,12 +29,18 @@ public class ShelterInspectionService {
@Autowired @Autowired
private JdbcTemplate jdbcTemplate; private JdbcTemplate jdbcTemplate;
// private JdbcTemplate shelterJdbcTemplate;
@Autowired @Autowired
public void setDataSource(@Qualifier("mysqlShelterinspectionDataSource") DataSource dataSource) { public void setDataSource(@Qualifier("mysqlShelterinspectionDataSource") DataSource dataSource) {
this.jdbcTemplate = new JdbcTemplate(dataSource); this.jdbcTemplate = new JdbcTemplate(dataSource);
} }
// @Autowired
// public void setShelterDataSource(@Qualifier("mysqlShelterDataSource") DataSource dataSource) {
// this.shelterJdbcTemplate = new JdbcTemplate(dataSource);
// }
private final RestTemplate restTemplate = new RestTemplate(); private final RestTemplate restTemplate = new RestTemplate();
private static final String API_URL = "https://nightshelter.gccservices.in/api/shelters/"; private static final String API_URL = "https://nightshelter.gccservices.in/api/shelters/";
@ -53,6 +59,7 @@ public class ShelterInspectionService {
return shelters != null ? shelters.size() : 0; return shelters != null ? shelters.size() : 0;
} }
// Dashboard
// Dashboard // Dashboard
public Map<String, Object> getDashboardData(String type, String value) { public Map<String, Object> getDashboardData(String type, String value) {
@ -60,14 +67,17 @@ public class ShelterInspectionService {
String dateCondition = ""; String dateCondition = "";
String residentQuery = ""; String residentQuery = "";
String residentParameter = "";
String residentParameter = value;
String resuceQuery = "";
// ========================================== // ==========================================
// DAY // DAY
// ========================================== // ==========================================
/* /*
* For each shelter: Take the latest qid = 4 record and up to the selected date.
* For each shelter:
* Take the latest qid = 4 record up to the selected date.
*/ */
if ("day".equalsIgnoreCase(type)) { if ("day".equalsIgnoreCase(type)) {
@ -76,38 +86,62 @@ public class ShelterInspectionService {
residentQuery = """ residentQuery = """
COALESCE( COALESCE(
(SELECT SUM(CAST(t.answer AS UNSIGNED))
(
SELECT SUM(CAST(t.answer AS UNSIGNED))
FROM ( FROM (
SELECT sld.shelter_id, r.answer, ROW_NUMBER() OVER
(PARTITION BY sld.shelter_id ORDER BY r.cdate DESC, r.id DESC) AS rn
SELECT
sld.shelter_id,
r.answer,
ROW_NUMBER() OVER (
PARTITION BY sld.shelter_id
ORDER BY r.cdate DESC, r.id DESC
) AS rn
FROM night_shelter_inspection_response r FROM night_shelter_inspection_response r
INNER JOIN surveyor_location_details sld ON sld.survey_id = r.survey_id AND sld.loginId = r.cby
WHERE r.qid = 4 AND r.isactive = 1 AND r.isdelete = 0
AND sld.is_active = 1 AND sld.is_delete = 0
AND DATE_FORMAT(r.cdate, '%Y-%m') = DATE_FORMAT( STR_TO_DATE(?, '%Y-%m-%d'), '%Y-%m')
AND DATE(r.cdate) <= ?) t
WHERE t.rn = 1), 0) AS totalResidents,
INNER JOIN surveyor_location_details sld
ON sld.survey_id = r.survey_id
AND sld.loginId = r.cby
WHERE r.qid = 4
AND r.isactive = 1
AND r.isdelete = 0
AND sld.is_active = 1
AND sld.is_delete = 0
AND DATE_FORMAT(r.cdate, '%Y-%m') =
DATE_FORMAT(
STR_TO_DATE(?, '%Y-%m-%d'),
'%Y-%m'
)
AND DATE(r.cdate) <= ?
) t
WHERE t.rn = 1
),
0
) AS totalResidents,
"""; """;
residentParameter = value;
// Rescue count from gcc_shelter
resuceQuery = """
COALESCE(
(
SELECT SUM(
CASE
WHEN qid = 5
THEN CAST(answer AS UNSIGNED)
END
)
FROM gcc_shelter.shelter_resuce_response
WHERE isactive = 1
AND isdelete = 0
AND DATE(cdate) = ?
),
0
) AS resuceCount,
""";
} }
// ========================================== // ==========================================
// MONTH // MONTH
// ========================================== // ==========================================
/*
* Only records from selected month.
* For each shelter: Take latest qid = 4 record in that month. and Then SUM all shelters.
*/
else if ("month".equalsIgnoreCase(type)) { else if ("month".equalsIgnoreCase(type)) {
dateCondition = dateCondition =
@ -115,36 +149,57 @@ public class ShelterInspectionService {
residentQuery = """ residentQuery = """
COALESCE( COALESCE(
(SELECT SUM(CAST(t.answer AS UNSIGNED))
(
SELECT SUM(CAST(t.answer AS UNSIGNED))
FROM ( FROM (
SELECT sld.shelter_id, r.answer, ROW_NUMBER() OVER
(PARTITION BY sld.shelter_id ORDER BY r.cdate DESC, r.id DESC) AS rn
SELECT
sld.shelter_id,
r.answer,
ROW_NUMBER() OVER (
PARTITION BY sld.shelter_id
ORDER BY r.cdate DESC, r.id DESC
) AS rn
FROM night_shelter_inspection_response r FROM night_shelter_inspection_response r
INNER JOIN surveyor_location_details sld ON sld.survey_id = r.survey_id AND sld.loginId = r.cby
WHERE r.qid = 4 AND r.isactive = 1 AND r.isdelete = 0
AND sld.is_active = 1 AND sld.is_delete = 0
AND DATE_FORMAT(r.cdate, '%Y-%m') = ?) t
WHERE t.rn = 1), 0) AS totalResidents,
INNER JOIN surveyor_location_details sld
ON sld.survey_id = r.survey_id
AND sld.loginId = r.cby
WHERE r.qid = 4
AND r.isactive = 1
AND r.isdelete = 0
AND sld.is_active = 1
AND sld.is_delete = 0
AND DATE_FORMAT(r.cdate, '%Y-%m') = ?
) t
WHERE t.rn = 1
),
0
) AS totalResidents,
"""; """;
residentParameter = value;
// Rescue count from gcc_shelter
resuceQuery = """
COALESCE(
(
SELECT SUM(
CASE
WHEN qid = 5
THEN CAST(answer AS UNSIGNED)
END
)
FROM gcc_shelter.shelter_resuce_response
WHERE isactive = 1
AND isdelete = 0
AND DATE_FORMAT(cdate, '%Y-%m') = ?
),
0
) AS resuceCount,
""";
} }
// ========================================== // ==========================================
// YEAR // YEAR
// ========================================== // ==========================================
/*
* Only records from selected year.
* For each shelter: Take latest qid = 4 record in that year. and Then SUM all shelters.
*/
else if ("year".equalsIgnoreCase(type)) { else if ("year".equalsIgnoreCase(type)) {
dateCondition = dateCondition =
@ -154,29 +209,51 @@ public class ShelterInspectionService {
COALESCE( COALESCE(
( (
SELECT SUM(CAST(t.answer AS UNSIGNED)) SELECT SUM(CAST(t.answer AS UNSIGNED))
FROM ( FROM (
SELECT sld.shelter_id, r.answer, ROW_NUMBER() OVER
(PARTITION BY sld.shelter_id ORDER BY r.cdate DESC, r.id DESC) AS rn
SELECT
sld.shelter_id,
r.answer,
ROW_NUMBER() OVER (
PARTITION BY sld.shelter_id
ORDER BY r.cdate DESC, r.id DESC
) AS rn
FROM night_shelter_inspection_response r FROM night_shelter_inspection_response r
INNER JOIN surveyor_location_details sld ON sld.survey_id = r.survey_id AND sld.loginId = r.cby
WHERE r.qid = 4 AND r.isactive = 1 AND r.isdelete = 0
AND sld.is_active = 1 AND sld.is_delete = 0
INNER JOIN surveyor_location_details sld
ON sld.survey_id = r.survey_id
AND sld.loginId = r.cby
WHERE r.qid = 4
AND r.isactive = 1
AND r.isdelete = 0
AND sld.is_active = 1
AND sld.is_delete = 0
AND YEAR(r.cdate) = ? AND YEAR(r.cdate) = ?
) t ) t
WHERE t.rn = 1), 0) AS totalResidents,
WHERE t.rn = 1
),
0
) AS totalResidents,
"""; """;
residentParameter = value;
// Rescue count from gcc_shelter
resuceQuery = """
COALESCE(
(
SELECT SUM(
CASE
WHEN qid = 5
THEN CAST(answer AS UNSIGNED)
END
)
FROM gcc_shelter.shelter_resuce_response
WHERE isactive = 1
AND isdelete = 0
AND YEAR(cdate) = ?
),
0
) AS resuceCount,
""";
} }
// ========================================== // ==========================================
// DASHBOARD SQL // DASHBOARD SQL
// ========================================== // ==========================================
@ -185,49 +262,308 @@ public class ShelterInspectionService {
SELECT SELECT
""" + residentQuery + """
""" + residentQuery + resuceQuery + """
COUNT(DISTINCT survey_id) AS numberOfVisits, COUNT(DISTINCT survey_id) AS numberOfVisits,
COALESCE(SUM(CASE WHEN qid = 16 THEN CAST(answer AS UNSIGNED) END), 0) AS rehabilitation,
COALESCE(
SUM(
CASE
WHEN qid = 16
THEN CAST(answer AS UNSIGNED)
END
),
0
) AS rehabilitation,
COALESCE(SUM(CASE WHEN qid = 17 THEN CAST(answer AS UNSIGNED) END), 0) AS reintegration,
COALESCE(
SUM(
CASE
WHEN qid = 17
THEN CAST(answer AS UNSIGNED)
END
),
0
) AS reintegration,
COALESCE(SUM(CASE WHEN qid = 48 THEN CAST(answer AS UNSIGNED) END), 0) AS entitlementAccess,
COALESCE(
SUM(
CASE
WHEN qid = 48
THEN CAST(answer AS UNSIGNED)
END
),
0
) AS entitlementAccess,
COALESCE(SUM(CASE WHEN qid = 11 THEN CAST(answer AS UNSIGNED) END), 0) AS leftWithInfo,
COALESCE(
SUM(
CASE
WHEN qid = 11
THEN CAST(answer AS UNSIGNED)
END
),
0
) AS leftWithInfo,
COALESCE(SUM(CASE WHEN qid = 13 THEN CAST(answer AS UNSIGNED) END), 0) AS leftWithoutInfo,
COALESCE(
SUM(
CASE
WHEN qid = 13
THEN CAST(answer AS UNSIGNED)
END
),
0
) AS leftWithoutInfo,
COALESCE(SUM(CASE WHEN qid = 10 THEN CAST(answer AS UNSIGNED) END), 0) AS deathCount
COALESCE(
SUM(
CASE
WHEN qid = 10
THEN CAST(answer AS UNSIGNED)
END
),
0
) AS deathCount
FROM night_shelter_inspection_response FROM night_shelter_inspection_response
WHERE isactive = 1 AND isdelete = 0
WHERE isactive = 1
AND isdelete = 0
""" + dateCondition; """ + dateCondition;
// ========================================== // ==========================================
// EXECUTE QUERY // EXECUTE QUERY
// ========================================== // ==========================================
if (dateCondition.isEmpty()) { if (dateCondition.isEmpty()) {
response.putAll(jdbcTemplate.queryForMap(dashboardSql));
response.putAll(
jdbcTemplate.queryForMap(dashboardSql)
);
} else if ("day".equalsIgnoreCase(type)) { } else if ("day".equalsIgnoreCase(type)) {
response.putAll(jdbcTemplate.queryForMap(dashboardSql, value, value, value));
/*
* Parameters:
*
* 1. Resident month
* 2. Resident selected date
* 3. Rescue selected date
* 4. Dashboard selected date
*/
response.putAll(
jdbcTemplate.queryForMap(
dashboardSql,
value,
value,
value,
value
)
);
} else { } else {
response.putAll(jdbcTemplate.queryForMap(dashboardSql, residentParameter, value));
/*
* Parameters:
*
* 1. Resident parameter
* 2. Rescue parameter
* 3. Dashboard date parameter
*/
response.putAll(
jdbcTemplate.queryForMap(
dashboardSql,
residentParameter,
value,
value
)
);
} }
return response; return response;
} }
// public Map<String, Object> getDashboardData(String type, String value) {
//
// Map<String, Object> response = new LinkedHashMap<>();
//
// String dateCondition = "";
// String residentQuery = "";
// String residentParameter = "";
//
//
// // ==========================================
// // DAY
// // ==========================================
// /*
// * For each shelter: Take the latest qid = 4 record and up to the selected date.
// */
//
// if ("day".equalsIgnoreCase(type)) {
//
// dateCondition = " AND DATE(cdate) = ? ";
//
// residentQuery = """
// COALESCE(
// (SELECT SUM(CAST(t.answer AS UNSIGNED))
// FROM (
// SELECT sld.shelter_id, r.answer, ROW_NUMBER() OVER
// (PARTITION BY sld.shelter_id ORDER BY r.cdate DESC, r.id DESC) AS rn
// FROM night_shelter_inspection_response r
//
// INNER JOIN surveyor_location_details sld ON sld.survey_id = r.survey_id AND sld.loginId = r.cby
//
// WHERE r.qid = 4 AND r.isactive = 1 AND r.isdelete = 0
// AND sld.is_active = 1 AND sld.is_delete = 0
//
//
// AND DATE_FORMAT(r.cdate, '%Y-%m') = DATE_FORMAT( STR_TO_DATE(?, '%Y-%m-%d'), '%Y-%m')
//
// AND DATE(r.cdate) <= ?) t
//
// WHERE t.rn = 1), 0) AS totalResidents,
//
// """;
//
//
//
// residentParameter = value;
// }
//
//
// // ==========================================
// // MONTH
// // ==========================================
// /*
// * Only records from selected month.
//
// * For each shelter: Take latest qid = 4 record in that month. and Then SUM all shelters.
// */
// else if ("month".equalsIgnoreCase(type)) {
//
// dateCondition =
// " AND DATE_FORMAT(cdate, '%Y-%m') = ? ";
//
// residentQuery = """
// COALESCE(
// (SELECT SUM(CAST(t.answer AS UNSIGNED))
// FROM (
// SELECT sld.shelter_id, r.answer, ROW_NUMBER() OVER
// (PARTITION BY sld.shelter_id ORDER BY r.cdate DESC, r.id DESC) AS rn
// FROM night_shelter_inspection_response r
//
// INNER JOIN surveyor_location_details sld ON sld.survey_id = r.survey_id AND sld.loginId = r.cby
//
// WHERE r.qid = 4 AND r.isactive = 1 AND r.isdelete = 0
// AND sld.is_active = 1 AND sld.is_delete = 0
//
// AND DATE_FORMAT(r.cdate, '%Y-%m') = ?) t
//
// WHERE t.rn = 1), 0) AS totalResidents,
//
// """;
//
// residentParameter = value;
// }
//
//
//
// // ==========================================
// // YEAR
// // ==========================================
// /*
// * Only records from selected year.
//
// * For each shelter: Take latest qid = 4 record in that year. and Then SUM all shelters.
// */
// else if ("year".equalsIgnoreCase(type)) {
//
// dateCondition =
// " AND YEAR(cdate) = ? ";
//
// residentQuery = """
// COALESCE(
// (
// SELECT SUM(CAST(t.answer AS UNSIGNED))
//
// FROM (
// SELECT sld.shelter_id, r.answer, ROW_NUMBER() OVER
// (PARTITION BY sld.shelter_id ORDER BY r.cdate DESC, r.id DESC) AS rn
// FROM night_shelter_inspection_response r
//
// INNER JOIN surveyor_location_details sld ON sld.survey_id = r.survey_id AND sld.loginId = r.cby
//
// WHERE r.qid = 4 AND r.isactive = 1 AND r.isdelete = 0
// AND sld.is_active = 1 AND sld.is_delete = 0
//
// AND YEAR(r.cdate) = ?
// ) t
//
// WHERE t.rn = 1), 0) AS totalResidents,
//
// """;
//
// residentParameter = value;
// }
//
//
//
// // ==========================================
// // DASHBOARD SQL
// // ==========================================
//
// String dashboardSql = """
//
// SELECT
//
// """ + residentQuery + """
//
// COUNT(DISTINCT survey_id) AS numberOfVisits,
//
// COALESCE(SUM(CASE WHEN qid = 16 THEN CAST(answer AS UNSIGNED) END), 0) AS rehabilitation,
//
// COALESCE(SUM(CASE WHEN qid = 17 THEN CAST(answer AS UNSIGNED) END), 0) AS reintegration,
//
// COALESCE(SUM(CASE WHEN qid = 48 THEN CAST(answer AS UNSIGNED) END), 0) AS entitlementAccess,
//
// COALESCE(SUM(CASE WHEN qid = 11 THEN CAST(answer AS UNSIGNED) END), 0) AS leftWithInfo,
//
// COALESCE(SUM(CASE WHEN qid = 13 THEN CAST(answer AS UNSIGNED) END), 0) AS leftWithoutInfo,
//
// COALESCE(SUM(CASE WHEN qid = 10 THEN CAST(answer AS UNSIGNED) END), 0) AS deathCount
//
// FROM night_shelter_inspection_response
//
// WHERE isactive = 1 AND isdelete = 0
//
// """ + dateCondition;
//
//
//
// // ==========================================
// // EXECUTE QUERY
// // ==========================================
//
//
// if (dateCondition.isEmpty()) {
//
// response.putAll(jdbcTemplate.queryForMap(dashboardSql));
// } else if ("day".equalsIgnoreCase(type)) {
//
// response.putAll(jdbcTemplate.queryForMap(dashboardSql, value, value, value));
// } else {
//
// response.putAll(jdbcTemplate.queryForMap(dashboardSql, residentParameter, value));
// }
//
// return response;
// }
// public Map<String, Object> getDashboardData(String type, String value) { // public Map<String, Object> getDashboardData(String type, String value) {

1015
src/main/java/in/gov/chennaicorporation/gccoffice/shelterinspection/Service/ShelterService.java
File diff suppressed because it is too large
View File

17
src/main/resources/templates/modules/shelterinspection/dashboard.html

@ -297,8 +297,8 @@
} }
.rescue-bg{ .rescue-bg{
background:#FFF6E6 !important;
color:#FF9800 !important;
background: #E6FFFB !important;
color: #009688 !important;
} }
.rehab-bg{ .rehab-bg{
@ -697,23 +697,23 @@
</div> </div>
</div> </div>
<!-- <div class="col mb-4 d-flex">
<div class="col mb-4 d-flex">
<div class="card dashboard-card text-center w-100"> <div class="card dashboard-card text-center w-100">
<div class="card-body"> <div class="card-body">
<div class="dashboard-icon rescue-bg"> <div class="dashboard-icon rescue-bg">
<i class="fas fa-user-shield"></i>
<i class="fas fa-user-friends"></i>
<!-- <i class="fas fa-eye"></i> -->
</div> </div>
<div class="dashboard-details"> <div class="dashboard-details">
<h2 id="numberOfVisits">0</h2>
<h6>Rescue</h6>
<small>All Shelters</small>
<h2 id="resuceCount">0</h2>
<h6>Resuce</h6>
</div> </div>
</div> </div>
</div> </div>
</div> -->
</div>
@ -1388,6 +1388,7 @@
$("#totalResidents").text(data.totalResidents); $("#totalResidents").text(data.totalResidents);
$("#numberOfVisits").text(data.numberOfVisits); $("#numberOfVisits").text(data.numberOfVisits);
$("#resuceCount").text(data.resuceCount);
$("#rehabilitation").text(data.rehabilitation); $("#rehabilitation").text(data.rehabilitation);
$("#reintegration").text(data.reintegration); $("#reintegration").text(data.reintegration);
$("#entitlementAccess").text(data.entitlementAccess); $("#entitlementAccess").text(data.entitlementAccess);

984
src/main/resources/templates/modules/shelterinspection/resucelist.html

@ -0,0 +1,984 @@
<!DOCTYPE html>
<html lang="en" dir="">
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{fragments/modules/base/head :: head}"></head>
<!-- DataTables -->
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.8/css/dataTables.bootstrap5.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.4.2/css/buttons.bootstrap5.min.css">
<style>
.table-responsive {
width: 100%;
}
</style>
<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="far fa-list-alt bg-blue"></i>
<div class="d-inline">
<h5>Resuce List</h5>
<span>Shelter Resuce</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" aria-current="page">Shelter Resuce</li>
<li class="breadcrumb-item active" aria-current="page">Resuce List</li>
</ol>
</nav>
</div>
</div>
</div>
<hr>
<!-- Filters Section -->
<div class="row mb-4">
<div class="col-md-4">
<label class="form-label fw-semibold me-2">From Date:</label>
<input type="date" id="fromDate" class="form-control d-inline-block" style="width:100px;">
<label class="form-label fw-semibold me-2">To Date:</label>
<input type="date" id="toDate" class="form-control d-inline-block" style="width:100px;">
</div>
<!-- <div class="col-md-2">
<select id="zone" class="form-control">
<option value="">All Zones</option>
</select>
</div>
<div class="col-md-2">
<select id="category" class="form-control">
<option value="">All Categories</option>
</select>
</div> -->
<div class="col-md-2">
<button class="btn btn-primary w-100" onclick="loadResuceList()">Search</button>
</div>
<div class="col-md-2">
<button class="btn btn-secondary w-100" onclick="resetFilters()">Reset</button>
</div>
</div>
<div class="table-responsive">
<table id="shelterResuceListTable"
class="table table-bordered table-striped dt-responsive nowrap w-100">
<thead class="thead-dark">
<tr>
<th class="text-center">S.No</th>
<th class="text-center">Resuce Designation</th>
<th class="text-center">No of Resuces</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</div>
<footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
</div>
</div>
<!-- Meeting List Details -->
<!-- Resuce List Details Modal -->
<div class="modal fade" id="ResuceDetailsModal" tabindex="-1" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog modal-xl modal-dialog-centered">
<div class="modal-content">
<!-- Header -->
<div class="modal-header">
<h5 class="modal-title" id="resuceDetailsModalTitle">
Resuce List Details
</h5>
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
<span>&times;</span>
</button>
</div>
<!-- Body -->
<div class="modal-body">
<div class="table-responsive">
<table id="resuceDetailsTable" class="table table-bordered table-striped table-hover w-100">
<thead class="thead-dark">
<tr>
<th class="text-center">S.No</th>
<th id="shelterColumnHeader" class="text-center">Shelter</th>
<th id="hospitalColumnHeader" class="text-center">Hospital Name</th>
<th class="text-center">CDO</th>
<th class="text-center">Date</th>
<th class="text-center">Resuce Date</th>
<!--<th class="text-center">Resuce Time</th>-->
<!--<th class="text-center">Area of Visit</th>
<th class="text-center">No of People in homeless person identified</th>-->
<th class="text-center">No of People in homeless situation rescued</th>
<!--<th class="text-center">Remark</th>-->
</tr>
</thead>
<tbody id="resuceDetailsBody"></tbody>
</table>
</div>
</div>
<!-- Footer -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
Close
</button>
</div>
</div>
</div>
</div>
<!-- =========================================================
RESCUED PEOPLE DETAILS MODAL
========================================================= -->
<div class="modal fade" id="rescuedPeopleModal" tabindex="-1" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<!-- Header -->
<div class="modal-header bg-primary text-white">
<h5 class="modal-title">
Rescued People Details
</h5>
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
<span>&times;</span>
</button>
</div>
<!-- Body -->
<div class="modal-body">
<div class="table-responsive">
<table id="rescuedPeopleTable" class="table table-bordered table-striped table-hover w-100">
<thead class="thead-dark">
<tr>
<th class="text-center">S.No</th>
<th class="text-center">Name</th>
<th class="text-center">Age</th>
<th class="text-center">Gender</th>
<th class="text-center">Rescue of Location</th>
<th class="text-center">Remarks</th>
</tr>
</thead>
<tbody id="rescuedPeopleBody"></tbody>
</table>
</div>
</div>
<!-- Footer -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
Close
</button>
</div>
</div>
</div>
</div>
<div th:replace="~{fragments/modules/base/script :: script}"></div>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.datatables.net/1.13.8/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.13.8/js/dataTables.bootstrap5.min.js"></script>
<script src="https://cdn.datatables.net/responsive/2.5.0/js/dataTables.responsive.min.js"></script>
<!-- DataTable Buttons -->
<script src="https://cdn.datatables.net/buttons/2.4.2/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.4.2/js/buttons.bootstrap5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
<script src="https://cdn.datatables.net/buttons/2.4.2/js/buttons.html5.min.js"></script>
<script th:inline="javascript">
$(document).ready(function () {
loadDropdowns();
//loadResuceList();
initializeResuceDates();
});
function resetFilters() {
$("#zone").val("");
$("#category").val("");
initializeResuceDates();
}
function loadResuceList() {
if ($.fn.DataTable.isDataTable('#shelterResuceListTable')) {
$('#shelterResuceListTable').DataTable().destroy();
}
$("#shelterResuceListTable tbody").empty();
$.ajax({
url: "/gcc/api/shelterinspection/shelterResuceList",
type: "GET",
data: {
fromDate: $("#fromDate").val(),
toDate: $("#toDate").val(),
/* zone: $("#zone").val(),
category: $("#category").val() */
},
success: function (response) {
console.log(response);
let rows = "";
$.each(response, function (i, item) {
rows += `
<tr>
<td>${i + 1}</td>
<td><strong>${item.resuceDesignation || "-"}</strong></td>
<td class="text-center">
${Number(item.totalResuces) > 0
? `<a href="javascript:void(0);"
onclick="viewResuceList('${item.resuceDesignationId}', '${escapeHtml(item.shelterName)}', '${item.uqid}', '${item.resuceDesignation}')"
style="color: #007bff; text-decoration: underline; cursor: pointer;">
${item.totalResuces}
</a>`
: `${item.totalResuces}`
}
</td>
</tr>
`;
});
$("#shelterResuceListTable tbody").html(rows);
$('#shelterResuceListTable').DataTable({
responsive: true,
pageLength: 10,
ordering: true,
dom: 'Bfrtip',
buttons: [
{ extend: 'pageLength', className: 'btn btn-warning' },
{ extend: 'excelHtml5', text: 'Excel', className: 'btn btn-success' },
{ extend: 'pdfHtml5', text: 'PDF', className: 'btn btn-secondary', orientation: 'landscape', pageSize: 'A4' }
]
});
},
error: function () {
Swal.fire({
icon: 'error',
title: 'Error',
text: 'Unable to load shelter list.',
allowOutsideClick: false
});
}
});
}
function formatCategory(category) {
if (!category) return "-";
return category
.replace(/-/g, " ")
.replace(/\b\w/g, function (letter) {
return letter.toUpperCase();
});
}
function viewResuceList(resuceDesignationId, shelterName, uqid, resuceDesignation) {
$.ajax({
url: "/gcc/api/shelterinspection/shelterResuceDetails",
type: "GET",
data: {
resuceDesignationId: resuceDesignationId,
uqid: uqid,
fromDate: $("#fromDate").val(),
toDate: $("#toDate").val()
},
success: function (res) {
if ($.fn.DataTable.isDataTable('#resuceDetailsTable')) {
$('#resuceDetailsTable').DataTable().destroy();
}
// Clear old data
$("#resuceDetailsBody").empty();
// =================================================
// SHOW / HIDE SHELTER / HOSPITAL COLUMN
// =================================================
if (String(resuceDesignationId) === "1") {
// Shelter
$("#shelterColumnHeader").show();
$("#hospitalColumnHeader").hide();
} else if (String(resuceDesignationId) === "5") {
// Hospital
$("#shelterColumnHeader").hide();
$("#hospitalColumnHeader").show();
} else {
// Other designations
$("#shelterColumnHeader").hide();
$("#hospitalColumnHeader").hide();
}
// ==========================================
// SET MODAL TITLE
// ==========================================
/*$("#resuceDetailsModalTitle").text(
"Resuce List Details - " + (shelterName || "-")
);*/
let modalName = "-";
// ---------------------------------------------
// CASE 1 : SHELTER
// ---------------------------------------------
modalName = resuceDesignation;
// ---------------------------------------------
// OTHER CASES
// ---------------------------------------------
$("#resuceDetailsModalTitle").text(
"Resuce List Details - " + modalName
);
let rows = "";
// ==========================================
// Destroy previous DataTable
// ==========================================
// ==========================================
// No Data
// ==========================================
if (!res || res.length === 0) {
rows = `
<tr>
<td colspan="9" class="text-center"> No Resuce details found </td>
</tr>
`;
}
// ==========================================
// Load Data
// ==========================================
else {
$.each(res, function (i, item) {
// ----------------------------------
// Table Row
// ----------------------------------
rows += `
<tr>
<td class="text-center">${item.sno || i + 1}</td>
<td class="shelterColumn">
<strong>${item.shelterName || "-"}</strong>
</td>
<td class="hospitalColumn">
<strong>${item.hospitalName || "-"}</strong>
</td>
<td class="text-center">${item.cdo || "-"}</td>
<td class="text-center">${item.date || "-"}</td>
<td class="text-center">${item.qid1 ?? "-"}</td>
<!-- <td class="text-center">${item.qid2 ?? "-"}</td>-->
<!-- <td class="text-center">${item.qid3 ?? "-"}</td>-->
<!-- <td class="text-center">${item.qid4 ?? "-"}</td>-->
<td class="text-center">
${Number(item.qid5) > 0
? `
<a href="javascript:void(0);"
onclick="viewRescuedPeople('${item.surveyId}')"
style="color:#007bff; text-decoration:underline; cursor:pointer;">
${item.qid5}
</a>
`
: `${item.qid5 ?? "-"}`
}
</td>
<!-- <td>${formatResuceRemark(item.qid11)}</td>-->
</tr>
`;
});
}
// ==========================================
// Insert Data
// ==========================================
$("#resuceDetailsBody").html(rows);
// ==========================================
// Initialize DataTable
// ==========================================
let resuceTable = $('#resuceDetailsTable').DataTable({
responsive: false,
pageLength: 10,
ordering: true,
autoWidth: false,
dom: 'Bfrtip',
buttons: [
{ extend: 'pageLength', className: 'btn btn-warning' },
{ extend: 'copyHtml5', text: 'Copy', className: 'btn btn-success' },
{
extend: 'excelHtml5', text: 'Excel', className: 'btn btn-secondary', exportOptions: {
columns: ":visible"
}
},
]
});
// =====================================================
// SHOW / HIDE COLUMNS
// =====================================================
if (String(resuceDesignationId) === "1") {
// =================================================
// DESIGNATION 1 = SHELTER
// =================================================
// Show Shelter column
resuceTable.column(1).visible(true);
// Hide Hospital column
resuceTable.column(2).visible(false);
}
else if (String(resuceDesignationId) === "5") {
// =================================================
// DESIGNATION 5 = HOSPITAL
// =================================================
// Hide Shelter column
resuceTable.column(1).visible(false);
// Show Hospital column
resuceTable.column(2).visible(true);
}
else {
// =================================================
// OTHER DESIGNATIONS
// =================================================
// Hide Shelter
resuceTable.column(1).visible(false);
// Hide Hospital
resuceTable.column(2).visible(false);
}
// ==========================================
// Show Modal
// ==========================================
$("#ResuceDetailsModal").modal({
backdrop: "static",
keyboard: false
});
$("#ResuceDetailsModal").modal("show");
},
error: function (xhr) {
Swal.fire({
icon: "error",
title: "Error",
text: "Unable to load meeting details.",
allowOutsideClick: false
});
}
});
}
// =========================================================
// ESCAPE HTML
// =========================================================
function escapeHtml(value) {
if (value === null || value === undefined) {
return "";
}
return String(value)
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
}
// =========================================================
// FORMAT Resuce REMARK
// =========================================================
function formatResuceRemark(value) {
// ==========================================
// NO REMARK
// ==========================================
if (
value === null ||
value === undefined ||
String(value).trim() === ''
) {
return `
<a href="javascript:void(0);"
class="btn btn-sm btn-outline-primary disabled">
No Remark
</a>
`;
}
var text = String(value).trim();
// ==========================================
// SPLIT ALL WORDS
// ==========================================
var words = text.split(/\s+/);
// ==========================================
// DISTRIBUTE ALL WORDS INTO 4 LINES
// ==========================================
var totalWords = words.length;
var wordsPerLine = Math.ceil(totalWords / 4);
var lines = [];
for (var i = 0; i < words.length; i += wordsPerLine) {
lines.push(
words.slice(i, i + wordsPerLine).join(' ')
);
}
// ==========================================
// MAXIMUM 4 LINES
// ==========================================
lines = lines.slice(0, 4);
return lines.join('<br>');
}
// =========================================================
// VIEW RESCUED PEOPLE DETAILS
// =========================================================
function viewRescuedPeople(surveyId) {
$.ajax({
url: "/gcc/api/shelterinspection/shelterRescuedPeopleDetails",
type: "GET",
data: {
surveyId: surveyId,
fromDate: $("#fromDate").val(),
toDate: $("#toDate").val()
},
success: function (res) {
console.log(res);
let rows = "";
// ==========================================
// DESTROY PREVIOUS DATATABLE
// ==========================================
if ($.fn.DataTable.isDataTable('#rescuedPeopleTable')) {
$('#rescuedPeopleTable').DataTable().destroy();
}
// ==========================================
// CLEAR OLD DATA
// ==========================================
$("#rescuedPeopleBody").empty();
// ==========================================
// NO DATA
// ==========================================
if (!res || res.length === 0) {
rows = `
<tr>
<td colspan="5" class="text-center">
No rescued people details found
</td>
</tr>
`;
}
// ==========================================
// LOAD DATA
// ==========================================
else {
$.each(res, function (i, item) {
rows += `
<tr>
<td class="text-center">${i + 1}</td>
<td class="text-center">${item.name || "-"}</td>
<td class="text-center">${item.age || "-"}</td>
<td class="text-center">${item.gender || "-"}</td>
<td class="text-center">${item.location || "-"}</td>
<td class="text-center">${item.remarks || "-"}</td>
</tr>
`;
});
}
// ==========================================
// INSERT DATA
// ==========================================
$("#rescuedPeopleBody").html(rows);
// ==========================================
// INITIALIZE DATATABLE
// ==========================================
$('#rescuedPeopleTable').DataTable({
responsive: false,
pageLength: 10,
ordering: true,
autoWidth: false,
dom: 'Bfrtip',
buttons: [
{ extend: 'pageLength', className: 'btn btn-warning' },
{ extend: 'copyHtml5', text: 'Copy', className: 'btn btn-success' },
{ extend: 'excelHtml5', text: 'Excel', className: 'btn btn-secondary' }
]
});
// ==========================================
// SHOW MODAL
// ==========================================
$("#rescuedPeopleModal").modal({
backdrop: "static",
keyboard: false
});
$("#rescuedPeopleModal").modal("show");
},
// ==========================================
// ERROR
// ==========================================
error: function (xhr) {
Swal.fire({
icon: "error",
title: "Error",
text: "Unable to load rescued people details.",
allowOutsideClick: false
});
}
});
}
// =========================================================
// INITIALIZE COMPLAINT DATE FILTER
// From Date = Minimum DB cdate
// To Date = Today
// =========================================================
function initializeResuceDates() {
$.ajax({
url: "/gcc/api/shelterinspection/shelterResuceMinDate",
type: "GET",
success: function (minDate) {
console.log("Minimum Meeting cdate:", minDate);
// =================================================
// TODAY
// =================================================
var today = new Date();
var yyyy = today.getFullYear();
var mm = String(today.getMonth() + 1).padStart(2, '0');
var dd = String(today.getDate()).padStart(2, '0');
var todayString = yyyy + '-' + mm + '-' + dd;
// =================================================
// FROM DATE
// =================================================
if (minDate) {
$('#fromDate').val(minDate);
} else {
// If no DB date found,
// use today
$('#fromDate').val(todayString);
}
// =================================================
// TO DATE = TODAY
// =================================================
$('#toDate').val(todayString);
// =================================================
// LOAD REPORT
// =================================================
loadResuceList();
},
error: function (xhr) {
console.error("Unable to get minimum meeting date:",);
// =================================================
// FALLBACK TO TODAY
// =================================================
var today = new Date();
var yyyy = today.getFullYear();
var mm = String(today.getMonth() + 1).padStart(2, '0');
var dd = String(today.getDate()).padStart(2, '0');
var todayString = yyyy + '-' + mm + '-' + dd;
$('#fromDate').val(todayString);
$('#toDate').val(todayString);
loadResuceList();
}
});
}
function loadDropdowns() {
// Zone
$.ajax({
url: "/gcc/api/shelterinspection/zones",
type: "GET",
success: function (data) {
let options = '<option value="">All Zones</option>';
data.forEach(function (zone) {
options += `<option value="${zone}">${zone}</option>`;
});
$("#zone").html(options);
}
});
// Category
$.ajax({
url: "/gcc/api/shelterinspection/categories",
type: "GET",
success: function (data) {
let options = '<option value="">All Categories</option>';
data.forEach(function (category) {
let text = category
.replace(/-/g, " ")
.replace(/\b\w/g, function (c) {
return c.toUpperCase();
});
options += `<option value="${category}">${text}</option>`;
});
$("#category").html(options);
}
});
}
</script>
</body>
</html>

800
src/main/resources/templates/modules/shelterinspection/smcmeetinglist.html

@ -0,0 +1,800 @@
<!DOCTYPE html>
<html lang="en" dir="">
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{fragments/modules/base/head :: head}"></head>
<!-- DataTables -->
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.8/css/dataTables.bootstrap5.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.4.2/css/buttons.bootstrap5.min.css">
<style>
.table-responsive {
width: 100%;
}
</style>
<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="far fa-list-alt bg-blue"></i>
<div class="d-inline">
<h5>SMC Meeting List</h5>
<span>Shelter SMC Meeting</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" aria-current="page">Shelter SMC Meeting</li>
<li class="breadcrumb-item active" aria-current="page">SMC Meeting List</li>
</ol>
</nav>
</div>
</div>
</div>
<hr>
<!-- Filters Section -->
<div class="row mb-4">
<div class="col-md-4">
<label class="form-label fw-semibold me-2">From Date:</label>
<input type="date" id="fromDate" class="form-control d-inline-block" style="width:100px;">
<label class="form-label fw-semibold me-2">To Date:</label>
<input type="date" id="toDate" class="form-control d-inline-block" style="width:100px;">
</div>
<div class="col-md-2">
<select id="zone" class="form-control">
<option value="">All Zones</option>
</select>
</div>
<div class="col-md-2">
<select id="category" class="form-control">
<option value="">All Categories</option>
</select>
</div>
<div class="col-md-2">
<button class="btn btn-primary w-100" onclick="loadMeetingList()">Search</button>
</div>
<div class="col-md-2">
<button class="btn btn-secondary w-100" onclick="resetFilters()">Reset</button>
</div>
</div>
<div class="table-responsive">
<table id="shelterListTable" class="table table-bordered table-striped dt-responsive nowrap w-100">
<thead class="thead-dark">
<tr>
<th class="text-center">S.No</th>
<th class="text-center">SHELTER</th>
<th class="text-center">Zone</th>
<th class="text-center">Category</th>
<th class="text-center">No of Meetings</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</div>
<footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
</div>
</div>
<!-- Meeting List Details -->
<!-- Meeting List Details Modal -->
<div class="modal fade" id="MeetingDetailsModal" tabindex="-1" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog modal-xl modal-dialog-centered">
<div class="modal-content">
<!-- Header -->
<div class="modal-header">
<h5 class="modal-title" id ="meetingDetailsModalTitle">
Meeting List Details
</h5>
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
<span>&times;</span>
</button>
</div>
<!-- Body -->
<div class="modal-body">
<div class="table-responsive">
<table id="meetingDetailsTable" class="table table-bordered table-striped table-hover w-100">
<thead class="thead-dark">
<tr>
<th class="text-center">S.No</th>
<th class="text-center">Shelter</th>
<th class="text-center">CDO</th>
<th class="text-center">Date</th>
<th class="text-center">No. of NGO Directors Attended</th>
<th class="text-center">No. of Shelter Staff Attended</th>
<th class="text-center">No. of Concerns Resolved / Addressed</th>
<th class="text-center">Photo</th>
<th class="text-center">Remark</th>
</tr>
</thead>
<tbody id="meetingDetailsBody"></tbody>
</table>
</div>
</div>
<!-- Footer -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
Close
</button>
</div>
</div>
</div>
</div>
<!-- =========================================================
Meeting PHOTO MODAL
========================================================= -->
<div class="modal fade" id="meetingPhotoModal" tabindex="-1" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<!-- Header -->
<div class="modal-header bg-primary text-white">
<h5 class="modal-title" id="meetingPhotoModalTitle">
Meeting Photo
</h5>
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
<span>&times;</span>
</button>
</div>
<!-- Body -->
<div class="modal-body text-center">
<!-- Photo -->
<div id="meetingPhotoContainer">
<img id="meetingModalPhoto" src="" class="img-fluid rounded"
style="max-height: 450px; max-width: 100%;">
</div>
</div>
<!-- Footer -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
Close
</button>
</div>
</div>
</div>
<div th:replace="~{fragments/modules/base/script :: script}"></div>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.datatables.net/1.13.8/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.13.8/js/dataTables.bootstrap5.min.js"></script>
<script src="https://cdn.datatables.net/responsive/2.5.0/js/dataTables.responsive.min.js"></script>
<!-- DataTable Buttons -->
<script src="https://cdn.datatables.net/buttons/2.4.2/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.4.2/js/buttons.bootstrap5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
<script src="https://cdn.datatables.net/buttons/2.4.2/js/buttons.html5.min.js"></script>
<script th:inline="javascript">
$(document).ready(function () {
loadDropdowns();
//loadMeetingList();
initializeMeetingDates();
});
function resetFilters() {
$("#zone").val("");
$("#category").val("");
//loadMeetingList();
initializeMeetingDates();
}
function loadMeetingList() {
if ($.fn.DataTable.isDataTable('#shelterListTable')) {
$('#shelterListTable').DataTable().destroy();
}
$("#shelterListTable tbody").empty();
$.ajax({
url: "/gcc/api/shelterinspection/shelterMeetingList",
type: "GET",
data: {
fromDate: $("#fromDate").val(),
toDate: $("#toDate").val(),
zone: $("#zone").val(),
category: $("#category").val()
},
success: function(response) {
let rows = "";
$.each(response, function(i, item) {
rows += `
<tr>
<td>${i + 1}</td>
<td><strong>${item.shelterName || "-"}</strong></td>
<td class="text-center">${item.zone || "-"}</td>
<td class="text-center">${formatCategory(item.category)}</td>
<td class="text-center">
${
Number(item.totalMeetings) > 0
? `<a href="javascript:void(0);"
onclick="viewMeeting('${item.uqid}', '${escapeHtml(item.shelterName)}')"
style="color: #007bff; text-decoration: underline; cursor: pointer;">
${item.totalMeetings}
</a>`
: `${item.totalMeetings}`
}
</td>
</tr>
`;
});
$("#shelterListTable tbody").html(rows);
$('#shelterListTable').DataTable({
responsive: true,
pageLength: 10,
ordering: true,
dom: 'Bfrtip',
buttons: [
{extend: 'pageLength', className: 'btn btn-warning'},
{extend: 'excelHtml5', text: 'Excel', className: 'btn btn-success'},
{extend: 'pdfHtml5', text: 'PDF', className: 'btn btn-secondary', orientation: 'landscape', pageSize: 'A4'}
]
});
},
error: function() {
Swal.fire({
icon: 'error',
title: 'Error',
text: 'Unable to load shelter list.',
allowOutsideClick: false
});
}
});
}
function formatCategory(category) {
if (!category) return "-";
return category
.replace(/-/g, " ")
.replace(/\b\w/g, function(letter) {
return letter.toUpperCase();
});
}
function viewMeeting(uqid, shelterName) {
$.ajax({
url: "/gcc/api/shelterinspection/shelterMeetingDetails",
type: "GET",
data: {
uqid: uqid,
fromDate: $("#fromDate").val(),
toDate: $("#toDate").val()
},
success: function (res) {
// ==========================================
// SET MODAL TITLE
// ==========================================
$("#meetingDetailsModalTitle").text(
"Meeting List Details - " + (shelterName || "-")
);
let rows = "";
// ==========================================
// Destroy previous DataTable
// ==========================================
if ($.fn.DataTable.isDataTable('#meetingDetailsTable')) {
$('#meetingDetailsTable').DataTable().destroy();
}
// Clear old data
$("#meetingDetailsBody").empty();
// ==========================================
// No Data
// ==========================================
if (!res || res.length === 0) {
rows = `
<tr>
<td colspan="9" class="text-center"> No meeting details found </td>
</tr>
`;
}
// ==========================================
// Load Data
// ==========================================
else {
$.each(res, function (i, item) {
// ----------------------------------
// Photo
// ----------------------------------
let photoHtml = formatMeetingPhoto(item.meetingPhoto);
// ----------------------------------
// Table Row
// ----------------------------------
rows += `
<tr>
<td class="text-center">${item.sno || i + 1}</td>
<td><strong>${item.shelterName || "-"}</strong></td>
<td class="text-center">${item.cdo || "-"}</td>
<td class="text-center">${item.date || "-"}</td>
<td class="text-center">${item.qid3 ?? "-"}</td>
<td class="text-center">${item.qid4 ?? "-"}</td>
<td class="text-center">${item.qid5 ?? "-"}</td>
<td class="text-center">${photoHtml}</td>
<td>${formatMeetingRemark(item.qid6)}</td>
</tr>
`;
});
}
// ==========================================
// Insert Data
// ==========================================
$("#meetingDetailsBody").html(rows);
// ==========================================
// Initialize DataTable
// ==========================================
$('#meetingDetailsTable').DataTable({
responsive: false,
pageLength: 10,
ordering: true,
autoWidth: false,
dom: 'Bfrtip',
buttons: [
{extend: 'pageLength', className: 'btn btn-warning'},
{extend: 'copyHtml5', text: 'Copy', className: 'btn btn-success'},
{extend: 'excelHtml5', text: 'Excel', className: 'btn btn-secondary'},
]
});
// ==========================================
// Show Modal
// ==========================================
$("#MeetingDetailsModal").modal({
backdrop: "static",
keyboard: false
});
$("#MeetingDetailsModal").modal("show");
},
error: function (xhr) {
Swal.fire({
icon: "error",
title: "Error",
text: "Unable to load meeting details.",
allowOutsideClick: false
});
}
});
}
// =========================================================
// MEETING PHOTO BUTTON
// =========================================================
$(document).on("click", ".meetingPhotoBtn, .photoBtn", function () {
var photoUrl = $(this).attr("data-photo");
if (photoUrl && photoUrl.trim() !== "") {
$("#meetingModalPhoto")
.attr("src", photoUrl)
.show();
$("#meetingPhotoModal").modal({
backdrop: "static",
keyboard: false
});
$("#meetingPhotoModal").modal("show");
}
});
// =========================================================
// FORMAT MEETING PHOTO
// =========================================================
function formatMeetingPhoto(photo) {
if (!photo || String(photo).trim() === "") {
return 'No Photo';
}
return `
<a href="javascript:void(0);"
id="meetingPhoto"
class="photoBtn btn btn-sm btn-outline-primary"
data-photo="${escapeHtml(photo)}">
View Photo
</a>
`;
}
// =========================================================
// FORMAT MEETING PHOTO
// =========================================================
function formatMeetingPhoto(photo) {
// ==========================================
// NO PHOTO
// ==========================================
if (!photo || String(photo).trim() === "") {
return `
<a href="javascript:void(0);"
class="btn btn-sm btn-outline-primary disabled">
No Photo
</a>
`;
}
// ==========================================
// PHOTO AVAILABLE
// ==========================================
return `
<a href="javascript:void(0);"
class="meetingPhotoBtn btn btn-sm btn-outline-primary"
data-photo="${escapeHtml(photo)}">
View Photo
</a>
`;
}
// =========================================================
// ESCAPE HTML
// =========================================================
function escapeHtml(value) {
if (value === null || value === undefined) {
return "";
}
return String(value)
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
}
// =========================================================
// FORMAT MEETING REMARK
// =========================================================
function formatMeetingRemark(value) {
// ==========================================
// NO REMARK
// ==========================================
if (
value === null ||
value === undefined ||
String(value).trim() === ''
) {
return `
<a href="javascript:void(0);"
class="btn btn-sm btn-outline-primary disabled">
No Remark
</a>
`;
}
var text = String(value).trim();
// ==========================================
// SPLIT ALL WORDS
// ==========================================
var words = text.split(/\s+/);
// ==========================================
// DISTRIBUTE ALL WORDS INTO 4 LINES
// ==========================================
var totalWords = words.length;
var wordsPerLine = Math.ceil(totalWords / 4);
var lines = [];
for (var i = 0; i < words.length; i += wordsPerLine) {
lines.push(
words.slice(i, i + wordsPerLine).join(' ')
);
}
// ==========================================
// MAXIMUM 4 LINES
// ==========================================
lines = lines.slice(0, 4);
return lines.join('<br>');
}
// =========================================================
// INITIALIZE COMPLAINT DATE FILTER
// From Date = Minimum DB cdate
// To Date = Today
// =========================================================
function initializeMeetingDates() {
$.ajax({
url: "/gcc/api/shelterinspection/shelterMeetingMinDate",
type: "GET",
success: function (minDate) {
console.log("Minimum Meeting cdate:", minDate);
// =================================================
// TODAY
// =================================================
var today = new Date();
var yyyy = today.getFullYear();
var mm = String(today.getMonth() + 1).padStart(2, '0');
var dd = String(today.getDate()).padStart(2, '0');
var todayString = yyyy + '-' + mm + '-' + dd;
// =================================================
// FROM DATE
// =================================================
if (minDate) {
$('#fromDate').val(minDate);
} else {
// If no DB date found,
// use today
$('#fromDate').val(todayString);
}
// =================================================
// TO DATE = TODAY
// =================================================
$('#toDate').val(todayString);
// =================================================
// LOAD REPORT
// =================================================
loadMeetingList();
},
error: function (xhr) {
console.error("Unable to get minimum meeting date:",);
// =================================================
// FALLBACK TO TODAY
// =================================================
var today = new Date();
var yyyy = today.getFullYear();
var mm = String(today.getMonth() + 1).padStart(2, '0');
var dd = String(today.getDate()).padStart(2, '0');
var todayString = yyyy + '-' + mm + '-' + dd;
$('#fromDate').val(todayString);
$('#toDate').val(todayString);
loadMeetingList();
}
});
}
function loadDropdowns() {
// Zone
$.ajax({
url: "/gcc/api/shelterinspection/zones",
type: "GET",
success: function(data) {
let options = '<option value="">All Zones</option>';
data.forEach(function(zone) {
options += `<option value="${zone}">${zone}</option>`;
});
$("#zone").html(options);
}
});
// Category
$.ajax({
url: "/gcc/api/shelterinspection/categories",
type: "GET",
success: function(data) {
let options = '<option value="">All Categories</option>';
data.forEach(function(category) {
let text = category
.replace(/-/g, " ")
.replace(/\b\w/g, function(c) {
return c.toUpperCase();
});
options += `<option value="${category}">${text}</option>`;
});
$("#category").html(options);
}
});
}
</script>
</body>
</html>

131
src/main/resources/templates/modules/shelterinspection/visitlist.html

@ -411,6 +411,14 @@
</div> </div>
<table class="table table-borderless">
<tr>
<td>
Overall Performance of the Staff
</td>
<td class="text-right" id="staffQ60"></td>
</tr>
</table>
</div> </div>
@ -563,6 +571,13 @@
<td class="text-right" id="foodQ20"></td> <td class="text-right" id="foodQ20"></td>
</tr> </tr>
<tr>
<td>
Quality of the Food
</td>
<td class="text-right" id="foodQ59"></td>
</tr>
<tr> <tr>
<td> <td>
Food Photo Food Photo
@ -1153,7 +1168,8 @@
buildStaffList(res.answers["3"]);
//buildStaffList(res.answers["3"]);
buildStaffList(res.answers["3"], res.answers);
//resident //resident
if (questionMaster.length === 0) { if (questionMaster.length === 0) {
@ -1271,65 +1287,35 @@
if (res && res.data && Array.isArray(res.data)) { if (res && res.data && Array.isArray(res.data)) {
questionMaster = res.data; questionMaster = res.data;
console.log(
"Question Master Loaded:",
questionMaster.length
);
console.log("Question Master Loaded:", questionMaster.length);
if (callback) { if (callback) {
callback(); callback();
} }
} else { } else {
console.error(
"Question master data not found.",
res
);
console.error("Question master data not found.", res);
questionMaster = []; questionMaster = [];
} }
}, },
error: function(xhr, status, error) { error: function(xhr, status, error) {
console.error(
"Question Master API Error:",
xhr.status,
error
);
console.error(
"Response:",
xhr.responseText
);
console.error("Question Master API Error:", xhr.status, error);
console.error("Response:", xhr.responseText);
questionMaster = []; questionMaster = [];
let message = "Unable to load question master."; let message = "Unable to load question master.";
if (xhr.status === 502) { if (xhr.status === 502) {
message =
"Question Master service is currently unavailable.";
message = "Question Master service is currently unavailable.";
} else if (xhr.status === 404) { } else if (xhr.status === 404) {
message =
"Question Master API was not found.";
message = "Question Master API was not found.";
} else if (xhr.status === 500) { } else if (xhr.status === 500) {
message =
"Internal server error while loading question master.";
message = "Internal server error while loading question master.";
} else if (xhr.status === 400) { } else if (xhr.status === 400) {
message =
"Invalid request for Question Master.";
message = "Invalid request for Question Master.";
} }
console.error("Question Master Error:", message); console.error("Question Master Error:", message);
@ -1444,11 +1430,12 @@
} */ } */
function buildStaffList(answer){
/* function buildStaffList(answer){
let html=""; let html="";
if(!answer){ if(!answer){
$("#staffList").html(""); $("#staffList").html("");
$("#staffQ60").html("");
return; return;
} }
@ -1487,6 +1474,65 @@
}); });
$("#staffList").html(html); $("#staffList").html(html);
// Q60
$("#staffQ60").html(
getDropdownText(60, ans["60"])
);
} */
function buildStaffList(answer, answers) {
let html = "";
if (!answer) {
$("#staffList").html("");
$("#staffCount").text("");
$("#staffQ60").html("");
return;
}
const selected = answer.split(",");
const staffQuestion =
questionMaster.find(q => q.qid == 3);
if (!staffQuestion) {
return;
}
$("#staffCount").text(
"(" +
selected.length +
"/" +
staffQuestion.options.length +
")"
);
selected.forEach(function(id) {
let option =
staffQuestion.options.find(
o => o.option_id == id
);
if (option) {
html += `
<div class="staff-item">
<i class="fa fa-check-circle text-success"></i>
${option.english_name}
</div>
`;
}
});
$("#staffList").html(html);
// Q60 - Overall Performance of Staff
$("#staffQ60").html(
getDropdownText(60, answers["60"])
);
} }
/*Resident Details*/ /*Resident Details*/
@ -1626,6 +1672,11 @@
getYesNo(ans["20"],21,22) getYesNo(ans["20"],21,22)
); );
// Q59
$("#foodQ59").html(
getDropdownText(59, ans["59"])
);
// Q21 Food Photo // Q21 Food Photo
// Q21 Food Photo // Q21 Food Photo

Loading…
Cancel
Save