obananapay_admin/users/edit-kyc.php

204 lines
9.2 KiB
PHP
Raw Normal View History

<!DOCTYPE html>
<html>
<head>
<?php include '../header.php'; ?>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
2024-03-07 14:23:47 +08:00
<link rel="stylesheet" href="edit-kyc.css">
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand">Verify KYCs</a>
</div>
</div>
</nav>
<div class="mainContainer">
<div class="section form-container">
<?php
2024-03-07 14:23:47 +08:00
$IDkyc = isset($_GET['kycID']) ? $_GET['kycID'] : '';
include '../functions-test.php';
2024-03-07 14:23:47 +08:00
$response = get_kyc_info($IDkyc);
$array = json_decode($response, true);
// Check if the decoding was successful
if ($array !== null) {
?>
<h2>Selfie</h2>
<div class="image-container">
<?php
// Display selfie image
if (!empty($array['selfie'])) {
echo '<img src="' . $array['selfie'] . '" alt="Selfie Image">';
} else {
echo '<p>No selfie available.</p>';
}
?>
</div>
<h3>User Information</h3>
<div class="form-container">
<fieldset disabled>
<form>
2024-03-07 14:23:47 +08:00
<label for="email">USER ID:</label>
<input class="form-control" type="text" id="email" name="kycID" value="<?php echo $array['userRef']['_id']; ?>" readonly>
<label for="fullName">Full Name:</label>
<input class="form-control" type="text" id="fullName" name="fullName" value="<?php echo $array['userRef']['fName'] . ' ' . $array['userRef']['lName']; ?>" readonly>
<label for="email">Email:</label>
<input class="form-control" type="text" id="email" name="email" value="<?php echo $array['userRef']['email']; ?>" readonly>
<label for="additionalStatus">Status:</label>
<input class="form-control" type="text" id="additionalStatus" name="additionalStatus" value="<?php echo $array['status']; ?>" readonly>
</fieldset>
</form>
</div>
<?php
} else {
echo 'Failed to decode JSON response.';
}
?>
</div>
<div class="section form-container">
<h2>Images</h2>
<div class="image-container">
<?php
if (!empty($array['images'])) {
foreach ($array['images'] as $image) {
echo '<img src="' . $image['link'] . '" alt="KYC Image">';
}
} else {
echo '<p>No images available.</p>';
}
?>
</div>
<h3>KYC Information</h3>
<div class="form-container">
<form>
<fieldset disabled>
2024-03-07 14:23:47 +08:00
<label for="email">KYC ID</label>
<input class="form-control" type="text" id="email" name="kycID" value="<?php echo $array['_id']; ?>" readonly>
<label for="additionalFullName">Full Name:</label>
<input class="form-control" type="text" id="additionalFullName" name="additionalFullName" value="<?php echo $array['full_name']; ?>" readonly>
<label for="idNum">ID Number:</label>
<input class="form-control" type="text" id="idNum" name="idNum" value="<?php echo $array['id_num']; ?>" readonly>
<label for="dob">Date of Birth:</label>
<input class="form-control" type="text" id="dob" name="dob" value="<?php echo $array['date_of_birth']; ?>" readonly>
<label for="address">Address:</label>
<input class="form-control" type="text" id="address" name="address" value="<?php echo $array['address']; ?>" readonly>
</fieldset>
</form>
</div>
</div>
<div class="section form-container">
<h2>Confirm KYC Details</h2>
2024-03-07 16:52:13 +08:00
<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>
2024-03-07 16:52:13 +08:00
<div class="checkbox-container">
<label for="checkbox2" class="checkbox-label">ID Number
<input type="checkbox" id="checkbox2" name="checkbox2">
</label>
</div>
2024-03-07 16:52:13 +08:00
<div class="checkbox-container">
<label for="checkbox3" class="checkbox-label">Date of Birth
<input type="checkbox" id="checkbox3" name="checkbox3">
</label>
</div>
2024-03-07 16:52:13 +08:00
<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>
2024-03-07 16:52:13 +08:00
<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>
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;
}
// 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 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);
}
2024-03-07 16:52:13 +08:00
}
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.");
}
2024-03-07 16:52:13 +08:00
}
</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>
2024-03-07 16:45:33 +08:00
</div>
</div>
</div>
2024-03-07 16:52:13 +08:00
</div>
</body>
</html>