minor changes in buttons

This commit is contained in:
jouls 2024-03-07 16:52:13 +08:00
parent 4c2a502756
commit 27197918b6
2 changed files with 85 additions and 101 deletions

View File

@ -100,117 +100,105 @@
<div class="section form-container"> <div class="section form-container">
<h2>Confirm KYC Details</h2> <h2>Confirm KYC Details</h2>
<div class="checkboxFormContainer">
<form id="checkboxForm">
<div class="checkbox-container">
<label for="checkbox1" class="checkbox-label">Full Name
<input type="checkbox" id="checkbox1" name="checkbox1">
</label>
</div>
<div class="checkbox-container">
<label for="checkbox2" class="checkbox-label">ID Number
<input type="checkbox" id="checkbox2" name="checkbox2">
</label>
</div>
<div class="checkbox-container">
<label for="checkbox3" class="checkbox-label">Date of Birth
<input type="checkbox" id="checkbox3" name="checkbox3">
</label>
</div>
<div class="checkbox-container">
<label for="checkbox4" class="checkbox-label">Address
<input type="checkbox" id="checkbox4" name="checkbox4">
</label>
</div>
</div>
<div class="form-container"> <div class="form-container">
<div class="checkboxFormContainer"> <h3>Change the status?</h3>
<form id="checkboxForm">
<div class="checkbox-container">
<label for="checkbox1" class="checkbox-label">Full Name
<input type="checkbox" id="checkbox1" name="checkbox1">
</label>
</div>
<div class="checkbox-container"> <button type="button" class="btn btn-danger" id="rejectButton" onclick="openRejectDialog();">Reject</button>
<label for="checkbox2" class="checkbox-label">ID Number <button type="button" class="btn btn-success" id="acceptButton" onclick="handleKycAction('<?php echo $IDkyc; ?>', '<?php echo $array['userRef']['_id']; ?>', true);" disabled>Accept</button>
<input type="checkbox" id="checkbox2" name="checkbox2">
</label>
</div>
<div class="checkbox-container">
<label for="checkbox3" class="checkbox-label">Date of Birth
<input type="checkbox" id="checkbox3" name="checkbox3">
</label>
</div>
<div class="checkbox-container">
<label for="checkbox4" class="checkbox-label">Address
<input type="checkbox" id="checkbox4" name="checkbox4">
</label>
</div>
</div>
<div class="form-container">
<h3>Change the status?</h3>
<button type="button" class="btn btn-danger" id="rejectButton" onclick="openRejectDialog();">Reject</button>
<button type="button" class="btn btn-success" id="acceptButton" onclick="handleKycAction('<?php echo $IDkyc; ?>', '<?php echo $array['userRef']['_id']; ?>', true);" disabled>Accept</button>
</div>
</form>
</div> </div>
</form>
</div> </div>
</div>
<script> <script>
var imageContainer = document.getElementById('zoomContainer'); function handleCheckboxChange() {
var originalTransform = window.getComputedStyle(imageContainer).getPropertyValue('transform'); // Check the status of checkboxes and enable/disable the "Accept" button
var areAllChecked = document.querySelectorAll('#checkboxForm input[type="checkbox"]:checked').length === 4;
document.getElementById('acceptButton').disabled = !areAllChecked;
}
imageContainer.addEventListener('mouseenter', function() { // Attach the handleCheckboxChange function to each checkbox's onchange event
imageContainer.style.transform = 'scale(1.5)'; var checkboxes = document.querySelectorAll('#checkboxForm input[type="checkbox"]');
}); checkboxes.forEach(function(checkbox) {
checkbox.addEventListener('change', handleCheckboxChange);
});
imageContainer.addEventListener('mouseleave', function() { function openRejectDialog() {
imageContainer.style.transform = originalTransform; $('#rejectModal').modal('show');
}); }
function handleCheckboxChange() { function handleKycAction(kycID, userID, isAccepted, reason) {
// Check the status of checkboxes and enable/disable the "Accept" button if (isAccepted) {
var areAllChecked = document.querySelectorAll('#checkboxForm input[type="checkbox"]:checked').length === 4; // Handle the logic for accept
document.getElementById('acceptButton').disabled = !areAllChecked; // You may call acceptFunction or perform other actions
window.location.href = 'update-kyc.php?kycID=' + kycID + '&userID=' + userID + '&isAccepted=true';
} else {
// Handle the logic for reject
// Redirect to update-kyc.php with the additional parameter
window.location.href = 'update-kyc.php?kycID=' + kycID + '&userID=' + userID + '&isAccepted=false&reason=' + encodeURIComponent(reason);
} }
}
// Attach the handleCheckboxChange function to each checkbox's onchange event function handleRejectWithReason() {
var checkboxes = document.querySelectorAll('#checkboxForm input[type="checkbox"]'); var reason = document.getElementById('rejectReason').value;
checkboxes.forEach(function(checkbox) { if (reason.trim() !== "") {
checkbox.addEventListener('change', handleCheckboxChange); // User entered a non-empty reason
}); var kycID = '<?php echo $IDkyc; ?>';
var userID = '<?php echo $array['userRef']['_id']; ?>';
function openRejectDialog() { handleKycAction(kycID, userID, false, reason);
$('#rejectModal').modal('show'); $('#rejectModal').modal('hide');
} else {
// User entered an empty reason
alert("Please provide a valid reason for rejection.");
} }
}
function handleKycAction(kycID, userID, isAccepted, reason) { </script>
if (isAccepted) { <div class="modal fade" id="rejectModal" tabindex="-1" role="dialog" aria-labelledby="rejectModalLabel" aria-hidden="true">
// Handle the logic for accept <div class="modal-dialog" role="document">
// You may call acceptFunction or perform other actions <div class="modal-content">
window.location.href = 'update-kyc.php?kycID=' + kycID + '&userID=' + userID + '&isAccepted=true'; <div class="modal-header">
} else { <h5 class="modal-title" id="rejectModalLabel">Confirm Rejection? State your reason</h5>
// Handle the logic for reject <button type="button" class="close" data-dismiss="modal" aria-label="Close">
// Redirect to update-kyc.php with the additional parameter <span aria-hidden="true">&times;</span>
window.location.href = 'update-kyc.php?kycID=' + kycID + '&userID=' + userID + '&isAccepted=false&reason=' + encodeURIComponent(reason); </button>
} </div>
} <div class="modal-body">
<label for="rejectReason">Enter your reasons here:</label>
function handleRejectWithReason() { <textarea class="form-control" id="rejectReason" placeholder="E.g. ID is expired.." required></textarea>
var reason = document.getElementById('rejectReason').value; </div>
if (reason.trim() !== "") { <div class="modal-footer">
// User entered a non-empty reason <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
var kycID = '<?php echo $IDkyc; ?>'; <button type="button" class="btn btn-danger" onclick="handleRejectWithReason();">Confirm</button>
var userID = '<?php echo $array['userRef']['_id']; ?>';
handleKycAction(kycID, userID, false, reason);
$('#rejectModal').modal('hide');
} else {
// User entered an empty reason
alert("Please provide a valid reason for rejection.");
}
}
</script>
<div class="modal fade" id="rejectModal" tabindex="-1" role="dialog" aria-labelledby="rejectModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="rejectModalLabel">Confirm Rejection? State your reason</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<label for="rejectReason">Enter your reasons here:</label>
<textarea class="form-control" id="rejectReason" placeholder="E.g. ID is expired.." required></textarea>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger" onclick="handleRejectWithReason();">Confirm</button>
</div>
</div> </div>
</div> </div>
</div> </div>
</div>
</body> </body>
</html> </html>

View File

@ -11,10 +11,6 @@ if (isset($_GET['kycID'], $_GET['userID'], $_GET['isAccepted'])) {
$isAccepted = ($_GET['isAccepted'] === 'true'); $isAccepted = ($_GET['isAccepted'] === 'true');
$reason = $_GET['reason']; $reason = $_GET['reason'];
// Now you can use the $reason variable as needed in your code
// echo "KYC ID: $kycID, User ID: $userID, Is Accepted: $isAccepted, Reason: $reason";
if ($isAccepted) { if ($isAccepted) {
// If isAccepted is true, call accept_kyc function // If isAccepted is true, call accept_kyc function
if (accept_kyc($kycID, $userID)) { if (accept_kyc($kycID, $userID)) {