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.

388 lines
16 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html>
  3. <head th:replace="~{fragments/modules/base/head :: head}">
  4. <!-- Include Bootstrap CSS for styling the modal -->
  5. <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet">
  6. </head>
  7. <body>
  8. <div class="wrapper">
  9. <header th:replace="~{fragments/modules/base/header :: header}"></header>
  10. <div class="page-wrap">
  11. <div th:replace="~{fragments/modules/base/menu :: menu}"></div>
  12. <div class="main-content">
  13. <div class="container-fluid">
  14. <div class="page-header">
  15. <div class="row align-items-end">
  16. <div class="col-lg-6">
  17. <div class="page-header-title">
  18. <i class="ik ik-thumbs-up bg-blue"></i>
  19. <div class="d-inline">
  20. <h5>NULM STAFF</h5>
  21. <span>Salary Approval</span>
  22. </div>
  23. </div>
  24. </div>
  25. <div class="col-lg-6">
  26. <nav class="breadcrumb-container" aria-label="breadcrumb">
  27. <ol class="breadcrumb">
  28. <li class="breadcrumb-item">
  29. <a href="/index"><i class="ik ik-home"></i></a>
  30. </li>
  31. <li class="breadcrumb-item active" aria-current="page">Salary Approval</li>
  32. </ol>
  33. </nav>
  34. </div>
  35. </div>
  36. </div>
  37. <hr>
  38. <div class="row">
  39. <div class="col-sm-3">
  40. <label for="month">Month:</label>
  41. <select id="month" class="form-control" required>
  42. <option value="">Select</option>
  43. <option value="January">January</option>
  44. <option value="February">February</option>
  45. <option value="March">March</option>
  46. <option value="April">April</option>
  47. <option value="May">May</option>
  48. <option value="June">June</option>
  49. <option value="July">July</option>
  50. <option value="August">August</option>
  51. <option value="September">September</option>
  52. <option value="October">October</option>
  53. <option value="November">November</option>
  54. <option value="December">December</option>
  55. </select>
  56. </div>
  57. <div class="col-sm-3">
  58. <label for="year">Year:</label>
  59. <input type="number" id="year" class="form-control" min="2000" max="2100" required>
  60. </div>
  61. <div class="col-sm-3">
  62. <label for="salaryStatus">Salary Status:</label>
  63. <select id="salaryStatus" class="form-control">
  64. <option value="">Select</option>
  65. <option value="Initiated">Initiated</option>
  66. <option value="Approved">Approved</option>
  67. </select>
  68. </div>
  69. <div class="col-sm-3">
  70. <button class="btn btn-primary mt-4" onclick="fetchSalaryReport()">Get Salary Info</button>
  71. </div>
  72. </div>
  73. <div class="card-block mt-4">
  74. <div>
  75. <table id="salaryDatatable" class="table table-striped table-bordered table-hover dataTable" role="grid" width="99.5%">
  76. <thead class="thead-dark">
  77. <tr role="row">
  78. <th>S.No</th>
  79. <th>Incharge Name</th>
  80. <th>Total Staff Count</th>
  81. <th>Salary Processed</th>
  82. <th>Total Salary Amount</th>
  83. <th>Salary Status</th>
  84. <th>Action</th>
  85. </tr>
  86. </thead>
  87. <tbody>
  88. <tr th:each="salaryInitiatedCounts, i : ${salaryInitiatedCounts}">
  89. <td th:text="${i.count}">0</td>
  90. <td th:text="${salaryInitiatedCounts.incharge_name}"></td>
  91. <!-- Make the Total Staff Count clickable -->
  92. <td>
  93. <a href="#" class="total-staff-count"
  94. th:data-incharge-id="${salaryInitiatedCounts.incharge_id}"
  95. th:data-month="${salaryInitiatedCounts.month}"
  96. th:data-incharge-name="${salaryInitiatedCounts.incharge_name}"
  97. th:data-zone="${salaryInitiatedCounts.zone}"
  98. th:data-enrollment-ids="${salaryInitiatedCounts.enrollment_ids}"
  99. th:text="${salaryInitiatedCounts.total_staff_count}"
  100. data-toggle="modal" data-target="#shgModal">
  101. </a>
  102. </td>
  103. <td th:text="${salaryInitiatedCounts.total_approved_count}"></td>
  104. <td th:text="${salaryInitiatedCounts.total_salary_amount}"></td>
  105. <td th:text="${salaryInitiatedCounts.salary_status}"></td>
  106. <td>
  107. <span th:if="${salaryInitiatedCounts.salary_status == 'Approved'}" class="badge badge-success">Approved</span>
  108. <button th:if="${salaryInitiatedCounts.salary_status == 'Initiated'}"
  109. class="btn btn-primary approve-btn"
  110. th:data-enrollment-ids="${salaryInitiatedCounts.enrollment_ids}"
  111. th:data-month="${salaryInitiatedCounts.month}"
  112. th:data-year="${salaryInitiatedCounts.year}">
  113. Approve
  114. </button>
  115. </td>
  116. </tr>
  117. </tbody>
  118. <tfoot class="thead-dark">
  119. <tr>
  120. <th>S.No</th>
  121. <th>Incharge Name</th>
  122. <th>Total Staff Count</th>
  123. <th>Salary Processed</th>
  124. <th>Total Salary Amount</th>
  125. <th>Salary Status</th>
  126. <th>Action</th>
  127. </tr>
  128. </tfoot>
  129. </table>
  130. </div>
  131. </div>
  132. <!-- Modal for displaying staff details -->
  133. <div class="modal fade" id="shgModal" tabindex="-1" role="dialog" aria-labelledby="shgModalLabel" aria-hidden="true">
  134. <div class="modal-dialog modal-xl" role="document">
  135. <div class="modal-content">
  136. <div class="modal-header">
  137. <h5 class="modal-title" id="shgModalLabel">Staff Details</h5>
  138. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  139. <span aria-hidden="true">&times;</span>
  140. </button>
  141. </div>
  142. <div class="modal-body">
  143. <!-- Table for displaying attendance details -->
  144. <div id="attendanceDetailsContainer">
  145. <h5>Attendance Details</h5>
  146. <table class="table table-striped">
  147. <thead>
  148. <tr>
  149. <th>S.No</th>
  150. <th>Employee ID</th>
  151. <th>Name</th>
  152. <th>Year</th>
  153. <th>Month</th>
  154. <th>Total Days Present</th>
  155. <th>Total Days Absent</th>
  156. <th>Total Days OD</th>
  157. <th>Total Days Salary</th>
  158. <th>Total Salary</th>
  159. <th>Salary Status</th>
  160. </tr>
  161. </thead>
  162. <tbody id="attendanceDetailsTableBody">
  163. <!-- Dynamic content will be loaded here -->
  164. </tbody>
  165. </table>
  166. </div>
  167. </div>
  168. <div class="modal-footer">
  169. <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
  170. </div>
  171. </div>
  172. </div>
  173. </div>
  174. <footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
  175. </div>
  176. </div>
  177. <div th:replace="~{fragments/modules/pgr/modal-box :: div}"></div>
  178. <script th:replace="~{fragments/modules/base/script :: script}"></script>
  179. <script th:replace="~{fragments/modules/pgr/script :: script}"></script>
  180. <script th:inline="javascript">
  181. function fetchSalaryReport() {
  182. const month = document.getElementById('month').value;
  183. const year = document.getElementById('year').value;
  184. const salaryStatus = document.getElementById('salaryStatus').value;
  185. if (month && year) {
  186. window.location.href = `/gcc/nulm/salary-approve?month=${month}&year=${year}&salaryStatus=${salaryStatus}`;
  187. } else {
  188. alert("Please select both month and year.");
  189. }
  190. }
  191. $(document).ready(function () {
  192. function clearUrlParams() {
  193. const currentUrl = window.location.href;
  194. const urlWithoutParams = currentUrl.split('?')[0]; // Remove the query parameters
  195. window.history.replaceState({}, document.title, urlWithoutParams); // Replace the current URL without params
  196. }
  197. // Call this on page load to reset the URL
  198. clearUrlParams();
  199. // Initialize DataTable
  200. var table = $('#salaryDatatable').DataTable({
  201. dom: 'Bftip',
  202. columnDefs: [
  203. { targets: 'no-sort', orderable: false }
  204. ],
  205. lengthMenu: [
  206. [50, 100, 200, 500, -1],
  207. ['50 rows', '100 rows', '200 rows', 'Show all']
  208. ],
  209. scrollY: '50vh',
  210. fixedColumns: {
  211. left: 1,
  212. right: 1
  213. },
  214. buttons: [
  215. {
  216. extend: 'pageLength',
  217. className: 'btn btn-warning'
  218. },
  219. {
  220. title: 'Data export',
  221. extend: 'copyHtml5',
  222. text: 'Copy',
  223. className: 'btn btn-secondary',
  224. id: 'copyBtn',
  225. columns: [0,1,2,3,4,5]
  226. },
  227. {
  228. extend: 'pdfHtml5',
  229. text: 'PDF',
  230. className: 'btn btn-secondary',
  231. id: 'pdfBtn',
  232. exportOptions: {
  233. columns: [0, 1, 2, 3, 4, 5]
  234. }
  235. },
  236. /*
  237. {
  238. extend: 'excelHtml5',
  239. text: 'EXCEL',
  240. className: 'btn btn-secondary',
  241. id: 'excelBtn'
  242. },
  243. {
  244. extend: 'csvHtml5',
  245. text: 'CSV',
  246. className: 'btn btn-secondary',
  247. id: 'csvBtn'
  248. }*/
  249. ],
  250. fixedHeader: true,
  251. autoWidth: true,
  252. responsive: true,
  253. searching: true,
  254. select: false,
  255. processing: false
  256. });
  257. // Handle total-staff-count click event
  258. $('.total-staff-count').on('click', function (event) {
  259. event.preventDefault(); // Prevent default anchor click behavior
  260. // Get inchargeName and month from the clicked element's data attributes
  261. // var inchargeName = $(this).data('incharge-name');
  262. var inchargeId = $(this).data('incharge-id')
  263. var month = $(this).data('month')
  264. var inchargeName = $(this).data('incharge-name')
  265. var zone = $(this).data('zone');
  266. var enrollmentIds = $(this).data('enrollment-ids');
  267. console.log(zone);
  268. console.log(inchargeName);
  269. // Make the AJAX call to fetch attendance details
  270. $.ajax({
  271. url: '/gcc/api/nulm/staffInititeadList',
  272. method: 'GET',
  273. data: {
  274. //inchargeName: inchargeName,
  275. inchargeId: inchargeId,
  276. month: month,
  277. inchargeName: inchargeName,
  278. enrollmentIds: enrollmentIds.join(',')
  279. },
  280. success: function (data) {
  281. // Populate the modal's table with the fetched data
  282. var tbody = $('#attendanceDetailsTableBody');
  283. tbody.empty(); // Clear any previous data
  284. // Loop through the data and append rows to the table
  285. $.each(data, function (index, item) {
  286. var row = `<tr>
  287. <td>${index + 1}</td>
  288. <td>${item.emp_id}</td>
  289. <td>${item.name}</td>
  290. <td>${item.year}</td>
  291. <td>${item.month}</td>
  292. <td>${item.total_days_present}</td>
  293. <td>${item.total_days_absent}</td>
  294. <td>${item.total_days_od}</td>
  295. <td>${item.total_days_salary}</td>
  296. <td>${item.total_salary}</td>
  297. <td>${item.salary_status}</td>
  298. </tr>`;
  299. tbody.append(row);
  300. });
  301. // Show the modal after data is populated
  302. $('#shgModal').modal('show');
  303. },
  304. error: function (xhr, status, error) {
  305. console.error('Failed to fetch data:', error);
  306. alert('Failed to load staff details. Please try again.');
  307. }
  308. });
  309. });
  310. $(document).on('click', '.approve-btn', function () {
  311. var enrollmentIds = $(this).data('enrollment-ids'); // Get the data attribute
  312. var month = $(this).data('month');
  313. var year = $(this).data('year');
  314. // Confirm the action with SweetAlert
  315. Swal.fire({
  316. title: 'Are you sure?',
  317. text: 'Do you want to approve the selected enrollments?',
  318. icon: 'warning',
  319. showCancelButton: true,
  320. confirmButtonColor: '#3085d6',
  321. cancelButtonColor: '#d33',
  322. confirmButtonText: 'Yes, approve it!'
  323. }).then((result) => {
  324. if (result.isConfirmed) {
  325. // Make the AJAX call
  326. $.ajax({
  327. url: '/gcc/api/nulm/update-salary-status',
  328. method: 'POST',
  329. contentType: 'application/x-www-form-urlencoded',
  330. data: {
  331. // Pass the enrollment IDs as a comma-separated string
  332. enrollmentIds: enrollmentIds.join(','), // Convert array to a comma-separated string
  333. month: month,
  334. year: year
  335. },
  336. success: function (response) {
  337. Swal.fire(
  338. 'Approved!',
  339. response,
  340. 'success'
  341. );
  342. // Optionally refresh the table or update the UI
  343. location.reload();
  344. },
  345. error: function (xhr, status, error) {
  346. console.error('Failed to approve:', error);
  347. Swal.fire(
  348. 'Error!',
  349. 'Failed to approve the selected enrollments. Please try again.',
  350. 'error'
  351. );
  352. }
  353. });
  354. }
  355. });
  356. });
  357. });
  358. </script>
  359. </div>
  360. </div>
  361. </body>
  362. </html>