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.

917 lines
36 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
2 years ago
​
​
​
2 years ago
2 years ago
​
​
​
​
​
​
​
2 years ago
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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}"></head>
  5. <style>
  6. .required{
  7. color: red;
  8. }
  9. #returnretrieddetailsModal .modal-body{
  10. max-height:80vh;
  11. overflow-y:auto;
  12. }
  13. #returnretrieddetailsModal .col-md-4,.col-md-12{
  14. padding-bottom: 10px;
  15. }
  16. .file-history-list {
  17. margin-top: 10px;
  18. padding-left: 0;
  19. }
  20. .file-history-item {
  21. display: flex;
  22. padding: 5px 10px;
  23. font-family: Arial, sans-serif;
  24. align-items: flex-start;
  25. position: relative; /* For vertical line positioning */
  26. margin-bottom: 1px; /* Add space between items */
  27. }
  28. .file-history-item::before {
  29. content: '';
  30. position: absolute;
  31. top: 0;
  32. bottom: 0;
  33. left: 120px; /* Position of the vertical line */
  34. width: 1px;
  35. background-color: #ddd;
  36. }
  37. .file-history-date {
  38. margin-top: 10px;
  39. flex: 0 0 100px;
  40. font-weight: bold;
  41. font-size: 0.8rem;
  42. color: #333;
  43. text-align: center;
  44. white-space: nowrap; /* Prevent wrapping */
  45. }
  46. .file-history-content {
  47. flex: 5;
  48. padding-left: 20px; /* Adds space after the vertical line */
  49. display: flex;
  50. flex-direction: column;
  51. gap: 5px; /* Adds spacing between status and remarks */
  52. white-space: pre-wrap; /* Prevents wrapping */
  53. overflow: visible; /* Prevents content overflow */
  54. text-overflow: ellipsis; /* Adds ellipsis if content exceeds container width */
  55. }
  56. .file-history-status {
  57. font-size: 0.8rem;
  58. font-weight: bold;
  59. color: #555;
  60. white-space:pre-wrap; /* Prevent wrapping */
  61. overflow: visible;
  62. text-overflow: ellipsis;
  63. }
  64. .file-history-remarks {
  65. font-size: 0.8rem;
  66. color: #777;
  67. white-space: pre-wrap; /* Prevent wrapping */
  68. overflow: visible;
  69. text-overflow: ellipsis;
  70. }
  71. .col-md-4 .form-check{
  72. width: 25%;
  73. }
  74. .form-check-label{
  75. padding-top: 4%;
  76. }
  77. </style>
  78. <body>
  79. <!--[if lt IE 8]>
  80. <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>
  81. <![endif]-->
  82. <div class="wrapper">
  83. <!-- header top menu Start -->
  84. <header th:replace="~{fragments/modules/base/header :: header}"></header>
  85. <!-- header top menu end -->
  86. <div class="page-wrap">
  87. <!--=============== Left Menu side Start ================-->
  88. <div th:replace="~{fragments/modules/base/menu :: menu}"></div>
  89. <!--=============== Left side End ================-->
  90. <div class="main-content">
  91. <div class="container-fluid">
  92. <div class="page-header mb-2">
  93. <div class="row align-items-end">
  94. <div class="col-lg-8">
  95. <div class="page-header-title">
  96. <i class="fa fa-list-alt bg-blue"></i>
  97. <div class="d-inline">
  98. <h5>Retirement</h5>
  99. <span>Department Entries</span>
  100. </div>
  101. </div>
  102. </div>
  103. <div class="col-lg-4">
  104. <nav class="breadcrumb-container" aria-label="breadcrumb">
  105. <ol class="breadcrumb">
  106. <li class="breadcrumb-item"><a href="/gcc/index"><i class="ik ik-home"></i></a></li>
  107. <li class="breadcrumb-item" aria-current="page">Department Entries</li>
  108. <li class="breadcrumb-item" aria-current="page">Received From Pension</li>
  109. <li class="breadcrumb-item active" aria-current="page">Retirement</li>
  110. </ol>
  111. </nav>
  112. </div>
  113. </div>
  114. </div>
  115. <div class="row mt-4">
  116. <div class="col-md-12">
  117. <div class="card">
  118. <div class="card-block">
  119. <h5 style="font-weight:bold;"> <span th:text="${deptname}" id="deptname"></span>&nbsp;Department</h5>
  120. <h5 style="font-weight:bold;">Received From Pension - Retirement</h5>
  121. <h5 style="font-weight:bold;"><span th:text="${deptId}" id="deptId" style="display:none"></span></h5>
  122. <span th:text="${userId}" id="userId" style="display:none"></span>
  123. <div id="returnretriedtable">
  124. <table id="ReturnRetriedDatatable" class="table table-striped table-bordered table-hover dataTable" role="grid">
  125. <thead class="thead-dark">
  126. <tr role="row">
  127. <th class="text-center">S.No</th>
  128. <th class="text-center">Employee Code</th>
  129. <th class="text-center">Name </th>
  130. <th class="text-center">Department</th>
  131. <th class="text-center">Designation</th>
  132. <th class="text-center">File Sent Date</th>
  133. <th class="text-center">File Type</th>
  134. <th class="text-center">View</th>
  135. </tr>
  136. </thead>
  137. <tbody style="text-align:center;">
  138. <!-- Thymeleaf loop to populate data -->
  139. <tr th:each="received, iterStat : ${receivedlist}">
  140. <td th:text="${iterStat.index + 1}" class="text-center"></td>
  141. <td th:text="${received['emp_no']}" class="text-center"></td>
  142. <td th:text="${received['emp_name']}" class="text-center"></td>
  143. <td th:text="${received['dept_name']}" class="text-center"></td>
  144. <td th:text="${received['designation']}" class="text-center"></td>
  145. <td th:text="${received['file_moved_date'] != null ? #dates.format(received['file_moved_date'], 'dd-MM-yyyy') : 'N/A'}" class="text-center"></td>
  146. <td th:text="${received['file_entry_type']}" class="text-center"></td>
  147. <td class="text-center">
  148. <button class="btn btn-primary btn-sm view-btn" th:attr="data-id=${received['emp_no']}, data-temp-id=${received['temp_id']}">
  149. View
  150. </button>
  151. </td>
  152. </tr>
  153. </tbody>
  154. </table>
  155. </div>
  156. </div>
  157. </div>
  158. </div>
  159. </div>
  160. </div>
  161. </div>
  162. <footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
  163. </div>
  164. </div>
  165. <!-- Modal Box -->
  166. <div class="modal fade" id="returnretrieddetailsModal" tabindex="-1" role="dialog" aria-labelledby="detailsModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false">
  167. <div class="modal-dialog modal-xl" role="document">
  168. <div class="modal-content">
  169. <div class="modal-header">
  170. <h5 class="modal-title" id="detailsModalLabel">
  171. Received From Pension - Retirement (<span id="modalEmployeeCode"></span>)
  172. </h5>
  173. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  174. <span aria-hidden="true">&times;</span>
  175. </button>
  176. </div>
  177. <div class="modal-body">
  178. <div class="row">
  179. <!-- Employee No -->
  180. <div class="col-md-4">
  181. <label for="employeenomodel" class="form-label fw-bold">Employee No </label>
  182. <input type="number" id="employeenomodel" class="form-control" readonly>
  183. </div>
  184. <!-- Employee Name -->
  185. <div class="col-md-4">
  186. <label for="employeename" class="form-label fw-bold">Employee Name </label>
  187. <input type="text" id="employeename" class="form-control" readonly>
  188. </div>
  189. <!-- Department -->
  190. <div class="col-md-4">
  191. <label for="department" class="form-label fw-bold">Department </label>
  192. <input type="text" id="department" class="form-control" readonly>
  193. </div>
  194. <!-- Designation -->
  195. <div class="col-md-4">
  196. <label for="designation" class="form-label fw-bold">Designation </label>
  197. <input type="text" id="designation" class="form-control" readonly>
  198. </div>
  199. <div class="col-md-4">
  200. <label for="retirementdate" class="form-label fw-bold">Retirement Date </label>
  201. <input type="date" id="retirementdate" class="form-control" readonly>
  202. </div>
  203. <!-- Class -->
  204. <div class="col-md-4">
  205. <label for="classes" class="form-label fw-bold">Class </label>
  206. <input type="text" id="classes" class="form-control" readonly>
  207. </div>
  208. <!-- Type of Retirement -->
  209. <div class="col-md-4">
  210. <label for="typeofretirement" class="form-label fw-bold">Type of Retirement </label>
  211. <input type="text" id="typeofretirement" class="form-control" readonly>
  212. </div>
  213. <!-- Date File Sent to Audit -->
  214. <div class="col-md-4">
  215. <label for="datefile_modal" class="form-label fw-bold">File Forward to Department Date </label>
  216. <input type="date" id="datefile_modal" class="form-control" readonly>
  217. </div>
  218. <!-- Remarks -->
  219. <div class="col-md-12">
  220. <label for="remarks_modal" class="form-label fw-bold">Comments/Remarks </label>
  221. <textarea id="remarks_modal" class="form-control" rows="4" readonly></textarea>
  222. </div>
  223. <!-- new -->
  224. <div class="col-md-12 mt-4">
  225. <h5>File History</h5>
  226. <div id="fileHistoryContainer" class="file-history-list">
  227. <!-- File History will be dynamically loaded here -->
  228. </div>
  229. </div>
  230. </div>
  231. <div class="row mb-2 mt-2">
  232. <div class="col-md-12 d-flex justify-content-center">
  233. <button type="button" class="btn btn-primary mx-2" id="submitbutton">Add Zone/Department Benefits</button>
  234. <button type="button" class="btn btn-secondary" data-dismiss="modal" id="back">Back</button>
  235. </div>
  236. </div>
  237. <div style="display :none" id="receivedcard">
  238. <div class="row">
  239. <!-- GPF -->
  240. <div class="col-md-4 mb-2">
  241. <label class="form-label fw-bold">GPF<span class="text-danger">*</span></label>
  242. <div class="d-flex align-items-center gap-5">
  243. <div class="form-check">
  244. <input class="form-check-input" type="radio" id="gpfYes" name="gpf" value="yes">
  245. <label class="form-check-label" for="gpfYes">Yes</label>
  246. </div>
  247. <div class="form-check">
  248. <input class="form-check-input" type="radio" id="gpfNo" name="gpf" value="no">
  249. <label class="form-check-label" for="gpfNo">No</label>
  250. </div>
  251. <div class="form-check">
  252. <input class="form-check-input" type="radio" id="gpf50" name="gpf" value="90">
  253. <label class="form-check-label" for="gpf50">90%</label>
  254. </div>
  255. </div>
  256. <!-- Placeholder for dynamically added input -->
  257. <div id="gpfAmountDiv" class="mt-3" style="display: none;">
  258. <label for="gpfAmount" class="form-label">Enter GPF Amount<span class="text-danger">*</span></label>
  259. <input type="number" id="gpfAmount" class="form-control" placeholder="Enter GPF amount" min="1" oninput="validatePositiveNumber(this)">
  260. </div>
  261. </div>
  262. <!-- Earned Leave & Leave on Private Affairs -->
  263. <div class="col-md-4 mb-2">
  264. <label class="form-label fw-bold">Earned Leave & Leave on Private Affairs<span class="text-danger">*</span></label>
  265. <div class="d-flex align-items-center gap-5">
  266. <div class="form-check">
  267. <input class="form-check-input" type="radio" id="earnedleaveYes" name="earnedleave" value="yes">
  268. <label class="form-check-label" for="earnedleaveYes">Yes</label>
  269. </div>
  270. <div class="form-check">
  271. <input class="form-check-input" type="radio" id="earnedleaveNo" name="earnedleave" value="no">
  272. <label class="form-check-label" for="earnedleaveNo">No</label>
  273. </div>
  274. </div>
  275. <!-- Placeholder for dynamically added input -->
  276. <div id="earnedleaveAmountDiv" class="mt-3" style="display: none;">
  277. <label for="earnedleaveAmount" class="form-label">Enter EL and LPA Amount<span class="text-danger">*</span></label>
  278. <input type="number" id="earnedleaveAmount" class="form-control" placeholder="Enter Amount" min="1" oninput="validatePositiveNumber(this)">
  279. </div>
  280. </div>
  281. <!-- SPFGS -->
  282. <div class="col-md-4 mb-2">
  283. <label class="form-label fw-bold">SPFGS<span class="text-danger">*</span></label>
  284. <div class="d-flex align-items-center gap-5">
  285. <div class="form-check">
  286. <input class="form-check-input" type="radio" id="spfgsYes" name="spfgs" value="yes">
  287. <label class="form-check-label" for="spfgsYes">Yes</label>
  288. </div>
  289. <div class="form-check">
  290. <input class="form-check-input" type="radio" id="spfgsNo" name="spfgs" value="no">
  291. <label class="form-check-label" for="spfgsNo">No</label>
  292. </div>
  293. </div>
  294. <!-- Placeholder for dynamically added input -->
  295. <div id="spfgsAmountDiv" class="mt-3" style="display: none;">
  296. <label for="spfgsAmount" class="form-label">Enter SPFGS Amount<span class="text-danger">*</span></label>
  297. <input type="number" id="spfgsAmount" class="form-control" placeholder="Enter spfgs Amount" min="1" oninput="validatePositiveNumber(this)">
  298. </div>
  299. </div>
  300. <div class="col-md-4 mb-2">
  301. <label for="recoveryemployeevalue" class="form-label fw-bold">Recovery From Employee</label>
  302. <input type="text" id="recoveryemployeevalue" class="form-control" placeholder="Enter Recovery From Employee">
  303. </div>
  304. <!-- DCRF File is Ready -->
  305. <div class="col-md-4">
  306. <label class="form-label fw-bold">DCRG File is Ready<span class="text-danger">*</span></label>
  307. <div class="d-flex align-items-center gap-5">
  308. <div class="form-check">
  309. <input class="form-check-input" type="radio" id="dcrgYes" name="dcrg" value="yes">
  310. <label class="form-check-label" for="dcrgYes">Yes</label>
  311. </div>
  312. <div class="form-check">
  313. <input class="form-check-input" type="radio" id="dcrgNo" name="dcrg" value="no">
  314. <label class="form-check-label" for="dcrgNo">No</label>
  315. </div>
  316. </div>
  317. </div>
  318. </div>
  319. <div class="row">
  320. <!-- Date File Forwarded to Pension -->
  321. <div class="col-md-4">
  322. <label for="datefile" class="form-label fw-bold">Date File Forwarded to Pension <span class="text-danger">*</span></label>
  323. <input type="text" id="datefile" class="form-control" readonly>
  324. </div>
  325. <!-- Remarks -->
  326. <div class="col-md-12">
  327. <label for="remarks" class="form-label fw-bold">Comments/Remarks<span class="text-danger">*</span></label>
  328. <textarea id="remarks" class="form-control" rows="4" placeholder="Enter your remarks here"></textarea>
  329. </div>
  330. </div>
  331. <div class="row mb-2 mt-2">
  332. <div class="col-md-12 d-flex justify-content-center">
  333. <button type="button" class="btn btn-primary" id="sendtopension">Submit</button>
  334. </div>
  335. </div>
  336. </div>
  337. </div>
  338. </div>
  339. </div>
  340. </div>
  341. <div th:replace="~{fragments/modules/base/app_module_menu_box :: div}"></div>
  342. <script th:replace="~{fragments/modules/base/script :: script}"></script>
  343. <script src="node_modules/tempusdominus-bootstrap-4/build/js/tempusdominus-bootstrap-4.min.js"></script>
  344. <!-- Bootstrap 5 JS -->
  345. <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
  346. <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
  347. <script>
  348. $(document).ready(function () {
  349. // Initialize DataTable
  350. const table = $('#ReturnRetriedDatatable').DataTable({
  351. dom: 'Bftip',
  352. columnDefs: [
  353. { targets: 'no-sort', orderable: false }
  354. ],
  355. lengthMenu: [
  356. [50, 100, 200, 500, -1],
  357. ['50 rows', '100 rows', '200 rows', 'Show all']
  358. ],
  359. scrollY: '50vh',
  360. buttons: [
  361. { extend: 'pageLength', className: 'btn btn-warning' },
  362. { title: 'Data export', extend: 'copyHtml5', text: 'Copy', className: 'btn btn-secondary' },
  363. { extend: 'excelHtml5', text: 'Excel', className: 'btn btn-secondary' },
  364. { extend: 'csvHtml5', text: 'CSV', className: 'btn btn-secondary' },
  365. { extend: 'pdfHtml5', text: 'PDF', className: 'btn btn-secondary' }
  366. ],
  367. fixedHeader: true,
  368. autoWidth: true,
  369. responsive: true,
  370. searching: true,
  371. select: false,
  372. processing: false
  373. });
  374. document.getElementById("submitbutton").addEventListener("click", function () {
  375. // Clear the inputs in the receivedcard section
  376. //$('#datefile').val('');
  377. $('#remarks').val('');
  378. // Make the receivedcard section visible
  379. document.getElementById("receivedcard").style.display = "block";
  380. // Scroll the receivedcard section into view
  381. document.getElementById("receivedcard").scrollIntoView({
  382. behavior: "smooth", // Smooth scrolling effect
  383. block: "center" // Aligns the element to the center of the viewport
  384. });
  385. });
  386. // Listen for changes on the GPF radio buttons
  387. document.querySelectorAll('input[name="gpf"]').forEach(radio => {
  388. radio.addEventListener('change', function () {
  389. const gpfAmountDiv = document.getElementById('gpfAmountDiv');
  390. if (this.value === 'yes' || this.value === '90') {
  391. gpfAmountDiv.style.display = 'block'; // Show the input field
  392. } else {
  393. gpfAmountDiv.style.display = 'none'; // Hide the input field
  394. document.getElementById('gpfAmount').value = ''; // Clear the input field
  395. }
  396. });
  397. });
  398. // Listen for changes on the private affaires radio buttons
  399. document.querySelectorAll('input[name="earnedleave"]').forEach(radio => {
  400. radio.addEventListener('change', function () {
  401. const earnedleaveAmountDiv = document.getElementById('earnedleaveAmountDiv');
  402. if (this.value === 'yes') {
  403. earnedleaveAmountDiv.style.display = 'block'; // Show the input field
  404. } else {
  405. earnedleaveAmountDiv.style.display = 'none'; // Hide the input field
  406. document.getElementById('earnedleaveAmount').value = ''; // Clear the input field
  407. }
  408. });
  409. });
  410. // Listen for changes on the spfgs radio buttons
  411. document.querySelectorAll('input[name="spfgs"]').forEach(radio => {
  412. radio.addEventListener('change', function () {
  413. const spfgsAmountDiv = document.getElementById('spfgsAmountDiv');
  414. if (this.value === 'yes') {
  415. spfgsAmountDiv.style.display = 'block'; // Show the input field
  416. } else {
  417. spfgsAmountDiv.style.display = 'none'; // Hide the input field
  418. document.getElementById('spfgsAmount').value = ''; // Clear the input field
  419. }
  420. });
  421. });
  422. });
  423. document.addEventListener("DOMContentLoaded", function() {
  424. // Get today's date
  425. const today = new Date();
  426. // Format the date as DD-MM-YYYY for display
  427. const day = String(today.getDate()).padStart(2, '0');
  428. const month = String(today.getMonth() + 1).padStart(2, '0'); // Months are 0-based
  429. const year = today.getFullYear();
  430. // Combine into DD-MM-YYYY format for display
  431. const formattedDateDisplay = `${day}-${month}-${year}`;
  432. // Set the value of the input field to the current date (in DD-MM-YYYY format for display)
  433. document.getElementById("datefile").value = formattedDateDisplay;
  434. });
  435. function convertDateFormat(dateString) {
  436. if (!dateString) return '';
  437. let [day, month, year] = dateString.split('-');
  438. return `${year}-${month}-${day}`;
  439. }
  440. //model function
  441. function fetchEmployeeDetails(tempId) {
  442. $.ajax({
  443. url: '/gcc/api/department/audit/getzonebenefitsdetails', // API to fetch employee details
  444. type: 'GET',
  445. data: { tempId: tempId }, // Pass EMPLOYEE_CODE as a parameter
  446. success: function (response) {
  447. if (response && response.length > 0) {
  448. let employeeDetails = response[0]; // Access the first object in the array
  449. console.log("response:",response);
  450. // Populate modal fields
  451. $('#employeenomodel').val(employeeDetails.emp_no);
  452. $('#employeename').val(employeeDetails.emp_name);
  453. $('#department').val(employeeDetails.dept_name);
  454. $('#designation').val(employeeDetails.designation);
  455. $('#typeofretirement').val(employeeDetails.type_of_retirement);
  456. $('#classes').val(employeeDetails.retirement_class);
  457. $('#datefile_modal').val(employeeDetails.file_moved_date);
  458. $('#remarks_modal').val(employeeDetails.remarks);
  459. $('#retirementdate').val(employeeDetails.retirement_date);
  460. // Update the modal title with the employee code
  461. $('#modalEmployeeCode').text(employeeDetails.emp_no);
  462. // Show the modal
  463. $('#returnretrieddetailsModal').modal('show');
  464. let status=employeeDetails.file_status;
  465. console.log("status=:"+status);
  466. $('#submitbutton').off('click').on('click', function() {
  467. if (status === 6) {
  468. $('#receivedcard').show();
  469. // GPF
  470. $('input[name="gpf"][value="' + employeeDetails.gpf + '"]').prop('checked', true);
  471. if (employeeDetails.gpf === "yes" || employeeDetails.gpf === "90") {
  472. $('#gpfAmountDiv').show();
  473. $('#gpfAmount').val(employeeDetails.gpf_amount);
  474. } else {
  475. $('#gpfAmountDiv').hide();
  476. }
  477. // Earned Leave & Leave on Private Affairs
  478. $('input[name="earnedleave"][value="' + employeeDetails.private_affairs + '"]').prop('checked', true);
  479. if (employeeDetails.private_affairs === "yes") {
  480. $('#earnedleaveAmountDiv').show();
  481. $('#earnedleaveAmount').val(employeeDetails.private_affairs_amount);
  482. } else {
  483. $('#earnedleaveAmountDiv').hide();
  484. }
  485. // SPFGS
  486. $('input[name="spfgs"][value="' + employeeDetails.spfgs + '"]').prop('checked', true);
  487. if (employeeDetails.spfgs === "yes") {
  488. $('#spfgsAmountDiv').show();
  489. $('#spfgsAmount').val(employeeDetails.spfgs_amount);
  490. } else {
  491. $('#spfgsAmountDiv').hide();
  492. }
  493. //recover emp
  494. $('#recoveryemployeevalue').val(employeeDetails.recovery_emp);
  495. // DCRG File
  496. $('input[name="dcrg"][value="' + employeeDetails.dcrg + '"]').prop('checked', true);
  497. //$('#datefile').val('');
  498. //$('#remarks').val('');
  499. }
  500. if (status === 5) {
  501. $('#gpfAmount').val('');
  502. $('#earnedleaveAmount').val('');
  503. $('#spfgsAmount').val('');
  504. $('#recoveryemployeevalue').val('');
  505. //$('#datefile').val('');
  506. //$('#remarks').val('');
  507. $('input[name="gpf"]').prop('checked', false);
  508. $('input[name="earnedleave"]').prop('checked', false);
  509. $('input[name="spfgs"]').prop('checked', false);
  510. $('input[name="dcrg"]').prop('checked', false);
  511. $('#gpfAmountDiv').hide();
  512. $('#earnedleaveAmountDiv').hide();
  513. $('#spfgsAmountDiv').hide();
  514. $('#receivedcard').show();
  515. }
  516. });
  517. /* document.getElementById('sendtopension').addEventListener('click', function () {
  518. let employeeNo = $('#employeenomodel').val(); // Using jQuery to get the value
  519. // Trigger the save function and pass the value
  520. saveEntryDetails(tempId,employeeNo);
  521. }); */
  522. $('#sendtopension').off('click').on('click', function () {
  523. let employeeNo = $('#employeenomodel').val(); // Get the employee number
  524. saveEntryDetails(tempId, employeeNo); // Call function with parameters
  525. });
  526. } else {
  527. Swal.fire({
  528. icon: 'info',
  529. title: 'No Data',
  530. text: 'No details found for the selected employee.',
  531. confirmButtonText: 'OK',
  532. });
  533. }
  534. },
  535. error: function () {
  536. Swal.fire({
  537. icon: 'error',
  538. title: 'Error',
  539. text: 'Failed to fetch employee details. Please try again.',
  540. confirmButtonText: 'OK',
  541. });
  542. },
  543. });
  544. }
  545. $(document).ready(function () {
  546. $(document).on('click', '.view-btn', function () {
  547. const empCode = $(this).data('id'); // Fetch `data-id` value
  548. console.log("empCode====="+empCode);
  549. const tempId = $(this).data('temp-id'); // Fetch `data-temp-id` value
  550. // Hide the receivedcard section before showing the modal
  551. $("#receivedcard").hide();
  552. fetchEmployeeDetails(tempId); // Call the function to fetch employee details
  553. loadFileHistory(tempId); // Load the file history for the selected employee
  554. });
  555. // Initialize the modal with static backdrop and disabled keyboard closing
  556. $('#returnretrieddetailsModal').modal({
  557. backdrop: 'static',
  558. keyboard: false,
  559. show: false // Ensure it doesn't auto-show on page load
  560. });
  561. // Handle close button click
  562. $('#back').click(function () {
  563. $('#returnretrieddetailsModal').modal('hide');
  564. });
  565. $('.close').click(function () {
  566. $('#returnretrieddetailsModal').modal('hide');
  567. });
  568. });
  569. function loadFileHistory(tempId) {
  570. $.ajax({
  571. url: '/gcc/api/department/audit/fileMovementhistory', // API endpoint
  572. type: 'GET',
  573. data: { tempId: tempId }, // Pass empCode as a parameter
  574. success: function (response) {
  575. if (response.length > 0) {
  576. let historyHtml = '';
  577. response.forEach(item => {
  578. historyHtml += `
  579. <div class="file-history-item">
  580. <div class="file-history-date">${formatDateTime(item.fileMovedDateHistory)}</div>
  581. <div class="file-history-content">
  582. <div class="file-history-status">${item.fileStatusHistory}</div>
  583. <div class="file-history-remarks">Comments/Remarks: ${item.remarksHistory || 'N/A'}</div>
  584. </div>
  585. </div>
  586. `;
  587. });
  588. $('#fileHistoryContainer').html(historyHtml);
  589. } else {
  590. $('#fileHistoryContainer').html('<p>No file history available.</p>');
  591. }
  592. },
  593. error: function () {
  594. $('#fileHistoryContainer').html('<p>Failed to load file history. Please try again later.</p>');
  595. }
  596. });
  597. }
  598. // Function to format date and time
  599. function formatDateTime(dateString) {
  600. const options = {
  601. day: '2-digit',
  602. month: '2-digit',
  603. year: 'numeric',
  604. };
  605. return new Date(dateString).toLocaleDateString('en-GB', options); // Formats as dd-mm-yyyy
  606. }
  607. function saveEntryDetails(tempId,empCode) {
  608. //console.log("emp_no inside=="+empCode);
  609. // Get the selected GPF value
  610. let selectedGpfValue = $('input[name="gpf"]:checked').val(); // Get the selected radio button value
  611. let gpfAmount = null;
  612. // Check if GPF Amount input is visible and get its value
  613. if (selectedGpfValue === 'yes' || selectedGpfValue === '90') {
  614. gpfAmount = $('#gpfAmount').val(); // Retrieve the amount if available, else null
  615. if(!gpfAmount){
  616. Swal.fire({
  617. icon: 'warning',
  618. title: 'Validation Error!',
  619. text: 'GPF amount are required.',
  620. confirmButtonText: 'OK'
  621. });
  622. return;
  623. }
  624. }
  625. let selectedElValue = $('input[name="earnedleave"]:checked').val();
  626. let earnedleaveAmount=null;
  627. if (selectedElValue === 'yes') {
  628. earnedleaveAmount = $('#earnedleaveAmount').val(); // Retrieve the amount if available, else null
  629. if(!earnedleaveAmount){
  630. Swal.fire({
  631. icon: 'warning',
  632. title: 'Validation Error!',
  633. text: 'Earned Leave Amount are required.',
  634. confirmButtonText: 'OK'
  635. });
  636. return;
  637. }
  638. }
  639. let selectedspfgsValue = $('input[name="spfgs"]:checked').val();
  640. let spfgsAmount=null;
  641. if (selectedspfgsValue === 'yes') {
  642. spfgsAmount = $('#spfgsAmount').val(); // Retrieve the amount if available, else null
  643. if(!spfgsAmount){
  644. Swal.fire({
  645. icon: 'warning',
  646. title: 'Validation Error!',
  647. text: 'SPFGS amount are required.',
  648. confirmButtonText: 'OK'
  649. });
  650. return;
  651. }
  652. }
  653. //dcrf
  654. let selecteddcrgValue = $('input[name="dcrg"]:checked').val();
  655. let entryDetails = {
  656. empNo: empCode,
  657. tempId:tempId,
  658. file_moved_date:convertDateFormat($('#datefile').val()?.trim()),
  659. remarks: $('#remarks').val(),
  660. deptId:$('#deptId').text().trim(),
  661. filemovedby:$('#userId').text().trim(),
  662. gpf: selectedGpfValue, // Add GPF value (null if none selected)
  663. gpfAmount: gpfAmount || null, // Include the GPF amount
  664. private_affairs:selectedElValue,
  665. private_affairs_amount:earnedleaveAmount || null,
  666. spfgs:selectedspfgsValue,
  667. spfgs_amount:spfgsAmount || null,
  668. recovery_emp:$('#recoveryemployeevalue').val()|| null,
  669. dcrg:selecteddcrgValue
  670. };
  671. console.log("entryDetails:",entryDetails);
  672. if (!entryDetails.dcrg) {
  673. Swal.fire({
  674. icon: 'warning',
  675. title: 'Validation Error!',
  676. text: 'DCRG are required.',
  677. confirmButtonText: 'OK'
  678. });
  679. return;
  680. }
  681. if (!entryDetails.spfgs) {
  682. Swal.fire({
  683. icon: 'warning',
  684. title: 'Validation Error!',
  685. text: 'SPFGS are required.',
  686. confirmButtonText: 'OK'
  687. });
  688. return;
  689. }
  690. if (!entryDetails.private_affairs) {
  691. Swal.fire({
  692. icon: 'warning',
  693. title: 'Validation Error!',
  694. text: 'Private affairs are required.',
  695. confirmButtonText: 'OK'
  696. });
  697. return;
  698. }
  699. if (!entryDetails.gpf) {
  700. Swal.fire({
  701. icon: 'warning',
  702. title: 'Validation Error!',
  703. text: 'GPF are required.',
  704. confirmButtonText: 'OK'
  705. });
  706. return;
  707. }
  708. if (!entryDetails.remarks) {
  709. Swal.fire({
  710. icon: 'warning',
  711. title: 'Validation Error!',
  712. text: 'Remarks are required.',
  713. confirmButtonText: 'OK'
  714. });
  715. return;
  716. }
  717. $('#sendtopension').prop('disabled', true).text('Processing...');
  718. $.ajax({
  719. url: '/gcc/api/department/received/updateEmployeeDetails',
  720. type: 'POST',
  721. contentType: 'application/json',
  722. data: JSON.stringify(entryDetails),
  723. success: function (response) {
  724. $('#sendtopension').prop('disabled', false).text('Submit');
  725. Swal.fire({
  726. icon: 'success',
  727. title: 'Success',
  728. text: response,
  729. allowOutsideClick: false,
  730. allowEscapeKey: false,
  731. allowEnterKey: false,
  732. confirmButtonText: 'OK'
  733. }).then((result) => {
  734. if (result.isConfirmed) {
  735. $('#sendtopension').prop('disabled', false).text('Submit');
  736. window.location.href = "/gcc/department/received/retirement";
  737. console.log("Continue clicked");
  738. }
  739. });
  740. },
  741. error: function (xhr, status, error) {
  742. $('#sendtopension').prop('disabled', false).text('Submit');
  743. Swal.fire({
  744. icon: 'error',
  745. title: 'Error',
  746. text: 'Failed to save details. Please try again.',
  747. confirmButtonText: 'OK'
  748. });
  749. console.error('Error:', xhr.responseText);
  750. }
  751. });
  752. }
  753. //amount field validation
  754. function validatePositiveNumber(input) {
  755. if (input.value < 1) {
  756. input.value = "";
  757. }
  758. }
  759. </script>
  760. </body>
  761. </html>