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.

730 lines
25 KiB

1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html xmlns:th="http://www.thymeleaf.org">
  3. <head th:replace="~{fragments/head-admin :: head}"></head>
  4. <meta charset="ISO-8859-1">
  5. <!-- Include DataTables CSS -->
  6. </head>
  7. <style>
  8. .block-content {
  9. padding-bottom: 10px;
  10. }
  11. .small-input {
  12. width: 150px;
  13. /* Adjust the width as needed */
  14. }
  15. .small-table th,
  16. .small-table td {
  17. font-size: 14px;
  18. /* Adjust font size as needed */
  19. }
  20. /* Reduce padding for table cells */
  21. .small-table td,
  22. .small-table th {
  23. padding: 5px;
  24. /* Adjust padding as needed */
  25. }
  26. .card-body table {
  27. width: 100%;
  28. padding: 100px;
  29. }
  30. .card-body th,
  31. td {
  32. padding: 8px;
  33. text-align: left;
  34. }
  35. .amount-cell {
  36. text-align: right;
  37. padding-right: 1rem;
  38. /* Adjust padding as needed */
  39. }
  40. </style>
  41. <body>
  42. <div id="page-container"
  43. class="sidebar-o sidebar-dark enable-page-overlay side-scroll page-header-fixed page-header-dark">
  44. <aside th:replace="~{fragments/aside-right :: aside}"></aside>
  45. <nav th:replace="~{fragments/nav-admin :: nav}"></nav>
  46. <header th:replace="~{fragments/header-admin :: header}"></header>
  47. <div class="content" style="margin-top: 77px;">
  48. <div class="block block-rounded">
  49. <div class="block-header bg-info text-white" style="background-color: #2c726c !important">
  50. <h3 class="block-title">Settlement List</h3>
  51. </div>
  52. <div class="block-content">
  53. <div class="table-responsive">
  54. <table id="settlementListTable" class="table table-bordered table-vcenter">
  55. <thead>
  56. <tr>
  57. <th>S.No</th>
  58. <th>Booking Id</th>
  59. <th>Booking Date</th>
  60. <th>Settlement id</th>
  61. <th>Settlement Raised Date</th>
  62. <th>Deposit Amount</th>
  63. <th>Collection Pending(if any)</th>
  64. <th>Refund Amount</th>
  65. <th>Refund Status</th>
  66. <th>View Details</th>
  67. </tr>
  68. </thead>
  69. <tbody>
  70. <!-- Iterate over past bookings and display them -->
  71. <tr th:each="settlemetList,rowStat : ${settlemetList}"
  72. th:if="${settlemetList.settlement != null}">
  73. <td class="text-center" th:text="${rowStat.index + 1}"></td>
  74. <td class="text-center" th:text="${settlemetList.bookingId}"></td>
  75. <td class="text-center" th:text="${settlemetList.bookingDate}"></td>
  76. <td class="text-center" th:text="${settlemetList.settlement.settlementId}"></td>
  77. <td class="text-center" th:text="${settlemetList.settlement.cdate}"></td>
  78. <td class="text-center" th:text="${settlemetList.settlement.depositAmount}"></td>
  79. <td class="text-center" th:text="${settlemetList.settlement.collectionPending}">
  80. </td>
  81. <td class="text-center" th:text="${settlemetList.settlement.refundedAmount}"></td>
  82. <td class="text-center" th:text="${settlemetList.refundStatus}"></td>
  83. <td>
  84. <span class="badge bg-primary" style="cursor:pointer"
  85. th:onclick="approve([[${settlemetList.settlement.settlementId}]])">View</span>
  86. <span class="badge bg-warning" style="cursor: pointer;"
  87. th:if="${#strings.trim(settlemetList.RefundStatus) == 'REJECTED'}"
  88. th:onclick="settleTheAmount([[${settlemetList.bookingId}]])">Raise
  89. Again</span>
  90. <span class="badge bg-warning" style="cursor: pointer;"
  91. th:if="${settlemetList.settlement.collectionPending > 0} and ${settlemetList.settlement.collectionStatus != 'paid'}"
  92. th:onclick="|fetchQRCode(${settlemetList.bookingId})|">QR
  93. </span>
  94. </td>
  95. </tr>
  96. </tbody>
  97. </table>
  98. </div>
  99. </div>
  100. </div>
  101. </div><br>
  102. <br>
  103. <br>
  104. <br>
  105. </div>
  106. <!--modal for pending-->
  107. <div class="modal fade backdrop" id="settlementinformation" data-backdrop="static" tabindex="-1" role="dialog"
  108. aria-labelledby="staticBackdropLabel" aria-hidden="true">
  109. <div class="modal-dialog modal-lg" role="document">
  110. <div class="modal-content">
  111. <form id="ownform">
  112. <div class="block block-rounded block-themed block-transparent mb-0">
  113. <div class="block-header bg-primary-dark">
  114. <h3 class="block-title" id="2mtitle">Settlement Information</h3>
  115. <div class="block-options">
  116. <button type="button" class="btn-block-option" data-bs-dismiss="modal"
  117. aria-label="Close">
  118. <i class="fa fa-fw fa-times"></i>
  119. </button>
  120. </div>
  121. </div>
  122. <div class="block-content row">
  123. <div class="col-md-12 col-lg-12 col-sm-12">
  124. <input type="hidden" class="form-control text-center" name="settlementid"
  125. id="settlementid" disabled />
  126. <div class="card-body">
  127. <table>
  128. <tr>
  129. <th colspan="10" style="background-color: #f2f2f2;">User Details</th>
  130. </tr>
  131. <tr>
  132. <th style="padding: 0.45rem 0.45rem;font-weight: normal;">User Name:</th>
  133. <td class="fw-semibold" style="padding: 0.45rem 0.45rem;" id="td_userName">
  134. </td>
  135. <th style="padding: 0.45rem 0.45rem;font-weight: normal;">Mobile Number:
  136. </th>
  137. <td class="fw-semibold" style="padding: 0.45rem 0.45rem;"
  138. id="td_mobileNumber"></td>
  139. <th style="padding: 0.45rem 0.45rem;font-weight: normal;">User Type:</th>
  140. <td class="fw-semibold" style="padding: 0.45rem 0.45rem;" id="td_usertype">
  141. </td>
  142. </tr>
  143. <tr>
  144. <th style="padding: 0.45rem 0.45rem;font-weight: normal;">User Address:</th>
  145. <td colspan="5" class="fw-semibold" style="padding: 0.45rem 0.45rem;"
  146. id="td_useraddress"></td>
  147. </tr>
  148. </table>
  149. </div>
  150. </div>
  151. <div class="col-md-12 col-lg-12 col-sm-12">
  152. <input type="hidden" class="form-control text-center" name="settlementid"
  153. id="settlementid" disabled />
  154. <div class="card-body">
  155. <table>
  156. <tr>
  157. <th colspan="4" style="background-color: #f2f2f2;">Booking
  158. Details(Booking Id:-<span id="booking_id" style="color:blue"></span>)
  159. </th>
  160. </tr>
  161. <tr>
  162. <th style="padding: 0.45rem 0.45rem;font-weight: normal">Booking Date:</th>
  163. <td class="fw-semibold" style="padding: 0.45rem 0.45rem;"
  164. id="td_bookingDate"></td>
  165. <th style="padding: 0.45rem 0.45rem;font-weight: normal">Deposit Amount:
  166. </th>
  167. <td class="fw-semibold amount-cell" style="padding: 0.45rem 0.45rem;"
  168. id="td_depositeAmount"></td>
  169. </tr>
  170. <tr>
  171. <th style="padding: 0.45rem 0.45rem;font-weight: normal">Start Date:</th>
  172. <td class="fw-semibold" style="padding: 0.45rem 0.45rem;" id="td_startDate">
  173. </td>
  174. <th style="padding: 0.45rem 0.45rem;font-weight: normal">Hall Amount:</th>
  175. <td class="fw-semibold amount-cell" style="padding: 0.45rem 0.45rem;"
  176. id="td_hallAmount"></td>
  177. </tr>
  178. <tr>
  179. <th style="padding: 0.45rem 0.45rem;font-weight: normal">END
  180. Date:</th>
  181. <td class="fw-semibold" style="padding: 0.45rem 0.45rem;" id="td_endDate">
  182. </td>
  183. <th style="padding: 0.45rem 0.45rem;font-weight: normal">GST @18%:</th>
  184. <td class="fw-semibold amount-cell" style="padding: 0.45rem 0.45rem;"
  185. id="td_gst"></td>
  186. </tr>
  187. <tr>
  188. <th style="padding: 0.45rem 0.45rem;font-weight: normal">Starting Slot:</th>
  189. <td class="fw-semibold" style="padding: 0.45rem 0.45rem;"
  190. id="td_startingSlot"></td>
  191. <th style="padding: 0.45rem 0.45rem;font-weight: normal">Total Amount:</th>
  192. <td class="fw-semibold amount-cell" style="padding: 0.45rem 0.45rem;"
  193. id="td_totalAmount"></td>
  194. </tr>
  195. <tr>
  196. <th style="padding: 0.45rem 0.45rem;font-weight: normal">Ending Slot:</th>
  197. <td class="fw-semibold" style="padding: 0.45rem 0.45rem;"
  198. id="td_endingSlot"></td>
  199. </tr>
  200. <tr>
  201. <th colspan="4" style="background-color: #f2f2f2;">EB
  202. Details</th>
  203. </tr>
  204. <tr>
  205. <th style="padding: 0.45rem 0.45rem;font-weight: normal">Consumer Number:
  206. </th>
  207. <td class="fw-semibold" style="padding: 0.45rem 0.45rem;" id="td_EBNumber">
  208. </td>
  209. <th style="padding: 0.45rem 0.45rem;font-weight: normal">EB Amount Per Unit:
  210. </th>
  211. <td class="fw-semibold" style="padding: 0.45rem 0.45rem;text-align:right"
  212. id="td_ebamountperunit"></td>
  213. </tr>
  214. <tr>
  215. <th style="padding: 0.45rem 0.45rem;font-weight: normal">Start Reading:</th>
  216. <td class="fw-semibold" style="padding: 0.45rem 0.45rem;"
  217. id="td_startingReading"></td>
  218. <th style="padding: 0.45rem 0.45rem;font-weight: normal">Unit Consumed:</th>
  219. <td class="fw-semibold" style="padding: 0.45rem 0.45rem;text-align:right"
  220. id="td_usedunit"></td>
  221. </tr>
  222. <tr>
  223. <th style="padding: 0.45rem 0.45rem;font-weight: normal">END Reading:</th>
  224. <td class="fw-semibold" style="padding: 0.45rem 0.45rem;"
  225. id="td_endingReading"></td>
  226. <th style="padding: 0.45rem 0.45rem;font-weight: normal">EB Amount:</th>
  227. <td class="fw-semibold" style="padding: 0.45rem 0.45rem;text-align:right"
  228. id="td_electricityamount"></td>
  229. </tr>
  230. </table>
  231. </div>
  232. </div>
  233. <div id="damageDetails" style="margin-bottom: -17px;"></div>
  234. <div class="col-md-12 col-lg-12 col-sm-12">
  235. <div class="card-body">
  236. <table>
  237. <tr>
  238. <th colspan="2" style="background-color: #f2f2f2;">Amount
  239. to be Refunded</th>
  240. </tr>
  241. <tr>
  242. <th style="padding: 0.45rem 0.45rem;font-weight: normal">Deposit Amount:
  243. </th>
  244. <td class="fw-semibold amount-cell" style="padding: 0.45rem 0.45rem;"
  245. id="td_depositeamountforrefund">0</td>
  246. </tr>
  247. <tr>
  248. <th style="padding: 0.45rem 0.45rem;font-weight: normal">EB Amount:</th>
  249. <td class="fw-semibold amount-cell"
  250. style="padding: 0.45rem 0.45rem;color:red" id="td_ebAmount">0</td>
  251. </tr>
  252. <tr>
  253. <th style="padding: 0.45rem 0.45rem;font-weight: normal">Damage(if any):
  254. </th>
  255. <td class="fw-semibold amount-cell"
  256. style="padding: 0.45rem 0.45rem;color:red" id="td_damage">0</td>
  257. </tr>
  258. <tr id="pendingcolumn">
  259. <th id="th_settel_label"
  260. style="padding: 0.45rem 0.45rem;font-weight: normal">Collection Pending
  261. Amount:</th>
  262. <td class="fw-semibold amount-cell"
  263. style="padding: 0.45rem 0.45rem; color: green;" id="td_pending_amt">0
  264. </td>
  265. </tr>
  266. <tr id="collectionstatuscolumn">
  267. <th id="label"
  268. style="padding: 0.45rem 0.45rem;font-weight: normal">Collection Pending Status
  269. :</th>
  270. <td class="fw-semibold amount-cell"
  271. style="padding: 0.45rem 0.45rem; color: green;" id="td_collection_status">
  272. </td>
  273. </tr>
  274. <tr>
  275. <th style="padding: 0.45rem 0.45rem;font-weight: normal">Actual refundable
  276. Amount:</th>
  277. <td class="fw-semibold amount-cell"
  278. style="padding: 0.45rem 0.45rem; color: green;" id="td_settel_amt">0
  279. </td>
  280. </tr>
  281. </table>
  282. </div>
  283. </div>
  284. <!-- End damage detail -->
  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. <a id="downloadLink" style="display: none;"></a>
  290. </div>
  291. </div>
  292. </form>
  293. </div>
  294. </div>
  295. </div>
  296. <div class="modal fade" id="fileModal" tabindex="-1" role="dialog" aria-labelledby="fileModalLabel"
  297. aria-hidden="true">
  298. <div class="modal-dialog modal-lg" role="document">
  299. <div class="modal-content">
  300. <div class="modal-header">
  301. <h5 class="modal-title" id="fileModalLabel">File Preview</h5>
  302. <button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
  303. <span aria-hidden="true">&times;</span>
  304. </button>
  305. </div>
  306. <div class="modal-body">
  307. <embed id="filePreview" src="" width="100%" height="600px">
  308. </div>
  309. <div class="modal-footer">
  310. <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
  311. </div>
  312. </div>
  313. </div>
  314. </div>
  315. <div class="modal fade" id="qrview" tabindex="-1" role="dialog" aria-labelledby="fileModalLabel"
  316. aria-hidden="true">
  317. <div class="modal-dialog modal-sm" role="document">
  318. <div class="modal-content">
  319. <div class="modal-header">
  320. <h5 class="modal-title" id="qrview">QR Code for Collection Pending</h5>
  321. </div>
  322. <div class="modal-body">
  323. <div>
  324. <img style="border:4px solid #15455D;width: 256px; height: 260px;border-radius:10px;"
  325. id="qrCodeImage" alt="QR Code">
  326. </div>
  327. </div>
  328. <div class="modal-footer">
  329. <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
  330. </div>
  331. </div>
  332. </div>
  333. </div>
  334. <div th:replace="~{fragments/resetpassword :: div}"></div>
  335. <footer th:replace="~{fragments/footer2 :: footer}"></footer>
  336. <script th:replace="~{fragments/loginscript :: script}"></script>
  337. <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
  338. <script>
  339. $(document).ready(
  340. function () {
  341. // DataTables buttons configuration
  342. var buttons = [{
  343. extend: 'pageLength',
  344. className: 'btn btn-primary'
  345. }, {
  346. title: 'Data export',
  347. extend: 'copyHtml5',
  348. text: 'Copy',
  349. className: 'btn btn-primary',
  350. id: 'copyBtn'
  351. }, {
  352. extend: 'excelHtml5',
  353. text: 'Excel',
  354. className: 'btn btn-primary',
  355. id: 'excelBtn'
  356. }, {
  357. extend: 'csvHtml5',
  358. text: 'CSV',
  359. className: 'btn btn-primary',
  360. id: 'csvBtn'
  361. }, {
  362. extend: 'pdfHtml5',
  363. text: 'PDF',
  364. className: 'btn btn-primary',
  365. id: 'pdfBtn'
  366. },
  367. ];
  368. $('#settlementListTable').DataTable(
  369. {
  370. dom: 'Bftip',
  371. columnDefs: [{
  372. targets: 'no-sort',
  373. orderable: false
  374. }],
  375. lengthMenu: [
  376. [50, 100, 200, 500, -1],
  377. ['50 rows', '100 rows', '200 rows',
  378. '500 rows', 'Show all']],
  379. scrollY: '50vh',
  380. fixedColumns: {
  381. left: 1,
  382. right: 1
  383. },
  384. buttons: [buttons],
  385. responsive: true,
  386. searching: true, // Enable search
  387. select: false,
  388. processing: false,
  389. });
  390. // Link the search input to DataTable
  391. $('#searchInput').on('keyup', function () {
  392. dataTable.search(this.value).draw();
  393. });
  394. });
  395. function showDamageImage(imageUrl) {
  396. document.getElementById('filePreview').src = imageUrl;
  397. $('#fileModal').modal('show');
  398. }
  399. function settleTheAmount(bookingId) {
  400. window.location.href = '/communityhall/admin/adminpage?bookingId=' + bookingId;
  401. }
  402. function approve(settlementId) {
  403. $.ajax({
  404. type: "GET",
  405. url: '/communityhall/api/officer/getSettlementList',
  406. data: {
  407. 'settlementsid': settlementId
  408. },
  409. success: function (x) {
  410. showSettlementInfo(x)
  411. showDamageDetails(x);
  412. }
  413. });
  414. }
  415. function showSettlementInfo(list) {
  416. $('#settlementinformation').modal({
  417. backdrop: 'static',
  418. keyboard: false
  419. });
  420. $('#settlementinformation').modal('show');
  421. document.getElementById("settlementid").value = list.settlement.settlementId;
  422. document.getElementById("td_userName").innerHTML = list.users.name;
  423. document.getElementById("td_mobileNumber").innerHTML = list.users.mobileNo;
  424. document.getElementById("td_usertype").innerHTML = list.users.usertype;
  425. var userDetails = list.users;
  426. var userDetailsString =
  427. userDetails.doorNo + ", " +
  428. userDetails.street + ", " +
  429. userDetails.area + ", " +
  430. userDetails.location + " ,Chennai- " +
  431. userDetails.pinCode;
  432. document.getElementById("td_useraddress").innerHTML = userDetailsString;
  433. document.getElementById("td_bookingDate").innerHTML = list.bookingDate;
  434. document.getElementById("td_depositeAmount").innerHTML = "₹ " + parseFloat(list.depositAmount).toFixed(2);
  435. document.getElementById("td_hallAmount").innerHTML = "₹ " + parseFloat(list.hallAmount).toFixed(2);
  436. document.getElementById("td_totalAmount").innerHTML = "₹ " + parseFloat(list.amountReceived).toFixed(2);
  437. var gstcl = (list.hallAmount * (list.hallDetails.gst / 100));
  438. var formattedGst = gstcl.toFixed(2);
  439. document.getElementById("td_gst").innerHTML = "₹ " + formattedGst;
  440. document.getElementById("td_startDate").innerHTML = list.startDate;
  441. document.getElementById("td_endDate").innerHTML = list.endDate;
  442. document.getElementById("booking_id").innerHTML = list.bookingId;
  443. function getTimeSlot(slotValue) {
  444. var timeSlot;
  445. var trimmedSlotValue = String(slotValue).trim(); // Convert to string and then trim
  446. if (trimmedSlotValue === '1') {
  447. timeSlot = 'Morning';
  448. } else if (trimmedSlotValue === '2') {
  449. timeSlot = 'Evening';
  450. } else {
  451. timeSlot = 'Unknown';
  452. }
  453. return timeSlot;
  454. }
  455. document.getElementById("td_startingSlot").innerHTML = getTimeSlot(list.startingSlot);
  456. document.getElementById("td_endingSlot").innerHTML = getTimeSlot(list.endingSlot);
  457. document.getElementById("td_EBNumber").innerHTML = list.hallDetails.ebNumber;
  458. document.getElementById("td_startingReading").innerHTML = list.ebDetails.startingReading;
  459. document.getElementById("td_endingReading").innerHTML = list.ebDetails.endingReading;
  460. document.getElementById("td_usedunit").innerHTML = list.ebDetails.usedUnit;
  461. document.getElementById("td_ebamountperunit").innerHTML = "₹ " + parseFloat(list.hallDetails.ebCostPerUnit).toFixed(2);
  462. document.getElementById("td_depositeamountforrefund").innerHTML = "₹ " + parseFloat(list.depositAmount).toFixed(2);
  463. document.getElementById("td_ebAmount").innerHTML = "₹ " + parseFloat(list.ebDetails.ebAmount).toFixed(2);
  464. document.getElementById("td_electricityamount").innerHTML = "₹ " + parseFloat(list.ebDetails.ebAmount).toFixed(2);
  465. document.getElementById("td_damage").innerHTML = "₹ " + parseFloat(list.settlement.damageAmount).toFixed(2);
  466. var eb_amt = list.ebDetails.ebAmount;
  467. var deposit_amt = list.depositAmount;
  468. var tem_total = deposit_amt - eb_amt;
  469. $("#td_settel_amt").html('');
  470. $("#td_settel_amt").html(tem_total);
  471. }
  472. function showDamageDetails(data) {
  473. var damageFieldContainer = $('#damageDetails');
  474. damageFieldContainer.empty();
  475. // Create a div for table responsiveness
  476. var tableResponsiveDiv = $('<div>').addClass('table-responsive').css('margin-right', '-24px');
  477. // Create table with similar classes and styles to the modal table
  478. var table = $('<table>').addClass('table table-bordered table-striped').css({'width': '97%', 'border-color': 'black', 'border-top-color': 'white'});
  479. var thead = $('<thead>').addClass('thead-light');
  480. var tbody = $('<tbody>');
  481. // Create Damage Details header row
  482. var headerRow = $('<tr>').appendTo(thead);
  483. $('<th>').attr('colspan', '6').text('Damage Details (if any)').css({
  484. 'padding': '0.45rem 0.45rem',
  485. 'background-color': '#f2f2f2',
  486. 'font-weight': 'bold',
  487. 'color': 'black',
  488. }).appendTo(headerRow);
  489. // Create table header row
  490. var columnHeadersRow = $('<tr>').css('background-color', '#f2f2f2').appendTo(thead);
  491. $('<th>').text('S.No').css({'padding': '0.45rem 0.45rem', 'text-align': 'center'}).appendTo(columnHeadersRow);
  492. $('<th>').text('Asset Name').css({'padding': '0.45rem 0.45rem', 'text-align': 'center'}).appendTo(columnHeadersRow);
  493. $('<th>').text('Damage Img').css({'padding': '0.45rem 0.45rem', 'text-align': 'center'}).appendTo(columnHeadersRow);
  494. $('<th>').text('Cost').css({'padding': '0.45rem 0.45rem', 'text-align': 'center'}).appendTo(columnHeadersRow);
  495. $('<th>').text('Qty').css({'padding': '0.45rem 0.45rem', 'text-align': 'center'}).appendTo(columnHeadersRow);
  496. $('<th>').text('Amount').css({'padding': '0.45rem 0.45rem', 'text-align': 'center'}).appendTo(columnHeadersRow);
  497. var totalAmount = 0;
  498. // Check if damageList is empty
  499. if (data.damageList.length === 0) {
  500. var row = $('<tr>').appendTo(tbody);
  501. $('<td>').attr('colspan', '6').text('No Damaged Items').css({
  502. 'padding': '0.45rem 0.45rem',
  503. 'text-align': 'center',
  504. 'font-weight': 'bold',
  505. 'background-color': '#f2f2f2'
  506. }).appendTo(row);
  507. } else {
  508. $.each(data.damageList, function (index, detail) {
  509. var row = $('<tr>').appendTo(tbody);
  510. $('<td>').text(index + 1).css({
  511. 'padding': '0.45rem 0.45rem',
  512. 'text-align': 'center'
  513. }).appendTo(row);
  514. $('<td>').text(detail.assetName).css({
  515. 'padding': '0.45rem 0.45rem',
  516. 'text-align': 'center'
  517. }).appendTo(row);
  518. var viewLink = $('<a>').attr('href', 'javascript:void(0)').text('View').on('click', function () {
  519. showDamageImage(detail.damageImageUrl);
  520. });
  521. $('<td>').css({
  522. 'padding': '0.45rem 0.45rem',
  523. 'text-align': 'center'
  524. }).append(viewLink).appendTo(row);
  525. var assetamt = (detail.assetAmount / detail.quantity).toFixed(2);
  526. $('<td>').text('₹ ' + assetamt).css({
  527. 'padding': '0.45rem 0.45rem',
  528. 'text-align': 'center'
  529. }).appendTo(row);
  530. $('<td>').text(detail.quantity).css({
  531. 'padding': '0.45rem 0.45rem',
  532. 'text-align': 'center'
  533. }).appendTo(row);
  534. var amount = detail.assetAmount;
  535. totalAmount += amount;
  536. $('<td>').text('₹ ' + amount.toFixed(2)).css({
  537. 'padding': '0.45rem 0.45rem',
  538. 'text-align': 'right'
  539. }).appendTo(row);
  540. });
  541. // Add row for total amount
  542. var totalRow = $('<tr>').appendTo(tbody);
  543. $('<td>').attr('colspan', '5').text('Total Amount').css({
  544. 'padding': '0.45rem 0.45rem',
  545. 'font-weight': 'bold',
  546. 'background-color': '#f2f2f2'
  547. }).appendTo(totalRow);
  548. $('<td>').text('₹ ' + totalAmount.toFixed(2)).css({
  549. 'padding': '0.45rem 0.45rem',
  550. 'text-align': 'right'
  551. }).appendTo(totalRow);
  552. $("#td_dam_amt").html('₹ ' + totalAmount.toFixed(2));
  553. }
  554. // Append the table elements to the container div
  555. table.append(thead, tbody);
  556. tableResponsiveDiv.append(table);
  557. damageFieldContainer.append(tableResponsiveDiv);
  558. var temp_total = parseFloat($("#td_settel_amt").html());
  559. var settleAmount = temp_total - totalAmount;
  560. if (settleAmount < 0) {
  561. var pendingstatus = data.settlement.collectionStatus;
  562. $("#td_settel_amt").html(0);
  563. $("#pendingcolumn").show();
  564. $("#collectionstatuscolumn").show();
  565. $('#td_collection_status').html(pendingstatus);
  566. $("#td_pending_amt").html(Math.abs(settleAmount).toFixed(2));
  567. $("#td_pending_amt").css("color", "red");
  568. $("#approvebutton").show();
  569. $("#rejectbutton").show();
  570. } else {
  571. $("#td_settel_amt").html('₹ ' + settleAmount.toFixed(2));
  572. $("#pendingcolumn").hide();
  573. $("#collectionstatuscolumn").hide();
  574. $("#td_settel_amt").css("color", "green"); // Set color to green for positive amounts
  575. $("#approvebutton").hide();
  576. $("#rejectbutton").hide();
  577. }
  578. }
  579. function showDamageImage(damageImageUrl) {
  580. document.getElementById('filePreview').src = damageImageUrl;
  581. $('#fileModal').modal('show');
  582. }
  583. function accept() {
  584. let id = document.getElementById("settlementid").value;
  585. Swal.fire({
  586. title: 'Do you want to Approve this Settlement ?',
  587. showDenyButton: true,
  588. showCancelButton: true,
  589. confirmButtonText: 'YES',
  590. denyButtonText: 'NO',
  591. }).then((result) => {
  592. /* Read more about isConfirmed, isDenied below */
  593. if (result.isConfirmed) {
  594. $.ajax({
  595. type: "POST",
  596. url: '/communityhall/api/officer/updateApprovedSettlementStatus/' + id,
  597. data: {
  598. 'status': 'COMPLETED',
  599. 'comments': 'Accepted',
  600. 'settlementId': id
  601. },
  602. success: function (data, textStatus, xhr) {
  603. if (xhr.status === 200) { // Check if the response status is OK
  604. Swal.fire(
  605. 'Done',
  606. 'Successfully Accepted to the ID:' + id,
  607. 'success'
  608. ).then(() => {
  609. location.reload();
  610. });
  611. } else {
  612. Swal.fire(
  613. 'Error',
  614. 'Failed to accept the user',
  615. 'error'
  616. );
  617. }
  618. },
  619. error: function (xhr, textStatus, errorThrown) {
  620. Swal.fire(
  621. 'Error',
  622. 'Failed to accept the user',
  623. 'error'
  624. );
  625. }
  626. });
  627. } else if (result.isDenied) {
  628. Swal.fire('Changes are not saved', '', 'info')
  629. }
  630. });
  631. }
  632. function fetchQRCode(bookingId) {
  633. $.ajax({
  634. url: '/communityhall/careTaker/api/generateQRCode',
  635. type: 'GET',
  636. data: { bookingId: bookingId },
  637. success: function(data) {
  638. // Set the QR code image source
  639. $('#qrview').modal('show');
  640. $('#qrCodeImage').attr('src', 'data:image/png;base64,' + data);
  641. // console.log(data);
  642. },
  643. error: function(jqXHR, textStatus, errorThrown) {
  644. console.error('Error fetching QR code:', textStatus, errorThrown);
  645. }
  646. });
  647. }
  648. </script>
  649. </body>
  650. </html>