2024-03-08 13:46:41 +08:00
|
|
|
<?php
|
|
|
|
session_start();
|
|
|
|
if (!isset($_SESSION['token'])) {
|
|
|
|
header("Location: /login/");
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
$user_id = $_SESSION['user_id'];
|
|
|
|
$BearerToken = $_SESSION['token'];
|
|
|
|
?>
|
2024-03-06 10:18:57 +08:00
|
|
|
<!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">
|
2024-03-08 10:34:02 +08:00
|
|
|
|
|
|
|
|
2024-03-06 10:18:57 +08:00
|
|
|
</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-08 11:09:13 +08:00
|
|
|
//gets the pass parameter kycID and assigned to local variable $IDkyc
|
2024-03-07 14:23:47 +08:00
|
|
|
$IDkyc = isset($_GET['kycID']) ? $_GET['kycID'] : '';
|
2024-03-06 10:18:57 +08:00
|
|
|
include '../functions-test.php';
|
2024-03-08 11:09:13 +08:00
|
|
|
//calls the get_kyc_info function insdie the functions-test.php that retrieves all the kyc data
|
2024-03-08 13:46:41 +08:00
|
|
|
$response = get_kyc_info($IDkyc, $BearerToken);
|
2024-03-06 10:18:57 +08:00
|
|
|
$array = json_decode($response, true);
|
|
|
|
|
2024-03-08 17:56:01 +08:00
|
|
|
$CurrentUserAddress = '' . $array['userRef']['address1'] . ', ' . $array['userRef']['city'] . ', ' . $array['userRef']['province'] . ', ' . $array['userRef']['country'] . ' ' . $array['userRef']['zip'];
|
|
|
|
|
2024-03-06 10:18:57 +08:00
|
|
|
// Check if the decoding was successful
|
|
|
|
if ($array !== null) {
|
|
|
|
?>
|
|
|
|
<h2>Selfie</h2>
|
|
|
|
<div class="image-container">
|
|
|
|
<?php
|
|
|
|
// Display selfie image
|
|
|
|
if (!empty($array['selfie'])) {
|
2024-03-08 10:34:02 +08:00
|
|
|
echo '<img src="' . $array['selfie'] . '" alt="Selfie Image" id="kycImg" class="selfieImg" onclick="trigger(\'kycImg\', \'Selfie Image\');">';
|
2024-03-06 10:18:57 +08:00
|
|
|
} else {
|
|
|
|
echo '<p>No selfie available.</p>';
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</div>
|
2024-03-08 11:24:54 +08:00
|
|
|
<div id="myModal" class="imgModal">
|
2024-03-08 11:48:17 +08:00
|
|
|
<span class="closeImg" onclick="closeModal()">×</span>
|
2024-03-08 11:24:54 +08:00
|
|
|
<img class="imgModal-content" id="img01" style="max-width: 100%; max-height: 80vh; width: auto; height: auto; margin: auto; display: block;">
|
2024-03-08 10:34:02 +08:00
|
|
|
|
|
|
|
</div>
|
2024-03-08 11:09:13 +08:00
|
|
|
<!-- Displays all the information retrieved by get_kyc_info() related to userInfo -->
|
2024-03-06 10:18:57 +08:00
|
|
|
<h3>User Information</h3>
|
|
|
|
<div class="form-container">
|
|
|
|
<fieldset disabled>
|
|
|
|
<form>
|
|
|
|
<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>
|
|
|
|
|
2024-03-08 17:56:01 +08:00
|
|
|
<label for="address">Address:</label>
|
|
|
|
<input class="form-control" type="text" id="address" name="address" value="<?php echo $CurrentUserAddress; ?>" readonly>
|
|
|
|
|
|
|
|
|
|
|
|
<label for="additionalStatus">KYC Status:</label>
|
2024-03-06 10:18:57 +08:00
|
|
|
<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>
|
2024-03-08 11:09:13 +08:00
|
|
|
<!-- Displays all the information related to kycInfo -->
|
2024-03-06 10:18:57 +08:00
|
|
|
<div class="section form-container">
|
|
|
|
<h2>Images</h2>
|
|
|
|
<div class="image-container">
|
|
|
|
<?php
|
|
|
|
if (!empty($array['images'])) {
|
|
|
|
foreach ($array['images'] as $image) {
|
2024-03-08 10:34:02 +08:00
|
|
|
|
2024-03-08 11:09:13 +08:00
|
|
|
$img = $image['link'];
|
|
|
|
echo '<img src="' . $img . '" alt="KYC Image" id="' . $img . '" class="kycImg" onclick="trigger(\'' . $img . '\', \'KYC Image\');">';
|
2024-03-06 10:18:57 +08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
echo '<p>No images available.</p>';
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</div>
|
2024-03-08 11:24:54 +08:00
|
|
|
<div id="myModal" class="imgModal">
|
2024-03-08 11:48:17 +08:00
|
|
|
<span class="closeImg">×</span>
|
2024-03-08 11:24:54 +08:00
|
|
|
<img class="imgModal-content" id="img01">
|
2024-03-08 10:34:02 +08:00
|
|
|
</div>
|
2024-03-06 10:18:57 +08:00
|
|
|
<h3>KYC Information</h3>
|
|
|
|
<div class="form-container">
|
|
|
|
<form>
|
|
|
|
<fieldset disabled>
|
|
|
|
<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>
|
|
|
|
|
2024-03-08 17:56:01 +08:00
|
|
|
<label for="address">ID Address:</label>
|
|
|
|
<input class="form-control" type="text" id="kyc_address" name="KycAddress" value="<?php echo $array['address']; ?>" readonly>
|
2024-03-06 10:18:57 +08:00
|
|
|
</fieldset>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-03-08 11:09:13 +08:00
|
|
|
<!-- Display section for confirmation or validation of information via checkbox -->
|
2024-03-06 10:18:57 +08:00
|
|
|
<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:49:15 +08:00
|
|
|
|
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:49:15 +08:00
|
|
|
|
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:49:15 +08:00
|
|
|
|
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:49:15 +08:00
|
|
|
|
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>
|
2024-03-08 11:09:13 +08:00
|
|
|
<!-- Scripts for modal boxes and image hovering -->
|
2024-03-08 10:34:02 +08:00
|
|
|
<script type="text/javascript">
|
2024-03-07 16:52:13 +08:00
|
|
|
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:49:15 +08:00
|
|
|
}
|
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:49:15 +08:00
|
|
|
}
|
2024-03-08 11:09:13 +08:00
|
|
|
};
|
2024-03-08 10:34:02 +08:00
|
|
|
|
2024-03-08 11:09:13 +08:00
|
|
|
var modal = document.getElementById("myModal");
|
2024-03-08 10:54:54 +08:00
|
|
|
|
2024-03-08 11:09:13 +08:00
|
|
|
function trigger(var1, caption) {
|
|
|
|
var modalImg = document.getElementById("img01");
|
2024-03-08 10:34:02 +08:00
|
|
|
|
2024-03-08 11:09:13 +08:00
|
|
|
modal.style.display = "block";
|
|
|
|
modalImg.src = document.getElementById(var1).src;
|
|
|
|
captionText.innerHTML = caption;
|
|
|
|
}
|
2024-03-08 10:34:02 +08:00
|
|
|
|
2024-03-08 17:21:36 +08:00
|
|
|
// Close the modal when clicking outside the image or x button
|
2024-03-08 11:09:13 +08:00
|
|
|
window.onclick = function(event) {
|
2024-03-08 17:21:36 +08:00
|
|
|
if (event.target == modal || event.target.classList.contains('closeImg')) {
|
2024-03-08 11:09:13 +08:00
|
|
|
modal.style.display = "none";
|
|
|
|
}
|
2024-03-08 10:54:54 +08:00
|
|
|
}
|
2024-03-07 16:52:13 +08:00
|
|
|
</script>
|
2024-03-08 11:09:13 +08:00
|
|
|
<!-- Creating a modal dialog box using Bootstrap framework in HTML. -->
|
2024-03-07 16:52:13 +08:00
|
|
|
<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">×</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>
|
2024-03-06 10:18:57 +08:00
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|