Victoria Hall Booking for Events
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.

711 lines
26 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html xmlns:th="http://www.thymeleaf.org">
  3. <head th:replace="~{fragments/head-admin :: 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. <aside th:replace="~{fragments/aside-right :: aside}"></aside>
  29. <!-- END Side Overlay (right)-->
  30. <!-- Sidebar Nav-->
  31. <nav th:replace="~{fragments/nav-admin :: nav}"></nav>
  32. <!-- END Sidebar -->
  33. <!-- Header -->
  34. <header th:replace="~{fragments/header-admin :: header}"></header>
  35. <!-- END Header -->
  36. <!-- Main Container -->
  37. <main id="main-container">
  38. <div class="content">
  39. <div class="block block-rounded">
  40. <div class="block-header block-header-default" >
  41. <h3 class="block-title">List of Bookings Waiting for NOC Approval</h3>
  42. </div>
  43. <div class="block-content p-0">
  44. <div class="p-sm-4 p-0">
  45. <div class="table-responsive">
  46. <table class="table table-bordered table-striped table-vcenter js-dataTable-responsive" id="bookingapprovedtable">
  47. <thead class="thead-light">
  48. <tr>
  49. <th class="text-center no-sort">S.No</th>
  50. <th class="text-center">Booking Id</th>
  51. <th class="text-center">Zone</th>
  52. <th class="text-center">Division</th>
  53. <th class="text-center" width="20%">Hall Name</th>
  54. <th class="text-center">User Name</th>
  55. <th class="text-center">User type</th>
  56. <th class="text-center" width="10%">Booking Date</th>
  57. <th class="text-center">Number of days</th>
  58. <th class="text-center">Reason for Booking</th>
  59. <th class="text-center">Caretaker Name/MobileNumber</th>
  60. <th class="text-center">Action</th>
  61. </tr>
  62. </thead>
  63. <tbody>
  64. <tr th:each="booking, rowStat : ${waitingBookings}">
  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}]])">Approve</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">
  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 (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 class="text-danger">*</span></label>
  271. <select class="form-control" id="reasontype">
  272. <option value="0" >Select Reason type</option>
  273. <option value="1">Illegal</option>
  274. <option value="2">Others</option>
  275. </select>
  276. </div>
  277. <div class="col-md-6 mb-2">
  278. <label class="form-label">Reason:<span class="text-danger">*</span></label>
  279. <textarea class="form-control " name="reason" id="reason" required style="height: 9px;"></textarea>
  280. <div id="reasonValidationText" class="text-danger small mt-1" style="display:none">
  281. Reason is required.</div>
  282. </div>
  283. </div>
  284. </div>
  285. </div>
  286. <div class="block-content block-content-full text-end bg-body" id="mbutton2">
  287. <button type="button" class="btn btn-sm btn-alt-secondary"
  288. data-bs-dismiss="modal">Close</button>
  289. <button type="button" class="btn btn-sm btn-primary" id="accepttbutton"
  290. th:onclick="accept()">Approve</button>
  291. <button type="button" class="btn btn-sm btn-primary" id="rejectbutton"
  292. th:onclick="rejectsubmit()">Reject</button>
  293. </div>
  294. </form>
  295. </div>
  296. </div>
  297. </div>
  298. <!-- End Modal User -->
  299. <!-- Footer -->
  300. <div class="modal fade" id="fileModal" tabindex="-1" role="dialog" aria-labelledby="fileModalLabel" aria-hidden="true">
  301. <div class="modal-dialog modal-lg" role="document">
  302. <div class="modal-content">
  303. <div class="modal-header">
  304. <h5 class="modal-title" id="fileModalLabel">File Preview</h5>
  305. <button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
  306. <span aria-hidden="true">&times;</span>
  307. </button>
  308. </div>
  309. <div class="modal-body">
  310. <embed id="filePreview" src="" width="100%" height="600px">
  311. </div>
  312. <div class="modal-footer">
  313. <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
  314. </div>
  315. </div>
  316. </div>
  317. </div>
  318. <div th:replace="~{fragments/resetpassword :: div}"></div>
  319. <footer th:replace="~{fragments/footer2 :: footer}"></footer>
  320. <script th:replace="~{fragments/loginscript :: script}"></script>
  321. <script>
  322. //script to open pending form
  323. function pendingbooking(bookingId) {
  324. $.ajax({
  325. type: "GET",
  326. url: '/victoriahallbooking/api/officer/getBookingDetails',
  327. data: {
  328. 'bookingsId': bookingId
  329. },
  330. success: function (x) {
  331. //console.log(x);
  332. showBookingInfo(x);
  333. }
  334. });
  335. }
  336. function showBookingInfo(list) {
  337. $('#pendingBookingForm').modal({
  338. backdrop: 'static',
  339. keyboard: false
  340. });
  341. $('#pendingBookingForm').modal('show');
  342. var todaydate = new Date().toISOString().split('T')[0];
  343. // Convert startDate to YYYY-MM-DD format if needed
  344. var startDate = new Date(list.startDate).toISOString().split('T')[0]; // Ensure this is in the correct format
  345. if (startDate > todaydate) {
  346. $('#reasondetails').show();
  347. $('#rejectbutton').show();
  348. } else {
  349. $('#reasondetails').hide();
  350. $('#rejectbutton').hide();
  351. }
  352. document.getElementById("td_userName").innerHTML = list.users.name;
  353. document.getElementById("td_mobileNumber").innerHTML = list.users.mobileNo;
  354. document.getElementById("td_usertype").innerHTML = list.users.usertype;
  355. document.getElementById("bookingid").value = list.bookingId;
  356. var userDetails = list.users;
  357. var userDetailsString =
  358. userDetails.doorNo + ", " +
  359. userDetails.street + ", " +
  360. userDetails.area + ", " +
  361. userDetails.location + "- " +
  362. userDetails.pinCode;
  363. document.getElementById("td_useraddress").innerHTML = userDetailsString;
  364. document.getElementById("td_hallName").innerHTML = list.hallDetails.hallName;
  365. var hallDetails = list.hallDetails;
  366. var hallDetailsString =
  367. hallDetails.doorNo + ", " +
  368. hallDetails.street + ", " +
  369. hallDetails.area + ", " +
  370. hallDetails.city + "- " +
  371. hallDetails.pinCode;
  372. document.getElementById("td_halladdress").innerHTML = hallDetailsString;
  373. document.getElementById("td_caretakername").innerHTML = list.hallDetails.hallInchargeName;
  374. document.getElementById("td_caretakermobileNumber").innerHTML = list.hallDetails.hallInchargeMobno;
  375. document.getElementById("td_bookingDate").innerHTML = list.bookingDate;
  376. document.getElementById("td_depositeAmount").innerHTML = '₹ ' + parseFloat(list.depositAmount).toFixed(2);
  377. document.getElementById("td_hallAmount").innerHTML = '₹ ' + parseFloat(list.hallAmount).toFixed(2);
  378. document.getElementById("td_totalAmount").innerHTML = '₹ ' + parseFloat(list.amountReceived).toFixed(2);
  379. var gstcl = (list.hallAmount * (list.hallDetails.gst/100));
  380. var formattedGst = gstcl.toFixed(2);
  381. document.getElementById("td_gst").innerHTML = '₹ ' + formattedGst;
  382. document.getElementById("td_startDate").innerHTML = list.startDate;
  383. document.getElementById("td_endDate").innerHTML = list.endDate;
  384. document.getElementById("booking_id").innerHTML = list.bookingId;
  385. function getTimeSlot(slotValue) {
  386. //console.log("Slot Value in getTimeSlot function:", slotValue);
  387. var timeSlot;
  388. var trimmedSlotValue = String(slotValue).trim(); // Convert to string and then trim
  389. if (trimmedSlotValue === '1') {
  390. timeSlot = 'Morning';
  391. } else if (trimmedSlotValue === '2') {
  392. timeSlot = 'Evening';
  393. } else {
  394. timeSlot = 'Unknown';
  395. }
  396. //console.log("Time Slot:", timeSlot);
  397. return timeSlot;
  398. }
  399. document.getElementById("td_startingSlot").innerHTML = getTimeSlot(list.startingSlot);
  400. document.getElementById("td_endingSlot").innerHTML = getTimeSlot(list.endingSlot);
  401. document.getElementById("td_bookingStatus").innerHTML = list.bookingStatus;
  402. // Check if transactionId is not null, otherwise set to "NA"
  403. document.getElementById("td_transactionId").innerHTML = list.payments && list.payments.transactionId ? list.payments.transactionId : "NA";
  404. // Check if amountReceived is not null, otherwise set to "NA"
  405. document.getElementById("td_payamountReceived").innerHTML = list.payments && list.payments.amountReceived ? '₹ ' + list.payments.amountReceived : "NA";
  406. // Check if paymentStatus is not null, otherwise set to "NA"
  407. document.getElementById("td_paymentStatus").innerHTML = list.payments && list.payments.paymentStatus ? list.payments.paymentStatus : "NA";
  408. showReasonDocuments(list);
  409. }
  410. function showReasonDocuments(list) {
  411. $.ajax({
  412. type: "GET",
  413. url: '/victoriahallbooking/api/officer/getReasonByName',
  414. data: {
  415. 'reasonName': list.reason
  416. },
  417. success: function (x) {
  418. //console.log(x);
  419. showReasonWithDocument(x, list);
  420. }
  421. });
  422. }
  423. // Display booking documents
  424. function showReasonWithDocument(reasonData, list) {
  425. var reasonDocumentData = reasonData.reasonDocumentMasterList;
  426. var bookingDocumentsList = list.bookingDocumentsList;
  427. const reasonFieldsContainer = $('#documents');
  428. reasonFieldsContainer.empty();
  429. // Create a responsive table container
  430. var tableResponsiveDiv = $('<div>').addClass('table-responsive');
  431. // Create the table with Bootstrap classes and custom styles
  432. var table = $('<table>').addClass('table table-bordered table-striped table-vcenter js-dataTable-responsive').css({
  433. 'width': '100%',
  434. 'height': 'auto',
  435. 'border': '1px solid black'
  436. });
  437. // Create the table header (thead)
  438. var thead = $('<thead>').appendTo(table);
  439. var headerRow = $('<tr>').appendTo(thead);
  440. $('<th>').attr('colspan', '3').text('Document Details').css({
  441. 'color': 'black',
  442. 'font-weight': 'bold',
  443. 'background-color': '#f2f2f2',
  444. 'padding': '0.45rem 0.45rem'
  445. }).appendTo(headerRow);
  446. // Create header row for columns
  447. var columnHeadersRow = $('<tr>').appendTo(thead);
  448. $('<th>').text('S.No').appendTo(columnHeadersRow);
  449. $('<th>').text('Required Info').appendTo(columnHeadersRow);
  450. $('<th>').text('Required Documents').appendTo(columnHeadersRow);
  451. // Create the table body (tbody)
  452. var tbody = $('<tbody>').appendTo(table);
  453. // Iterate through the documents list and populate rows
  454. for (var i = 0; i < bookingDocumentsList.length; i++) {
  455. (function (index) {
  456. var row = $('<tr>').appendTo(tbody);
  457. $('<td>').text(index + 1).appendTo(row);
  458. // Determine the text content for the second cell
  459. var name = bookingDocumentsList[index].name ? bookingDocumentsList[index].name : ''; // Empty string if name is null or undefined
  460. var fieldText = reasonDocumentData[index].fieldName;
  461. var fullText = name ? fieldText + ': ' + name : fieldText; // Include colon only if name is not empty
  462. $('<td>').text(fullText).appendTo(row);
  463. // Create a link to view document image
  464. var viewLink = $('<a>').attr('href', 'javascript:void(0)').text(reasonDocumentData[index].docFieldName).on('click', function () {
  465. showDocumentImage(bookingDocumentsList[index].bookingDocUrl);
  466. });
  467. $('<td>').append(viewLink).appendTo(row);
  468. })(i);
  469. }
  470. // Append table to the responsive container
  471. tableResponsiveDiv.append(table);
  472. // Append table to the container in the DOM
  473. reasonFieldsContainer.append(tableResponsiveDiv);
  474. }
  475. function showDocumentImage(fileURL) {
  476. //console.log(fileURL);
  477. openFileModal(fileURL);
  478. }
  479. // Event delegation for dynamically added elements
  480. $(document).on('click', '.view-document', function () {
  481. const fileURL = $(this).data('url');
  482. openFileModal(fileURL);
  483. });
  484. function openFileModal(fileURL) {
  485. $('#filePreview').attr('src', fileURL);
  486. $('#fileModal').modal('show');
  487. }
  488. function accept() {
  489. let id = document.getElementById("bookingid").value;
  490. Swal.fire({
  491. title: 'Do you want to Accept this User?',
  492. showDenyButton: true,
  493. showCancelButton: true,
  494. confirmButtonText: 'YES',
  495. denyButtonText: 'NO',
  496. }).then((result) => {
  497. if (result.isConfirmed) {
  498. // Show loading popup
  499. const loadingSwal = Swal.fire({
  500. title: 'Processing...',
  501. text: 'Please wait while we process the acceptance.',
  502. allowOutsideClick: false, // Prevent closing the popup
  503. didOpen: () => {
  504. Swal.showLoading(); // Show the loading spinner
  505. },
  506. showConfirmButton: false, // Hide the confirm button during loading
  507. });
  508. $.ajax({
  509. type: "POST",
  510. url: '/victoriahallbooking/api/officer/updateBookingApproved/' + id,
  511. data: {
  512. 'status': 'APPROVED',
  513. 'comments': 'Accepted',
  514. 'bookingId': id
  515. },
  516. success: function (data, textStatus, xhr) {
  517. loadingSwal.close(); // Close the loading popup
  518. if (xhr.status === 200) {
  519. Swal.fire(
  520. 'Done',
  521. 'Successfully Approved to the ID: ' + id,
  522. 'success'
  523. ).then(() => {
  524. location.reload(); // Reload page after success
  525. });
  526. } else {
  527. Swal.fire(
  528. 'Error',
  529. 'Failed to accept the Booking',
  530. 'error'
  531. );
  532. }
  533. },
  534. error: function (xhr, textStatus, errorThrown) {
  535. loadingSwal.close(); // Close the loading popup
  536. Swal.fire(
  537. 'Error',
  538. 'Failed to accept the Booking',
  539. 'error'
  540. );
  541. }
  542. });
  543. } else if (result.isDenied) {
  544. Swal.fire('Changes are not saved', '', 'info');
  545. }
  546. });
  547. }
  548. function rejectsubmit() {
  549. let id = document.getElementById("bookingid").value;
  550. let reason = document.getElementById("reason").value.trim();
  551. let reasontype = document.getElementById("reasontype").value;
  552. // Check if reason is empty only when rejecting
  553. if (reason === "" || reason.length === 0) {
  554. document.getElementById("reasonValidationText").style.display = "block";
  555. return false; // Prevent form submission
  556. } else {
  557. document.getElementById("reasonValidationText").style.display = "none";
  558. }
  559. Swal.fire({
  560. title: 'Do you want to Reject this User ?',
  561. showDenyButton: true,
  562. showCancelButton: true,
  563. confirmButtonText: 'YES',
  564. denyButtonText: 'NO',
  565. }).then((result) => {
  566. /* Read more about isConfirmed, isDenied below */
  567. if (result.isConfirmed) {
  568. $.ajax({
  569. type: "POST",
  570. url: '/victoriahallbooking/api/officer/updateBookingReject/' + id,
  571. data: {
  572. 'status': 'REJECTED',
  573. 'comments': reason,
  574. 'bookingId': id,
  575. 'reasontype': reasontype
  576. },
  577. success: function (data, textStatus, xhr) {
  578. //console.log("Rejection successful");
  579. if (xhr.status === 200) { // Check if the response status is OK
  580. Swal.fire(
  581. 'Done',
  582. 'Successfully Rejected to the ID:' + id,
  583. 'success'
  584. ).then(() => {
  585. location.reload();
  586. });
  587. } else {
  588. Swal.fire(
  589. 'Error',
  590. 'Failed to reject the user',
  591. 'error'
  592. );
  593. }
  594. },
  595. error: function (xhr, textStatus, errorThrown) {
  596. console.error("Error:", errorThrown);
  597. Swal.fire(
  598. 'Error',
  599. 'Failed to reject the user',
  600. 'error'
  601. );
  602. }
  603. });
  604. } else if (result.isDenied) {
  605. Swal.fire('Changes are not saved', '', 'info')
  606. }
  607. });
  608. return false; // Prevent form submission
  609. }
  610. $(document).ready(
  611. function () {
  612. var buttons = [{
  613. extend: 'pageLength',
  614. className: 'btn btn-primary'
  615. }, {
  616. title: 'Data export',
  617. extend: 'copyHtml5',
  618. text: 'Copy',
  619. className: 'btn btn-primary',
  620. id: 'copyBtn'
  621. }, {
  622. extend: 'excelHtml5',
  623. text: 'Excel',
  624. className: 'btn btn-primary',
  625. id: 'excelBtn'
  626. }, {
  627. extend: 'csvHtml5',
  628. text: 'CSV',
  629. className: 'btn btn-primary',
  630. id: 'csvBtn'
  631. }, {
  632. extend: 'pdfHtml5',
  633. text: 'PDF',
  634. className: 'btn btn-primary',
  635. id: 'pdfBtn'
  636. },
  637. ];
  638. $('#bookingapprovedtable').DataTable(
  639. {
  640. dom: 'Bftip',
  641. columnDefs: [{
  642. targets: 'no-sort',
  643. orderable: false
  644. }],
  645. lengthMenu: [
  646. [50, 100, 200, 500, -1],
  647. ['50 rows', '100 rows', '200 rows',
  648. '500 rows', 'Show all']],
  649. scrollY: '50vh',
  650. fixedColumns: {
  651. left: 1,
  652. right: 1
  653. },
  654. buttons: [buttons],
  655. responsive: true,
  656. searching: true, // Enable search
  657. select: false,
  658. processing: false,
  659. });
  660. // Link the search input to DataTable
  661. $('#searchInput').on('keyup', function () {
  662. dataTable.search(this.value).draw();
  663. });
  664. });
  665. </script>
  666. </body>
  667. </html>