<?php
   use App\Libraries\MyEncrypt;
   use App\Models\CommonModel;
   $session = session();
   $validation =  \Config\Services::validation();
   $this->db = db_connect();
   
   $CommonModel = model('CommonModel');
   $header_data = $CommonModel->GetSiteSettings('site');
   if(!$header_data){
   	$header_data = $CommonModel->defaultlangSettingall('site');
   }
   foreach ($header_data as $row) 
   {
   	$headers[$row->site_key] = $row->site_value;
   }
   ?>

<!doctype html>
<html lang="en"  class="w-[640px]">
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <title><?php echo $headers['site_meta_title'];?></title>
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <meta name="keywords" content="<?php echo $headers['site_meta_key'];?>" />
      <meta name="description" content="<?php echo $headers['site_meta_description'];?>" />
      <!--Basic Bootstrap-->
      <link href="<?php echo base_url();?>/assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
      <!--Font icons-->
      <link href="<?php echo base_url();?>/assets/css/all.css"  rel="stylesheet" type="text/css">
      <!--Carousel Slider-->
      <link href="<?php echo base_url();?>/assets/css/owl.carousel.min.css" rel="stylesheet" type="text/css">
      <link href="<?php echo base_url();?>/assets/css/owl.theme.default.min.css" rel="stylesheet" type="text/css">
      <!--fonts-->
      <link href="https://fonts.googleapis.com/css2?family=Mulish:ital,wght@0,200..1000;1,200..1000&display=swap" rel="stylesheet">
      <link href="https://fonts.googleapis.com/css2?family=Aleo:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
      <link href="https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap" rel="stylesheet">
      <!--animate CSS -->
      <link rel="stylesheet" href="<?php echo base_url();?>/assets/css/aos.css">
      <link rel="stylesheet" href="<?php echo base_url();?>/assets/css/animate.css">
      <!--Theme CSS -->
      <link rel="stylesheet" type="text/css" href="<?php echo base_url();?>/assets/css/style.css">
   </head>
   <style>
      .help-block {
    	color:red;
    	font-size:12px;
    	font-weight:bold;
    }
   </style>
   <body class="section-overflow">
      <section class="banner-bg bg-grade1 position-relative">
        <ul class="added-banner-images list-unstyled mb-0">
            <li><img src="<?php echo base_url();?>/assets/images/banner-number.png" alt=""></li>
            <li><img src="<?php echo base_url();?>/assets/images/banner-trade.png" alt=""></li>
            <li><img src="<?php echo base_url();?>/assets/images/banner-curve.png" alt=""></li>
            <li><img src="<?php echo base_url();?>/assets/images/banner-statistics.png" alt=""></li>
        </ul>
         <!-- common-header start-->
         <div class="container">
            <header class="pt-3 pb-3 position-relative">
               <!--<div class="row">
                  <div class="col-6">
                     <div class="back-arrow">
                        <a href="<?php echo base_url();?>/login">
                           <iconify-icon icon="bi:arrow-left-circle-fill"></iconify-icon>
                        </a>
                     </div>
                  </div>
                  <div class="col-6">
                     <div class="common-icon d-flex align-items-center justify-content-end">
                        <div class="wallet-icon header-icon me-2">
                           <a href="<?php echo base_url();?>/user/asset" class="text-decoration-none ">
                              <iconify-icon icon="ph:wallet-bold"></iconify-icon>
                           </a>
                        </div>
                        <div class="header-icon">
                           <a href="<?php echo base_url();?>/news" class="text-decoration-none">
                              <iconify-icon icon="mdi:notifications-none"></iconify-icon>
                           </a>
                        </div>
                     </div>
                  </div>
               </div>-->
            </header>
            <!-- common-header end-->
         </div>
         <!-- wrapper-content start -->
         <section class="dash-wrap login-wrap">
            <div class="row">
               <div class="col-12">
                  <div class="container">
                     <div class="banner position-relative  pt-3">
                        <div class="added-number">
                           <h5 class="fw-bold text-white"></h5>
                        </div>
                        <div class="row">
                           <div class="col-6">
                              <div class="banner-content">
                                 <h2 class="fw-bold text-white">Hello,</h2>
                                 <h5 class="text-white"> Welcome</h5>
                                 <h1 class="text-primary aleo">Trade Pilot</h1>
                              </div>
                           </div>
                           <div class="col-6">
                              <div class="banner-img">
                                 <img src="<?php echo base_url();?>/assets/images/banner-img.png" alt="">
                              </div>
                           </div>
                        </div>
                     </div>
                     <div class="row">
                        <div class="col-12">
                           <div class="form-page position-relative">
                              <div class="form-title text-center ">
                                 <h1 class="text-white aleo  ">Sign In</h1>
                              </div>
                              <form class="steps-validation create-user" method="post" action="<?php echo base_url();?>/user/login">
                              
                              <?php 
                              $session = \Config\Services::session();
                              if($session->getFlashData('success_message')) 
                              {
                              ?>
                                <div class="success-msg input-msg">
                                    <img src="<?php echo base_url();?>/assets/images/success.png">
                                    <p class="text-white fw-medium ms-2 mb-0"><?php echo $session->getFlashData('success_message');?></p>
                                </div>
                      
                           <?php 
                              } 
                              else if($session->getFlashData('error_message')) 
                              { 
                              ?>

                                <div class="error-msg input-msg">
                                    <img src="<?php echo base_url();?>/assets/images/error.png">
                                    <p class="text-white fw-medium ms-2 mb-0"><?php echo $session->getFlashData('error_message');?></p>
                                </div>         
                           <?php 
                              } 
                              ?>

                              <div class="col-12">
                                 <div class="form-block form-group position-relative">
                                    <span> Username</span>
                                    <input type="text" class="form-control" placeholder=" Username" name="username" id="username">
                                 </div>
                              </div>
                              <div class="col-12">
                                 <div class="form-block form-group position-relative">
                                    <div class="form-ico">
                                       <iconify-icon icon="stash:eye-closed-solid" id="togglePasswordIcon"></iconify-icon>
                                    </div>
                                    <span> Password</span>
                                    <input type="password" class="form-control " id="password" name="password" aria-describedby="" placeholder="Enter Password">
                                 </div>
                              </div>
                              <div class="col-12">
                                 <div class="d-flex align-items-center justify-content-between">
                                    <div class="checkbox before-login mb-4 position-relative mt-2  text-start">
                                       <label class="text-black fs-6 fw-bold">
                                       <input type="checkbox" value="remember-me">
                                       <a href="" class="">Remember Me
                                       </a> </label>
                                    </div>
                                    <div class="checkbox before-login mb-4 position-relative mt-2  text-start">
                                       <label class="text-black fs-6 fw-bold">
                                       <a href="<?php echo base_url();?>/reset" class="">Forget password?
                                       </a> </label>
                                    </div>
                                 </div>
                                 <div class="form-btn my-4 text-center">
                                 <button class="btn btn-primary" type="submit">
                                 Login Your Account
                                 </button>
                                   
                                </div>
                              </div>
                              </form>
                           </div>
                        </div>
                     </div>
                     <div class="row ">
                        <div class="col-12">
                           <div class="checkbox no-account mt-4 text-center">
                              <label class="text-black fw-bold fs-6">
                             <a href="<?php echo base_url();?>/register" class="text-decoration-none inner-foot-link">Regsiter an account</a> </label>
                           </div>
                        </div>
                     </div>
                  </div>
               </div>
            </div>
         </section>
         <div class="container">
            <div class="row">
               <div class="col-12">
                  <div class="cpy-rights text-center mt-4 mb-3">
                     <h6 class="fs-6 text-black fw-bold">@ <?php echo date("Y");?> <a href="#">Trade Pilot Auto Trading.</a> All Rights Reserved </h6>
                  </div>
               </div>
            </div>
         </div>
         <!-- wrapper-content end-->
      </section>
      <!-- Modal -->
      <div class="modal fade  modal-fullscreen" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
         <div class="modal-dialog">
            <div class="modal-content">
               <div class="modal-body">
                  <button type="button"    class="btn-close" data-bs-dismiss="modal" aria-label="Close" style="float: right;"></button>
                  <div class="embed-responsive embed-responsive-16by9">
                     <iframe  class="embed-responsive-item" src="https://www.youtube.com/embed/zpOULjyy-n8?rel=0" allowfullscreen></iframe>
                  </div>
               </div>
            </div>
         </div>
      </div>
      <script src="<?php echo base_url();?>/assets/js/jquery.min.js"></script> 
      <script src="<?php echo base_url();?>/assets/js/bootstrap.min.js"></script> 
      <script src="<?php echo base_url();?>/assets/js/script.js"></script> 
      <script src="<?php echo base_url();?>/assets/js/owl.carousel.min.js"></script>
      <script src="<?php echo base_url();?>/assets/js/iconify-icon.min.js"></script>
      <script src="<?php echo base_url();?>/assets/js/aos.js"></script>
      <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
      <script type="text/javascript" src="<?php echo base_url();?>/assets/js/formValidation1.js"></script>
      <script type="text/javascript" src="<?php echo base_url();?>/assets/js/bootstrap.js"></script>
      <script>
         AOS.init({
         });
      </script>
          <script type="text/javascript">

        const passwordField = document.getElementById("password");
        const togglePasswordIcon = document.getElementById("togglePasswordIcon");

        togglePasswordIcon.addEventListener("click", function () {
            if (passwordField.type === "password") {
                // Change to text
                passwordField.type = "text";
                togglePasswordIcon.setAttribute("icon", "mdi:eye-outline"); // Change icon
            } else {
                // Change to password
                passwordField.type = "password";
                togglePasswordIcon.setAttribute("icon", "stash:eye-closed-solid"); // Change icon
            }
        });

         jQuery.noConflict();
         (function( $ ) {
         $(document).on("click", '#getcode', function() {
             var referral=$('#invitor_code').val();
             var email=$('#email').val();
            if(email !="")
            {
         
               $.ajax({
                 type: 'post',
                 url : '<?php echo base_url();?>/user/register/verifyregcode',
                 data : {'email':email,'referral':referral},
                 dataType:'json',
                 success : function(msg)
                 {
                 
                   console.log(msg);
                   
                    if(msg!='exist' && msg!='exist1')
                    {
                       var myVar;
                       setTimeout(function(){
                           $("#otpmsg").html('<div class="help-block">'+msg+'</div>')},500);
                    }
                    else
                    {
                       if(msg=='exist')
                       {
                         var myVar;
                         setTimeout(function(){
                           $("#otpmsg").html('<div class="help-block">Email Already Exist</div>')},500);
         
                       }
                       else
                       {
                            var myVar;
                         setTimeout(function(){
                           $("#otpmsg").html('<div class="help-block">Given invite code not valid</div>')},500);
                       }
                   } 
                 }
             })
           }
           else
           {
             setTimeout(function(){
                           $("#otpmsg").html('<div class="help-block">Please Enter Email id first</div>')},500)
         
           }
           
         
         });
         
         $('.create-user').formValidation({
         framework: 'bootstrap',
         excluded: [':disabled'],
         
         fields: {
            
             username: {
             validators: {
             notEmpty: {
             message: 'Username is required'
             },
             regexp: {
             regexp: /^[a-zA-Z0-9]*$/,
             message: 'Username only accepts alphanumerics'
             }
         
             }
             },
             password: {
             validators: {
             notEmpty: {
             message: 'Password is Required'
             }
             }
           }
             
         }
         })
         
         })(jQuery);
         
         
        
      </script>
   </body>
</html>
