This portal only for GCC Officers. Based on there roles and Group ID they can view there module`s Like PGR, QR Public Asset Feedback, Makkalai Thedi Mayor,etc...
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.

770 lines
35 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html lang="en" dir="ltr" xmlns:th="http://www.thymeleaf.org">
  3. <head th:replace="~{fragments/modules/base/head :: head}">
  4. <meta charset="UTF-8" />
  5. <title>Staff Strength Management</title>
  6. <style>
  7. body {
  8. background-color: #f8f9fa;
  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. /* Optional: styling update button gap */
  39. .btn-gap {
  40. margin-left: 1rem;
  41. }
  42. </style>
  43. <!-- jQuery -->
  44. <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  45. <!-- Bootstrap CSS (you may already have it from your fragments) -->
  46. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" />
  47. <!-- Bootstrap JS Bundle -->
  48. <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
  49. </head>
  50. <body>
  51. <div class="wrapper">
  52. <header th:replace="~{fragments/modules/base/header :: header}"></header>
  53. <div class="page-wrap">
  54. <div th:replace="~{fragments/modules/base/menu :: menu}"></div>
  55. <div class="card">
  56. <div class="main-content" style="background-color: white;">
  57. <!-- Container for Read-only Table View -->
  58. <div id="staffReadOnlyView" class="container mt-4" style="display: none; margin-left: -204px;margin-top: 5px;"></div>
  59. <!-- Update Button for Staff (if record exists) -->
  60. <div class="text-center mt-3" id="updateStaffContainer" style="display: none;">
  61. <button type="button" class="btn btn-primary" id="updateStaffBtn">Update</button>
  62. </div>
  63. <!-- Container for Editable Staff Form -->
  64. <div id="staffFormContainer">
  65. <form id="staffStrengthForm" novalidate>
  66. <!-- SG Teachers -->
  67. <div class="col-md-12">
  68. <div class="card" style="background-color: lightgrey; padding: 20px; margin-left: -127px; margin-top: -67px;">
  69. <div class="card-header">
  70. <b>1. SG Teachers *</b>
  71. </div>
  72. <div class="row mt-3">
  73. <div class="col-md-3">
  74. <label>No of Regu Teachers</label>
  75. <input type="number" class="form-control" name="sgRegTeacher" id="sgRegTeacher" placeholder="Enter Value" required />
  76. </div>
  77. <div class="col-md-3">
  78. <label>No of Smc Teachers</label>
  79. <input type="number" class="form-control" name="sgTempTeacher" id="sgTempTeacher" placeholder="Enter Value" required />
  80. </div>
  81. <div class="col-md-3">
  82. <label>No of Part-time Teachers</label>
  83. <input type="number" class="form-control" name="sgPtTeacher" id="sgPtTeacher" placeholder="Enter Value" required />
  84. </div>
  85. <div class="col-md-3">
  86. <label>No of NGO Teachers</label>
  87. <input type="number" class="form-control" name="sgNgoTeacher" id="sgNgoTeacher" placeholder="Enter Value" required />
  88. </div>
  89. </div>
  90. </div>
  91. </div>
  92. <!-- BT Teachers -->
  93. <div class="col-md-12">
  94. <div class="card" style="background-color: aliceblue; margin-left: -127px; padding: 20px; margin-top: 10px;">
  95. <div class="card-header">
  96. <b>2. BT Teachers *</b>
  97. </div>
  98. <div class="row mt-3">
  99. <div class="col-md-3">
  100. <label>No of Regu Teachers</label>
  101. <input type="number" class="form-control" name="btRegTeacher" id="btRegTeacher" placeholder="Enter Value" required />
  102. </div>
  103. <div class="col-md-3">
  104. <label>No of Smc Teachers</label>
  105. <input type="number" class="form-control" name="btTempTeacher" id="btTempTeacher" placeholder="Enter Value" required />
  106. </div>
  107. <div class="col-md-3">
  108. <label>No of Part-time Teachers</label>
  109. <input type="number" class="form-control" name="btPtTeacher" id="btPtTeacher" placeholder="Enter Value" required />
  110. </div>
  111. <div class="col-md-3">
  112. <label>No of NGO Teachers</label>
  113. <input type="number" class="form-control" name="btNgoTeacher" id="btNgoTeacher" placeholder="Enter Value" required />
  114. </div>
  115. </div>
  116. </div>
  117. </div>
  118. <!-- PG Teachers -->
  119. <div class="col-md-12">
  120. <div class="card" style="background-color: cornsilk; margin-left: -127px; padding: 20px; margin-top: 10px;">
  121. <div class="card-header">
  122. <b>3. PG Teachers *</b>
  123. </div>
  124. <div class="row mt-3">
  125. <div class="col-md-3">
  126. <label>No of Regu Teachers</label>
  127. <input type="number" class="form-control" name="pgRegTeacher" id="pgRegTeacher" placeholder="Enter Value" required />
  128. </div>
  129. <div class="col-md-3">
  130. <label>No of Smc Teachers</label>
  131. <input type="number" class="form-control" name="pgTempTeacher" id="pgTempTeacher" placeholder="Enter Value" required />
  132. </div>
  133. <div class="col-md-3">
  134. <label>No of Part-time Teachers</label>
  135. <input type="number" class="form-control" name="pgPtTeacher" id="pgPtTeacher" placeholder="Enter Value" required />
  136. </div>
  137. <div class="col-md-3">
  138. <label>No of NGO Teachers</label>
  139. <input type="number" class="form-control" name="pgNgoTeacher" id="pgNgoTeacher" placeholder="Enter Value" required />
  140. </div>
  141. </div>
  142. </div>
  143. </div>
  144. <div class="col-md-12">
  145. <div class="card mt-3" style="background-color: lavender; padding: 20px; margin-left: -127px;">
  146. <div class="card-header">
  147. <b>4. PET Teachers*</b>
  148. </div>
  149. <div class="row mt-3">
  150. <div class="col-md-3">
  151. <label>No of Regu Teachers</label>
  152. <input type="number" class="form-control" name="petRegTeacher" id="petRegTeacher" placeholder="Enter Value" required />
  153. </div>
  154. <div class="col-md-3">
  155. <label>No of Smc Teachers</label>
  156. <input type="number" class="form-control" name="petTempTeacher" id="petTempTeacher" placeholder="Enter Value" required />
  157. </div>
  158. <div class="col-md-3">
  159. <label>No of Grade 1 Teachers</label>
  160. <input type="number" class="form-control" name="petGrade1Teacher" id="petGrade1Teacher" placeholder="Enter Value" required />
  161. </div>
  162. <div class="col-md-3">
  163. <label>No of Grade 2 Teachers</label>
  164. <input type="number" class="form-control" name="petGrade2Teacher" id="petGrade2Teacher" placeholder="Enter Value" required />
  165. </div>
  166. </div>
  167. </div>
  168. </div>
  169. <div class="col-md-12">
  170. <div class="card mt-3" style="background-color: honeydew; padding: 20px; margin-left: -127px;">
  171. <div class="card-header">
  172. <b>5. kG Teachers*</b>
  173. </div>
  174. <div class="row mt-3">
  175. <div class="col-md-3">
  176. <label>No of Regu Teachers</label>
  177. <input type="number" class="form-control" name="kgRegTeacher" id="kgRegTeacher" placeholder="Enter Value" required />
  178. </div>
  179. <div class="col-md-3">
  180. <label>No of Smc Teachers</label>
  181. <input type="number" class="form-control" name="kgTempTeacher" id="kgTempTeacher" placeholder="Enter Value" required />
  182. </div>
  183. </div>
  184. </div>
  185. </div>
  186. <!-- Other Details -->
  187. <div class="col-md-12">
  188. <div class="card" style="padding: 20px; margin-left: -127px; background-color: #f8f9fa; margin-top: 10px;">
  189. <div class="card-header">
  190. <b>Other Details *</b>
  191. </div>
  192. <div class="row mt-3">
  193. <!-- <div class="col-md-3">
  194. <label>No of KG Teachers</label>
  195. <input type="number" class="form-control" name="kgTeacher" id="kgTeacher" placeholder="Enter Value" required />
  196. </div>
  197. <div class="col-md-3">
  198. <label>No of PT Teachers</label>
  199. <input type="number" class="form-control" name="petTeacher" id="petTeacher" placeholder="Enter Value" required />
  200. </div>-->
  201. <div class="col-md-3">
  202. <label>Total No of OA</label>
  203. <input type="number" class="form-control" name="totOa" id="totOa" placeholder="Enter Value" required />
  204. </div>
  205. <div class="col-md-3">
  206. <label>KG Ayah</label>
  207. <input type="number" class="form-control" name="kgAyah" id="kgAyah" placeholder="Enter Value" required />
  208. </div>
  209. <div class="col-md-3 mt-3">
  210. <label>Computer Assistance</label>
  211. <input type="number" class="form-control" name="compAss" id="compAss" placeholder="Enter Value" required />
  212. </div>
  213. <div class="col-md-3 mt-3">
  214. <label>Watchman</label>
  215. <input type="number" class="form-control" name="watchmen" id="watchmen" placeholder="Enter Value" required />
  216. </div>
  217. <div class="col-md-3 mt-3">
  218. <label>Scavengers</label>
  219. <input type="number" class="form-control" name="scavengers" id="scavengers" placeholder="Enter Value" required />
  220. </div>
  221. <div class="col-md-3 mt-3">
  222. <label>Sweeper</label>
  223. <input type="number" class="form-control" name="maintenanceWork" id="maintenanceWork" placeholder="Enter Value" required />
  224. </div>
  225. </div>
  226. <div class="card-footer text-center mt-3">
  227. <button type="submit" class="btn btn-primary" id="requestSubmitBtn">
  228. <i class="ik ik-save"></i> Submit
  229. </button>
  230. <button type="reset" class="btn btn-secondary ml-2" id="resetButton">
  231. <i class="ik ik-refresh-cw"></i> Reset
  232. </button>
  233. </div>
  234. </div>
  235. </div>
  236. </form>
  237. </div>
  238. <!-- End of Staff Form -->
  239. <!-- Page Loader -->
  240. <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;">
  241. <div style="position: relative; top: 50%; transform: translateY(-50%);">
  242. <div class="spinner-border text-primary" role="status" style="width: 3rem; height: 3rem;">
  243. <span class="sr-only">Loading...</span>
  244. </div>
  245. <p style="margin-top: 1rem; font-size: 1.2rem; color: #007bff;">Please wait...</p>
  246. </div>
  247. </div>
  248. </div>
  249. </div>
  250. </div>
  251. </div>
  252. <!-- Staff Update Modal -->
  253. <div class="modal fade" id="staffUpdateModal" tabindex="-1">
  254. <div class="modal-dialog modal-xl">
  255. <div class="modal-content">
  256. <div class="modal-header">
  257. <h5 class="modal-title">Update Staff Strength</h5>
  258. <button type="button" class="close" data-bs-dismiss="modal"
  259. aria-label="Close"><span aria-hidden="true">&times;</span></button>
  260. </div>
  261. <div class="modal-body">
  262. <div class="row g-3">
  263. <!-- SG Section -->
  264. <div class="col-md-3"><label>SG - Regu Teachers *</label><input type="number" id="modal_sgRegTeacher" class="form-control" /></div>
  265. <div class="col-md-3"><label>SG - Smc Teachers *</label><input type="number" id="modal_sgTempTeacher" class="form-control" /></div>
  266. <div class="col-md-3"><label>SG - Part-time Teachers *</label><input type="number" id="modal_sgPtTeacher" class="form-control" /></div>
  267. <div class="col-md-3"><label>SG - NGO Teachers *</label><input type="number" id="modal_sgNgoTeacher" class="form-control" /></div>
  268. <!-- BT Section -->
  269. <div class="col-md-3"><label>BT - Regu Teachers *</label><input type="number" id="modal_btRegTeacher" class="form-control" /></div>
  270. <div class="col-md-3"><label>BT - Smc Teachers *</label><input type="number" id="modal_btTempTeacher" class="form-control" /></div>
  271. <div class="col-md-3"><label>BT - Part-time Teachers *</label><inputtype="number" id="modal_btPtTeacher" class="form-control" /></div>
  272. <div class="col-md-3"><label>BT - NGO Teachers *</label><input type="number" id="modal_btNgoTeacher" class="form-control" /></div>
  273. <!-- PG Section -->
  274. <div class="col-md-3"><label>PG - Regu Teachers *</label><input type="number" id="modal_pgRegTeacher" class="form-control" /></div>
  275. <div class="col-md-3"><label>PG - Smc Teachers *</label><input type="number" id="modal_pgTempTeacher" class="form-control" /></div>
  276. <div class="col-md-3"><label>PG - Part-time Teachers *</label><input type="number" id="modal_pgPtTeacher" class="form-control" /></div>
  277. <div class="col-md-3"><label>PG - NGO Teachers *</label><input type="number" id="modal_pgNgoTeacher" class="form-control" /></div>
  278. <!-- PET Section -->
  279. <div class="col-md-3"><label>PET - Regu Teachers *</label><input type="number" id="modal_petRegTeacher" class="form-control" /></div>
  280. <div class="col-md-3"><label>PET - Smc Teachers *</label><input type="number" id="modal_petTempTeacher" class="form-control" /></div>
  281. <div class="col-md-3"><label>PET - Grade 1 Teachers *</label><input type="number" id="modal_petg1Teacher" class="form-control" /></div>
  282. <div class="col-md-3"><label>PET - Grade 2 Teachers *</label><input type="number" id="modal_petg2Teacher" class="form-control" /></div>
  283. <!-- kg Section -->
  284. <div class="col-md-3"><label>KG - Regu Teachers *</label><input type="number" id="modal_kgRegTeacher" class="form-control" /></div>
  285. <div class="col-md-3"><label>KG - Smc Teachers *</label><input type="number" id="modal_kgTempTeacher" class="form-control" /></div>
  286. <!-- Other Section -->
  287. <!-- <div class="col-md-3"><label>KG Teachers *</label><input id="modal_kgTeacher" class="form-control" /></div>
  288. <div class="col-md-3"><label>PT Teachers *</label><input id="modal_petTeacher" class="form-control" /></div>-->
  289. <div class="col-md-3"><label>Total OA *</label><input type="number" id="modal_totOa" class="form-control" /></div>
  290. <div class="col-md-3"><label>KG Ayah *</label><input type="number" id="modal_kgAyah" class="form-control" /></div>
  291. <div class="col-md-3"><label>Computer Assistance *</label><input type="number" id="modal_compAss" class="form-control" /></div>
  292. <div class="col-md-3"><label>Watchmen *</label><input type="number" id="modal_watchmen" class="form-control" /></div>
  293. <div class="col-md-3"><label>Scavengers *</label><input type="number" id="modal_scavengers" class="form-control" /></div>
  294. <div class="col-md-3"><label>Sweeper *</label><input type="number" id="modal_maintenanceWork" class="form-control" /></div>
  295. </div>
  296. </div>
  297. <div class="modal-footer">
  298. <button class="btn btn-primary" id="saveStaffModalUpdate">Save Changes</button>
  299. <button class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
  300. </div>
  301. </div>
  302. </div>
  303. </div>
  304. <!-- Scripts -->
  305. <script>
  306. $(document).ready(function () {
  307. const urlParams = new URLSearchParams(window.location.search);
  308. const schoolId = urlParams.get("schoolId");
  309. // Allow only whole positive numbers in number fields
  310. document.querySelectorAll('input[type="number"]').forEach(function (input) {
  311. input.addEventListener("input", function () {
  312. this.value = this.value.replace(/[^0-9]/g, "");
  313. if (parseInt(this.value) < 0) {
  314. this.value = "";
  315. }
  316. });
  317. });
  318. // Fetch staff data against schoolId
  319. $.ajax({
  320. url: '/gcc/api/gccschool/buildingasset/getStaffStrengthBySchoolId',
  321. type: 'GET',
  322. data: { schoolId },
  323. success: function (response) {
  324. console.log(response);
  325. if (response.status === 'OK' && response.staffStrength.length > 0) {
  326. const data = response.staffStrength[0];
  327. // Build a read-only table with fetched staff data
  328. const tableHtml = `
  329. <h6 class="text-left mb-3"><b>Staff Strength Details</b></h6>
  330. <hr>
  331. <!-- SG Teachers -->
  332. <h6><b>1. SG Teachers *</b></h6>
  333. <table class="table">
  334. <tbody>
  335. <tr><td>No of Regu Teachers</td><td>${data.sg_reg_teacher || 0}</td></tr>
  336. <tr><td>No of Smc Teachers</td><td>${data.sg_temp_teacher || 0}</td></tr>
  337. <tr><td>No of Part-time Teachers</td><td>${data.sg_pt_teacher || 0}</td></tr>
  338. <tr><td>No of NGO Teachers</td><td>${data.sg_ngo_teacher || 0}</td></tr>
  339. </tbody>
  340. </table>
  341. <!-- BT Teachers -->
  342. <h6><b>2. BT Teachers *</b></h6>
  343. <table class="table">
  344. <tbody>
  345. <tr><td>No of Regu Teachers</td><td>${data.bt_reg_teacher || 0}</td></tr>
  346. <tr><td>No of Smc Teachers</td><td>${data.bt_temp_teacher || 0}</td></tr>
  347. <tr><td>No of Part-time Teachers</td><td>${data.bt_pt_teacher || 0}</td></tr>
  348. <tr><td>No of NGO Teachers</td><td>${data.bt_ngo_teacher || 0}</td></tr>
  349. </tbody>
  350. </table>
  351. <!-- PG Teachers -->
  352. <h6><b>3. PG Teachers *</b></h6>
  353. <table class="table">
  354. <tbody>
  355. <tr><td>No of Regu Teachers</td><td>${data.pg_reg_teacher || 0}</td></tr>
  356. <tr><td>No of Smc Teachers</td><td>${data.pg_temp_teacher || 0}</td></tr>
  357. <tr><td>No of Part-time Teachers</td><td>${data.pg_pt_teacher || 0}</td></tr>
  358. <tr><td>No of NGO Teachers</td><td>${data.pg_ngo_teacher || 0}</td></tr>
  359. </tbody>
  360. </table>
  361. <!-- PG Teachers -->
  362. <h6><b>4. PET Teachers *</b></h6>
  363. <table class="table">
  364. <tbody>
  365. <tr><td>No of Regu Teachers</td><td>${data.pet_reg_teacher || 0}</td></tr>
  366. <tr><td>No of Smc Teachers</td><td>${data.pet_temp_teacher || 0}</td></tr>
  367. <tr><td>No of Grade 1 Teachers</td><td>${data.pet_grade1_teacher || 0}</td></tr>
  368. <tr><td>No of Grade 2 Teachers</td><td>${data.pet_grade2_teacher || 0}</td></tr>
  369. </tbody>
  370. </table>
  371. <!-- PG Teachers -->
  372. <h6><b>5. kG Teachers *</b></h6>
  373. <table class="table">
  374. <tbody>
  375. <tr><td>No of Regu Teachers</td><td>${data.kg_reg_teacher || 0}</td></tr>
  376. <tr><td>No of Smc Teachers</td><td>${data.kg_temp_teacher || 0}</td></tr>
  377. </tbody>
  378. </table>
  379. <!-- Other Details -->
  380. <h6><b>6. Other Details *</b></h6>
  381. <table class="table">
  382. <tbody>
  383. <tr><td>Total OA</td><td>${data.tot_oa || 0}</td></tr>
  384. <tr><td>KG Ayah</td><td>${data.kg_ayah || 0}</td></tr>
  385. <tr><td>Computer Assistance</td><td>${data.comp_ass || 0}</td></tr>
  386. <tr><td>Watchmen</td><td>${data.watchmen || 0}</td></tr>
  387. <tr><td>Scavengers</td><td>${data.scavengers || 0}</td></tr>
  388. <tr><td>Sweeper</td><td>${data.maintenance_work || 0}</td></tr>
  389. </tbody>
  390. </table>
  391. `;
  392. // Populate read-only view and hide staff form
  393. $('#staffReadOnlyView').html(tableHtml).show();
  394. $('#staffFormContainer').hide();
  395. $('#updateStaffContainer').show();
  396. // Bind Update button click event to open the modal with prefilled values
  397. $('#updateStaffBtn').click(() => {
  398. $('#modal_sgRegTeacher').val(data.sg_reg_teacher);
  399. $('#modal_sgTempTeacher').val(data.sg_temp_teacher);
  400. $('#modal_sgPtTeacher').val(data.sg_pt_teacher);
  401. $('#modal_sgNgoTeacher').val(data.sg_ngo_teacher);
  402. $('#modal_btRegTeacher').val(data.bt_reg_teacher);
  403. $('#modal_btTempTeacher').val(data.bt_temp_teacher);
  404. $('#modal_btPtTeacher').val(data.bt_pt_teacher);
  405. $('#modal_btNgoTeacher').val(data.bt_ngo_teacher);
  406. $('#modal_pgRegTeacher').val(data.pg_reg_teacher);
  407. $('#modal_pgTempTeacher').val(data.pg_temp_teacher);
  408. $('#modal_pgPtTeacher').val(data.pg_pt_teacher);
  409. $('#modal_pgNgoTeacher').val(data.pg_ngo_teacher);
  410. $('#modal_petRegTeacher').val(data.pet_reg_teacher);
  411. $('#modal_petTempTeacher').val(data.pet_temp_teacher);
  412. $('#modal_petg1Teacher').val(data.pet_grade1_teacher);
  413. $('#modal_petg2Teacher').val(data.pet_grade2_teacher);
  414. $('#modal_kgRegTeacher').val(data.kg_reg_teacher);
  415. $('#modal_kgTempTeacher').val(data.kg_temp_teacher);
  416. $('#modal_totOa').val(data.tot_oa);
  417. $('#modal_kgAyah').val(data.kg_ayah);
  418. $('#modal_compAss').val(data.comp_ass);
  419. $('#modal_watchmen').val(data.watchmen);
  420. $('#modal_scavengers').val(data.scavengers);
  421. $('#modal_maintenanceWork').val(data.maintenance_work);
  422. $('#staffUpdateModal').modal('show');
  423. });
  424. } else {
  425. // No staff data found – show form for entry
  426. $('#staffReadOnlyView').hide();
  427. $('#staffFormContainer').show();
  428. $('#updateStaffContainer').hide();
  429. }
  430. }
  431. });
  432. // Staff Form submission event
  433. $("#staffStrengthForm").submit(function (event) {
  434. event.preventDefault();
  435. console.log("Submit button clicked for Staff");
  436. console.log("SchoolId:", schoolId);
  437. // Validation: Check required fields
  438. /* const requiredFields = {
  439. 'sgRegTeacher': 'SG - Regular Teachers',
  440. 'sgTempTeacher': 'SG - Temp Teachers',
  441. 'sgPtTeacher': 'SG - Part-time Teachers',
  442. 'sgNgoTeacher': 'SG - NGO Teachers',
  443. 'btRegTeacher': 'BT - Regular Teachers',
  444. 'btTempTeacher': 'BT - Temp Teachers',
  445. 'btPtTeacher': 'BT - Part-time Teachers',
  446. 'btNgoTeacher': 'BT - NGO Teachers',
  447. 'pgRegTeacher': 'PG - Regular Teachers',
  448. 'pgTempTeacher': 'PG - Temp Teachers',
  449. 'pgPtTeacher': 'PG - Part-time Teachers',
  450. 'pgNgoTeacher': 'PG - NGO Teachers',
  451. 'kgTeacher': 'KG Teachers',
  452. 'petTeacher': 'PT Teachers',
  453. 'totOa': 'Total OA',
  454. 'kgAyah': 'KG Ayah',
  455. 'compAss': 'Computer Assistance',
  456. 'watchmen': 'Watchman',
  457. 'scavengers': 'Scavengers',
  458. 'maintenanceWork': 'Maintenance Works'
  459. };*/
  460. const requiredFields = {
  461. sgRegTeacher: 'SG - Regular Teachers',
  462. sgTempTeacher: 'SG - Smc Teachers',
  463. sgPtTeacher: 'SG - Part-time Teachers',
  464. sgNgoTeacher: 'SG - NGO Teachers',
  465. btRegTeacher: 'BT - Regular Teachers',
  466. btTempTeacher: 'BT - Smc Teachers',
  467. btPtTeacher: 'BT - Part-time Teachers',
  468. btNgoTeacher: 'BT - NGO Teachers',
  469. pgRegTeacher: 'PG - Regular Teachers',
  470. pgTempTeacher: 'PG - Smc Teachers',
  471. pgPtTeacher: 'PG - Part-time Teachers',
  472. pgNgoTeacher: 'PG - NGO Teachers',
  473. petRegTeacher: 'PET - Regular Teachers',
  474. petTempTeacher: 'PET - Smc Teachers',
  475. petGrade1Teacher: 'PET - Grade 1 Teachers',
  476. petGrade2Teacher: 'PET - Grade 2 Teachers',
  477. kgRegTeacher: 'KG - Regular Teachers',
  478. kgTempTeacher: 'KG - Smc Teachers',
  479. totOa: 'Total OA',
  480. kgAyah: 'KG Ayah',
  481. compAss: 'Computer Assistance',
  482. watchmen: 'Watchman',
  483. scavengers: 'Scavengers',
  484. maintenanceWork: 'Sweeper'
  485. };
  486. for (let fieldId in requiredFields) {
  487. const value = $(`#${fieldId}`).val();
  488. if (value === null || value.trim() === "" || isNaN(Number(value)) || parseInt(value) < 0) {
  489. Swal.fire({
  490. icon: 'warning',
  491. title: 'Missing or Invalid Input',
  492. text: `Please enter a valid number for "${requiredFields[fieldId]}"`,
  493. allowOutsideClick: false,
  494. allowEscapeKey: false,
  495. allowEnterKey: false,
  496. showConfirmButton: true
  497. });
  498. return;
  499. }
  500. }
  501. // Show loader before submitting
  502. $('#pageLoader').show();
  503. // Prepare form data
  504. var formData = new FormData(document.getElementById("staffStrengthForm"));
  505. formData.append("schoolId", schoolId);
  506. // Debug log (optional)
  507. const debugObj = {};
  508. formData.forEach((value, key) => {
  509. debugObj[key] = value;
  510. });
  511. console.log("Form Data Collected:", debugObj);
  512. // Submit via AJAX
  513. $.ajax({
  514. type: "POST",
  515. url: "/gcc/api/gccschool/schoolproperty/saveStaffStrength",
  516. data: formData,
  517. processData: false,
  518. contentType: false,
  519. success: function (response) {
  520. $("#pageLoader").hide();
  521. console.log("Data Submitted Successfully:", response);
  522. Swal.fire({
  523. icon: "success",
  524. title: "Data Saved!",
  525. text: "Staff strength details saved successfully!",
  526. confirmButtonColor: "#3085d6",
  527. allowOutsideClick: false,
  528. allowEscapeKey: false,
  529. allowEnterKey: false,
  530. showConfirmButton: true
  531. }).then(() => {
  532. $("#staffStrengthForm")[0].reset();
  533. // Optionally, reload page to refresh view
  534. location.reload();
  535. });
  536. },
  537. error: function (xhr, status, error) {
  538. $("#pageLoader").hide();
  539. console.error("Submission Error:", xhr.responseText);
  540. Swal.fire({
  541. icon: "error",
  542. title: "Error!",
  543. text: "Something went wrong. Please try again.",
  544. allowOutsideClick: false,
  545. allowEscapeKey: false,
  546. allowEnterKey: false,
  547. confirmButtonColor: "#d33"
  548. });
  549. }
  550. });
  551. });
  552. function resetStaffFields() {
  553. console.log("Reset button clicked");
  554. $('#staffStrengthForm input[type="number"]').val('');
  555. }
  556. $(document).on('click', '#resetButton', function (event) {
  557. event.preventDefault();
  558. resetStaffFields();
  559. });
  560. // Reset Button click event
  561. /* $("#resetButton").click(function () {
  562. Swal.fire({
  563. title: "Are you sure?",
  564. text: "This will reset all form fields!",
  565. icon: "warning",
  566. showCancelButton: true,
  567. confirmButtonColor: "#3085d6",
  568. cancelButtonColor: "#d33",
  569. confirmButtonText: "Yes, reset!"
  570. }).then((result) => {
  571. if (result.isConfirmed) {
  572. $("input[type='number']").val("");
  573. Swal.fire("Reset!", "Form has been cleared.", "success");
  574. }
  575. });
  576. });*/
  577. // Handle Save from Staff Update Modal
  578. $("#saveStaffModalUpdate").on('click', function () {
  579. const modalRequiredFields = {
  580. modal_sgRegTeacher: 'SG - Regular Teachers',
  581. modal_sgTempTeacher: 'SG - Smc Teachers',
  582. modal_sgPtTeacher: 'SG - Part-time Teachers',
  583. modal_sgNgoTeacher: 'SG - NGO Teachers',
  584. modal_btRegTeacher: 'BT - Regular Teachers',
  585. modal_btTempTeacher: 'BT - Smc Teachers',
  586. modal_btPtTeacher: 'BT - Part-time Teachers',
  587. modal_btNgoTeacher: 'BT - NGO Teachers',
  588. modal_pgRegTeacher: 'PG - Regular Teachers',
  589. modal_pgTempTeacher: 'PG - Smc Teachers',
  590. modal_pgPtTeacher: 'PG - Part-time Teachers',
  591. modal_pgNgoTeacher: 'PG - NGO Teachers',
  592. modal_petRegTeacher: 'PET - Regular Teachers',
  593. modal_petTempTeacher: 'PET - Smc Teachers',
  594. modal_petg1Teacher: 'PET - Grade 1 Teachers',
  595. modal_petg2Teacher: 'PET - Grade 2 Teachers',
  596. modal_kgRegTeacher: 'KG - Regular Teachers',
  597. modal_kgTempTeacher: 'KG - Smc Teachers',
  598. modal_totOa: 'Total OA',
  599. modal_kgAyah: 'KG Ayah',
  600. modal_compAss: 'Computer Assistance',
  601. modal_watchmen: 'Watchmen',
  602. modal_scavengers: 'Scavengers',
  603. modal_maintenanceWork: 'Sweeper'
  604. };
  605. for (let fieldId in modalRequiredFields) {
  606. const value = $(`#${fieldId}`).val();
  607. if (value === null || value.trim() === "" || isNaN(Number(value)) || parseInt(value) < 0) {
  608. Swal.fire({
  609. icon: 'warning',
  610. title: 'Missing or Invalid Input',
  611. text: `Please enter a valid number for "${modalRequiredFields[fieldId]}"`,
  612. allowOutsideClick: false,
  613. allowEscapeKey: false,
  614. allowEnterKey: false,
  615. showConfirmButton: true
  616. });
  617. return false; // Prevent further execution if validation fails
  618. }
  619. }
  620. const updatedData = {
  621. sgRegTeacher: $('#modal_sgRegTeacher').val(),
  622. sgTempTeacher: $('#modal_sgTempTeacher').val(),
  623. sgPtTeacher: $('#modal_sgPtTeacher').val(),
  624. sgNgoTeacher: $('#modal_sgNgoTeacher').val(),
  625. btRegTeacher: $('#modal_btRegTeacher').val(),
  626. btTempTeacher: $('#modal_btTempTeacher').val(),
  627. btPtTeacher: $('#modal_btPtTeacher').val(),
  628. btNgoTeacher: $('#modal_btNgoTeacher').val(),
  629. pgRegTeacher: $('#modal_pgRegTeacher').val(),
  630. pgTempTeacher: $('#modal_pgTempTeacher').val(),
  631. pgPtTeacher: $('#modal_pgPtTeacher').val(),
  632. pgNgoTeacher: $('#modal_pgNgoTeacher').val(),
  633. petRegTeacher: $('#modal_petRegTeacher').val(),
  634. petTempTeacher: $('#modal_petTempTeacher').val(),
  635. petGrade1Teacher: $('#modal_petg1Teacher').val(),
  636. petGrade2Teacher: $('#modal_petg2Teacher').val(),
  637. kgRegTeacher: $('#modal_kgRegTeacher').val(),
  638. kgTempTeacher: $('#modal_kgTempTeacher').val(),
  639. totOa: $('#modal_totOa').val(),
  640. kgAyah: $('#modal_kgAyah').val(),
  641. compAss: $('#modal_compAss').val(),
  642. watchmen: $('#modal_watchmen').val(),
  643. scavengers: $('#modal_scavengers').val(),
  644. maintenanceWork: $('#modal_maintenanceWork').val(),
  645. school_id: schoolId // IMPORTANT: use same name as @RequestParam
  646. };
  647. $('#pageLoader').show();
  648. $.ajax({
  649. url: '/gcc/api/gccschool/schoolproperty/updateStaffDetails',
  650. type: 'POST',
  651. contentType: 'application/x-www-form-urlencoded',
  652. data: $.param(updatedData),
  653. success: function (res) {
  654. $('#pageLoader').hide();
  655. $('#staffUpdateModal').modal('hide');
  656. // Swal.fire('Updated!', res, 'success').then(() => location.reload());
  657. Swal.fire({
  658. title: 'Updated!',
  659. text: 'Staff strength details updated successfully!',
  660. icon: 'success',
  661. allowOutsideClick: false,
  662. allowEscapeKey: false,
  663. allowEnterKey: false,
  664. showConfirmButton: true
  665. }).then(() => location.reload());
  666. },
  667. error: function (err) {
  668. $('#pageLoader').hide();
  669. Swal.fire({
  670. title: 'Error',
  671. text: err.responseText,
  672. icon: 'error',
  673. allowOutsideClick: false,
  674. allowEscapeKey: false,
  675. allowEnterKey: false,
  676. showConfirmButton: true
  677. });
  678. //Swal.fire('Error', err.responseText, 'error');
  679. }
  680. });
  681. });
  682. });
  683. </script>
  684. </body>
  685. </html>