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.

194 lines
6.4 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. Download Second Order Copy
  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. if (slNo === '' ) {
  83. Swal.fire('Missing Input', 'Please enter SL No ', 'warning');
  84. return;
  85. }
  86. let url = '/election/api/mobile/second-order?';
  87. if (slNo !== '') {
  88. url += 'slNo=' + slNo;
  89. }
  90. $('#pageLoader').show();
  91. fetch(url)
  92. .then(response => {
  93. if (response.status === 404) {
  94. throw new Error("No data found for given input");
  95. }
  96. if (response.status === 400) {
  97. throw new Error("Invalid input");
  98. }
  99. if (!response.ok) {
  100. throw new Error("Something went wrong");
  101. }
  102. // ✅ Extract filename BEFORE converting to blob
  103. const disposition = response.headers.get("Content-Disposition");
  104. let fileName = "SecondOrder.pdf";
  105. if (disposition && disposition.includes("filename=")) {
  106. fileName = disposition
  107. .split("filename=")[1]
  108. .replace(/"/g, "")
  109. .trim();
  110. }
  111. // ✅ Return BOTH blob + filename
  112. return response.blob().then(blob => ({ blob, fileName }));
  113. })
  114. .then(({ blob, fileName }) => {
  115. let downloadUrl = window.URL.createObjectURL(blob);
  116. let a = document.createElement("a");
  117. a.href = downloadUrl;
  118. a.download = fileName; // ✅ filename from backend
  119. document.body.appendChild(a);
  120. a.click();
  121. a.remove();
  122. window.URL.revokeObjectURL(downloadUrl); // ✅ cleanup
  123. })
  124. .catch(err => {
  125. Swal.fire({
  126. icon: 'warning',
  127. title: 'No data',
  128. text: err.message,
  129. allowOutsideClick: false,
  130. allowEscapeKey: false,
  131. allowEnterKey: false
  132. });
  133. })
  134. .finally(() => {
  135. $('#pageLoader').hide();
  136. });
  137. });
  138. $('#clearSearchBtn').click(function () {
  139. // Clear input fields
  140. $('#slNoInput').val('');
  141. //$('#mobileInput').val('');
  142. // Optional: hide loader if visible
  143. $('#pageLoader').hide();
  144. });
  145. </script>
  146. </body>
  147. </html>