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.

379 lines
17 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html lang="en" dir="">
  3. <html xmlns:th="http://www.thymeleaf.org">
  4. <head th:replace="~{fragments/modules/base/head :: head}">
  5. </head>
  6. <body>
  7. <!--[if lt IE 8]>
  8. <p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
  9. <![endif]-->
  10. <div class="wrapper">
  11. <!-- header top menu Start -->
  12. <header th:replace="~{fragments/modules/base/header :: header}"></header>
  13. <!-- header top menu end -->
  14. <div class="page-wrap">
  15. <!--=============== Left Menu side Start ================-->
  16. <div th:replace="~{fragments/modules/base/menu :: menu}"></div>
  17. <!--=============== Left side End ================-->
  18. <div class="main-content">
  19. <div class="container-fluid">
  20. <div class="page-header">
  21. <div class="row align-items-end">
  22. <div class="col-lg-6">
  23. <div class="page-header-title">
  24. <i class="ik ik-thumbs-up bg-blue"></i>
  25. <div class="d-inline">
  26. <h5>NULM STAFF</h5>
  27. <span>Staff Details Updation</span>
  28. </div>
  29. </div>
  30. </div>
  31. <div class="col-lg-6">
  32. <nav class="breadcrumb-container" aria-label="breadcrumb">
  33. <ol class="breadcrumb">
  34. <li class="breadcrumb-item">
  35. <a href="/index"><i class="ik ik-home"></i></a>
  36. </li>
  37. <li class="breadcrumb-item active" aria-current="page">Staff Details Updation</li>
  38. </ol>
  39. </nav>
  40. </div>
  41. </div>
  42. </div>
  43. <hr>
  44. <div class="card-block">
  45. <div>
  46. <form id="departmentFilterForm" method="GET" action="/gcc/nulm/updateStaff">
  47. <div class="form-group">
  48. <label for="zone">Zone (Department)</label>
  49. <select class="form-control" id="zone" name="department" style="width: 300px;" onchange="this.form.submit()">
  50. <option value="">Select Zone</option>
  51. <option th:each="department : ${departments}"
  52. th:value="${department.department}"
  53. th:text="${department.department}"
  54. th:selected="${department.department == selectedDepartment}">
  55. </option>
  56. </select>
  57. </div>
  58. </form>
  59. <table id="salaryDatatable" class="table table-striped table-bordered table-hover dataTable" role="grid" width="99.5%">
  60. <thead class="thead-dark">
  61. <tr role="row">
  62. <th>S.No</th>
  63. <th>Employee ID</th>
  64. <th>Employee Name</th>
  65. <th>Designation</th>
  66. <th>Gender</th>
  67. <th>Date Of Birth</th>
  68. <th>Action</th>
  69. </tr>
  70. </thead>
  71. <tbody>
  72. <tr th:each="enrollments, i : ${enrollments}">
  73. <td th:text="${i.count}">0</td>
  74. <td th:text="${enrollments.emp_id}"></td>
  75. <td th:text="${enrollments.name}"></td>
  76. <td th:text="${enrollments.designation}"></td>
  77. <td th:text="${enrollments.gender}"></td>
  78. <td th:text="${enrollments.date_of_birth}"></td>
  79. <td class="text-center">
  80. <a href="#" th:onclick="return callEdit([[${enrollments.enrollment_id}]])" data-animation="true" data-toggle="tooltip" data-placement="top" title="Edit" data-original-title="Edit"><i class="ik ik-edit f-16 mr-15 text-green"></i></a>
  81. </td>
  82. </tr>
  83. </tbody>
  84. <tfoot class="thead-dark">
  85. <tr role="row">
  86. <th>S.No</th>
  87. <th>Employee ID</th>
  88. <th>Employee Name</th>
  89. <th>Designation</th>
  90. <th>Gender</th>
  91. <th>Date Of Birth</th>
  92. <th>Action</th>
  93. </tr>
  94. </tfoot>
  95. </table>
  96. </div>
  97. </div>
  98. <!-- Enrollment Edit Modal -->
  99. <div class="modal fade" id="editEnrollmentModal" tabindex="-1" role="dialog" aria-labelledby="editEnrollmentModalLabel" aria-hidden="true">
  100. <div class="modal-dialog" role="document">
  101. <div class="modal-content">
  102. <div class="modal-header">
  103. <h5 class="modal-title" id="editEnrollmentModalLabel">Edit Enrollment Details</h5>
  104. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  105. <span aria-hidden="true">&times;</span>
  106. </button>
  107. </div>
  108. <div class="modal-body">
  109. <!-- Form for Editing Enrollment -->
  110. <form id="editEnrollmentForm">
  111. <input type="hidden" id="enrollmentId" name="enrollmentId">
  112. <div class="form-group">
  113. <label for="name">Name</label>
  114. <input type="text" class="form-control" id="name" name="name" disabled style="color: black;">
  115. </div>
  116. <div class="form-group">
  117. <label for="dateOfBirth">Date of Birth</label>
  118. <input type="date" class="form-control" id="dateOfBirth" name="dateOfBirth" required>
  119. </div>
  120. <div class="form-group">
  121. <label for="gender">Gender</label>
  122. <input type="text" class="form-control" id="gender" name="gender" required>
  123. </div>
  124. <div class="form-group">
  125. <label for="gender">Designation</label>
  126. <input type="text" class="form-control" id="designation" name="designation" disabled style="color: black;">
  127. </div>
  128. <div class="form-group">
  129. <label for="inchargeName">Incharge Name</label>
  130. <input type="text" class="form-control" id="inchargename" name="inchargename" disabled style="color: black;">
  131. </div>
  132. <div class="form-group">
  133. <label for="phoneNumber">Incharge Number</label>
  134. <input type="number" class="form-control" id="inchargeno" name="inchargeno" disabled style="color: black;">
  135. </div>
  136. <div class="form-group">
  137. <label for="shg">Self Help Group</label>
  138. <select class="form-control" id="shg" name="shg" required>
  139. <!-- Dropdown options will be populated dynamically via JavaScript -->
  140. </select>
  141. </div>
  142. <div class="form-group">
  143. <label for="orderNumber">Order Number</label>
  144. <select class="form-control" id="orderNumber" name="orderNumber" required>
  145. <!-- Dropdown options will be populated dynamically via JavaScript -->
  146. </select>
  147. </div>
  148. <!-- Add more fields as needed -->
  149. <button type="button" class="btn btn-primary" id="updateEnrollmentButton">Save Changes</button>
  150. <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
  151. </form>
  152. </div>
  153. </div>
  154. </div>
  155. </div>
  156. </div>
  157. </div>
  158. <footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
  159. </div>
  160. </div>
  161. <div th:replace="~{fragments/modules/pgr/modal-box :: div}"></div>
  162. <div th:replace="~{fragments/modules/base/app_module_menu_box :: div}"></div>
  163. <script th:replace="~{fragments/modules/base/script :: script}"></script>
  164. <script th:replace="~{fragments/modules/pgr/script :: script}"></script>
  165. <script th:inline="javascript">
  166. $(document).ready(function () {
  167. // Initialize DataTable
  168. const table = $('#salaryDatatable').DataTable({
  169. dom: 'Bftip',
  170. columnDefs: [
  171. { targets: 'no-sort', orderable: false }
  172. ],
  173. lengthMenu: [
  174. [50, 100, 200, 500, -1],
  175. ['50 rows', '100 rows', '200 rows', 'Show all']
  176. ],
  177. scrollY: '50vh',
  178. fixedColumns: {
  179. left: 1,
  180. right: 1
  181. },
  182. buttons: [
  183. { extend: 'pageLength', className: 'btn btn-warning' },
  184. { title: 'Data export', extend: 'copyHtml5', text: 'Copy', className: 'btn btn-secondary', id: 'copyBtn' },
  185. { extend: 'excelHtml5', text: 'Excel', className: 'btn btn-secondary', id: 'excelBtn' },
  186. { extend: 'csvHtml5', text: 'CSV', className: 'btn btn-secondary', id: 'csvBtn' },
  187. { extend: 'pdfHtml5', text: 'PDF', className: 'btn btn-secondary', id: 'pdfBtn' }
  188. ],
  189. fixedHeader: true,
  190. autoWidth: true,
  191. responsive: true,
  192. searching: true,
  193. select: false,
  194. processing: false
  195. });
  196. // Function to open the edit modal and populate data
  197. window.callEdit = function (enrollmentId) {
  198. fetchEnrollmentDetails(enrollmentId);
  199. return false; // Prevent default anchor click behavior
  200. };
  201. function loadDepartments(selectedDepartment) {
  202. $.ajax({
  203. url: '/gcc/api/nulm/getDepartment',
  204. type: 'GET',
  205. success: function (response) {
  206. const departmentDropdown = $('#zone');
  207. departmentDropdown.empty(); // Clear existing options
  208. departmentDropdown.append('<option value="">Select Zone</option>');
  209. response.forEach(function (department) {
  210. const departmentName = department.department; // Correct the attribute name if necessary
  211. const isSelected = departmentName === selectedDepartment ? 'selected' : '';
  212. departmentDropdown.append(new Option(departmentName, departmentName, false, isSelected));
  213. });
  214. // If no department selected, show "Select Zone"
  215. if (!selectedDepartment) {
  216. departmentDropdown.val('');
  217. }
  218. },
  219. error: function (xhr, status, error) {
  220. console.error('Error fetching departments:', error);
  221. }
  222. });
  223. }
  224. // Load departments on page load
  225. const selectedDepartment = /*[[${selectedDepartment}]]*/ ''; // Get this from Thymeleaf or other server-side context
  226. loadDepartments(selectedDepartment);
  227. function fetchEnrollmentDetails(enrollmentId) {
  228. $.ajax({
  229. url: `/gcc/api/nulm/getEnrollmentdeatilsByID/${enrollmentId}`,
  230. type: 'GET',
  231. success: function (response) {
  232. if (response && response.length > 0) {
  233. const enrollment = response[0];
  234. // Populate modal fields with data
  235. $('#enrollmentId').val(enrollment.enrollment_id);
  236. $('#name').val(enrollment.name);
  237. $('#dateOfBirth').val(enrollment.date_of_birth);
  238. $('#gender').val(enrollment.gender);
  239. $('#designation').val(enrollment.designation);
  240. $('#inchargename').val(enrollment.incharge_name);
  241. $('#inchargeno').val(enrollment.incharge_phoneno);
  242. // Call fetchDropdownData and pass the existing group and order values
  243. fetchDropdownData(enrollment.group_id, enrollment.order_id);
  244. // Open the modal
  245. $('#editEnrollmentModal').modal('show');
  246. } else {
  247. alert('Enrollment details not found.');
  248. }
  249. },
  250. error: function (xhr, status, error) {
  251. console.error('Error fetching enrollment details:', error);
  252. alert('An error occurred while fetching enrollment details.');
  253. }
  254. });
  255. }
  256. function fetchDropdownData(selectedGroupId, selectedOrderId) {
  257. // Fetch Self Help Group dropdown
  258. $.ajax({
  259. url: '/gcc/api/nulm/selfHelpGroups',
  260. type: 'GET',
  261. success: function (response) {
  262. const selfHelpGroupDropdown = $('#shg');
  263. selfHelpGroupDropdown.empty(); // Clear existing options
  264. selfHelpGroupDropdown.append('<option value="">Select Self Help Group</option>');
  265. response.forEach(function (item) {
  266. const isSelected = item.groupId == selectedGroupId ? 'selected' : ''; // Check if this option should be selected
  267. selfHelpGroupDropdown.append(new Option(item.groupName, item.groupId, false, isSelected));
  268. });
  269. // If no group selected, show "Select Self Help Group"
  270. if (!selectedGroupId) {
  271. selfHelpGroupDropdown.val('');
  272. }
  273. },
  274. error: function (xhr, status, error) {
  275. console.error('Error fetching self-help groups:', error);
  276. }
  277. });
  278. // Fetch Order Number dropdown
  279. $.ajax({
  280. url: '/gcc/api/nulm/orderNumbers',
  281. type: 'GET',
  282. success: function (response) {
  283. const orderNumberDropdown = $('#orderNumber');
  284. orderNumberDropdown.empty(); // Clear existing options
  285. orderNumberDropdown.append('<option value="">Select Order Number</option>');
  286. response.forEach(function (item) {
  287. const isSelected = item.orderId == selectedOrderId ? 'selected' : ''; // Check if this option should be selected
  288. orderNumberDropdown.append(new Option(item.orderNumber, item.orderId, false, isSelected));
  289. });
  290. // If no order selected, show "Select Order Number"
  291. if (!selectedOrderId) {
  292. orderNumberDropdown.val('');
  293. }
  294. },
  295. error: function (xhr, status, error) {
  296. console.error('Error fetching order numbers:', error);
  297. }
  298. });
  299. }
  300. $('#updateEnrollmentButton').on('click', function () {
  301. const enrollmentId = $('#enrollmentId').val();
  302. const updatedData = {
  303. name: $('#name').val(),
  304. dateOfBirth: $('#dateOfBirth').val(),
  305. gender: $('#gender').val(),
  306. groupId: $('#shg').val(), // Get the selected group_id from dropdown
  307. orderId: $('#orderNumber').val() // Get the selected order_id from dropdown
  308. };
  309. $.ajax({
  310. url: `/gcc/api/nulm/updateEnrollment/${enrollmentId}`,
  311. type: 'POST',
  312. data: updatedData,
  313. success: function (response) {
  314. Swal.fire({
  315. title: 'Success!',
  316. text: 'Enrollment updated successfully!',
  317. icon: 'success',
  318. confirmButtonText: 'OK'
  319. }).then((result) => {
  320. if (result.isConfirmed) {
  321. $('#editEnrollmentModal').modal('hide'); // Hide the modal
  322. location.reload(); // Optionally reload the page to refresh the data
  323. }
  324. });
  325. },
  326. error: function (xhr, status, error) {
  327. console.error('Error updating enrollment details:', error);
  328. alert('An error occurred while updating enrollment details.');
  329. }
  330. });
  331. });
  332. });
  333. </script>
  334. </body>
  335. </html>