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.

945 lines
38 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. #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. .card-block {
  79. padding: 20px;
  80. }
  81. .form-label {
  82. margin-bottom: 0.5rem;
  83. }
  84. input.form-control {
  85. padding: 10px;
  86. }
  87. .form-select {
  88. padding: 10px;
  89. height: 40px;
  90. }
  91. #employeeCard label{
  92. padding-top: 2%;
  93. }
  94. </style>
  95. <body>
  96. <!--[if lt IE 8]>
  97. <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>
  98. <![endif]-->
  99. <div class="wrapper">
  100. <!-- header top menu Start -->
  101. <header th:replace="~{fragments/modules/base/header :: header}"></header>
  102. <!-- header top menu end -->
  103. <div class="page-wrap">
  104. <!--=============== Left Menu side Start ================-->
  105. <div th:replace="~{fragments/modules/base/menu :: menu}"></div>
  106. <!--=============== Left side End ================-->
  107. <div class="main-content">
  108. <div class="container-fluid">
  109. <div class="page-header mb-2">
  110. <div class="row align-items-end">
  111. <div class="col-lg-8">
  112. <div class="page-header-title">
  113. <i class="fa fa-list-alt bg-blue"></i>
  114. <div class="d-inline">
  115. <h5>Department Entries</h5>
  116. <span>Contributory Pension Scheme</span>
  117. </div>
  118. </div>
  119. </div>
  120. <div class="col-lg-4">
  121. <nav class="breadcrumb-container" aria-label="breadcrumb">
  122. <ol class="breadcrumb">
  123. <li class="breadcrumb-item"><a href="/gcc/index"><i class="ik ik-home"></i></a></li>
  124. <li class="breadcrumb-item" aria-current="page">Department Entries</li>
  125. <li class="breadcrumb-item" aria-current="page">NewEntry</li>
  126. <li class="breadcrumb-item active" aria-current="page">Contributory Pension Scheme</li>
  127. </ol>
  128. </nav>
  129. </div>
  130. </div>
  131. </div>
  132. <div class="row mt-4" >
  133. <div class="col-md-12">
  134. <div class="card">
  135. <div class="card-block">
  136. <h5 style="font-weight:bold;">New Entry - Contributory Pension</h5><span th:text="${filecategory}" id="filecategory" style="display:none"></span>
  137. <h5 style="font-weight:bold;"><span th:text="${deptId}" id="deptId" style="display:none"></span></h5>
  138. <span th:text="${userId}" id="userId" style="display:none"></span>
  139. <div class="row mb-4">
  140. <!-- Input Fields for Year Selection -->
  141. <!-- Start Year Dropdown as Button Dropdown -->
  142. <div class="col-md-4" >
  143. <label for="empCode" class="form-label fw-bold">Search by Employee No <span class="text-danger">*</span></label>
  144. <div class="dropdown">
  145. <input type="number" id="empCode" class="form-control" pattern="^[A-Za-z0-9]+$" placeholder="Enter Employee No" required>
  146. <small id="employeenoHelp" class="form-text text-muted">Only numeric characters (numbers) are allowed.</small>
  147. </div>
  148. </div>
  149. <div class="col-md-4 mt-20">
  150. <button id="searchButton" class="btn btn-primary mt-2" Style="height:38px;">Search</button>
  151. <!-- <button id="resetButton" class="btn btn-secondary mt-2">Reset</button> -->
  152. </div>
  153. </div>
  154. </div>
  155. </div>
  156. </div>
  157. </div>
  158. <div class="row mb-4" id="employeeCard" style="display: none;">
  159. <div class="col-md-12">
  160. <div class="card">
  161. <div class="card-block">
  162. <h5 style="font-weight:bold;">New Entry - Contributory Pension - <span id="EmployeeCode"></span></h5>
  163. <hr>
  164. <div class="row">
  165. <!-- Employee No -->
  166. <div class="col-md-6">
  167. <label for="employeeno" class="form-label fw-bold">Employee No <span class="text-danger">*</span></label>
  168. <div class="dropdown">
  169. <input type="number" id="employeeno" class="form-control" readonly>
  170. </div>
  171. </div>
  172. <!-- Employee Name -->
  173. <div class="col-md-6">
  174. <label for="employeename" class="form-label fw-bold">Employee Name <span class="text-danger">*</span></label>
  175. <div class="dropdown">
  176. <input type="text" id="employeename" class="form-control" readonly>
  177. </div>
  178. </div>
  179. <div class="col-md-6">
  180. <label for="Department" class="form-label fw-bold">Department <span class="text-danger">*</span></label>
  181. <div class="dropdown">
  182. <input type="text" id="department" class="form-control" readonly>
  183. </div>
  184. </div>
  185. <div class="col-md-6">
  186. <label for="Designation" class="form-label fw-bold">Designation<span class="text-danger">*</span></label>
  187. <div class="dropdown">
  188. <input type="text" id="designation" class="form-control" readonly>
  189. </div>
  190. </div>
  191. <div class="col-md-6">
  192. <label for="classes" class="form-label fw-bold">Class<span class="text-danger">*</span></label>
  193. <div class="dropdown" >
  194. <input type="text" id="classes" class="form-control" readonly>
  195. </div>
  196. </div>
  197. <div class="col-md-6">
  198. <label for="retirement" class="form-label fw-bold">Type Of Retirement<span class="text-danger">*</span></label>
  199. <div class="dropdown" >
  200. <select id="retirement" class="form-select" style="width: 100%;" required>
  201. </select>
  202. </div>
  203. </div>
  204. <div class="col-md-6">
  205. <label for="filesentuac" class="form-label fw-bold">
  206. Whether file sent to UAC (if yes, Date)
  207. <span class="text-danger">*</span>
  208. </label>
  209. <div class="d-flex align-items-center">
  210. <div class="form-check" style="padding-right:10px;">
  211. <input type="radio" id="yes" name="filesentuac" class="form-check-input" value="yes">
  212. <label for="yes" class="form-check-label">Yes</label>
  213. </div>
  214. <br>
  215. <div class="form-check">
  216. <input type="radio" id="no" name="filesentuac" class="form-check-input" value="no">
  217. <label for="no" class="form-check-label">No</label>
  218. </div>
  219. </div>
  220. <div class="dropdown" id="dateInputContainer" style="display: none; margin-top: 10px;">
  221. <input type="date" id="dateInput" name="filesentuac_date" class="form-control" onclick="this.showPicker()" >
  222. </div>
  223. </div>
  224. <div class="col-md-6">
  225. <label for="pendingDuration" class="form-label fw-bold">
  226. Pending Duration
  227. <span class="text-danger">*</span>
  228. </label>
  229. <div class="d-flex align-items-center">
  230. <div class="form-check" style="padding-right:10px;">
  231. <input type="radio" id="pendingDurationYes" name="pendingDuration" value="yes" class="form-check-input">
  232. <label for="pendingDurationYes" class="form-check-label">Yes</label>
  233. </div>
  234. <div class="form-check">
  235. <input type="radio" id="pendingDurationNo" name="pendingDuration" value="no" class="form-check-input">
  236. <label for="pendingDurationNo" class="form-check-label">No</label>
  237. </div>
  238. </div>
  239. <div class="dropdown" id="pendingDurationInputContainer" style="display: none; margin-top: 10px;">
  240. <input type="text" id="pendingDurationInput" name="pendingDurationValue" class="form-control" placeholder="Enter details for pending duration">
  241. </div>
  242. </div>
  243. <div class="col-md-6">
  244. <label for="cpsamount" class="form-label fw-bold">
  245. Whether CPS Amount Settled
  246. <span class="text-danger">*</span>
  247. </label>
  248. <div class="d-flex align-items-center">
  249. <div class="form-check" style="padding-right:10px;">
  250. <input type="radio" id="yes1" name="cpsamount" class="form-check-input" value="yes">
  251. <label for="yes1" class="form-check-label">Yes</label>
  252. </div>
  253. <div class="form-check">
  254. <input type="radio" id="no1" name="cpsamount" class="form-check-input" value="no">
  255. <label for="no1" class="form-check-label">No</label>
  256. </div>
  257. </div>
  258. <div class="dropdown" id="cpsAmountInputContainer" style="display: none; margin-top: 10px;">
  259. <input type="number" id="cpsAmountInput" name="cpsamount_value" class="form-control"
  260. placeholder="Enter CPS Amount" min="1" oninput="validatePositiveNumber(this)">
  261. </div>
  262. </div>
  263. <div class="col-md-6">
  264. <label for="elamount" class="form-label fw-bold">
  265. Whether EL/LPA Amount Settled
  266. <span class="text-danger">*</span>
  267. </label>
  268. <div class="d-flex align-items-center">
  269. <div class="form-check" style="padding-right:10px;">
  270. <input type="radio" id="yes2" name="elamount" class="form-check-input" value="yes">
  271. <label for="yes2" class="form-check-label">Yes</label>
  272. </div>
  273. <div class="form-check">
  274. <input type="radio" id="no2" name="elamount" class="form-check-input" value="no">
  275. <label for="no2" class="form-check-label">No</label>
  276. </div>
  277. </div>
  278. <div class="dropdown" id="elAmountInputContainer" style="display: none; margin-top: 10px;">
  279. <input type="number" id="elAmountInput" name="elamount_value" class="form-control"
  280. placeholder="Enter EL/LPA Amount" min="1" oninput="validatePositiveNumber(this)">
  281. </div>
  282. </div>
  283. <div class="col-md-6">
  284. <label for="spfgsamount" class="form-label fw-bold">
  285. Whether SPFGS Amount Settled
  286. <span class="text-danger">*</span>
  287. </label>
  288. <div class="d-flex align-items-center">
  289. <div class="form-check" style="padding-right:10px;">
  290. <input type="radio" id="yes3" name="spfgsamount" class="form-check-input" value="yes">
  291. <label for="yes3" class="form-check-label">Yes</label>
  292. </div>
  293. <div class="form-check">
  294. <input type="radio" id="no3" name="spfgsamount" class="form-check-input" value="no">
  295. <label for="no3" class="form-check-label">No</label>
  296. </div>
  297. </div>
  298. <div class="dropdown" id="spfgsAmountInputContainer" style="display: none; margin-top: 10px;">
  299. <input type="number" id="spfgsAmountInput" name="spfgsamount_value" class="form-control"
  300. placeholder="Enter SPFGS Amount" min="1" oninput="validatePositiveNumber(this)">
  301. </div>
  302. </div>
  303. <div class="col-md-12">
  304. <label for="Remarks" class="form-label fw-bold">Comments/Remarks <span class="text-danger">*</span></label>
  305. <div class="dropdown">
  306. <textarea id="remarks" class="form-control" rows="4" placeholder="Enter your remarks here" required></textarea>
  307. </div>
  308. </div>
  309. </div>
  310. <div class="row mt-4">
  311. <div class="col-12 d-flex justify-content-center">
  312. <button id="lfauditButton" class="btn btn-primary mt-2 mx-2">Submit</button>
  313. <button id="cancelButton" class="btn btn-secondary mt-2">Cancel</button>
  314. </div>
  315. </div>
  316. </div>
  317. </div>
  318. </div>
  319. </div>
  320. </div>
  321. </div>
  322. <div id="pageLoader" style="display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255, 255, 255, 0.8); z-index: 9999; text-align: center;">
  323. <div style="position: relative; top: 50%; transform: translateY(-50%);">
  324. <div class="spinner-border text-primary" role="status" style="width: 3rem; height: 3rem;">
  325. <span class="sr-only">Loading...</span>
  326. </div>
  327. <!-- Add the 'Please wait' text below the spinner -->
  328. <p style="margin-top: 1rem; font-size: 1.2rem; color: #007bff;">Please wait...</p>
  329. </div>
  330. </div>
  331. <footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
  332. </div>
  333. </div>
  334. <div th:replace="~{fragments/modules/base/app_module_menu_box :: div}"></div>
  335. <script th:replace="~{fragments/modules/base/script :: script}"></script>
  336. <script src="node_modules/tempusdominus-bootstrap-4/build/js/tempusdominus-bootstrap-4.min.js"></script>
  337. <!-- Bootstrap 5 JS -->
  338. <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
  339. <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
  340. <script>
  341. $(document).ready(function (){
  342. // Handle Search button click
  343. $('#searchButton').on('click', function () {
  344. const empCode = $('#empCode').val();
  345. console.log("empCode",empCode);
  346. if (empCode) {
  347. $('#pageLoader').show();
  348. document.getElementById("employeeCard").style.display = "block";
  349. }else{
  350. Swal.fire({
  351. icon: "warning", // Display a warning icon
  352. title: "Missing Employee Number",
  353. text: "Please enter an employee number to proceed.",
  354. confirmButtonText: "OK",
  355. customClass: {
  356. confirmButton: "btn btn-primary" // Optional styling for the button
  357. }
  358. });
  359. //document.getElementById("newemployeeCard").style.display = "block";
  360. return; // Stop further execution if empCode is not provided
  361. }
  362. // Format dates to dd-MM-yyyy
  363. $('#pageLoader').show();
  364. $('#employeeCard').hide();
  365. $('#newemployeeCard').hide();
  366. $('#retirement').val('');
  367. $('#dateInput').val('');
  368. $('#remarks').val('');
  369. $('#pendingDurationInput').val('');
  370. $('#cpsAmountInput').val('');
  371. $('#elAmountInput').val('');
  372. $('#spfgsAmountInput').val('');
  373. $('input[name="filesentuac"]').prop('checked', false);
  374. $('input[name="pendingDuration"]').prop('checked', false);
  375. $('input[name="cpsamount"]').prop('checked', false);
  376. $('input[name="elamount"]').prop('checked', false);
  377. $('input[name="spfgsamount"]').prop('checked', false);
  378. // Call the API
  379. $('#pageLoader').show();
  380. $.ajax({
  381. url: '/gcc/api/department/newentry/cpsexists', // Endpoint to check existence
  382. type: 'GET',
  383. data: { empCode: empCode },
  384. success: function (existsResponse) {
  385. console.log("Exists API Response:", existsResponse);
  386. $('#pageLoader').hide(); // Hide loader after the first API response
  387. if (existsResponse && existsResponse.exists) {
  388. console.log(`Employee Code ${empCode} exists in the database.`);
  389. Swal.fire({
  390. icon: "warning",
  391. title: "Already Exists",
  392. text: "This employee number already exists.",
  393. confirmButtonText: "OK",
  394. customClass: {
  395. confirmButton: "btn btn-primary"
  396. }
  397. });
  398. return; // Exit if employee already exists
  399. }
  400. $('#pageLoader').show();
  401. $.ajax({
  402. url: '/gcc/api/department/newentry/employeedetails', // Correct API URL
  403. type: 'GET',
  404. data: { empCode: empCode },
  405. success: function (response) {
  406. $('#pageLoader').hide();
  407. console.log("response:", response.list);
  408. if (response.list && response.list.length > 0) {
  409. // Clear existing data
  410. let employeeDetails = response.list[0];
  411. console.log("employeedetails",response);
  412. const loggedInDeptId = $('#deptId').text().trim(); // Get logged-in deptId dynamically
  413. // Validate department ID
  414. if (employeeDetails.ID_DEPT !== loggedInDeptId) {
  415. Swal.fire({
  416. icon: "error",
  417. title: "Access Denied",
  418. text: "This employee does not belong to your department. Please try again with a valid employee code.",
  419. confirmButtonText: "OK",
  420. customClass: {
  421. confirmButton: "btn btn-danger"
  422. }
  423. });
  424. return; // Exit if the department does not match
  425. }
  426. $('#employeeno').val(employeeDetails.EMPLOYEE_CODE);
  427. $('#employeename').val(employeeDetails.EMPLOYEE_NAME);
  428. $('#department').val(employeeDetails.DEPARTMENT);
  429. $('#designation').val(employeeDetails.DESIGNATION);
  430. $('#classes').val(employeeDetails.GROUP_TYPE);
  431. $('#retrirementdate').val(employeeDetails.RETIREMENT_DATE);
  432. $('#EmployeeCode').text(empCode);
  433. //show the modal
  434. $('#employeeCard').show();
  435. } else {
  436. //$('#pageLoader').hide();
  437. //document.getElementById("newemployeeCard").style.display = "block";
  438. Swal.fire({
  439. icon: "warning", // Display a warning icon
  440. title: "No Data Found",
  441. text: "No details found for this employee number.",
  442. confirmButtonText: "OK",
  443. customClass: {
  444. confirmButton: "btn btn-primary" // Optional styling for the button
  445. }
  446. });
  447. //document.getElementById("newemployeeCard").style.display = "block"; // Show the new employee card
  448. }
  449. },
  450. error: function () {
  451. $('#pageLoader').hide(); // Hide loader on error
  452. Swal.fire({
  453. icon: "error",
  454. title: "Error",
  455. text: "An error occurred while fetching data. Please try again.",
  456. confirmButtonText: "OK",
  457. });
  458. }
  459. });
  460. },
  461. error: function () {
  462. $('#pageLoader').hide();
  463. Swal.fire({
  464. icon: "error",
  465. title: "Error",
  466. text: "An error occurred while fetching data. Please try again.",
  467. confirmButtonText: "OK",
  468. });
  469. }
  470. });
  471. });
  472. })
  473. $(document).ready(function () {
  474. function loadRetirementTypes() {
  475. $.ajax({
  476. url: "/gcc/api/getRetrimentTypes",
  477. type: "GET",
  478. success: function (data) {
  479. var dropdown = $("#retirement");
  480. dropdown.empty();
  481. dropdown.append('<option value="" selected>-- Select Option --</option>');
  482. $.each(data, function (key, entry) {
  483. if (entry.retriment_type !== "Provisional") { // Exclude "Provisional"
  484. dropdown.append($('<option></option>').attr('value', entry.retriment_type).text(entry.retriment_type));
  485. }
  486. });
  487. },
  488. error: function () {
  489. console.log("Error loading dropdown data.");
  490. }
  491. });
  492. }
  493. // Call function on page load
  494. loadRetirementTypes();
  495. });
  496. // Trigger search on pressing Enter key
  497. $('#empCode').on('keydown', function (event) {
  498. if (event.key === 'Enter') {
  499. event.preventDefault(); // Prevent default form submission or page reload
  500. const empCode = $('#empCode').val(); // Get the value of empCode
  501. if (!empCode) {
  502. // Show Swal alert if the employee number is missing
  503. Swal.fire({
  504. icon: "warning", // Display a warning icon
  505. title: "Missing Employee Number",
  506. text: "Please enter an employee number to proceed.",
  507. confirmButtonText: "OK",
  508. customClass: {
  509. confirmButton: "btn btn-primary" // Optional styling for the button
  510. }
  511. });
  512. return; // Stop further execution
  513. }
  514. $('#searchButton').click(); // Trigger the click event of the search button
  515. }
  516. });
  517. // Handle close button click
  518. $('#cancelButton').click(function () {
  519. // Clear the input field value
  520. $('#empCode').val('');
  521. document.getElementById('dateInputContainer').style.display = 'none';
  522. document.getElementById('pendingDurationInputContainer').style.display = 'none';
  523. document.getElementById('cpsAmountInputContainer').style.display = 'none';
  524. document.getElementById('elAmountInputContainer').style.display = 'none';
  525. document.getElementById('spfgsAmountInputContainer').style.display = 'none';
  526. // Hide the card
  527. $('#employeeCard').hide();
  528. });
  529. // Handle close button click
  530. $('#cancelButtonnew').click(function () {
  531. // Clear the input field value
  532. $('#empCode').val('');
  533. $('#newemployeeCard').hide();
  534. });
  535. // Set the max attribute to today's date to disable future dates
  536. document.addEventListener("DOMContentLoaded", function () {
  537. let today = new Date().toISOString().split("T")[0];
  538. document.getElementById("dateInput").setAttribute("max", today);
  539. });
  540. document.querySelectorAll('input[name="filesentuac"]').forEach(radio => {
  541. radio.addEventListener('change', function () {
  542. const dateInputContainer = document.getElementById('dateInputContainer');
  543. if (this.value === 'yes') {
  544. dateInputContainer.style.display = 'block'; // Show the input field
  545. } else {
  546. dateInputContainer.style.display = 'none'; // Hide the input field
  547. document.getElementById('dateInput').value = ''; // Clear the input field
  548. }
  549. });
  550. });
  551. document.querySelectorAll('input[name="pendingDuration"]').forEach(radio => {
  552. radio.addEventListener('change', function () {
  553. const pendingDurationInputContainer = document.getElementById('pendingDurationInputContainer');
  554. if (this.value === 'yes') {
  555. pendingDurationInputContainer.style.display = 'block'; // Show the input field
  556. } else {
  557. pendingDurationInputContainer.style.display = 'none'; // Hide the input field
  558. document.getElementById('pendingDurationInput').value = ''; // Clear the input field
  559. }
  560. });
  561. });
  562. document.querySelectorAll('input[name="cpsamount"]').forEach(radio => {
  563. radio.addEventListener('change', function () {
  564. const cpsAmountInputContainer = document.getElementById('cpsAmountInputContainer');
  565. if (this.value === 'yes') {
  566. cpsAmountInputContainer.style.display = 'block'; // Show the input field
  567. } else {
  568. cpsAmountInputContainer.style.display = 'none'; // Hide the input field
  569. document.getElementById('cpsAmountInput').value = ''; // Clear the input field
  570. }
  571. });
  572. });
  573. document.querySelectorAll('input[name="elamount"]').forEach(radio => {
  574. radio.addEventListener('change', function () {
  575. const elAmountInputContainer = document.getElementById('elAmountInputContainer');
  576. if (this.value === 'yes') {
  577. elAmountInputContainer.style.display = 'block'; // Show the input field
  578. } else {
  579. elAmountInputContainer.style.display = 'none'; // Hide the input field
  580. document.getElementById('elAmountInput').value = ''; // Clear the input field
  581. }
  582. });
  583. });
  584. document.querySelectorAll('input[name="spfgsamount"]').forEach(radio => {
  585. radio.addEventListener('change', function () {
  586. const spfgsAmountInputContainer = document.getElementById('spfgsAmountInputContainer');
  587. if (this.value === 'yes') {
  588. spfgsAmountInputContainer.style.display = 'block'; // Show the input field
  589. } else {
  590. spfgsAmountInputContainer.style.display = 'none'; // Hide the input field
  591. document.getElementById('spfgsAmountInput').value = ''; // Clear the input field
  592. }
  593. });
  594. });
  595. function validatePositiveNumber(input) {
  596. if (input.value < 1) {
  597. input.value = "";
  598. }
  599. }
  600. function saveNewEntryDetailsPensionScheme() {
  601. let selecteduacValue = $('input[name="filesentuac"]:checked').val();
  602. let uacDate = null;
  603. if (selecteduacValue === 'yes') {
  604. uacDate = $('#dateInput').val();
  605. if (!uacDate) {
  606. Swal.fire({
  607. icon: 'warning',
  608. title: 'Validation Error',
  609. text: 'Please Enter UAC Date',
  610. confirmButtonText: 'OK'
  611. });
  612. return; // Stop further execution if validation fails
  613. }
  614. }
  615. let pendingDuration= $('input[name="pendingDuration"]:checked').val();
  616. let pendingDurationReason=null;
  617. if (pendingDuration === 'yes' ) {
  618. pendingDurationReason = $('#pendingDurationInput').val(); // Retrieve the amount if available, else null
  619. if (!pendingDurationReason) {
  620. Swal.fire({
  621. icon: 'warning',
  622. title: 'Validation Error',
  623. text: 'Please Enter Pending Reason',
  624. confirmButtonText: 'OK'
  625. });
  626. return; // Stop further execution if validation fails
  627. }
  628. }
  629. let selcpsamount = $('input[name="cpsamount"]:checked').val();
  630. let selcpsamountval = null;
  631. if (selcpsamount === 'yes') {
  632. selcpsamountval = $('#cpsAmountInput').val();
  633. if (!selcpsamountval || selcpsamountval <= 0) {
  634. Swal.fire({
  635. icon: 'warning',
  636. title: 'Validation Error',
  637. text: 'Please enter a valid CPS Amount greater than zero',
  638. confirmButtonText: 'OK'
  639. });
  640. return ; // Stop further execution
  641. }
  642. }
  643. let selelamount = $('input[name="elamount"]:checked').val();
  644. let selelamountval = null;
  645. if (selelamount === 'yes') {
  646. selelamountval = $('#elAmountInput').val();
  647. if (!selelamountval || selelamountval <= 0) {
  648. Swal.fire({
  649. icon: 'warning',
  650. title: 'Validation Error',
  651. text: 'Please enter a valid EL/LPA Amount greater than zero',
  652. confirmButtonText: 'OK'
  653. });
  654. return ; // Stop further execution
  655. }
  656. }
  657. let selspfgsamount = $('input[name="spfgsamount"]:checked').val();
  658. let selspfgsamountval = null;
  659. if (selspfgsamount === 'yes') {
  660. selspfgsamountval = $('#spfgsAmountInput').val().trim(); // Trim input to remove spaces
  661. if (!selspfgsamountval || selspfgsamountval <= 0) {
  662. Swal.fire({
  663. icon: 'warning',
  664. title: 'Validation Error',
  665. text: 'Please enter a valid SPFGS Amount greater than zero',
  666. confirmButtonText: 'OK'
  667. });
  668. return; // Stop further execution if validation fails
  669. }
  670. }
  671. // Collecting input values
  672. let entryDetails = {
  673. empNo: $('#employeeno').val(),
  674. empName: $('#employeename').val(),
  675. deptName: $('#department').val(),
  676. designation: $('#designation').val(),
  677. classes: $('#classes').val(),
  678. fileMovedBy: $('#userId').text().trim(),
  679. remarks: $('#remarks').val(),
  680. retirementType: $('#retirement').val(),
  681. uac: selecteduacValue,
  682. uacDate: uacDate,
  683. pendingDuration: pendingDuration,
  684. reasonPending: pendingDurationReason,
  685. cps: selcpsamount,
  686. cpsAmount: selcpsamountval,
  687. elOrLpa: selelamount,
  688. elOrLpaAmount:selelamountval,
  689. spfgs: selspfgsamount,
  690. spfgsAmount: selspfgsamountval,
  691. deptId: $('#deptId').text().trim(),
  692. filecategory:$('#filecategory').text().trim()
  693. };
  694. if(!entryDetails.retirementType){
  695. Swal.fire({
  696. icon: 'warning',
  697. title: 'Validation Error!',
  698. text: 'Type of Retirement is required.',
  699. confirmButtonText: 'OK'
  700. });
  701. return;
  702. }
  703. if(!entryDetails.uac){
  704. Swal.fire({
  705. icon: 'warning',
  706. title: 'Validation Error!',
  707. text: 'uac is required.',
  708. confirmButtonText: 'OK'
  709. });
  710. return;
  711. }
  712. if(!entryDetails.pendingDuration){
  713. Swal.fire({
  714. icon: 'warning',
  715. title: 'Validation Error!',
  716. text: 'Pending Duration is required!.',
  717. confirmButtonText: 'OK'
  718. });
  719. return;
  720. }
  721. if(!entryDetails.cps){
  722. Swal.fire({
  723. icon: 'warning',
  724. title: 'Validation Error!',
  725. text: 'CPS is required.',
  726. confirmButtonText: 'OK'
  727. });
  728. return;
  729. }
  730. if(!entryDetails.elOrLpa){
  731. Swal.fire({
  732. icon: 'warning',
  733. title: 'Validation Error!',
  734. text: 'EL/LPA is required.',
  735. confirmButtonText: 'OK'
  736. });
  737. return;
  738. }
  739. if(!entryDetails.spfgs){
  740. Swal.fire({
  741. icon: 'warning',
  742. title: 'Validation Error!',
  743. text: 'SPFGS is required.',
  744. confirmButtonText: 'OK'
  745. });
  746. return;
  747. }
  748. if(!entryDetails.remarks){
  749. Swal.fire({
  750. icon: 'warning',
  751. title: 'Validation Error!',
  752. text: 'Remarks is required.',
  753. confirmButtonText: 'OK'
  754. });
  755. return;
  756. }
  757. console.log("entrydetails:>>", entryDetails);
  758. $('#lfauditButton').prop('disabled', true).text('Processing...');
  759. // AJAX call to save data
  760. $.ajax({
  761. url: '/gcc/api/department/newentry/saveEmployeeDetailsPensionScheme',
  762. type: 'POST',
  763. contentType: 'application/json',
  764. data: JSON.stringify(entryDetails),
  765. success: function (response) {
  766. $('#lfauditButton').prop('disabled', false).text('Submit');
  767. console.log("saveddetails:",entryDetails);
  768. Swal.fire({
  769. icon: 'success',
  770. title: 'Success',
  771. text: response,
  772. allowOutsideClick: false,
  773. allowEscapeKey: false,
  774. allowEnterKey: false,
  775. confirmButtonText: 'OK'
  776. }).then((result) => {
  777. if (result.isConfirmed) {
  778. $('#lfauditButton').prop('disabled', false).text('Submit');
  779. window.location.href = '/gcc/department/newentry/contributorypensionscheme';
  780. console.log('Continue clicked');
  781. }
  782. });
  783. },
  784. error: function (xhr, status, error) {
  785. $('#lfauditButton').prop('disabled', false).text('Submit');
  786. Swal.fire({
  787. icon: 'error',
  788. title: 'Error',
  789. text: 'Failed to save details. Please try again.',
  790. confirmButtonText: 'OK'
  791. });
  792. console.error('Error:', xhr.responseText);
  793. }
  794. });
  795. }
  796. $('#lfauditButton').off('click').on('click', saveNewEntryDetailsPensionScheme);
  797. </script>
  798. </body>
  799. </html>