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.

916 lines
36 KiB

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-sm-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" placeholder="Enter your remarks here" 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. // DCRG File
  494. $('input[name="dcrg"][value="' + employeeDetails.dcrg + '"]').prop('checked', true);
  495. //$('#datefile').val('');
  496. $('#remarks').val('');
  497. }
  498. if (status === 5) {
  499. $('#gpfAmount').val('');
  500. $('#earnedleaveAmount').val('');
  501. $('#spfgsAmount').val('');
  502. $('#recoveryemployeevalue').val('');
  503. //$('#datefile').val('');
  504. $('#remarks').val('');
  505. $('input[name="gpf"]').prop('checked', false);
  506. $('input[name="earnedleave"]').prop('checked', false);
  507. $('input[name="spfgs"]').prop('checked', false);
  508. $('input[name="dcrg"]').prop('checked', false);
  509. $('#gpfAmountDiv').hide();
  510. $('#earnedleaveAmountDiv').hide();
  511. $('#spfgsAmountDiv').hide();
  512. $('#receivedcard').show();
  513. }
  514. });
  515. /* document.getElementById('sendtopension').addEventListener('click', function () {
  516. let employeeNo = $('#employeenomodel').val(); // Using jQuery to get the value
  517. // Trigger the save function and pass the value
  518. saveEntryDetails(tempId,employeeNo);
  519. }); */
  520. $('#sendtopension').off('click').on('click', function () {
  521. let employeeNo = $('#employeenomodel').val(); // Get the employee number
  522. saveEntryDetails(tempId, employeeNo); // Call function with parameters
  523. });
  524. } else {
  525. Swal.fire({
  526. icon: 'info',
  527. title: 'No Data',
  528. text: 'No details found for the selected employee.',
  529. confirmButtonText: 'OK',
  530. });
  531. }
  532. },
  533. error: function () {
  534. Swal.fire({
  535. icon: 'error',
  536. title: 'Error',
  537. text: 'Failed to fetch employee details. Please try again.',
  538. confirmButtonText: 'OK',
  539. });
  540. },
  541. });
  542. }
  543. $(document).ready(function () {
  544. $(document).on('click', '.view-btn', function () {
  545. const empCode = $(this).data('id'); // Fetch `data-id` value
  546. console.log("empCode====="+empCode);
  547. const tempId = $(this).data('temp-id'); // Fetch `data-temp-id` value
  548. // Hide the receivedcard section before showing the modal
  549. $("#receivedcard").hide();
  550. fetchEmployeeDetails(tempId); // Call the function to fetch employee details
  551. loadFileHistory(tempId); // Load the file history for the selected employee
  552. });
  553. // Initialize the modal with static backdrop and disabled keyboard closing
  554. $('#returnretrieddetailsModal').modal({
  555. backdrop: 'static',
  556. keyboard: false,
  557. show: false // Ensure it doesn't auto-show on page load
  558. });
  559. // Handle close button click
  560. $('#back').click(function () {
  561. $('#returnretrieddetailsModal').modal('hide');
  562. });
  563. $('.close').click(function () {
  564. $('#returnretrieddetailsModal').modal('hide');
  565. });
  566. });
  567. function loadFileHistory(tempId) {
  568. $.ajax({
  569. url: '/gcc/api/department/audit/fileMovementhistory', // API endpoint
  570. type: 'GET',
  571. data: { tempId: tempId }, // Pass empCode as a parameter
  572. success: function (response) {
  573. if (response.length > 0) {
  574. let historyHtml = '';
  575. response.forEach(item => {
  576. historyHtml += `
  577. <div class="file-history-item">
  578. <div class="file-history-date">${formatDateTime(item.fileMovedDateHistory)}</div>
  579. <div class="file-history-content">
  580. <div class="file-history-status">${item.fileStatusHistory}</div>
  581. <div class="file-history-remarks">Comments/Remarks: ${item.remarksHistory || 'N/A'}</div>
  582. </div>
  583. </div>
  584. `;
  585. });
  586. $('#fileHistoryContainer').html(historyHtml);
  587. } else {
  588. $('#fileHistoryContainer').html('<p>No file history available.</p>');
  589. }
  590. },
  591. error: function () {
  592. $('#fileHistoryContainer').html('<p>Failed to load file history. Please try again later.</p>');
  593. }
  594. });
  595. }
  596. // Function to format date and time
  597. function formatDateTime(dateString) {
  598. const options = {
  599. day: '2-digit',
  600. month: '2-digit',
  601. year: 'numeric',
  602. };
  603. return new Date(dateString).toLocaleDateString('en-GB', options); // Formats as dd-mm-yyyy
  604. }
  605. function saveEntryDetails(tempId,empCode) {
  606. //console.log("emp_no inside=="+empCode);
  607. // Get the selected GPF value
  608. let selectedGpfValue = $('input[name="gpf"]:checked').val(); // Get the selected radio button value
  609. let gpfAmount = null;
  610. // Check if GPF Amount input is visible and get its value
  611. if (selectedGpfValue === 'yes' || selectedGpfValue === '90') {
  612. gpfAmount = $('#gpfAmount').val(); // Retrieve the amount if available, else null
  613. if(!gpfAmount){
  614. Swal.fire({
  615. icon: 'warning',
  616. title: 'Validation Error!',
  617. text: 'GPF amount are required.',
  618. confirmButtonText: 'OK'
  619. });
  620. return;
  621. }
  622. }
  623. let selectedElValue = $('input[name="earnedleave"]:checked').val();
  624. let earnedleaveAmount=null;
  625. if (selectedElValue === 'yes') {
  626. earnedleaveAmount = $('#earnedleaveAmount').val(); // Retrieve the amount if available, else null
  627. if(!earnedleaveAmount){
  628. Swal.fire({
  629. icon: 'warning',
  630. title: 'Validation Error!',
  631. text: 'Earned Leave Amount are required.',
  632. confirmButtonText: 'OK'
  633. });
  634. return;
  635. }
  636. }
  637. let selectedspfgsValue = $('input[name="spfgs"]:checked').val();
  638. let spfgsAmount=null;
  639. if (selectedspfgsValue === 'yes') {
  640. spfgsAmount = $('#spfgsAmount').val(); // Retrieve the amount if available, else null
  641. if(!spfgsAmount){
  642. Swal.fire({
  643. icon: 'warning',
  644. title: 'Validation Error!',
  645. text: 'SPFGS amount are required.',
  646. confirmButtonText: 'OK'
  647. });
  648. return;
  649. }
  650. }
  651. //dcrf
  652. let selecteddcrgValue = $('input[name="dcrg"]:checked').val();
  653. let entryDetails = {
  654. empNo: empCode,
  655. tempId:tempId,
  656. file_moved_date:convertDateFormat($('#datefile').val()?.trim()),
  657. remarks: $('#remarks').val(),
  658. deptId:$('#deptId').text().trim(),
  659. filemovedby:$('#userId').text().trim(),
  660. gpf: selectedGpfValue, // Add GPF value (null if none selected)
  661. gpfAmount: gpfAmount || null, // Include the GPF amount
  662. private_affairs:selectedElValue,
  663. private_affairs_amount:earnedleaveAmount || null,
  664. spfgs:selectedspfgsValue,
  665. spfgs_amount:spfgsAmount || null,
  666. recovery_emp:$('#recoveryemployeevalue').val()|| null,
  667. dcrg:selecteddcrgValue
  668. };
  669. console.log("entryDetails:",entryDetails);
  670. if (!entryDetails.dcrg) {
  671. Swal.fire({
  672. icon: 'warning',
  673. title: 'Validation Error!',
  674. text: 'DCRG are required.',
  675. confirmButtonText: 'OK'
  676. });
  677. return;
  678. }
  679. if (!entryDetails.spfgs) {
  680. Swal.fire({
  681. icon: 'warning',
  682. title: 'Validation Error!',
  683. text: 'SPFGS are required.',
  684. confirmButtonText: 'OK'
  685. });
  686. return;
  687. }
  688. if (!entryDetails.private_affairs) {
  689. Swal.fire({
  690. icon: 'warning',
  691. title: 'Validation Error!',
  692. text: 'Private affairs are required.',
  693. confirmButtonText: 'OK'
  694. });
  695. return;
  696. }
  697. if (!entryDetails.gpf) {
  698. Swal.fire({
  699. icon: 'warning',
  700. title: 'Validation Error!',
  701. text: 'GPF are required.',
  702. confirmButtonText: 'OK'
  703. });
  704. return;
  705. }
  706. if (!entryDetails.remarks) {
  707. Swal.fire({
  708. icon: 'warning',
  709. title: 'Validation Error!',
  710. text: 'Remarks are required.',
  711. confirmButtonText: 'OK'
  712. });
  713. return;
  714. }
  715. $('#sendtopension').prop('disabled', true).text('Processing...');
  716. $.ajax({
  717. url: '/gcc/api/department/received/updateEmployeeDetails',
  718. type: 'POST',
  719. contentType: 'application/json',
  720. data: JSON.stringify(entryDetails),
  721. success: function (response) {
  722. $('#sendtopension').prop('disabled', false).text('Submit');
  723. Swal.fire({
  724. icon: 'success',
  725. title: 'Success',
  726. text: response,
  727. allowOutsideClick: false,
  728. allowEscapeKey: false,
  729. allowEnterKey: false,
  730. confirmButtonText: 'OK'
  731. }).then((result) => {
  732. if (result.isConfirmed) {
  733. $('#sendtopension').prop('disabled', false).text('Submit');
  734. window.location.href = "/gcc/department/received/retirement";
  735. console.log("Continue clicked");
  736. }
  737. });
  738. },
  739. error: function (xhr, status, error) {
  740. $('#sendtopension').prop('disabled', false).text('Submit');
  741. Swal.fire({
  742. icon: 'error',
  743. title: 'Error',
  744. text: 'Failed to save details. Please try again.',
  745. confirmButtonText: 'OK'
  746. });
  747. console.error('Error:', xhr.responseText);
  748. }
  749. });
  750. }
  751. //amount field validation
  752. function validatePositiveNumber(input) {
  753. if (input.value < 1) {
  754. input.value = "";
  755. }
  756. }
  757. </script>
  758. </body>
  759. </html>