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.

190 lines
6.6 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>Hall Allocation</h5>
  25. <span>Hall Allocation Process</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" style="margin-top: 15px;">
  34. <div class="card-body">
  35. <input type="hidden" id="loginUserId" th:value="${loginUserId}">
  36. <div class="form-group">
  37. <div class="row">
  38. <!-- Department -->
  39. <div class="col-sm-12 col-md-6">
  40. <label class="form-label" for="traininglist">Select traininglist
  41. <span class="text-danger">*</span>
  42. </label>
  43. <select class="form-control" id="traininglist" required>
  44. <option value=""> Select traininglist </option>
  45. </select>
  46. </div>
  47. <!-- Office Name -->
  48. </div>
  49. </div>
  50. <div class="form-group text-center">
  51. <button type="submit" class="btn btn-primary " id="createdBtn">Submit</button>
  52. <button type="reset" class="btn btn-secondary ml-2" id="resetBtn">Reset</button>
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. <div id="pageLoader"
  61. 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;">
  62. <div style="position: relative; top: 50%; transform: translateY(-50%);">
  63. <div class="spinner-border text-primary" role="status" style="width: 3rem; height: 3rem;">
  64. <span class="sr-only">Loading...</span>
  65. </div>
  66. <!-- Add the 'Please wait' text below the spinner -->
  67. <p style="margin-top: 1rem; font-size: 1.2rem; color: #007bff;">Please wait...</p>
  68. </div>
  69. </div>
  70. <div th:replace="~{fragments/modules/base/app_module_menu_box :: div}"></div>
  71. <footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
  72. </div>
  73. </div>
  74. <script th:replace="~{fragments/modules/base/script :: script}"></script>
  75. <script type="text/javascript">
  76. // ✅ Reset Button
  77. document.getElementById('resetBtn').addEventListener('click', function (e) {
  78. e.preventDefault();
  79. location.reload();
  80. });
  81. $(document).ready(function () {
  82. // load training list
  83. $.ajax({
  84. url: "/election/api/checkAvailability",
  85. method: "GET",
  86. success: function (response) {
  87. let traininglist = $("#traininglist");
  88. traininglist.empty().append('<option value="">-- Select Training --</option>');
  89. if (response.status !== "success" || !response.data || response.data.length === 0) {
  90. return;
  91. }
  92. response.data.forEach(training => {
  93. traininglist.append(`
  94. <option
  95. value="${training.id}"
  96. data-allocation-url="${training.allocation_url || ''}">
  97. ${training.training_name}
  98. </option>
  99. `);
  100. });
  101. },
  102. error: function () {
  103. Swal.fire("Error", "Failed to load training list", "error");
  104. }
  105. });
  106. });
  107. // ✅ Create Batch
  108. $("#createdBtn").click(function (e) {
  109. e.preventDefault();
  110. const selectedOption = $("#traininglist option:selected");
  111. const allocationUrl = selectedOption.data("allocation-url");
  112. if (!allocationUrl) {
  113. Swal.fire(
  114. "Validation Error",
  115. "Selected training does not have an allocation URL.",
  116. "warning"
  117. );
  118. return;
  119. }
  120. // Show loader
  121. $("#pageLoader").show();
  122. // ✅ Call selected allocation URL
  123. $.ajax({
  124. url: allocationUrl,
  125. type: "POST",
  126. success: function (response) {
  127. $("#pageLoader").hide();
  128. Swal.fire("Success", "Hall Allocation Process completed successfully.", "success");
  129. },
  130. error: function (xhr) {
  131. $("#pageLoader").hide();
  132. Swal.fire("Error", "Failed to process hall allocation.", "error");
  133. }
  134. });
  135. });
  136. </script>
  137. </body>
  138. </html>