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.

628 lines
19 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
​
​
​
​
​
​
​
​
​
2 years ago
​
​
2 years ago
​
​
​
2 years ago
​
​
​
​
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
  3. <head th:replace="~{fragments/head :: head}">
  4. <script src="https://maps.googleapis.com/maps/api/js?key="></script>
  5. <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  6. </head>
  7. <style>
  8. /* Hide button and div2 on small screens */
  9. @media only screen and (max-width: 576px) {
  10. /* Adjust the font size for better readability on smaller screens */
  11. body {
  12. font-size: 14px;
  13. padding: 0 10px;
  14. }
  15. /* Modify the layout of certain elements */
  16. .col-sm-4 {
  17. width: 85%;
  18. margin-bottom: 10px;
  19. }
  20. .select2-container {
  21. width: 100% !important;
  22. margin-bottom: 10px;
  23. }
  24. .text-center {
  25. text-align: center !important;
  26. }
  27. #toggleButton {
  28. display: none;
  29. }
  30. #div2 {
  31. display: none;
  32. }
  33. .table-container {
  34. overflow-y: auto;
  35. display: flex;
  36. justify-content: center;
  37. align-items: center;
  38. height: 100%;
  39. }
  40. .table-responsive-md {
  41. overflow-x: auto;
  42. -webkit-overflow-scrolling: touch;
  43. width: 100%;
  44. }
  45. /* Custom CSS for table */
  46. #amountDetails {
  47. margin-top: 26px;
  48. width: 95%;
  49. }
  50. #amountDetails table {
  51. width: 100%;
  52. max-width: 100%;
  53. margin: 0 auto;
  54. border-collapse: collapse;
  55. }
  56. #amountDetails th,
  57. #amountDetails td {
  58. padding: 8px;
  59. border: 1px solid #ddd;
  60. text-align: left;
  61. word-wrap: break-word;
  62. white-space: normal;
  63. }
  64. /* Custom CSS for carousel */
  65. .thumbnail {
  66. cursor: pointer;
  67. }
  68. .carousel-item img {
  69. width: 100%;
  70. height: auto;
  71. }
  72. .carousel-image {
  73. max-height: 300px;
  74. width: auto;
  75. margin: 0 auto;
  76. }
  77. .carousel-control-prev,
  78. .carousel-control-next {
  79. color: black;
  80. }
  81. /* Custom CSS for amount details */
  82. #totalAmountDiv {
  83. margin-top: 20px;
  84. width: 100%;
  85. text-align: center;
  86. }
  87. #totalAmount {
  88. font-size: 18px;
  89. font-weight: bold;
  90. }
  91. }
  92. </style>
  93. <body>
  94. <!-- Pre-loader start -->
  95. <div class="theme-loader">
  96. <div class="ball-scale">
  97. <div class='contain'>
  98. <div class="ring">
  99. <div class="frame"></div>
  100. </div>
  101. <div class="ring">
  102. <div class="frame"></div>
  103. </div>
  104. <div class="ring">
  105. <div class="frame"></div>
  106. </div>
  107. <div class="ring">
  108. <div class="frame"></div>
  109. </div>
  110. <div class="ring">
  111. <div class="frame"></div>
  112. </div>
  113. <div class="ring">
  114. <div class="frame"></div>
  115. </div>
  116. <div class="ring">
  117. <div class="frame"></div>
  118. </div>
  119. <div class="ring">
  120. <div class="frame"></div>
  121. </div>
  122. <div class="ring">
  123. <div class="frame"></div>
  124. </div>
  125. <div class="ring">
  126. <div class="frame"></div>
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. <!-- Pre-loader end -->
  132. <div id="pcoded" class="pcoded">
  133. <div class="pcoded-container">
  134. <!-- Menu header start -->
  135. <nav th:replace="~{fragments/nav-user :: nav}"></nav>
  136. <!-- Menu header end -->
  137. <div class="pcoded-main-container">
  138. <nav th:replace="~{fragments/nav-usermenu :: nav}"></nav>
  139. <div class="pcoded-wrapper">
  140. <div class="pcoded-content">
  141. <div class="pcoded-inner-content">
  142. <!-- Main-body start -->
  143. <div class="main-body">
  144. <div class="page-wrapper">
  145. <!-- Page-header start -->
  146. <div class="page-header m-t-20"></div>
  147. <!-- Page-header end -->
  148. <!-- Page body start -->
  149. <div class="page-body">
  150. <div class="content">
  151. <div class="block block-rounded" style="width: 75%;margin-left: 12%;">
  152. <div class="block-header block-header-default">
  153. <h3 class="block-title">Calculate Rent Amount</h3>
  154. </div>
  155. <div class="block-content p-0">
  156. <div class="p-sm-4 p-0">
  157. <div class="row justify-content-center">
  158. <div class="col-sm-4 col-lg-6 col-md-4">
  159. <label for="selecthall">Select Hall:</label>
  160. <input type="hidden" id="hallIdDuplicate" value="">
  161. <select id="selecthall" class="form-control"
  162. name="hallId" required>
  163. <option value="">Select a hall</option>
  164. <!-- Dynamically populated options will be inserted here -->
  165. </select>
  166. </div>
  167. <br>
  168. <br>
  169. <div id="amountDetails"
  170. style="display:none; margin-top: 26px; width: 94%;">
  171. <div class="row justify-content-center">
  172. <div class="col-sm-4 col-lg-3 col-md-4"
  173. id="reasonforBookingdiv">
  174. <label for="reasonforBooking">Reason For
  175. Booking:</label>
  176. <select id="reasonforBooking"
  177. name="reasonforBooking" class="form-control"
  178. required>
  179. <option value="">Select</option>
  180. <option value="SGE">State Govt Event
  181. </option>
  182. <option value="CGE">Central Govt Event
  183. </option>
  184. <option value="MARRIAGE">Marriage</option>
  185. <option value="BIRTHDAY">BirthDay</option>
  186. <option value="COMMERCIAL">Commercial</option>
  187. <option value="others">Others</option>
  188. </select>
  189. </div>
  190. <div class="col-sm-4 col-lg-3 col-md-4">
  191. <label for="numDaysCount">Number of
  192. Days:</label>
  193. <select class="form-control" id="numDaysCount"
  194. name="days" required>
  195. <option value="">Select</option>
  196. <option value="1">1</option>
  197. <option value="2">2</option>
  198. <!--<option value="3">3</option>
  199. <option value="4">4</option>
  200. <option value="5">5</option>
  201. <option value="6">6</option>
  202. <option value="7">7</option>-->
  203. </select>
  204. </div>
  205. <div class="col-sm-4 col-lg-3 col-md-4"
  206. id="startPeriodDropdowndiv"> <label
  207. for="startPeriodDropdown">Start
  208. Period:</label>
  209. <select id="startPeriodDropdown"
  210. name="startingSlot" class="form-control"
  211. required>
  212. <option value="">Select</option>
  213. <option value="1">Morning (6:00 AM)</option>
  214. <option value="2">Evening (2:00 PM)</option>
  215. </select>
  216. </div>
  217. <div class="col-sm-4 col-lg-3 col-md-4"
  218. id="endPeriodDropdowndiv"> <label
  219. for="endPeriodDropdown">End Period:</label>
  220. <select id="endPeriodDropdown" name="endingSlot"
  221. class="form-control" required>
  222. <option value="">Select</option>
  223. <option value="1">Morning (2:00 PM)</option>
  224. <option value="2">Evening (10:00 PM)
  225. </option>
  226. </select>
  227. </div>
  228. </div>
  229. <br>
  230. <div class="text-center">
  231. <button id="calculateButton"
  232. class="btn btn-primary">Calculate</button>
  233. </div>
  234. <input type="hidden" id="selectedhallId">
  235. <div id="totalAmountDiv" class="text-center mt-3"
  236. style="display:none;">
  237. <table
  238. class="table table-bordered center-table table-align">
  239. <tbody>
  240. <tr>
  241. <td class="td-align"><strong> Hall
  242. Amount:</strong>
  243. </td>
  244. <td><span
  245. id="actualhallAmount_td">Rs</span>
  246. </td>
  247. </tr>
  248. <tr>
  249. <td class="td-align">
  250. <strong>Discount:</strong>
  251. </td>
  252. <td><span id="discount_td">0%</span>
  253. </td>
  254. </tr>
  255. <tr id="additionalcharges"
  256. style="display:none">
  257. <td class="td-align">
  258. <strong>Rent Amount:</strong>
  259. </td>
  260. <td><span id="rentamount_td">0</span>
  261. </td>
  262. </tr>
  263. <tr id="additionalcharges_tr"
  264. style="display:none">
  265. <td class="td-align">
  266. <strong>Additional charges (Cleaning
  267. + P.A.
  268. System + E.B):</strong>
  269. </td>
  270. <td><span
  271. id="additionalcharges_td">0</span>
  272. </td>
  273. </tr>
  274. <tr>
  275. <td class="td-align"><strong>Net
  276. Amount:</strong>
  277. </td>
  278. <td><span id="hallAmount_td">Rs</span>
  279. </td>
  280. </tr>
  281. <tr>
  282. <td class="td-align"><strong>GST
  283. Amount:</strong></td>
  284. <td><span id="gst_td">Rs</span></td>
  285. </tr>
  286. <tr>
  287. <td class="td-align"><strong>Deposit
  288. Amount:</strong></td>
  289. <td><span
  290. id="depositAmount_td">Rs</span>
  291. </td>
  292. </tr>
  293. <tr>
  294. <td class="td-align"><strong>Total
  295. Amount:</strong>
  296. </td>
  297. <td><span id="totalAmount_td">Rs</span>
  298. </td>
  299. </tr>
  300. </tbody>
  301. </table>
  302. </div>
  303. </div>
  304. </div>
  305. </div>
  306. </div>
  307. </div>
  308. </div>
  309. <!-- Page body end -->
  310. </div>
  311. </div>
  312. <!-- Main-body end -->
  313. </div>
  314. </div>
  315. </div>
  316. </div>
  317. </div>
  318. </div>
  319. </div>
  320. <footer th:replace="~{fragments/footer2 :: footer}"></footer>
  321. <!-- Login Modal-->
  322. <div th:replace="~{fragments/loginreg :: div}"></div>
  323. <script th:replace="~{fragments/script :: script}"></script>
  324. <script th:replace="~{fragments/logRegiOtpScript :: script}"></script>
  325. <script>
  326. function getHallDetails(hallId, callback) {
  327. $.ajax({
  328. type: 'GET',
  329. url: '/communityhall/user/api/gethalldetails/' + hallId,
  330. success: function (response) {
  331. callback(response);
  332. },
  333. error: function (xhr, status, error) {
  334. //console.error('Error fetching hall details:', error);
  335. }
  336. });
  337. }
  338. // Get hallId from URL parameters and fetch hall details
  339. const urlParams = new URLSearchParams(window.location.search);
  340. const hallId = urlParams.get('hallId');
  341. $(document).ready(function () {
  342. if (hallId != null) {
  343. getHallDetails(hallId, function (response) {
  344. $('#hallIdDuplicate').val(hallId);
  345. $('#selecthall').val(hallId);
  346. $('#fullDayAmount').data('amount', response.fullDayRent);
  347. $('#halfDayAmount').data('amount', response.halfDayRent);
  348. $('#depositAmount').data('amount', response.depositAmount);
  349. $('#gst').data('rate', response.gst);
  350. $('#amountDetails').show();
  351. $('#selecthall').prop('disabled', true);
  352. });
  353. }
  354. });
  355. // Populate the dropdown options with the received hall names
  356. $(function () {
  357. $("#selecthall").select2();
  358. });
  359. $.ajax({
  360. type: 'GET',
  361. url: '/communityhall/user/api/gethallnames',
  362. success: function (response) {
  363. var selectHallDropdown = $('#selecthall');
  364. $.each(response, function (index, hall) {
  365. selectHallDropdown.append($('<option></option>').attr('value', hall.hallId).text(hall.hallName));
  366. if (hallId == hall.hallId) {
  367. selectHallDropdown.find('option[value="' + hall.hallId + '"]').prop('selected', true);
  368. }
  369. });
  370. },
  371. error: function (xhr, status, error) {
  372. console.error('Error fetching hall names:', error);
  373. }
  374. });
  375. // Event listener for the Select Hall dropdown change
  376. $('#selecthall').change(function () {
  377. localStorage.clear();
  378. var hallId = $(this).val();
  379. if (hallId) {
  380. getHallDetails(hallId, function (response) {
  381. localStorage.setItem("isSGE",response.sge); // Fetch SGE status from the response
  382. localStorage.setItem("isCGE",response.cge);
  383. $('#fullDayAmount').text(response.fullDayRent.toFixed(2));
  384. $('#halfDayAmount').text(response.halfDayRent.toFixed(2));
  385. $('#depositAmount').text(response.depositAmount.toFixed(2));
  386. $('#gst').text(response.gst.toFixed(0) + '%');
  387. $('#reasonforBooking').val('');
  388. $('#numDaysCount').val(''); // Clear the numDaysCount dropdown
  389. $('#selectedhallId').val(hallId);
  390. // Reset the startDate and endDate fields
  391. $('#startPeriodDropdown').val('');
  392. $('#endPeriodDropdown').val('');
  393. $('#totalAmountDiv').hide();
  394. /*if (!isSGE) {
  395. $('#reasonforBookingdiv').hide();
  396. }*/
  397. // $('#reasonforBookingdiv').show();
  398. // Show the required amount details once hall is selected
  399. $('#amountDetails').show();
  400. });
  401. } else {
  402. // Hide the amount details if no hall is selected
  403. $('#amountDetails').hide();
  404. }
  405. });
  406. function calculateAmount(numDays, startPeriod, endPeriod, fullDayAmount, halfDayAmount) {
  407. var amount = 0;
  408. // If there is only one day
  409. if (numDays === 1) {
  410. if (startPeriod === "1" && endPeriod === "2") {
  411. amount = fullDayAmount;
  412. } else if (startPeriod === "1" && endPeriod === "1") {
  413. amount = halfDayAmount;
  414. } else if (startPeriod === "2" && endPeriod === "2") {
  415. amount = halfDayAmount;
  416. }
  417. } else {
  418. // For multiple days
  419. if (startPeriod === "1" && endPeriod === "2") {
  420. amount = fullDayAmount * numDays;
  421. } else if (startPeriod === "1" && endPeriod === "1") {
  422. amount = fullDayAmount * (numDays - 1) + halfDayAmount;
  423. } else if (startPeriod === "2" && endPeriod === "2") {
  424. amount = fullDayAmount * (numDays - 1) + halfDayAmount;
  425. }
  426. else if (startPeriod === "2" && endPeriod === "1") {
  427. amount = fullDayAmount * (numDays - 2) + halfDayAmount * 2;
  428. }
  429. }
  430. return amount;
  431. }
  432. function calculateGST(amount, gstRate) {
  433. return parseFloat(((amount * gstRate) / 100).toFixed(2));
  434. }
  435. function handlePeriodDropdowns(numDays, startPeriod) {
  436. if (numDays === 1 && startPeriod === "2") {
  437. $('#endPeriodDropdown').val("2");
  438. $('#endPeriodDropdown').prop('disabled', true);
  439. } else {
  440. $('#endPeriodDropdown').prop('disabled', false);
  441. }
  442. }
  443. $('#numDaysCount').change(function () {
  444. var numDays = parseInt($(this).val(), 10);
  445. var startPeriod = $('#startPeriodDropdown').val();
  446. handlePeriodDropdowns(numDays, startPeriod);
  447. });
  448. $('#startPeriodDropdown').change(function () {
  449. var numDays = parseInt($('#numDaysCount').val(), 10);
  450. var startPeriod = $(this).val();
  451. handlePeriodDropdowns(numDays, startPeriod);
  452. });
  453. $('#calculateButton').click(function () {
  454. /*alert(hallId);*/
  455. var hallId = $('#selectedhallId').val();
  456. /*alert("hallId:-"+hallId);*/
  457. if(hallId == undefined || hallId == ''){
  458. /*alert($('#hallIdDuplicate').val())*/
  459. hallId = $('#hallIdDuplicate').val();
  460. /*alert("hallId done :-"+hallId);*/
  461. }
  462. var numDays = parseInt($('#numDaysCount').val(), 10);
  463. var startPeriod = $('#startPeriodDropdown').val();
  464. var endPeriod = $('#endPeriodDropdown').val();
  465. var reasonForBooking = $('#reasonforBooking').val();
  466. // Validate input fields
  467. if (isNaN(numDays) || numDays < 1 || numDays > 7) {
  468. $('#numDaysCount')[0].setCustomValidity('Please select a valid number of days.');
  469. $('#numDaysCount')[0].reportValidity();
  470. return;
  471. }
  472. if (reasonforBooking === 'SGE') {
  473. var startPeriod = $('#startPeriodDropdown').val("1");
  474. var endPeriod = $('#endPeriodDropdown').val("2");
  475. }
  476. $.ajax({
  477. type: 'GET',
  478. url: '/communityhall/user/api/calculatehallamount',
  479. data: {
  480. hallId: hallId,
  481. numDays: numDays,
  482. startPeriod: startPeriod,
  483. endPeriod: endPeriod,
  484. reasonforBooking: reasonForBooking
  485. },
  486. success: function (response) {
  487. console.log(response);
  488. // Update HTML elements with the response data
  489. if ((response.reasonforBooking === 'SGE') || (response.reasonforBooking === 'CGE')) {
  490. if(response.startperiod==='1' && response.endPeriod === '2'){
  491. $('#actualhallAmount_td').text('₹' + response.fulldayhallAmount);
  492. }else{
  493. $('#actualhallAmount_td').text('₹' + response.halfdayhallAmount);
  494. }
  495. document.getElementById("additionalcharges").style.display = 'table-row'; // Show row
  496. document.getElementById("additionalcharges_tr").style.display = 'table-row'
  497. $('#discount_td').text(response.discount + '%');
  498. $("#rentamount_td").html(response.rentAmount);
  499. $("#additionalcharges_td").html('₹'+response.additionalCharges);
  500. $('#hallAmount_td').text('₹' + response.netAmount);
  501. $('#gst_td').text('₹' + response.gst);
  502. $('#depositAmount_td').text('₹' + response.depositAmount);
  503. $('#totalAmount_td').text('₹' + response.totalAmount);
  504. $('#totalAmountDiv').show();
  505. } else {
  506. $('#actualhallAmount_td').text('₹' + response.amount);
  507. $('#discount_td').text(response.discount + '%');
  508. $('#hallAmount_td').text('₹' + response.discountAmount);
  509. $('#gst_td').text('₹' + response.gst);
  510. $('#depositAmount_td').text('₹' + response.depositAmount);
  511. $('#totalAmount_td').text('₹' + response.totalAmount);
  512. document.getElementById("additionalcharges").style.display = 'none'; // Hide row
  513. document.getElementById("additionalcharges_tr").style.display = 'none'; // Hide row
  514. // Show the total amount div
  515. $('#totalAmountDiv').show();
  516. }
  517. },
  518. error: function (xhr, status, error) {
  519. console.error('Error occurred: ' + error);
  520. }
  521. });
  522. });
  523. document.addEventListener("DOMContentLoaded", function () {
  524. const reasonDropdown = document.getElementById("reasonforBooking");
  525. const numDaysDropdown = document.getElementById("numDaysCount");
  526. const startPeriodDropdown = document.getElementById("startPeriodDropdown");
  527. const endPeriodDropdown = document.getElementById("endPeriodDropdown");
  528. reasonDropdown.addEventListener("change", function () {
  529. const selectedValue = reasonDropdown.value;
  530. if (selectedValue === "MARRIAGE" || selectedValue === "COMMERCIAL") {
  531. // Enable dropdowns for Marriage and Commercial
  532. numDaysDropdown.disabled = false;
  533. numDaysDropdown.value = ""; // Allow the user to select
  534. startPeriodDropdown.disabled = false;
  535. startPeriodDropdown.value = ""; // Allow the user to select
  536. endPeriodDropdown.disabled = false;
  537. endPeriodDropdown.value = ""; // Allow the user to select
  538. } else {
  539. // Set to one day and disable for other events
  540. numDaysDropdown.value = "1";
  541. numDaysDropdown.disabled = true;
  542. // Reset and disable start and end period dropdowns
  543. startPeriodDropdown.value = "";
  544. startPeriodDropdown.disabled = false;
  545. endPeriodDropdown.value = "";
  546. endPeriodDropdown.disabled = false;
  547. }
  548. });
  549. });
  550. $('#reasonforBooking').change(function () {
  551. var isSGE = localStorage.getItem("isSGE") === "true";
  552. var isCGE = localStorage.getItem("isCGE") === "true";
  553. var reasonForBooking = $('#reasonforBooking').val();
  554. if ((reasonForBooking === 'SGE' && !isSGE) || (reasonForBooking === 'CGE' && !isCGE)) {
  555. // Show popup for Government Events
  556. Swal.fire({
  557. title: 'Government Event',
  558. text: 'Shenoy Nagar Community Center (Auditorium) full Mandapam (Amma Arangam) is available for state government events.',
  559. icon: 'info',
  560. confirmButtonText: 'OK'
  561. }).then((result) => {
  562. if (result.isConfirmed) {
  563. window.location.reload();
  564. }
  565. });
  566. }
  567. });
  568. </script>
  569. </body>
  570. </html>