Added dialog box

This commit is contained in:
jouls 2024-03-07 16:45:33 +08:00
parent c15cfc8b76
commit 0fa2d78ec6
2 changed files with 46 additions and 5 deletions

View File

@ -129,7 +129,7 @@
<div class="form-container">
<h3>Change the status?</h3>
<button type="button" class="btn btn-danger" id="rejectButton" onclick="window.location.href='update-kyc.php?kycID=<?php echo $IDkyc; ?>&userID=<?php echo $array['userRef']['_id']; ?>&isAccepted=false';">Reject</button>
<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>
@ -149,7 +149,11 @@
checkbox.addEventListener('change', handleCheckboxChange);
});
function handleKycAction(kycID, userID, isAccepted) {
function openRejectDialog() {
$('#rejectModal').modal('show');
}
function handleKycAction(kycID, userID, isAccepted, reason) {
if (isAccepted) {
// Handle the logic for accept
// You may call acceptFunction or perform other actions
@ -157,10 +161,44 @@
} 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';
window.location.href = 'update-kyc.php?kycID=' + kycID + '&userID=' + userID + '&isAccepted=false&reason=' + encodeURIComponent(reason);
}
}
function handleRejectWithReason() {
var reason = document.getElementById('rejectReason').value;
if (reason.trim() !== "") {
// User entered a non-empty reason
var kycID = '<?php echo $IDkyc; ?>';
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>
</body>
</html>

View File

@ -9,9 +9,12 @@ if (isset($_GET['kycID'], $_GET['userID'], $_GET['isAccepted'])) {
$kycID = $_GET['kycID'];
$userID = $_GET['userID'];
$isAccepted = ($_GET['isAccepted'] === 'true');
$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";
echo "KYC ID: $kycID, User ID: $userID, Is Accepted: $isAccepted";
//Call the appropriate function based on isAccepted value
if ($isAccepted) {
// If isAccepted is true, call accept_kyc function
if (accept_kyc($kycID, $userID)) {