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.

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