You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

531 lines
18 KiB

2 years ago
​
​
​
​
2 years ago
​
​
​
2 years ago
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
​
2 years ago
2 years ago
​
​
2 years ago
​
​
​
2 years ago
​
​
​
​
2 years ago
2 years ago
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
2 years ago
2 years ago
​
​
2 years ago
2 years ago
​
2 years ago
2 years ago
​
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
2 years ago
2 years ago
​
​
2 years ago
2 years ago
​
​
2 years ago
2 years ago
​
​
2 years ago
2 years ago
​
​
2 years ago
2 years ago
​
​
​
​
​
​
​
​
​
​
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
​
​
2 years ago
2 years ago
​
2 years ago
​
​
​
​
​
​
​
​
​
2 years ago
​
​
2 years ago
​
​
​
2 years ago
​
​
​
​
2 years ago
​
​
2 years ago
2 years ago
​
​
​
​
​
​
​
​
2 years ago
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
2 years ago
​
​
​
2 years ago
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
2 years ago
​
​
​
​
2 years ago
​
2 years ago
​
​
​
​
2 years ago
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
2 years ago
​
​
​
​
​
​
2 years ago
​
2 years ago
​
​
2 years ago
2 years ago
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html xmlns:th="http://www.thymeleaf.org">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>CheckList User</title>
  6. <!-- Google Font -->
  7. <link href="https://fonts.googleapis.com/css2?family=Lato:wght@400;700&display=swap" rel="stylesheet">
  8. <!-- Bootstrap CSS -->
  9. <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
  10. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css"
  11. integrity="sha512-Kc323vGBEqzTmouAECnVceyQqyqdsSiqLQISBL29aUW4U/M7pSPA/gEUZQqv1cwx4OnYxTxve5UMg5GT6L4JJg=="
  12. crossorigin="anonymous" referrerpolicy="no-referrer" />
  13. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
  14. <link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" />
  15. <script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
  16. <style>
  17. /*rating style for css*/
  18. .rating {
  19. direction: rtl;
  20. display: inline-flex;
  21. font-size: 24px;
  22. }
  23. .rating input {
  24. display: none;
  25. }
  26. .rating label {
  27. color: #ddd;
  28. cursor: pointer;
  29. margin: 0;
  30. }
  31. .rating input:checked~label {
  32. color: #414f69;
  33. }
  34. .rating label:hover,
  35. .rating label:hover~label {
  36. color: #414f69;
  37. }
  38. /* Style for resizing content */
  39. .resizable-content {
  40. font-size: medium;
  41. transition: font-size 0.3s ease;
  42. }
  43. .comment-table {
  44. width: 100%;
  45. border-collapse: collapse;
  46. }
  47. .comment-table td {
  48. padding: 0.5rem;
  49. border: 1px solid #ddd;
  50. /* Light border color */
  51. }
  52. .comment-table td:first-child {
  53. width: 25%;
  54. /* Adjust as needed for label column width */
  55. font-weight: bold;
  56. }
  57. .comment-table td:nth-child(2) {
  58. width: 75%;
  59. /* Adjust as needed for value column width */
  60. }
  61. </style>
  62. </head>
  63. <body>
  64. <!-- Insert the header fragment -->
  65. <div th:insert="~{fragments/header :: headerFragment}"></div>
  66. <div class="container mt-4">
  67. <!-- Loader GIF -->
  68. <div id="loader" style="display: none; text-align: center;">
  69. <img src="images/Thin broken ring.gif" alt="Loading..." />
  70. </div>
  71. <div class="mt-1">
  72. <div class="row align-items-center justify-content-center">
  73. <h4 class="title resizable-content" style="color: #414f69;">Check Complaint Status</h4>
  74. </div>
  75. </div>
  76. <!-- Card Section -->
  77. <div class="card p-3 resizable-content" style="margin-bottom: 8px;color: #414f69;">
  78. <div class="card mb-3 resizable-content">
  79. <div class="card-header text-white" style="background-color: #414f69;">1. Complaining Person's Details
  80. </div>
  81. <div class="card-body">
  82. <div class="row">
  83. <div class="col-md-6">
  84. Complainant ID:
  85. <input type="text" id="complaintid" class="form-control" value="" disabled>
  86. </div>
  87. <div class="col-md-6">
  88. Complainant Mobile Number:
  89. <input type="text" id="complaint-mobile-number" class="form-control" value="" disabled>
  90. </div>
  91. <div class="col-md-6">
  92. Complainant Name:
  93. <input type="text" id="complaint-customer-name" class="form-control" value="" disabled>
  94. </div>
  95. <!--<div class="col-md-6">
  96. Gender:
  97. <select class="form-control" id="gender" disabled>
  98. <option value="0">Select Gender</option>
  99. <option value="male">Male</option>
  100. <option value="female">Female</option>
  101. <option value="transgender">Transgender</option>
  102. </select>
  103. </div>-->
  104. </div>
  105. </div>
  106. </div>
  107. <div class="card mb-3 resizable-content">
  108. <div class="card-header text-white" style="background-color: #414f69;">2. Complaint Location Details
  109. </div>
  110. <div class="card-body">
  111. <div class="row">
  112. <div class="col-md-4">
  113. Complainant Street:
  114. <input type="text" id="street" class="form-control" disabled>
  115. </div>
  116. <div class="col-md-4">
  117. Complainant Zone:
  118. <input type="text" class="form-control" id="zone" disabled>
  119. </div>
  120. <div class="col-md-4">
  121. Complainant Ward:
  122. <input type="text" class="form-control" id="ward" disabled>
  123. </div>
  124. <div class="col-md-4">
  125. Complainant Area:
  126. <input type="text" class="form-control" id="area" disabled>
  127. </div>
  128. <div class="col-md-4">
  129. Complainant Locality:
  130. <input type="text" class="form-control" id="location" disabled>
  131. </div>
  132. </div>
  133. </div>
  134. </div>
  135. <div class="card resizable-content">
  136. <div class="card-header text-white" style="background-color: #414f69;">3. Complaint Type</div>
  137. <div class="card-body">
  138. <div class="row">
  139. <div class="col-md-4">
  140. Complainant Type:
  141. <input type="text" class="form-control" id="complaintType" disabled>
  142. </div>
  143. <!--<div class="col-md-4">
  144. Complainant Sub-Type:
  145. <input type="text" class="form-control" disabled>
  146. </div>
  147. <div class="col-md-4">
  148. Complainant Title:
  149. <input type="text" class="form-control" disabled>
  150. </div>-->
  151. <div class="col-md-12">
  152. Complainant Description:
  153. <input type="text" class="form-control" id="complaintdesc" disabled>
  154. </div>
  155. </div>
  156. </div>
  157. </div>
  158. </div>
  159. <div class="card mb-3 resizable-content">
  160. <div class="card-header text-white" style="background-color: #414f69;">Complaint Action</div>
  161. <div class="card-body">
  162. <div class="row">
  163. <!--<div class="col-md-2" id="">Aug 24<br>7.00 pm</div>-->
  164. <div class="col-md-4">
  165. Complaint Closed Date:
  166. <input type="text" class="form-control" id="commentDate" disabled>
  167. </div>
  168. <div class="col-md-4">
  169. Official Name:
  170. <input type="text" class="form-control" id="commentuser" disabled>
  171. </div>
  172. <!--<div class="col-md-2"><button class="btn btn-sm"
  173. style="background-color: #414f69;color: white;" id="status"></button></div>-->
  174. <div class="col-md-4">
  175. Status:
  176. <input type="text" class="form-control" id="status"
  177. style="background-color: #414f69;color: white;" disabled>
  178. </div>
  179. </div>
  180. </div>
  181. </div>
  182. <div class="card mb-3 resizable-content">
  183. <div class="card-header text-white" style="background-color: #414f69;">Complaint Action History</div>
  184. <div class="card-body">
  185. <div id="comments-container"></div> <!-- Container for comments -->
  186. </div>
  187. </div>
  188. <div class="card mb-3 resizable-content">
  189. <div class="card-header text-white" style="background-color: #414f69;">Update Complaint</div>
  190. <div class="card-body">
  191. <div class="row">
  192. <div class="col-md-6">
  193. Change Complaint Status:
  194. <select class="form-control" name="complaintStatusID" id="complaintStatus">
  195. <option value="0">Choose</option>
  196. <option value="8">WITHDRAW</option>
  197. <option value="9">REOPENED</option>
  198. <option value="10" selected="true">CLOSE</option>
  199. </select>
  200. </div>
  201. <div class="col-md-6" id="img" style="display: none;">
  202. Photo:
  203. <input type="file" class="form-control" id="photo">
  204. </div>
  205. </div>
  206. <div class="row">
  207. <div class="col-md-12">
  208. Details of Complaint:
  209. <textarea class="form-control" id="othercomplaint-details" rows="3"
  210. placeholder="Enter complaint details" maxlength="400" required></textarea>
  211. </div>
  212. </div>
  213. <div class="row align-items-center justify-content-center" style="margin-top: 5px;">
  214. <button class="btn btn-sm" style="background-color: #414f69;color: white;">Submit</button>
  215. </div>
  216. </div>
  217. </div>
  218. </div>
  219. <!-- Bootstrap JS -->
  220. <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  221. <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js"></script>
  222. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
  223. <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
  224. <script>
  225. </script>
  226. <!-- JavaScript to handle button clicks -->
  227. <script>
  228. // /api/getComplaintDetailsbyId
  229. $(document).ready(function () {
  230. var urlParams = new URLSearchParams(window.location.search);
  231. var complaintNo = urlParams.get('complaintno');
  232. if (complaintNo) {
  233. $('#loader').show();
  234. $.ajax({
  235. url: '/api/getComplaintDetailsbyId', // Replace with your actual API endpoint
  236. type: 'GET',
  237. data: {complaintid: complaintNo},
  238. success: function (response) {
  239. console.log('API response:', response);
  240. $('#loader').hide();
  241. if (Array.isArray(response) && response.length > 0) {
  242. var complaintListHistory = response[0].ComplaintListHistory;
  243. if (Array.isArray(complaintListHistory) && complaintListHistory.length > 0) {
  244. var complaintDetails = complaintListHistory[0];
  245. // Decode HTML entities before populating fields
  246. function decodeHtmlEntities(str) {
  247. var txt = document.createElement('textarea');
  248. txt.innerHTML = str;
  249. return txt.value;
  250. }
  251. // Populate other form fields
  252. document.getElementById("complaintid").value = complaintDetails.complaintid || '';
  253. document.getElementById("complaint-mobile-number").value = complaintDetails.CustomerMobile || '';
  254. document.getElementById("complaint-customer-name").value = complaintDetails.CustomerName || '';
  255. document.getElementById("street").value = complaintDetails.Street || '';
  256. document.getElementById("zone").value = complaintDetails.Zone || '';
  257. document.getElementById("ward").value = complaintDetails.Division || '';
  258. document.getElementById("area").value = complaintDetails.Area || '';
  259. document.getElementById("location").value = complaintDetails.Location || '';
  260. document.getElementById("complaintType").value = complaintDetails.complainttype || '';
  261. // Decode and populate complaint description
  262. document.getElementById("complaintdesc").value = decodeHtmlEntities(complaintDetails.complaintdetails || '');
  263. document.getElementById("commentDate").value = complaintDetails.complaintcloseddate || '';
  264. document.getElementById("commentuser").value = complaintDetails.Officialname || '';
  265. document.getElementById("status").value = complaintDetails.complaintcurrentstatus || '';
  266. // Handle nested Comments array
  267. if (Array.isArray(complaintDetails.Comments) && complaintDetails.Comments.length > 0) {
  268. var commentsContainer = $('#comments-container');
  269. commentsContainer.empty(); // Clear the container
  270. var comments = complaintDetails.Comments;
  271. var lastComment = comments[comments.length - 1];
  272. // Decode HTML entities for last comment
  273. function decodeHtmlEntities(str) {
  274. var txt = document.createElement('textarea');
  275. txt.innerHTML = str;
  276. return txt.value;
  277. }
  278. // Handle last comment
  279. var userImageHtml = '';
  280. if (Array.isArray(lastComment.userimages) && lastComment.userimages.length > 0) {
  281. var imageUrl = lastComment.userimages[0].Comp_Image;
  282. if (imageUrl && imageUrl !== 'null') {
  283. userImageHtml = `
  284. <div class="col-md-12">
  285. <img src="${imageUrl}" alt="User Image" class="img-fluid">
  286. </div>`;
  287. }
  288. }
  289. var lastCommentHtml = `
  290. <div class="row mb-3">
  291. <table class="comment-table">
  292. <tr>
  293. <td style="color:#3c4959">User:</td>
  294. <td>${lastComment.user || ''}</td>
  295. </tr>
  296. <tr>
  297. <td style="color:#3c4959">Message:</td>
  298. <td>${lastComment.message || ''}</td>
  299. </tr>
  300. <tr>
  301. <td style="color:#3c4959">Comment Date:</td>
  302. <td>${lastComment.comment_date || ''}</td>
  303. </tr>
  304. ${userImageHtml}
  305. </table>
  306. </div>
  307. <hr>`;
  308. commentsContainer.append(lastCommentHtml);
  309. // Add dropdown button for other comments
  310. if (comments.length > 1) {
  311. var dropdownHtml = `
  312. <button id="show-all-comments" class="btn mt-3" style="margin-bottom: 10px;background-color: #3c4959;
  313. color: white;">Show All Comments</button>
  314. <div id="all-comments" style="display:none;">`;
  315. // Add all comments to dropdown
  316. comments.forEach(function (comment, index) {
  317. if (index < comments.length - 1) { // Skip the last comment
  318. var userImageHtml = '';
  319. if (Array.isArray(comment.userimages) && comment.userimages.length > 0) {
  320. var imageUrl = comment.userimages[0].Comp_Image;
  321. if (imageUrl && imageUrl !== 'null') {
  322. userImageHtml = `
  323. <div class="col-md-12">
  324. <img src="${imageUrl}" alt="User Image" class="img-fluid">
  325. </div>`;
  326. }
  327. }
  328. dropdownHtml += `
  329. <div class="row mb-3">
  330. <table class="comment-table">
  331. <tr>
  332. <td style="color:#3c4959">User:</td>
  333. <td>${comment.user || ''}</td>
  334. </tr>
  335. <tr>
  336. <td style="color:#3c4959">Message:</td>
  337. <td>${comment.message || ''}</td>
  338. </tr>
  339. <tr>
  340. <td style="color:#3c4959">Comment Date:</td>
  341. <td>${comment.comment_date || ''}</td>
  342. </tr>
  343. ${userImageHtml}
  344. </table>
  345. </div>
  346. <hr>`;
  347. }
  348. });
  349. dropdownHtml += '</div>';
  350. commentsContainer.append(dropdownHtml);
  351. // Toggle display of all comments
  352. $('#show-all-comments').click(function () {
  353. $('#all-comments').toggle();
  354. $(this).text($(this).text() === 'Show All Comments' ? 'Hide Comments' : 'Show All Comments');
  355. });
  356. }
  357. } else {
  358. $('#comments-container').html('<p>No comments found.</p>');
  359. }
  360. } else {
  361. alert('No complaint details found in ComplaintListHistory.');
  362. }
  363. } else {
  364. alert('Unexpected response structure.');
  365. }
  366. },
  367. error: function (xhr, status, error) {
  368. console.log('Error:', xhr.responseText);
  369. alert('An error occurred while fetching complaint details.');
  370. $('#loader').hide();
  371. }
  372. });
  373. } else {
  374. alert('No complaint number provided.');
  375. }
  376. });
  377. $(document).ready(function () {
  378. $('#complaintStatus').change(function () {
  379. if ($(this).val() == '9') { // Show the image field if 'REOPENED' is selected
  380. $('#img').show();
  381. } else {
  382. $('#img').hide();
  383. }
  384. });
  385. // Handle the form submission
  386. $('.btn').click(function (e) {
  387. e.preventDefault();
  388. var complaintId = 'YOUR_COMPLAINT_ID'; // You should fetch this dynamically
  389. var status = $('#complaintStatus').val();
  390. var message = $('#othercomplaint-details').val();
  391. // Validate the "Details of Complaint" field
  392. if (message.trim() === "") {
  393. // Display a SweetAlert validation message if the field is empty
  394. Swal.fire({
  395. title: 'Validation Error!',
  396. text: 'Please enter the details of the complaint.',
  397. icon: 'warning',
  398. confirmButtonText: 'OK'
  399. });
  400. return; // Stop the form submission if the field is empty
  401. }
  402. // Convert image to base64 if it's selected
  403. var imageFile = $('#photo')[0].files[0];
  404. var compImage = '';
  405. if (imageFile) {
  406. var reader = new FileReader();
  407. reader.readAsDataURL(imageFile);
  408. reader.onload = function () {
  409. compImage = reader.result.split(',')[1]; // Extract base64 part
  410. // Proceed with the AJAX call after the image is converted
  411. updateComplaint(complaintId, message, status, compImage);
  412. };
  413. } else {
  414. // No image selected, proceed with the AJAX call without the image
  415. updateComplaint(complaintId, message, status, '');
  416. }
  417. });
  418. // Function to send the AJAX request to the backend
  419. function updateComplaint(complaintId, message, status, compImage) {
  420. $.ajax({
  421. url: '/updateComplaint', // Adjust this to match your endpoint
  422. type: 'POST',
  423. data: {
  424. ComplaintId: complaintId, // complaintId mapped from your backend
  425. Message: message, // message field
  426. Status: status, // status dropdown
  427. Comp_Image: compImage // base64 image data
  428. },
  429. success: function (response) {
  430. // Display SweetAlert and redirect on 'OK'
  431. Swal.fire({
  432. title: 'Success!',
  433. text: 'Complaint updated successfully.',
  434. icon: 'success',
  435. confirmButtonText: 'OK'
  436. }).then((result) => {
  437. if (result.isConfirmed) {
  438. // Redirect to home.html after clicking OK
  439. window.location.href = 'home';
  440. }
  441. });
  442. },
  443. error: function (xhr, status, error) {
  444. // Handle error
  445. console.error('Error updating complaint:', error);
  446. }
  447. });
  448. }
  449. });
  450. </script>
  451. </body>
  452. </html>