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.

191 lines
6.1 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. #AttendanceDatatable td {
  6. vertical-align: middle !important;
  7. }
  8. #AttendanceDatatable td:last-child {
  9. text-align: center;
  10. }
  11. .mark-present,
  12. .mark-absent {
  13. width: 90px;
  14. }
  15. </style>
  16. </head>
  17. <body>
  18. <div class="wrapper">
  19. <!-- header top menu Start -->
  20. <header th:replace="~{fragments/modules/base/header :: header}"></header>
  21. <!-- header top menu end -->
  22. <div class="page-wrap">
  23. <!--=============== Left Menu side Start ================-->
  24. <div th:replace="~{fragments/modules/base/menu :: menu}"></div>
  25. <!--=============== Left side End ================-->
  26. <div class="main-content">
  27. <div class="container-fluid">
  28. <div class="row mt-1">
  29. <div class="col-md-12">
  30. <div class="card mt-2">
  31. <div class="card-header" style="font-weight: bold;">
  32. Form 12 Data
  33. </div>
  34. <div class="card-body d-flex align-items-end">
  35. <!-- SL No -->
  36. <div class="col-sm-3">
  37. <label for="slNoInput">Search by Unique No</label>
  38. <input type="text" id="slNoInput" class="form-control"
  39. placeholder="Enter Unique No">
  40. </div>
  41. <div class="col-md-1 col-sm-12 text-center pt-4">
  42. <span style="font-weight: bold;">OR</span>
  43. </div>
  44. <!-- Mobile Number -->
  45. <div class="col-sm-3">
  46. <label for="mobileInput">Search by Mobile No</label>
  47. <input type="text" id="mobileInput" class="form-control"
  48. placeholder="Enter Mobile Number" maxlength="10">
  49. </div>
  50. <!-- Button (hidden initially) -->
  51. <div class="col-sm-4 d-flex align-items-end">
  52. <button id="searchBtn" class="btn btn-success mr-2">
  53. Search
  54. </button>
  55. <button id="clearSearchBtn" class="btn btn-danger">
  56. Clear
  57. </button>
  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>
  80. $('#searchBtn').click(function () {
  81. let slNo = $('#slNoInput').val().trim();
  82. let mobileNo = $('#mobileInput').val().trim();
  83. // ✅ Validation
  84. if (slNo === '' && mobileNo === '') {
  85. Swal.fire('Missing Input', 'Please enter SL No or Mobile Number', 'warning');
  86. return;
  87. }
  88. if (slNo !== '' && mobileNo !== '') {
  89. Swal.fire('Invalid Input', 'Enter either SL No OR Mobile Number, not both', 'error');
  90. return;
  91. }
  92. let url = '/election/api/mobile/form12?';
  93. if (slNo !== '') {
  94. url += 'slNo=' + slNo;
  95. } else {
  96. url += 'mobile=' + mobileNo;
  97. }
  98. $('#pageLoader').show();
  99. fetch(url)
  100. .then(response => {
  101. if (response.status === 404) {
  102. throw new Error("No data found for given input");
  103. }
  104. if (response.status === 400) {
  105. throw new Error("Invalid input");
  106. }
  107. if (!response.ok) {
  108. throw new Error("Something went wrong");
  109. }
  110. return response.blob();
  111. })
  112. .then(blob => {
  113. let downloadUrl = window.URL.createObjectURL(blob);
  114. let a = document.createElement("a");
  115. a.href = downloadUrl;
  116. a.download = "Form12.pdf"; // you can make dynamic
  117. document.body.appendChild(a);
  118. a.click();
  119. a.remove();
  120. })
  121. .catch(err => {
  122. Swal.fire({
  123. icon: 'warning',
  124. title: 'No data',
  125. text: err.message,
  126. allowOutsideClick: false,
  127. allowEscapeKey:false,
  128. allowEnterKey:false
  129. });
  130. })
  131. .finally(() => {
  132. $('#pageLoader').hide();
  133. });
  134. });
  135. $('#clearSearchBtn').click(function () {
  136. // Clear input fields
  137. $('#slNoInput').val('');
  138. $('#mobileInput').val('');
  139. // Optional: hide loader if visible
  140. $('#pageLoader').hide();
  141. });
  142. </script>
  143. </body>
  144. </html>