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.

735 lines
25 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
​
​
​
  1. <!DOCTYPE html>
  2. <html xmlns:th="http://www.thymeleaf.org">
  3. <head th:replace="~{fragments/head-officer :: head}"></head>
  4. <style>
  5. .card-body table {
  6. width: 100%;
  7. padding: 100px;
  8. }
  9. .card-body th,
  10. td {
  11. padding: 8px;
  12. text-align: left;
  13. }
  14. .amount-cell {
  15. text-align: right;
  16. padding-right: 1rem;
  17. /* Adjust padding as needed */
  18. }
  19. .table {
  20. width: 100% !important;
  21. }
  22. </style>
  23. <body>
  24. <!-- Page Container -->
  25. <div id="page-container"
  26. class="sidebar-o sidebar-dark enable-page-overlay side-scroll page-header-fixed page-header-dark">
  27. <!-- Sidebar Nav-->
  28. <nav th:replace="~{fragments/nav-officer :: nav}"></nav>
  29. <!-- END Sidebar -->
  30. <!-- Header -->
  31. <header th:replace="~{fragments/header-officer :: header}"></header>
  32. <!-- END Header -->
  33. <!-- Main Container -->
  34. <main id="main-container">
  35. <div class="content">
  36. <div class="block block-rounded">
  37. <div class="block-header block-header-default">
  38. <h3 class="block-title">List of Bookings Approved</h3>
  39. </div>
  40. <div class="block-content p-0">
  41. <div class="p-sm-4 p-0">
  42. <div class="table-responsive">
  43. <table class="table table-bordered table-striped table-vcenter js-dataTable-responsive"
  44. id="bookingaccepetedtable">
  45. <thead class="thead-light">
  46. <tr>
  47. <th class="text-center no-sort">S.No</th>
  48. <th class="text-center">Booking Id</th>
  49. <th class="text-center">Zone</th>
  50. <th class="text-center">Division</th>
  51. <th class="text-center" width="20%">Hall Name</th>
  52. <th class="text-center">User Name</th>
  53. <th class="text-center">User type</th>
  54. <th class="text-center" width="10%">Booking Date</th>
  55. <th class="text-center">Number of days</th>
  56. <th class="text-center">Reason for Booking</th>
  57. <th class="text-center">Caretaker Name/MobileNumber</th>
  58. <th class="text-center">Action</th>
  59. </tr>
  60. </thead>
  61. <tbody>
  62. <!--<tbody th:each="registration, i : ${registrations}">-->
  63. <!--<tr>-->
  64. <tr th:each="booking, rowStat : ${bookingList}">
  65. <td class="text-center" th:text="${rowStat.index + 1}"></td>
  66. <td class="text-center" th:text="${booking.bookingId}"></td>
  67. <td class="text-center" th:text="${booking.hallDetails.zone}"></td>
  68. <td class="text-center" th:text="${booking.hallDetails.division}"></td>
  69. <td class="text-center" th:text="${booking.hallDetails.hallName}"></td>
  70. <td class="text-center" th:text="${booking.users.name}"></td>
  71. <td class="text-center" th:text="${booking.users.usertype}"></td>
  72. <td class="text-center" th:text="${booking.bookingDate}"></td>
  73. <td class="text-center" th:text="${booking.noOfDays}"></td>
  74. <td class="text-center" th:text="${booking.reason}"></td>
  75. <td class="text-center"
  76. th:text="${booking.hallDetails.hallInchargeName} + ' / ' + ${booking.hallDetails.hallInchargeMobno}">
  77. </td>
  78. <td>
  79. <p>
  80. <span class="badge bg-warning" style="cursor: pointer;"
  81. th:onclick="pendingbooking([[${booking.bookingId}]])">Approved</span>
  82. </p>
  83. </td>
  84. </tr>
  85. </tbody>
  86. </table>
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. </div>
  92. </main>
  93. <!-- END Main Container -->
  94. <!--modal for pening-->
  95. <div class="modal fade backdrop" id="pendingBookingForm" data-backdrop="static" tabindex="-1" role="dialog"
  96. aria-labelledby="staticBackdropLabel" aria-hidden="true">
  97. <div class="modal-dialog modal-lg" role="document">
  98. <div class="modal-content">
  99. <form id="ownform" onsubmit="return rejectsubmit();">
  100. <div class="block block-rounded block-themed block-transparent mb-0">
  101. <div class="block-header bg-primary-dark">
  102. <h3 class="block-title" id="2mtitle">Booking Information</h3>
  103. <div class="block-options">
  104. <button type="button" class="btn-block-option" data-bs-dismiss="modal"
  105. aria-label="Close">
  106. <i class="fa fa-fw fa-times"></i>
  107. </button>
  108. </div>
  109. </div>
  110. <div class="block-content row">
  111. <div class="col-md-12 col-lg-12 col-sm-12 mb-2">
  112. <input type="hidden" class="form-control text-center" name="bookingid"
  113. id="bookingid" disabled />
  114. <div class="card-body">
  115. <table>
  116. <tr>
  117. <th colspan="10" style="background-color: #f2f2f2;">User Details</th>
  118. </tr>
  119. <tr>
  120. <th style="padding: 0.45rem 0.45rem;font-weight: normal;">User Name:
  121. </th>
  122. <td class="fw-semibold" style="padding: 0.45rem 0.45rem;"
  123. id="td_userName"></td>
  124. <th style="padding: 0.45rem 0.45rem;font-weight: normal;">Mobile Number:
  125. </th>
  126. <td class="fw-semibold" style="padding: 0.45rem 0.45rem;"
  127. id="td_mobileNumber"></td>
  128. <th style="padding: 0.45rem 0.45rem;font-weight: normal;">User Type:
  129. </th>
  130. <td class="fw-semibold" style="padding: 0.45rem 0.45rem;"
  131. id="td_usertype"></td>
  132. </tr>
  133. <tr>
  134. <th style="padding: 0.45rem 0.45rem;font-weight: normal;">User Address:
  135. </th>
  136. <td colspan="5" class="fw-semibold" style="padding: 0.45rem 0.45rem;"
  137. id="td_useraddress"></td>
  138. </tr>
  139. </table>
  140. </div>
  141. </div>
  142. <div class="col-md-12 col-lg-12 col-sm-12 mb-2">
  143. <input type="hidden" class="form-control text-center" name="bookingid"
  144. id="bookingid" disabled />
  145. <div class="card-body">
  146. <table>
  147. <tr>
  148. <th colspan="10" style="background-color: #f2f2f2;">Hall Details</th>
  149. </tr>
  150. <tr>
  151. <th style="padding: 0.45rem 0.45rem;font-weight: normal;">Hall Name:
  152. </th>
  153. <td colspan="10" class="fw-semibold" style="padding: 0.45rem 0.45rem;"
  154. id="td_hallName"></td>
  155. </tr>
  156. <th style="padding: 0.45rem 0.45rem;font-weight: normal;">Hall Address:</th>
  157. <td colspan="10" class="fw-semibold" style="padding: 0.45rem 0.45rem;"
  158. id="td_halladdress"></td>
  159. </tr>
  160. <tr>
  161. <th style="padding: 0.45rem 0.45rem;font-weight: normal;">Caretaker
  162. Name:</th>
  163. <td class="fw-semibold" style="padding: 0.45rem 0.45rem;"
  164. id="td_caretakername"></td>
  165. <th style="padding: 0.45rem 0.45rem;font-weight: normal;">Caretaker
  166. Mobile Number:</th>
  167. <td class="fw-semibold" style="padding: 0.45rem 0.45rem;"
  168. id="td_caretakermobileNumber"></td>
  169. </tr>
  170. </table>
  171. </div>
  172. </div>
  173. <div class="col-md-12 col-lg-12 col-sm-12">
  174. <input type="hidden" class="form-control text-center" name="settlementid"
  175. id="settlementid" disabled />
  176. <div class="card-body">
  177. <table>
  178. <tr>
  179. <th colspan="4" style="background-color: #f2f2f2;">Booking
  180. Details of Booking Id:-<span id="booking_id"
  181. style="color:blue"></span></th>
  182. </tr>
  183. <tr>
  184. <th style="padding: 0.45rem 0.45rem;font-weight: normal">Booking Date:
  185. </th>
  186. <td class="fw-semibold" style="padding: 0.45rem 0.45rem;"
  187. id="td_bookingDate"></td>
  188. <th style="padding: 0.45rem 0.45rem;font-weight: normal">Booking Status:
  189. </th>
  190. <td class="fw-semibold" style="padding: 0.45rem 0.45rem;"
  191. id="td_bookingStatus"></td>
  192. </tr>
  193. <tr>
  194. <th style="padding: 0.45rem 0.45rem;font-weight: normal">Start Date:
  195. </th>
  196. <td class="fw-semibold" style="padding: 0.45rem 0.45rem;"
  197. id="td_startDate"></td>
  198. <th style="padding: 0.45rem 0.45rem;font-weight: normal">Deposit
  199. Amount:</th>
  200. <td class="fw-semibold amount-cell" style="padding: 0.45rem 0.45rem;"
  201. id="td_depositeAmount"></td>
  202. </tr>
  203. <tr>
  204. <th style="padding: 0.45rem 0.45rem;font-weight: normal">END
  205. Date:</th>
  206. <td class="fw-semibold" style="padding: 0.45rem 0.45rem;"
  207. id="td_endDate"></td>
  208. <th style="padding: 0.45rem 0.45rem;font-weight: normal">Hall Amount:
  209. </th>
  210. <td class="fw-semibold amount-cell" style="padding: 0.45rem 0.45rem;"
  211. id="td_hallAmount"></td>
  212. </tr>
  213. <tr>
  214. <th style="padding: 0.45rem 0.45rem;font-weight: normal">Starting Slot:
  215. </th>
  216. <td class="fw-semibold" style="padding: 0.45rem 0.45rem;"
  217. id="td_startingSlot"></td>
  218. <th style="padding: 0.45rem 0.45rem;font-weight: normal">GST @18%:</th>
  219. <td class="fw-semibold amount-cell" style="padding: 0.45rem 0.45rem;"
  220. id="td_gst"></td>
  221. </tr>
  222. <tr>
  223. <th style="padding: 0.45rem 0.45rem;font-weight: normal">Ending Slot:
  224. </th>
  225. <td class="fw-semibold" style="padding: 0.45rem 0.45rem;"
  226. id="td_endingSlot"></td>
  227. <th style="padding: 0.45rem 0.45rem;font-weight: normal">Total Amount:
  228. </th>
  229. <td class="fw-semibold amount-cell" style="padding: 0.45rem 0.45rem;"
  230. id="td_totalAmount"></td>
  231. </tr>
  232. </table>
  233. </div>
  234. </div>
  235. <div class="col-sm-12">
  236. <!--<label class="form-label">Documents:<span class="text-danger"></span></label>-->
  237. <div class="documents" id="documents"></div>
  238. </div>
  239. <div class="col-md-12 col-lg-12 col-sm-12 mb-2">
  240. <input type="hidden" class="form-control text-center" name="bookingid"
  241. id="bookingid" disabled />
  242. <div class="card-body">
  243. <table>
  244. <tr>
  245. <th colspan="10" style="background-color: #f2f2f2;">Booking Payment
  246. Details</th>
  247. </tr>
  248. <tr>
  249. <th style="padding: 0.45rem 0.45rem;font-weight: normal;">Transaction
  250. ID:</th>
  251. <td colspan="10" class="fw-semibold" style="padding: 0.45rem 0.45rem;"
  252. id="td_transactionId"></td>
  253. </tr>
  254. <th style="padding: 0.45rem 0.45rem;font-weight: normal;">Amount Received:
  255. </th>
  256. <td colspan="10" class="fw-semibold" style="padding: 0.45rem 0.45rem;"
  257. id="td_payamountReceived"></td>
  258. </tr>
  259. <tr>
  260. <th style="padding: 0.45rem 0.45rem;font-weight: normal;">Transaction
  261. Status:</th>
  262. <td class="fw-semibold" style="padding: 0.45rem 0.45rem;"
  263. id="td_paymentStatus"></td>
  264. </tr>
  265. </table>
  266. </div>
  267. </div>
  268. <div class="row" id="reasondetails">
  269. <div class="col-md-6 mb-2">
  270. <label class="form-label">Reason type :<span
  271. class="text-danger">*</span></label>
  272. <select class="form-control" id="reasontype">
  273. <option value="0">Select Reason type</option>
  274. <option value="1">Illegal</option>
  275. <option value="2">Others</option>
  276. </select>
  277. </div>
  278. <div class="col-md-6 mb-2">
  279. <label class="form-label">Reason:<span class="text-danger">*</span></label>
  280. <textarea class="form-control " name="reason" id="reason" required
  281. style="height: 9px;"></textarea>
  282. <div id="reasonValidationText" class="text-danger small mt-1"
  283. style="display:none">
  284. Reason is required.</div>
  285. </div>
  286. </div>
  287. </div>
  288. </div>
  289. <div class="block-content block-content-full text-end bg-body" id="mbutton2">
  290. <button type="button" class="btn btn-sm btn-alt-secondary"
  291. data-bs-dismiss="modal">Close</button>
  292. <button type="button" class="btn btn-sm btn-primary" id="rejectbutton"
  293. th:onclick="rejectsubmit()">Reject</button>
  294. </div>
  295. </form>
  296. </div>
  297. </div>
  298. </div>
  299. <!-- End Modal User -->
  300. <!-- Footer -->
  301. <div class="modal fade" id="fileModal" tabindex="-1" role="dialog" aria-labelledby="fileModalLabel"
  302. aria-hidden="true">
  303. <div class="modal-dialog modal-lg" role="document">
  304. <div class="modal-content">
  305. <div class="modal-header">
  306. <h5 class="modal-title" id="fileModalLabel">File Preview</h5>
  307. <button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
  308. <span aria-hidden="true">&times;</span>
  309. </button>
  310. </div>
  311. <div class="modal-body">
  312. <embed id="filePreview" src="" width="100%" height="600px">
  313. </div>
  314. <div class="modal-footer">
  315. <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
  316. </div>
  317. </div>
  318. </div>
  319. </div>
  320. <footer th:replace="~{fragments/footer2 :: footer}"></footer>
  321. <!-- END Footer -->
  322. </div>
  323. <!-- Scripts -->
  324. <div th:replace="~{fragments/resetpassword :: div}"></div>
  325. <script th:replace="~{fragments/loginscript :: script}"></script>
  326. <script>
  327. //script to open pending form
  328. function pendingbooking(bookingId) {
  329. $.ajax({
  330. type: "GET",
  331. url: '/communityhall/api/officer/getBookingDetails',
  332. data: {
  333. 'bookingsId': bookingId
  334. },
  335. success: function (x) {
  336. showBookingInfo(x);
  337. }
  338. });
  339. }
  340. function showBookingInfo(list) {
  341. $('#pendingBookingForm').modal({
  342. backdrop: 'static',
  343. keyboard: false
  344. });
  345. $('#pendingBookingForm').modal('show');
  346. document.getElementById("td_userName").innerHTML = list.users.name;
  347. document.getElementById("td_mobileNumber").innerHTML = list.users.mobileNo;
  348. document.getElementById("td_usertype").innerHTML = list.users.usertype;
  349. document.getElementById("bookingid").value = list.bookingId;
  350. var userDetails = list.users;
  351. var userDetailsString =
  352. userDetails.doorNo + ", " +
  353. userDetails.street + ", " +
  354. userDetails.area + ", " +
  355. userDetails.location + "- " +
  356. userDetails.pinCode;
  357. document.getElementById("td_useraddress").innerHTML = userDetailsString;
  358. document.getElementById("td_hallName").innerHTML = list.hallDetails.hallName;
  359. var hallDetails = list.hallDetails;
  360. var hallDetailsString =
  361. hallDetails.doorNo + ", " +
  362. hallDetails.street + ", " +
  363. hallDetails.area + ", " +
  364. hallDetails.city + "- " +
  365. hallDetails.pinCode;
  366. document.getElementById("td_halladdress").innerHTML = hallDetailsString;
  367. document.getElementById("td_caretakername").innerHTML = list.hallDetails.hallInchargeName;
  368. document.getElementById("td_caretakermobileNumber").innerHTML = list.hallDetails.hallInchargeMobno;
  369. document.getElementById("td_bookingDate").innerHTML = list.bookingDate;
  370. document.getElementById("td_depositeAmount").innerHTML = '₹ ' + parseFloat(list.depositAmount).toFixed(2);
  371. document.getElementById("td_hallAmount").innerHTML = '₹ ' + parseFloat(list.hallAmount).toFixed(2);
  372. document.getElementById("td_totalAmount").innerHTML = '₹ ' + parseFloat(list.amountReceived).toFixed(2);
  373. var gstcl = (list.hallAmount * (list.hallDetails.gst / 100));
  374. var formattedGst = gstcl.toFixed(2);
  375. document.getElementById("td_gst").innerHTML = '₹ ' + formattedGst;
  376. document.getElementById("td_startDate").innerHTML = list.startDate;
  377. document.getElementById("td_endDate").innerHTML = list.endDate;
  378. document.getElementById("booking_id").innerHTML = list.bookingId;
  379. function getTimeSlot(slotValue) {
  380. var timeSlot;
  381. var trimmedSlotValue = String(slotValue).trim(); // Convert to string and then trim
  382. if (trimmedSlotValue === '1') {
  383. timeSlot = 'Morning';
  384. } else if (trimmedSlotValue === '2') {
  385. timeSlot = 'Evening';
  386. } else {
  387. timeSlot = 'Unknown';
  388. }
  389. return timeSlot;
  390. }
  391. document.getElementById("td_startingSlot").innerHTML = getTimeSlot(list.startingSlot);
  392. document.getElementById("td_endingSlot").innerHTML = getTimeSlot(list.endingSlot);
  393. document.getElementById("td_bookingStatus").innerHTML = list.bookingStatus;
  394. document.getElementById("td_transactionId").innerHTML = list.payments && list.payments.transactionId ? list.payments.transactionId : "NA";
  395. // Check if amountReceived is not null, otherwise set to "NA"
  396. document.getElementById("td_payamountReceived").innerHTML = list.payments && list.payments.amountReceived ? '₹ ' + list.payments.amountReceived : "NA";
  397. // Check if paymentStatus is not null, otherwise set to "NA"
  398. document.getElementById("td_paymentStatus").innerHTML = list.payments && list.payments.paymentStatus ? list.payments.paymentStatus : "NA";
  399. showReasonDocuments(list);
  400. if (list.reason === 'State Govt Event' || list.reason === 'Central Govt Event' || list.reason === 'Commercial & Others') {
  401. // Disable the reject button
  402. document.getElementById('rejectbutton').disabled = true;
  403. // Hide the reasondetails div
  404. $('#reasondetails').hide();
  405. } else {
  406. // Enable the reject button
  407. document.getElementById('rejectbutton').disabled = false;
  408. // Show the reasondetails div (if it was hidden before)
  409. $('#reasondetails').show();
  410. }
  411. var todaydate = new Date().toISOString().split('T')[0];
  412. // Convert startDate to YYYY-MM-DD format if needed
  413. var startDate = new Date(list.startDate).toISOString().split('T')[0]; // Ensure this is in the correct format
  414. if (startDate > todaydate) {
  415. $('#reasondetails').show();
  416. $('#rejectbutton').show();
  417. } else {
  418. $('#reasondetails').hide();
  419. $('#rejectbutton').hide();
  420. }
  421. }
  422. function showReasonDocuments(list) {
  423. $.ajax({
  424. type: "GET",
  425. url: '/communityhall/api/officer/getReasonByName',
  426. data: {
  427. 'reasonName': list.reason
  428. },
  429. success: function (x) {
  430. showReasonWithDocument(x, list);
  431. }
  432. });
  433. }
  434. // Display booking documents
  435. function showReasonWithDocument(reasonData, list) {
  436. var reasonDocumentData = reasonData.reasonDocumentMasterList;
  437. var bookingDocumentsList = list.bookingDocumentsList;
  438. const reasonFieldsContainer = $('#documents');
  439. reasonFieldsContainer.empty();
  440. // Create a responsive table container
  441. var tableResponsiveDiv = $('<div>').addClass('table-responsive');
  442. // Create the table with Bootstrap classes and custom styles
  443. var table = $('<table>').addClass('table table-bordered table-striped table-vcenter js-dataTable-responsive').css({
  444. 'width': '100%',
  445. 'height': 'auto',
  446. 'border': '1px solid black'
  447. });
  448. // Create the table header (thead)
  449. var thead = $('<thead>').appendTo(table);
  450. var headerRow = $('<tr>').appendTo(thead);
  451. $('<th>').attr('colspan', '3').text('Document Details').css({
  452. 'color': 'black',
  453. 'font-weight': 'bold',
  454. 'background-color': '#f2f2f2',
  455. 'padding': '0.45rem 0.45rem'
  456. }).appendTo(headerRow);
  457. // Create header row for columns
  458. var columnHeadersRow = $('<tr>').appendTo(thead);
  459. $('<th>').text('S.No').appendTo(columnHeadersRow);
  460. $('<th>').text('Required Info').appendTo(columnHeadersRow);
  461. $('<th>').text('Required Documents').appendTo(columnHeadersRow);
  462. // Create the table body (tbody)
  463. var tbody = $('<tbody>').appendTo(table);
  464. // Iterate through the documents list and populate rows
  465. for (var i = 0; i < bookingDocumentsList.length; i++) {
  466. (function (index) {
  467. var row = $('<tr>').appendTo(tbody);
  468. $('<td>').text(index + 1).appendTo(row);
  469. // Determine the text content for the second cell
  470. var name = bookingDocumentsList[index].name ? bookingDocumentsList[index].name : ''; // Empty string if name is null or undefined
  471. var fieldText = reasonDocumentData[index].fieldName;
  472. var fullText = name ? fieldText + ': ' + name : fieldText; // Include colon only if name is not empty
  473. $('<td>').text(fullText).appendTo(row);
  474. // Create a link to view document image
  475. var viewLink = $('<a>').attr('href', 'javascript:void(0)').text(reasonDocumentData[index].docFieldName).on('click', function () {
  476. showDocumentImage(bookingDocumentsList[index].bookingDocUrl);
  477. });
  478. $('<td>').append(viewLink).appendTo(row);
  479. })(i);
  480. }
  481. // Append table to the responsive container
  482. tableResponsiveDiv.append(table);
  483. // Append table to the container in the DOM
  484. reasonFieldsContainer.append(tableResponsiveDiv);
  485. }
  486. function showDocumentImage(fileURL) {
  487. openFileModal(fileURL);
  488. }
  489. // Event delegation for dynamically added elements
  490. $(document).on('click', '.view-document', function () {
  491. const fileURL = $(this).data('url');
  492. openFileModal(fileURL);
  493. });
  494. function openFileModal(fileURL) {
  495. $('#filePreview').attr('src', fileURL);
  496. $('#fileModal').modal('show');
  497. }
  498. function accept() {
  499. let id = document.getElementById("bookingid").value;
  500. Swal.fire({
  501. title: 'Do you want to Accept this User ?',
  502. showDenyButton: true,
  503. showCancelButton: true,
  504. confirmButtonText: 'YES',
  505. denyButtonText: 'NO',
  506. }).then((result) => {
  507. /* Read more about isConfirmed, isDenied below */
  508. if (result.isConfirmed) {
  509. $.ajax({
  510. type: "POST",
  511. url: '/communityhall/api/officer/updateBookingApproved/' + id,
  512. data: {
  513. 'status': 'APPROVED',
  514. 'comments': 'Accepted',
  515. 'bookingId': id
  516. },
  517. success: function (data, textStatus, xhr) {
  518. if (xhr.status === 200) { // Check if the response status is OK
  519. Swal.fire(
  520. 'Done',
  521. 'Successfully Accepted to the ID:' + id,
  522. 'success'
  523. ).then(() => {
  524. location.reload();
  525. });
  526. } else {
  527. Swal.fire(
  528. 'Error',
  529. 'Failed to accept the user',
  530. 'error'
  531. );
  532. }
  533. },
  534. error: function (xhr, textStatus, errorThrown) {
  535. Swal.fire(
  536. 'Error',
  537. 'Failed to accept the user',
  538. 'error'
  539. );
  540. }
  541. });
  542. } else if (result.isDenied) {
  543. Swal.fire('Changes are not saved', '', 'info')
  544. }
  545. });
  546. }
  547. function rejectsubmit() {
  548. let id = document.getElementById("bookingid").value;
  549. let reason = document.getElementById("reason").value.trim();
  550. let reasontype = document.getElementById("reasontype").value;
  551. // Check if reason is empty only when rejecting
  552. if (reason === "" || reason.length === 0) {
  553. document.getElementById("reasonValidationText").style.display = "block";
  554. return false; // Prevent form submission
  555. } else {
  556. document.getElementById("reasonValidationText").style.display = "none";
  557. }
  558. Swal.fire({
  559. title: 'Do you want to Reject this User?',
  560. showDenyButton: true,
  561. showCancelButton: true,
  562. confirmButtonText: 'YES',
  563. denyButtonText: 'NO',
  564. }).then((result) => {
  565. if (result.isConfirmed) {
  566. // Show loading popup
  567. const loadingSwal = Swal.fire({
  568. title: 'Processing...',
  569. text: 'Please wait while we process the rejection.',
  570. allowOutsideClick: false, // Prevent closing the popup
  571. didOpen: () => {
  572. Swal.showLoading(); // Show the loading spinner
  573. },
  574. showConfirmButton: false, // Hide the confirm button during loading
  575. });
  576. $.ajax({
  577. type: "POST",
  578. url: '/communityhall/api/officer/updateBookingReject/' + id,
  579. data: {
  580. 'status': 'REJECTED',
  581. 'comments': reason,
  582. 'bookingId': id,
  583. 'reasontype': reasontype
  584. },
  585. success: function (data, textStatus, xhr) {
  586. loadingSwal.close(); // Close the loading popup
  587. if (xhr.status === 200) {
  588. Swal.fire(
  589. 'Done',
  590. 'Successfully Rejected to the ID: ' + id,
  591. 'success'
  592. ).then(() => {
  593. location.reload(); // Reload page after success
  594. });
  595. } else {
  596. Swal.fire(
  597. 'Error',
  598. 'Failed to reject the user',
  599. 'error'
  600. );
  601. }
  602. },
  603. error: function (xhr, textStatus, errorThrown) {
  604. loadingSwal.close(); // Close the loading popup
  605. Swal.fire(
  606. 'Error',
  607. 'Failed to reject the user',
  608. 'error'
  609. );
  610. }
  611. });
  612. } else if (result.isDenied) {
  613. Swal.fire('Changes are not saved', '', 'info');
  614. }
  615. });
  616. return false; // Prevent form submission
  617. }
  618. $(document).ready(
  619. function () {
  620. var buttons = [{
  621. extend: 'pageLength',
  622. className: 'btn btn-primary'
  623. }, {
  624. title: 'Data export',
  625. extend: 'copyHtml5',
  626. text: 'Copy',
  627. className: 'btn btn-primary',
  628. id: 'copyBtn'
  629. }, {
  630. extend: 'excelHtml5',
  631. text: 'Excel',
  632. className: 'btn btn-primary',
  633. id: 'excelBtn'
  634. }, {
  635. extend: 'csvHtml5',
  636. text: 'CSV',
  637. className: 'btn btn-primary',
  638. id: 'csvBtn'
  639. }, {
  640. extend: 'pdfHtml5',
  641. text: 'PDF',
  642. className: 'btn btn-primary',
  643. id: 'pdfBtn'
  644. },
  645. ];
  646. $('#bookingaccepetedtable').DataTable(
  647. {
  648. dom: 'Bftip',
  649. columnDefs: [{
  650. targets: 'no-sort',
  651. orderable: false
  652. }],
  653. lengthMenu: [
  654. [50, 100, 200, 500, -1],
  655. ['50 rows', '100 rows', '200 rows',
  656. '500 rows', 'Show all']],
  657. scrollY: '50vh',
  658. fixedColumns: {
  659. left: 1,
  660. right: 1
  661. },
  662. buttons: [buttons],
  663. responsive: true,
  664. searching: true, // Enable search
  665. select: false,
  666. processing: false,
  667. });
  668. });
  669. </script>
  670. </body>
  671. </html>