<!doctype html>
<html lang="en" translate="no" class="w-[640px] mx-auto md:w-full">
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Transfer</title>
      <?php echo view('user/layout/head');?>
   </head>
   <style>
      .para
      {
      text-align:justify;
      color:#fff;
      }
      .password-toggle-icon {
      position: absolute;
      top: 81%;
      right: 100px;
      color:#fff;
      transform: translateY(-50%);
      cursor: pointer;
      }
      .password-toggle-icon i {
      font-size: 18px;
      line-height: 1;
      color: #fff;
      transition: color 0.3s ease-in-out;
      margin-bottom: 20px;
      }
      .password-toggle-icon i:hover {
      color: gold;
      }
      .help-block {
      color: red;
      margin: 0em 0em 0em !important;
      }
      p.frgtpwd1 {
      background:#8DC540 !important
      }
      p.frgtpwd1 i {
      background:#8DC540 !important;
      color:#fff !important
      }
      p.frgtpwd {
      font-size: 13px;
      color: #fff;
      text-align: left;
      line-height: 24px;
      margin: 0 0 1em 0;
      background: #22313F;
      border-radius: 2px;
      padding:10px 39px 10px 10px;
      font-weight: 600;
      position: relative;
      }
      p.frgtpwd i {
      position: absolute;
      top: 0;
      right: 0;
      padding:15px 8px 8px 8px;
      font-size: 14px;
      background: #F5AB35;
      color: #22313F;
      height: 100%;
      }
      p.frgtpwdred {
      background:#EB5055 !important;
      }
      p.frgtpwdred i {
      background:#EB5055 !important
      }
      .alert-success {
      color: #0f5132;
      background-color: #d1e7dd;
      border-color: #badbcc;
      font-size: 12px;
      }
      .span
      {
      font-size: 12px;
      color: #9395a1;
      margin-top: 14px;
      font-weight: 900;
      }
      .nav-item
      {
      border:2px solid  rgba(140,98,10,1) !important;
      }
      .sam .active {
      background: linear-gradient(180deg, rgba(179,137,34,1) 0%, rgba(140,98,10,1) 50%, rgba(179,137,34,1) 100%, rgba(14,72,62,1) 100%) !important;
      border-radius: 0px !important;
      }
   </style>
   <body class="reg-overflow">
      <section class=" dash-banner-bg banner-bg referral profile">
         <div class="container">
         <!---header start---->
         <?php echo view('user/layout/header');?>
         <!---header end---->
         <!---banner start---->

         <div class="row">
               <div class="col-lg-12">
                  <div class="dash-wrap">
                     <div class="title text-center py-1">
                        <h2 class="text-primary ">Transfer</h2>
                     </div>

                     <div class="row">
               <div class="col-lg-12">
                  <div class="income-sec">
                     <div class="total-income d-flex align-items-center">
                        <div class="ref-content text-start">
                           <h5 class="text-white">
                              USDT Balance : <span id="balanceVal"><?php echo number_format("0.00",2); ?></span>&nbsp;<span id="deduct"><?php echo strtoupper('USDT');?></span>
                              <div id="ip-exist" style="display:none;color:#d84315;" class="error_msg"><?php echo "Insufficient Amount";?></div>
                           </h5>
                        </div>
                     </div>
                  </div>
              
               <?php
                     use App\Libraries\MyEncrypt;
                     use App\Helpers\site_helper;
                     use App\Helpers\form_helper;
                     $this->db = db_connect();
                     $this->session = session();
                     $this->common_model = model('CommonModel');
                     $this->form_validation =  \Config\Services::validation();
                     $list = \Config\Services::validation()->listErrors();
                     
                     helper('form_helper');
                     //echo view('user/common_header');
                     $us_data = userMinPass();
                     ?>
                  <div class="col-lg-12">
                     <?php 
                        $session = \Config\Services::session();
                        if($session->getFlashData('success_message')) 
                        {
                        ?>
                     <p class="frgtpwd frgtpwd1 mt-5"><i class="fa fa-thumbs-up"></i><?php echo $session->getFlashData('success_message');?></p>
                     <?php 
                        } 
                        else if($session->getFlashData('error_message')) 
                        { 
                        ?>
                     <p class="frgtpwd frgtpwd1 frgtpwdred mt-5"><i class="fa fa-thumbs-down"></i><?php echo $session->getFlashData('error_message');?></p>
                     <?php 
                        } 
                        ?>
                     <?php 
                        // $this->uri = service('uri');
                        // $this->uri->getSegment('2');
                        
                                $user=$this->session->get('uusersid');
                                $coinid='1';
                                $buy_bal=curbalance($this->session->get('uusersid'),$coinid);
                                $bal=str_replace(",","", $buy_bal);
                        
                                $first_dat=$this->db->query("select * from coin_info where coid='".$coinid."'");  
                                $fir_d=$first_dat->getResult();
                                $coin_det=$fir_d[0];
                        
                                $withdraw_datas = $this->common_model->GetSettingall('withdraw');
                                foreach ($withdraw_datas as $key => $value) {
                                    if($value->site_key == "trans_fee")
                                       $coin_dets = $value->site_value;
                                    if($value->site_key == "trans_min_amt")
                                       $trans_min_amt = $value->site_value;
                                    if($value->site_key == "trans_max_amt")
                                       $trans_max_amt = $value->site_value;   
                        
                                }
                                
                        
                                ?>
                                
                                

                                <div class="team-tab">
                        <ul class="nav sam d-flex justify-content-center ps-0" id="pills-tab" role="tablist">
                           
                           <li class="nav-item" role="presentation">
                              <button class="nav-link active" id="pills-dep2-tab " data-bs-toggle="pill" data-bs-target="#pills-dep2"
                                 type="button" role="tab" aria-controls="pills-dep2" aria-selected="true">
                                 <div class="make-list">
                                    <div class="process">
                                       <span>Transfer to others</span>
                                    </div>
                                 </div>
                              </button>
                           </li>
                           <li class="nav-item" role="presentation">
                              <button class="nav-link" id="pills-dep3-tab " data-bs-toggle="pill" data-bs-target="#pills-dep3"
                                 type="button" role="tab" aria-controls="pills-dep3" aria-selected="true">
                                 <div class="make-list">
                                    <div class="process">
                                       <span>Transfer to gas wallet</span>
                                    </div>
                                 </div>
                              </button>
                           </li>
                        </ul>
                        <div class="tab-content" id="pills-tabContent" style="margin-top:8px;">
                           <div class="tab-pane fade show active  " id="pills-dep2" role="tabpanel" aria-labelledby="pills-dep2-tab">

                              <div class="reg-page mt-5 ">
                                 <form class="steps-validation transfer" method="post"  id="pin" action="<?php echo $action;?>">
                                    <div class="row" style="margin-top:20px ">
                                       <div class="col-sm-12 <?php if($this->form_validation->getError('amount')) echo "has-error";?>">
                                          <div class="form-block form-group mb-3 user-box" >
                                             <input name="amount" class="form-control" type="text" id="amount" placeholder="Transfer Amount" value="" />
                                             <span id="amount_error" style="color:red"></span>
                                             <?php echo $this->form_validation->getError('amount', '<span class="help-block">', '</span>'); ?>
                                          </div>
                                       </div>
                                       <div class="col-sm-12  <?php if($this->form_validation->getError('recv_id')) echo "has-error";?>">
                                          <div class="form-block  mb-3 user-box">
                                             <input name="recv_id" class="form-control"   type="text" id="recv_id"  placeholder="Receiver ID" value="" />
                                             <span id="name-error" style="color:red"></span>
                                             <?php echo $this->form_validation->getError('recv_id', '<span class="help-block">', '</span>'); ?>
                                          </div>
                                       </div>
                                       <!--<div class="col-sm-12  <?php if($this->form_validation->getError('sec_pin')) echo "has-error";?>">
                                          <div class="form-block position-relative login-ico form-group">
                                             <div class="form-ico password-toggle-icon" style="right:0px;"><i class="fa-regular fa-eye-slash"></i></div>
                                             <input name="sec_pin" class="form-control"   type="password" id="sec_pin"  placeholder="Security Pin" value="" />
                                             <span id="pin-error" style="color:red"></span>
                                             <?php echo $this->form_validation->getError('sec_pin', '<span class="help-block">', '</span>'); ?>
                                          </div>
                                       </div>-->

                                       <div class="col-sm-12">
                                             <div class=" form-block position-relative login-ico">
                                             <div class="form-ico password-toggle-icon" style="right:0px;"><i class="fa-regular fa-eye-slash"></i></div>
                                                <input type="password" class="form-control " id="sec_pin" name="sec_pin" aria-describedby="" placeholder="Security Pin">
                                             </div>
                                       </div>
                                    </div>
                                    <div class="col-lg-12 mt-2">
                                       <div class="form-block  form-group mb-3 user-box">
                                          <div class="row text-white text-start">
                                             <div class="col-lg-5">
                                                <p>Transfer Fee </p>
                                             </div>
                                             <div class="col-lg-6">
                                                <strong><?php echo number_format($coin_dets,2); ?></strong>&nbsp;<span>Will be deducted</span>
                                             </div>
                                          </div>
                                          <div class="col-lg-12 mt-2">
                                             <div class="form-block  form-group mb-3 user-box">
                                                <div class="row text-white text-start">
                                                   <div class="col-lg-5">
                                                      <p>Received Amount </p>
                                                   </div>
                                                   <div class="col-lg-6">
                                                      <strong  id="recv_amt">0</strong>&nbsp;<span>Will be transfer</span>
                                                   </div>
                                                </div>
                                             </div>
                                          </div>
                                       </div>
                                       <br>
                                    
                                       <input type="hidden" id="transfee" name="trans_fee">
                                       <input type="hidden" id="org_amount" name="org_amt">
                                       <div align="center">
                                          <button type="submit" id="trans" name="trans" class="btn btn-primary mb-5" >Transfer</button>
                                       </div>
                                    </div>
                                 </form>
                              </div>
                             
                           </div>


                           <div class="tab-pane fade" id="pills-dep3" role="tabpanel" aria-labelledby="pills-dep3-tab">
                              <div class="reg-page mt-5">
                                 <form action="<?php echo base_url();?>/user/validategastransfer" id="transfer1" method="post">
                                    <div class="row" style="margin-top:20px ">
                                          <div class="col-sm-12 <?php if($this->form_validation->getError('amount')) echo "has-error";?>">
                                             <div class="form-block form-group mb-3 user-box" >
                                                <input name="amount" class="form-control" type="text" id="amount" placeholder="Gas Amount" value="" />
                                                <span id="amount_error" style="color:red"></span>
                                                <?php echo $this->form_validation->getError('amount', '<span class="help-block">', '</span>'); ?>
                                             </div>
                                          </div>
                                    </div>
                                    <div align="center">
                                 <button type="submit" id="trans1" name="trans1" class="btn btn-primary mb-5" >Transfer</button>
                              </div>
                                 </form>
                              </div>
                           </div>
                     </div>

                                
         
                  
                  
                  
                  
               </div>
            </div>
         </div>
      </section>
      <?php echo view('user/layout/footer');?>
      <?php echo view('user/layout/footer-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 type="text/javascript">
         jQuery.noConflict();
         (function( $ ) {
             $(document).ready(function() {
             
          $('#amount').change(function(){
           var amount = $('#amount').val();
           var with_fee = <?php echo $coin_dets;?>;
           var trans_min_amt = <?php echo $trans_min_amt;?>;
           var trans_max_amt = <?php echo $trans_max_amt;?>;
           if(amount >= trans_min_amt && amount <= trans_max_amt) {
           $('#amount_error').css('display','none');
           $('#amount_error').html();
           $('#trans').removeClass('disabled');
           var remain = +amount - +with_fee;
           $('#recv_amt').html(remain);
           $('#transfee').val(with_fee);
           $('#org_amount').val(remain);
           }else {
                  $('#amount_error').css('display','inline');
                  $('#amount_error').html('Amount is not less than '+trans_min_amt+' and not more than '+trans_max_amt);
                  $('#btn').addClass('disabled');
           }
         });
         
         
         $.ajax({
           type: 'post',
           url : '<?php echo base_url();?>/checkbalance/<?php echo $coinid?>',
           success : function(msg)
           {
         
             if(msg) {
               $('#balanceVal').html(msg);
         
               if(msg=='<?php echo number_format('0',$currency_info->deimal_point, '.', ''); ?>' || msg < '0') {
         
                 $('#ip-exist').css('display','block');
                 $('#balanceVal').css('color','#d84315');
                 $('#deduct').css('color','#d84315');
                 $('.error_msg').parent().parent().addClass('has-error');
                 $('#trans').addClass('disabled');
         
               } else {
         
                 $('#ip-exist').css('display','none');
                 $('#balanceVal').css('color','#fff');
                 $('#deduct').css('color','#fff');
                 $('.error_msg').parent().parent().removeClass('has-error');
               }
             }
           }
         });
         
         
            $('#recv_id').change(function(){
                var name = $('#recv_id').val();
               
         
            $.ajax({
           type: 'post',
           url : '<?php echo base_url();?>/withdraw/name_verify',
           data : {"rec_name":name},
           success : function(msg)
           {
             
             if(msg == 1){
                   $('#name-error').css('display','none');
                   $('#name-error').html();
                   $('#trans').removeClass('disabled');
             }else if(msg == 2){
                  $('#name-error').html('Invalid Username');
                  $('#name-error').css('display','inline');
                  $('#trans').addClass('disabled');
             }else{
                  $('#name-error').css('display','inline');
                  $('#name-error').html('Inactive account');
                  $('#trans').addClass('disabled');
             }
           }
         });
         
          });
         
         
          $('.transfer').formValidation({
         
           
             framework: 'bootstrap',
             excluded: [':disabled'],
           
             fields: {
                     amount: {
                     validators: {
                         notEmpty: {
                             message: '<?php echo "Transfer amount is required";?>'
                         },
                         regexp: {
                   regexp: /^[0-9.]+$/,
                   message: '<?php echo "Transfer amount is Invalid"; ?>'
                 },
                 remote: {
                   url: function(validator, $field, value) {
                     return '<?php echo base_url();?>/checkfee/<?php echo $coinid?>';
                   },
                   type: 'POST',
                   delay: 1000,
                   
                 }
                     }
                 },
                 recv_id: {
                     validators: {
                         notEmpty: {
                             message: '<?php echo "Receiver Id is required";?>'
                         }
                     }
                 },
                 sec_pin: {
                     validators: {
                         notEmpty: {
                             message:  '<?php echo "Security pin is required";?>' 
                         },
                         remote: {
                                    url: function(validator, $field, value) {
                                        
                                        return '<?php echo base_url();?>/withdraw/validsecuritypin';
                                    },
                                    type: 'POST',
                                    delay: 1000,
                                    message: '<?php echo "Security pin invalid"; ?>'
                                }
                        
                     }
                 }
                 
             }
            });

            $('#transfer1').formValidation({
         
           
         framework: 'bootstrap',
         excluded: [':disabled'],
       
         fields: {
                 amount: {
                 validators: {
                     notEmpty: {
                         message: '<?php echo "Gas amount is required";?>'
                     },
                     regexp: {
               regexp: /^[0-9.]+$/,
               message: '<?php echo "Gas amount is Invalid"; ?>'
             },
             remote: {
               url: function(validator, $field, value) {
                 return '<?php echo base_url();?>/checkfee/<?php echo $coinid?>';
               },
               type: 'POST',
               delay: 1000,
               
             }
                 }
             },
            
             
         }
        });
         
         
         
         
         
          });

          
         })(jQuery);
      </script>
      <script>
         const passwordField = document.getElementById("sec_pin");
         const togglePassword = document.querySelector(".password-toggle-icon i");
         
         togglePassword.addEventListener("click", function () {
         
         if (passwordField.type === "password") {
         passwordField.type = "text";
         
         togglePassword.classList.remove("fa-eye-slash");
         togglePassword.classList.add("fa-eye");
         } else {
         passwordField.type = "password";
         togglePassword.classList.remove("fa-eye");
         togglePassword.classList.add("fa-eye-slash");
         
         }
         });
      </script>
      <script></script>
   </body>
</html>