<?php
// session_start();
require("../includes/db_connect.php");
require_once("includes/admin_session_token.php");

if (isset($_GET['accountId'])) {
  $accountId = $_GET['accountId'];

  $sql = "SELECT * FROM kyc_documents WHERE accountId=? LIMIT 1";
  $sth = $conn->prepare($sql, [PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY]);
  $sth->execute([$accountId]);
  $kyc_documents = $sth->fetchAll();

  if (count($kyc_documents) > 0) {
    foreach ($kyc_documents as $key => $value) {

      $accountId = $value['accountId'];
      $full_legal_name = $value['full_legal_name'];
      $ssn = $value['ssn'];
      $nationality = $value['nationality'];
      $date_of_birth = $value['date_of_birth'];
      $address = $value['address'];
      $mobile_number = $value['mobile_number'];
      $email_address = $value['email_address'];
      $status  = $value['status'];
      $front_document  = $value['front_document'];
      $back_document  = $value['back_document'];
      $date = $value['date'];

      $dtf = new DateTime($date);
      $dis_date = $dtf->format('d/m/Y');

      if ($status != 1) {

        $_SESSION['approve_accountId'] = $accountId;

    }else {
        header('Location: identity-verification');
        exit();
    }
}
}else {
    header('Location: identity-verification');
    exit();
}

}else {
  header('Location: identity-verification');
  exit();
}

?>

<!DOCTYPE html>
<html lang="en">

<head>
    <title>Review Identity</title>

    <?php require("includes/header.php"); ?>

    <!-- [ Main Content ] start -->
    <div class="content ht-100v pd-0">
        <div class="content-header">
        </div><!-- content-header -->

        <div class="content-body">
            <div class="container pd-x-0">
                <div class="d-sm-flex align-items-center justify-content-between mg-b-20 mg-lg-b-25 mg-xl-b-30">
                    <div>
                        <nav aria-label="breadcrumb">
                            <ol class="breadcrumb breadcrumb-style1 mg-b-10">
                                <li class="breadcrumb-item"><a href="#">Users review idenntity</a></li>
                            </ol>
                        </nav>
                    </div>

                </div>

                <div class="row row-xs">
                    <div class="col-sm-12">
                        <div class="card">
                            <div class="card-body">

                                <div class="row col-xl-12">
                                    <div class="col-md-10 row">
                                        <div class="col-md-6" style="margin-top: 20px; margin-bottom: 30px;">
                                            <label>Full Legal Name</label>
                                            <input type="text" id="dateFrom" class="form-control" disabled="true" value="<?php echo($full_legal_name) ?>">
                                        </div>
                                        <div class="col-md-6" style="margin-top: 20px; margin-bottom: 30px;">
                                            <label>Nationality</label>
                                            <input type="text" id="dateTo" class="form-control" disabled="true" value="<?php echo($nationality) ?>">
                                        </div>
                                         <div class="col-md-6" style="margin-top: 20px; margin-bottom: 30px;">
                                            <label>SSN</label>
                                            <input type="text" id="dateTo" class="form-control" disabled="true" value="<?php echo($ssn) ?>">
                                        </div>
                                         <div class="col-md-6" style="margin-top: 20px; margin-bottom: 30px;">
                                            
                                        </div>

                                        <div class="col-md-6" style="margin-top: 20px; margin-bottom: 30px;">
                                            <label>Date of Birth</label>
                                            <input type="text" id="dateTo" class="form-control" disabled="true" value="<?php echo($date_of_birth) ?>">
                                        </div>

                                        <div class="col-md-6" style="margin-top: 20px; margin-bottom: 30px;">
                                            <label>Address</label>
                                            <input type="text" id="dateTo" class="form-control" disabled="true" value="<?php echo($address) ?>">
                                        </div>

                                        <div class="col-md-6" style="margin-top: 20px; margin-bottom: 30px;">
                                            <label>Mobile Number</label>
                                            <input type="text" id="dateTo" class="form-control" disabled="true" value="<?php echo($mobile_number) ?>">
                                        </div>

                                        <div class="col-md-6" style="margin-top: 20px; margin-bottom: 30px;">
                                            <label>Email Address</label>
                                            <input type="text" id="dateTo" class="form-control" disabled="true" value="<?php echo($email_address) ?>">
                                        </div>

                                        <div class="col-md-6" style="margin-top: 20px; margin-bottom: 30px;">
                                            <label>Front of ID </label>
                                            <p><a href="../<?php echo($front_document) ?>" target="_blank"><img style="width: 200px; height: 200px" src="../<?php echo($front_document) ?>"></a></p>
                                        </div>

                                        <div class="col-md-6" style="margin-top: 20px; margin-bottom: 30px;">
                                            <label>Back of ID </label>
                                            <p><a href="../<?php echo($back_document) ?>" target="_blank"><img style="width: 200px; height: 200px" src="../<?php echo($back_document) ?>"></a></p>
                                        </div>

                                        <div class="col-md-6" style="margin-top: 20px; margin-bottom: 30px;">
                                            <label>Date Submitted</label>
                                            <input type="text" class="form-control" placeholder="" disabled="true" value="<?php echo($dis_date) ?>">
                                        </div>

                                        <div class="col-md-12" style="margin-top: 20px; margin-bottom: 30px;">
                                            <button id="approve_identity" class="btn btn-xs btn-primary flex-fill" style="font-size: .8125rem; font-weight: 600;">Approve
                                                <span style="display: none;" class="button_spinner spinner-border spinner-border-sm" role="status" aria-hidden="false"></span>
                                                <span class="sr-only">Please wait...</span>
                                            </button>
                                        </div>
                                    </div>

                                </div>
                            </div>

                        </div>
                    </div>
                </div><!-- row -->
            </div><!-- container -->
        </div>
    </div>

<?php require("includes/footer.php"); ?>
<script src="../js/admin/review-identity.js"></script>

</body>

</html>