<!doctype html>
<html lang="en"  class="w-[640px]">
   <head>
      <?php echo view('user/layout/head');?>
   </head>
   <style>
      .help-block 
      {
      color:red;
      font-size:12px;
      font-weight:bold;
      }
      #getcode {
      box-shadow: 0px 0px 39px 0px rgba(255,227,172,0.27);
      border: none;
      padding: 8px 22px;
      margin-top: -22px;
      margin-left: 4px;
      border-top-right-radius: 10px;
      display: flex;
      align-items: end;
      border-bottom-right-radius: 10px;
      }
      .quantity {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 5px;
      }
      .quantity .minus,
      .quantity .plus {
      width: 40px;
      height: 40px;
      border: none;
      background-color: #007bff;
      color: white;
      font-size: 20px;
      font-weight: bold;
      border-radius: 5px;
      cursor: pointer;
      transition: background-color 0.3s;
      }
      .quantity .minus:hover,
      .quantity .plus:hover {
      background-color: #0056b3;
      }
      .quantity .minus:disabled,
      .quantity .plus:disabled {
      background-color: #cccccc;
      cursor: not-allowed;
      }
      .quantity .input-box {
      /* width: 85%; */
      /* width: 60px;
      height: 40px; */
      text-align: center;
      font-size: 16px;
      border: 1px solid #ccc;
      border-radius: 5px;
      }
      .pagination {
      display: flex;
      justify-content: center;
      margin-top: 20px;
      }
      .pagination-btn {
      background: #007bff;
      color: white;
      border: none;
      padding: 10px 20px;
      border-radius: 5px;
      cursor: pointer;
      margin: 0 5px;
      }
      .pagination-btn:disabled {
      background: #6c757d;
      cursor: not-allowed;
      }
      #pageInfo {
      align-self: center;
      margin: 0 10px;
      color:white !important;
      }
      .spin {
      animation: spin 1s infinite;
      }
      @keyframes spin {
      from { transform: rotate(0deg); }
      to { transform: rotate(360deg); }
      }
   </style>
   <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 team-wrap">
            <div class="container">
               <?php 
                  $this->session = \Config\Services::session();
                  $this->db = db_connect();
                  $uusersid = $this->session->get('uusersid');
                  
                  use App\Libraries\MyEncrypt;
                  use App\Helpers\site_helper;
                  use App\Helpers\form_helper;
                  
                  $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="row">
                  <div class="col-12">
                     <div class="quantify-header d-flex align-items-center text-white justify-content-between">
                        <div class="trade-content ms-2">
                           <h6 class="text-white fw-semibold aleo mb-0 align-items-center">USDT Balance</h6>
                        </div>
                        <div class="repeat-icon d-flex align-items-center">
                           <h5 class="text-white me-2 fw-bold "><span id="balanceVal"><?php echo number_format("0.00",2); ?></span><span id="deduct"><?php echo strtoupper('USDT');?></span>
                              <span id="ip-exist" style="display:none;color:#d84315;" class="error_msg"><?php echo "Insufficient Amount";?></span>  
                           </h5>
                           <a href="javascript:void(0)">
                              <iconify-icon icon="mage:reload-reverse" class="fs-3" id="balance_load"></iconify-icon>
                           </a>
                        </div>
                     </div>
                  </div>
               </div>
               <div class="col-lg-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 
                     } 
                     ?>
                  <?php 
                     $id = 'NyYmemh5aXA=';
                     
                     $myencrypt = new MyEncrypt;
                     $coinid = $myencrypt->decode($id);
                     $user=$this->session->get('uusersid');
                     $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 == "with_fee")
                     $coin_dets = $value->site_value;
                     if($value->site_key == "with_min_amt")
                     $trans_min_amt = $value->site_value;
                     if($value->site_key == "with_max_amt")
                     $trans_max_amt = $value->site_value; 
                     if($value->site_key == "with_instant")
                     $trans_instant = $value->site_value; 
                     }
                     
                     ?> 
                  <div class="team-tab mt-4">
                     <ul class="nav nav-pills 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-dep1-tab " data-bs-toggle="pill" data-bs-target="#pills-dep1"
                              type="button" role="tab" aria-controls="pills-dep1" aria-selected="true">
                              <div class="make-list">
                                 <div class="process">
                                    <span>Withdrawal</span>
                                 </div>
                              </div>
                           </button>
                        </li>
                        <li class="nav-item" role="presentation">
                           <button class="nav-link" 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>Withdraw History</span>
                                 </div>
                              </div>
                           </button>
                        </li>
                     </ul>
                     <div class="tab-content" id="pills-tabContent">
                        <div class="tab-pane fade show active" id="pills-dep1" role="tabpanel" aria-labelledby="pills-dep1-tab">
                           <form class="steps-validation withdraw" method="post"  id="pin" action="<?php echo $action;?>">
                              <div class="offset-sm-1 col-sm-10">
                                 <div class="team-profit-content" style="text-align:start !important">
                                    <div class="row" >
                                       <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">
                                             <div class="quantity">
                                                <button class="minus btn btn-secondary" aria-label="Decrease">&minus;</button>
                                                <input 
                                                   name="amount" 
                                                   class="form-control input-box" 
                                                   type="text" 
                                                   id="amount" 
                                                   placeholder="Withdraw Amount" 
                                                   value="" 
                                                   />
                                                <button class="plus btn btn-secondary" aria-label="Increase">&plus;</button>
                                             </div>
                                             <small id="amount_error" style="color:red"></small>
                                             <?php echo $this->form_validation->getError('amount', '<span class="help-block">', '</span>'); ?>
                                          </div>
                                       </div>
                                       <div class="col-sm-12">
                                          <div id="otpmsg" ></div>
                                       </div>
                                       <!--<div class="col-sm-12   <?php if($this->form_validation->getError('code1')) echo "has-error";?>" >
                                          <div class="form-block form-group mb-3 user-box position-relative" >
                                             <input name="code1" class="form-control" type="text" id="code1" placeholder="Enter Code" value="" />
                                             <button type="button" id="getcode" name="getcode">GETCODE</button>
                                          </div>
                                          
                                          </div>-->
                                       <div class="col-sm-12">
                                          <div class="form-block form-group  position-relative" >
                                             <div class="input-group">
                                                <input type="text" class="form-control" name="code1" id="code1"  maxLength="6"  placeholder="Verfication Code">
                                                <div class="input-group-btn"> &nbsp;
                                                   <button type="button" name="getcode" id="getcode"   class="btn btn-primary">SEND</button>
                                                </div>
                                             </div>
                                             <?php echo $this->form_validation->getError('code1', '<span class="help-block">', '</span>'); ?>
                                          </div>
                                       </div>
                                       <div class="col-sm-12 <?php if($this->form_validation->getError('address')) echo "has-error";?>">
                                          <div class="form-block form-group mb-3 user-box">
                                             <textarea class="form-control" name="address" id="address" placeholder="USDT address"></textarea>
                                             <!-- <input name="recv_id" class="form-control"   type="text" id="recv_id"  placeholder="Receiver ID" value="" /> -->
                                             <small id="name-error" style="color:red"></small>
                                             <?php echo $this->form_validation->getError('address', '<span class="help-block">', '</span>'); ?>
                                          </div>
                                       </div>
                                    </div>
                                    <div class="col-sm-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">
                                                <label>Withdraw Fee </label>
                                             </div>
                                             <div class="col-lg-6">
                                                <strong><?php echo number_format($coin_dets,2); ?></strong>&nbsp;<small>Will be deducted</small>
                                             </div>
                                          </div>
                                          <div class="col-sm-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">
                                                      <label>Received Amount </label>
                                                   </div>
                                                   <div class="col-lg-6">
                                                      <strong  id="recv_amt">0</strong>&nbsp;<small>Will be withdrawn</small>
                                                   </div>
                                                </div>
                                             </div>
                                          </div>
                                       </div>
                                       <input type="hidden" id="transfee" name="trans_fee">
                                       <input type="hidden" id="org_amount" name="org_amt">
                                       <div class="form-btn my-4 text-center">
                                          <button type="submit" id="trans" name="trans" class="btn btn-primary mb-5" >Withdraw</button>
                                       </div>
                                    </div>
                                 </div>
                              </div>
                           </form>
                           <hr  class="text-white">
                           <div class="title para" style="margin-top:20px;padding:10px;">
                              <p class="text-white"> <iconify-icon icon="clarity:success-standard-solid" class="me-2"></iconify-icon> Kindly provide a valid USDT wallet address for withdrawal to prevent any potential loss of funds. </p>
                              <p class="text-white"> <iconify-icon icon="clarity:success-standard-solid" class="me-2"></iconify-icon> Withdrawals are processed within +1 days, with a fee deducted from the withdrawn amount. </p>
                              <p class="text-white"> <iconify-icon icon="clarity:success-standard-solid" class="me-2"></iconify-icon>The withdrawal fee is a fixed amount of 2 USDT.</p>
                              <p style="color:orange;"> <iconify-icon icon="clarity:success-standard-solid" class="me-2"></iconify-icon> Important note: Please choose the network carefully and make sure it matches the network of the platform you're withdrawing funds to. If you select the wrong network, your funds might be lost and cannot be recovered.</p>
                           </div>
                          
                           
                        </div>
                        <div class="tab-pane fade " id="pills-dep2" role="tabpanel" aria-labelledby="pills-dep2-tab">
                            
                           <?php
                              if($records)
                              {
                                  ?>
                                  <div class="row justify-content-center mb-3" id="myItems">
                           
                              <div class="col-md-12 col-xl-12">
                                 <?php 
                                    $i=0;
                                       foreach ($records as $records) 
                                       {
                                           $i++;
                                    
                                           ?>
                                 <!-- Taping content st-->
                                 <div id="quantify-section" class="quantify-box py-4">
                                    <div class="qunatify-inner-sec">
                                       <div class="quantify-inner-box d-flex align-items-center justify-content-between">
                                          <div class="quantify-inner-box-left">
                                             <small class="text-white fw-medium ">Withdraw</small>
                                             <h6 class="text-white fw-medium aleo">
                                                Date: <?php echo $records->date; ?>&nbsp;&nbsp;
                                                <span class="mode btn-outline-primary">
                                                <?php 
                                                   if ($records->type == 'withdraw_request') {
                                                         echo 'Pending';
                                                   } elseif ($records->type == 'withdrawal') {
                                                         echo 'Success';
                                                   } else {
                                                         echo 'Unknown';
                                                   }
                                                   
                                                   $get_admin_fee = $this->db->table('history')
                                                   ->where('substatus', $records->id)
                                                   ->get()
                                                   ->getRow();
                                                   ?>
                                                </span>
                                             </h6>
                                          </div>
                                          <div class="quantify-inner-box-right toggle-icon" onclick="toggle('<?php echo $i;?>');">
                                             <i class="fa fa-circle-chevron-down text-white"></i>
                                          </div>
                                       </div>
                                       <div class="row" style="border:none;display:none;" id="nav<?php echo $i;?>">
                                          <div class="col-6">
                                             <ul class="quantify-history quantify-history-left text-start list-unstyled mb-0">
                                                <li>Amount</li>
                                                <li>Admin fee</li>
                                                <li>Total Received</li>
                                                <li>Address</li>
                                             </ul>
                                          </div>
                                          <div class="col-6">
                                             <ul class="quantify-history quantify-history-right text-end list-unstyled mb-0">
                                                <li><?php echo $records->amount+ $get_admin_fee->amount;?></li>
                                                <li><?php echo $get_admin_fee->amount;?></li>
                                                <li><?php echo $records->amount;?></li>
                                                <li><?php echo $records->address;?></li>
                                             </ul>
                                          </div>
                                       </div>
                                    </div>
                                 </div>
                                 <!-- Taping content end-->
                                 <?php 
                                    } 
                                  
                              } 
                              else 
                              {
                                    ?>
                                 <div class="quantify-box py-4">
                                    <div class="qunatify-inner-sec">
                                       <div class="quantify-inner-box d-flex align-items-center justify-content-between">
                                          <div class="quantify-inner-box-left">
                                             <h4 class="text-white fw-medium aleo"> No Transaction Records Found</h4>
                                          </div>
                                       </div>
                                    </div>
                                 </div>
                            <?php 
                            }
                            ?>
                                  <div class="pagination">
                                    <button id="prevPage" class="pagination-btn" onclick="changePage('prev')">« Previous</button>
                                    <span id="pageInfo"></span>
                                    <button id="nextPage" class="pagination-btn" onclick="changePage('next')">Next »</button>
                                 </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 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 type="text/javascript">
         function view_trade(str)
         {
         window.location="<?php echo base_url();?>/tradedetails/"+str;
         }
         
         function toggle(id) {
         // Get the target content and icon
         const content = document.getElementById('nav' + id);
         const icon = document.querySelector(`.toggle-icon[onclick="toggle('${id}');"] i`);
         
         // Get all contents and icons to hide/show them
         /*document.querySelectorAll('.items-owner-box[id^="nav"]').forEach((section) => {
         if (section.id !== 'nav' + id) {
         section.style.display = 'none';
         }
         });
         
         document.querySelectorAll('.toggle-icon i').forEach((iconElement) => {
         iconElement.classList.remove('fa-circle-chevron-up');
         iconElement.classList.add('fa-circle-chevron-down');
         });*/
         
         // Toggle the selected content
         if (content.style.display === 'flex') {
         content.style.display = 'none';
         icon.classList.remove('fa-circle-chevron-up');
         icon.classList.add('fa-circle-chevron-down');
         } else {
         content.style.display = 'flex';
         icon.classList.remove('fa-circle-chevron-down');
         icon.classList.add('fa-circle-chevron-up');
         }
         }
         
         // let currentPage = 1;
         // const itemsPerPage = 10; // Number of items per page
         // let totalPages =1;
       
         // // Load initial data when DOM is ready
         // document.addEventListener('DOMContentLoaded', function () {
       
         // loadPage(currentPage);
         // });
         
         // // Function to load data dynamically
         // function loadPage(page) {
         // const uusersid = '<?php echo $this->session->get('uusersid'); ?>';
      
         
         // $.ajax({
         // method: 'POST',
         // url: '<?php echo base_url("/trade_records"); ?>',
         // data: {
           
         //    uusersid: uusersid,
          
         //    page: page,
         //    itemsPerPage: itemsPerPage,
           
         // },
         // success: function (response) {
         //    const data = JSON.parse(response);
         //    const myItems = document.getElementById('myItems');
         //    myItems.innerHTML = '';
         
         //    if (data.items.length === 0) {
         //        myItems.innerHTML = `
         //             <div class="quantify-box py-4">
                        
         //                    <div class="qunatify-inner-sec">
         //                        <div class="quantify-inner-box d-flex align-items-center justify-content-between">
         //                            <div class="quantify-inner-box-left">
                                    
         //                            <h4 class="text-white fw-medium aleo"> No Transaction Records Found</h4>
         //                            </div>
                                    
         //                        </div>
                                
         //                    </div>
         //                </div>`;
         //    } else {
         //        data.items.forEach(item => { 
                   
         
         //            myItems.innerHTML += `
         //                <div class="quantify-box py-4">
         //                    <div class="row my-items-section">
         //                        <div class="col-6" style="margin-bottom:10px">
         //                            <div class="trade-using-coin d-flex align-items-center">
         //                                <div class="btc-ico">
         //                                    <img style="width:30px;height:29px" src="<?php echo base_url();?>/${item.image}" alt="">
         //                                </div>
         //                                <div class="value-coin">
         //                                    <h4 class="text-white mb-0">${item.pair} </h4>
         //                                </div>
         //                            </div>
         //                        </div>
         //                        <div class="col-6">
         //                            <div class="pause-btn text-end">
         //                                <a href="javascript:void(0);" class="btn-outline-primary">${item.type}</a>
         //                            </div>
         //                        </div>
         //                    </div>
         //                    <div class="qunatify-inner-sec">
         //                        <div class="quantify-inner-box d-flex align-items-center justify-content-between">
         //                            <div class="quantify-inner-box-left">
         //                                <small class="text-white fw-medium">Turnover: ${item.turnover}</small>
         //                                <h6 class="text-white fw-medium aleo">Order Time: ${item.orderTime}&nbsp;&nbsp;<span class="mode btn-outline-primary">${item.order_mode}</span></h6>
         //                            </div>
         //                            <div class="quantify-inner-box-right toggle-icon" onclick="toggle('${item.id}');">
         //                                <i class="fa fa-circle-chevron-down text-white"></i>
         //                            </div>
         //                        </div>
         //                        <div class="row" style="border:none;display:none;" id="nav${item.id}">
         
         //                              ${item.method === '2' ? `
         //                          <div class="row" style="margin:10px">
         //          <div class="col-12">
         //             <div class="quantify-header d-flex align-items-center text-white justify-content-between">
         //                <div class="trade-content ms-2">
         //                   <h6 class="text-white fw-semibold aleo mb-0 align-items-center">
         //                   <span id="total_count"> Profit : ${item.profit} | Fuel : ${item.fuel}  </span> 
         //                </div>
         //                <div class="repeat-icon d-flex align-items-center">
                          
                          
         //                   <a style="color:green;font-size:14px;font-weight:bold;" class="text-decoration-none">
         //                 ${item.percentage}
         //                   </a>
         //                </div>
         //             </div>
         //          </div>
         //       </div>
         //                     ` : ''}
         
               
         
         //                            <div class="col-6">
         //                                <ul class="quantify-history quantify-history-left text-start list-unstyled mb-0">
         //                                    <li>Order No</li>
         //                                    <li>Order Limit</li>
         //                                    <li>Market Execution Price</li>
         //                                    <li>Filled Quantity</li>
         //                                    <li>Filled Amount</li>
         //                                </ul>
         //                            </div>
         //                            <div class="col-6">
         //                                <ul class="quantify-history quantify-history-right text-end list-unstyled mb-0">
         //                                    <li>${item.orderNo}</li>
         //                                    <li>Market Price</li>
         //                                    <li>${item.averagePrice}</li>
         //                                    <li>${item.filledQuantity} ${item.tradingPair}</li>
         //                                    <li>${item.filledAmount} ${item.currency}</li>
         //                                </ul>
         //                            </div>
         //                        </div>
         //                    </div>
         //                </div>`;
         //        });
         //    }
         
         //    totalPages = data.totalPages;
         //    document.getElementById('total_count').innerText = data.totalitems;
         //    document.getElementById('prevPage').disabled = !data.hasPrev;
         //    document.getElementById('nextPage').disabled = !data.hasNext;
         //    document.getElementById('pageInfo').innerText = `Page ${page} of ${data.totalPages}`;
         // },
         // });
         // }
         
         
         
         
         
         // function changePage(direction) {
         // if (direction === 'prev' && currentPage > 1) {
         // currentPage--;
         // } else if (direction === 'next' && currentPage < totalPages) {
         // currentPage++;
         // }
         // loadPage(currentPage);
         // }
         
         $('#confirm').click(function(){
         $("#date_err").html("");
         var start_date=$("#start_date").val();
         var end_date=$("#end_date").val();
         var ordermode=$("#ordermode").val();
         var sta_mode=$("#sta_mode").val();
         
         if(start_date!='' && end_date=='')
         {
         $("#date_err").html("Start and End date Must Required");
         }
         else if(start_date=='' && end_date!='')
         {
         $("#date_err").html("Start and End date Must Required");
         }
         else
         {
         $('#staticBackdrop1').modal('hide');
         let currentPage = 1;
         loadPage(currentPage,start_date,end_date,ordermode,sta_mode);
         }
         
         });
         
         $('#reset').click(function(){
         let currentPage = 1;
         loadPage(currentPage);
         });
         
         
         
         
         
         
         
         
      </script>
      <script>
         (function () {
             const quantityContainer = document.querySelector(".quantity");
             const minusBtn = quantityContainer.querySelector(".minus");
             const plusBtn = quantityContainer.querySelector(".plus");
             const inputBox = quantityContainer.querySelector(".input-box");
         
             // Set dynamic min and max values
             const minValue = <?php echo $trans_min_amt;?>;
             const maxValue = <?php echo $trans_max_amt;?>;
         
             updateButtonStates();
         
             quantityContainer.addEventListener("click", handleButtonClick);
             inputBox.addEventListener("input", handleQuantityChange);
         
             function updateButtonStates() {
                 const value = parseInt(inputBox.value);
                 minusBtn.disabled = value <= minValue;
                 plusBtn.disabled = value >= maxValue;
             }
         
             function handleButtonClick(event) {
                 if (event.target.classList.contains("minus")) {
                     decreaseValue();
                 } else if (event.target.classList.contains("plus")) {
                     increaseValue();
                 }
             }
         
             function decreaseValue() {
                 let value = parseInt(inputBox.value);
                 value = isNaN(value) ? minValue : Math.max(value - 1, minValue);
                 inputBox.value = value;
                 updateButtonStates();
                 handleQuantityChange();
             }
         
             function increaseValue() {
                 let value = parseInt(inputBox.value);
                 value = isNaN(value) ? minValue : Math.min(value + 1, maxValue);
                 inputBox.value = value;
                 updateButtonStates();
                 handleQuantityChange();
             }
         
             function handleQuantityChange() {
                 let value = parseInt(inputBox.value);
                 value = isNaN(value) ? minValue : Math.min(Math.max(value, minValue), maxValue); // Clamp the value within range
                 inputBox.value = value; // Update the input field in case of invalid input
         
                 // Execute your code here based on the updated quantity value
                 console.log("Quantity changed:", value);
             }
         })();
      </script>
      <script>
         jQuery.noConflict();
         (function ($) {
            $(document).ready(function () {
         
               $('#getcode').on("click", function () {
                  $.ajax({
                     type: 'post',
                     url: '<?php echo base_url();?>/withdraw/verifyregcode',
                     data: {
                        'sub': 1
                     },
                     dataType: 'json',
                     success: function (msg) {
                        if (msg !== '') {
                        
                          $("#otpmsg").html('<div class="alert alert-success">' + msg + '</div>');
                           setTimeout(otphide,3000);
                        }
                     }
                  })
         
               });
         
                 function otphide()
                 {
                 $('#otpmsg').html("");
                 }
            
         
         
               $('#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');
                        }
                     }
                  }
               });
         
         
           
         
               $('.withdraw').formValidation({
         
         
                  framework: 'bootstrap',
                  excluded: [':disabled'],
         
                  fields: {
                     amount: {
                        validators: {
                           notEmpty: {
                              message: '<?php echo "Withdraw amount is required";?>'
                           },
                           regexp: {
                              regexp: /^[0-9.]+$/,
                              message: '<?php echo "Withdraw amount is Invalid"; ?>'
                           },
                           remote: {
                              url: function (validator, $field, value) {
                                 return '<?php echo base_url();?>/checkfee/<?php echo $coinid?>';
                              },
                              type: 'POST',
                              delay: 1000,
                            
                           }
                        }
                     },
                     code1: {
                        validators: {
                           notEmpty: {
                              message: 'Please Enter the verification code'
                           },
                           remote: {
                              url: function (validator, $field, value) {
                                 return '<?php echo base_url();?>/withdraw/verifyotp'
                              },
                              type: 'POST',
                              delay: 500,
                              message: '<?php echo "Invalid Code, Try again "; ?>'
                           }
                        }
                     },
                     address: {
                        validators: {
                           notEmpty: {
                              message: '<?php echo "Address is required";?>'
                           }
                        }
                     },
         
                  }
               });
         
         
            });
         })(jQuery);
         document.getElementById('balance_load').addEventListener('click', function() {
                  
                  
                  this.classList.add('spin');
                  read_function();
                  setTimeout(() => {
                  
                  this.classList.remove('spin');
                  }, 1000); // Duration of the animation in milliseconds
                  });
      </script> 
   </body>
</html>
