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.

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