This portal only for GCC Officers. Based on there roles and Group ID they can view there module`s Like PGR, QR Public Asset Feedback, Makkalai Thedi Mayor,etc...
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.

445 lines
20 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns:th="http://www.thymeleaf.org">
  3. <head th:replace="~{fragments/modules/base/head :: head}"></head>
  4. <body>
  5. <div class="wrapper">
  6. <!-- Header -->
  7. <header th:replace="~{fragments/modules/base/header :: header}"></header>
  8. <div class="page-wrap">
  9. <!-- Left Menu -->
  10. <div th:replace="~{fragments/modules/base/menu :: menu}"></div>
  11. <div class="main-content">
  12. <div class="container-fluid">
  13. <div class="page-header">
  14. <div class="row align-items-end">
  15. <div class="col-lg-8">
  16. <div class="page-header-title">
  17. <i class="fas fa-th-large bg-blue"></i>
  18. <div class="d-inline">
  19. <h5>C & D Waste Collectors </h5>
  20. <span>Pending</span>
  21. </div>
  22. </div>
  23. </div>
  24. <div class="col-lg-4">
  25. <nav class="breadcrumb-container" aria-label="breadcrumb">
  26. <ol class="breadcrumb">
  27. <li class="breadcrumb-item"><a href="/index"><i class="ik ik-home"></i></a></li>
  28. <li class="breadcrumb-item">C & D Waste Collectors</li>
  29. <li class="breadcrumb-item active" aria-current="page">Pending</li>
  30. </ol>
  31. </nav>
  32. </div>
  33. </div>
  34. </div>
  35. <hr>
  36. <div class="row">
  37. <div class="col-md-12">
  38. <div class="card">
  39. <div class="card-header">
  40. </div>
  41. <div class="card-block">
  42. <!-- Show the table structure -->
  43. <table id="worksDatatable" class="table table-striped table-bordered table-hover dataTable" role="grid" width="99.5%">
  44. <thead class="thead-dark">
  45. <tr role="row">
  46. <th>S.NO</th> <!-- Auto-incrementing index -->
  47. <th>Name</th>
  48. <th>Mobile No</th>
  49. <th>Address</th>
  50. <th>Actions</th>
  51. </tr>
  52. </thead>
  53. <tbody>
  54. <!-- Check if userDetails is empty or null -->
  55. <!-- Iterate over userDetails to display pending registrations -->
  56. <tr th:each="pendinglist, status : ${userDetails}">
  57. <td th:text="${status.index + 1}">1</td> <!-- Auto-incrementing index -->
  58. <td th:text="${pendinglist['name']}">Name</td>
  59. <td th:text="${pendinglist['mobile_no']}">Mobile No</td>
  60. <td th:text="${pendinglist['address']}">Address</td>
  61. <td class="text-center">
  62. <button class="btn btn-info"
  63. th:attr="onclick='showModal(' + ${pendinglist['register_id']} + ')'"
  64. th:text="'View Details'">
  65. </button>
  66. </td>
  67. </tr>
  68. </tbody>
  69. <tfoot class="thead-dark">
  70. <tr>
  71. <th>S.NO</th>
  72. <th>Name</th>
  73. <th>Mobile No</th>
  74. <th>Address</th>
  75. <th>Actions</th>
  76. </tr>
  77. </tfoot>
  78. </table>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. <!-- Modal -->
  85. <!-- Modal -->
  86. <div class="modal fade" id="detailModal" tabindex="-1" role="dialog" aria-labelledby="detailModalLabel" aria-hidden="true">
  87. <div class="modal-dialog modal-lg" role="document">
  88. <div class="modal-content">
  89. <div class="modal-header">
  90. <h5 class="modal-title" id="detailModalLabel">Register id: <span id="modal_register_id"></span></h5>
  91. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  92. <span aria-hidden="true">&times;</span>
  93. </button>
  94. </div>
  95. <div class="modal-body">
  96. <div id="cduserinfoHTML">
  97. </div>
  98. <div class="row">
  99. <div class="col-md-12">
  100. <p><strong>Adhaar Photo/Document:</strong></p>
  101. <div id="modal_adhaar_container"></div>
  102. </div>
  103. <div class="col-md-12">
  104. <p><strong>User Photo:</strong></p>
  105. <div id="modal_user_photo_container"></div>
  106. </div>
  107. <div class="col-md-12">
  108. <p><strong>RC Book Document:</strong></p>
  109. <div id="modal_vehicle_doc_container"></div>
  110. </div>
  111. <div class="col-md-12">
  112. <p><strong>Lease Vehicle Document:</strong></p>
  113. <div id="modal_leasevehicle_doc_container"></div>
  114. </div>
  115. </div>
  116. <!-- Rejection Section -->
  117. <div id="rejectionSection" style="display: none; margin-top: 20px;">
  118. <p><strong>Reason for Rejection <span class="text-danger">*</span></strong></p>
  119. <textarea id="rejectionReason" rows="4" class="form-control"></textarea>
  120. <button type="button" class="btn btn-danger mt-2" onclick="confirmRejection()">Confirm</button>
  121. </div>
  122. </div>
  123. <div class="modal-footer">
  124. <button type="button" class="btn btn-success" onclick="acceptAction()">Accept</button>
  125. <button type="button" class="btn btn-warning" onclick="showRejectionSection()">Reject</button>
  126. <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. </div>
  132. <footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
  133. </div>
  134. </div>
  135. <!-- Include jQuery and Bootstrap JavaScript -->
  136. <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  137. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
  138. <script th:replace="~{fragments/modules/base/script :: script}"></script>
  139. <script type="text/javascript">
  140. $(document).ready(function() {
  141. // Initialize the DataTable
  142. var table = $('#worksDatatable').DataTable({
  143. dom: 'Bftip',
  144. columnDefs: [
  145. { targets: 'no-sort', orderable: false } // Disable sorting for certain columns
  146. ],
  147. lengthMenu: [
  148. [50, 100, 200, 500, -1],
  149. ['50 rows', '100 rows', '200 rows', 'Show all']
  150. ],
  151. scrollY: '50vh',
  152. fixedColumns: {
  153. left: 1,
  154. right: 1
  155. },
  156. buttons: [
  157. {
  158. extend: 'pageLength',
  159. className: 'btn btn-warning'
  160. },
  161. {
  162. title: 'Data export',
  163. extend: 'copyHtml5',
  164. text: 'Copy',
  165. className: 'btn btn-secondary',
  166. id: 'copyBtn'
  167. },
  168. {
  169. extend: 'excelHtml5',
  170. text: 'Excel',
  171. className: 'btn btn-secondary',
  172. id: 'excelBtn'
  173. },
  174. {
  175. extend: 'csvHtml5',
  176. text: 'CSV',
  177. className: 'btn btn-secondary',
  178. id: 'csvBtn'
  179. },
  180. {
  181. extend: 'pdfHtml5',
  182. text: 'PDF',
  183. className: 'btn btn-secondary',
  184. id: 'pdfBtn'
  185. }
  186. ],
  187. fixedHeader: true,
  188. autoWidth: true,
  189. responsive: true,
  190. searching: true,
  191. select: false,
  192. processing: false,
  193. language: {
  194. emptyTable: "No pending registrations available." // Custom message for empty tables
  195. }
  196. });
  197. });
  198. function showModal(registerId) {
  199. $.ajax({
  200. url: '/gcc/api/registration/pendingbyid?registerId=' + registerId,
  201. method: 'GET',
  202. dataType: 'json',
  203. success: function(data) {
  204. console.log(data);
  205. // Check if data is not empty
  206. if (data.length > 0) {
  207. // Access the first item in the array
  208. const userData = data[0]; // Get the first object from the array
  209. let userinfo = ``;
  210. userinfo = `<p><strong>Name:</strong> <span id="modal_name">${userData.name}</span></p>
  211. <p><strong>Mobile No:</strong> <span id="modal_mobile_no">${userData.mobile_no}</span></p>
  212. <p><strong>Address:</strong> <span id="modal_address">${userData.address}</span></p>
  213. <p><strong>Vehicle No:</strong> <span id="modal_vehicle_num">${userData.vehicle_num}</span></p> <!-- Added Vehicle No -->
  214. <p><strong>Vehicle Type:</strong> <span id="modal_vehicletype">${userData.vehicletype}</span></p>
  215. <p ><strong>Ref Num:</strong> <span id="modal_ref_num">${userData.reference_num}</span></p>`;
  216. $("#cduserinfoHTML").html(userinfo);
  217. $("#modal_register_id").html(userData.register_id);
  218. console.log(userData.adhaarurl);
  219. // Display the files (Adhaar, User Photo, Vehicle Document)
  220. if (userData.adhaarurl!=null) {
  221. displayFile('modal_adhaar_container', userData.adhaarurl);
  222. }
  223. if (userData.user_photourl) {
  224. displayFile('modal_user_photo_container', userData.user_photourl);
  225. }
  226. //if (userData.rcbookurl) {
  227. displayFile('modal_vehicle_doc_container', userData.rcbookurl);
  228. //}
  229. if (userData.leasedocurl) {
  230. displayFile('modal_leasevehicle_doc_container', userData.leasedocurl);
  231. }
  232. // Hide rejection section initially
  233. document.getElementById('rejectionSection').style.display = 'none';
  234. document.getElementById('rejectionReason').value = ''; // Clear previous input
  235. // Show the modal
  236. $('#detailModal').modal({
  237. backdrop: 'static',
  238. keyboard: false
  239. });
  240. } else {
  241. // Handle case where no data is returned
  242. alert('No data found for this registration ID.');
  243. }
  244. },
  245. error: function(err) {
  246. console.error(err);
  247. alert('Failed to fetch data');
  248. }
  249. });
  250. }
  251. // Function to handle Accept action
  252. function acceptAction() {
  253. const registerId = document.getElementById('modal_register_id').innerText; // Get register_id from the modal
  254. const rowElement = document.querySelector(`tr[data-register-id="${registerId}"]`); // Find the row by register_id
  255. const mobileNo = document.getElementById('modal_mobile_no').innerText;
  256. const refNum = document.getElementById('modal_ref_num').innerText;
  257. $.ajax({
  258. url: '/gcc/api/registration/acceptbyid',
  259. method: 'POST',
  260. data: {
  261. registerId: registerId
  262. },
  263. success: function(response) {
  264. console.log(response);
  265. // URL for accepted registration message
  266. const acceptMessageUrl = `https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to=${mobileNo}&v=1.1&format=json&msg_type=IMAGE&method=SENDMEDIAMESSAGE&caption=Welcome+to+Greater+Chennai+Corporation%2C+%0A%0AYour+Registered+ID+is+%2A${registerId}%2A+.%0AYour+C%26D+waste+registration+has+been+approved+successfully.+%0A%0AFor+downloading+your+ID+card%2C+kindly+click+on+the+button+below+%F0%9F%91%87&media_url=https%3A%2F%2Fres.cloudinary.com%2Fdpub5muar%2Fimage%2Fupload%2Fv1729597847%2Fq2ihjs99puhhwkjzajyo.png&isTemplate=true&buttonUrlParam=userdetail%3Fregister_id%3D${refNum}`;
  267. //https://gccservices.chennaicorporation.gov.in/volunteer/wastecollectors/https://gccservices.chennaicorporation.gov.in/volunteer/wastecollectors/userdetail?register_id=5
  268. // Call the WhatsApp function to send acceptance message
  269. sendWhatsAppMessage(mobileNo, acceptMessageUrl);
  270. Swal.fire({
  271. title: 'Success!',
  272. text: 'Registration Accepted Successfully',
  273. icon: 'success',
  274. confirmButtonText: 'OK'
  275. }).then((result) => {
  276. if (result.isConfirmed) {
  277. $('#detailModal').modal('hide'); // Close the modal after success
  278. location.reload(); // Reload page (optional)
  279. }
  280. });
  281. },
  282. error: function(error) {
  283. console.error(error);
  284. Swal.fire({
  285. title: 'Error!',
  286. text: 'Failed to Accept Registration',
  287. icon: 'error',
  288. confirmButtonText: 'OK'
  289. });
  290. }
  291. });
  292. }
  293. function showRejectionSection() {
  294. // Show the rejection section when Reject button is clicked
  295. document.getElementById('rejectionSection').style.display = 'block';
  296. }
  297. function confirmRejection() {
  298. const registerId = document.getElementById('modal_register_id').innerText; // Get register_id from the modal
  299. const rejectionReason = document.getElementById('rejectionReason').value; // Get the rejection reason
  300. const mobileNo = document.getElementById('modal_mobile_no').innerText; // Get mobile number from the modal
  301. const refNum = document.getElementById('modal_ref_num').innerText;
  302. if (!rejectionReason) {
  303. Swal.fire({
  304. title: 'Info',
  305. text: 'Please provide a reason for rejection.',
  306. icon: 'info',
  307. confirmButtonText: 'OK'
  308. });
  309. return; // Stop if no reason is provided
  310. }
  311. $.ajax({
  312. url: '/gcc/api/registration/rejectbyid', // API endpoint for rejection
  313. method: 'POST',
  314. data: {
  315. registerId: registerId, // Pass registerId as request param
  316. reason: rejectionReason // Pass the rejection reason
  317. },
  318. success: function(response) {
  319. // URL for rejected registration
  320. const rejectMessageUrl = `https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to=${mobileNo}&v=1.1&format=json&msg_type=IMAGE&method=SENDMEDIAMESSAGE&caption=Welcome+to+Greater+Chennai+Corporation%2C%0A%0AYour+Registered+ID+is+%2A${registerId}%2A+.%0AYour+C%26D+waste+registration+has+been+Rejected.+%0A%0AKindly+click+on+the+button+below+for+viewing+the+status%F0%9F%91%87&media_url=https%3A%2F%2Fres.cloudinary.com%2Fdpub5muar%2Fimage%2Fupload%2Fv1729598221%2Fci7ybspyanctl9lackby.jpg&isTemplate=true&buttonUrlParam=userdetail%3Fregister_id%3D${refNum}`;
  321. //const acceptMessageUrl = `https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to=${mobileNo}&v=1.1&format=json&msg_type=IMAGE&method=SENDMEDIAMESSAGE&caption=Welcome+to+Greater+Chennai+Corporation%2C+%0A%0AYour+Registered+ID+is+%2A${registerId}%2A+.%0AYour+C%26D+waste+registration+has+been+approved+successfully.+%0A%0AFor+downloading+your+ID+card%2C+kindly+click+on+the+button+below+%F0%9F%91%87&media_url=https%3A%2F%2Fgccservices.in%2Fgcc%2Ffiles%2Fc_d%2F1_approved.jpg&isTemplate=true&buttonUrlParam=userdetail%3Fregister_id%3D${registerId}`;
  322. sendWhatsAppMessage(mobileNo, rejectMessageUrl); // Call the WhatsApp function to send rejection message
  323. Swal.fire({
  324. title: 'Success!',
  325. text: 'Registration Rejected!!',
  326. icon: 'success',
  327. confirmButtonText: 'OK'
  328. }).then((result) => {
  329. if (result.isConfirmed) {
  330. $('#detailModal').modal('hide'); // Close the modal after success
  331. location.reload(); // Reload page (optional)
  332. }
  333. });
  334. },
  335. error: function(error) {
  336. console.error(error);
  337. Swal.fire({
  338. title: 'Error!',
  339. text: 'Failed to Reject Registration',
  340. icon: 'error',
  341. confirmButtonText: 'OK'
  342. });
  343. }
  344. });
  345. }
  346. function displayFile(containerId, filePath) {
  347. const container = document.getElementById(containerId);
  348. // Check if filePath is defined and not null
  349. if (filePath) {
  350. const fileExtension = filePath.split('.').pop().toLowerCase();
  351. const fullPath = filePath; // Construct full URL
  352. console.log('Full Path:', fullPath);
  353. if (fileExtension === 'pdf') {
  354. container.innerHTML = `<embed src="${fullPath}" type="application/pdf" width="100%" height="500px" />`;
  355. } else {
  356. container.innerHTML = `<img src="${fullPath}" alt="Document" class="img-fluid img-thumbnail" />`;
  357. }
  358. } else {
  359. // If filePath is undefined or null, display a default message
  360. container.innerHTML = 'No document available';
  361. }
  362. }
  363. function sendWhatsAppMessage(cellnumber, msgUrl) {
  364. // Send the WhatsApp message
  365. $.ajax({
  366. url: '/gcc/api/cd/whatsapp/send-whatsapp-message', // Replace with your service path
  367. type: 'POST',
  368. data: { msgUrl: msgUrl },
  369. error: function(xhr, status, error) {
  370. console.error('Error sending WhatsApp message:', error);
  371. Swal.fire({
  372. title: 'Error!',
  373. text: 'Message Not sent!',
  374. icon: 'error',
  375. timer: 2000,
  376. showConfirmButton: false
  377. });
  378. }
  379. });
  380. }
  381. </script>
  382. </body>
  383. </html>