Browse Source

Scheduler refund amount code disabled and right click disabled and coniditon added in 3rd step of hall booking form

master
Praveenkumartvmalai 1 year ago
parent
commit
267e7fe25e
  1. 24
      src/main/java/com/gcc/communityHall/paymentService/scheduler/PaymentStatusScheduler.java
  2. 12
      src/main/java/com/gcc/communityHall/service/Impl/BookingServiceImpl.java
  3. 210
      src/main/resources/templates/user/hallbookingform.html
  4. 495
      src/main/resources/templates/user/viewhistory.html

24
src/main/java/com/gcc/communityHall/paymentService/scheduler/PaymentStatusScheduler.java

@ -328,21 +328,21 @@ public class PaymentStatusScheduler {
} }
//need to be commented //need to be commented
@Transactional
public void intiateRefund(int bookingId, int userId) throws Exception {
List<BookingCalendar> bc = calendarService.getCalendarByBookingId(bookingId);
if (bc != null && bc.isEmpty()) {
String s = paymentGatewayServiceImpl.refundTheAmount(bookingId, userId);
if (s.equals("Refunded")) {
bookingService.updateRefundStatus(bookingId, BookingDetails.RefundStatus.COMPLETED);
}
// @Transactional
// public void intiateRefund(int bookingId, int userId) throws Exception {
// List<BookingCalendar> bc = calendarService.getCalendarByBookingId(bookingId);
// if (bc != null && bc.isEmpty()) {
// String s = paymentGatewayServiceImpl.refundTheAmount(bookingId, userId);
// if (s.equals("Refunded")) {
// bookingService.updateRefundStatus(bookingId, BookingDetails.RefundStatus.COMPLETED);
// }
} else {
bookingService.updateRefundStatus(bookingId, BookingDetails.RefundStatus.FAILURE);
}
// } else {
// bookingService.updateRefundStatus(bookingId, BookingDetails.RefundStatus.FAILURE);
// }
}
// }
} }

12
src/main/java/com/gcc/communityHall/service/Impl/BookingServiceImpl.java

@ -626,6 +626,7 @@ public class BookingServiceImpl implements BookingService {
@Override @Override
public Map<String, Object> saveBookingDetails(Map<String, Object> formData) { public Map<String, Object> saveBookingDetails(Map<String, Object> formData) {
Map<String, Object> hs = new HashMap<>(); Map<String, Object> hs = new HashMap<>();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
BookingDetails bookingDetails = null; BookingDetails bookingDetails = null;
Integer userId = userSession.getUserId(); Integer userId = userSession.getUserId();
@ -659,6 +660,16 @@ public class BookingServiceImpl implements BookingService {
bookingDetails.setHallDetails(hallDetails); bookingDetails.setHallDetails(hallDetails);
String startDate = formData.get("startDate").toString(); String startDate = formData.get("startDate").toString();
LocalDate startD = LocalDate.parse(startDate, formatter);
LocalDate today = LocalDate.now();
LocalDate sixMonthsLater = today.plusMonths(6);
if (startD.isBefore(today)) {
return Collections.singletonMap("status", "pastdate");
} else if (startD.isAfter(sixMonthsLater)) {
return Collections.singletonMap("status", "futuredate");
}
String endDate = formData.get("endDate").toString(); String endDate = formData.get("endDate").toString();
String relation = formData.get("relation").toString(); String relation = formData.get("relation").toString();
double days = Double.parseDouble(formData.get("days").toString()); double days = Double.parseDouble(formData.get("days").toString());
@ -852,7 +863,6 @@ public class BookingServiceImpl implements BookingService {
int i = 0; int i = 0;
String startDateStr = bookingDetails.getStartDate(); String startDateStr = bookingDetails.getStartDate();
String endDateStr = bookingDetails.getEndDate(); String endDateStr = bookingDetails.getEndDate();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate start = LocalDate.parse(startDateStr, formatter); LocalDate start = LocalDate.parse(startDateStr, formatter);
LocalDate end = LocalDate.parse(endDateStr, formatter); LocalDate end = LocalDate.parse(endDateStr, formatter);
int hallId = bookingDetails.getHallDetails().getHallId(); int hallId = bookingDetails.getHallDetails().getHallId();

210
src/main/resources/templates/user/hallbookingform.html

@ -930,6 +930,7 @@
bottom: 0; bottom: 0;
opacity: 0; opacity: 0;
} }
to { to {
bottom: 30px; bottom: 30px;
opacity: 1; opacity: 1;
@ -941,6 +942,7 @@
bottom: 30px; bottom: 30px;
opacity: 1; opacity: 1;
} }
to { to {
bottom: 0; bottom: 0;
opacity: 0; opacity: 0;
@ -957,11 +959,58 @@
color: white; color: white;
} }
/* css fror toast */
/* Toast styling */
#toast {
visibility: hidden;
min-width: 200px;
margin-left: -100px;
background: #333;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 10px;
position: fixed;
z-index: 9999;
left: 50%;
bottom: 30px;
font-size: 14px;
}
#toast.show {
visibility: visible;
animation: fadein 0.5s, fadeout 0.5s 2s;
}
@keyframes fadein {
from {
bottom: 10px;
opacity: 0;
}
to {
bottom: 30px;
opacity: 1;
}
}
@keyframes fadeout {
from {
bottom: 30px;
opacity: 1;
}
to {
bottom: 10px;
opacity: 0;
}
}
</style> </style>
<body> <body>
<!-- Pre-loader start -->
<div class="theme-loader">
<!-- Pre-loader start -->
<div class="theme-loader">
<div class="ball-scale"> <div class="ball-scale">
<div class='contain'> <div class='contain'>
<div class="ring"> <div class="ring">
@ -996,9 +1045,9 @@
</div> </div>
</div> </div>
</div> </div>
</div>
<!-- Pre-loader end -->
<div id="pcoded" class="pcoded">
</div>
<!-- Pre-loader end -->
<div id="pcoded" class="pcoded">
<div class="pcoded-container"> <div class="pcoded-container">
<!-- Menu header end --> <!-- Menu header end -->
<div class="pcoded-main-container"> <div class="pcoded-main-container">
@ -1226,7 +1275,8 @@
<button type="button" <button type="button"
class="btn btn-primary btn-square-md" class="btn btn-primary btn-square-md"
style="background-color:#008000;"></button> style="background-color:#008000;"></button>
<p style="margin-left: -7px;">Day(Available)</p>
<p style="margin-left: -7px;">Day(Available)
</p>
</div> </div>
<div class="col col-lg-2 col-sm-2 col-md-2"> <div class="col col-lg-2 col-sm-2 col-md-2">
<button type="button" <button type="button"
@ -1239,8 +1289,7 @@
<button type="button" <button type="button"
class="btn btn-primary btn-square-md" class="btn btn-primary btn-square-md"
style="background-color:#FFEA00;"></button> style="background-color:#FFEA00;"></button>
<p
style="margin-left: -8px;">
<p style="margin-left: -8px;">
Evening(Available)</p> Evening(Available)</p>
</div> </div>
<div class="col col-lg-2 col-sm-2 col-md-2"> <div class="col col-lg-2 col-sm-2 col-md-2">
@ -1484,18 +1533,21 @@
style="background-color: rgb(21,69,93); position: relative;"> style="background-color: rgb(21,69,93); position: relative;">
<img src="media/images/logo-sm.png" alt="Logo" <img src="media/images/logo-sm.png" alt="Logo"
style="position: absolute; left: 10px; top: 7px; height: 30px;"> style="position: absolute; left: 10px; top: 7px; height: 30px;">
<h6 style="color: white; text-align: center; line-height: 3.1;">
<h6
style="color: white; text-align: center; line-height: 3.1;">
Payment Details for Confirmation Payment Details for Confirmation
<span id="timer" <span id="timer"
style="display: inline; float:right;margin-right:10px;"> style="display: inline; float:right;margin-right:10px;">
<span class="sand-clock"></span> <!-- Hourglass icon -->
<span class="sand-clock"></span>
<!-- Hourglass icon -->
<span id="timerText">Payment Closes in 15:00</span> <span id="timerText">Payment Closes in 15:00</span>
<!-- Timer text --> <!-- Timer text -->
</span> </span>
</h6> </h6>
</div> </div>
<div class="col-md-12"> <div class="col-md-12">
<table class="table table-bordered center-table table-align">
<table
class="table table-bordered center-table table-align">
<tbody> <tbody>
<tr> <tr>
<td class="td-align"><strong>Full Name:</strong> <td class="td-align"><strong>Full Name:</strong>
@ -1520,7 +1572,8 @@
<tr> <tr>
<td class="td-align"><strong>Hall <td class="td-align"><strong>Hall
Name:</strong></td> Name:</strong></td>
<td class="td-align" style="text-wrap:wrap;">
<td class="td-align"
style="text-wrap:wrap;">
<span id="selecthall_td"></span> <span id="selecthall_td"></span>
</td> </td>
</tr> </tr>
@ -1613,9 +1666,11 @@
</td> </td>
<td><span id="rentamount_td">0</span></td> <td><span id="rentamount_td">0</span></td>
</tr> </tr>
<tr id="additionalcharges_tr" style="display:none">
<tr id="additionalcharges_tr"
style="display:none">
<td class="td-align"> <td class="td-align">
<strong>Additional charges (Cleaning + P.A.
<strong>Additional charges (Cleaning +
P.A.
System + E.B):</strong> System + E.B):</strong>
</td> </td>
<td><span id="additionalcharges_td">0</span> <td><span id="additionalcharges_td">0</span>
@ -1664,7 +1719,7 @@
<label data-toggle="tooltip" data-placement="top" <label data-toggle="tooltip" data-placement="top"
title="Click To View"> title="Click To View">
<input type="checkbox" id="checkin" <input type="checkbox" id="checkin"
onchange="togglePaymentButton(this)"/>
onchange="togglePaymentButton(this)" />
<a href="#" id="termsLink">I agree to the Terms and <a href="#" id="termsLink">I agree to the Terms and
Conditions</a> Conditions</a>
</label> </label>
@ -1688,9 +1743,9 @@
</div> </div>
</div> </div>
</div> </div>
</div>
<!-- Modal HTML for Bootstrap 5 -->
<div class="modal fade" id="termsModal" tabindex="-1" aria-labelledby="termsModalLabel" aria-hidden="true">
</div>
<!-- Modal HTML for Bootstrap 5 -->
<div class="modal fade" id="termsModal" tabindex="-1" aria-labelledby="termsModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg"> <div class="modal-dialog modal-lg">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
@ -1706,15 +1761,15 @@
</div> </div>
</div> </div>
</div> </div>
</div>
<div th:replace="~{fragments/loginreg :: div}"></div>
<script th:replace="~{fragments/script :: script}"></script>
<script th:replace="~{fragments/logRegiOtpScript :: script}"></script>
<script th:replace="~{fragments/PaymentScript :: script}"></script>
<script src="https://cdn.jsdelivr.net/npm/compressorjs@latest/dist/compressor.min.js"></script>
</div>
<div th:replace="~{fragments/loginreg :: div}"></div>
<script th:replace="~{fragments/script :: script}"></script>
<script th:replace="~{fragments/logRegiOtpScript :: script}"></script>
<script th:replace="~{fragments/PaymentScript :: script}"></script>
<script src="https://cdn.jsdelivr.net/npm/compressorjs@latest/dist/compressor.min.js"></script>
<!-- Payment script end-->
<script>
<!-- Payment script end-->
<script>
let reasonMaxData = new Map(); // in beginning let reasonMaxData = new Map(); // in beginning
let reasonLabelData = new Map(); let reasonLabelData = new Map();
let reasoncode = new Map(); let reasoncode = new Map();
@ -1975,6 +2030,24 @@
}).then(function () { }).then(function () {
location.reload(); // Example: reload the page location.reload(); // Example: reload the page
}); });
} else if (response.status === 'pastdate') {
Swal.fire({
icon: 'error',
title: 'Past Date',
text: 'Start date cannot be in the past',
confirmButtonText: 'OK'
}).then(function () {
location.reload();
});
} else if (response.status === 'futuredate') {
Swal.fire({
icon: 'error',
title: 'Future Date',
text: 'Start date cannot be more than 6 months from today',
confirmButtonText: 'OK'
}).then(function () {
location.reload();
});
} else { } else {
userId = response.userId; userId = response.userId;
bookingId = response.bookingId; bookingId = response.bookingId;
@ -2139,7 +2212,7 @@
url: '/communityhall/admin/api/getReasonDocumentDetails', url: '/communityhall/admin/api/getReasonDocumentDetails',
type: 'GET', type: 'GET',
dataType: 'json', dataType: 'json',
data: {reasonId: reasonId}
data: { reasonId: reasonId }
}) })
.done(function (data) { .done(function (data) {
validateForm(); validateForm();
@ -2888,15 +2961,15 @@
const endPeriod = parseInt(getEndPeriodValue()); // Use getEndPeriodValue here const endPeriod = parseInt(getEndPeriodValue()); // Use getEndPeriodValue here
const periodText = { const periodText = {
0: {text: "select", time: ""},
1: {text: "Morning", time: "6:00 AM"},
2: {text: "Afternoon", time: "2:00 PM"}
0: { text: "select", time: "" },
1: { text: "Morning", time: "6:00 AM" },
2: { text: "Afternoon", time: "2:00 PM" }
}; };
const endPeriodText = { const endPeriodText = {
0: {text: "select", time: ""},
1: {text: "Afternoon", time: "2:00 PM"},
2: {text: "Evening", time: "10:00 PM"}
0: { text: "select", time: "" },
1: { text: "Afternoon", time: "2:00 PM" },
2: { text: "Evening", time: "10:00 PM" }
}; };
const startDate = new Date(startDateStr); const startDate = new Date(startDateStr);
@ -3114,9 +3187,9 @@
$("#numDaysCount").val(''); $("#numDaysCount").val('');
validateForm(); validateForm();
if ((selectedDate === currentDateString && currentHours >= 6 )|| bookingStatus[0]) {
if ((selectedDate === currentDateString && currentHours >= 6) || bookingStatus[0]) {
$("#startPeriodDropdown option[value='1']").prop("disabled", true); $("#startPeriodDropdown option[value='1']").prop("disabled", true);
}else if (bookingStatus[1]) {
} else if (bookingStatus[1]) {
$("#startPeriodDropdown option[value='2']").prop("disabled", true); $("#startPeriodDropdown option[value='2']").prop("disabled", true);
} }
updateEndDate(selectedDate); updateEndDate(selectedDate);
@ -3333,6 +3406,71 @@
} }
timerElement.innerHTML = "Timer Stopped"; // Optionally update the message timerElement.innerHTML = "Timer Stopped"; // Optionally update the message
} }
</script>
(function () {
function block(e) {
e.preventDefault();
e.stopPropagation();
return false;
}
// Disable right‑click
window.addEventListener('contextmenu', block, true);
// 2) Disable drag (images/text) — optional
// window.addEventListener('dragstart', block, true);
// 3) Disable common DevTools / view‑source shortcuts
window.addEventListener('keydown', function (e) {
// Normalize: e.key is a string like 'F12' or 'I'; keyCode is a number (deprecated but useful for older browsers)
var key = e.key;
var code = e.keyCode || e.which;
// F12 (DevTools)
if (key === 'F12' || code === 123) return block(e);
// Ctrl+Shift+I/J/C (DevTools / Inspect / Console)
if (e.ctrlKey && e.shiftKey && (key === 'I' || key === 'J' || key === 'C' || code === 73 || code === 74 || code === 67)) return block(e);
// Ctrl+U (view source)
if (e.ctrlKey && (key === 'u' || key === 'U' || code === 85)) return block(e);
// Ctrl+S (save page)
if (e.ctrlKey && (key === 's' || key === 'S' || code === 83)) return block(e);
// Firefox specific shortcuts
// Ctrl+Shift+K opens Web Console
if (e.ctrlKey && e.shiftKey && (key === 'K' || code === 75)) return block(e);
// Ctrl+Shift+E opens Network Monitor
if (e.ctrlKey && e.shiftKey && (key === 'E' || code === 69)) return block(e);
}, true);
let threshold = 160;
setInterval(function () {
if (window.outerHeight - window.innerHeight > threshold ||
window.outerWidth - window.innerWidth > threshold) {
document.body.innerHTML = "<h1 style='color:red;text-align:center;margin-top:20%'>DevTools detected. Page disabled.</h1>";
}
}, 500);
})();
function showToast(msg) {
var toast = document.getElementById("toast");
toast.textContent = msg;
toast.className = "show";
setTimeout(function () {
toast.className = toast.className.replace("show", "");
}, 2500);
}
$(document).on("contextmenu",
"#ui-datepicker-div td, #ui-datepicker-div a, #ui-datepicker-div .ui-datepicker-title", function (e) {
e.preventDefault();
showToast("Right-click disabled");
return false;
});
</script>
</body> </body>
</html> </html>

495
src/main/resources/templates/user/viewhistory.html

@ -504,11 +504,26 @@
cursor: pointer; cursor: pointer;
} }
.otp-input-box {
display: flex;
justify-content: center;
gap: 10px;
margin: 20px 0;
}
.otp-input-box .otp-input {
width: 40px;
height: 40px;
text-align: center;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 5px;
}
</style> </style>
<body> <body>
<!-- Pre-loader start -->
<div class="theme-loader">
<!-- Pre-loader start -->
<div class="theme-loader">
<div class="ball-scale"> <div class="ball-scale">
<div class='contain'> <div class='contain'>
<div class="ring"> <div class="ring">
@ -543,10 +558,10 @@
</div> </div>
</div> </div>
</div> </div>
</div>
<!-- Pre-loader end -->
</div>
<!-- Pre-loader end -->
<div id="pcoded" class="pcoded">
<div id="pcoded" class="pcoded">
<div class="pcoded-container"> <div class="pcoded-container">
<!-- Menu header start --> <!-- Menu header start -->
<nav th:replace="~{fragments/nav-user :: nav}"></nav> <nav th:replace="~{fragments/nav-user :: nav}"></nav>
@ -844,7 +859,7 @@
</tr> </tr>
<input type="hidden" <input type="hidden"
class="form-control text-center" class="form-control text-center"
name="bookingid" id="bookingid" disabled/>
name="bookingid" id="bookingid" disabled />
<tr> <tr>
<th colspan="10" <th colspan="10"
style="background-color: lightgrey;"> style="background-color: lightgrey;">
@ -1322,8 +1337,7 @@
<embed id="filePreview" src="" width="100%" height="600px"> <embed id="filePreview" src="" width="100%" height="600px">
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary"
data-bs-dismiss="modal">Close
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close
</button> </button>
</div> </div>
</div> </div>
@ -1342,7 +1356,7 @@
<br> <br>
<div style="margin-bottom: -59px; margin-left: -185px;"> <div style="margin-bottom: -59px; margin-left: -185px;">
<!-- Adding margin-top for separation --> <!-- Adding margin-top for separation -->
<p style="font-size: 14px; color: #6c757d;">Note: Only the Start Date can be
<p style="font-size: 14px; color: #6c757d;"> the Start Date can be
changed.</p> changed.</p>
</div> </div>
<button type="button" class="btn-close" data-bs-dismiss="modal" <button type="button" class="btn-close" data-bs-dismiss="modal"
@ -1430,8 +1444,7 @@
</div> </div>
<!-- Modal Footer --> <!-- Modal Footer -->
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary"
data-bs-dismiss="modal">Close
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close
</button> </button>
<button type="button" class="btn btn-primary" onclick="Reschedule()">Save <button type="button" class="btn btn-primary" onclick="Reschedule()">Save
Changes Changes
@ -1441,6 +1454,61 @@
</div> </div>
</div> </div>
<!-- Reschedule OTP Verification Modal -->
<div class="modal fade" id="rescheduleOtpModal" tabindex="-1" role="dialog"
aria-labelledby="rescheduleOtpModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h6 class="modal-title m-0" id="rescheduleOtpModalLabel">Reschedule Verification
</h6>
<button type="button" class="btn-close" data-bs-dismiss="modal"
aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="row">
<div class="mb-3 text-center">
<img src="media/images/mobileotp.png" width="50%" alt="Mobileotp">
</div>
<div class="mb-0 text-center">
<h4>OTP Verification</h4>
<p class="text-mute">Enter the OTP sent to <b class="text-info"
id="rescheduleMobileTxt"></b></p>
<p class="text-danger" id="rescheduleOtpError"></p>
</div>
<div class="mb-3 text-center">
<div class="otp-input-box">
<input type="text" maxlength="1" class="otp-input" id="rescheduleOtp1"
required />
<input type="text" maxlength="1" class="otp-input" id="rescheduleOtp2"
required />
<input type="text" maxlength="1" class="otp-input" id="rescheduleOtp3"
required />
<input type="text" maxlength="1" class="otp-input" id="rescheduleOtp4"
required />
<input type="text" maxlength="1" class="otp-input" id="rescheduleOtp5"
required />
</div>
</div>
<div class="mb-3 text-center">
<div id="rescheduleResendContainer">
<p class="mb-0">Didn't receive OTP?</p>
<p class="mb-0 text-info" id="rescheduleResendLink">Please wait..<span
id="rescheduleCountdown">60</span>s</p>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary btn-sm"
data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary btn-sm"
onclick="verifyRescheduleOtp()">Verify OTP</button>
</div>
</div>
</div>
</div>
<!-- Tracking Log Modal --> <!-- Tracking Log Modal -->
<!-- Tracking Modal --> <!-- Tracking Modal -->
<div class="modal fade" id="trackingModal" tabindex="-1" aria-labelledby="trackingModalLabel" <div class="modal fade" id="trackingModal" tabindex="-1" aria-labelledby="trackingModalLabel"
@ -1482,8 +1550,7 @@
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary"
data-bs-dismiss="modal">Close
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close
</button> </button>
<button type="button" class="btn btn-primary" id="submitNocButton">Submit</button> <button type="button" class="btn btn-primary" id="submitNocButton">Submit</button>
</div> </div>
@ -1541,8 +1608,7 @@
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary"
data-bs-dismiss="modal">Close
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close
</button> </button>
</div> </div>
</div> </div>
@ -1564,6 +1630,16 @@
<script src="https://cdn.datatables.net/buttons/2.4.1/js/dataTables.buttons.min.js"></script> <script src="https://cdn.datatables.net/buttons/2.4.1/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.4.1/js/buttons.html5.min.js"></script> <script src="https://cdn.datatables.net/buttons/2.4.1/js/buttons.html5.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
// Reschedule variables
var rescheduleBookingId = null;
var rescheduleStartDate = null;
var rescheduleEndDate = null;
var rescheduleMobileNumber = null;
var rescheduleHallId = null;
var rescheduleStartingSlot = null;
var rescheduleEndingSlot = null;
var rescheduleReason = null;
$(document).ready(function () { $(document).ready(function () {
$('#detailstable').DataTable({ $('#detailstable').DataTable({
responsive: true, responsive: true,
@ -1649,7 +1725,7 @@
$.ajax({ $.ajax({
url: '/communityhall/user/api/trackBooking', url: '/communityhall/user/api/trackBooking',
method: 'GET', method: 'GET',
data: {bookingId: bookingId}, // Send booking ID to the server
data: { bookingId: bookingId }, // Send booking ID to the server
success: function (data) { success: function (data) {
// console.log("Received tracking data:", data); // console.log("Received tracking data:", data);
@ -1778,7 +1854,7 @@
$.ajax({ $.ajax({
url: '/communityhall/user/api/viewAllBookingDetails', url: '/communityhall/user/api/viewAllBookingDetails',
method: 'GET', method: 'GET',
data: {bookingId: bookingId},
data: { bookingId: bookingId },
success: function (response) { success: function (response) {
document.getElementById("td_userName").innerHTML = response.users.name; document.getElementById("td_userName").innerHTML = response.users.name;
document.getElementById("td_mobileNumber").innerHTML = response.users.mobileNo; document.getElementById("td_mobileNumber").innerHTML = response.users.mobileNo;
@ -1835,7 +1911,7 @@
document.getElementById("bookingstatus_td").innerHTML = response.bookingStatus; document.getElementById("bookingstatus_td").innerHTML = response.bookingStatus;
console.log("before comments user view history..."); console.log("before comments user view history...");
console.log("Comments..."+response.comments);
console.log("Comments..." + response.comments);
if (response.bookingStatus === 'REJECTED' && response.comments) { if (response.bookingStatus === 'REJECTED' && response.comments) {
document.getElementById("rejectionreasondiv").style.display = "block"; document.getElementById("rejectionreasondiv").style.display = "block";
@ -2177,6 +2253,43 @@
} }
} }
function resetRescheduleOTPSection() {
// Hide OTP section
var otpSection = document.getElementById("otpSection");
if (otpSection) {
otpSection.style.display = "none";
}
// Show reschedule button and hide verify button
var rescheduleBtn = document.getElementById("rescheduleBtn");
var verifyOtpBtn = document.getElementById("verifyOtpBtn");
if (rescheduleBtn) {
rescheduleBtn.style.display = "inline-block";
}
if (verifyOtpBtn) {
verifyOtpBtn.style.display = "none";
}
// Clear OTP input fields
for (let i = 1; i <= 6; i++) {
var otpField = document.getElementById("otp" + i);
if (otpField) {
otpField.value = "";
}
}
// Reset variables
rescheduleBookingId = null;
rescheduleStartDate = null;
rescheduleEndDate = null;
rescheduleMobileNumber = null;
rescheduleHallId = null;
rescheduleStartingSlot = null;
rescheduleEndingSlot = null;
rescheduleReason = null;
}
function openRescheduleModal(bookingId, startDate, endDate, noOfDays, hallId, startingSlot, endingSlot, reason) { function openRescheduleModal(bookingId, startDate, endDate, noOfDays, hallId, startingSlot, endingSlot, reason) {
// Function to map slot values to their text representation // Function to map slot values to their text representation
function getSlotText(slot) { function getSlotText(slot) {
@ -2205,10 +2318,19 @@
document.getElementById("startingSlotText").value = getSlotText(startingSlot); document.getElementById("startingSlotText").value = getSlotText(startingSlot);
document.getElementById("endingSlotText").value = getSlotText(endingSlot); document.getElementById("endingSlotText").value = getSlotText(endingSlot);
// Store booking details for OTP verification
rescheduleBookingId = bookingId;
rescheduleStartDate = startDate;
rescheduleEndDate = endDate;
rescheduleHallId = hallId;
rescheduleStartingSlot = startingSlot;
rescheduleEndingSlot = endingSlot;
rescheduleReason = reason;
// Optionally, fetch and update calendar or availability based on hallId // Optionally, fetch and update calendar or availability based on hallId
getBookingCalendar(hallId, reason); getBookingCalendar(hallId, reason);
// Show the modal
// Show the date change modal
$('#bookingRescheduleModal').modal('show'); $('#bookingRescheduleModal').modal('show');
} }
@ -2314,6 +2436,40 @@
updateEndDate(selectedDate, noofdays, startingSlot, endingSlot); updateEndDate(selectedDate, noofdays, startingSlot, endingSlot);
}); });
// Handle changes in the start date input
// $("#startDateInput").on("change", function () {
// const selectedDate = $(this).val();
// const bookingStatus = window.bookingResponse[selectedDate] || {};
// const currentHours = new Date().getHours();
// const currentDateString = $("#serverDate").val();
// $("#startPeriodDropdown option").prop("disabled", false);
// $("#startPeriodDropdown").val(0).prop("disabled", false);
// $("#endPeriodDropdown").val(0).prop("disabled", false);
// $("#numDaysCount").val('');
// validateForm();
// // Disable Morning slot for today between 6 AM and 2 PM
// if (selectedDate === currentDateString && currentHours >= 6 && currentHours < 14) {
// $("#startPeriodDropdown option[value='1']").prop("disabled", true);
// Swal.fire({
// title: 'Morning Slot Not Available',
// text: 'You can only book Evening Slot for today between 6 AM and 2 PM.',
// icon: 'warning',
// confirmButtonText: 'OK'
// });
// } else {
// if ((selectedDate === currentDateString && currentHours >= 6) || bookingStatus[0]) {
// $("#startPeriodDropdown option[value='1']").prop("disabled", true);
// } else if (bookingStatus[1]) {
// $("#startPeriodDropdown option[value='2']").prop("disabled", true);
// }
// }
// updateEndDate(selectedDate);
// });
} }
function handleBookingStatus(bookingStatus, defaultMessage) { function handleBookingStatus(bookingStatus, defaultMessage) {
@ -2614,72 +2770,282 @@
} }
function Reschedule() { function Reschedule() {
// Retrieve values from modal inputs
var bookingId = document.getElementById("bookingId").value;
var startDate = document.getElementById("startDateInput").value;
var endDate = document.getElementById("endDateInput").value;
var originalStartDate = document.getElementById("startDatetext").value;
// Get mobile number and show OTP modal for verification
$.ajax({
type: "GET",
url: '/communityhall/user/api/viewAllBookingDetails',
data: { bookingId: rescheduleBookingId },
success: function (response) {
rescheduleMobileNumber = response.users.mobileNo;
// Check if the rescheduled start date is the same as the original booked start date
if (startDate === originalStartDate) {
// Show mobile number in OTP modal
document.getElementById("rescheduleMobileTxt").textContent = rescheduleMobileNumber;
// Clear any previous OTP errors
document.getElementById("rescheduleOtpError").textContent = "";
// Clear OTP inputs
for (let i = 1; i <= 5; i++) {
document.getElementById("rescheduleOtp" + i).value = "";
}
// Close date change modal and show OTP modal
$('#bookingRescheduleModal').modal('hide');
$('#rescheduleOtpModal').modal('show');
// Send OTP immediately
sendRescheduleOTP(rescheduleMobileNumber);
},
error: function () {
Swal.fire({ Swal.fire({
icon: 'warning',
title: 'Warning',
text: 'Your Rescheduled Start Date is the same as Your booking Start Date. Please change the date.',
icon: 'error',
title: 'Error',
text: 'Failed to get booking details. Please try again.',
showConfirmButton: true showConfirmButton: true
}); });
return;
} }
if (!endDate) {
});
}
function sendRescheduleOTP(mobileNumber) {
$.ajax({
type: "GET",
url: "/communityhall/user/api/sendOTP",
data: {
mobileNo: mobileNumber,
purpose: "reschedule"
},
success: function (response) {
// Start countdown timer
startRescheduleCountdown();
},
error: function () {
Swal.fire({ Swal.fire({
icon: 'error', icon: 'error',
title: 'Error', title: 'Error',
text: 'End Date is Empty! Please check your Start Date', // Error message from backend
text: 'Failed to send OTP. Please try again.',
showConfirmButton: true showConfirmButton: true
}); });
return;
} }
});
}
function startRescheduleCountdown() {
var resendTimeout;
var resendLink = $("#rescheduleResendLink");
$("#rescheduleResendLink").html('<a href="#" id="rescheduleResendLink" class="text-info" onclick="return resendRescheduleOTP();">Resend OTP</a>');
var countdown = $("#rescheduleCountdown");
function startCountdown() {
var timeleft = 60;
countdown.text(timeleft);
resendTimeout = setInterval(function () {
timeleft--;
countdown.text(timeleft);
if (timeleft <= 0) {
clearInterval(resendTimeout);
$("#rescheduleResendLink").html('<a href="#" id="rescheduleResendLink" class="text-info" onclick="return sendRescheduleOTP(' + rescheduleMobileNumber + ');">Resend OTP</a>');
}
}, 1000);
}
startCountdown();
}
function resendRescheduleOTP() {
if (rescheduleMobileNumber) {
sendRescheduleOTP(rescheduleMobileNumber);
// Restart countdown timer after resending OTP
startRescheduleCountdown();
}
}
function verifyRescheduleOtp() {
// Get all the input fields with class `otp-input`
var otpInputs = $('.otp-input');
// Get the OTP value as a string
var otpValue = '';
otpInputs.each(function () {
otpValue += $(this).val();
});
if (otpValue.length !== 5) {
document.getElementById("rescheduleOtpError").textContent = "Please enter complete OTP";
return false;
}
// Verify OTP
$.ajax({
type: "GET",
url: "/communityhall/user/api/verifyofficialOTP",
data: {
otp: otpValue
},
dataType: 'text',
success: function (response) {
if (response.trim() === "Success") {
// OTP verified successfully, close OTP modal and proceed with reschedule
$('#rescheduleOtpModal').modal('hide');
validateDatesAndReschedule();
} else {
document.getElementById("rescheduleOtpError").textContent = "OTP is Incorrect!!!";
// Clear OTP inputs
for (let i = 1; i <= 5; i++) {
document.getElementById("rescheduleOtp" + i).value = "";
}
}
},
error: function () {
document.getElementById("rescheduleOtpError").textContent = "Error verifying OTP. Please try again.";
}
});
return false;
}
function proceedWithReschedule() {
// Debug: Log the data being sent
console.log('Reschedule data:', {
bookingId: rescheduleBookingId,
startDate: rescheduleStartDate,
endDate: rescheduleEndDate
});
// Ajax POST request
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "/communityhall/user/api/reschedule-dates", url: "/communityhall/user/api/reschedule-dates",
data: { data: {
bookingId: bookingId,
startDate: startDate,
endDate: endDate
bookingId: rescheduleBookingId,
startDate: rescheduleStartDate,
endDate: rescheduleEndDate
}, },
success: function (response) { success: function (response) {
// Handle success response
Swal.fire({ Swal.fire({
icon: 'success', icon: 'success',
title: 'Success', title: 'Success',
text: response, // Success message from backend
showConfirmButton: false,
timer: 1500
}).then(function () {
// Optionally reload page or update UI
location.reload(); // Example: reload the page
text: 'Booking rescheduled successfully!',
showConfirmButton: true
}).then((result) => {
if (result.isConfirmed) {
// Close modal and reload page
$('#bookingRescheduleModal').modal('hide');
location.reload();
}
}); });
}, },
error: function (xhr, status, error) { error: function (xhr, status, error) {
if (xhr.responseText.includes("Dates are already occupied")) {
console.error('Reschedule API Error:', {
status: xhr.status,
statusText: xhr.statusText,
responseText: xhr.responseText,
error: error
});
let errorMessage = 'Failed to reschedule booking. Please try again.';
if (xhr.responseText) {
try {
const errorData = JSON.parse(xhr.responseText);
errorMessage = errorData.message || errorData.error || errorMessage;
} catch (e) {
errorMessage = xhr.responseText || errorMessage;
}
}
Swal.fire({ Swal.fire({
icon: 'error', icon: 'error',
title: 'Error', title: 'Error',
text: 'Dates are already occupied. Please select another date.', // Error message from backend
text: errorMessage,
showConfirmButton: true showConfirmButton: true
}); });
} else {
}
});
}
function validateDatesAndReschedule() {
// Retrieve values from modal inputs
var startDate = document.getElementById("startDateInput").value;
var endDate = document.getElementById("endDateInput").value;
var originalStartDate = document.getElementById("startDatetext").value;
// Debug: Log the retrieved dates
console.log('Retrieved dates:', {
startDate: startDate,
endDate: endDate,
originalStartDate: originalStartDate
});
// Check if the rescheduled start date is the same as the original booked start date
if (startDate === originalStartDate) {
Swal.fire({
icon: 'warning',
title: 'Warning',
text: 'Your Rescheduled Start Date is the same as Your booking Start Date. Please change the date.',
showConfirmButton: true
});
return;
}
if (!endDate) {
Swal.fire({ Swal.fire({
icon: 'error', icon: 'error',
title: 'Error', title: 'Error',
text: 'An error occurred while rescheduling your booking. Please try again.', // General error message
text: 'End Date is Empty! Please check your Start Date',
showConfirmButton: true showConfirmButton: true
}); });
return;
} }
}
// Store the validated dates
rescheduleStartDate = startDate;
rescheduleEndDate = endDate;
// Debug: Log the final dates being sent
console.log('Final reschedule dates:', {
startDate: rescheduleStartDate,
endDate: rescheduleEndDate,
bookingId: rescheduleBookingId
}); });
// Proceed with reschedule
proceedWithReschedule();
} }
$(document).ready(function () { $(document).ready(function () {
@ -2693,7 +3059,7 @@
$('#simpletable').DataTable({ $('#simpletable').DataTable({
dom: 'Bftip', dom: 'Bftip',
columnDefs: [ columnDefs: [
{targets: 'no-sort', orderable: false}
{ targets: 'no-sort', orderable: false }
], ],
lengthMenu: [ lengthMenu: [
[5, 10, 20, 50, -1], [5, 10, 20, 50, -1],
@ -2724,10 +3090,10 @@
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: '/communityhall/user/api/getTransactionDetails', url: '/communityhall/user/api/getTransactionDetails',
data: {'userId': userId},
data: { 'userId': userId },
success: function (data) { success: function (data) {
// console.log("Full response:", data); // console.log("Full response:", data);
// console.log("Refund Details:", data.refundDetails);
// console.log("Refund Details:", data.refundDetails);
const transactions = data.transactions || []; const transactions = data.transactions || [];
@ -2821,7 +3187,7 @@
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
body: JSON.stringify({message}),
body: JSON.stringify({ message }),
}) })
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
@ -2838,11 +3204,28 @@
} }
} }
// OTP input navigation for reschedule modal
$('.otp-input').on('keyup', function (e) {
var $this = $(this);
if ($this.val().length === 1) {
$this.next('.otp-input').focus();
}
if ($this.val().length === 0) {
$this.prev('.otp-input').focus();
}
});
// Clear OTP inputs when OTP modal is shown
$('#rescheduleOtpModal').on('shown.bs.modal', function () {
$('.otp-input').val('');
$('#rescheduleOtpError').text('');
});
</script> </script>
</div>
</div>
</div>
</div>
</div>
</div>
</body> </body>
</html> </html>
Loading…
Cancel
Save