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.

981 lines
33 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html lang="en" dir="ltr">
  3. <html xmlns:th="http://www.thymeleaf.org">
  4. <head th:replace="~{fragments/modules/base/head :: head}"></head>
  5. <style>
  6. body {
  7. background-color: #f8f9fa;
  8. /* font-family: Arial, sans-serif;*/
  9. }
  10. .header {
  11. font-size: 22px;
  12. font-weight: bold;
  13. margin-bottom: 20px;
  14. }
  15. .table {
  16. border: 1px solid #dee2e6;
  17. }
  18. .table th,
  19. .table td {
  20. border: 1px solid #dee2e6;
  21. padding: 10px;
  22. }
  23. .section-title {
  24. font-size: 18px;
  25. font-weight: bold;
  26. margin-top: 20px;
  27. border-bottom: 2px solid #007bff;
  28. padding-bottom: 5px;
  29. }
  30. .form-group {
  31. margin-top: 15px;
  32. }
  33. .radio-group {
  34. display: flex;
  35. gap: 20px;
  36. margin-top: 10px;
  37. }
  38. </style>
  39. <body>
  40. <div class="wrapper">
  41. <header th:replace="~{fragments/modules/base/header :: header}"></header>
  42. <div class="page-wrap">
  43. <div th:replace="~{fragments/modules/base/menu :: menu}"></div>
  44. <div class="main-content">
  45. <div class="container">
  46. <div class="header">School Module - Master Details</div>
  47. <hr style="border: 1px solid #ccc; margin-top: 10px; margin-bottom: 20px;">
  48. <!-- Card 1: School Information -->
  49. <div class="col-md-12">
  50. <div class="card">
  51. <div class="card-header" style="background-color: #404E67; color: white;">
  52. School Information
  53. </div>
  54. <table class="table" id="schoolInfoTable" >
  55. <!-- Table rows will be dynamically injected -->
  56. </table>
  57. </div>
  58. </div>
  59. <ul class="nav nav-tabs" id="myTab" role="tablist">
  60. <li class="nav-item"><a class="nav-link active" id="otherDetailsTab" href="#">Other Details</a>
  61. </li>
  62. <li class="nav-item"><a class="nav-link" id="staffDetailsTab" data-toggle="tab"
  63. href="/gcc/school/staffdetails" role="tab" aria-controls="staffdetails"
  64. aria-selected="false">Staff
  65. Details</a></li>
  66. <li class="nav-item"><a class="nav-link" id="staffDetailsTab" data-toggle="tab"
  67. href="/gcc/school/studentdetails" role="tab" aria-controls="staffdetails"
  68. aria-selected="false">Student
  69. Details</a></li>
  70. <li class="nav-item" role="presentation"><a class="nav-link" id="buildingDetailstab"
  71. href="#">Buildings</a></li>
  72. <li class="nav-item" role="presentation"><a class="nav-link" id="playgroundDetailstab"
  73. data-toggle="tab" href="/gcc/school/playground" role="tab" aria-controls="playground"
  74. aria-selected="false">Playground</a></li>
  75. <li class="nav-item" role="presentation"><a class="nav-link" id="drinkingwaterDetailstab"
  76. data-toggle="tab" href="/gcc/school/drinkingwater" role="tab"
  77. aria-controls="drinkingwater" aria-selected="false">Drinking
  78. Water</a></li>
  79. <li class="nav-item" role="presentation"><a class="nav-link" id="tioletsDetailstab"
  80. data-toggle="tab" href="/gcc/school/toilets" role="tab" aria-controls="tiolets"
  81. aria-selected="false">Toilets</a></li>
  82. <li class="nav-item" role="presentation"><a class="nav-link" id="itassestsDetailstab"
  83. href="#">School Assets</a></li>
  84. </li>
  85. <li class="nav-item" role="presentation"><a class="nav-link" id="kitchenDetailstab"
  86. data-toggle="tab" href="/gcc/school/kitchen" role="tab" aria-controls="kitchen"
  87. aria-selected="false">Kitchen</a></li>
  88. </ul>
  89. <div id="itassestsDetailsSection" style="display: none;">
  90. <ul class="nav nav-tabs" id="itAssetsSubTabs">
  91. <li class="nav-item"><a class="nav-link active" id="RoomAssetTab"
  92. data-url="/gcc/school/roomassets" href="#">Rooms Assets Mapping</a></li>
  93. <li class="nav-item"><a class="nav-link" id="AssetManageTab"
  94. data-url="/gcc/school/assetmanagement" href="#">IT Asset Management</a></li>
  95. <li class="nav-item"><a class="nav-link" id="AddElectricalAssetTab"
  96. data-url="/gcc/school/addelectricalasset" href="#">Electrical Asset Management</a></li>
  97. <li class="nav-item"><a class="nav-link" id="AddFurnitureAssetTab"
  98. data-url="/gcc/school/addfurnitureasset" href="#">Furniture Asset Management</a></li>
  99. </ul>
  100. <div id="itAssetsContent"></div>
  101. </div>
  102. <!-- This section should be initially hidden -->
  103. <div id="buildingDetailsSection" style="display: none;">
  104. <!-- Place for sub-tabs -->
  105. <ul id="buildingSubTabs" class="nav nav-tabs">
  106. <li class="nav-item">
  107. <a class="nav-link active" id="buildingListTab" data-url="/gcc/school/building"
  108. href="#">Building List</a>
  109. </li>
  110. <li class="nav-item">
  111. <a class="nav-link" id="roomListTab" data-url="/gcc/school/room" href="#">Room List</a>
  112. </li>
  113. </ul>
  114. <!-- Content loaded by tab click -->
  115. <div id="buildingContent"></div>
  116. </div>
  117. <div id="staffDetailsSection" style="display: none;">Loading
  118. staff details...</div>
  119. <div id="playgroundDetailsSection" style="display: none;">
  120. Loading playground details...</div>
  121. <div id="drinkingwaterDetailsSection" style="display: none;">
  122. Loading drinking water details...</div>
  123. <div id="toiletsDetailsSection" style="display: none;">
  124. Loading toilets details...</div>
  125. <div id="itassestsDetailsSection" style="display: none;">
  126. Loading IT assets details...</div>
  127. <div id="kitchenDetailsSection" style="display: none;">
  128. Loading kitchen details...</div>
  129. <!-- Single Card Wrapper -->
  130. <div class="col-md-12" id="otherDetailsSection" style="display: none;">
  131. <div class="card" style="padding: 18px; margin-top: 27px;">
  132. <div class="card-header">
  133. <b>Site & Built Up Area</b>
  134. </div>
  135. <!-- Read-Only View -->
  136. <div id="otherDetailsReadOnlyView" style="display: none; text-align: center;">
  137. <br>
  138. <div style="display: inline-block; width: 100%; max-width: 900px; text-align: left;">
  139. <table class="table table-bordered">
  140. <tbody>
  141. <tr>
  142. <td><b> Site Area (Acre)</b></td>
  143. <td id="ro_land_area"></td>
  144. <td><b> Built-up Area (Sq. ft)</b></td>
  145. <td id="ro_buildup_area"></td>
  146. </tr>
  147. <tr>
  148. <td><b>Compound Wall</b></td>
  149. <td id="ro_compoundWall"></td>
  150. <td><b>Name Board</b></td>
  151. <td id="ro_nameBoard"></td>
  152. </tr>
  153. <tr>
  154. <td><b>PA System</b></td>
  155. <td id="ro_paSystem"></td>
  156. <td><b>Electric Bell</b></td>
  157. <td id="ro_electricBell"></td>
  158. </tr>
  159. <tr>
  160. <td><b>Generator Set</b></td>
  161. <td id="ro_generatorSet"></td>
  162. <td colspan="2"></td>
  163. </tr>
  164. </tbody>
  165. </table>
  166. <div class="text-center">
  167. <button type="button" class="btn btn-primary"
  168. id="updateOtherDetailsBtn">Update</button>
  169. </div>
  170. </div>
  171. </div>
  172. <!-- Form View -->
  173. <div id="otherDetailsSectionform" style="display: none;">
  174. <form id="schoolDetailsForm">
  175. <div class="row" style="padding: 15px;">
  176. <div class="col-md-6 form-group">
  177. <label>Approx Site Area of the School (In Acre) *</label>
  178. <input type="text" id="land_area" class="form-control"
  179. placeholder="Enter in Acre" required />
  180. </div>
  181. <div class="col-md-6 form-group">
  182. <label> Approx Built Up Area of the School (In Sq. ft) *</label>
  183. <input type="text" id="buildup_area" class="form-control"
  184. placeholder="Enter in Sq. ft" required />
  185. </div>
  186. </div>
  187. <div class="card-header"><b>Compound & Name Board</b></div>
  188. <div class="row" style="padding: 15px;">
  189. <div class="col-md-6 form-group">
  190. <label>Presence of Compound Wall *</label>
  191. <div class="radio-group">
  192. <input type="radio" name="compoundWall" value="Yes"> Yes
  193. <input type="radio" name="compoundWall" value="No"> No
  194. </div>
  195. </div>
  196. <div class="col-md-6 form-group">
  197. <label>Presence of School Name Board (New Board) *</label>
  198. <div class="radio-group">
  199. <input type="radio" name="nameBoard" value="Yes"> Yes
  200. <input type="radio" name="nameBoard" value="No"> No
  201. </div>
  202. </div>
  203. </div>
  204. <div class="card-header"><b>Electrical</b></div>
  205. <div class="row" style="padding: 15px;">
  206. <div class="col-md-4 form-group">
  207. <label>Is PA System Available? *</label>
  208. <div class="radio-group">
  209. <input type="radio" name="paSystem" value="Yes"> Yes
  210. <input type="radio" name="paSystem" value="No"> No
  211. </div>
  212. </div>
  213. <div class="col-md-4 form-group">
  214. <label>Is Electric Bell Available? *</label>
  215. <div class="radio-group">
  216. <input type="radio" name="electricBell" value="Yes"> Yes
  217. <input type="radio" name="electricBell" value="No"> No
  218. </div>
  219. </div>
  220. <div class="col-md-4 form-group">
  221. <label>Is Generator Set Available? *</label>
  222. <div class="radio-group">
  223. <input type="radio" name="generatorSet" value="Yes"> Yes
  224. <input type="radio" name="generatorSet" value="No"> No
  225. </div>
  226. </div>
  227. </div>
  228. <div class="card-footer text-center">
  229. <button type="submit" class="btn btn-primary" id="requestSubmitBtn"><i
  230. class="ik ik-save"></i> Submit</button>
  231. <button type="reset" class="btn btn-secondary mr-2" id="resetButton"><i
  232. class="ik ik-refresh-cw"></i> Reset</button>
  233. </div>
  234. </form>
  235. </div>
  236. </div>
  237. </div>
  238. </div>
  239. </div>
  240. <footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
  241. </div>
  242. <!-- Form -->
  243. <!-- Modal -->
  244. <div class="modal fade" id="otherDetailsModal" tabindex="-1" data-bs-backdrop="static" data-bs-keyboard="false" aria-labelledby="otherDetailsModalLabel"
  245. aria-hidden="true" >
  246. <div class="modal-dialog modal-lg">
  247. <div class="modal-content">
  248. <div class="modal-header">
  249. <h5 class="modal-title" id="otherDetailsModalLabel">Update Other
  250. Details</h5>
  251. <button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
  252. <span aria-hidden="true">&times;</span>
  253. </button>
  254. </div>
  255. <div class="modal-body">
  256. <div id="otherDetailsFormWrapper">
  257. <form id="updateOtherDetailsForm">
  258. <div class="row mb-3">
  259. <div class="col-md-6">
  260. <label> Approx Site Area of the School (In Acre) *</label>
  261. <input type="text" id="modal_land_area" class="form-control"
  262. placeholder="Enter in Acres" required />
  263. </div>
  264. <div class="col-md-6">
  265. <label> Approx Built Up Area of the School (In Sq. ft)
  266. *</label>
  267. <input type="text" id="modal_buildup_area" class="form-control"
  268. placeholder="Enter in Sq. ft" required />
  269. </div>
  270. </div>
  271. <div class="row mb-3">
  272. <div class="col-md-6">
  273. <label>Presence of Compound Wall *</label>
  274. <div>
  275. <input type="radio" name="modalcompoundWall" value="1"> Yes
  276. <input type="radio" name="modalcompoundWall" value="0"> No
  277. </div>
  278. </div>
  279. <div class="col-md-6">
  280. <label>Presence of School Name Board (New Board)* </label>
  281. <div>
  282. <input type="radio" name="modalnameBoard" value="1"> Yes
  283. <input type="radio" name="modalnameBoard" value="0">
  284. No
  285. </div>
  286. </div>
  287. </div>
  288. <div class="row mb-3">
  289. <div class="col-md-4">
  290. <label>Is PA System Available? *</label>
  291. <div>
  292. <input type="radio" name="modalpaSystem" value="1">
  293. Yes
  294. <input type="radio" name="modalpaSystem" value="0">
  295. No
  296. </div>
  297. </div>
  298. <div class="col-md-4">
  299. <label>Is Electric Bell Available? *</label>
  300. <div>
  301. <input type="radio" name="modalelectricBell" value="1"> Yes
  302. <input type="radio" name="modalelectricBell" value="0"> No
  303. </div>
  304. </div>
  305. <div class="col-md-4">
  306. <label>Is Generator Set Available? *</label>
  307. <div>
  308. <input type="radio" name="modalgeneratorSet" value="1"> Yes
  309. <input type="radio" name="modalgeneratorSet" value="0"> No
  310. </div>
  311. </div>
  312. </div>
  313. <div class="text-center">
  314. <button type="submit" class="btn btn-primary" id="requestSubmitBtn">Submit</button>
  315. <!--<button type="reset" class="btn btn-secondary btn-gap"
  316. id="resetButton">Reset</button>-->
  317. </div>
  318. </form>
  319. </div>
  320. </div>
  321. </div>
  322. </div>
  323. </div>
  324. <script th:replace="~{fragments/modules/base/script :: script}"></script>
  325. <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
  326. <script>
  327. // jQuery or vanilla JS to open the modal
  328. $(document).on('click', '#updateOtherDetailsBtn', function () {
  329. $('#otherDetailsModal').modal('show');
  330. });
  331. const urlParams = new URLSearchParams(window.location.search);
  332. const schoolId = urlParams.get("schoolId");
  333. $(document).ready(function () {
  334. /* const urlParams = new URLSearchParams(window.location.search);
  335. const schoolId = urlParams.get("schoolId"); */
  336. $.ajax({
  337. type: 'GET',
  338. url: '/gcc/api/gccschool/schoolproperty/getSchoolDetails',
  339. data: {schoolId: schoolId},
  340. success: function (data) {
  341. console.log(data);
  342. const html = `
  343. <tr><th>School Name:</th><td>${data.school_name}</td><th>UDISE Code:</th><td>${data.udise}</td></tr>
  344. <tr><th>Category:</th><td>${data.category}</td><th>Ward:</th><td>${data.division}</td></tr>
  345. <tr></td><th>Zone:</th><td>${data.zone}</td>
  346. <th>Address:</th><td>${data.address}</td></tr>
  347. `;
  348. $('#schoolInfoTable').html(html);
  349. }
  350. });
  351. $('.nav-link').click(function (e) {
  352. e.preventDefault();
  353. let url = $(this).attr(
  354. 'href');
  355. let targetId = $(this)
  356. .attr('id');
  357. // Hide all sections
  358. $(
  359. '#otherDetailsSection, #staffDetailsSection, #buildingDetailsSection, #playgroundDetailsSection, #drinkingwaterDetailsSection, #toiletsDetailsSection, #itassestsDetailsSection, #kitchenDetailsSection')
  360. .hide();
  361. // Remove active class from all nav links
  362. $('.nav-link').removeClass(
  363. 'active');
  364. $(this).addClass('active');
  365. // Handle Section Display and Load Data
  366. switch (targetId) {
  367. case 'otherDetailsTab':
  368. $('#otherDetailsSection').show();
  369. $('#schoolDetailsForm')[0].reset();
  370. break;
  371. case 'staffDetailsTab':
  372. $(
  373. '#staffDetailsSection')
  374. .show();
  375. loadData(url,
  376. '#staffDetailsSection');
  377. break;
  378. case 'buildingDetailstab':
  379. $('#buildingDetailsSection').show();
  380. // Set Building List as default
  381. $('#buildingListTab').addClass('active');
  382. $('#roomListTab').removeClass('active');
  383. // Load Building List content
  384. $('#buildingContent').html('<p>Loading Building List...</p>');
  385. loadData('/gcc/school/building', '#buildingContent');
  386. break;
  387. case 'roomListTab':
  388. $('#buildingDetailsSection').show();
  389. // Reset sub-tab states
  390. $('#buildingListTab').removeClass('active');
  391. $('#roomListTab').addClass('active');
  392. // Load Building List by default
  393. $('#buildingContent').html('<p>Loading Room List...</p>');
  394. loadData('/gcc/school/room', '#buildingContent');
  395. break;
  396. case 'playgroundDetailstab':
  397. $(
  398. '#playgroundDetailsSection')
  399. .show();
  400. loadData(url,
  401. '#playgroundDetailsSection');
  402. break;
  403. case 'drinkingwaterDetailstab':
  404. $(
  405. '#drinkingwaterDetailsSection')
  406. .show();
  407. loadData(url,
  408. '#drinkingwaterDetailsSection');
  409. break;
  410. case 'tioletsDetailstab':
  411. $(
  412. '#toiletsDetailsSection')
  413. .show();
  414. loadData(url,
  415. '#toiletsDetailsSection');
  416. break;
  417. case 'kitchenDetailstab':
  418. $(
  419. '#kitchenDetailsSection')
  420. .show();
  421. loadData(url,
  422. '#kitchenDetailsSection');
  423. break;
  424. case 'itassestsDetailstab':
  425. $('#itassestsDetailsSection').show();
  426. // Set Building List as default
  427. $('#RoomAssetTab').addClass('active');
  428. $('#AssetManageTab').removeClass('active');
  429. $('#AddElectricalAssetTab').removeClass('active');
  430. $('#AddFurnitureAssetTab').removeClass('active');
  431. // Load Building List content
  432. $('#itAssetsContent').html('<p>Loading Asset Room List...</p>');
  433. loadData('/gcc/school/roomassets', '#itAssetsContent');
  434. break;
  435. case 'AssetManageTab':
  436. $('#itassestsDetailsSection').show();
  437. // Reset sub-tab states
  438. $('#AssetManageTab').addClass('active');
  439. $('#RoomAssetTab').removeClass('active');
  440. $('#AddElectricalAssetTab').removeClass('active');
  441. $('#AddFurnitureAssetTab').removeClass('active');
  442. // Load Building List by default
  443. $('#itAssetsContent').html('<p>Loading Asset List...</p>');
  444. loadData('/gcc/school/assetmanagement', '#itAssetsContent');
  445. break;
  446. case 'AddElectricalAssetTab':
  447. $('#itassestsDetailsSection').show();
  448. // Reset sub-tab states
  449. $('#AssetManageTab').removeClass('active');
  450. $('#RoomAssetTab').removeClass('active');
  451. $('#AddElectricalAssetTab').addClass('active');
  452. $('#AddFurnitureAssetTab').removeClass('active');
  453. // Load Building List by default
  454. $('#itAssetsContent').html('<p>Loading Add Electrical Asset content...</p>');
  455. loadData('/gcc/school/addelectricalasset', '#itAssetsContent');
  456. break;
  457. case 'AddFurnitureAssetTab':
  458. $('#itassestsDetailsSection').show();
  459. // Reset sub-tab states
  460. $('#AssetManageTab').removeClass('active');
  461. $('#RoomAssetTab').removeClass('active');
  462. $('#AddElectricalAssetTab').removeClass('active');
  463. $('#AddFurnitureAssetTab').addClass('active');
  464. // Load Building List by default
  465. $('#itAssetsContent').html('<p>Loading Add Furniture Asset content...</p>');
  466. loadData('/gcc/school/addfurnitureasset', '#itAssetsContent');
  467. break;
  468. }
  469. });
  470. // Handle IT Assets Sub-tabs Click
  471. /*$('#itAssetsSubTabs').on('click', '.nav-link', function (e) {
  472. e.preventDefault();
  473. let url = $(this).attr('href');
  474. $('#itAssetsSubTabs .nav-link').removeClass('active');
  475. $(this).addClass('active');
  476. // Ensure #itAssetsContent is cleared before loading
  477. $('#itAssetsContent').html('<p>Loading...</p>');
  478. $.get(url, function (data) {
  479. $('#itAssetsContent').html(data);
  480. }).fail(function () {
  481. $('#itAssetsContent').html('<p>Error loading data. Please try again later.</p>');
  482. });
  483. });*/
  484. // Click event for Room List Tab
  485. /* $(document).on('click', '#roomListTab', function (e) {
  486. e.preventDefault();
  487. // Show the main building section
  488. $('#buildingDetailsSection').show();
  489. // Set active tab
  490. $('#roomListTab').addClass('active');
  491. $('#buildingListTab').removeClass('active');
  492. // Load Room List content
  493. $('#buildingContent').html('<p>Loading Room List...</p>');
  494. loadData('/gcc/school/room', '#buildingContent');
  495. }); */
  496. // Click event for Building List Tab
  497. $(document).on('click', '#buildingListTab', function (e) {
  498. e.preventDefault();
  499. // Show the main building section
  500. $('#buildingDetailsSection').show();
  501. // Set active tab
  502. $('#buildingListTab').addClass('active');
  503. $('#roomListTab').removeClass('active');
  504. // Load Building List content
  505. $('#buildingContent').html('<p>Loading Building List...</p>');
  506. loadData('/gcc/school/building', '#buildingContent');
  507. });
  508. $(document).on('click', '#RoomAssetTab', function (e) {
  509. e.preventDefault();
  510. // Show the main building section
  511. $('#itassestsDetailsSection').show();
  512. // Set active tab
  513. $('#RoomAssetTab').addClass('active');
  514. $('#AssetManageTab').removeClass('active');
  515. // Load Building List content
  516. $('#itAssetsContent').html('<p>Loading Asset Room List...</p>');
  517. loadData('/gcc/school/roomassets', '#itAssetsContent');
  518. });
  519. // 🔁 Delegate Click Event for Building Sub-tabs
  520. /* $(document).on('click', '#buildingSubTabs .nav-link', function (e) {
  521. e.preventDefault();
  522. // Remove active class from all sub-tabs
  523. $('#buildingSubTabs .nav-link').removeClass('active');
  524. $(this).addClass('active');
  525. // Get the correct API URL from `data-url`
  526. let contentUrl = $(this).data('url');
  527. // Load content dynamically
  528. if (contentUrl) {
  529. $('#buildingContent').html('<p>Loading...</p>');
  530. $.get(contentUrl, function (data) {
  531. $('#buildingContent').html(data);
  532. }).fail(function () {
  533. $('#buildingContent').html('<p>Error loading data. Please try again later.</p>');
  534. });
  535. }
  536. });*/
  537. });
  538. // Function to load data via AJAX
  539. function loadData(url, sectionId) {
  540. $.get(url, function (data) {
  541. $(sectionId).html(data);
  542. }).fail(function () {
  543. $(sectionId).html('<p>Error loading data. Please try again later.</p>');
  544. });
  545. }
  546. document.getElementById('buildup_area').addEventListener('input', function () {
  547. // Allow only whole numbers (no decimals)
  548. this.value = this.value.replace(/[^0-9]/g, '');
  549. // Prevent negative values
  550. if (parseInt(this.value) < 0) {
  551. this.value = '';
  552. }
  553. });
  554. document.getElementById('modal_buildup_area').addEventListener('input', function () {
  555. // Allow only whole numbers (no decimals)
  556. this.value = this.value.replace(/[^0-9]/g, '');
  557. // Prevent negative values
  558. if (parseInt(this.value) < 0) {
  559. this.value = '';
  560. }
  561. });
  562. document.getElementById('land_area').addEventListener('input', function () {
  563. // Remove any non-numeric characters except decimal point
  564. this.value = this.value.replace(/[^0-9.]/g, '');
  565. // Ensure the value is nfot negative
  566. if (this.value < 0) {
  567. this.value = '';
  568. }
  569. });
  570. document.getElementById('modal_land_area').addEventListener('input', function () {
  571. // Remove any non-numeric characters except decimal point
  572. this.value = this.value.replace(/[^0-9.]/g, '');
  573. // Ensure the value is nfot negative
  574. if (this.value < 0) {
  575. this.value = '';
  576. }
  577. });
  578. $('#requestSubmitBtn').on('click', function (e) {
  579. e.preventDefault();
  580. let landArea = $('#land_area').val().trim();
  581. let buildupArea = $('#buildup_area').val().trim();
  582. let isCompound = $('input[name="compoundWall"]:checked').val();
  583. let isNameboard = $('input[name="nameBoard"]:checked').val();
  584. let isPasystem = $('input[name="paSystem"]:checked').val();
  585. let isBell = $('input[name="electricBell"]:checked').val();
  586. let isGenerator = $('input[name="generatorSet"]:checked').val();
  587. //let schoolId = 1; // hardcoded
  588. // Field validation
  589. if (isNaN(parseFloat(landArea)) || landArea <= 0 ) {
  590. Swal.fire({
  591. icon: 'info',
  592. title: 'Validation Error',
  593. text: 'Site Area numbers greater than 0.',
  594. allowOutsideClick: false,
  595. allowEscapeKey: false,
  596. allowEnterKey: false,
  597. confirmButtonText: 'OK'
  598. });
  599. return;
  600. }
  601. if ( isNaN(parseFloat(buildupArea)) || buildupArea < 50) {
  602. Swal.fire({
  603. icon: 'info',
  604. title: 'Validation Error',
  605. text: ' Built-up Area must be numbers greater than 50.',
  606. allowOutsideClick: false,
  607. allowEscapeKey: false,
  608. allowEnterKey: false,
  609. confirmButtonText: 'OK'
  610. });
  611. return;
  612. }
  613. let fields = {
  614. "Site Area of the School": landArea,
  615. "Built Up Area of the School": buildupArea,
  616. "Compound Wall": isCompound,
  617. "School Name Board": isNameboard,
  618. "PA System": isPasystem,
  619. "Electric Bell": isBell,
  620. "Generator Set": isGenerator
  621. };
  622. for (let key in fields) {
  623. if (!fields[key] || fields[key] === "") {
  624. Swal.fire({
  625. icon: 'info',
  626. title: 'Validation Error',
  627. text: `Please enter/select: ${key}`,
  628. allowOutsideClick: false,
  629. allowEscapeKey: false,
  630. allowEnterKey: false,
  631. confirmButtonText: 'OK'
  632. });
  633. return;
  634. }
  635. }
  636. // Check numeric fields
  637. // Show loader
  638. $('#pageLoader').show();
  639. // Prepare form data
  640. let formData = {
  641. land_area: parseFloat(landArea),
  642. buildup_area: parseFloat(buildupArea),
  643. is_compound: isCompound ,
  644. is_nameboard: isNameboard,
  645. is_pasystem: isPasystem,
  646. is_bell: isBell,
  647. is_generator: isGenerator,
  648. school_id: schoolId
  649. };
  650. // AJAX call
  651. $.ajax({
  652. type: 'POST',
  653. url: '/gcc/api/gccschool/schoolproperty/saveSchoolBuildupArea',
  654. data: $.param(formData), // Serialize object to x-www-form-urlencoded
  655. success: function (data) {
  656. $('#pageLoader').hide();
  657. Swal.fire({
  658. title: 'Success!',
  659. text: 'School Build-up Area data saved successfully!',
  660. icon: 'success',
  661. allowOutsideClick: false,
  662. allowEscapeKey: false,
  663. allowEnterKey: false,
  664. confirmButtonText: 'OK'
  665. }).then(() => {
  666. window.location.reload();
  667. });
  668. },
  669. error: function (xhr, status, error) {
  670. console.error('AJAX Error:', error);
  671. $('#pageLoader').hide();
  672. Swal.fire({
  673. title: 'Error!',
  674. text: 'Something went wrong while saving the data.',
  675. icon: 'error',
  676. allowOutsideClick: false,
  677. allowEscapeKey: false,
  678. allowEnterKey: false,
  679. confirmButtonText: 'OK'
  680. });
  681. }
  682. });
  683. });
  684. /* document.getElementById("resetButton").addEventListener("click", function (event) {
  685. event.preventDefault(); // Prevent default reset behavior (which might refresh or reset other logic)
  686. // Clear all input fields (text)
  687. document.querySelectorAll('input[type="text"]').forEach(input => input.value = "");
  688. // Uncheck all radio buttons
  689. document.querySelectorAll('input[type="radio"]').forEach(radio => radio.checked = false);
  690. });*/
  691. $(document).ready(function () {
  692. $.ajax({
  693. url: '/gcc/api/gccschool/buildingasset/getotherdetailsBySchoolId',
  694. type: 'GET',
  695. data: {schoolId},
  696. success: function (response) {
  697. if (response.status === 'OK' && response.otherdetailsBySchool.length > 0) {
  698. const data = response.otherdetailsBySchool[0];
  699. const hasValidData =
  700. !!data.land_area ||
  701. !!data.buildup_area ||
  702. data.is_compound !== null ||
  703. data.is_nameboard !== null ||
  704. data.is_pasystem !== null ||
  705. data.is_bell !== null ||
  706. data.is_generator !== null;
  707. if (hasValidData) {
  708. // Fill read-only
  709. $('#ro_land_area').text(data.land_area || '');
  710. $('#ro_buildup_area').text(data.buildup_area || '');
  711. $('#ro_compoundWall').text(data.is_compound ? 'Yes' : 'No');
  712. $('#ro_nameBoard').text(data.is_nameboard ? 'Yes' : 'No');
  713. $('#ro_paSystem').text(data.is_pasystem ? 'Yes' : 'No');
  714. $('#ro_electricBell').text(data.is_bell ? 'Yes' : 'No');
  715. $('#ro_generatorSet').text(data.is_generator ? 'Yes' : 'No');
  716. $('#otherDetailsSection').show();
  717. $('#otherDetailsReadOnlyView').show();
  718. $('#otherDetailsSectionform').hide();
  719. } else {
  720. $('#otherDetailsSection').show();
  721. $('#otherDetailsReadOnlyView').hide();
  722. $('#otherDetailsSectionform').show();
  723. }
  724. } else {
  725. // ✅ No data at all
  726. $('#otherDetailsSection').show();
  727. $('#otherDetailsReadOnlyView').hide();
  728. $('#otherDetailsSectionform').show();
  729. }
  730. },
  731. error: function () {
  732. console.error('Error fetching other details');
  733. $('#otherDetailsSection').show();
  734. $('#otherDetailsReadOnlyView').hide();
  735. $('#otherDetailsSectionform').show();
  736. }
  737. });
  738. $('#updateOtherDetailsBtn').on('click', function () {
  739. console.log("schoolId", schoolId);
  740. $.ajax({
  741. url: '/gcc/api/gccschool/buildingasset/getotherdetailsBySchoolId',
  742. type: 'GET',
  743. data: {schoolId},
  744. success: function (response) {
  745. console.log("response");
  746. console.log(response);
  747. if (response.status === 'OK' && response.otherdetailsBySchool.length > 0) {
  748. const data = response.otherdetailsBySchool[0];
  749. console.log("land_area:", data.land_area);
  750. console.log("buildup_area:", data.buildup_area);
  751. $('#modal_land_area').val(data.land_area);
  752. $('#modal_buildup_area').val(data.buildup_area );
  753. //$('#buildup_area').val(data.buildup_area);
  754. $('input[name="modalcompoundWall"][value="' + (data.is_compound ? '1' : '0') + '"]').prop('checked', true);
  755. $('input[name="modalnameBoard"][value="' + (data.is_nameboard ? '1' : '0') + '"]').prop('checked', true);
  756. $('input[name="modalpaSystem"][value="' + (data.is_pasystem ? '1' : '0') + '"]').prop('checked', true);
  757. $('input[name="modalelectricBell"][value="' + (data.is_bell ? '1' : '0') + '"]').prop('checked', true);
  758. $('input[name="modalgeneratorSet"][value="' + (data.is_generator ? '1' : '0') + '"]').prop('checked', true);
  759. $('#otherDetailsFormWrapper').show();
  760. $('#otherDetailsReadOnlyView').show();
  761. $('#otherDetailsModal').modal('show');
  762. }
  763. }
  764. });
  765. });
  766. $('#updateOtherDetailsForm').on('submit', function (e) {
  767. e.preventDefault();
  768. // Collect values from modal
  769. const land_area = parseFloat($('#modal_land_area').val().trim());
  770. const buildup_area = parseFloat($('#modal_buildup_area').val().trim());
  771. const is_compound = $('input[name="modalcompoundWall"]:checked').val();
  772. const is_nameboard = $('input[name="modalnameBoard"]:checked').val();
  773. const is_pasystem = $('input[name="modalpaSystem"]:checked').val();
  774. const is_bell = $('input[name="modalelectricBell"]:checked').val();
  775. const is_generator = $('input[name="modalgeneratorSet"]:checked').val();
  776. console.log("text");
  777. console.log(land_area);
  778. console.log(is_bell);
  779. if (isNaN(land_area) || isNaN(buildup_area)) {
  780. Swal.fire("Validation Error", "Please enter valid area values.", "warning");
  781. return;
  782. }
  783. if (isNaN(parseFloat(land_area)) || land_area <= 0 || isNaN(parseFloat(buildup_area)) || buildup_area <= 50) {
  784. Swal.fire({
  785. icon: 'info',
  786. title: 'Validation Error',
  787. text: 'Site Area and Built-up Area must be valid numbers.',
  788. allowOutsideClick: false,
  789. allowEscapeKey: false,
  790. allowEnterKey: false,
  791. confirmButtonText: 'OK'
  792. });
  793. return;
  794. }
  795. // Prepare payload
  796. const formData = {
  797. land_area,
  798. buildup_area,
  799. is_compound,
  800. is_nameboard,
  801. is_pasystem,
  802. is_bell,
  803. is_generator,
  804. school_id: schoolId // already declared in your script
  805. };
  806. // AJAX call to your controller
  807. $.ajax({
  808. url: '/gcc/api/gccschool/schoolproperty/updateOtherDetails',
  809. type: 'POST',
  810. data: formData,
  811. success: function (response) {
  812. /* if (response === 'Success') {
  813. Swal.fire("Success!", "Other details updated successfully.", "success")
  814. .then(() => window.location.reload());
  815. } else {
  816. Swal.fire("Error", "Something went wrong. Try again.", "error");
  817. }
  818. },
  819. error: function (xhr, status, error) {
  820. console.error("AJAX Error:", error);
  821. Swal.fire("Error", "Server error occurred.", "error");
  822. }*/
  823. if (response === 'Success') {
  824. Swal.fire({
  825. title: "Success!",
  826. text: "Other details updated successfully.",
  827. icon: "success",
  828. allowOutsideClick: false,
  829. allowEscapeKey: false,
  830. allowEnterKey: false
  831. }).then(() => window.location.reload());
  832. } else {
  833. Swal.fire({
  834. title: "Error",
  835. text: "Something went wrong. Try again.",
  836. icon: "error",
  837. allowOutsideClick: false,
  838. allowEscapeKey: false,
  839. allowEnterKey: false
  840. });
  841. }
  842. },
  843. error: function (xhr, status, error) {
  844. console.error("AJAX Error:", error);
  845. Swal.fire({
  846. title: "Error",
  847. text: "Server error occurred.",
  848. icon: "error",
  849. allowOutsideClick: false,
  850. allowEscapeKey: false,
  851. allowEnterKey: false
  852. });
  853. }
  854. });
  855. });
  856. });
  857. </script>
  858. </body>
  859. </html>