louie-kyc #1

Merged
erwin merged 27 commits from louie-kyc into main 2024-04-19 10:33:46 +08:00
2 changed files with 85 additions and 101 deletions
Showing only changes of commit 27197918b6 - Show all commits

View File

@ -100,117 +100,105 @@
<div class="section form-container">
<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="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>
<h3>Change the status?</h3>
<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">
<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>
<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>
<script>
var imageContainer = document.getElementById('zoomContainer');
var originalTransform = window.getComputedStyle(imageContainer).getPropertyValue('transform');
<script>
function handleCheckboxChange() {
// 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() {
imageContainer.style.transform = 'scale(1.5)';
});
// Attach the handleCheckboxChange function to each checkbox's onchange event
var checkboxes = document.querySelectorAll('#checkboxForm input[type="checkbox"]');
checkboxes.forEach(function(checkbox) {
checkbox.addEventListener('change', handleCheckboxChange);
});
imageContainer.addEventListener('mouseleave', function() {
imageContainer.style.transform = originalTransform;
});
function openRejectDialog() {
$('#rejectModal').modal('show');
}
function handleCheckboxChange() {
// 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;
function handleKycAction(kycID, userID, isAccepted, reason) {
if (isAccepted) {
// Handle the logic for accept
// 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
var checkboxes = document.querySelectorAll('#checkboxForm input[type="checkbox"]');
checkboxes.forEach(function(checkbox) {
checkbox.addEventListener('change', handleCheckboxChange);
});
function openRejectDialog() {
$('#rejectModal').modal('show');
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.");
}
function handleKycAction(kycID, userID, isAccepted, reason) {
if (isAccepted) {
// Handle the logic for accept
// 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);
}
}
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>
}
</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

@ -11,10 +11,6 @@ if (isset($_GET['kycID'], $_GET['userID'], $_GET['isAccepted'])) {
$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";
if ($isAccepted) {
// If isAccepted is true, call accept_kyc function
if (accept_kyc($kycID, $userID)) {