<!doctype html>
<html lang="en"  class="w-[640px]">
<?php echo view('user/layout/head');?>
   <body class="section-overflow">
      <!--banner start -->
      <section class="banner-bg overall-bg ">
         <div class="container">
         <?php echo view('user/layout/header');?>
         </div>
         <section class="dash-wrap asset-wrap">
            <div class="container">
               <div class="row">
                  <div class="col-12">
                  <?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="income-sec">
                        <div class="total-income d-flex align-items-center">
                           <div class="ref-content text-start">
                              <h5 class="text-white">
                                 Total Income (USDT)
                              </h5>
                           </div>
                           <div class="ref-copy">
                              <a href="javascript:void(0);" class="text-decoration-none">
                                 <iconify-icon icon="fa-regular:eye" id="togglePasswordIcon"></iconify-icon>
                              </a>
                           </div>
                        </div>

                        <?php
                           use App\Libraries\MyEncrypt;
                           use App\Helpers\site_helper;
                           use App\Helpers\form_helper;
                           $this->db = db_connect();
                           $this->session = session();
                           $user=$this->session->get('uusersid');
                           $coinid='1';
                           $buy_bal=curbalance($this->session->get('uusersid'),$coinid);
                           $bal=str_replace(",","", $buy_bal);
                           
                           $user_data=$this->db->query("select * from uusers where uusersid='".$user."'")->getRow();

                           ?>

                        <a href="<?php echo base_url();?>/user/asset_history" class="menu-list d-flex align-items-center  align-items-center justify-content-center text-decoration-none mt-4">
                           <div class="total-income-content d-flex align-items-center ">
                              <div class="usd-ico text-white">
                                 <iconify-icon icon="cryptocurrency:usdt"></iconify-icon>
                              </div>
                             <h5 class="mx-1 mb-0">USDT Assets</h5>
                              <div class="menu-list-arrow ">
                                 <iconify-icon icon="ic:twotone-greater-than"></iconify-icon>
                              </div>
                           </div>
                        </a>
                        <div class="total-income-content-value">
                           <h2 class="text-center text-primary mb-4" id="password" data-balance="<?php echo $bal; ?>" ><?php echo $bal;?></h2>
                        </div>
                     </div>
                     <!---banner end---->
                     <!---statistic start---->
                     <div class="row">
                        <div class="col-12">
                           <ul class=" list-unstyled asset-list mb-0 text-center">
                              <li>
                                 <a href="<?php echo base_url();?>/asset/recharge" class="text-decoration-none">
                                    <div class="asset-icon-bg1">
                                       <div class="asset-icon-bg">
                                          <div class="asset-icon">
                                             <iconify-icon icon="icon-park-outline:add"></iconify-icon>
                                          </div>
                                       </div>
                                    </div>
                                    <h6 class="text-white fw-semibold">Recharge </h6>
                                 </a>
                              </li>
                              <?php 
                              if($user_data->user_withdraw=='1')
                              {
                              ?>
                              <li>
                                 <a href="<?php echo base_url();?>/withdrawfund" class="text-decoration-none">
                                    <div class="asset-icon-bg1">
                                       <div class="asset-icon-bg">
                                          <div class="asset-icon">
                                             <iconify-icon icon="gg:arrow-down-r"></iconify-icon>
                                          </div>
                                       </div>
                                    </div>
                                    <h6 class="text-white fw-semibold">Withdraw</h6>
                                 </a>
                              </li>
                              <?php 
                              }
                              
                              ?>
                              <?php 
                              if($user_data->user_transfer=='1')
                              {
                              ?>
                              <li>
                                 <a href="<?php echo base_url();?>/transfer" class="text-decoration-none">
                                    <div class="asset-icon-bg1">
                                       <div class="asset-icon-bg">
                                          <div class="asset-icon">
                                             <iconify-icon icon="icon-park-outline:file-withdrawal-one"></iconify-icon>
                                          </div>
                                       </div>
                                    </div>
                                    <h6 class="text-white fw-semibold">Transfer </h6>
                                 </a>
                              </li>
                              <?php
                              }
                              ?>
                           </ul>
                        </div>
                     </div>
                     <!---statistic end---->
                     <div class="transaction mt-4">
                        <div class="container">
                           <div class="row">
                              <div class=" col-12">
                                 <div class="table-responsive trans asset-trans position-relative mb-5">
                                    <div class="head_trans py-3">
                                       <h4 class="fw-medium text-white aleo text-center mb-0"> Last 5 Transaction </h4>
                                    </div>
                                    <table class="payment-info">
                                       <tbody>
                                       <?php 
                                             if($history)
                                             {
                                             foreach($history as $row)
                                             {
                                             
                                              $date = $row->date;
                                              
                                              if($row->type=='activation')
                                              {
                                                  $symbol="";
                                                  $title ="Activation";
                                                  $amount = "0";
                                              }
                                              else
                                              
                                              {
                                                  $symbol="+";
                                                  $title ="Transaction";
                                                  $amount = $row -> amount;
                                              }
                                             
                                              // print_r($date);
                                              
                                              if($row->type=='fuel' || $row->type=='deducted_gaswallet')
                                              {
                                                  $description_check=str_replace('fuel fee deduction for order no','',$row->description);
                                                  
                                                  $get_order=$this->db->query("select * from api_trade_history where order_id='".trim($description_check)."'")->getRow();
                                                  if($get_order)
                                                  {
                                                      $base=substr($get_order->pair,0,-4);
                                                      $pair=$base.'/USDT';
                                                      $description='Fuel Fee &nbsp;: ['.$pair.'&nbsp;TurnOver &nbsp;:&nbsp;'.$get_order->comm_price.']';
                                                  }
                                                  else
                                                  {
                                                      $description='';
                                                  }
                                              }
                                              else
                                              {
                                                  $description=$row->description;
                                              }
                                             
                                             ?>
                                          <tr>
                                             <td>
                                                <div class="asset-trans-content d-flex align-items-center justify-content-between">
                                                   <div class="asset-trans-left text-start">
                                                      <h6 class="aleo text-white mb-0"><?php echo $title;?></h6>
                                                      <small class="text-primary fs-6 py-2 fw-bold lato"><?php echo $date;?></small>
                                                      <h6 class="fw-medium fs-6 mb-0">Remark</h6>
                                                   </div>
                                                   <div class="asset-trans-right text-end">
                                                      <small class="text-primary lato fw-bold "><?php echo $symbol;?> <?php echo number_format($amount,4);?></small>
                                                      <h6 class="text-white fs-6 mt-4"><?php echo $description;?></h6>
                                                   </div>
                                                </div>
                                             </td>
                                          </tr>
                                          <?php } } else {?>
                                          <tr>
                                             <td><img src="<?php echo base_url() ;?>/assets/images/norecord1.svg" alt="No records found"></td>
                                          </tr>
                                          <?php } ?>
                                       </tbody>
                                    </table>
                                 </div>
                              </div>
                           </div>
                        </div>
                     </div>
                  </div>
               </div>
            </div>
         </section>
         <!--footer start -->
         <?php echo view('user/layout/footer');?>
         <!--footer end -->
      </section>
  
      <?php echo view('user/layout/footer-script');?>
      <script>
         AOS.init({
         });
      </script>
      <script>
         const passwordField = document.getElementById("password");
         const togglePasswordIcon = document.getElementById("togglePasswordIcon");

         // Get the original balance from the data attribute
         const originalBalance = passwordField.getAttribute("data-balance");

         togglePasswordIcon.addEventListener("click", function () {
            if (passwordField.textContent === "•".repeat(originalBalance.length)) {
               // Show the original balance
               passwordField.textContent = originalBalance;
               togglePasswordIcon.setAttribute("icon", "mdi:eye-outline"); // Open eye icon
            } else {
               // Hide the balance with dots
               passwordField.textContent = "•".repeat(originalBalance.length);
               togglePasswordIcon.setAttribute("icon", "stash:eye-closed-solid"); // Closed eye icon
            }
         });

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