<?php
require_once("../../app/config.php");
$title="Referral Earnings";
require_once('../include/user_header.php');
require_once('../include/user_navbar.php');
require_once('../include/user_sidebar.php');
$trans = mysqli_query($dbc, "SELECT * FROM transfers WHERE status=2 ORDER BY transfers.id DESC");
?>
<div class="content-wrapper">

      <!-- Page header -->
      <div class="page-header page-header-light">
        <div class="page-header-content header-elements-md-inline">
          <div class="page-title d-flex">
            <h4><i class="icon-paperplane mr-2"></i><span class="font-weight-semibold">Referral Earnings</span></h4>
          </div>
        </div>

        <div class="breadcrumb-line breadcrumb-line-light header-elements-md-inline">
          <div class="d-flex">
            <div class="breadcrumb">
              <a href="./dashboard" class="breadcrumb-item"><i class="icon-home2 mr-2"></i> Home</a>
            </div>
          </div>

          <div class="header-elements d-none">
            <div class="breadcrumb justify-content-center">
            </div>
          </div>
        </div>
      </div>
  <div class="content">
    <div class="row">
      <div class="col-md-12">
        <div class="card">
          <div class="card-header header-elements-inline">
            <h6 class="card-title font-weight-semibold">Referral Earnings</h6>
          </div>
          <table class="table datatable-show-all">
            <thead>
              <tr>
                <th>S/N</th>
                <th>Amount</th>                                                                       
                <th>Sender</th>                                                                       
                <th>Receiver</th>                                                                            
                <th>Date</th>        
              </tr>
            </thead>
            <tbody>
<?php while($row1 = mysqli_fetch_array($trans)){
$sender=mysqli_fetch_array(mysqli_query($dbc, "SELECT * FROM users WHERE id='".$row1['sender_id']."'"));
$receiver=mysqli_fetch_array(mysqli_query($dbc, "SELECT * FROM users WHERE id='".$row1['receiver_id']."'"));?>
<tr>
<td><?php echo $index++;?>.</td>
<td><?php echo $scan2['currency'].number_format($row1['amount']);?></td>
<td><?php echo $sender['username'];?></td>
<td><?php echo $receiver['name'];?></td>
<td><?php echo date("Y/m/d h:i:A", strtotime($row1['date']));?></td>
</tr>
<?php }?>                                             
               </tbody>
          </table>
        </div>
      </div>
    </div>
  </div>
</div>
<?php require_once('../include/user_footer.php');?>
      