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.

731 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-caretaker :: nav}"></nav>
  46. <header th:replace="~{fragments/header-caretaker :: 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. <script th:replace="~{fragments/script :: script}"></script>
  336. <footer th:replace="~{fragments/footer2 :: footer}"></footer>
  337. <script th:replace="~{fragments/loginscript :: script}"></script>
  338. <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
  339. <script>
  340. $(document).ready(
  341. function () {
  342. // DataTables buttons configuration
  343. var buttons = [{
  344. extend: 'pageLength',
  345. className: 'btn btn-primary'
  346. }, {
  347. title: 'Data export',
  348. extend: 'copyHtml5',
  349. text: 'Copy',
  350. className: 'btn btn-primary',
  351. id: 'copyBtn'
  352. }, {
  353. extend: 'excelHtml5',
  354. text: 'Excel',
  355. className: 'btn btn-primary',
  356. id: 'excelBtn'
  357. }, {
  358. extend: 'csvHtml5',
  359. text: 'CSV',
  360. className: 'btn btn-primary',
  361. id: 'csvBtn'
  362. }, {
  363. extend: 'pdfHtml5',
  364. text: 'PDF',
  365. className: 'btn btn-primary',
  366. id: 'pdfBtn'
  367. },
  368. ];
  369. $('#settlementListTable').DataTable(
  370. {
  371. dom: 'Bftip',
  372. columnDefs: [{
  373. targets: 'no-sort',
  374. orderable: false
  375. }],
  376. lengthMenu: [
  377. [50, 100, 200, 500, -1],
  378. ['50 rows', '100 rows', '200 rows',
  379. '500 rows', 'Show all']],
  380. scrollY: '50vh',
  381. fixedColumns: {
  382. left: 1,
  383. right: 1
  384. },
  385. buttons: [buttons],
  386. responsive: true,
  387. searching: true, // Enable search
  388. select: false,
  389. processing: false,
  390. });
  391. // Link the search input to DataTable
  392. $('#searchInput').on('keyup', function () {
  393. dataTable.search(this.value).draw();
  394. });
  395. });
  396. function showDamageImage(imageUrl) {
  397. document.getElementById('filePreview').src = imageUrl;
  398. $('#fileModal').modal('show');
  399. }
  400. function settleTheAmount(bookingId) {
  401. window.location.href = '/communityhall/caretaker/caretakerpage?bookingId=' + bookingId;
  402. }
  403. function approve(settlementId) {
  404. $.ajax({
  405. type: "GET",
  406. url: '/communityhall/api/officer/getSettlementList',
  407. data: {
  408. 'settlementsid': settlementId
  409. },
  410. success: function (x) {
  411. showSettlementInfo(x)
  412. showDamageDetails(x);
  413. }
  414. });
  415. }
  416. function showSettlementInfo(list) {
  417. $('#settlementinformation').modal({
  418. backdrop: 'static',
  419. keyboard: false
  420. });
  421. $('#settlementinformation').modal('show');
  422. document.getElementById("settlementid").value = list.settlement.settlementId;
  423. document.getElementById("td_userName").innerHTML = list.users.name;
  424. document.getElementById("td_mobileNumber").innerHTML = list.users.mobileNo;
  425. document.getElementById("td_usertype").innerHTML = list.users.usertype;
  426. var userDetails = list.users;
  427. var userDetailsString =
  428. userDetails.doorNo + ", " +
  429. userDetails.street + ", " +
  430. userDetails.area + ", " +
  431. userDetails.location + " ,Chennai- " +
  432. userDetails.pinCode;
  433. document.getElementById("td_useraddress").innerHTML = userDetailsString;
  434. document.getElementById("td_bookingDate").innerHTML = list.bookingDate;
  435. document.getElementById("td_depositeAmount").innerHTML = "₹ " + parseFloat(list.depositAmount).toFixed(2);
  436. document.getElementById("td_hallAmount").innerHTML = "₹ " + parseFloat(list.hallAmount).toFixed(2);
  437. document.getElementById("td_totalAmount").innerHTML = "₹ " + parseFloat(list.amountReceived).toFixed(2);
  438. var gstcl = (list.hallAmount * (list.hallDetails.gst / 100));
  439. var formattedGst = gstcl.toFixed(2);
  440. document.getElementById("td_gst").innerHTML = "₹ " + formattedGst;
  441. document.getElementById("td_startDate").innerHTML = list.startDate;
  442. document.getElementById("td_endDate").innerHTML = list.endDate;
  443. document.getElementById("booking_id").innerHTML = list.bookingId;
  444. function getTimeSlot(slotValue) {
  445. var timeSlot;
  446. var trimmedSlotValue = String(slotValue).trim(); // Convert to string and then trim
  447. if (trimmedSlotValue === '1') {
  448. timeSlot = 'Morning';
  449. } else if (trimmedSlotValue === '2') {
  450. timeSlot = 'Evening';
  451. } else {
  452. timeSlot = 'Unknown';
  453. }
  454. return timeSlot;
  455. }
  456. document.getElementById("td_startingSlot").innerHTML = getTimeSlot(list.startingSlot);
  457. document.getElementById("td_endingSlot").innerHTML = getTimeSlot(list.endingSlot);
  458. document.getElementById("td_EBNumber").innerHTML = list.hallDetails.ebNumber;
  459. document.getElementById("td_startingReading").innerHTML = list.ebDetails.startingReading;
  460. document.getElementById("td_endingReading").innerHTML = list.ebDetails.endingReading;
  461. document.getElementById("td_usedunit").innerHTML = list.ebDetails.usedUnit;
  462. document.getElementById("td_ebamountperunit").innerHTML = "₹ " + parseFloat(list.hallDetails.ebCostPerUnit).toFixed(2);
  463. document.getElementById("td_depositeamountforrefund").innerHTML = "₹ " + parseFloat(list.depositAmount).toFixed(2);
  464. document.getElementById("td_ebAmount").innerHTML = "₹ " + parseFloat(list.ebDetails.ebAmount).toFixed(2);
  465. document.getElementById("td_electricityamount").innerHTML = "₹ " + parseFloat(list.ebDetails.ebAmount).toFixed(2);
  466. document.getElementById("td_damage").innerHTML = "₹ " + parseFloat(list.settlement.damageAmount).toFixed(2);
  467. var eb_amt = list.ebDetails.ebAmount;
  468. var deposit_amt = list.depositAmount;
  469. var tem_total = deposit_amt - eb_amt;
  470. $("#td_settel_amt").html('');
  471. $("#td_settel_amt").html(tem_total);
  472. }
  473. function showDamageDetails(data) {
  474. var damageFieldContainer = $('#damageDetails');
  475. damageFieldContainer.empty();
  476. // Create a div for table responsiveness
  477. var tableResponsiveDiv = $('<div>').addClass('table-responsive').css('margin-right', '-24px');
  478. // Create table with similar classes and styles to the modal table
  479. var table = $('<table>').addClass('table table-bordered table-striped').css({'width': '97%', 'border-color': 'black', 'border-top-color': 'white'});
  480. var thead = $('<thead>').addClass('thead-light');
  481. var tbody = $('<tbody>');
  482. // Create Damage Details header row
  483. var headerRow = $('<tr>').appendTo(thead);
  484. $('<th>').attr('colspan', '6').text('Damage Details (if any)').css({
  485. 'padding': '0.45rem 0.45rem',
  486. 'background-color': '#f2f2f2',
  487. 'font-weight': 'bold',
  488. 'color': 'black',
  489. }).appendTo(headerRow);
  490. // Create table header row
  491. var columnHeadersRow = $('<tr>').css('background-color', '#f2f2f2').appendTo(thead);
  492. $('<th>').text('S.No').css({'padding': '0.45rem 0.45rem', 'text-align': 'center'}).appendTo(columnHeadersRow);
  493. $('<th>').text('Asset Name').css({'padding': '0.45rem 0.45rem', 'text-align': 'center'}).appendTo(columnHeadersRow);
  494. $('<th>').text('Damage Img').css({'padding': '0.45rem 0.45rem', 'text-align': 'center'}).appendTo(columnHeadersRow);
  495. $('<th>').text('Cost').css({'padding': '0.45rem 0.45rem', 'text-align': 'center'}).appendTo(columnHeadersRow);
  496. $('<th>').text('Qty').css({'padding': '0.45rem 0.45rem', 'text-align': 'center'}).appendTo(columnHeadersRow);
  497. $('<th>').text('Amount').css({'padding': '0.45rem 0.45rem', 'text-align': 'center'}).appendTo(columnHeadersRow);
  498. var totalAmount = 0;
  499. // Check if damageList is empty
  500. if (data.damageList.length === 0) {
  501. var row = $('<tr>').appendTo(tbody);
  502. $('<td>').attr('colspan', '6').text('No Damaged Items').css({
  503. 'padding': '0.45rem 0.45rem',
  504. 'text-align': 'center',
  505. 'font-weight': 'bold',
  506. 'background-color': '#f2f2f2'
  507. }).appendTo(row);
  508. } else {
  509. $.each(data.damageList, function (index, detail) {
  510. var row = $('<tr>').appendTo(tbody);
  511. $('<td>').text(index + 1).css({
  512. 'padding': '0.45rem 0.45rem',
  513. 'text-align': 'center'
  514. }).appendTo(row);
  515. $('<td>').text(detail.assetName).css({
  516. 'padding': '0.45rem 0.45rem',
  517. 'text-align': 'center'
  518. }).appendTo(row);
  519. var viewLink = $('<a>').attr('href', 'javascript:void(0)').text('View').on('click', function () {
  520. showDamageImage(detail.damageImageUrl);
  521. });
  522. $('<td>').css({
  523. 'padding': '0.45rem 0.45rem',
  524. 'text-align': 'center'
  525. }).append(viewLink).appendTo(row);
  526. var assetamt = (detail.assetAmount / detail.quantity).toFixed(2);
  527. $('<td>').text('₹ ' + assetamt).css({
  528. 'padding': '0.45rem 0.45rem',
  529. 'text-align': 'center'
  530. }).appendTo(row);
  531. $('<td>').text(detail.quantity).css({
  532. 'padding': '0.45rem 0.45rem',
  533. 'text-align': 'center'
  534. }).appendTo(row);
  535. var amount = detail.assetAmount;
  536. totalAmount += amount;
  537. $('<td>').text('₹ ' + amount.toFixed(2)).css({
  538. 'padding': '0.45rem 0.45rem',
  539. 'text-align': 'right'
  540. }).appendTo(row);
  541. });
  542. // Add row for total amount
  543. var totalRow = $('<tr>').appendTo(tbody);
  544. $('<td>').attr('colspan', '5').text('Total Amount').css({
  545. 'padding': '0.45rem 0.45rem',
  546. 'font-weight': 'bold',
  547. 'background-color': '#f2f2f2'
  548. }).appendTo(totalRow);
  549. $('<td>').text('₹ ' + totalAmount.toFixed(2)).css({
  550. 'padding': '0.45rem 0.45rem',
  551. 'text-align': 'right'
  552. }).appendTo(totalRow);
  553. $("#td_dam_amt").html('₹ ' + totalAmount.toFixed(2));
  554. }
  555. // Append the table elements to the container div
  556. table.append(thead, tbody);
  557. tableResponsiveDiv.append(table);
  558. damageFieldContainer.append(tableResponsiveDiv);
  559. var temp_total = parseFloat($("#td_settel_amt").html());
  560. var settleAmount = temp_total - totalAmount;
  561. if (settleAmount < 0) {
  562. var pendingstatus = data.settlement.collectionStatus;
  563. $("#td_settel_amt").html(0);
  564. $("#pendingcolumn").show();
  565. $("#collectionstatuscolumn").show();
  566. $('#td_collection_status').html(pendingstatus);
  567. $("#td_pending_amt").html(Math.abs(settleAmount).toFixed(2));
  568. $("#td_pending_amt").css("color", "red");
  569. $("#approvebutton").show();
  570. $("#rejectbutton").show();
  571. } else {
  572. $("#td_settel_amt").html('₹ ' + settleAmount.toFixed(2));
  573. $("#pendingcolumn").hide();
  574. $("#collectionstatuscolumn").hide();
  575. $("#td_settel_amt").css("color", "green"); // Set color to green for positive amounts
  576. $("#approvebutton").hide();
  577. $("#rejectbutton").hide();
  578. }
  579. }
  580. function showDamageImage(damageImageUrl) {
  581. document.getElementById('filePreview').src = damageImageUrl;
  582. $('#fileModal').modal('show');
  583. }
  584. function accept() {
  585. let id = document.getElementById("settlementid").value;
  586. Swal.fire({
  587. title: 'Do you want to Approve this Settlement ?',
  588. showDenyButton: true,
  589. showCancelButton: true,
  590. confirmButtonText: 'YES',
  591. denyButtonText: 'NO',
  592. }).then((result) => {
  593. /* Read more about isConfirmed, isDenied below */
  594. if (result.isConfirmed) {
  595. $.ajax({
  596. type: "POST",
  597. url: '/communityhall/api/officer/updateApprovedSettlementStatus/' + id,
  598. data: {
  599. 'status': 'COMPLETED',
  600. 'comments': 'Accepted',
  601. 'settlementId': id
  602. },
  603. success: function (data, textStatus, xhr) {
  604. if (xhr.status === 200) { // Check if the response status is OK
  605. Swal.fire(
  606. 'Done',
  607. 'Successfully Accepted to the ID:' + id,
  608. 'success'
  609. ).then(() => {
  610. location.reload();
  611. });
  612. } else {
  613. Swal.fire(
  614. 'Error',
  615. 'Failed to accept the user',
  616. 'error'
  617. );
  618. }
  619. },
  620. error: function (xhr, textStatus, errorThrown) {
  621. Swal.fire(
  622. 'Error',
  623. 'Failed to accept the user',
  624. 'error'
  625. );
  626. }
  627. });
  628. } else if (result.isDenied) {
  629. Swal.fire('Changes are not saved', '', 'info')
  630. }
  631. });
  632. }
  633. function fetchQRCode(bookingId) {
  634. $.ajax({
  635. url: '/communityhall/careTaker/api/generateQRCode',
  636. type: 'GET',
  637. data: { bookingId: bookingId },
  638. success: function(data) {
  639. // Set the QR code image source
  640. $('#qrview').modal('show');
  641. $('#qrCodeImage').attr('src', 'data:image/png;base64,' + data);
  642. // console.log(data);
  643. },
  644. error: function(jqXHR, textStatus, errorThrown) {
  645. console.error('Error fetching QR code:', textStatus, errorThrown);
  646. }
  647. });
  648. }
  649. </script>
  650. </body>
  651. </html>