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.

477 lines
18 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns:th="http://www.thymeleaf.org">
  3. <head th:replace="~{fragments/modules/base/head :: head}">
  4. </head>
  5. <style>
  6. </style>
  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="fa fa-list-alt bg-blue"></i>
  23. <div class="d-inline">
  24. <h5>Schools Reports</h5>
  25. </div>
  26. </div>
  27. </div>
  28. <div class="col-lg-4">
  29. <nav class="breadcrumb-container" aria-label="breadcrumb">
  30. <ol class="breadcrumb">
  31. <li class="breadcrumb-item"><a href="/gcc/index"><i
  32. class="ik ik-home"></i></a></li>
  33. <li class="breadcrumb-item" aria-current="page">school</li>
  34. <li class="breadcrumb-item active" aria-current="page">Reports</li>
  35. </ol>
  36. </nav>
  37. </div>
  38. </div>
  39. </div>
  40. <div class="row mt-4">
  41. <div class="col-12">
  42. <div class="card">
  43. <div class="card-header">
  44. <span style="font-size: medium;font-weight: bold;">Reports Filters</span>
  45. </div>
  46. <div class="card-body">
  47. <div class="row">
  48. <div class="col-sm-2 mb-2">
  49. <label for="aeodropdown" style="font-size: medium;">AEO:</label>
  50. <select id="aeodropdown" class="form-control">
  51. <option value="">Select</option>
  52. </select>
  53. </div>
  54. <div class="col-sm-2 mb-2">
  55. <label for="zonedropdown" style="font-size: medium;">Zone:</label>
  56. <select id="zonedropdown" class="form-control">
  57. <option value="">Select</option>
  58. </select>
  59. </div>
  60. <div class="col-sm-2 mb-2">
  61. <label for="warddropdown" style="font-size: medium;">Ward:</label>
  62. <select id="warddropdown" class="form-control">
  63. <option value="">Select</option>
  64. </select>
  65. </div>
  66. </div>
  67. <div class="row mt-4">
  68. <div class="col-12 d-flex justify-content-center">
  69. <button type="submit" id="searchBtn"
  70. class="btn btn-primary mx-2">Search</button>
  71. <button class="btn btn-danger mx-2" id="resetBtn"
  72. name="reset" type="reset">Reset</button>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. </div>
  79. <div class="row mt-4">
  80. <div class="col-md-12">
  81. <div class="card">
  82. <div class="card-header">
  83. <span style="font-size: medium;font-weight: bold;">Reports List</span>
  84. </div>
  85. <div class="card-body">
  86. <div class="table-responsive">
  87. <table id="ReportDatatable"
  88. class="table table-striped table-bordered table-hover dataTable"
  89. role="grid">
  90. <thead class="thead-dark">
  91. <tr role="row">
  92. <th class="text-center no-sort">S.No</th>
  93. <th class="text-center" style="width: 100px;">AEO</th>
  94. <th class="text-center">Zone</th>
  95. <th class="text-center">Ward</th>
  96. <th class="text-center">UDISE code</th>
  97. <th class="text-center">Other Details</th>
  98. <th class="text-center">Staff Details</th>
  99. <th class="text-center">Student Details</th>
  100. <th class="text-center">Buildings</th>
  101. <th class="text-center">Playground</th>
  102. <th class="text-center">Drinking Water</th>
  103. <th class="text-center">Toilets</th>
  104. <th class="text-center">School Assets</th>
  105. <th class="text-center">Kitchen</th>
  106. <th class="text-center">Overall status</th>
  107. </tr>
  108. </thead>
  109. <tbody>
  110. </tbody>
  111. </table>
  112. </div>
  113. </div>
  114. </div>
  115. </div>
  116. </div>
  117. </div>
  118. </div>
  119. <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;">
  120. <div style="position: relative; top: 50%; transform: translateY(-50%);">
  121. <div class="spinner-border text-primary" role="status" style="width: 3rem; height: 3rem;">
  122. <span class="sr-only">Loading...</span>
  123. </div>
  124. <!-- Add the 'Please wait' text below the spinner -->
  125. <p style="margin-top: 1rem; font-size: 1.2rem; color: #007bff;">Please wait...</p>
  126. </div>
  127. </div>
  128. <footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
  129. </div>
  130. </div>
  131. <script th:replace="~{fragments/modules/base/script :: script}"></script>
  132. <!-- sweet alert -->
  133. <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
  134. <script type="text/javascript">
  135. document.addEventListener("DOMContentLoaded", function () {
  136. fetchAEOSchoolData([], '', '');
  137. let aeoDropdown = document.getElementById('aeodropdown');
  138. let zoneDropdown = document.getElementById('zonedropdown');
  139. let wardDropdown = document.getElementById('warddropdown');
  140. fetch('/gcc/api/gccschool/report/getAEOList')
  141. .then(response => response.json())
  142. .then(data => {
  143. // Clear existing options
  144. aeoDropdown.innerHTML = `<option value="">Select</option>`;
  145. // Add options from the API response
  146. data.data.forEach(aeo => {
  147. aeoDropdown.innerHTML += `<option value="${aeo.udise}">${aeo.aeo_num}</option>`;
  148. });
  149. })
  150. .catch(error => {
  151. console.error('Error fetching in AEO List:', error);
  152. });
  153. aeoDropdown.addEventListener('change', function () {
  154. const selectedGroup = aeoDropdown.value;
  155. if (selectedGroup) {
  156. fetch(`/gcc/api/gccschool/report/getAEOZone?udise=${encodeURIComponent(selectedGroup)}`)
  157. .then(response => response.json())
  158. .then(data => {
  159. // Clear existing options
  160. zoneDropdown.innerHTML = `<option value="">Select</option>`;
  161. // Add options from the API response
  162. data.data.forEach(zone => {
  163. zoneDropdown.innerHTML += `<option value="${zone}">${zone}</option>`;
  164. });
  165. wardDropdown.innerHTML = `<option value="">Select</option>`;
  166. })
  167. .catch(error => {
  168. console.error('Error fetching zone for aeo:', error);
  169. });
  170. } else {
  171. zoneDropdown.innerHTML = `<option value="">Select</option>`;
  172. wardDropdown.innerHTML = `<option value="">Select</option>`;
  173. }
  174. });
  175. zoneDropdown.addEventListener('change', function () {
  176. const selectedAeo = aeoDropdown.value;
  177. const selectedZone= zoneDropdown.value;
  178. if (selectedAeo && selectedZone) {
  179. fetch(`/gcc/api/gccschool/report/getAEOWard?udise=${encodeURIComponent(selectedAeo)}&zone=${encodeURIComponent(selectedZone)}`)
  180. .then(response => response.json())
  181. .then(data => {
  182. // Clear existing options
  183. wardDropdown.innerHTML = `<option value="">Select</option>`;
  184. // Add options from the API response
  185. data.data.forEach(Ward => {
  186. wardDropdown.innerHTML += `<option value="${Ward}">${Ward}</option>`;
  187. });
  188. })
  189. .catch(error => {
  190. console.error('Error fetching ward for aeo:', error);
  191. });
  192. } else {
  193. wardDropdown.innerHTML = `<option value="">Select</option>`;
  194. }
  195. });
  196. });
  197. $(document).ready(function() {
  198. /* var table = $('#ReportDatatable').DataTable({
  199. dom: 'Bftip',
  200. columnDefs: [
  201. { targets: 'no-sort', orderable: false }
  202. ],
  203. lengthMenu: [
  204. [50, 100, 200, 500, -1],
  205. ['50 rows', '100 rows', '200 rows', 'Show all']
  206. ],
  207. scrollY: '80vh',
  208. scrollX: true,
  209. buttons: [
  210. {
  211. extend: 'pageLength',
  212. className: 'btn btn-warning'
  213. },
  214. {
  215. title: 'Data export',
  216. extend: 'copyHtml5',
  217. text: 'Copy',
  218. className: 'btn btn-secondary',
  219. id: 'copyBtn'
  220. },
  221. {
  222. extend: 'excelHtml5',
  223. text: 'Excel',
  224. className: 'btn btn-secondary',
  225. id: 'excelBtn'
  226. },
  227. {
  228. extend: 'csvHtml5',
  229. text: 'CSV',
  230. className: 'btn btn-secondary',
  231. id: 'csvBtn'
  232. },
  233. {
  234. extend: 'pdfHtml5',
  235. text: 'PDF',
  236. className: 'btn btn-secondary',
  237. id: 'pdfBtn'
  238. }
  239. ],
  240. fixedHeader: true,
  241. autoWidth: true,
  242. responsive: false,
  243. searching: true,
  244. select: false,
  245. processing: false
  246. }); */
  247. document.getElementById('resetBtn').addEventListener('click', function () {
  248. event.preventDefault();
  249. location.reload();
  250. });
  251. document.getElementById('searchBtn').addEventListener('click', function (e) {
  252. let aeoDropdown = document.getElementById('aeodropdown');
  253. let zoneDropdown = document.getElementById('zonedropdown');
  254. let wardDropdown = document.getElementById('warddropdown');
  255. // ✅ Extract selected values from a multi-select dropdown as an array
  256. let aeovalue = Array.from(aeoDropdown.selectedOptions).map(opt => opt.value);
  257. //let aeovalue =aeoDropdown.value;
  258. let zonevalue = zoneDropdown.value;
  259. let wardvalue = wardDropdown.value;
  260. console.log("aeovalue: ",aeovalue);
  261. console.log("zonevalue: ",zonevalue);
  262. console.log("wardvalue: ",wardvalue);
  263. if (!aeovalue || aeovalue.length === 0) {
  264. Swal.fire({
  265. icon: 'info',
  266. title: 'Info',
  267. text: 'Please Select AEO',
  268. showConfirmButton: true,
  269. timer: 3000
  270. });
  271. e.preventDefault();
  272. return;
  273. }
  274. fetchAEOSchoolData(aeovalue, zonevalue, wardvalue);
  275. });
  276. });
  277. function fetchAEOSchoolData(aeovalue, zonevalue, wardvalue)
  278. {
  279. const params = new URLSearchParams();
  280. aeovalue.forEach(val =>{ console.log("Appending udise:", val);
  281. params.append("udise", val)}); // Use 'udiseList' as repeated query parameter
  282. params.append("zone", zonevalue);
  283. params.append("ward", wardvalue);
  284. $('#pageLoader').show();
  285. $.ajax({
  286. type: "GET",
  287. url: `/gcc/api/gccschool/report/getAEOSchoolData?${params.toString()}`, // Append query string to URL
  288. contentType: "application/json",
  289. success: function (response) {
  290. console.log("API Response:", response);
  291. $('#pageLoader').hide();
  292. if (response.message === "Success") {
  293. console.log("Details Array:", response.data);
  294. // Ensure details is an array and has at least one entry
  295. if (Array.isArray(response.data) && response.data.length > 0) {
  296. let scrollHeight = response.data.length <= 50 ? 'auto' : '80vh';
  297. let table = $('#ReportDatatable').DataTable({
  298. destroy: true,
  299. searching: true,
  300. autoWidth: true,
  301. paging: true,
  302. info: true,
  303. data: response.data,
  304. columns: [
  305. {
  306. data: null,
  307. render: (data, type, row, meta) => meta.row + 1,
  308. className: 'text-center'
  309. },
  310. { data: 'aeo_num', defaultContent: '-', className: 'text-center' },
  311. { data: 'zone', defaultContent: '-', className: 'text-center' },
  312. { data: 'division', defaultContent: '-', className: 'text-center' },
  313. { data: 'udise', defaultContent: '-', className: 'text-center' },
  314. { data: 'other_details', defaultContent: '-', className: 'text-center' },
  315. { data: 'staff_details', defaultContent: '-', className: 'text-center' },
  316. { data: 'students_details', defaultContent: '-', className: 'text-center' },
  317. { data: 'buildings', defaultContent: '-', className: 'text-center' },
  318. { data: 'playground_details', defaultContent: '-', className: 'text-center' },
  319. { data: 'drinkingwater_details', defaultContent: '-', className: 'text-center' },
  320. { data: 'toilet_details', defaultContent: '-', className: 'text-center' },
  321. { data: 'school_assets', defaultContent: '-', className: 'text-center' },
  322. { data: 'kitchen_details', defaultContent: '-', className: 'text-center' },
  323. { data: 'overall_status', defaultContent: '-', className: 'text-center' }
  324. ],
  325. dom: 'Bfrtip',
  326. buttons: [
  327. {
  328. extend: 'pageLength',
  329. className: 'btn btn-warning'
  330. },
  331. {
  332. title: 'Data export',
  333. extend: 'copyHtml5',
  334. text: 'Copy',
  335. className: 'btn btn-secondary',
  336. id: 'copyBtn'
  337. },
  338. {
  339. extend: 'excelHtml5',
  340. text: 'Excel',
  341. className: 'btn btn-secondary',
  342. id: 'excelBtn'
  343. },
  344. {
  345. extend: 'csvHtml5',
  346. text: 'CSV',
  347. className: 'btn btn-secondary',
  348. id: 'csvBtn'
  349. },
  350. {
  351. extend: 'pdfHtml5',
  352. text: 'PDF',
  353. className: 'btn btn-secondary',
  354. id: 'pdfBtn'
  355. }
  356. ],
  357. columnDefs: [
  358. { targets: 'no-sort', orderable: false }
  359. ],
  360. lengthMenu: [
  361. [50, 100, 200, 500, -1],
  362. ['50 rows', '100 rows', '200 rows', 'Show all']
  363. ],
  364. scrollY: scrollHeight,
  365. scrollX: true,
  366. responsive: false,
  367. searching: true
  368. });
  369. }
  370. }
  371. else if (response.message === "NoData") {
  372. $('#pageLoader').hide();
  373. Swal.fire({
  374. icon: 'warning',
  375. title: response.data,
  376. text: 'No data available for the selected criteria.'
  377. });
  378. }
  379. else {
  380. $('#pageLoader').hide();
  381. Swal.fire({
  382. icon: 'error',
  383. title: 'Error',
  384. text: response.message || 'Something went wrong!'
  385. });
  386. }
  387. },
  388. error: function (error) {
  389. $('#pageLoader').hide();
  390. Swal.fire({
  391. icon: 'error',
  392. title: 'Error',
  393. text: response.message || 'Something went wrong!'
  394. });
  395. }
  396. });
  397. }
  398. </script>
  399. </body>
  400. </html>