<!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>Rewards</title>
      <?php echo view('user/layout/head');?>
      <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/2.0.8/css/dataTables.dataTables.min.css">
   </head>
   <style>
      .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;
      }
      .head {
      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%);
      color: #fff;
      border: 1px;
      }
      .dt-paging 
      {
      text-align:center ;
      margin-top:15px;
      }
      div.dt-container .dt-paging .dt-paging-button.disabled, div.dt-container .dt-paging .dt-paging-button.disabled:hover, div.dt-container .dt-paging .dt-paging-button.disabled:active {
      color: #fff !important;
      }
      div.dt-container .dt-paging .dt-paging-button {
      color: #fff !important;
      padding:0px 10px 0px 10px !important;
      }
      .dt-paging-button
      {
      font-size:20px !important;
      color:#fff !important;
      padding:0px 10px 0px 10px !important;
      }
      .dt-paging .current
      {
      border : 1px solid #e49a00 !important;
      /* border-radius : 20px !important; */
      background : #e49a00 !important;
      }
      .dt-empty
      {
      text-align:center !important;
      }
   </style>
   <body class="reg-overflow">
      <section class="dash-banner-bg banner-bg">
         <div class="container">
         <!---header start---->
         <?php echo view('user/layout/header');?>
         <!---header end---->
         <!---banner start---->
         <div class="row">
            <div class="col-lg-12">
               <?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');
                  helper('form_helper');
                  
                  
                  $id = 'NyYmemh5aXA=';
                          
                  $myencrypt = new MyEncrypt;
                  $coinid = $myencrypt->decode($id);
                  $uusersid=$this->session->get('uusersid');
                  $buy_bal=curbalance($this->session->get('uusersid'),$coinid);
                  $bal=str_replace(",","", $buy_bal);
                  
                  ?>
               <div class="dash-wrap">
                  <div class="title text-center py-1">
                     <h2 class="text-primary ">Rewards</h2>
                  </div>
                  <center>
                     <div class="col-lg-10 mt-5 mb-5">
                        <div class="income-sec">
                           <div class="total-income d-flex align-items-center">
                              <div class="ref-content text-start">
                                 <h5 class="text-white">
                                    USDT Asset Balance : <span ><?php echo number_format($bal,2); ?></span>&nbsp;<span id="deduct"><?php echo strtoupper('USDT');?></span>
                                 </h5>
                              </div>
                           </div>
                        </div>
                     </div>
                  </center>
                  <?php 
                        $arr = explode("?", $_SERVER['REQUEST_URI']);
                        if(!empty($arr[1]))
                        {
                            $val=$arr[1];
                        }
                        else
                        {
                            $val='';
                        }
                  ?>
                  <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 <?php if($val=="") { ?> active <?php }?>" 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>History Record</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>Reward Details</span>
                                 </div>
                              </div>
                           </button>
                        </li>

                        <li class="nav-item" role="presentation">
                           <button class="nav-link <?php if($val=="gas") { ?> active <?php }?>" id="pills-dep7-tab " data-bs-toggle="pill" data-bs-target="#pills-dep7"
                              type="button" role="tab" aria-controls="pills-dep7" aria-selected="true">
                              <div class="make-list">
                                 <div class="process">
                                    <span>Gas wallet</span>
                                 </div>
                              </div>
                           </button>
                        </li>
                     </ul>
                     <div class="tab-content" id="pills-tabContent">
                        <div class="tab-pane fade <?php if($val=="") { ?> show active <?php } ?>  " id="pills-dep2" role="tabpanel" aria-labelledby="pills-dep2-tab">
                           <div class="search-bar my-2">
                              <form class="form-inline my-2 my-lg-0">
                                 <input class="form-control mr-sm-2" id="myInput" type="search" placeholder="Search datas...." aria-label="Search">
                              </form>
                           </div>
                           <div class="table-responsive trans position-relative">
                              <table class="trans_info" id="example1">
                                 <thead class="head">
                                    <tr class="text-center">
                                       <th  class="th">Type</th>
                                       <th class="th">Amount</th>
                                       <th class="th">Date</th>
                                       <th class="th">Description</th>
                                    </tr>
                                 </thead>
                                 <tbody id="myTable">
                                    <?php 
                                       if(!empty($transaction_history)) { 
                                       foreach ($transaction_history as $key => $value) {
                                       
                                         if($value->type !='pool_interest' && $value->type !='balance_share_commision' && $value->amount > 0)
                                         { 
                                       
                                         ?>
                                    <tr style="text-align:center">
                                       <td><?php echo ucfirst(str_replace('_', " ", $value->type)); ?></td>
                                       <td><?php echo number_format($value->amount,2); ?> USDT</td>
                                       <td><?php if($value->date){ echo date('Y-m-d',strtotime($value->date)); }else{ echo '---';}?></td>
                                       <td><?php if($value->description){ echo $value->description; }else{  echo '---'; }?></td>
                                      
                                    </tr>
                                    <?php  } }
                                       }
                                       
                                       ?>
                                 </tbody>
                              </table>
                           </div>
                        </div>

                        <div class="tab-pane <?php if($val=="gas") { ?> active <?php }?>" id="pills-dep7" role="tabpanel" aria-labelledby="pills-dep7-tab">
                           <div class="search-bar my-2">
                              <form class="form-inline my-2 my-lg-0">
                                 <input class="form-control mr-sm-2" id="myInput" type="search" placeholder="Search datas...." aria-label="Search">
                              </form>
                           </div>
                           <div class="table-responsive trans position-relative">
                              <table class="trans_info" id="example2" style="width:100%;">
                                 <thead class="head">
                                    <tr class="text-center">
                                       <th  class="th">Type</th>
                                       <th class="th">Amount</th>
                                       <th class="th">Date</th>
                                       <th class="th">Description</th>
                                       <th class="th">Order No</th>
                                    </tr>
                                 </thead>
                                 <tbody id="myTable">
                                    <?php 
                                       if(!empty($transaction_history)) { 
                                       foreach ($transaction_history as $key => $value) {
                                          
                                          
                                         if($value->type =='transfer_gaswallet' || $value->type =='deducted_gaswallet' && $value->amount > 0)
                                         { 
                                              if($value->type=='transfer_gaswallet')
                                              {
                                                  $description=$value->description;
                                                  $orderno='';
                                              }
                                              else
                                              {
                                                   $description_check=str_replace('fuel fee deduction for order no','',$value->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.']';
                                                      $orderno=$get_order->order_id;
                                                  }
                                                  else
                                                  {
                                                      $description='';
                                                      $orderno='';
                                                  }
                                              }
                                       
                                         ?>
                                       <tr style="text-align:center">
                                          <td><?php echo ucfirst(str_replace('_', " ", $value->type)); ?></td>
                                          <td><?php echo number_format($value->amount,2); ?> USDT</td>
                                          <td><?php if($value->date){ echo date('Y-m-d',strtotime($value->date)); }else{ echo '---';}?></td>
                                          <td><?php if($description){ echo $description; }else{  echo '---'; }?></td>
                                          <td><?php if($orderno){ echo $orderno; }else{  echo '---'; }?></td>
                                       
                                       </tr>
                                    <?php  
                                             
                                         } 
                                           
                                       }
                                       }
                                       
                                       ?>
                                 </tbody>
                              </table>
                           </div>
                        </div>
                        <div class="tab-pane fade  " id="pills-dep3" role="tabpanel" aria-labelledby="pills-dep3-tab">
                           <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-dep4-tab " data-bs-toggle="pill" data-bs-target="#pills-dep4"
                                       type="button" role="tab" aria-controls="pills-dep2" aria-selected="true">
                                       <div class="make-list">
                                          <div class="process">
                                             <span>Activation Reward</span>
                                          </div>
                                       </div>
                                    </button>
                                 </li>
                                 <li class="nav-item" role="presentation">
                                    <button class="nav-link" id="pills-dep5-tab " data-bs-toggle="pill" data-bs-target="#pills-dep5"
                                       type="button" role="tab" aria-controls="pills-dep3" aria-selected="true">
                                       <div class="make-list">
                                          <div class="process">
                                             <span>Team Reward</span>
                                          </div>
                                       </div>
                                    </button>
                                 </li>
                                 <li class="nav-item" role="presentation">
                                    <button class="nav-link" id="pills-dep6-tab " data-bs-toggle="pill" data-bs-target="#pills-dep6"
                                       type="button" role="tab" aria-controls="pills-dep6" aria-selected="true">
                                       <div class="make-list">
                                          <div class="process">
                                             <span>Fuel Deduction</span>
                                          </div>
                                       </div>
                                    </button>
                                 </li>
                                 
                              </ul>
                              <div class="tab-content" id="pills-tabContent">
                                 <div class="tab-pane fade show active " id="pills-dep4" role="tabpanel" aria-labelledby="pills-dep4-tab">
                                    <div class="team-profit-content">
                                       <div class="row">
                                          <div class="col-lg-6  col-sm-6 py-2">
                                             <div class="team-list">
                                                <p class="fw-light text-white-50 mb-0">Today's total Profit(USDT)
                                                </p>
                                                <h5 class="fw-bold text-white">
                                                <?php echo  number_format($today_activation_reward->profit,2) ? number_format($today_activation_reward->profit,2) : 0.00; ?> USDT</h4>
                                             </div>
                                          </div>
                                          <div class="col-lg-6  col-sm-6 py-2"  >
                                             <div class="team-list">
                                                <p class="fw-light text-white-50 mb-0">Cumulative profit(USDT)</p>
                                                <h5 class="fw-bold text-white">
                                                <?php echo  number_format($total_activation_reward->profit,2) ? number_format($total_activation_reward->profit,2) : 0.00; ?> USDT</h4>
                                             </div>
                                          </div>
                                       </div>
                                    </div>
                                    <div class="search-bar my-2">
                                       <form class="form-inline my-2 my-lg-0">
                                          <input class="form-control mr-sm-2" id="myInput1" type="search" placeholder="Search ...." aria-label="Search">
                                       </form>
                                    </div>
                                    <div class="table-responsive trans position-relative">
                                       <table class="trans_info" id="example2"  style = "width:100%">
                                          <thead class="head">
                                             <tr class="text-center">
                                                <th  class="th">Sno</th>
                                                <th class="th">Amount</th>
                                                <th class="th">Description</th>
                                                <th class="th">Date</th>
                                             </tr>
                                          </thead>
                                          <tbody id="myTable1">
                                             <?php 
                                             
                                                if ($activation_reward) {
                                                $i=0;
                                                foreach ($activation_reward as $key => $value) {
                                                    
                                                    
                                                
                                                $i++;
                                                ?>
                                             <tr style="text-align:center">
                                                <td><?php echo $i;?></td>
                                                <td><?php echo number_format($value->amount,2) ?></td>
                                                <td><?php echo ucfirst($value->description); ?></td>
                                             
                                                <td><?php echo date('Y-m-d',strtotime($value->date)); ?></td>
                                             </tr>
                                             <?php
                                                }
                                                 
                                                  }
                                                  ?>
                                          </tbody>
                                       </table>
                                    </div>
                                 </div>
                                 <div class="tab-pane fade  " id="pills-dep5" role="tabpanel" aria-labelledby="pills-dep5-tab">
                                    <div class="team-profit-content">
                                       <div class="row">
                                          <div class="col-lg-6  col-sm-6 py-2">
                                             <div class="team-list">
                                                <p class="fw-light text-white-50 mb-0">Today's total Profit(USDT)
                                                </p>
                                                <h5 class="fw-bold text-white">
                                                <?php echo  number_format($today_team_reward->profit,2) ? number_format($today_team_reward->profit,2) : 0.00; ?> USDT</h4>
                                             </div>
                                          </div>
                                          <div class="col-lg-6  col-sm-6 py-2"  >
                                             <div class="team-list">
                                                <p class="fw-light text-white-50 mb-0">Cumulative profit(USDT)</p>
                                                <h5 class="fw-bold text-white">
                                                <?php echo  number_format($total_team_reward->profit,2) ? number_format($total_team_reward->profit,2) : 0.00; ?> USDT</h4>
                                             </div>
                                          </div>
                                       </div>
                                    </div>
                                    <div class="search-bar my-2">
                                       <form class="form-inline my-2 my-lg-0">
                                          <input class="form-control mr-sm-2" id="myInput2" type="search" placeholder="Search ...." aria-label="Search">
                                       </form>
                                    </div>
                                    <div class="table-responsive trans position-relative">
                                       <table class="trans_info" id="example3"  style = "width:100%">
                                          <thead class="head">
                                             <tr class="text-center">
                                                <th  class="th">Sno</th>
                                                <th class="th">Amount</th>
                                                <th class="th">Description</th>
                                               <th class="th">Date</th>
                                             </tr>
                                          </thead>
                                          <tbody id="myTable2">
                                             <?php 
                                                $i=0;
                                                if(!empty($team_reward)) { 
                                                
                                                foreach ($team_reward as $key => $value) {
                                                if($value->uusersid == $uusersid) { 
                                                  $i++;
                                                ?>
                                             <tr style="text-align:center">
                                                <td><?php echo $i;?></td>
                                                <td><?php echo number_format($value->amount,2) ?></td>
                                                <td><?php echo ucfirst($value->description); ?></td>
                                                
                                                <td><?php echo date('Y-m-d',strtotime($value->date)); ?></td>
                                             </tr>
                                             <?php } }
                                                }
                                                
                                                ?>
                                          </tbody>
                                       </table>
                                    </div>
                                 </div>
                                 <div class="tab-pane fade  " id="pills-dep6" role="tabpanel" aria-labelledby="pills-dep6-tab">
                                    <div class="search-bar my-2">
                                       <form class="form-inline my-2 my-lg-0">
                                          <input class="form-control mr-sm-2" id="myInput3" type="search" placeholder="Search ...." aria-label="Search">
                                       </form>
                                    </div>
                                    <div class="table-responsive trans position-relative">
                                       <table class="trans_info" id="example4"  style = "width:100%">
                                          <thead class="head">
                                             <tr class="text-center">
                                                <th  class="th">Sno</th>
                                                <th class="th">Amount</th>
                                                <th class="th">Description</th>
                                                <th class="th">From User</th>
                                                <th class="th">Date</th>
                                             </tr>
                                          </thead>
                                          <tbody id="myTable3">
                                             <?php
                                                $i=0; 
                                                if(!empty($fuel_deduction)) { 
                                                foreach ($fuel_deduction as $key => $value) {
                                                if($value->uusersid == $uusersid) { 
                                                   
                                                  $pair = $this->db->query("Select * from trade_process where id='".$value->transactionid."'")->getRow();
                                                  if($pair)
                                                  {
                                                   $pair=$pair->pair;
                                                  }
                                                  $i++;
                                                ?>
                                             <tr style="text-align:center">
                                                <td><?php echo $i;?></td>
                                                <td><?php echo number_format($value->amount,8) ?></td>
                                                <td><?php echo ucfirst($value->description); ?></td>
                                                <td><?php echo strtoupper($pair); ?></td>
                                                <td><?php echo date('Y-m-d',strtotime($value->date)); ?></td>
                                             </tr>
                                             <?php } } 
                                                }
                                                
                                                ?>
                                          </tbody>
                                       </table>
                                    </div>
                                 </div>
                              </div>
                           </div>
                           <!-- 2nd tab content end -->
                        </div>
                     </div>
                     <!-- 1st tab content end -->
                  </div>
               </div>
            </div>
            <?php echo view('user/layout/footer');?>
         </div>
      </section>
      <?php echo view('user/layout/footer-script');?>
      <script src="https://cdn.datatables.net/2.0.8/js/dataTables.min.js"></script>
      <!-- <script src="http://demo.myslworld.com/ARM008/styles/web_style/js/jquery.dataTables.min.js"></script> -->
      <script>
         $(document).ready(function(){
         $("#myInput").on("keyup", function() {
         var value = $(this).val().toLowerCase();
         $("#myTable tr").filter(function() {
         $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
         });
         });
         
         $("#myInput1").on("keyup", function() {
         var value = $(this).val().toLowerCase();
         $("#myTable1 tr").filter(function() {
         $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
         });
         });
         
         $("#myInput2").on("keyup", function() {
         var value = $(this).val().toLowerCase();
         $("#myTable2 tr").filter(function() {
         $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
         });
         });
         
         $("#myInput3").on("keyup", function() {
         var value = $(this).val().toLowerCase();
         $("#myTable3 tr").filter(function() {
         $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
         });
         });
         
         $('#example1').DataTable({
         pagingType: 'full_numbers',
         searching: false,
         info:false,
         lengthChange: false,
         pageLength : 10,
         
         
         
         });
         
         $('#example2').DataTable({
         pagingType: 'full_numbers',
         searching: false,
         info:false,
         lengthChange: false,
         pageLength : 10
         
         
         });
         
         $('#example3').DataTable({
         pagingType: 'full_numbers',
         searching: false,
         info:false,
         lengthChange: false,
         pageLength : 20
         
         
         });
         
         $('#example4').DataTable({
         pagingType: 'full_numbers',
         searching: false,
         info:false,
         lengthChange: false,
         pageLength : 20
         
         
         });
         
         });
      </script>
   </body>
</html>