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.

757 lines
30 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>Pendency</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">Pendency</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><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> New Entry - Pendency</h5>
  138. <span th:text="${userId}" id="userId" style="display:none"></span>
  139. <div class="row mb-4">
  140. <div class="col-md-4" >
  141. <label for="empCode" class="form-label fw-bold">Search by Employee No <span class="text-danger">*</span></label>
  142. <div class="dropdown">
  143. <input type="number" id="empCode" class="form-control" pattern="^[A-Za-z0-9]+$" placeholder="Enter Employee No" required>
  144. <small id="employeenoHelp" class="form-text text-muted">Only numeric characters (numbers) are allowed.</small>
  145. </div>
  146. </div>
  147. <div class="col-md-4 mt-20">
  148. <button id="searchButton" class="btn btn-primary mt-2" Style="height:38px;">Search</button>
  149. <!-- <button id="resetButton" class="btn btn-secondary mt-2">Reset</button> -->
  150. </div>
  151. </div>
  152. </div>
  153. </div>
  154. </div>
  155. </div>
  156. <div class="row mb-4" id="employeeCard" style="display: none;">
  157. <div class="col-md-12">
  158. <div class="card">
  159. <div class="card-block">
  160. <h5 style="font-weight:bold;">New Entry - Pendency - <span id="EmployeeCode"></span></h5>
  161. <hr>
  162. <div class="row">
  163. <!-- Employee No -->
  164. <div class="col-md-6">
  165. <label for="employeeno" class="form-label fw-bold">Employee No <span class="text-danger">*</span></label>
  166. <div class="dropdown">
  167. <input type="number" id="employeeno" class="form-control" readonly>
  168. </div>
  169. </div>
  170. <!-- Employee Name -->
  171. <div class="col-md-6">
  172. <label for="employeename" class="form-label fw-bold">Employee Name <span class="text-danger">*</span></label>
  173. <div class="dropdown">
  174. <input type="text" id="employeename" class="form-control" readonly>
  175. </div>
  176. </div>
  177. <div class="col-md-6">
  178. <label for="Department" class="form-label fw-bold">Department <span class="text-danger">*</span></label>
  179. <div class="dropdown">
  180. <input type="text" id="department" class="form-control" readonly>
  181. </div>
  182. </div>
  183. <div class="col-md-6">
  184. <label for="Designation" class="form-label fw-bold">Designation<span class="text-danger">*</span></label>
  185. <div class="dropdown">
  186. <input type="text" id="designation" class="form-control" readonly>
  187. </div>
  188. </div>
  189. <div class="col-md-6">
  190. <label for="classes" class="form-label fw-bold">Class<span class="text-danger">*</span></label>
  191. <div class="dropdown" >
  192. <input type="text" id="classes" class="form-control" readonly>
  193. </div>
  194. </div>
  195. <div class="col-sm-6">
  196. <label for="retirementdate" class="form-label fw-bold">Retirement Date <span class="text-danger">*</span></label>
  197. <input type="date" id="retirementdate" class="form-control" readonly>
  198. </div>
  199. <div class="col-md-6">
  200. <label for="retirement" class="form-label fw-bold">Type Of Retirement<span class="text-danger">*</span></label>
  201. <select id="retirement" class="form-select" style="width: 100%;height: 40px;" required>
  202. </select>
  203. </div>
  204. <!-- pending duration-->
  205. <div class="col-md-6">
  206. <label for="pendingDuration" class="form-label fw-bold">
  207. Pending Duration
  208. <span class="text-danger">*</span>
  209. </label>
  210. <div class="d-flex align-items-center">
  211. <div class="form-check" style="padding-right:10px;">
  212. <input type="radio" id="yes" name="pendingDuration" value="yes"class="form-check-input">
  213. <label for="yes" class="form-check-label">Yes</label>
  214. </div>
  215. <div class="form-check">
  216. <input type="radio" id="no" name="pendingDuration" value="no"class="form-check-input">
  217. <label for="no" class="form-check-label">No</label>
  218. </div>
  219. </div>
  220. <div class="dropdown" id="pendingDurationInputContainer" style="display: none; margin-top: 10px;">
  221. <input type="text" id="pendingDurationInput" name="pendingDurationValue" class="form-control" placeholder="Enter details for pending duration">
  222. </div>
  223. </div>
  224. </div>
  225. <div class="row">
  226. <div class="col-md-6">
  227. <label for="Audit File" class="form-label fw-bold">Date file sent to Audit<span class="text-danger">*</span></label>
  228. <div class="dropdown">
  229. <input type="text" id="filesentdate" class="form-control" readonly>
  230. </div>
  231. </div>
  232. <div class="col-md-12">
  233. <label for="remarks" class="form-label fw-bold">Comments/Remarks <span class="text-danger">*</span></label>
  234. <div class="dropdown">
  235. <textarea id="remarks" class="form-control" rows="4" placeholder="Enter your remarks here" required></textarea>
  236. </div>
  237. </div>
  238. </div>
  239. <div class="row mt-4">
  240. <div class="col-12 d-flex justify-content-center">
  241. <button id="lfauditButton" class="btn btn-primary mt-2 mx-2">Mark as sent Audit</button>
  242. <button id="cancelButton" class="btn btn-secondary mt-2">Cancel</button>
  243. </div>
  244. </div>
  245. </div>
  246. </div>
  247. </div>
  248. </div>
  249. </div>
  250. </div>
  251. <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;">
  252. <div style="position: relative; top: 50%; transform: translateY(-50%);">
  253. <div class="spinner-border text-primary" role="status" style="width: 3rem; height: 3rem;">
  254. <span class="sr-only">Loading...</span>
  255. </div>
  256. <!-- Add the 'Please wait' text below the spinner -->
  257. <p style="margin-top: 1rem; font-size: 1.2rem; color: #007bff;">Please wait...</p>
  258. </div>
  259. </div>
  260. <footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
  261. </div>
  262. </div>
  263. <div th:replace="~{fragments/modules/base/app_module_menu_box :: div}"></div>
  264. <script th:replace="~{fragments/modules/base/script :: script}"></script>
  265. <script src="node_modules/tempusdominus-bootstrap-4/build/js/tempusdominus-bootstrap-4.min.js"></script>
  266. <!-- Bootstrap 5 JS -->
  267. <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
  268. <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
  269. <script>
  270. $(document).ready(function (){
  271. $('#searchButton').on('click', function () {
  272. const empCode = $('#empCode').val().trim(); // Trim any extra spaces
  273. console.log("empCode:", empCode);
  274. // If empCode is missing, show a warning and abort.
  275. if (!empCode) {
  276. Swal.fire({
  277. icon: "warning",
  278. title: "Missing Employee Number",
  279. text: "Please enter an employee number to proceed.",
  280. confirmButtonText: "OK",
  281. customClass: {
  282. confirmButton: "btn btn-primary"
  283. }
  284. });
  285. console.log("No Employee Code provided. Aborting search.");
  286. return;
  287. }
  288. // Show loader and hide any previously displayed cards
  289. $('#pageLoader').show();
  290. $('#employeeCard').hide();
  291. $('#newemployeeCard').hide();
  292. // Clear/reset form fields
  293. $('#typeofcategory').val('');
  294. $('#retirement').val('');
  295. $('#pendingDurationInput').val('');
  296. $('#remarks').val('');
  297. $('input[name="pendingDuration"]').prop('checked', false);
  298. document.getElementById("pendingDurationInputContainer").style.display = "none";
  299. // STEP 1: Check if the employee already exists in the database.
  300. $.ajax({
  301. url: '/gcc/api/department/newentry/prexists', // Endpoint to check existence
  302. type: 'GET',
  303. data: { empCode: empCode },
  304. success: function (existsResponse) {
  305. console.log("Exists API Response:", existsResponse);
  306. $('#pageLoader').hide();
  307. // If the employee exists, show a warning and stop processing.
  308. if (existsResponse && existsResponse.exists) {
  309. Swal.fire({
  310. icon: "warning",
  311. title: "Already Exists",
  312. text: "This employee number already exists.",
  313. confirmButtonText: "OK",
  314. customClass: {
  315. confirmButton: "btn btn-primary"
  316. }
  317. });
  318. return;
  319. }
  320. // STEP 2: If the employee does not exist, fetch employee details.
  321. $('#pageLoader').show(); // Show loader for the second API call
  322. $.ajax({
  323. url: '/gcc/api/department/newentry/employeedetails', // Correct API URL for employee details
  324. type: 'GET',
  325. data: { empCode: empCode },
  326. success: function (response) {
  327. $('#pageLoader').hide();
  328. console.log("Employee Details API Response:", response.list);
  329. if (response.list && response.list.length > 0) {
  330. // Retrieve the first (and presumably only) employee details record.
  331. let employeeDetails = response.list[0];
  332. console.log("Employee Details:", employeeDetails);
  333. // Optional: Validate department ID if needed.
  334. const loggedInDeptId = $('#deptId').text().trim();
  335. const currentDate = $('#filesentdate').val().trim();
  336. if(employeeDetails.RETIREMENT_DATE >= currentDate){
  337. Swal.fire({
  338. icon: "warning",
  339. title: "Not Applicable",
  340. text: "This employee not applicable for this pendency.",
  341. confirmButtonText: "OK",
  342. customClass: {
  343. confirmButton: "btn btn-primary"
  344. }
  345. });
  346. return;
  347. }
  348. // If the returned data is invalid, show a warning.
  349. if (!employeeDetails || !employeeDetails.EMPLOYEE_CODE) {
  350. Swal.fire({
  351. icon: "warning",
  352. title: "No Data Found",
  353. text: "No details found for this employee number.",
  354. confirmButtonText: "OK",
  355. customClass: {
  356. confirmButton: "btn btn-primary"
  357. }
  358. });
  359. return;
  360. }
  361. if (employeeDetails.ID_DEPT !== loggedInDeptId) {
  362. Swal.fire({
  363. icon: "error",
  364. title: "Access Denied",
  365. text: "This employee does not belong to your department. Please try again with a valid employee code.",
  366. confirmButtonText: "OK",
  367. customClass: {
  368. confirmButton: "btn btn-danger"
  369. }
  370. });
  371. return;
  372. }
  373. // Populate the form fields with the fetched employee details.
  374. $('#employeeno').val(employeeDetails.EMPLOYEE_CODE);
  375. $('#employeename').val(employeeDetails.EMPLOYEE_NAME);
  376. $('#department').val(employeeDetails.DEPARTMENT);
  377. $('#designation').val(employeeDetails.DESIGNATION);
  378. $('#classes').val(employeeDetails.GROUP_TYPE);
  379. $('#retirementdate').val(employeeDetails.RETIREMENT_DATE);
  380. $('#EmployeeCode').text(empCode);
  381. // Finally, display the employee card/modal.
  382. $('#employeeCard').show();
  383. } else {
  384. $('#pageLoader').hide();
  385. Swal.fire({
  386. icon: "warning",
  387. title: "No Data Found",
  388. text: "No details found for this employee number.",
  389. confirmButtonText: "OK",
  390. customClass: {
  391. confirmButton: "btn btn-primary"
  392. }
  393. });
  394. }
  395. },
  396. error: function () {
  397. $('#pageLoader').hide();
  398. Swal.fire({
  399. icon: "error",
  400. title: "Error",
  401. text: "An error occurred while fetching data. Please try again.",
  402. confirmButtonText: "OK"
  403. });
  404. }
  405. });
  406. },
  407. error: function () {
  408. $('#pageLoader').hide();
  409. Swal.fire({
  410. icon: "error",
  411. title: "Error",
  412. text: "An error occurred while checking the employee. Please try again.",
  413. confirmButtonText: "OK"
  414. });
  415. }
  416. });
  417. });
  418. /* document.getElementById('lfauditButton').addEventListener('click', function () {
  419. // Trigger the save function when the button is clicked
  420. saveEntryDetails();
  421. }); */
  422. //$('#lfauditButton').one('click', saveEntryDetails);
  423. $('#lfauditButton').off('click').on('click', saveEntryDetails);
  424. })
  425. // Handle close button click
  426. $('#cancelButton').click(function () {
  427. // Clear the input field value
  428. $('#empCode').val('');
  429. // Hide the card
  430. $('#employeeCard').hide();
  431. });
  432. // Handle close button click
  433. $('#cancelButtonnew').click(function () {
  434. // Clear the input field value
  435. $('#empCode').val('');
  436. // Hide the card
  437. $('#newemployeeCard').hide();
  438. });
  439. // Trigger search on pressing Enter key
  440. $('#empCode').on('keydown', function (event) {
  441. if (event.key === 'Enter') {
  442. event.preventDefault(); // Prevent default form submission or page reload
  443. const empCode = $('#empCode').val(); // Get the value of empCode
  444. if (!empCode) {
  445. // Show Swal alert if the employee number is missing
  446. Swal.fire({
  447. icon: "warning", // Display a warning icon
  448. title: "Missing Employee Number",
  449. text: "Please enter an employee number to proceed.",
  450. confirmButtonText: "OK",
  451. customClass: {
  452. confirmButton: "btn btn-primary" // Optional styling for the button
  453. }
  454. });
  455. return; // Stop further execution
  456. }
  457. $('#searchButton').click(); // Trigger the click event of the search button
  458. }
  459. });
  460. $(document).ready(function () {
  461. function loadRetirementTypes() {
  462. $.ajax({
  463. url: "/gcc/api/getRetrimentTypes",
  464. type: "GET",
  465. success: function (data) {
  466. var dropdown = $("#retirement");
  467. dropdown.empty();
  468. dropdown.append('<option value="" selected>-- Select Option --</option>');
  469. $.each(data, function (key, entry) {
  470. if (entry.retriment_type !== "Provisional") { // Exclude "Provisional"
  471. dropdown.append($('<option></option>').attr('value', entry.retriment_type).text(entry.retriment_type));
  472. }
  473. });
  474. },
  475. error: function () {
  476. console.log("Error loading dropdown data.");
  477. }
  478. });
  479. }
  480. // Call function on page load
  481. loadRetirementTypes();
  482. });
  483. document.addEventListener("DOMContentLoaded", function() {
  484. // Get today's date
  485. const today = new Date();
  486. // Format the date as DD-MM-YYYY for display
  487. const day = String(today.getDate()).padStart(2, '0');
  488. const month = String(today.getMonth() + 1).padStart(2, '0'); // Months are 0-based
  489. const year = today.getFullYear();
  490. // Combine into DD-MM-YYYY format for display
  491. const formattedDateDisplay = `${day}-${month}-${year}`;
  492. // Set the value of the input field to the current date (in DD-MM-YYYY format for display)
  493. document.getElementById("filesentdate").value = formattedDateDisplay;
  494. });
  495. function convertDateFormat(dateString) {
  496. if (!dateString) return '';
  497. let [day, month, year] = dateString.split('-');
  498. return `${year}-${month}-${day}`;
  499. }
  500. function saveEntryDetails() {
  501. let pendingDuration= $('input[name="pendingDuration"]:checked').val();
  502. let pendingDurationReason=null;
  503. if (pendingDuration === 'yes' ) {
  504. pendingDurationReason = $('#pendingDurationInput').val(); // Retrieve the amount if available, else null
  505. if (!pendingDurationReason) {
  506. Swal.fire({
  507. icon: 'warning',
  508. title: 'Validation Error',
  509. text: 'Please Enter Pending Reason',
  510. confirmButtonText: 'OK'
  511. });
  512. return; // Stop further execution if validation fails
  513. }
  514. }
  515. //pendencyCategory:$('#typeofcategory').val(),
  516. let entryDetails = {
  517. empNo: $('#employeeno').val(),
  518. empName: $('#employeename').val(),
  519. deptName: $('#department').val(),
  520. designation: $('#designation').val(),
  521. retirementclass: $('#classes').val(),
  522. typeOfRetirement: $('#retirement').val(),
  523. retirementDate:$('#retirementdate').val(),
  524. pendingDuration: pendingDuration,
  525. reasonPending: pendingDurationReason,
  526. dateToAudit: convertDateFormat($('#filesentdate').val()?.trim()),
  527. remarks: $('#remarks').val(),
  528. deptId:$('#deptId').text().trim(),
  529. filemovedby:$('#userId').text().trim(),
  530. filecategory:$('#filecategory').text().trim()
  531. };
  532. console.log("entrydetails..",entryDetails);
  533. if (!entryDetails.pendingDuration) {
  534. Swal.fire({
  535. icon: 'warning',
  536. title: 'Validation Error!',
  537. text: 'Pending Duration.',
  538. confirmButtonText: 'OK'
  539. });
  540. return;
  541. }
  542. if (!entryDetails.typeOfRetirement) {
  543. Swal.fire({
  544. icon: 'warning',
  545. title: 'Validation Error!',
  546. text: 'Type of Retirement.',
  547. confirmButtonText: 'OK'
  548. });
  549. return;
  550. }
  551. if (!entryDetails.remarks) {
  552. Swal.fire({
  553. icon: 'warning',
  554. title: 'Validation Error!',
  555. text: 'Remarks are required.',
  556. confirmButtonText: 'OK'
  557. });
  558. return;
  559. }
  560. $('#lfauditButton').prop('disabled', true).text('Processing...');
  561. $.ajax({
  562. url: '/gcc/api/department/newentry/savePendecnyDetails',
  563. type: 'POST',
  564. contentType: 'application/json',
  565. data: JSON.stringify(entryDetails),
  566. success: function (response) {
  567. $('#lfauditButton').prop('disabled', false).text('Mark as sent Audit');
  568. Swal.fire({
  569. icon: 'success',
  570. title: 'Success',
  571. text: response,
  572. allowOutsideClick: false,
  573. allowEscapeKey: false,
  574. allowEnterKey: false,
  575. confirmButtonText: 'OK'
  576. }).then((result) => {
  577. if (result.isConfirmed) {
  578. $('#lfauditButton').prop('disabled', false).text('Mark as sent Audit');
  579. window.location.href = "/gcc/department/newentry/pendency";
  580. console.log("Continue clicked");
  581. }
  582. });
  583. },
  584. error: function (xhr, status, error) {
  585. $('#lfauditButton').prop('disabled', false).text('Mark as sent Audit');
  586. Swal.fire({
  587. icon: 'error',
  588. title: 'Error',
  589. text: 'Failed to save details. Please try again.',
  590. confirmButtonText: 'OK'
  591. });
  592. console.error('Error:', xhr.responseText);
  593. }
  594. });
  595. }
  596. function handleCategoryChange() {
  597. const categoryDropdown = document.getElementById('typeofcategory');
  598. const retirementDetailsContainer = document.getElementById('retirementDetailsContainer');
  599. // Show or hide the retirement details dropdown based on the selection
  600. if (categoryDropdown.value === 'Retirement') {
  601. retirementDetailsContainer.style.display = 'block'; // Show retirement dropdown
  602. } else {
  603. retirementDetailsContainer.style.display = 'none'; // Hide retirement dropdown
  604. }
  605. }
  606. document.querySelectorAll('input[name="pendingDuration"]').forEach(radio => {
  607. radio.addEventListener('change', function () {
  608. const pendingDurationInputContainer = document.getElementById('pendingDurationInputContainer');
  609. if (this.value === 'yes') {
  610. pendingDurationInputContainer.style.display = 'block'; // Show the input field
  611. } else {
  612. pendingDurationInputContainer.style.display = 'none'; // Hide the input field
  613. document.getElementById('pendingDurationInput').value = ''; // Clear the input field
  614. }
  615. });
  616. });
  617. </script>
  618. </body>
  619. </html>