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.

562 lines
15 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>Updation</h5>
  25. <span>View and manage application Entries </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>Fill in the details </span>
  36. </div>
  37. <div class="card-body">
  38. <div class="row align-items-end">
  39. <div class="col-md-3 col-sm-12">
  40. <label class="form-label" for="unique_num">Unique No</label>
  41. <input type="text" class="form-control" id="unique_num">
  42. </div>
  43. <div class="col-md-1 col-sm-12 text-center pt-4">
  44. <span style="font-weight: bold;">OR</span>
  45. </div>
  46. <div class="col-md-3 col-sm-12">
  47. <label class="form-label" for="mobile_num">Mobile No</label>
  48. <input type="text" class="form-control" id="mobile_num">
  49. </div>
  50. <div class="col-md-3 col-sm-12 d-flex align-items-end">
  51. <button type="submit" id="searchBtn"
  52. class="btn btn-primary mx-2">Search</button>
  53. <button class="btn btn-danger mx-2" id="resetBtn"
  54. name="reset">Reset</button>
  55. </div>
  56. </div>
  57. <br>
  58. </div>
  59. </div>
  60. </div>
  61. </div>
  62. <!-- data table -->
  63. <div class="row" id="detailscard">
  64. <div class="col-md-12">
  65. <div class="card">
  66. <div class="card-body">
  67. <div class="table-responsive">
  68. <table id="DetailsDatatable"
  69. class="table table-striped table-bordered table-hover dataTable"
  70. role="grid">
  71. <thead class="thead-dark">
  72. <tr role="row">
  73. <th class="text-center">S.No</th>
  74. <th class="text-center">Unique No</th>
  75. <th class="text-center width1">Name / Pay Scale / Cur.Basic / Grade Pay</th>
  76. <th class="text-center">Sex</th>
  77. <th class="text-center">Designation</th>
  78. <th class="text-center">State / Central</th>
  79. <th class="text-center">Mobile Number</th>
  80. <th class="text-center">Residential Address</th>
  81. <th class="text-center">Native Constituency</th>
  82. <th class="text-center">Residential Constituency</th>
  83. <th class="text-center">Working Constituency</th>
  84. <th class="text-center">Enrolled - Part / Sl.No / EPIC / Assembly Constituency</th>
  85. <th class="text-center">Photo</th>
  86. <th class="text-center">Action</th>
  87. </tr>
  88. </thead>
  89. <tbody>
  90. </tbody>
  91. </table>
  92. </div>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. </div>
  98. </div>
  99. <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;">
  100. <div style="position: relative; top: 50%; transform: translateY(-50%);">
  101. <div class="spinner-border text-primary" role="status" style="width: 3rem; height: 3rem;">
  102. <span class="sr-only">Loading...</span>
  103. </div>
  104. <!-- Add the 'Please wait' text below the spinner -->
  105. <p style="margin-top: 1rem; font-size: 1.2rem; color: #007bff;">Please wait...</p>
  106. </div>
  107. </div>
  108. <div th:replace="~{fragments/modules/base/app_module_menu_box :: div}"></div>
  109. <footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
  110. </div>
  111. </div>
  112. <script th:replace="~{fragments/modules/base/script :: script}"></script>
  113. <script type="text/javascript">
  114. document.getElementById('resetBtn').addEventListener('click', function (e) {
  115. location.reload();
  116. });
  117. $(document).ready(function() {
  118. // MOBILE NO: exactly 10 digits
  119. $('#mobile_num').on('input', function () {
  120. // Allow only digits
  121. this.value = this.value.replace(/\D/g, '');
  122. // Max 10 digits
  123. if (this.value.length > 10) {
  124. this.value = this.value.slice(0, 10);
  125. }
  126. });
  127. $('#unique_num').on('input', function () {
  128. // Allow only digits
  129. this.value = this.value.replace(/\D/g, '');
  130. });
  131. var table = $('#DetailsDatatable').DataTable({
  132. dom: 'Bftip',
  133. columnDefs: [
  134. { width: "150px", targets: 2 }, // Name / Pay Scale column
  135. { width: "150px", targets: 6 }, // Office Address column
  136. { width: "150px", targets: 8 },
  137. { width: "150px", targets: 12 }
  138. ],
  139. lengthMenu: [
  140. [50, 100, 200, 500, -1],
  141. ['50 rows', '100 rows', '200 rows', 'Show all']
  142. ],
  143. scrollY: '50vh',
  144. scrollX: true,
  145. buttons: [
  146. {
  147. extend: 'pageLength',
  148. className: 'btn btn-warning'
  149. },
  150. {
  151. title: 'Data export',
  152. extend: 'copyHtml5',
  153. text: 'Copy',
  154. className: 'btn btn-secondary',
  155. id: 'copyBtn'
  156. },
  157. {
  158. extend: 'excelHtml5',
  159. text: 'Excel',
  160. className: 'btn btn-secondary',
  161. id: 'excelBtn'
  162. },
  163. {
  164. extend: 'csvHtml5',
  165. text: 'CSV',
  166. className: 'btn btn-secondary',
  167. id: 'csvBtn'
  168. },
  169. {
  170. extend: 'pdfHtml5',
  171. text: 'PDF',
  172. className: 'btn btn-secondary',
  173. id: 'pdfBtn'
  174. }
  175. ],
  176. fixedHeader: true,
  177. autoWidth: true,
  178. responsive: false,
  179. searching: true,
  180. select: false,
  181. processing: false
  182. });
  183. });
  184. document.getElementById('searchBtn').addEventListener('click', function (e) {
  185. $('#pageLoader').show();
  186. let unique_num = document.getElementById('unique_num').value;
  187. let mobile_num = document.getElementById('mobile_num').value;
  188. console.log(unique_num,",",mobile_num);
  189. if(!unique_num && !mobile_num && !batch_num){
  190. $('#pageLoader').hide();
  191. Swal.fire({
  192. icon: 'warning',
  193. title: 'For Search, Any One Is Required ',
  194. text: 'Please Enter required details',
  195. showConfirmButton: true,
  196. timer: 3000
  197. });
  198. e.preventDefault();
  199. return;
  200. }
  201. if(mobile_num){
  202. // Rule 1: Must be exactly 10 digits & must not start with 0
  203. if (!/^[1-9][0-9]{9}$/.test(mobile_num)) {
  204. $('#pageLoader').hide();
  205. Swal.fire({
  206. icon: 'warning',
  207. title: 'Invalid Mobile Number',
  208. text: 'Mobile number must be 10 digits and cannot start with 0.'
  209. });
  210. return;
  211. }
  212. // Rule 2: Reject sequential numbers like 1234567890
  213. if (mobile_num === "1234567890") {
  214. $('#pageLoader').hide();
  215. Swal.fire({
  216. icon: 'warning',
  217. title: 'Invalid Mobile Number',
  218. text: 'Sequential numbers like 1234567890 are not allowed.'
  219. });
  220. return;
  221. }
  222. // Rule 3: Reject all digits same (1111111111, 2222222222, etc.)
  223. if (/^(\d)\1{9}$/.test(mobile_num)) {
  224. $('#pageLoader').hide();
  225. Swal.fire({
  226. icon: 'warning',
  227. title: 'Invalid Mobile Number',
  228. text: 'All digits cannot be the same.'
  229. });
  230. return;
  231. }
  232. }
  233. $.ajax({
  234. type: "GET",
  235. url: `/election/api/updatepollperson/getbymobandslno`,
  236. data:{
  237. mobileNo:mobile_num,
  238. slNo:unique_num
  239. },
  240. contentType: "application/json",
  241. success: function (response) {
  242. console.log("API Response:", response);
  243. $('#pageLoader').hide();
  244. if (response.status === "success") {
  245. console.log("Details Array:", response.data);
  246. // Convert object → array
  247. let records = response.data || [];
  248. console.log("Table Records:", records);
  249. let table = $('#DetailsDatatable').DataTable({
  250. destroy: true,
  251. searching: true,
  252. autoWidth: true,
  253. paging: true,
  254. info: true,
  255. data: records,
  256. columns: [
  257. {
  258. data: null,
  259. render: (data, type, row, meta) => meta.row + 1,
  260. className: 'text-center'
  261. },
  262. { data: null,
  263. className: 'text-center' ,
  264. render: r => `${r.slno || '-'}`
  265. },
  266. { data: null,
  267. className: 'text-center width1' ,
  268. render: r => `
  269. ${r.name || '-'}<br>
  270. <small>
  271. ${r.pay_scale || '-'} /
  272. ${r.curr_basic }
  273. </small>`
  274. },
  275. { data: 'sex',className: 'text-center' },
  276. { data: 'designation',className: 'text-center' },
  277. { data: 'govt_type',className: 'text-center' },
  278. { data: 'r_mobile_no' ,className: 'text-center' },
  279. { data: 'res_address', className: 'text-center' },
  280. { data: null,
  281. className: 'text-center' ,
  282. render: r => `${r.native_ac_no || '-'} - ${r.native_assembly || '-'}`
  283. },
  284. { data: null,
  285. className: 'text-center' ,
  286. render: r => `${r.reside_ac_no || '-'} - ${r.res_assembly || '-'}`
  287. },
  288. { data: null,
  289. className: 'text-center' ,
  290. render: r => `${r.work_ac_no || '-'} - ${r.work_assembly || '-'}`
  291. },
  292. {
  293. data: null,
  294. className: 'text-center',
  295. render: {
  296. display: r => `
  297. Part: ${r.elector_part_no }<br>
  298. Sl: ${r.elector_sl_no }<br>
  299. ${r.epic_no }<br>
  300. ${r.elector_ac_no } - ${r.enrolled_assembly }
  301. `,
  302. export: r =>
  303. `Part: ${r.elector_part_no }\n` +
  304. `Sl: ${r.elector_sl_no }\n` +
  305. `${r.elector_epic_no }\n` +
  306. `${r.elector_ac_no } - ${r.enrolled_assembly }`
  307. }
  308. },
  309. {
  310. data: 'img_full_path',
  311. className: 'text-center',
  312. render: function (url, type, row) {
  313. if (!url) {
  314. return `<span style="color:red;">No Image</span>`;
  315. }
  316. return `
  317. <img src="${url}"
  318. style="height: 100px; width: 100px; object-fit: cover; border:1px solid #ccc;"
  319. alt="Photo">
  320. `;
  321. }
  322. },
  323. {
  324. data: null,
  325. className: 'text-center',
  326. render: function (data) {
  327. let slno=data.slno;
  328. return `
  329. <button class="btn btn-primary btn-sm"
  330. onclick="goToUpdateForm('${slno}')">
  331. Update
  332. </button>
  333. `;
  334. }
  335. }
  336. ],
  337. dom: 'Bfrtip',
  338. buttons: [
  339. {
  340. extend: 'pageLength',
  341. className: 'btn btn-warning'
  342. },
  343. {
  344. title: 'Data export',
  345. extend: 'copyHtml5',
  346. text: 'Copy',
  347. className: 'btn btn-secondary',
  348. id: 'copyBtn'
  349. },
  350. {
  351. extend: 'excelHtml5',
  352. text: 'Excel',
  353. className: 'btn btn-secondary',
  354. id: 'excelBtn',
  355. filename: function () {
  356. return 'polling_personnel_details_' + getTimestamp();
  357. }
  358. },
  359. {
  360. extend: 'csvHtml5',
  361. text: 'CSV',
  362. className: 'btn btn-secondary',
  363. id: 'csvBtn',
  364. filename: function () {
  365. return 'polling_personnel_details_' + getTimestamp();
  366. }
  367. },
  368. {
  369. extend: 'pdfHtml5',
  370. text: 'PDF',
  371. className: 'btn btn-secondary',
  372. id: 'pdfBtn',
  373. title:'Polling Personnel Details',
  374. filename: function () {
  375. return 'polling_personnel_details_' + getTimestamp();
  376. },
  377. orientation: 'landscape', // ⭐ important line
  378. pageSize: 'A4',
  379. customize: function (doc) {
  380. doc.pageOrientation = 'landscape';
  381. // Reduce page margins to use full width
  382. doc.pageMargins = [10, 10, 10, 10];
  383. // Reduce default font size so columns fit
  384. doc.defaultStyle.fontSize = 7;
  385. doc.styles.tableHeader.fontSize = 8;
  386. // ⭐ Force table to shrink inside page
  387. doc.content[1].table.widths = [
  388. 20, // S.No
  389. 30, // Unique/Batch
  390. 60, // Name / Pay Scale
  391. 20, // Sex
  392. 60, // Designation
  393. 30, // State / Central
  394. 100, // Office Address
  395. 50, // Mobile
  396. 90, // Residence Address
  397. 40, // Native
  398. 40, // Reside
  399. 40, // Work
  400. 70, // Enrolled
  401. 50, // Photo
  402. 30 // action
  403. ];
  404. // ⭐ Remove large default paddings
  405. var objLayout = {};
  406. objLayout['hLineWidth'] = function(i) { return 0.3; };
  407. objLayout['vLineWidth'] = function(i) { return 0.3; };
  408. objLayout['hLineColor'] = function(i) { return '#000'; };
  409. objLayout['vLineColor'] = function(i) { return '#000'; };
  410. objLayout['paddingLeft'] = function(i) { return 2; };
  411. objLayout['paddingRight'] = function(i) { return 2; };
  412. objLayout['paddingTop'] = function(i) { return 2; };
  413. objLayout['paddingBottom'] = function(i) { return 2; };
  414. doc.content[1].layout = objLayout;
  415. }
  416. }
  417. ],
  418. columnDefs: [
  419. { width: "150px", targets: 2},
  420. { width: "150px", targets: 6},
  421. { width: "120px", targets: 8},
  422. { width: "150px", targets: 12} ,
  423. { width: "150px", targets: 12}
  424. ],
  425. lengthMenu: [
  426. [50, 100, 200, 500, -1],
  427. ['50 rows', '100 rows', '200 rows', 'Show all']
  428. ],
  429. scrollY: '80vh',
  430. scrollX: true,
  431. responsive: false,
  432. searching: true
  433. });
  434. }
  435. else if (response.status === "no_data") {
  436. $('#pageLoader').hide();
  437. Swal.fire({
  438. icon: 'info',
  439. title: 'No Data',
  440. text: response.data || 'Something went wrong!'
  441. });
  442. }
  443. else if (response.status === "error") {
  444. $('#pageLoader').hide();
  445. Swal.fire({
  446. icon: 'error',
  447. title: 'Error',
  448. text: response.message || 'Something went wrong!'
  449. });
  450. }
  451. else {
  452. $('#pageLoader').hide();
  453. Swal.fire({
  454. icon: 'error',
  455. title: 'Error',
  456. text: response.message || 'Something went wrong!'
  457. });
  458. }
  459. },
  460. error: function (error) {
  461. $('#pageLoader').hide();
  462. Swal.fire({
  463. icon: 'error',
  464. title: 'Error',
  465. text: response.message || 'Something went wrong!'
  466. });
  467. }
  468. });
  469. });
  470. function goToUpdateForm(slno) {
  471. // Save values in sessionStorage
  472. sessionStorage.setItem("slno", slno);
  473. // Redirect to form page
  474. window.location.href = "/election/update_pollingperson/updateform";
  475. }
  476. </script>
  477. </body>
  478. </html>