Browse Source

Reopen and Followup implemented in socialmedia complaints

main
Hariprasath S 5 months ago
parent
commit
4d84796829
  1. 71
      gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/SocialMediaApiController.java
  2. 138
      gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/QaqcAgentsService.java
  3. 119
      gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/SocialMediaService.java
  4. 36
      gcc_officer_portal/src/main/resources/templates/modules/callcenterqaqc/complaintstatus.html
  5. 160
      gcc_officer_portal/src/main/resources/templates/modules/callcenterqaqc/socialmediacomplaints.html
  6. 25
      gcc_officer_portal/src/main/resources/templates/modules/callcenterqaqc/socialmediacompletedlist.html

71
gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/SocialMediaApiController.java

@ -51,7 +51,8 @@ public class SocialMediaApiController {
@PostMapping("/update") @PostMapping("/update")
@ResponseBody @ResponseBody
public ResponseEntity<String> updateCallDetails(@RequestParam("complaintNumber") String complaintNumber, public ResponseEntity<String> updateCallDetails(@RequestParam("complaintNumber") String complaintNumber,
@RequestParam("userId") String userId,@RequestParam("action") String action,@RequestParam("remarks") String remarks
@RequestParam("userId") String userId,@RequestParam("action") String action,@RequestParam("remarks") String remarks,
@RequestParam(value = "remainderDate", required = false) String remainderDate
) { ) {
try { try {
// System.out.println("Updating Complaint Number: " + complaintNumber); // System.out.println("Updating Complaint Number: " + complaintNumber);
@ -59,7 +60,7 @@ public class SocialMediaApiController {
// System.out.println("action= " + action); // System.out.println("action= " + action);
// System.out.println("remarks="+remarks); // System.out.println("remarks="+remarks);
int updated_agent = Integer.parseInt(userId); int updated_agent = Integer.parseInt(userId);
// System.out.println("updated_agent: " + updated_agent);
// System.out.println("remainderDate: " + remainderDate);
if(remarks.isEmpty()) if(remarks.isEmpty())
{ {
remarks="N/A"; remarks="N/A";
@ -74,7 +75,7 @@ public class SocialMediaApiController {
if ("COMPLETED".equals(action) || "REOPEN".equals(action)) if ("COMPLETED".equals(action) || "REOPEN".equals(action))
{ {
boolean statusUpdated =ChangeStatusInErp(complaintNumber,action,remarks,erp_name); boolean statusUpdated =ChangeStatusInErp(complaintNumber,action,remarks,erp_name);
System.out.println("statusUpdated="+statusUpdated);
//System.out.println("statusUpdated="+statusUpdated);
if (!statusUpdated) if (!statusUpdated)
{ {
@ -84,7 +85,7 @@ public class SocialMediaApiController {
Map<String, Object> details =getDetailsByComplaintNumber(complaintNumber); Map<String, Object> details =getDetailsByComplaintNumber(complaintNumber);
int rowInserted=socialservice.uploadComplaintDetailsInLogs(details,action,remarks,updated_agent);
int rowInserted=socialservice.uploadComplaintDetailsInLogs(details,action,remarks,updated_agent,remainderDate);
if(rowInserted!=1) if(rowInserted!=1)
{ {
return ResponseEntity.ok("save"); return ResponseEntity.ok("save");
@ -102,8 +103,8 @@ public class SocialMediaApiController {
try { try {
String url = "https://erp.chennaicorporation.gov.in/pgr/newmobileservice?serviceId=getComplaintByID&ComplaintId=" String url = "https://erp.chennaicorporation.gov.in/pgr/newmobileservice?serviceId=getComplaintByID&ComplaintId="
+ complaintNumber + "&imgUrlonly=yes";
System.out.println("Request URL: " + url);
+ complaintNumber + "&imgUrlonly=yes&isQcuser=Yes&jsonResp=Yes";
//System.out.println("Request URL: " + url);
ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class); ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class);
@ -272,7 +273,7 @@ public class SocialMediaApiController {
String url="https://erp.chennaicorporation.gov.in/pgr/newmobileservice?serviceId=ms_dashboard_details&From_date="+formattedFromDate+"&To_date="+formattedToDate+"&jsonResp=Yes&Status="+status+"&isQcuser=Yes"+"&ComplaintType="+type+"&ComplaintGroupId="+group+"&compmode="+mode+"&Zoneid="+zone+"&RegionId="+region; String url="https://erp.chennaicorporation.gov.in/pgr/newmobileservice?serviceId=ms_dashboard_details&From_date="+formattedFromDate+"&To_date="+formattedToDate+"&jsonResp=Yes&Status="+status+"&isQcuser=Yes"+"&ComplaintType="+type+"&ComplaintGroupId="+group+"&compmode="+mode+"&Zoneid="+zone+"&RegionId="+region;
System.out.println(url);
//System.out.println(url);
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
@ -287,8 +288,16 @@ public class SocialMediaApiController {
} }
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
Map<String, Object> responseMap = objectMapper.readValue(rawResponse, Map.class); Map<String, Object> responseMap = objectMapper.readValue(rawResponse, Map.class);
List<Map<String, Object>> details = (List<Map<String, Object>>) responseMap.get("Details");
List<Map<String, Object>> details;
details = (List<Map<String, Object>>) responseMap.get("Details");
//System.out.println(details); //System.out.println(details);
if(status.equals("redressed") || status.equals("closed")) {
details=socialservice.getfiltreddetails(details);
}
if (details == null) { if (details == null) {
response.put("status", "nodata"); response.put("status", "nodata");
response.put("message", "No Data, please change criteria"); response.put("message", "No Data, please change criteria");
@ -314,7 +323,7 @@ public class SocialMediaApiController {
@RequestParam String endDate, @RequestParam String status, @RequestParam String endDate, @RequestParam String status,
@RequestParam String zone) { @RequestParam String zone) {
System.out.printf("==================="+startDate,endDate,zone);
//System.out.printf("==================="+startDate,endDate,zone);
Map<String, Object> response = new HashMap<>(); Map<String, Object> response = new HashMap<>();
try { try {
@ -349,4 +358,48 @@ public class SocialMediaApiController {
return response; return response;
} }
@GetMapping("/getA1dropdowns")
public ResponseEntity<?> getA1dropdowns(){
try {
List<Map<String, Object>> list = socialservice.getA1dropdowns();
Map<String, Object> response = new HashMap<>();
response.put("status", "success");
response.put("data", list);
return ResponseEntity.ok(response);
} catch (Exception ex) {
ex.printStackTrace();
Map<String, Object> error = new HashMap<>();
error.put("status", "error");
error.put("message", ex.getMessage());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error);
}
}
@GetMapping("/getA2dropdowns")
public ResponseEntity<?> getA2dropdowns(){
try {
List<Map<String, Object>> list = socialservice.getA2dropdowns();
Map<String, Object> response = new HashMap<>();
response.put("status", "success");
response.put("data", list);
return ResponseEntity.ok(response);
} catch (Exception ex) {
ex.printStackTrace();
Map<String, Object> error = new HashMap<>();
error.put("status", "error");
error.put("message", ex.getMessage());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error);
}
}
} }

138
gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/QaqcAgentsService.java

@ -524,48 +524,150 @@ public class QaqcAgentsService {
} }
// public List<Map<String, Object>> getAttendedComplainthistory(
// String startDate, String endDate, String complaintNumber, String complaintMobileNumber) {
//
// // Base query with JOIN to include agent_name
// StringBuilder query = new StringBuilder(
// "SELECT qcl.*, al.agent_name " +
// "FROM qaqc_call_logs qcl " +
// "LEFT JOIN agents_list al ON qcl.agent_id = al.agent_id " +
// "WHERE 1=1 ");
//
// // List to store query parameters
// List<Object> params = new ArrayList<>();
//
// // Add date range condition if provided
// if (startDate != null && !startDate.isEmpty()) {
// query.append("AND DATE(qcl.created_date) >= ? ");
// params.add(startDate);
// }
// if (endDate != null && !endDate.isEmpty()) {
// query.append("AND DATE(qcl.created_date) <= ? ");
// params.add(endDate);
// }
//
// // Add complaint number condition if provided
// if (complaintNumber != null && !complaintNumber.isEmpty()) {
// query.append("AND qcl.complaint_number = ? ");
// params.add(complaintNumber);
// }
//
// // Add complaint mobile number condition if provided
// if (complaintMobileNumber != null && !complaintMobileNumber.isEmpty()) {
// query.append("AND qcl.complaint_mobilenumber = ? ");
// params.add(complaintMobileNumber);
// }
//
// // Group by qcl.id and agent_name to avoid SQL error
// query.append("GROUP BY qcl.id, al.agent_name ");
//
// // Add ordering clause
// query.append("ORDER BY qcl.created_date DESC");
//
// // Execute the query with dynamic parameters
// return jdbcTemplate.queryForList(query.toString(), params.toArray());
// }
public List<Map<String, Object>> getAttendedComplainthistory( public List<Map<String, Object>> getAttendedComplainthistory(
String startDate, String endDate, String complaintNumber, String complaintMobileNumber) {
String startDate,
String endDate,
String complaintNumber,
String complaintMobileNumber) {
// Base query with JOIN to include agent_name
StringBuilder query = new StringBuilder( StringBuilder query = new StringBuilder(
"SELECT qcl.*, al.agent_name " +
"SELECT * FROM ( " +
// ================= QAQC CALL LOGS =================
"SELECT " +
"qcl.id, " +
"qcl.qaqc_id, " +
"qcl.call_category, " +
"qcl.agent_id, " +
"qcl.complaint_number, " +
"qcl.complaint_date, " +
"qcl.complaint_person_name, " +
"qcl.complaint_mobilenumber, " +
"qcl.complaint_type, " +
"qcl.complaint_mode, " +
"qcl.department, " +
"qcl.complaint_group, " +
"qcl.official_name, " +
"qcl.official_mobilenum, " +
"qcl.call_status, " +
"qcl.remainder_date, " +
"qcl.remarks, " +
"qcl.created_date, " +
"qcl.is_processed, " +
"qcl.updated_agent, " +
"al.agent_name, " +
"'QAQC' AS source_table " +
"FROM qaqc_call_logs qcl " + "FROM qaqc_call_logs qcl " +
"LEFT JOIN agents_list al ON qcl.agent_id = al.agent_id " + "LEFT JOIN agents_list al ON qcl.agent_id = al.agent_id " +
"WHERE 1=1 ");
// List to store query parameters
"UNION ALL " +
// ================= SOCIAL MEDIA =================
"SELECT " +
"smc.id, " +
"NULL AS qaqc_id, " +
"NULL AS call_category, " +
"smc.updated_by AS agent_id, " +
"smc.complaint_number, " +
"smc.complaint_date, " +
"smc.complaint_person_name, " +
"smc.complaint_mobilenumber, " +
"smc.complaint_type, " +
"smc.complaint_mode, " +
"smc.department, " +
"NULL AS complaint_group, " +
"smc.official_name, " +
"smc.official_mobilenum, " +
"smc.call_status, " +
"smc.remainder_date AS remainder_date, " +
"smc.remarks, " +
"smc.created_date, " +
"smc.is_processed AS is_processed, " +
"smc.updated_by AS updated_agent, " +
"al.agent_name, " +
"'SOCIAL_MEDIA' AS source_table " +
"FROM social_media_completed smc " +
"LEFT JOIN agents_list al ON smc.updated_by = al.agent_id " +
") x WHERE 1=1 "
);
List<Object> params = new ArrayList<>(); List<Object> params = new ArrayList<>();
// Add date range condition if provided
// ================= DATE FILTER =================
if (startDate != null && !startDate.isEmpty()) { if (startDate != null && !startDate.isEmpty()) {
query.append("AND DATE(qcl.created_date) >= ? ");
query.append("AND DATE(x.created_date) >= ? ");
params.add(startDate); params.add(startDate);
} }
if (endDate != null && !endDate.isEmpty()) { if (endDate != null && !endDate.isEmpty()) {
query.append("AND DATE(qcl.created_date) <= ? ");
query.append("AND DATE(x.created_date) <= ? ");
params.add(endDate); params.add(endDate);
} }
// Add complaint number condition if provided
// ================= COMPLAINT NUMBER =================
if (complaintNumber != null && !complaintNumber.isEmpty()) { if (complaintNumber != null && !complaintNumber.isEmpty()) {
query.append("AND qcl.complaint_number = ? ");
query.append("AND x.complaint_number = ? ");
params.add(complaintNumber); params.add(complaintNumber);
} }
// Add complaint mobile number condition if provided
// ================= MOBILE NUMBER =================
if (complaintMobileNumber != null && !complaintMobileNumber.isEmpty()) { if (complaintMobileNumber != null && !complaintMobileNumber.isEmpty()) {
query.append("AND qcl.complaint_mobilenumber = ? ");
query.append("AND x.complaint_mobilenumber = ? ");
params.add(complaintMobileNumber); params.add(complaintMobileNumber);
} }
// Group by qcl.id and agent_name to avoid SQL error
query.append("GROUP BY qcl.id, al.agent_name ");
// ================= ORDER =================
query.append("ORDER BY x.created_date DESC");
// Add ordering clause
query.append("ORDER BY qcl.created_date DESC");
// Execute the query with dynamic parameters
return jdbcTemplate.queryForList(query.toString(), params.toArray()); return jdbcTemplate.queryForList(query.toString(), params.toArray());
} }

119
gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/SocialMediaService.java

@ -4,7 +4,8 @@ import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.time.LocalDate;
import java.util.HashMap;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -26,7 +27,7 @@ public class SocialMediaService {
} }
@Transactional @Transactional
public int uploadComplaintDetailsInLogs(Map<String, Object> details,String action,String remarks,int updated_agent) {
public int uploadComplaintDetailsInLogs(Map<String, Object> details,String action,String remarks,int updated_agent,String remainderDate) {
//System.out.println("Complaint Details: " + details); //System.out.println("Complaint Details: " + details);
// Extract other field values from complaintDetails // Extract other field values from complaintDetails
String complaintNumber = details.get("complaintid").toString(); String complaintNumber = details.get("complaintid").toString();
@ -42,16 +43,22 @@ public class SocialMediaService {
String remarksfield = remarks; String remarksfield = remarks;
String zone = details.get("Zone").toString(); String zone = details.get("Zone").toString();
int updated_by=updated_agent; int updated_by=updated_agent;
String cur_status = details.get("currentStatus").toString();
String finalremainderDate=null;
if(!remainderDate.isEmpty()) {
finalremainderDate=remainderDate;
}
LocalDateTime currentDate = LocalDateTime.now(); LocalDateTime currentDate = LocalDateTime.now();
String query = "INSERT INTO gcc_1913_qaqc.social_media_completed (complaint_number,zone,complaint_date, complaint_person_name,remarks, " String query = "INSERT INTO gcc_1913_qaqc.social_media_completed (complaint_number,zone,complaint_date, complaint_person_name,remarks, "
+ "complaint_mobilenumber, complaint_type, complaint_mode, department, official_name,official_mobilenum, call_status,created_date,updated_by) "
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?)";
+ "complaint_mobilenumber, complaint_type, complaint_mode, department, official_name,official_mobilenum, call_status,created_date,updated_by,cur_status,remainder_date) "
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?,?)";
int rowsAffected = jdbcTemplate.update(query, complaintNumber,zone, complaintDate,personName,remarksfield, int rowsAffected = jdbcTemplate.update(query, complaintNumber,zone, complaintDate,personName,remarksfield,
personMobNo, cType, cMode, department, officialName, officialMobileNum,callStatus, personMobNo, cType, cMode, department, officialName, officialMobileNum,callStatus,
currentDate,updated_by);
currentDate,updated_by,cur_status,finalremainderDate);
//System.out.println("Rows Inserted in table : " + rowsAffected); //System.out.println("Rows Inserted in table : " + rowsAffected);
return rowsAffected; return rowsAffected;
@ -59,7 +66,7 @@ public class SocialMediaService {
} }
public List<Map<String, Object>> getdetails(String formattedFromDate, String formattedToDate, String status, String zone) { public List<Map<String, Object>> getdetails(String formattedFromDate, String formattedToDate, String status, String zone) {
StringBuilder query = new StringBuilder("SELECT * FROM gcc_1913_qaqc.social_media_completed WHERE DATE(created_date) BETWEEN ? AND ? ");
StringBuilder query = new StringBuilder("SELECT *,DATE_FORMAT(remainder_date, '%d/%m/%Y') as formatted_fdate FROM gcc_1913_qaqc.social_media_completed WHERE DATE(created_date) BETWEEN ? AND ? ");
List<Object> params = new ArrayList<>(); List<Object> params = new ArrayList<>();
params.add(formattedFromDate); params.add(formattedFromDate);
params.add(formattedToDate); params.add(formattedToDate);
@ -74,15 +81,9 @@ public class SocialMediaService {
params.add(status); params.add(status);
} }
// Log the query and parameters for debugging
//System.out.println("Executing query: " + query.toString());
//System.out.println("With parameters: " + params);
// Execute the query // Execute the query
List<Map<String, Object>> results = jdbcTemplate.queryForList(query.toString(), params.toArray()); List<Map<String, Object>> results = jdbcTemplate.queryForList(query.toString(), params.toArray());
// Log the results for debugging
//System.out.println("Query results: " + results);
return results.isEmpty() ? null : results; return results.isEmpty() ? null : results;
} }
@ -100,6 +101,100 @@ public class SocialMediaService {
return erpUsername; return erpUsername;
} }
public List<Map<String, Object>> getA1dropdowns() {
String sql="SELECT * FROM call_status WHERE isactive=1 AND isdelete=0 AND call_category_id=5";
try {
return jdbcTemplate.queryForList(sql);
} catch (Exception ex) {
ex.printStackTrace();
return new ArrayList<>(); // return empty list on error
}
}
public List<Map<String, Object>> getA2dropdowns() {
String sql="SELECT * FROM call_status WHERE isactive=1 AND isdelete=0 AND call_category_id=6";
try {
return jdbcTemplate.queryForList(sql);
} catch (Exception ex) {
ex.printStackTrace();
return new ArrayList<>(); // return empty list on error
}
}
public List<Map<String, Object>> getfiltreddetails(List<Map<String, Object>> details) {
List<Map<String, Object>> followupData = getFollowupData();
if (followupData == null || followupData.isEmpty()) {
return details;
}
LocalDate currentDate = LocalDate.now();
// Store complaint_number -> followup row
Map<String, Map<String, Object>> followupMap = new HashMap<>();
for (Map<String, Object> followup : followupData) {
String complaintNumber = String.valueOf(followup.get("complaint_number"));
followupMap.put(complaintNumber, followup);
}
List<Map<String, Object>> filteredDetails = new ArrayList<>();
for (Map<String, Object> detail : details) {
String complaintNumber =String.valueOf(detail.get("Complaint Number"));
// If complaint not in followup table
if (!followupMap.containsKey(complaintNumber)) {
filteredDetails.add(detail);
continue;
}
Map<String, Object> followupRow =followupMap.get(complaintNumber);
String remainderDateStr =String.valueOf(followupRow.get("remainder_date"));
LocalDate remainderDate = LocalDate.parse(remainderDateStr);
// remainder_date <= current date
if (!remainderDate.isAfter(currentDate)) {
// UPDATE is_processed = 0
Integer id = (Integer) followupRow.get("id");
updateFollowupProcessed(id);
filteredDetails.add(detail);
}
// ELSE:
// remainder_date > currentDate
// skip / eliminate from frontend
}
return filteredDetails;
}
private void updateFollowupProcessed(Integer id) {
String sql =
"UPDATE social_media_completed " +
"SET is_processed = 0 " +
"WHERE id = ?";
jdbcTemplate.update(sql, id);
}
private List<Map<String, Object>> getFollowupData() {
String sqlQuery = "select id, complaint_number,call_status, remainder_date from social_media_completed where is_processed=1 AND call_status='FOLLOWUP'";
return jdbcTemplate.queryForList(sqlQuery);
}
} }

36
gcc_officer_portal/src/main/resources/templates/modules/callcenterqaqc/complaintstatus.html

@ -114,17 +114,11 @@
<div class="row mt-4"> <div class="row mt-4">
<div class="col-12"> <div class="col-12">
<div class="card"> <div class="card">
<div
class="card-header d-flex justify-content-between align-items-center">
<div class="card-header d-flex justify-content-between align-items-center">
<h3 class="mb-0" style="font-weight: bold">Check Complaint <h3 class="mb-0" style="font-weight: bold">Check Complaint
Status</h3> Status</h3>
<!-- div class="d-flex">
<button type="button" class="btn btn-primary" id="searchBtn">Search</button>
</div> -->
<div class="d-flex">
<!-- <div class="d-flex">
<input type="date" class="form-control mr-2" id="startDate" <input type="date" class="form-control mr-2" id="startDate"
placeholder="Start Date"> <input type="date" placeholder="Start Date"> <input type="date"
@ -138,6 +132,32 @@
id="searchBtn">Search</button> id="searchBtn">Search</button>
<button type="button" class="btn btn-secondary ml-2" <button type="button" class="btn btn-secondary ml-2"
id="resetBtn">Reset</button> id="resetBtn">Reset</button>
</div> -->
</div>
<div class="card-block">
<div class="row">
<div class="col-sm-2 mb-2">
<input type="date" class="form-control mr-2" id="startDate" placeholder="Start Date">
</div>
<div class="col-sm-2 mb-2">
<input type="date" class="form-control mr-2" id="endDate" placeholder="End Date">
</div>
<div class="col-sm-2 mb-2">
<input class="form-control mr-2" placeholder="complaintnumber" id="complaintNumber">
</div>
<div class="col-sm-2 mb-2">
<input class="form-control mr-2" placeholder="mobilenumber" id="complaintMobileNumber">
</div>
<div class="col-sm-1 mb-2">
<select id="year" class="year-dropdown" style="height: 35px;"></select>
</div>
<button type="submit" class="btn btn-primary ml-2" style="height: 35px;"
id="searchBtn">Search</button>
<button type="button" class="btn btn-secondary ml-2" style="height: 35px;"
id="resetBtn">Reset</button>
</div> </div>
</div> </div>

160
gcc_officer_portal/src/main/resources/templates/modules/callcenterqaqc/socialmediacomplaints.html

@ -433,6 +433,68 @@
$(document).ready(function() { $(document).ready(function() {
let a1Dropdowns = [];
let a2Dropdowns = [];
// A1 Dropdown API
function loadA1Dropdowns() {
return $.ajax({
url: '/gcc/api/callcenterqaqc/socialmedia/getA1dropdowns',
type: 'GET',
success: function(response) {
if (response.status === "success") {
a1Dropdowns = response.data;
}
}
});
}
// A2 Dropdown API
function loadA2Dropdowns() {
return $.ajax({
url: '/gcc/api/callcenterqaqc/socialmedia/getA2dropdowns',
type: 'GET',
success: function(response) {
if (response.status === "success") {
a2Dropdowns = response.data;
}
}
});
}
// LOAD BOTH APIs INITIALY
$.when(
loadA1Dropdowns(),
loadA2Dropdowns()
).done(function () {
console.log("A1 Dropdowns Loaded", a1Dropdowns);
console.log("A2 Dropdowns Loaded", a2Dropdowns);
});
$(document).on('change', '.action-dropdown', function () {
let selectedValue = $(this).val();
let followupDateField = $(this)
.closest('.action-container')
.find('.followup-date');
if (selectedValue === "FOLLOWUP") {
followupDateField.show();
} else {
followupDateField.hide();
followupDateField.val('');
}
});
var table = $('#ReportDatatable').DataTable({ var table = $('#ReportDatatable').DataTable({
dom: 'Bftip', dom: 'Bftip',
columnDefs: [ columnDefs: [
@ -611,18 +673,50 @@
className: 'text-center', className: 'text-center',
render: function(data, type, row) { render: function(data, type, row) {
let options = `<option value="">Select</option>
<option value="COMPLETED">COMPLETED</option>`;
let dropdownData = [];
// REDRESSED -> A1
if (status === "redressed") {
dropdownData = a1Dropdowns;
}
// CLOSED -> A2
if (status === "closed") { if (status === "closed") {
options += `<option value="REOPEN">REOPEN</option>`;
dropdownData = a2Dropdowns;
} }
return (status === "closed" || status === "redressed")
? `<select class="form-control" id="action">
if (status === "closed" || status === "redressed") {
let options = `<option value="">Select</option>`;
dropdownData.forEach(function(item) {
options += `
<option value="${item.call_status}">
${item.call_status}
</option>
`;
});
return `
<div class="action-container">
<select class="form-control action-dropdown">
${options} ${options}
</select>`
: '-';
</select>
<input
type="date"
class="form-control followup-date mt-2"
style="display:none;"
min="${new Date(Date.now() + 86400000).toISOString().split('T')[0]}"
>
</div>
`;
}
return '-';
} }
}, },
{ {
@ -1024,12 +1118,14 @@
// Find the closest table row and get the specific action and remarks // Find the closest table row and get the specific action and remarks
const row = $(`button[data-complaint-number="${complaintNumber}"]`).closest('tr'); const row = $(`button[data-complaint-number="${complaintNumber}"]`).closest('tr');
const actionValue = row.find('select').val(); // Select dropdown within the same row const actionValue = row.find('select').val(); // Select dropdown within the same row
const remarksValue = row.find('input').val(); // Input field within the same row
const remarksValue = row.find('#remarks').val();
const remainderDate = row.find('.followup-date').val();
console.log("complaintNumber:",complaintNumber) console.log("complaintNumber:",complaintNumber)
console.log("Action:", actionValue); console.log("Action:", actionValue);
console.log("Remarks:", remarksValue); console.log("Remarks:", remarksValue);
console.log("Remainder Date:", remainderDate);
// Check if action is empty // Check if action is empty
if (actionValue === "") { if (actionValue === "") {
@ -1052,6 +1148,29 @@
return; // Stop execution if remarks are empty return; // Stop execution if remarks are empty
} }
if (actionValue === "FOLLOWUP" && remainderDate === "") {
Swal.fire({
icon: 'warning',
title: 'Date Required',
text: 'Please select followup date.'
});
return;
}
if (actionValue === "FOLLOWUP" && remarksValue.trim() === "") {
Swal.fire({
icon: 'warning',
title: 'Remarks Required',
text: 'Please enter remarks.'
});
return; // Stop execution if remarks are empty
}
Swal.fire({ Swal.fire({
title: 'Are you sure to update?', title: 'Are you sure to update?',
text: 'This action will update the complaint.', text: 'This action will update the complaint.',
@ -1067,6 +1186,7 @@
reverseButtons: false // Optional: makes the "No" button appear first reverseButtons: false // Optional: makes the "No" button appear first
}).then((result) => { }).then((result) => {
if (result.isConfirmed) { if (result.isConfirmed) {
$('#pageLoader').show();
// User clicked "Yes" // User clicked "Yes"
$('.btn.btn-success').prop('disabled', true); $('.btn.btn-success').prop('disabled', true);
$.ajax({ $.ajax({
@ -1076,9 +1196,11 @@
complaintNumber: complaintNumber, complaintNumber: complaintNumber,
userId: userId, userId: userId,
action: actionValue, // Add selected action to the request data action: actionValue, // Add selected action to the request data
remarks: remarksValue // Add remarks to the request data
remarks: remarksValue, // Add remarks to the request data
remainderDate: remainderDate
}, },
success: function (response) { success: function (response) {
$('#pageLoader').hide();
if (response === "Success") { if (response === "Success") {
Swal.fire({ Swal.fire({
icon: 'success', icon: 'success',
@ -1126,6 +1248,7 @@
} }
}, },
error: function (xhr, status, error) { error: function (xhr, status, error) {
$('#pageLoader').hide();
$('.btn.btn-success').prop('disabled', false); $('.btn.btn-success').prop('disabled', false);
Swal.fire("Error", `An error occurred: ${xhr.responseText || error}`, "error"); Swal.fire("Error", `An error occurred: ${xhr.responseText || error}`, "error");
} }
@ -1140,24 +1263,5 @@
</script> </script>
<!--
{
data: '',
defaultContent: '-',
className: 'text-center',
render: function(data, type, row) {
return `
<td class="text-center">
<select class="form-control" id="action">
<option value="">Select</option>
<option value="COMPLETED">COMPLETED</option>
<option value="REOPENED">REOPEN</option>
</select>
</td>`;
}
},
-->
</body> </body>
</html> </html>

25
gcc_officer_portal/src/main/resources/templates/modules/callcenterqaqc/socialmediacompletedlist.html

@ -123,7 +123,8 @@
<select id="status" class="form-control"> <select id="status" class="form-control">
<option value="ALL">Select</option> <option value="ALL">Select</option>
<option value="COMPLETED">Completed</option> <option value="COMPLETED">Completed</option>
<option value="REOPENED">Reopened</option>
<option value="REOPEN">Reopened</option>
<option value="FOLLOWUP">Followup</option>
</select> </select>
</div> </div>
@ -435,7 +436,27 @@
{ data: 'complaint_person_name', defaultContent: '-', className: 'text-center' }, { data: 'complaint_person_name', defaultContent: '-', className: 'text-center' },
{ data: 'complaint_mobilenumber', defaultContent: '-', className: 'text-center' }, { data: 'complaint_mobilenumber', defaultContent: '-', className: 'text-center' },
{ data: 'official_name', defaultContent: '-', className: 'text-center' }, { data: 'official_name', defaultContent: '-', className: 'text-center' },
{ data: 'call_status', defaultContent: '-', className: 'text-center' },
{
data: null,
defaultContent: '-',
className: 'text-center',
render: function(data, type, row) {
if (row.call_status === "FOLLOWUP") {
return `
<div>
<div><b>${row.call_status}</b></div>
<div class="text-danger">
${row.formatted_fdate}
</div>
</div>
`;
}
return row.call_status || '-';
}
},
{ {
data: 'complaint_number', data: 'complaint_number',
render: function(data, type, row) { render: function(data, type, row) {

Loading…
Cancel
Save