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.

338 lines
12 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns:th="http://www.thymeleaf.org">
  3. <head th:replace="~{fragments/modules/base/head :: head}">
  4. <style>
  5. </style>
  6. </head>
  7. <body>
  8. <div class="wrapper">
  9. <!-- header top menu Start -->
  10. <header th:replace="~{fragments/modules/base/header :: header}"></header>
  11. <!-- header top menu end -->
  12. <div class="page-wrap">
  13. <!--=============== Left Menu side Start ================-->
  14. <div th:replace="~{fragments/modules/base/menu :: menu}"></div>
  15. <!--=============== Left side End ================-->
  16. <div class="main-content">
  17. <div class="container-fluid">
  18. <div class="page-header mb-2">
  19. <div class="row align-items-end">
  20. <div class="col-lg-8">
  21. <div class="page-header-title">
  22. <!-- <i class="far fa-calendar-plus bg-blue"></i> -->
  23. <div class="d-inline">
  24. <h5>Batches</h5>
  25. <span>View and manage application batches</span>
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. <div class="row">
  32. <div class="col-md-12">
  33. <div class="card">
  34. <div class="card-header">
  35. <span style="font-weight: bold;">Batches List</span>
  36. </div>
  37. <div class="card-body">
  38. <div class="table-responsive">
  39. <table id="batchDatatable"
  40. class="table table-striped table-bordered table-hover dataTable"
  41. role="grid">
  42. <thead class="thead-dark">
  43. <tr role="row">
  44. <th class="text-center">S.No</th>
  45. <th class="text-center">Batch ID</th>
  46. <th class="text-center">Receiving Date</th>
  47. <th class="text-center">Department</th>
  48. <th class="text-center">Office Name</th>
  49. <th class="text-center">Applications</th>
  50. <th class="text-center">Completed</th>
  51. <th class="text-center">Pending</th>
  52. <th class="text-center">Action</th>
  53. </tr>
  54. </thead>
  55. <tbody>
  56. </tbody>
  57. </table>
  58. </div>
  59. </div>
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. <div id="pageLoader" style="display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255, 255, 255, 0.8); z-index: 9999; text-align: center;">
  66. <div style="position: relative; top: 50%; transform: translateY(-50%);">
  67. <div class="spinner-border text-primary" role="status" style="width: 3rem; height: 3rem;">
  68. <span class="sr-only">Loading...</span>
  69. </div>
  70. <!-- Add the 'Please wait' text below the spinner -->
  71. <p style="margin-top: 1rem; font-size: 1.2rem; color: #007bff;">Please wait...</p>
  72. </div>
  73. </div>
  74. <div th:replace="~{fragments/modules/base/app_module_menu_box :: div}"></div>
  75. <footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
  76. </div>
  77. </div>
  78. <script th:replace="~{fragments/modules/base/script :: script}"></script>
  79. <script type="text/javascript">
  80. $(document).ready(function() {
  81. var table = $('#batchDatatable').DataTable({
  82. dom: 'Bftip',
  83. columnDefs: [
  84. { targets: 'no-sort', orderable: false }
  85. ],
  86. lengthMenu: [
  87. [50, 100, 200, 500, -1],
  88. ['50 rows', '100 rows', '200 rows', 'Show all']
  89. ],
  90. scrollY: '50vh',
  91. scrollX: true,
  92. buttons: [
  93. {
  94. extend: 'pageLength',
  95. className: 'btn btn-warning'
  96. },
  97. {
  98. title: 'Data export',
  99. extend: 'copyHtml5',
  100. text: 'Copy',
  101. className: 'btn btn-secondary',
  102. id: 'copyBtn'
  103. },
  104. {
  105. extend: 'excelHtml5',
  106. text: 'Excel',
  107. className: 'btn btn-secondary',
  108. id: 'excelBtn'
  109. },
  110. {
  111. extend: 'csvHtml5',
  112. text: 'CSV',
  113. className: 'btn btn-secondary',
  114. id: 'csvBtn'
  115. },
  116. {
  117. extend: 'pdfHtml5',
  118. text: 'PDF',
  119. className: 'btn btn-secondary',
  120. id: 'pdfBtn'
  121. }
  122. ],
  123. fixedHeader: true,
  124. autoWidth: true,
  125. responsive: false,
  126. searching: true,
  127. select: false,
  128. processing: false
  129. });
  130. getbatchdetails();
  131. });
  132. function getbatchdetails(){
  133. $('#pageLoader').show();
  134. $.ajax({
  135. type: "GET",
  136. url: `/election/api/dataentry/batch/getBatchDetails`, // Append query string to URL
  137. contentType: "application/json",
  138. success: function (response) {
  139. console.log("API Response:", response);
  140. $('#pageLoader').hide();
  141. if (response.status === "success") {
  142. console.log("Details Array:", response.data);
  143. // Ensure details is an array and has at least one entry
  144. if (Array.isArray(response.data) && response.data) {
  145. let table = $('#batchDatatable').DataTable({
  146. destroy: true,
  147. searching: true,
  148. autoWidth: true,
  149. paging: true,
  150. info: true,
  151. data: response.data,
  152. columns: [
  153. {
  154. data: null,
  155. render: (data, type, row, meta) => meta.row + 1,
  156. className: 'text-center'
  157. },
  158. { data: 'id', defaultContent: '-', className: 'text-center' },
  159. { data: 'rec_date', defaultContent: '-', className: 'text-center' },
  160. { data: 'dept_name', defaultContent: '-', className: 'text-center' },
  161. {
  162. data: null,
  163. className: "text-center",
  164. render: function (data, type, row) {
  165. let address = '';
  166. if (row.address1) address += row.address1;
  167. if (row.address2) address += (address ? ', ' : '') + row.address2;
  168. return `
  169. <div>
  170. <span>${row.office_name}</span><br>
  171. <span class="text-muted">${address || '-'}</span>
  172. </div>
  173. `;
  174. }
  175. },
  176. { data: 'noof_application', defaultContent: '-', className: 'text-center' },
  177. { data: 'completed', defaultContent: '-', className: 'text-center' },
  178. { data: 'pending', defaultContent: '-', className: 'text-center' },
  179. {
  180. data: 'id',
  181. className: 'text-center',
  182. render: function (data, type, row) {
  183. return `
  184. <button class="btn btn-primary btn-sm"
  185. onclick="gotodetailspage('${row.id}', '${row.pending}')">
  186. New Entry
  187. </button>
  188. `;
  189. }
  190. }
  191. ],
  192. dom: 'Bfrtip',
  193. buttons: [
  194. {
  195. extend: 'pageLength',
  196. className: 'btn btn-warning'
  197. },
  198. {
  199. title: 'Data export',
  200. extend: 'copyHtml5',
  201. text: 'Copy',
  202. className: 'btn btn-secondary',
  203. id: 'copyBtn',
  204. },
  205. {
  206. extend: 'excelHtml5',
  207. text: 'Excel',
  208. className: 'btn btn-secondary',
  209. id: 'excelBtn',
  210. filename: function () {
  211. return 'batch_details_' + getTimestamp();
  212. }
  213. },
  214. {
  215. extend: 'csvHtml5',
  216. text: 'CSV',
  217. className: 'btn btn-secondary',
  218. id: 'csvBtn',
  219. filename: function () {
  220. return 'batch_details_' + getTimestamp();
  221. }
  222. },
  223. {
  224. extend: 'pdfHtml5',
  225. text: 'PDF',
  226. className: 'btn btn-secondary',
  227. id: 'pdfBtn',
  228. filename: function () {
  229. return 'batch_details_' + getTimestamp();
  230. }
  231. }
  232. ],
  233. columnDefs: [
  234. { targets: 'no-sort', orderable: false }
  235. ],
  236. lengthMenu: [
  237. [50, 100, 200, 500, -1],
  238. ['50 rows', '100 rows', '200 rows', 'Show all']
  239. ],
  240. scrollY: '80vh',
  241. scrollX: true,
  242. responsive: false,
  243. searching: true
  244. });
  245. }
  246. else{
  247. $('#pageLoader').hide();
  248. Swal.fire({
  249. icon: 'error',
  250. title: 'Error',
  251. text:'Something went wrong!'
  252. });
  253. }
  254. }
  255. else if (response.status === "error") {
  256. $('#pageLoader').hide();
  257. Swal.fire({
  258. icon: 'error',
  259. title: 'Error',
  260. text: response.message || 'Something went wrong!'
  261. });
  262. }
  263. else {
  264. $('#pageLoader').hide();
  265. Swal.fire({
  266. icon: 'error',
  267. title: 'Error',
  268. text: response.message || 'Something went wrong!'
  269. });
  270. }
  271. },
  272. error: function (error) {
  273. $('#pageLoader').hide();
  274. Swal.fire({
  275. icon: 'error',
  276. title: 'Error',
  277. text: response.message || 'Something went wrong!'
  278. });
  279. }
  280. });
  281. }
  282. function gotodetailspage(batchid, pending) {
  283. if (Number(pending) === 0) {
  284. Swal.fire({
  285. title: "No Pending Entries",
  286. text: "All entries are completed for this batch.",
  287. icon: "warning"
  288. });
  289. return; // stop redirect
  290. }
  291. // else proceed
  292. window.location.href = '/election/dataentry/batchbyid?batchid=' + batchid;
  293. }
  294. function getTimestamp() {
  295. const now = new Date();
  296. const yyyy = now.getFullYear();
  297. const mm = String(now.getMonth() + 1).padStart(2, '0');
  298. const dd = String(now.getDate()).padStart(2, '0');
  299. const hh = String(now.getHours()).padStart(2, '0');
  300. const mi = String(now.getMinutes()).padStart(2, '0');
  301. const ss = String(now.getSeconds()).padStart(2, '0');
  302. return `${yyyy}${mm}${dd}_${hh}${mi}${ss}`;
  303. }
  304. </script>
  305. </body>
  306. </html>